@aztec-labs/txe 6.0.0-nightly.20260829

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 (173) hide show
  1. package/dest/AuthRegistry-D4XJULH3.js +3 -0
  2. package/dest/AuthRegistry-D4XJULH3.js.map +7 -0
  3. package/dest/ContractClassRegistry-Q76MXQZD.js +3 -0
  4. package/dest/ContractClassRegistry-Q76MXQZD.js.map +7 -0
  5. package/dest/ContractInstanceRegistry-CTRARU77.js +3 -0
  6. package/dest/ContractInstanceRegistry-CTRARU77.js.map +7 -0
  7. package/dest/FeeJuice-YLTJXWYJ.js +3 -0
  8. package/dest/FeeJuice-YLTJXWYJ.js.map +7 -0
  9. package/dest/HandshakeRegistry-BRPEG7GL.js +3 -0
  10. package/dest/HandshakeRegistry-BRPEG7GL.js.map +7 -0
  11. package/dest/MultiCallEntrypoint-CJHMYQT5.js +3 -0
  12. package/dest/MultiCallEntrypoint-CJHMYQT5.js.map +7 -0
  13. package/dest/SchnorrAccount-OB4N4QIM.js +3 -0
  14. package/dest/SchnorrAccount-OB4N4QIM.js.map +7 -0
  15. package/dest/SchnorrInitializerlessAccount-TWGKRUSY.js +3 -0
  16. package/dest/SchnorrInitializerlessAccount-TWGKRUSY.js.map +7 -0
  17. package/dest/bin/check_txe_oracle_version.d.ts +2 -0
  18. package/dest/bin/check_txe_oracle_version.d.ts.map +1 -0
  19. package/dest/bin/check_txe_oracle_version.js +22 -0
  20. package/dest/bin/index.d.ts +3 -0
  21. package/dest/bin/index.d.ts.map +1 -0
  22. package/dest/bin/index.js +4 -0
  23. package/dest/bin/index.js.map +7 -0
  24. package/dest/bin/oracle_test_server.d.ts +3 -0
  25. package/dest/bin/oracle_test_server.d.ts.map +1 -0
  26. package/dest/bin/oracle_test_server.js +41 -0
  27. package/dest/chunk-32UHX7YY.js +3 -0
  28. package/dest/chunk-32UHX7YY.js.map +7 -0
  29. package/dest/chunk-F4QVFWNM.js +258 -0
  30. package/dest/chunk-F4QVFWNM.js.map +7 -0
  31. package/dest/chunk-LILEKW2X.js +304 -0
  32. package/dest/chunk-LILEKW2X.js.map +7 -0
  33. package/dest/constants.d.ts +7 -0
  34. package/dest/constants.d.ts.map +1 -0
  35. package/dest/constants.js +10 -0
  36. package/dest/dispatcher_pool.d.ts +67 -0
  37. package/dest/dispatcher_pool.d.ts.map +1 -0
  38. package/dest/dispatcher_pool.js +288 -0
  39. package/dest/index.d.ts +52 -0
  40. package/dest/index.d.ts.map +1 -0
  41. package/dest/index.js +102 -0
  42. package/dest/metafile.json +38805 -0
  43. package/dest/msgpackr_fr_extension.d.ts +2 -0
  44. package/dest/msgpackr_fr_extension.d.ts.map +1 -0
  45. package/dest/msgpackr_fr_extension.js +21 -0
  46. package/dest/oracle/interfaces.d.ts +90 -0
  47. package/dest/oracle/interfaces.d.ts.map +1 -0
  48. package/dest/oracle/interfaces.js +3 -0
  49. package/dest/oracle/noir-structs/gas_settings_data.d.ts +14 -0
  50. package/dest/oracle/noir-structs/gas_settings_data.d.ts.map +1 -0
  51. package/dest/oracle/noir-structs/gas_settings_data.js +1 -0
  52. package/dest/oracle/noir-structs/tx_effects_data.d.ts +11 -0
  53. package/dest/oracle/noir-structs/tx_effects_data.d.ts.map +1 -0
  54. package/dest/oracle/noir-structs/tx_effects_data.js +1 -0
  55. package/dest/oracle/tagging_secret_strategy.d.ts +12 -0
  56. package/dest/oracle/tagging_secret_strategy.d.ts.map +1 -0
  57. package/dest/oracle/tagging_secret_strategy.js +12 -0
  58. package/dest/oracle/test-resolver/default_fixtures.d.ts +16 -0
  59. package/dest/oracle/test-resolver/default_fixtures.d.ts.map +1 -0
  60. package/dest/oracle/test-resolver/default_fixtures.js +207 -0
  61. package/dest/oracle/test-resolver/index.d.ts +9 -0
  62. package/dest/oracle/test-resolver/index.d.ts.map +1 -0
  63. package/dest/oracle/test-resolver/index.js +32 -0
  64. package/dest/oracle/test-resolver/resolver.d.ts +48 -0
  65. package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
  66. package/dest/oracle/test-resolver/resolver.js +181 -0
  67. package/dest/oracle/txe_oracle_public_context.d.ts +58 -0
  68. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -0
  69. package/dest/oracle/txe_oracle_public_context.js +170 -0
  70. package/dest/oracle/txe_oracle_registry.d.ts +164 -0
  71. package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
  72. package/dest/oracle/txe_oracle_registry.js +753 -0
  73. package/dest/oracle/txe_oracle_top_level_context.d.ts +128 -0
  74. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -0
  75. package/dest/oracle/txe_oracle_top_level_context.js +815 -0
  76. package/dest/oracle/txe_oracle_version.d.ts +17 -0
  77. package/dest/oracle/txe_oracle_version.d.ts.map +1 -0
  78. package/dest/oracle/txe_oracle_version.js +14 -0
  79. package/dest/oracle/txe_private_execution_oracle.d.ts +17 -0
  80. package/dest/oracle/txe_private_execution_oracle.d.ts.map +1 -0
  81. package/dest/oracle/txe_private_execution_oracle.js +15 -0
  82. package/dest/rpc_server.d.ts +14 -0
  83. package/dest/rpc_server.d.ts.map +1 -0
  84. package/dest/rpc_server.js +78 -0
  85. package/dest/rpc_translator.d.ts +140 -0
  86. package/dest/rpc_translator.d.ts.map +1 -0
  87. package/dest/rpc_translator.js +976 -0
  88. package/dest/server.bundle.js +3 -0
  89. package/dest/server.bundle.js.map +7 -0
  90. package/dest/state_machine/archiver.d.ts +32 -0
  91. package/dest/state_machine/archiver.d.ts.map +1 -0
  92. package/dest/state_machine/archiver.js +95 -0
  93. package/dest/state_machine/dummy_p2p_client.d.ts +69 -0
  94. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -0
  95. package/dest/state_machine/dummy_p2p_client.js +180 -0
  96. package/dest/state_machine/global_variable_builder.d.ts +15 -0
  97. package/dest/state_machine/global_variable_builder.d.ts.map +1 -0
  98. package/dest/state_machine/global_variable_builder.js +25 -0
  99. package/dest/state_machine/index.d.ts +22 -0
  100. package/dest/state_machine/index.d.ts.map +1 -0
  101. package/dest/state_machine/index.js +110 -0
  102. package/dest/state_machine/mock_epoch_cache.d.ts +43 -0
  103. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -0
  104. package/dest/state_machine/mock_epoch_cache.js +88 -0
  105. package/dest/state_machine/synchronizer.d.ts +41 -0
  106. package/dest/state_machine/synchronizer.d.ts.map +1 -0
  107. package/dest/state_machine/synchronizer.js +70 -0
  108. package/dest/txe_session.d.ts +179 -0
  109. package/dest/txe_session.d.ts.map +1 -0
  110. package/dest/txe_session.js +697 -0
  111. package/dest/utils/block_creation.d.ts +28 -0
  112. package/dest/utils/block_creation.d.ts.map +1 -0
  113. package/dest/utils/block_creation.js +59 -0
  114. package/dest/utils/encoding.d.ts +194 -0
  115. package/dest/utils/encoding.d.ts.map +1 -0
  116. package/dest/utils/encoding.js +136 -0
  117. package/dest/utils/expected_failure_error.d.ts +4 -0
  118. package/dest/utils/expected_failure_error.d.ts.map +1 -0
  119. package/dest/utils/expected_failure_error.js +5 -0
  120. package/dest/utils/tx_effect_creation.d.ts +5 -0
  121. package/dest/utils/tx_effect_creation.d.ts.map +1 -0
  122. package/dest/utils/tx_effect_creation.js +12 -0
  123. package/dest/utils/txe_account_store.d.ts +10 -0
  124. package/dest/utils/txe_account_store.d.ts.map +1 -0
  125. package/dest/utils/txe_account_store.js +17 -0
  126. package/dest/utils/txe_artifact_resolver.d.ts +36 -0
  127. package/dest/utils/txe_artifact_resolver.d.ts.map +1 -0
  128. package/dest/utils/txe_artifact_resolver.js +160 -0
  129. package/dest/utils/txe_public_contract_data_source.d.ts +20 -0
  130. package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -0
  131. package/dest/utils/txe_public_contract_data_source.js +51 -0
  132. package/dest/worker.bundle.js +3 -0
  133. package/dest/worker.bundle.js.map +7 -0
  134. package/dest/worker.d.ts +2 -0
  135. package/dest/worker.d.ts.map +1 -0
  136. package/dest/worker.js +92 -0
  137. package/package.json +115 -0
  138. package/src/bin/check_txe_oracle_version.ts +31 -0
  139. package/src/bin/index.ts +49 -0
  140. package/src/bin/oracle_test_server.ts +51 -0
  141. package/src/constants.ts +13 -0
  142. package/src/dispatcher_pool.ts +319 -0
  143. package/src/index.ts +152 -0
  144. package/src/msgpackr_fr_extension.ts +22 -0
  145. package/src/oracle/interfaces.ts +125 -0
  146. package/src/oracle/noir-structs/gas_settings_data.ts +16 -0
  147. package/src/oracle/noir-structs/tx_effects_data.ts +11 -0
  148. package/src/oracle/tagging_secret_strategy.ts +25 -0
  149. package/src/oracle/test-resolver/default_fixtures.ts +278 -0
  150. package/src/oracle/test-resolver/index.ts +43 -0
  151. package/src/oracle/test-resolver/resolver.ts +245 -0
  152. package/src/oracle/txe_oracle_public_context.ts +220 -0
  153. package/src/oracle/txe_oracle_registry.ts +501 -0
  154. package/src/oracle/txe_oracle_top_level_context.ts +1086 -0
  155. package/src/oracle/txe_oracle_version.ts +17 -0
  156. package/src/oracle/txe_private_execution_oracle.ts +30 -0
  157. package/src/rpc_server.ts +86 -0
  158. package/src/rpc_translator.ts +1229 -0
  159. package/src/state_machine/archiver.ts +118 -0
  160. package/src/state_machine/dummy_p2p_client.ts +264 -0
  161. package/src/state_machine/global_variable_builder.ts +39 -0
  162. package/src/state_machine/index.ts +152 -0
  163. package/src/state_machine/mock_epoch_cache.ts +111 -0
  164. package/src/state_machine/synchronizer.ts +105 -0
  165. package/src/txe_session.ts +1107 -0
  166. package/src/utils/block_creation.ts +91 -0
  167. package/src/utils/encoding.ts +171 -0
  168. package/src/utils/expected_failure_error.ts +5 -0
  169. package/src/utils/tx_effect_creation.ts +28 -0
  170. package/src/utils/txe_account_store.ts +23 -0
  171. package/src/utils/txe_artifact_resolver.ts +217 -0
  172. package/src/utils/txe_public_contract_data_source.ts +60 -0
  173. package/src/worker.ts +98 -0
