@aztec/txe 0.0.1-commit.2eb6648a → 0.0.1-commit.2f68f620
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/ContractClassRegistry-PII7Q556.js +3 -0
- package/dest/ContractClassRegistry-PII7Q556.js.map +7 -0
- package/dest/ContractInstanceRegistry-3MHLGFNZ.js +3 -0
- package/dest/ContractInstanceRegistry-3MHLGFNZ.js.map +7 -0
- package/dest/FeeJuice-TQV5AQK7.js +3 -0
- package/dest/FeeJuice-TQV5AQK7.js.map +7 -0
- package/dest/MultiCallEntrypoint-SBJUIJY7.js +3 -0
- package/dest/MultiCallEntrypoint-SBJUIJY7.js.map +7 -0
- package/dest/SchnorrAccount-MQXPIZ44.js +3 -0
- package/dest/SchnorrAccount-MQXPIZ44.js.map +7 -0
- package/dest/bin/check_txe_oracle_version.d.ts +2 -0
- package/dest/bin/check_txe_oracle_version.d.ts.map +1 -0
- package/dest/bin/check_txe_oracle_version.js +61 -0
- package/dest/bin/index.js +3 -30
- package/dest/bin/index.js.map +7 -0
- package/dest/bin/oracle_test_server.d.ts +3 -0
- package/dest/bin/oracle_test_server.d.ts.map +1 -0
- package/dest/bin/oracle_test_server.js +41 -0
- package/dest/chunk-BJVAAXNA.js +3 -0
- package/dest/chunk-BJVAAXNA.js.map +7 -0
- package/dest/chunk-CDITIZHX.js +257 -0
- package/dest/chunk-CDITIZHX.js.map +7 -0
- package/dest/chunk-W2NSX64C.js +304 -0
- package/dest/chunk-W2NSX64C.js.map +7 -0
- package/dest/constants.d.ts +5 -1
- package/dest/constants.d.ts.map +1 -1
- package/dest/constants.js +8 -0
- package/dest/dispatcher_pool.d.ts +67 -0
- package/dest/dispatcher_pool.d.ts.map +1 -0
- package/dest/dispatcher_pool.js +284 -0
- package/dest/index.d.ts +185 -7
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +71 -157
- package/dest/metafile.json +36545 -0
- package/dest/msgpackr_fr_extension.d.ts +2 -0
- package/dest/msgpackr_fr_extension.d.ts.map +1 -0
- package/dest/msgpackr_fr_extension.js +21 -0
- package/dest/oracle/interfaces.d.ts +56 -30
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/test-resolver/fixtures.d.ts +43 -0
- package/dest/oracle/test-resolver/fixtures.d.ts.map +1 -0
- package/dest/oracle/test-resolver/fixtures.js +39 -0
- package/dest/oracle/test-resolver/index.d.ts +9 -0
- package/dest/oracle/test-resolver/index.d.ts.map +1 -0
- package/dest/oracle/test-resolver/index.js +33 -0
- package/dest/oracle/test-resolver/resolver.d.ts +34 -0
- package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
- package/dest/oracle/test-resolver/resolver.js +114 -0
- package/dest/oracle/txe_oracle_public_context.d.ts +38 -14
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +55 -13
- package/dest/oracle/txe_oracle_registry.d.ts +147 -0
- package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_registry.js +562 -0
- package/dest/oracle/txe_oracle_top_level_context.d.ts +45 -26
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +244 -88
- package/dest/oracle/txe_oracle_version.d.ts +17 -0
- package/dest/oracle/txe_oracle_version.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_version.js +14 -0
- package/dest/oracle/txe_private_execution_oracle.d.ts +17 -0
- package/dest/oracle/txe_private_execution_oracle.d.ts.map +1 -0
- package/dest/oracle/txe_private_execution_oracle.js +15 -0
- package/dest/rpc_server.d.ts +14 -0
- package/dest/rpc_server.d.ts.map +1 -0
- package/dest/rpc_server.js +78 -0
- package/dest/rpc_translator.d.ts +96 -228
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +815 -624
- package/dest/server.bundle.js +3 -0
- package/dest/server.bundle.js.map +7 -0
- package/dest/state_machine/archiver.d.ts +6 -5
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +30 -21
- package/dest/state_machine/dummy_p2p_client.d.ts +24 -15
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +39 -18
- package/dest/state_machine/global_variable_builder.d.ts +9 -4
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +9 -3
- package/dest/state_machine/index.d.ts +7 -3
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +23 -5
- package/dest/state_machine/mock_epoch_cache.d.ts +18 -3
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +33 -2
- package/dest/state_machine/synchronizer.d.ts +5 -5
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +4 -4
- package/dest/txe_session.d.ts +80 -15
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +236 -42
- package/dest/utils/encoding.d.ts +191 -0
- package/dest/utils/encoding.d.ts.map +1 -0
- package/dest/{util → utils}/encoding.js +7 -2
- package/dest/{util → utils}/expected_failure_error.d.ts +1 -1
- package/dest/utils/expected_failure_error.d.ts.map +1 -0
- package/dest/{util → utils}/txe_account_store.d.ts +1 -1
- package/dest/utils/txe_account_store.d.ts.map +1 -0
- package/dest/utils/txe_artifact_resolver.d.ts +37 -0
- package/dest/utils/txe_artifact_resolver.d.ts.map +1 -0
- package/dest/utils/txe_artifact_resolver.js +161 -0
- package/dest/utils/txe_public_contract_data_source.d.ts +20 -0
- package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -0
- package/dest/{util → utils}/txe_public_contract_data_source.js +6 -25
- package/dest/worker.bundle.js +3 -0
- package/dest/worker.bundle.js.map +7 -0
- package/dest/worker.d.ts +2 -0
- package/dest/worker.d.ts.map +1 -0
- package/dest/worker.js +92 -0
- package/package.json +38 -21
- package/src/bin/check_txe_oracle_version.ts +70 -0
- package/src/bin/index.ts +11 -2
- package/src/bin/oracle_test_server.ts +51 -0
- package/src/constants.ts +10 -0
- package/src/dispatcher_pool.ts +316 -0
- package/src/index.ts +97 -190
- package/src/msgpackr_fr_extension.ts +23 -0
- package/src/oracle/interfaces.ts +58 -35
- package/src/oracle/test-resolver/fixtures.ts +84 -0
- package/src/oracle/test-resolver/index.ts +45 -0
- package/src/oracle/test-resolver/resolver.ts +165 -0
- package/src/oracle/txe_oracle_public_context.ts +72 -12
- package/src/oracle/txe_oracle_registry.ts +401 -0
- package/src/oracle/txe_oracle_top_level_context.ts +282 -147
- package/src/oracle/txe_oracle_version.ts +17 -0
- package/src/oracle/txe_private_execution_oracle.ts +30 -0
- package/src/rpc_server.ts +87 -0
- package/src/rpc_translator.ts +1000 -1006
- package/src/state_machine/archiver.ts +42 -20
- package/src/state_machine/dummy_p2p_client.ts +63 -30
- package/src/state_machine/global_variable_builder.ts +18 -3
- package/src/state_machine/index.ts +25 -5
- package/src/state_machine/mock_epoch_cache.ts +43 -3
- package/src/state_machine/synchronizer.ts +5 -5
- package/src/txe_session.ts +351 -96
- package/src/{util → utils}/encoding.ts +8 -2
- package/src/utils/txe_artifact_resolver.ts +217 -0
- package/src/{util → utils}/txe_public_contract_data_source.ts +10 -38
- package/src/worker.ts +98 -0
- package/dest/util/encoding.d.ts +0 -720
- package/dest/util/encoding.d.ts.map +0 -1
- package/dest/util/expected_failure_error.d.ts.map +0 -1
- package/dest/util/txe_account_store.d.ts.map +0 -1
- package/dest/util/txe_contract_store.d.ts +0 -12
- package/dest/util/txe_contract_store.d.ts.map +0 -1
- package/dest/util/txe_contract_store.js +0 -22
- package/dest/util/txe_public_contract_data_source.d.ts +0 -21
- package/dest/util/txe_public_contract_data_source.d.ts.map +0 -1
- package/src/util/txe_contract_store.ts +0 -36
- /package/dest/{util → utils}/expected_failure_error.js +0 -0
- /package/dest/{util → utils}/txe_account_store.js +0 -0
- /package/src/{util → utils}/expected_failure_error.ts +0 -0
- /package/src/{util → utils}/txe_account_store.ts +0 -0
package/dest/index.js
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
|
-
import { loadContractArtifact } from '@aztec/aztec.js/abi';
|
|
3
|
-
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
4
|
-
import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
5
1
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { protocolContractNames } from '@aztec/protocol-contracts';
|
|
9
|
-
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
10
|
-
import { computeArtifactHash } from '@aztec/stdlib/contract';
|
|
2
|
+
import { cloneEphemeralStoreFrom } from '@aztec/kv-store/lmdb-v2';
|
|
3
|
+
import { ContractStore } from '@aztec/pxe/client/lazy';
|
|
11
4
|
import { zodFor } from '@aztec/stdlib/schemas';
|
|
12
|
-
import {
|
|
13
|
-
import { createReadStream } from 'fs';
|
|
14
|
-
import { readFile, readdir } from 'fs/promises';
|
|
15
|
-
import { join, parse } from 'path';
|
|
5
|
+
import { join } from 'path';
|
|
16
6
|
import { z } from 'zod';
|
|
7
|
+
// Side-effect import: registers the msgpackr Fr extension for the bundled `Fr` class. Must
|
|
8
|
+
// be loaded before any `sendMessage` call. See msgpackr_fr_extension.ts for the why.
|
|
9
|
+
import './msgpackr_fr_extension.js';
|
|
17
10
|
import { TXESession } from './txe_session.js';
|
|
18
|
-
import { ForeignCallArgsSchema, ForeignCallResultSchema
|
|
11
|
+
import { ForeignCallArgsSchema, ForeignCallResultSchema } from './utils/encoding.js';
|
|
12
|
+
import { TXEArtifactResolver } from './utils/txe_artifact_resolver.js';
|
|
13
|
+
// Protocol contracts TXE registers in its contract store. Only AuthRegistry is needed for the
|
|
14
|
+
// current test suites; add a contract here if a lookup against a `0x000…00X` address fails.
|
|
15
|
+
export const TXE_REQUIRED_PROTOCOL_CONTRACTS = [];
|
|
19
16
|
const sessions = new Map();
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const TXEForeignCallInputSchema = zodFor()(z.object({
|
|
17
|
+
export const TXEForeignCallInputSchema = zodFor()(z.object({
|
|
18
|
+
// Nargo generates session_id as a u64, which may exceed Number.MAX_SAFE_INTEGER.
|
|
19
|
+
// Zod 4's `.int()` enforces the safe-integer bound, so we drop it here and only require
|
|
20
|
+
// the value to be a non-negative number (it is used solely as a Map key).
|
|
25
21
|
// eslint-disable-next-line camelcase
|
|
26
|
-
session_id: z.number().
|
|
22
|
+
session_id: z.number().nonnegative(),
|
|
27
23
|
function: z.string(),
|
|
28
24
|
// eslint-disable-next-line camelcase
|
|
29
25
|
root_path: z.string(),
|
|
@@ -31,156 +27,74 @@ const TXEForeignCallInputSchema = zodFor()(z.object({
|
|
|
31
27
|
package_name: z.string(),
|
|
32
28
|
inputs: ForeignCallArgsSchema
|
|
33
29
|
}));
|
|
34
|
-
class TXEDispatcher {
|
|
30
|
+
export class TXEDispatcher {
|
|
35
31
|
logger;
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
contractStore;
|
|
33
|
+
artifactResolver;
|
|
34
|
+
contractStoreSourceDir;
|
|
35
|
+
schnorrClassId;
|
|
36
|
+
constructor(logger, opts){
|
|
38
37
|
this.logger = logger;
|
|
38
|
+
this.contractStoreSourceDir = opts.contractStoreSourceDir;
|
|
39
|
+
this.schnorrClassId = Fr.fromString(opts.schnorrClassId);
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
resolve(hash.read());
|
|
48
|
-
});
|
|
49
|
-
fd.pipe(hash);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
async #processDeployInputs({ inputs, root_path: rootPath, package_name: packageName }) {
|
|
53
|
-
const [contractPath, initializer] = inputs.slice(0, 2).map((input)=>fromArray(input).map((char)=>String.fromCharCode(char.toNumber())).join(''));
|
|
54
|
-
const decodedArgs = fromArray(inputs[3]);
|
|
55
|
-
const secret = fromSingle(inputs[4]);
|
|
56
|
-
const publicKeys = secret.equals(Fr.ZERO) ? PublicKeys.default() : (await deriveKeys(secret)).publicKeys;
|
|
57
|
-
const publicKeysHash = await publicKeys.hash();
|
|
58
|
-
let artifactPath = '';
|
|
59
|
-
const { dir: contractDirectory, base: contractFilename } = parse(contractPath);
|
|
60
|
-
if (contractDirectory) {
|
|
61
|
-
if (contractDirectory.includes('@')) {
|
|
62
|
-
// We're deploying a contract that belongs in a workspace
|
|
63
|
-
// env.deploy("../path/to/workspace/root@packageName/contractName")
|
|
64
|
-
const [workspace, pkg] = contractDirectory.split('@');
|
|
65
|
-
const targetPath = join(rootPath, workspace, '/target');
|
|
66
|
-
this.logger.debug(`Looking for compiled artifact in workspace ${targetPath}`);
|
|
67
|
-
artifactPath = join(targetPath, `${pkg}-${contractFilename}.json`);
|
|
68
|
-
} else {
|
|
69
|
-
// We're deploying a standalone external contract
|
|
70
|
-
// env.deploy("../path/to/contract/root/contractName")
|
|
71
|
-
const targetPath = join(rootPath, contractDirectory, '/target');
|
|
72
|
-
this.logger.debug(`Looking for compiled artifact in ${targetPath}`);
|
|
73
|
-
[artifactPath] = (await readdir(targetPath)).filter((file)=>file.endsWith(`-${contractFilename}.json`));
|
|
74
|
-
}
|
|
75
|
-
} else {
|
|
76
|
-
// We're deploying a local contract
|
|
77
|
-
// env.deploy("contractName")
|
|
78
|
-
artifactPath = join(rootPath, './target', `${packageName}-${contractFilename}.json`);
|
|
79
|
-
}
|
|
80
|
-
const fileHash = await this.fastHashFile(artifactPath);
|
|
81
|
-
const cacheKey = `${contractDirectory ?? ''}-${contractFilename}-${initializer}-${decodedArgs.map((arg)=>arg.toString()).join('-')}-${publicKeysHash}-${fileHash}`;
|
|
82
|
-
let instance;
|
|
83
|
-
let artifact;
|
|
84
|
-
if (TXEArtifactsCache.has(cacheKey)) {
|
|
85
|
-
this.logger.debug(`Using cached artifact for ${cacheKey}`);
|
|
86
|
-
({ artifact, instance } = TXEArtifactsCache.get(cacheKey));
|
|
87
|
-
} else {
|
|
88
|
-
this.logger.debug(`Loading compiled artifact ${artifactPath}`);
|
|
89
|
-
const artifactJSON = JSON.parse(await readFile(artifactPath, 'utf-8'));
|
|
90
|
-
const artifactWithoutHash = loadContractArtifact(artifactJSON);
|
|
91
|
-
artifact = {
|
|
92
|
-
...artifactWithoutHash,
|
|
93
|
-
// Artifact hash is *very* expensive to compute, so we do it here once
|
|
94
|
-
// and the TXE contract data provider can cache it
|
|
95
|
-
artifactHash: await computeArtifactHash(artifactWithoutHash)
|
|
96
|
-
};
|
|
97
|
-
this.logger.debug(`Deploy ${artifact.name} with initializer ${initializer}(${decodedArgs}) and public keys hash ${publicKeysHash.toString()}`);
|
|
98
|
-
instance = await getContractInstanceFromInstantiationParams(artifact, {
|
|
99
|
-
constructorArgs: decodedArgs,
|
|
100
|
-
skipArgsDecoding: true,
|
|
101
|
-
salt: Fr.ONE,
|
|
102
|
-
publicKeys,
|
|
103
|
-
constructorArtifact: initializer ? initializer : undefined,
|
|
104
|
-
deployer: AztecAddress.ZERO
|
|
105
|
-
});
|
|
106
|
-
TXEArtifactsCache.set(cacheKey, {
|
|
107
|
-
artifact,
|
|
108
|
-
instance
|
|
109
|
-
});
|
|
41
|
+
/**
|
|
42
|
+
* Clones the pre-populated LMDB at `contractStoreSourceDir` into a fresh per-instance tmpdir
|
|
43
|
+
* on first use, so this dispatcher has a writable store already containing the required
|
|
44
|
+
* protocol contracts + SchnorrAccount. Idempotent — subsequent calls are no-ops.
|
|
45
|
+
*/ async warmUp() {
|
|
46
|
+
if (this.contractStore) {
|
|
47
|
+
return;
|
|
110
48
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (TXEArtifactsCache.has(cacheKey)) {
|
|
119
|
-
this.logger.debug(`Using cached artifact for ${cacheKey}`);
|
|
120
|
-
({ artifact, instance } = TXEArtifactsCache.get(cacheKey));
|
|
121
|
-
} else {
|
|
122
|
-
const keys = await deriveKeys(secret);
|
|
123
|
-
const args = [
|
|
124
|
-
keys.publicKeys.masterIncomingViewingPublicKey.x,
|
|
125
|
-
keys.publicKeys.masterIncomingViewingPublicKey.y
|
|
126
|
-
];
|
|
127
|
-
artifact = {
|
|
128
|
-
...SchnorrAccountContractArtifact,
|
|
129
|
-
// Artifact hash is *very* expensive to compute, so we do it here once
|
|
130
|
-
// and the TXE contract data provider can cache it
|
|
131
|
-
artifactHash: await computeArtifactHash(SchnorrAccountContractArtifact)
|
|
132
|
-
};
|
|
133
|
-
instance = await getContractInstanceFromInstantiationParams(artifact, {
|
|
134
|
-
constructorArgs: args,
|
|
135
|
-
skipArgsDecoding: true,
|
|
136
|
-
salt: Fr.ONE,
|
|
137
|
-
publicKeys: keys.publicKeys,
|
|
138
|
-
constructorArtifact: 'constructor',
|
|
139
|
-
deployer: AztecAddress.ZERO
|
|
140
|
-
});
|
|
141
|
-
TXEArtifactsCache.set(cacheKey, {
|
|
142
|
-
artifact,
|
|
143
|
-
instance
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
inputs.splice(0, 0, artifact, instance);
|
|
49
|
+
const t0 = Date.now();
|
|
50
|
+
const kvStore = await cloneEphemeralStoreFrom(join(this.contractStoreSourceDir, 'data.mdb'), 'txe-contracts', undefined, 2);
|
|
51
|
+
this.contractStore = new ContractStore(kvStore);
|
|
52
|
+
this.artifactResolver = new TXEArtifactResolver(this.contractStore, this.schnorrClassId);
|
|
53
|
+
this.logger.debug('Cloned shared protocol-contracts store', {
|
|
54
|
+
totalMs: Date.now() - t0
|
|
55
|
+
});
|
|
147
56
|
}
|
|
148
57
|
// eslint-disable-next-line camelcase
|
|
149
58
|
async resolve_foreign_call(callData) {
|
|
150
|
-
const { session_id: sessionId, function: functionName, inputs } = callData;
|
|
59
|
+
const { session_id: sessionId, function: functionName, inputs, root_path: rootPath, package_name: packageName } = callData;
|
|
151
60
|
this.logger.debug(`Calling ${functionName} on session ${sessionId}`);
|
|
152
61
|
if (!sessions.has(sessionId)) {
|
|
153
62
|
this.logger.debug(`Creating new session ${sessionId}`);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
sessions.set(sessionId, await TXESession.init(this.protocolContracts));
|
|
158
|
-
}
|
|
159
|
-
switch(functionName){
|
|
160
|
-
case 'txeDeploy':
|
|
161
|
-
{
|
|
162
|
-
await this.#processDeployInputs(callData);
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
case 'txeAddAccount':
|
|
166
|
-
{
|
|
167
|
-
await this.#processAddAccountInputs(callData);
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
63
|
+
await this.warmUp();
|
|
64
|
+
sessions.set(sessionId, await TXESession.init(this.contractStore, this.artifactResolver, rootPath, packageName));
|
|
170
65
|
}
|
|
171
66
|
return await sessions.get(sessionId).processFunction(functionName, inputs);
|
|
172
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Releases a session and its resources (per-session LMDB + `NativeWorldStateService`).
|
|
70
|
+
* Called by the dispatcher pool when nargo closes its TCP connection for a test (see
|
|
71
|
+
* `rpc_server.ts`'s socket tracker). No-op if the session was never created — that happens
|
|
72
|
+
* when nargo opens a connection but errors before sending a request.
|
|
73
|
+
*/ async disposeSession(sessionId) {
|
|
74
|
+
const session = sessions.get(sessionId);
|
|
75
|
+
if (!session) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
sessions.delete(sessionId);
|
|
79
|
+
await session.dispose();
|
|
80
|
+
}
|
|
173
81
|
}
|
|
174
|
-
|
|
82
|
+
/** Diagnostic-only: number of sessions currently held by this worker. */ export function activeSessionCount() {
|
|
83
|
+
return sessions.size;
|
|
84
|
+
}
|
|
85
|
+
export const TXEDispatcherApiSchema = {
|
|
175
86
|
// eslint-disable-next-line camelcase
|
|
176
|
-
resolve_foreign_call: z.function(
|
|
87
|
+
resolve_foreign_call: z.function({
|
|
88
|
+
input: z.tuple([
|
|
89
|
+
TXEForeignCallInputSchema
|
|
90
|
+
]),
|
|
91
|
+
output: ForeignCallResultSchema
|
|
92
|
+
}),
|
|
93
|
+
// disposeSession is invoked over IPC from the worker, not via RPC; required by ApiSchemaFor.
|
|
94
|
+
disposeSession: z.function({
|
|
95
|
+
input: z.tuple([
|
|
96
|
+
z.number().nonnegative()
|
|
97
|
+
]),
|
|
98
|
+
output: z.void()
|
|
99
|
+
})
|
|
177
100
|
};
|
|
178
|
-
/**
|
|
179
|
-
* Creates an RPC server that forwards calls to the TXE.
|
|
180
|
-
* @param logger - Logger to output to
|
|
181
|
-
* @returns A TXE RPC server.
|
|
182
|
-
*/ export function createTXERpcServer(logger) {
|
|
183
|
-
return createSafeJsonRpcServer(new TXEDispatcher(logger), TXEDispatcherApiSchema, {
|
|
184
|
-
http200OnError: true
|
|
185
|
-
});
|
|
186
|
-
}
|