@aztec/txe 0.0.1-commit.03f7ef2 → 0.0.1-commit.04d373f

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 (141) 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 +5 -0
  23. package/dest/constants.d.ts.map +1 -0
  24. package/dest/constants.js +7 -0
  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 +49 -31
  41. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  42. package/dest/oracle/txe_oracle_top_level_context.js +265 -119
  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 -67
  55. package/dest/state_machine/archiver.d.ts.map +1 -1
  56. package/dest/state_machine/archiver.js +65 -182
  57. package/dest/state_machine/dummy_p2p_client.d.ts +28 -17
  58. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  59. package/dest/state_machine/dummy_p2p_client.js +51 -24
  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 +10 -4
  63. package/dest/state_machine/index.d.ts +11 -7
  64. package/dest/state_machine/index.d.ts.map +1 -1
  65. package/dest/state_machine/index.js +57 -16
  66. package/dest/state_machine/mock_epoch_cache.d.ts +26 -8
  67. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  68. package/dest/state_machine/mock_epoch_cache.js +49 -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 +83 -19
  76. package/dest/txe_session.d.ts.map +1 -1
  77. package/dest/txe_session.js +291 -66
  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 -5
  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/utils/txe_account_store.d.ts +10 -0
  90. package/dest/utils/txe_account_store.d.ts.map +1 -0
  91. package/dest/{util/txe_account_data_provider.js → utils/txe_account_store.js} +1 -1
  92. package/dest/utils/txe_public_contract_data_source.d.ts +20 -0
  93. package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -0
  94. package/dest/utils/txe_public_contract_data_source.js +48 -0
  95. package/dest/worker.bundle.js +3 -0
  96. package/dest/worker.bundle.js.map +7 -0
  97. package/dest/worker.d.ts +2 -0
  98. package/dest/worker.d.ts.map +1 -0
  99. package/dest/worker.js +92 -0
  100. package/package.json +38 -22
  101. package/src/bin/check_txe_oracle_version.ts +37 -0
  102. package/src/bin/index.ts +11 -2
  103. package/src/constants.ts +9 -0
  104. package/src/dispatcher_pool.ts +316 -0
  105. package/src/index.ts +166 -80
  106. package/src/msgpackr_fr_extension.ts +23 -0
  107. package/src/oracle/interfaces.ts +48 -34
  108. package/src/oracle/txe_oracle_public_context.ts +46 -18
  109. package/src/oracle/txe_oracle_top_level_context.ts +322 -169
  110. package/src/oracle/txe_private_execution_oracle.ts +30 -0
  111. package/src/rpc_server.ts +87 -0
  112. package/src/rpc_translator.ts +687 -326
  113. package/src/state_machine/archiver.ts +69 -220
  114. package/src/state_machine/dummy_p2p_client.ts +80 -37
  115. package/src/state_machine/global_variable_builder.ts +19 -4
  116. package/src/state_machine/index.ts +73 -16
  117. package/src/state_machine/mock_epoch_cache.ts +61 -14
  118. package/src/state_machine/synchronizer.ts +6 -6
  119. package/src/txe_oracle_version.ts +17 -0
  120. package/src/txe_session.ts +439 -132
  121. package/src/utils/block_creation.ts +19 -16
  122. package/src/{util → utils}/encoding.ts +8 -2
  123. package/src/utils/tx_effect_creation.ts +3 -11
  124. package/src/{util/txe_account_data_provider.ts → utils/txe_account_store.ts} +1 -1
  125. package/src/utils/txe_public_contract_data_source.ts +58 -0
  126. package/src/worker.ts +98 -0
  127. package/dest/util/encoding.d.ts +0 -720
  128. package/dest/util/encoding.d.ts.map +0 -1
  129. package/dest/util/expected_failure_error.d.ts.map +0 -1
  130. package/dest/util/txe_account_data_provider.d.ts +0 -10
  131. package/dest/util/txe_account_data_provider.d.ts.map +0 -1
  132. package/dest/util/txe_contract_data_provider.d.ts +0 -12
  133. package/dest/util/txe_contract_data_provider.d.ts.map +0 -1
  134. package/dest/util/txe_contract_data_provider.js +0 -22
  135. package/dest/util/txe_public_contract_data_source.d.ts +0 -21
  136. package/dest/util/txe_public_contract_data_source.d.ts.map +0 -1
  137. package/dest/util/txe_public_contract_data_source.js +0 -67
  138. package/src/util/txe_contract_data_provider.ts +0 -36
  139. package/src/util/txe_public_contract_data_source.ts +0 -86
  140. /package/dest/{util → utils}/expected_failure_error.js +0 -0
  141. /package/src/{util → utils}/expected_failure_error.ts +0 -0