@@ -0,0 +1,697 @@
1
+ import { BlockNumber } from '@aztec-labs/foundation/branded-types';
2
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
3
+ import { createLogger } from '@aztec-labs/foundation/log';
4
+ import { KeyStore } from '@aztec-labs/key-store';
5
+ import { openEphemeralStore } from '@aztec-labs/kv-store/lmdb-v2';
6
+ import { AddressStore, AnchorBlockStore, AnchoredContractData, CapsuleService, CapsuleStore, FactService, FactStore, NoteService, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderTaggingStore, StagedWriteCoordinator, TaggingSecretSourcesStore, composeHooks, runOperation } from '@aztec-labs/pxe/server';
7
+ import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, LEGACY_ORACLE_REGISTRY, Option, TransientArrayService, UtilityExecutionOracle, buildACIRCallback } from '@aztec-labs/pxe/simulator';
8
+ import { ExecutionError, WASMSimulator, createSimulationError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness } from '@aztec-labs/simulator/client';
9
+ import { STANDARD_AUTH_REGISTRY_ADDRESS } from '@aztec-labs/standard-contracts/auth-registry/constants';
10
+ import { FunctionSelector, FunctionType } from '@aztec-labs/stdlib/abi';
11
+ import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
12
+ import { GasSettings } from '@aztec-labs/stdlib/gas';
13
+ import { computeProtocolNullifier } from '@aztec-labs/stdlib/hash';
14
+ import { makeGlobalVariables } from '@aztec-labs/stdlib/testing';
15
+ import { CallContext, OFFCHAIN_MESSAGE_IDENTIFIER, TxContext } from '@aztec-labs/stdlib/tx';
16
+ import { z } from 'zod';
17
+ import { DEFAULT_ADDRESS } from './constants.js';
18
+ import { makeResolveTaggingSecretStrategyHook } from './oracle/tagging_secret_strategy.js';
19
+ import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
20
+ import { callTxeLegacyHandler } from './oracle/txe_oracle_registry.js';
21
+ import { TXEOracleTopLevelContext, authorizeAllUtilityCallsHook } from './oracle/txe_oracle_top_level_context.js';
22
+ import { TXE_ORACLE_VERSION_MAJOR, TXE_ORACLE_VERSION_MINOR } from './oracle/txe_oracle_version.js';
23
+ import { TXEPrivateExecutionOracle } from './oracle/txe_private_execution_oracle.js';
24
+ import { RPCTranslator, UnavailableOracleError } from './rpc_translator.js';
25
+ import { TXEArchiver } from './state_machine/archiver.js';
26
+ import { TXEStateMachine } from './state_machine/index.js';
27
+ import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
28
+ import { makeTxEffect } from './utils/tx_effect_creation.js';
29
+ import { TXEAccountStore } from './utils/txe_account_store.js';
30
+ function emptyLastCallState() {
31
+ return {
32
+ offchainEffects: [],
33
+ queried: false,
34
+ txHash: Option.none(),
35
+ anchorBlockTimestamp: 0n
36
+ };
37
+ }
38
+ /**
39
+ * A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
40
+ * state, etc., independent of all other tests running in parallel.
41
+ */ export class TXESession {
42
+ state = {
43
+ name: 'TOP_LEVEL'
44
+ };
45
+ authwits = new Map();
46
+ taggingSecretStrategies = new Map();
47
+ authorizeAllUtilityCallTargets = false;
48
+ lastCallInfo = emptyLastCallState();
49
+ txeOracleVersion;
50
+ disposed = false;
51
+ logger;
52
+ sessionStore;
53
+ stateMachine;
54
+ oracleHandler;
55
+ contractStore;
56
+ noteStore;
57
+ keyStore;
58
+ addressStore;
59
+ accountStore;
60
+ senderTaggingStore;
61
+ recipientTaggingStore;
62
+ taggingSecretSourcesStore;
63
+ capsuleStore;
64
+ factStore;
65
+ privateEventStore;
66
+ stagedWriteCoordinator;
67
+ operationContributors;
68
+ currentChangeSetId;
69
+ chainId;
70
+ version;
71
+ nextBlockTimestamp;
72
+ artifactResolver;
73
+ rootPath;
74
+ packageName;
75
+ constructor(args){
76
+ this.logger = args.logger;
77
+ this.sessionStore = args.sessionStore;
78
+ this.stateMachine = args.stateMachine;
79
+ this.oracleHandler = args.oracleHandler;
80
+ this.contractStore = args.contractStore;
81
+ this.noteStore = args.noteStore;
82
+ this.keyStore = args.keyStore;
83
+ this.addressStore = args.addressStore;
84
+ this.accountStore = args.accountStore;
85
+ this.senderTaggingStore = args.senderTaggingStore;
86
+ this.recipientTaggingStore = args.recipientTaggingStore;
87
+ this.taggingSecretSourcesStore = args.taggingSecretSourcesStore;
88
+ this.capsuleStore = args.capsuleStore;
89
+ this.factStore = args.factStore;
90
+ this.privateEventStore = args.privateEventStore;
91
+ this.stagedWriteCoordinator = args.stagedWriteCoordinator;
92
+ this.operationContributors = args.operationContributors;
93
+ this.currentChangeSetId = args.currentChangeSetId;
94
+ this.chainId = args.chainId;
95
+ this.version = args.version;
96
+ this.nextBlockTimestamp = args.nextBlockTimestamp;
97
+ this.artifactResolver = args.artifactResolver;
98
+ this.rootPath = args.rootPath;
99
+ this.packageName = args.packageName;
100
+ }
101
+ /**
102
+ * Tears down the per-session AVM simulator (process pool + CDB server), the `NativeWorldStateService`,
103
+ * and the `txe-session` LMDB. Called via IPC when the dispatcher detects the end of a test. Idempotent.
104
+ */ async dispose() {
105
+ if (this.disposed) {
106
+ return;
107
+ }
108
+ this.disposed = true;
109
+ // Dispose the AVM pool before the world state: it kills the bb-avm-sim processes so they release their
110
+ // connection to the WSDB server, letting it shut down cleanly. Skipping this leaks a bb-avm-sim process
111
+ // (and keeps its WSDB alive) per session.
112
+ try {
113
+ await this.stateMachine.synchronizer.closeIpc();
114
+ } catch (err) {
115
+ this.logger.warn(`Error closing AVM simulator during session dispose`, err);
116
+ }
117
+ try {
118
+ await this.stateMachine.synchronizer.nativeWorldStateService.close();
119
+ } catch (err) {
120
+ this.logger.warn(`Error closing native world state during session dispose`, err);
121
+ }
122
+ try {
123
+ await this.sessionStore.close();
124
+ } catch (err) {
125
+ this.logger.warn(`Error closing session LMDB during dispose`, err);
126
+ }
127
+ }
128
+ static async init(contractStore, artifactResolver, rootPath, packageName) {
129
+ // Size LMDB's reader slots to the libuv pool (capped to 2 in bin/index.ts via
130
+ // HARDWARE_CONCURRENCY): each native LMDB read needs a libuv worker thread to run, so any
131
+ // slot beyond the pool size would sit idle while still consuming a semaphore + reader-table
132
+ // entry per session.
133
+ const store = await openEphemeralStore('txe-session', undefined, 2);
134
+ const addressStore = new AddressStore(store);
135
+ const privateEventStore = new PrivateEventStore(store);
136
+ const noteStore = new NoteStore(store);
137
+ const senderTaggingStore = new SenderTaggingStore(store);
138
+ const recipientTaggingStore = new RecipientTaggingStore(store);
139
+ const taggingSecretSourcesStore = new TaggingSecretSourcesStore(store);
140
+ const capsuleStore = new CapsuleStore(store);
141
+ const factStore = new FactStore(store);
142
+ const keyStore = new KeyStore(store);
143
+ const accountStore = new TXEAccountStore(store);
144
+ const archiver = new TXEArchiver(store);
145
+ const anchorBlockStore = new AnchorBlockStore(store);
146
+ const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
147
+ const stagedWriteCoordinator = new StagedWriteCoordinator({
148
+ kvStore: store,
149
+ stagedStores: [
150
+ capsuleStore,
151
+ factStore,
152
+ senderTaggingStore,
153
+ recipientTaggingStore,
154
+ privateEventStore,
155
+ noteStore
156
+ ]
157
+ });
158
+ const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
159
+ const version = new Fr(await stateMachine.node.getVersion());
160
+ const chainId = new Fr(await stateMachine.node.getChainId());
161
+ const logger = createLogger('txe:session');
162
+ const initialChangeSetId = stagedWriteCoordinator.begin();
163
+ const topLevelOracleHandler = new TXEOracleTopLevelContext({
164
+ stateMachine,
165
+ contractStore,
166
+ noteStore,
167
+ keyStore,
168
+ addressStore,
169
+ accountStore,
170
+ senderTaggingStore,
171
+ recipientTaggingStore,
172
+ taggingSecretSourcesStore,
173
+ capsuleStore,
174
+ factStore,
175
+ privateEventStore,
176
+ nextBlockTimestamp,
177
+ chainId,
178
+ version,
179
+ authwits: new Map(),
180
+ taggingSecretStrategies: new Map(),
181
+ authorizeAllUtilityCallTargets: false,
182
+ artifactResolver,
183
+ rootPath,
184
+ packageName
185
+ });
186
+ await topLevelOracleHandler.mineDeploymentNullifiers([
187
+ STANDARD_AUTH_REGISTRY_ADDRESS
188
+ ]);
189
+ return new TXESession({
190
+ logger,
191
+ sessionStore: store,
192
+ stateMachine,
193
+ oracleHandler: topLevelOracleHandler,
194
+ contractStore,
195
+ noteStore,
196
+ keyStore,
197
+ addressStore,
198
+ accountStore,
199
+ senderTaggingStore,
200
+ recipientTaggingStore,
201
+ taggingSecretSourcesStore,
202
+ capsuleStore,
203
+ factStore,
204
+ privateEventStore,
205
+ stagedWriteCoordinator,
206
+ operationContributors: [
207
+ stateMachine.contractSyncService
208
+ ],
209
+ currentChangeSetId: initialChangeSetId,
210
+ chainId,
211
+ version,
212
+ nextBlockTimestamp,
213
+ artifactResolver,
214
+ rootPath,
215
+ packageName
216
+ });
217
+ }
218
+ /**
219
+ * Processes an oracle function invoked by the Noir test associated to this session.
220
+ * @param functionName The name of the oracle.
221
+ * @param inputs The inputs of the oracle.
222
+ * @returns The oracle return values.
223
+ */ processFunction(functionName, inputs) {
224
+ try {
225
+ // Oracles retired into the PXE legacy registry have no translator method; dispatch them through the same
226
+ // buildACIRCallback legacy path that contract execution uses, keeping TXE's two oracle paths in sync.
227
+ // Use an own-property check: `in` would match inherited `Object.prototype` keys (e.g. `constructor`), routing
228
+ // them into the legacy path instead of letting them fall through to the unknown-oracle error.
229
+ if (Object.hasOwn(LEGACY_ORACLE_REGISTRY, functionName)) {
230
+ return callTxeLegacyHandler(functionName, inputs, this.oracleHandler);
231
+ }
232
+ const translator = new RPCTranslator(this, this.oracleHandler);
233
+ // We perform a runtime validation to check that the function name corresponds to a real oracle handler.
234
+ const validatedFunctionName = z.string().refine((fn)=>typeof translator[fn] === 'function' && !fn.startsWith('handlerAs') && fn !== 'constructor').parse(functionName);
235
+ return translator[validatedFunctionName](...inputs);
236
+ } catch (error) {
237
+ if (error instanceof z.ZodError) {
238
+ let versionHint;
239
+ if (!this.txeOracleVersion) {
240
+ versionHint = ' The test appears to use an older version of Aztec.nr that does not' + ' support test environment oracle versioning. Update Aztec.nr to a compatible version.' + ' See https://docs.aztec.network/errors/12';
241
+ } else if (this.txeOracleVersion.minor > TXE_ORACLE_VERSION_MINOR) {
242
+ versionHint = ` The test uses Aztec.nr test oracle version` + ` ${this.txeOracleVersion.major}.${this.txeOracleVersion.minor}, but this test environment` + ` only supports up to ${TXE_ORACLE_VERSION_MAJOR}.${TXE_ORACLE_VERSION_MINOR}.` + ` Upgrade the Aztec CLI to a compatible version.` + ` See https://docs.aztec.network/errors/12`;
243
+ } else {
244
+ versionHint = ` The test's oracle version (${this.txeOracleVersion.major}.${this.txeOracleVersion.minor})` + ` is compatible with this test environment` + ` (${TXE_ORACLE_VERSION_MAJOR}.${TXE_ORACLE_VERSION_MINOR}), so this oracle should be` + ` available. This is an unexpected error, please report it.` + ` See https://docs.aztec.network/errors/13`;
245
+ }
246
+ throw new Error(`Unknown oracle '${functionName}'.${versionHint}`);
247
+ } else if (error instanceof Error) {
248
+ throw new Error(`Execution error while processing function ${functionName} in state ${this.state.name}: ${error.message}`);
249
+ } else {
250
+ throw new Error(`Unknown execution error while processing function ${functionName} in state ${this.state.name}`);
251
+ }
252
+ }
253
+ }
254
+ /** Ends the current operation (committing its change set, or discarding it on failure) and begins a new one. */ async cycleOperation() {
255
+ const operationArgs = {
256
+ stagedWriteCoordinator: this.stagedWriteCoordinator,
257
+ contributors: this.operationContributors,
258
+ changeSetId: this.currentChangeSetId,
259
+ log: this.logger
260
+ };
261
+ try {
262
+ // The operation's work already happened through the session's oracles, so there is nothing left to run.
263
+ await runOperation(operationArgs, ()=>Promise.resolve());
264
+ } finally{
265
+ this.currentChangeSetId = this.stagedWriteCoordinator.begin();
266
+ }
267
+ return this.currentChangeSetId;
268
+ }
269
+ resetLastCall() {
270
+ const notQueriedMessageCount = this.lastCallInfo.queried ? 0 : this.lastCallInfo.offchainEffects.filter((payload)=>payload[0]?.equals(OFFCHAIN_MESSAGE_IDENTIFIER)).length;
271
+ if (notQueriedMessageCount > 0) {
272
+ this.logger.warn(`Dropping ${notQueriedMessageCount} unqueried offchain message(s) from the previous top-level call. ` + `To deliver them, call \`env.offchain_messages()\` and forward the result to the recipient contract's ` + `\`offchain_receive\` utility before issuing another top-level call. To intentionally discard, assign ` + `to \`let _ = env.offchain_messages()\` to silence this warning.`);
273
+ }
274
+ this.lastCallInfo = emptyLastCallState();
275
+ }
276
+ recordOffchainEffect(data) {
277
+ this.lastCallInfo.offchainEffects.push(data);
278
+ }
279
+ setLastCallContext(txHash, anchorBlockTimestamp) {
280
+ this.lastCallInfo.txHash = txHash;
281
+ this.lastCallInfo.anchorBlockTimestamp = anchorBlockTimestamp;
282
+ }
283
+ async withTopLevelCallTracking(work) {
284
+ this.resetLastCall();
285
+ // Capture the anchor *before* `work` runs: private/public executor calls mine a new block as a
286
+ // side effect, and that block's timestamp should not be attributed to this call's anchor.
287
+ const anchorBlockTimestamp = (await this.stateMachine.node.getBlockData('latest')).header.globalVariables.timestamp;
288
+ const { result, txHash } = await work();
289
+ this.setLastCallContext(txHash ? Option.some(txHash) : Option.none(), anchorBlockTimestamp);
290
+ return result;
291
+ }
292
+ getLastCallOffchainEffects() {
293
+ this.lastCallInfo.queried = true;
294
+ const effects = this.lastCallInfo.offchainEffects;
295
+ return effects;
296
+ }
297
+ getLastCallContext() {
298
+ const { txHash, anchorBlockTimestamp } = this.lastCallInfo;
299
+ return {
300
+ txHash,
301
+ anchorBlockTimestamp
302
+ };
303
+ }
304
+ async executePrivateCall(from, targetContractAddress, functionSelector, args, argsHash, isStaticCall, additionalScopes, authorizedUtilityCallTargets, gasSettings) {
305
+ const handler = this.handlerAsTxe();
306
+ return await this.withTopLevelCallTracking(async ()=>{
307
+ const { returnValues, offchainEffects } = await handler.privateCallNewFlow(from?.value, targetContractAddress, functionSelector, args, argsHash, isStaticCall, additionalScopes, this.currentChangeSetId, authorizedUtilityCallTargets, GasSettings.from(gasSettings));
308
+ // Private execution collects offchain effects inside PXE's PrivateExecutionOracle rather than round-tripping
309
+ // them through `aztec_utl_emitOffchainEffect`, so the session buffer is empty at this point. Drain the effects
310
+ // from the execution tree into the session buffer so the next `env.offchain_messages()` call in the test sees
311
+ // them.
312
+ for (const data of offchainEffects){
313
+ this.recordOffchainEffect(data);
314
+ }
315
+ await this.cycleOperation();
316
+ if (isStaticCall) {
317
+ // Static calls revert their checkpoint and mine no block, so there is no tx hash to tag offchain effects
318
+ // with. Querying `getLastTxEffects()` here would return an unrelated predecessor tx.
319
+ return {
320
+ result: returnValues
321
+ };
322
+ }
323
+ const { txHash } = await handler.getLastTxEffects();
324
+ return {
325
+ result: returnValues,
326
+ txHash: txHash.hash
327
+ };
328
+ });
329
+ }
330
+ async executeUtilityFunction(from, targetContractAddress, functionSelector, args, authorizedUtilityCallTargets) {
331
+ const handler = this.handlerAsTxe();
332
+ return await this.withTopLevelCallTracking(async ()=>{
333
+ const returnValues = await handler.executeUtilityFunction(from?.value, targetContractAddress, functionSelector, args, this.currentChangeSetId, authorizedUtilityCallTargets);
334
+ await this.cycleOperation();
335
+ return {
336
+ result: returnValues
337
+ };
338
+ });
339
+ }
340
+ async executePublicCall(from, targetContractAddress, calldata, isStaticCall, gasSettings) {
341
+ const handler = this.handlerAsTxe();
342
+ return await this.withTopLevelCallTracking(async ()=>{
343
+ const returnValues = await handler.publicCallNewFlow(from?.value, targetContractAddress, calldata, isStaticCall, GasSettings.from(gasSettings));
344
+ await this.cycleOperation();
345
+ if (isStaticCall) {
346
+ // See the equivalent branch in `executePrivateCall`.
347
+ return {
348
+ result: returnValues
349
+ };
350
+ }
351
+ const { txHash } = await handler.getLastTxEffects();
352
+ return {
353
+ result: returnValues,
354
+ txHash: txHash.hash
355
+ };
356
+ });
357
+ }
358
+ async getPrivateEvents(selector, contractAddress, scope) {
359
+ const handler = this.handlerAsTxe();
360
+ await handler.syncContractNonOracleMethod(contractAddress, scope, this.currentChangeSetId);
361
+ // Cycle the change set to commit the stores after the contract sync.
362
+ await this.cycleOperation();
363
+ return handler.getPrivateEvents(selector, contractAddress, scope);
364
+ }
365
+ handlerAsTxe() {
366
+ if (!('isTxe' in this.oracleHandler)) {
367
+ throw new UnavailableOracleError('Txe');
368
+ }
369
+ return this.oracleHandler;
370
+ }
371
+ setTxeOracleVersion(major, minor) {
372
+ if (major !== TXE_ORACLE_VERSION_MAJOR) {
373
+ const hint = major > TXE_ORACLE_VERSION_MAJOR ? 'The test was compiled with a newer version of Aztec.nr than your test environment supports. Upgrade your test environment to a compatible version.' : 'The test was compiled with an older version of Aztec.nr than your test environment supports. Recompile the test with a compatible version of Aztec.nr.';
374
+ throw new Error(`Incompatible test environment version: ${hint} See https://docs.aztec.network/errors/12 (expected test oracle major version ${TXE_ORACLE_VERSION_MAJOR}, got ${major})`);
375
+ }
376
+ this.txeOracleVersion = {
377
+ major,
378
+ minor
379
+ };
380
+ this.logger.debug(`Test compiled with test oracle version ${major}.${minor}`);
381
+ }
382
+ async enterTopLevelState() {
383
+ switch(this.state.name){
384
+ case 'PRIVATE':
385
+ {
386
+ await this.exitPrivateState();
387
+ break;
388
+ }
389
+ case 'PUBLIC':
390
+ {
391
+ await this.exitPublicState();
392
+ break;
393
+ }
394
+ case 'UTILITY':
395
+ {
396
+ this.exitUtilityContext();
397
+ break;
398
+ }
399
+ case 'TOP_LEVEL':
400
+ {
401
+ throw new Error(`Expected to be in state other than TOP_LEVEL`);
402
+ }
403
+ default:
404
+ {
405
+ this.state;
406
+ }
407
+ }
408
+ // Commit all staged stores from the change set that was just completed, then begin a new change set
409
+ await this.cycleOperation();
410
+ this.oracleHandler = new TXEOracleTopLevelContext({
411
+ stateMachine: this.stateMachine,
412
+ contractStore: this.contractStore,
413
+ noteStore: this.noteStore,
414
+ keyStore: this.keyStore,
415
+ addressStore: this.addressStore,
416
+ accountStore: this.accountStore,
417
+ senderTaggingStore: this.senderTaggingStore,
418
+ recipientTaggingStore: this.recipientTaggingStore,
419
+ taggingSecretSourcesStore: this.taggingSecretSourcesStore,
420
+ capsuleStore: this.capsuleStore,
421
+ factStore: this.factStore,
422
+ privateEventStore: this.privateEventStore,
423
+ nextBlockTimestamp: this.nextBlockTimestamp,
424
+ chainId: this.chainId,
425
+ version: this.version,
426
+ authwits: this.authwits,
427
+ taggingSecretStrategies: this.taggingSecretStrategies,
428
+ authorizeAllUtilityCallTargets: this.authorizeAllUtilityCallTargets,
429
+ artifactResolver: this.artifactResolver,
430
+ rootPath: this.rootPath,
431
+ packageName: this.packageName
432
+ });
433
+ this.state = {
434
+ name: 'TOP_LEVEL'
435
+ };
436
+ this.logger.debug(`Entered state ${this.state.name}`);
437
+ }
438
+ async enterPrivateState(contractAddressOpt, anchorBlockNumberOpt, gasSettings) {
439
+ const contractAddress = contractAddressOpt?.value ?? DEFAULT_ADDRESS;
440
+ const anchorBlockNumber = anchorBlockNumberOpt?.value;
441
+ this.exitTopLevelState();
442
+ this.resetLastCall();
443
+ // Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
444
+ // build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
445
+ // a single transaction with the effects of what was done in the test.
446
+ const anchorBlock = await this.stateMachine.node.getBlock(anchorBlockNumber ?? 'latest').then((b)=>b?.header);
447
+ await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock, this.currentChangeSetId).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
448
+ const latestBlock = await this.stateMachine.node.getBlock('latest').then((b)=>b?.header);
449
+ const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
450
+ blockNumber: BlockNumber(latestBlock.globalVariables.blockNumber + 1),
451
+ timestamp: this.nextBlockTimestamp,
452
+ version: this.version,
453
+ chainId: this.chainId
454
+ });
455
+ const txRequestHash = getSingleTxBlockRequestHash(nextBlockGlobalVariables.blockNumber);
456
+ const protocolNullifier = await computeProtocolNullifier(txRequestHash);
457
+ const noteCache = new ExecutionNoteCache(protocolNullifier);
458
+ const taggingIndexCache = new ExecutionTaggingIndexCache();
459
+ const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
460
+ const transientArrayService = new TransientArrayService();
461
+ const anchoredContractData = new AnchoredContractData(this.contractStore, this.stateMachine.contractClassService, anchorBlock);
462
+ this.oracleHandler = new TXEPrivateExecutionOracle({
463
+ argsHash: Fr.ZERO,
464
+ txContext: new TxContext(this.chainId, this.version, GasSettings.from(gasSettings)),
465
+ txRequestSalt: Fr.ZERO,
466
+ callContext: new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
467
+ anchorBlockHeader: anchorBlock,
468
+ utilityExecutor,
469
+ authWitnesses: [],
470
+ capsules: [],
471
+ executionCache: new HashedValuesCache(),
472
+ noteCache,
473
+ taggingIndexCache,
474
+ anchoredContractData,
475
+ noteStore: this.noteStore,
476
+ keyStore: this.keyStore,
477
+ addressStore: this.addressStore,
478
+ aztecNode: this.stateMachine.node,
479
+ senderTaggingStore: this.senderTaggingStore,
480
+ recipientTaggingStore: this.recipientTaggingStore,
481
+ taggingSecretSourcesStore: this.taggingSecretSourcesStore,
482
+ capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
483
+ factService: new FactService(this.factStore, await this.keyStore.getAccounts()),
484
+ privateEventStore: this.privateEventStore,
485
+ contractSyncService: this.stateMachine.contractSyncService,
486
+ l2TipsStore: this.stateMachine.l2TipsProvider,
487
+ changeSetId: this.currentChangeSetId,
488
+ scopes: await this.keyStore.getAccounts(),
489
+ txResolver: this.stateMachine.txResolver,
490
+ simulator: new WASMSimulator(),
491
+ hooks: this.buildExecutionHooks(),
492
+ transientArrayService
493
+ });
494
+ // We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
495
+ // data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
496
+ // difference resides in that the simulator has all information needed in order to run the simulation, while ours
497
+ // will be ongoing as the different oracles will be invoked from the Noir test, until eventually the private
498
+ // execution finishes.
499
+ this.state = {
500
+ name: 'PRIVATE',
501
+ nextBlockGlobalVariables,
502
+ noteCache,
503
+ taggingIndexCache
504
+ };
505
+ this.logger.debug(`Entered state ${this.state.name}`);
506
+ // Record the *resolved* anchor's timestamp — if the caller pinned the anchor to a past block
507
+ // via `anchorBlockNumber`, "latest" would be the wrong anchor for offchain-message semantics.
508
+ this.setLastCallContext(Option.none(), anchorBlock.globalVariables.timestamp);
509
+ return this.oracleHandler.getPrivateContextInputs();
510
+ }
511
+ async enterPublicState(contractAddressOpt) {
512
+ const contractAddress = contractAddressOpt?.value ?? DEFAULT_ADDRESS;
513
+ this.exitTopLevelState();
514
+ this.resetLastCall();
515
+ // The PublicContext will create a block with a single transaction in it, containing the effects of what was done in
516
+ // the test. The block therefore gets the *next* block number and timestamp.
517
+ const latestHeader = (await this.stateMachine.node.getBlockData('latest')).header;
518
+ const globalVariables = makeGlobalVariables(undefined, {
519
+ blockNumber: BlockNumber(latestHeader.globalVariables.blockNumber + 1),
520
+ timestamp: this.nextBlockTimestamp,
521
+ version: this.version,
522
+ chainId: this.chainId
523
+ });
524
+ this.oracleHandler = new TXEOraclePublicContext(contractAddress, await this.stateMachine.synchronizer.nativeWorldStateService.fork(), getSingleTxBlockRequestHash(globalVariables.blockNumber), globalVariables, this.contractStore);
525
+ this.state = {
526
+ name: 'PUBLIC'
527
+ };
528
+ this.logger.debug(`Entered state ${this.state.name}`);
529
+ // Public state is anchored at the latest block.
530
+ this.setLastCallContext(Option.none(), latestHeader.globalVariables.timestamp);
531
+ }
532
+ async enterUtilityState(contractAddressOpt) {
533
+ const contractAddress = contractAddressOpt?.value ?? DEFAULT_ADDRESS;
534
+ this.exitTopLevelState();
535
+ this.resetLastCall();
536
+ const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
537
+ // There is no automatic message discovery and contract-driven syncing process in inlined private or utility
538
+ // contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
539
+ // we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
540
+ // be removed from the database.
541
+ // TODO(#12553): make the synchronizer sync here instead and remove this
542
+ await new NoteService(this.noteStore, this.stateMachine.node, anchorBlockHeader, this.currentChangeSetId).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
543
+ this.oracleHandler = new UtilityExecutionOracle({
544
+ callContext: CallContext.from({
545
+ msgSender: AztecAddress.NULL_MSG_SENDER,
546
+ contractAddress,
547
+ // No specific function is being executed in this inlined utility context, hence the empty selector.
548
+ functionSelector: FunctionSelector.empty(),
549
+ isStaticCall: true
550
+ }),
551
+ authWitnesses: [],
552
+ capsules: [],
553
+ anchorBlockHeader,
554
+ anchoredContractData: new AnchoredContractData(this.contractStore, this.stateMachine.contractClassService, anchorBlockHeader),
555
+ noteStore: this.noteStore,
556
+ keyStore: this.keyStore,
557
+ addressStore: this.addressStore,
558
+ aztecNode: this.stateMachine.node,
559
+ recipientTaggingStore: this.recipientTaggingStore,
560
+ taggingSecretSourcesStore: this.taggingSecretSourcesStore,
561
+ capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
562
+ factService: new FactService(this.factStore, await this.keyStore.getAccounts()),
563
+ privateEventStore: this.privateEventStore,
564
+ txResolver: this.stateMachine.txResolver,
565
+ contractSyncService: this.stateMachine.contractSyncService,
566
+ l2TipsStore: this.stateMachine.l2TipsProvider,
567
+ changeSetId: this.currentChangeSetId,
568
+ scopes: await this.keyStore.getAccounts(),
569
+ simulator: new WASMSimulator(),
570
+ utilityExecutor: this.utilityExecutorForContractSync(anchorBlockHeader),
571
+ hooks: this.buildExecutionHooks(),
572
+ // Execution-tree root (top-level utility run): own store; nested frames inherit it.
573
+ transientArrayService: new TransientArrayService()
574
+ });
575
+ this.state = {
576
+ name: 'UTILITY'
577
+ };
578
+ this.logger.debug(`Entered state ${this.state.name}`);
579
+ // Utility state anchors at whatever the anchor block store is pointing to (tracked as latest).
580
+ this.setLastCallContext(Option.none(), anchorBlockHeader.globalVariables.timestamp);
581
+ }
582
+ exitTopLevelState() {
583
+ if (this.state.name != 'TOP_LEVEL') {
584
+ throw new Error(`Expected to be in state 'TOP_LEVEL', but got '${this.state.name}' instead`);
585
+ }
586
+ // Note that while all public and private contexts do is build a single block that we then process when exiting
587
+ // them, the top level context does most of its work as it goes: it creates empty blocks (via `advanceBlocksBy`
588
+ // and `deploy`), creates blocks with transactions (via `privateCallNewFlow` and `publicCallNewFlow`), adds
589
+ // accounts to PXE (via `addAccount`), etc. This is a slight inconsistency in the working model of this class, but
590
+ // is not too bad. The `close` call below therefore only hands back the session-scoped values that a test
591
+ // sets directly at the top level, outside any contract execution (e.g. via `advanceTimestampBy`,
592
+ // `addAuthWitness`, `setTaggingSecretStrategies`). The oracle handler is discarded on every state transition,
593
+ // so the session must seed these values into the contexts it creates later.
594
+ // TODO: persisting authwits this way is quite unfortunate: they create a temporary utility context that would
595
+ // otherwise reset them, so we'd not be able to pass more than one per execution. Ideally authwits would be passed
596
+ // alongside a contract call instead of pre-seeded.
597
+ ({ nextBlockTimestamp: this.nextBlockTimestamp, authwits: this.authwits, taggingSecretStrategies: this.taggingSecretStrategies, authorizeAllUtilityCallTargets: this.authorizeAllUtilityCallTargets } = this.oracleHandler.close());
598
+ }
599
+ async exitPrivateState() {
600
+ if (this.state.name != 'PRIVATE') {
601
+ throw new Error(`Expected to be in state 'PRIVATE', but got '${this.state.name}' instead`);
602
+ }
603
+ this.logger.debug('Exiting Private state, building block with collected side effects', {
604
+ blockNumber: this.state.nextBlockGlobalVariables.blockNumber
605
+ });
606
+ // We rely on the note cache to determine the effects of the transaction. This is incomplete as it doesn't private
607
+ // logs (other effects like enqueued public calls don't need to be considered since those are not allowed).
608
+ const txEffect = await makeTxEffect(this.state.noteCache, this.state.nextBlockGlobalVariables.blockNumber);
609
+ // We build a block holding just this transaction
610
+ const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
611
+ await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
612
+ const block = await makeTXEBlock(forkedWorldTrees, this.state.nextBlockGlobalVariables, [
613
+ txEffect
614
+ ]);
615
+ await this.stateMachine.handleL2Block(block);
616
+ await forkedWorldTrees.close();
617
+ this.logger.debug('Exited PublicContext with built block', {
618
+ blockNumber: block.number,
619
+ txEffects: block.body.txEffects
620
+ });
621
+ }
622
+ async exitPublicState() {
623
+ if (this.state.name != 'PUBLIC') {
624
+ throw new Error(`Expected to be in state 'PUBLIC', but got '${this.state.name}' instead`);
625
+ }
626
+ const block = await this.oracleHandler.close();
627
+ await this.stateMachine.handleL2Block(block);
628
+ }
629
+ exitUtilityContext() {
630
+ if (this.state.name != 'UTILITY') {
631
+ throw new Error(`Expected to be in state 'UTILITY', but got '${this.state.name}' instead`);
632
+ }
633
+ }
634
+ utilityExecutorForContractSync(anchorBlock) {
635
+ return async (call, scopes)=>{
636
+ const anchoredContractData = new AnchoredContractData(this.contractStore, this.stateMachine.contractClassService, anchorBlock);
637
+ const entryPointArtifact = await anchoredContractData.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
638
+ if (!entryPointArtifact) {
639
+ throw new Error(`Cannot run function ${call.selector} on ${call.to}: the contract is not registered.`);
640
+ }
641
+ if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
642
+ throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
643
+ }
644
+ try {
645
+ const simulator = new WASMSimulator();
646
+ const oracle = new UtilityExecutionOracle({
647
+ callContext: CallContext.from({
648
+ msgSender: AztecAddress.NULL_MSG_SENDER,
649
+ contractAddress: call.to,
650
+ functionSelector: call.selector,
651
+ isStaticCall: true
652
+ }),
653
+ authWitnesses: [],
654
+ capsules: [],
655
+ anchorBlockHeader: anchorBlock,
656
+ anchoredContractData,
657
+ noteStore: this.noteStore,
658
+ keyStore: this.keyStore,
659
+ addressStore: this.addressStore,
660
+ aztecNode: this.stateMachine.node,
661
+ recipientTaggingStore: this.recipientTaggingStore,
662
+ taggingSecretSourcesStore: this.taggingSecretSourcesStore,
663
+ capsuleService: new CapsuleService(this.capsuleStore, scopes),
664
+ factService: new FactService(this.factStore, scopes),
665
+ privateEventStore: this.privateEventStore,
666
+ txResolver: this.stateMachine.txResolver,
667
+ contractSyncService: this.stateMachine.contractSyncService,
668
+ l2TipsStore: this.stateMachine.l2TipsProvider,
669
+ changeSetId: this.currentChangeSetId,
670
+ scopes,
671
+ simulator,
672
+ utilityExecutor: this.utilityExecutorForContractSync(anchorBlock),
673
+ hooks: this.buildExecutionHooks(),
674
+ // Top-level utility entrypoint: gets a fresh store. Nested frames inherit it via UtilityExecutionOracle.
675
+ transientArrayService: new TransientArrayService()
676
+ });
677
+ await simulator.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, buildACIRCallback(oracle)).catch((err)=>{
678
+ err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
679
+ throw new ExecutionError(err.message, {
680
+ contractAddress: call.to,
681
+ functionSelector: call.selector
682
+ }, extractCallStack(err, entryPointArtifact.debug), {
683
+ cause: err
684
+ });
685
+ });
686
+ } catch (err) {
687
+ throw createSimulationError(err instanceof Error ? err : new Error('Unknown error contract data sync'));
688
+ }
689
+ };
690
+ }
691
+ /** Execution hooks for the oracles this session builds. Every oracle construction site must use this. */ buildExecutionHooks() {
692
+ return composeHooks({
693
+ resolveTaggingSecretStrategy: makeResolveTaggingSecretStrategyHook(this.taggingSecretStrategies),
694
+ authorizeUtilityCall: this.authorizeAllUtilityCallTargets ? authorizeAllUtilityCallsHook : undefined
695
+ });
696
+ }
697
+ }