@aztec/txe 0.0.1-commit.96bb3f7 → 0.0.1-commit.993d240

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.
Files changed (138) hide show
  1. package/dest/ContractClassRegistry-KKNT527R.js +3 -0
  2. package/dest/ContractClassRegistry-KKNT527R.js.map +7 -0
  3. package/dest/ContractInstanceRegistry-GSKBNL3Q.js +3 -0
  4. package/dest/ContractInstanceRegistry-GSKBNL3Q.js.map +7 -0
  5. package/dest/FeeJuice-GUJ5O6GB.js +3 -0
  6. package/dest/FeeJuice-GUJ5O6GB.js.map +7 -0
  7. package/dest/MultiCallEntrypoint-ZQPCKVKL.js +3 -0
  8. package/dest/MultiCallEntrypoint-ZQPCKVKL.js.map +7 -0
  9. package/dest/SchnorrAccount-QIXE5DXA.js +3 -0
  10. package/dest/SchnorrAccount-QIXE5DXA.js.map +7 -0
  11. package/dest/bin/check_txe_oracle_version.d.ts +2 -0
  12. package/dest/bin/check_txe_oracle_version.d.ts.map +1 -0
  13. package/dest/bin/check_txe_oracle_version.js +32 -0
  14. package/dest/bin/index.js +3 -30
  15. package/dest/bin/index.js.map +7 -0
  16. package/dest/chunk-BJVAAXNA.js +3 -0
  17. package/dest/chunk-BJVAAXNA.js.map +7 -0
  18. package/dest/chunk-DF6RMOC6.js +304 -0
  19. package/dest/chunk-DF6RMOC6.js.map +7 -0
  20. package/dest/chunk-PPJTNNUG.js +265 -0
  21. package/dest/chunk-PPJTNNUG.js.map +7 -0
  22. package/dest/constants.d.ts +3 -2
  23. package/dest/constants.d.ts.map +1 -1
  24. package/dest/constants.js +5 -1
  25. package/dest/dispatcher_pool.d.ts +67 -0
  26. package/dest/dispatcher_pool.d.ts.map +1 -0
  27. package/dest/dispatcher_pool.js +284 -0
  28. package/dest/index.d.ts +188 -7
  29. package/dest/index.d.ts.map +1 -1
  30. package/dest/index.js +148 -75
  31. package/dest/metafile.json +38147 -0
  32. package/dest/msgpackr_fr_extension.d.ts +2 -0
  33. package/dest/msgpackr_fr_extension.d.ts.map +1 -0
  34. package/dest/msgpackr_fr_extension.js +21 -0
  35. package/dest/oracle/interfaces.d.ts +40 -28
  36. package/dest/oracle/interfaces.d.ts.map +1 -1
  37. package/dest/oracle/txe_oracle_public_context.d.ts +18 -13
  38. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  39. package/dest/oracle/txe_oracle_public_context.js +31 -16
  40. package/dest/oracle/txe_oracle_top_level_context.d.ts +39 -23
  41. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  42. package/dest/oracle/txe_oracle_top_level_context.js +225 -89
  43. package/dest/oracle/txe_private_execution_oracle.d.ts +17 -0
  44. package/dest/oracle/txe_private_execution_oracle.d.ts.map +1 -0
  45. package/dest/oracle/txe_private_execution_oracle.js +15 -0
  46. package/dest/rpc_server.d.ts +14 -0
  47. package/dest/rpc_server.d.ts.map +1 -0
  48. package/dest/rpc_server.js +78 -0
  49. package/dest/rpc_translator.d.ts +144 -82
  50. package/dest/rpc_translator.d.ts.map +1 -1
  51. package/dest/rpc_translator.js +599 -238
  52. package/dest/server.bundle.js +3 -0
  53. package/dest/server.bundle.js.map +7 -0
  54. package/dest/state_machine/archiver.d.ts +20 -69
  55. package/dest/state_machine/archiver.d.ts.map +1 -1
  56. package/dest/state_machine/archiver.js +47 -187
  57. package/dest/state_machine/dummy_p2p_client.d.ts +26 -16
  58. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  59. package/dest/state_machine/dummy_p2p_client.js +44 -20
  60. package/dest/state_machine/global_variable_builder.d.ts +9 -4
  61. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  62. package/dest/state_machine/global_variable_builder.js +9 -3
  63. package/dest/state_machine/index.d.ts +10 -6
  64. package/dest/state_machine/index.d.ts.map +1 -1
  65. package/dest/state_machine/index.js +55 -14
  66. package/dest/state_machine/mock_epoch_cache.d.ts +25 -8
  67. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  68. package/dest/state_machine/mock_epoch_cache.js +46 -9
  69. package/dest/state_machine/synchronizer.d.ts +6 -6
  70. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  71. package/dest/state_machine/synchronizer.js +4 -4
  72. package/dest/txe_oracle_version.d.ts +17 -0
  73. package/dest/txe_oracle_version.d.ts.map +1 -0
  74. package/dest/txe_oracle_version.js +14 -0
  75. package/dest/txe_session.d.ts +73 -10
  76. package/dest/txe_session.d.ts.map +1 -1
  77. package/dest/txe_session.js +242 -39
  78. package/dest/utils/block_creation.d.ts +4 -4
  79. package/dest/utils/block_creation.d.ts.map +1 -1
  80. package/dest/utils/block_creation.js +18 -4
  81. package/dest/utils/encoding.d.ts +191 -0
  82. package/dest/utils/encoding.d.ts.map +1 -0
  83. package/dest/{util → utils}/encoding.js +7 -2
  84. package/dest/{util → utils}/expected_failure_error.d.ts +1 -1
  85. package/dest/utils/expected_failure_error.d.ts.map +1 -0
  86. package/dest/utils/tx_effect_creation.d.ts +2 -3
  87. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  88. package/dest/utils/tx_effect_creation.js +3 -6
  89. package/dest/{util → utils}/txe_account_store.d.ts +1 -1
  90. package/dest/utils/txe_account_store.d.ts.map +1 -0
  91. package/dest/utils/txe_public_contract_data_source.d.ts +20 -0
  92. package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -0
  93. package/dest/{util → utils}/txe_public_contract_data_source.js +6 -25
  94. package/dest/worker.bundle.js +3 -0
  95. package/dest/worker.bundle.js.map +7 -0
  96. package/dest/worker.d.ts +2 -0
  97. package/dest/worker.d.ts.map +1 -0
  98. package/dest/worker.js +92 -0
  99. package/package.json +38 -22
  100. package/src/bin/check_txe_oracle_version.ts +37 -0
  101. package/src/bin/index.ts +11 -2
  102. package/src/constants.ts +6 -1
  103. package/src/dispatcher_pool.ts +316 -0
  104. package/src/index.ts +166 -80
  105. package/src/msgpackr_fr_extension.ts +23 -0
  106. package/src/oracle/interfaces.ts +48 -34
  107. package/src/oracle/txe_oracle_public_context.ts +46 -18
  108. package/src/oracle/txe_oracle_top_level_context.ts +282 -151
  109. package/src/oracle/txe_private_execution_oracle.ts +30 -0
  110. package/src/rpc_server.ts +87 -0
  111. package/src/rpc_translator.ts +687 -326
  112. package/src/state_machine/archiver.ts +53 -235
  113. package/src/state_machine/dummy_p2p_client.ts +70 -32
  114. package/src/state_machine/global_variable_builder.ts +18 -3
  115. package/src/state_machine/index.ts +72 -15
  116. package/src/state_machine/mock_epoch_cache.ts +57 -14
  117. package/src/state_machine/synchronizer.ts +6 -6
  118. package/src/txe_oracle_version.ts +17 -0
  119. package/src/txe_session.ts +352 -104
  120. package/src/utils/block_creation.ts +19 -16
  121. package/src/{util → utils}/encoding.ts +8 -2
  122. package/src/utils/tx_effect_creation.ts +3 -11
  123. package/src/{util → utils}/txe_public_contract_data_source.ts +10 -38
  124. package/src/worker.ts +98 -0
  125. package/dest/util/encoding.d.ts +0 -720
  126. package/dest/util/encoding.d.ts.map +0 -1
  127. package/dest/util/expected_failure_error.d.ts.map +0 -1
  128. package/dest/util/txe_account_store.d.ts.map +0 -1
  129. package/dest/util/txe_contract_store.d.ts +0 -12
  130. package/dest/util/txe_contract_store.d.ts.map +0 -1
  131. package/dest/util/txe_contract_store.js +0 -22
  132. package/dest/util/txe_public_contract_data_source.d.ts +0 -21
  133. package/dest/util/txe_public_contract_data_source.d.ts.map +0 -1
  134. package/src/util/txe_contract_store.ts +0 -36
  135. /package/dest/{util → utils}/expected_failure_error.js +0 -0
  136. /package/dest/{util → utils}/txe_account_store.js +0 -0
  137. /package/src/{util → utils}/expected_failure_error.ts +0 -0
  138. /package/src/{util → utils}/txe_account_store.ts +0 -0