@@ -4,13 +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';
11
- import { makeContentCommitment } from '@aztec/stdlib/testing';
10
+ import { Body, L2Block } from '@aztec/stdlib/block';
12
11
  import { AppendOnlyTreeSnapshot, MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
13
- import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
12
+ import { BlockHeader, GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
14
13
 
15
14
  /**
16
15
  * Returns a transaction request hash that is valid for transactions that are the only ones in a block.
@@ -47,20 +46,18 @@ export async function insertTxEffectIntoWorldTrees(
47
46
  export async function makeTXEBlockHeader(
48
47
  worldTrees: MerkleTreeWriteOperations,
49
48
  globalVariables: GlobalVariables,
50
- ): Promise<L2BlockHeader> {
49
+ ): Promise<BlockHeader> {
51
50
  const stateReference = await worldTrees.getStateReference();
52
51
  const archiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
53
52
 
54
- return new L2BlockHeader(
55
- new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
56
- makeContentCommitment(),
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;
@@ -2,7 +2,7 @@ import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
2
2
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
3
  import { CompleteAddress } from '@aztec/stdlib/contract';
4
4
 
5
- export class TXEAccountDataProvider {
5
+ export class TXEAccountStore {
6
6
  #accounts: AztecAsyncMap<string, Buffer>;
7
7
 
8
8
  constructor(store: AztecAsyncKVStore) {
@@ -0,0 +1,58 @@
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
+ import type { ContractStore } from '@aztec/pxe/server';
4
+ import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
5
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+ import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
7
+
8
+ export class TXEPublicContractDataSource implements ContractDataSource {
9
+ constructor(
10
+ private blockNumber: BlockNumber,
11
+ private contractStore: ContractStore,
12
+ ) {}
13
+
14
+ getBlockNumber(): Promise<BlockNumber> {
15
+ return Promise.resolve(this.blockNumber);
16
+ }
17
+
18
+ async getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
19
+ const contractClass = await this.contractStore.getContractClassWithPreimage(id);
20
+ if (!contractClass) {
21
+ return;
22
+ }
23
+ return {
24
+ id: contractClass.id,
25
+ artifactHash: contractClass.artifactHash,
26
+ packedBytecode: contractClass.packedBytecode,
27
+ privateFunctionsRoot: contractClass.privateFunctionsRoot,
28
+ version: contractClass.version,
29
+ };
30
+ }
31
+
32
+ async getBytecodeCommitment(id: Fr): Promise<Fr | undefined> {
33
+ const contractClass = await this.contractStore.getContractClassWithPreimage(id);
34
+ return contractClass?.publicBytecodeCommitment;
35
+ }
36
+
37
+ async getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
38
+ const instance = await this.contractStore.getContractInstance(address);
39
+ return instance && { ...instance, address };
40
+ }
41
+
42
+ getContractClassIds(): Promise<Fr[]> {
43
+ throw new Error('Method not implemented.');
44
+ }
45
+
46
+ async getContractArtifact(address: AztecAddress): Promise<ContractArtifact | undefined> {
47
+ const instance = await this.contractStore.getContractInstance(address);
48
+ return instance && this.contractStore.getContractArtifact(instance.currentContractClassId);
49
+ }
50
+
51
+ async getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
52
+ return await this.contractStore.getDebugFunctionName(address, selector);
53
+ }
54
+
55
+ registerContractFunctionSignatures(_signatures: []): Promise<void> {
56
+ return Promise.resolve();
57
+ }
58
+ }
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
+ });