@@ -4,12 +4,12 @@ import {
4
4
  NULLIFIER_SUBTREE_HEIGHT,
5
5
  NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
6
6
  } from '@aztec/constants';
7
- import { BlockNumber } from '@aztec/foundation/branded-types';
7
+ import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
8
8
  import { padArrayEnd } from '@aztec/foundation/collection';
9
9
  import { Fr } from '@aztec/foundation/curves/bn254';
10
- import { Body, L2Block, L2BlockHeader } from '@aztec/stdlib/block';
10
+ import { Body, L2Block } from '@aztec/stdlib/block';
11
11
  import { AppendOnlyTreeSnapshot, MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
12
- import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
12
+ import { BlockHeader, GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
13
13
 
14
14
  /**
15
15
  * Returns a transaction request hash that is valid for transactions that are the only ones in a block.
@@ -46,21 +46,18 @@ export async function insertTxEffectIntoWorldTrees(
46
46
  export async function makeTXEBlockHeader(
47
47
  worldTrees: MerkleTreeWriteOperations,
48
48
  globalVariables: GlobalVariables,
49
- ): Promise<L2BlockHeader> {
49
+ ): Promise<BlockHeader> {
50
50
  const stateReference = await worldTrees.getStateReference();
51
51
  const archiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
52
52
 
53
- return new L2BlockHeader(
54
- new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
55
- Fr.ZERO,
56
- Fr.ZERO,
57
- stateReference,
53
+ return BlockHeader.from({
54
+ lastArchive: new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
55
+ spongeBlobHash: Fr.ZERO,
56
+ state: stateReference,
58
57
  globalVariables,
59
- Fr.ZERO,
60
- Fr.ZERO,
61
- Fr.ZERO,
62
- Fr.ZERO,
63
- );
58
+ totalFees: Fr.ZERO,
59
+ totalManaUsed: Fr.ZERO,
60
+ });
64
61
  }
65
62
 
66
63
  /**
@@ -84,11 +81,17 @@ export async function makeTXEBlock(
84
81
  const header = await makeTXEBlockHeader(worldTrees, globalVariables);
85
82
 
86
83
  // Update the archive tree with this block's header hash
87
- await worldTrees.updateArchive(header.toBlockHeader());
84
+ await worldTrees.updateArchive(header);
88
85
 
89
86
  // Get the new archive state after updating
90
87
  const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
91
88
  const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
92
89
 
93
- return new L2Block(newArchive, header, new Body(txEffects));
90
+ // L2Block requires checkpointNumber and indexWithinCheckpoint.
91
+ // TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
92
+ // This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
93
+ const checkpointNumber = CheckpointNumber.fromBlockNumber(globalVariables.blockNumber);
94
+ const indexWithinCheckpoint = IndexWithinCheckpoint(0);
95
+
96
+ return new L2Block(newArchive, header, new Body(txEffects), checkpointNumber, indexWithinCheckpoint);
94
97
  }
@@ -3,6 +3,7 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
3
3
  import { hexToBuffer } from '@aztec/foundation/string';
4
4
  import { type ContractArtifact, ContractArtifactSchema } from '@aztec/stdlib/abi';
5
5
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+ import { BlockHash } from '@aztec/stdlib/block';
6
7
  import { type ContractInstanceWithAddress, ContractInstanceWithAddressSchema } from '@aztec/stdlib/contract';
7
8
 
8
9
  import { z } from 'zod';
@@ -25,6 +26,10 @@ export function addressFromSingle(obj: ForeignCallSingle) {
25
26
  return new AztecAddress(fromSingle(obj));
26
27
  }
27
28
 
29
+ export function blockHashFromSingle(obj: ForeignCallSingle) {
30
+ return new BlockHash(fromSingle(obj));
31
+ }
32
+
28
33
  export function fromArray(obj: ForeignCallArray) {
29
34
  return obj.map(str => Fr.fromBuffer(hexToBuffer(str)));
30
35
  }
@@ -142,9 +147,10 @@ export function arrayOfArraysToBoundedVecOfArrays(
142
147
 
143
148
  const numFieldsToPad = maxLen * nestedArrayLength - flattenedStorage.length;
144
149
 
145
- const flattenedStorageWithPadding = flattenedStorage.concat(Array(numFieldsToPad).fill(new Fr(0)));
150
+ // Pad with hex-encoded zeros so the result is uniformly `ForeignCallSingle` (string); raw Fr
151
+ // instances would JSON-serialize as `{ asBigInt: "0" }` and nargo would reject the response.
152
+ const flattenedStorageWithPadding = flattenedStorage.concat(toArray(Array(numFieldsToPad).fill(new Fr(0))));
146
153
 
147
- // At last we get the actual length of the BoundedVec and return the values.
148
154
  const len = toSingle(new Fr(bVecStorage.length));
149
155
  return [flattenedStorageWithPadding, len];
150
156
  }
@@ -4,16 +4,12 @@ import type { ExecutionNoteCache } from '@aztec/pxe/simulator';
4
4
  import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash } from '@aztec/stdlib/hash';
5
5
  import { TxEffect, TxHash } from '@aztec/stdlib/tx';
6
6
 
7
- export async function makeTxEffect(
8
- noteCache: ExecutionNoteCache,
9
- protocolNullifier: Fr,
10
- txBlockNumber: BlockNumber,
11
- ): Promise<TxEffect> {
7
+ export async function makeTxEffect(noteCache: ExecutionNoteCache, txBlockNumber: BlockNumber): Promise<TxEffect> {
12
8
  const txEffect = TxEffect.empty();
13
9
 
14
- const { usedProtocolNullifierForNonces } = noteCache.finish();
15
- const nonceGenerator = usedProtocolNullifierForNonces ? protocolNullifier : noteCache.getAllNullifiers()[0];
10
+ noteCache.finish();
16
11
 
12
+ const nonceGenerator = noteCache.getNonceGenerator();
17
13
  txEffect.noteHashes = await Promise.all(
18
14
  noteCache
19
15
  .getAllNotes()
@@ -28,10 +24,6 @@ export async function makeTxEffect(
28
24
  // Nullifiers are already siloed
29
25
  txEffect.nullifiers = noteCache.getAllNullifiers();
30
26
 
31
- if (usedProtocolNullifierForNonces) {
32
- txEffect.nullifiers.unshift(protocolNullifier);
33
- }
34
-
35
27
  txEffect.txHash = new TxHash(new Fr(txBlockNumber));
36
28
 
37
29
  return txEffect;
@@ -1,19 +1,11 @@
1
1
  import { BlockNumber } from '@aztec/foundation/branded-types';
2
2
  import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { ContractStore } from '@aztec/pxe/server';
4
- import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
4
+ import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
5
5
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
- import {
7
- type ContractClassPublic,
8
- type ContractDataSource,
9
- type ContractInstanceWithAddress,
10
- computePrivateFunctionsRoot,
11
- computePublicBytecodeCommitment,
12
- getContractClassPrivateFunctionFromArtifact,
13
- } from '@aztec/stdlib/contract';
6
+ import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
14
7
 
15
8
  export class TXEPublicContractDataSource implements ContractDataSource {
16
- #privateFunctionsRoot: Map<string, Buffer> = new Map();
17
9
  constructor(
18
10
  private blockNumber: BlockNumber,
19
11
  private contractStore: ContractStore,
@@ -24,42 +16,22 @@ export class TXEPublicContractDataSource implements ContractDataSource {
24
16
  }
25
17
 
26
18
  async getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
27
- const contractClass = await this.contractStore.getContractClass(id);
19
+ const contractClass = await this.contractStore.getContractClassWithPreimage(id);
28
20
  if (!contractClass) {
29
21
  return;
30
22
  }
31
- const artifact = await this.contractStore.getContractArtifact(id);
32
- if (!artifact) {
33
- return;
34
- }
35
-
36
- let privateFunctionsRoot;
37
- if (!this.#privateFunctionsRoot.has(id.toString())) {
38
- const privateFunctions = await Promise.all(
39
- artifact.functions
40
- .filter(fn => fn.functionType === FunctionType.PRIVATE)
41
- .map(fn => getContractClassPrivateFunctionFromArtifact(fn)),
42
- );
43
- privateFunctionsRoot = await computePrivateFunctionsRoot(privateFunctions);
44
- this.#privateFunctionsRoot.set(id.toString(), privateFunctionsRoot.toBuffer());
45
- } else {
46
- privateFunctionsRoot = Fr.fromBuffer(this.#privateFunctionsRoot.get(id.toString())!);
47
- }
48
-
49
23
  return {
50
- id,
51
- artifactHash: contractClass!.artifactHash,
52
- packedBytecode: contractClass!.packedBytecode,
53
- privateFunctionsRoot,
54
- version: contractClass!.version,
55
- privateFunctions: [],
56
- utilityFunctions: [],
24
+ id: contractClass.id,
25
+ artifactHash: contractClass.artifactHash,
26
+ packedBytecode: contractClass.packedBytecode,
27
+ privateFunctionsRoot: contractClass.privateFunctionsRoot,
28
+ version: contractClass.version,
57
29
  };
58
30
  }
59
31
 
60
32
  async getBytecodeCommitment(id: Fr): Promise<Fr | undefined> {
61
- const contractClass = await this.contractStore.getContractClass(id);
62
- return contractClass && computePublicBytecodeCommitment(contractClass.packedBytecode);
33
+ const contractClass = await this.contractStore.getContractClassWithPreimage(id);
34
+ return contractClass?.publicBytecodeCommitment;
63
35
  }
64
36
 
65
37
  async getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
package/src/worker.ts ADDED
@@ -0,0 +1,98 @@
1
+ import { BackendType, Barretenberg, BarretenbergSync } from '@aztec/bb.js';
2
+ import { type Logger, createLogger } from '@aztec/foundation/log';
3
+
4
+ import { parentPort, workerData } from 'node:worker_threads';
5
+
6
+ // Importing `./index.js` registers the msgpackr Fr extension transitively (via
7
+ // ./msgpackr_fr_extension.js); this must happen before any `sendMessage` call.
8
+ import { TXEDispatcher, type TXEDispatcherOptions, type TXEForeignCallInput, activeSessionCount } from './index.js';
9
+
10
+ // Seed both bb.js singletons with the WASM backend before any crypto call. `initSingleton`
11
+ // binds the singleton to whichever backend the first call requests, so this pre-empts the
12
+ // implicit `Barretenberg.initSingleton()` inside `poseidon2Hash` from `@aztec/foundation/crypto`.
13
+ // TXE only needs hashing (no proving, no verification), so WASM is sufficient and
14
+ // `skipSrsInit: true` skips the CRS load. `threads: 1` keeps the WASM backend on a single
15
+ // thread — additional threads would each spawn a nested worker_thread, multiplying memory cost
16
+ // per pool worker.
17
+ void Barretenberg.initSingleton({ backend: BackendType.Wasm, skipSrsInit: true, threads: 1 });
18
+ void BarretenbergSync.initSingleton({ backend: BackendType.Wasm });
19
+
20
+ if (!parentPort) {
21
+ throw new Error('worker.ts must be loaded as a worker_thread');
22
+ }
23
+
24
+ const port = parentPort;
25
+ const logger: Logger = createLogger('txe:worker');
26
+
27
+ // The pool builds a template LMDB containing the protocol contracts + the SchnorrAccount
28
+ // artifact on the main thread and passes its data dir via `workerData`. The dispatcher clones
29
+ // that LMDB into a per-worker store on first use, so this worker gets a writable copy already
30
+ // populated.
31
+ const dispatcherOpts: TXEDispatcherOptions = {
32
+ contractStoreSourceDir: workerData.contractStoreSourceDir,
33
+ schnorrClassId: workerData.schnorrClassId,
34
+ };
35
+ const dispatcher = new TXEDispatcher(logger, dispatcherOpts);
36
+
37
+ interface ForeignCallRequest {
38
+ type: 'foreign-call';
39
+ requestId: number;
40
+ callData: TXEForeignCallInput;
41
+ }
42
+
43
+ interface DisposeSessionMessage {
44
+ type: 'dispose-session';
45
+ sessionId: number;
46
+ }
47
+
48
+ type IncomingMessage = ForeignCallRequest | DisposeSessionMessage;
49
+
50
+ interface SerializedError {
51
+ message: string;
52
+ name?: string;
53
+ stack?: string;
54
+ }
55
+
56
+ function serializeError(err: unknown): SerializedError {
57
+ if (err instanceof Error) {
58
+ return { message: err.message, name: err.name, stack: err.stack };
59
+ }
60
+ return { message: String(err) };
61
+ }
62
+
63
+ // Periodic memstat for diagnostic builds — set TXE_WORKER_MEMSTAT=1 to enable. Posts JS-heap
64
+ // breakdown + active-session count back to the dispatcher so we can attribute RSS growth
65
+ // between V8 heap (would show in heapUsed) and native (LMDB / world-state / WASM).
66
+ if (process.env.TXE_WORKER_MEMSTAT === '1') {
67
+ setInterval(() => {
68
+ const m = process.memoryUsage();
69
+ port.postMessage({
70
+ type: 'memstat',
71
+ sessions: activeSessionCount(),
72
+ rss: m.rss,
73
+ heapTotal: m.heapTotal,
74
+ heapUsed: m.heapUsed,
75
+ external: m.external,
76
+ arrayBuffers: m.arrayBuffers,
77
+ });
78
+ }, 2000).unref();
79
+ }
80
+
81
+ port.on('message', (msg: IncomingMessage) => {
82
+ switch (msg.type) {
83
+ case 'foreign-call':
84
+ void (async () => {
85
+ try {
86
+ const value = await dispatcher.resolve_foreign_call(msg.callData);
87
+ port.postMessage({ type: 'result', requestId: msg.requestId, ok: true, value });
88
+ } catch (err) {
89
+ port.postMessage({ type: 'result', requestId: msg.requestId, ok: false, error: serializeError(err) });
90
+ }
91
+ })();
92
+ return;
93
+ case 'dispose-session':
94
+ // Fire-and-forget; the main thread does not wait for confirmation.
95
+ void dispatcher.disposeSession(msg.sessionId).catch(err => logger.warn(`disposeSession failed`, err));
96
+ return;
97
+ }
98
+ });