@aztec/txe 0.0.1-commit.0c875d939 → 0.0.1-commit.0ec55a70b

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 (60) hide show
  1. package/dest/index.d.ts +1 -1
  2. package/dest/index.d.ts.map +1 -1
  3. package/dest/index.js +88 -54
  4. package/dest/oracle/interfaces.d.ts +32 -28
  5. package/dest/oracle/interfaces.d.ts.map +1 -1
  6. package/dest/oracle/txe_oracle_public_context.d.ts +13 -13
  7. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  8. package/dest/oracle/txe_oracle_public_context.js +12 -12
  9. package/dest/oracle/txe_oracle_top_level_context.d.ts +30 -23
  10. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  11. package/dest/oracle/txe_oracle_top_level_context.js +95 -55
  12. package/dest/rpc_translator.d.ts +128 -82
  13. package/dest/rpc_translator.d.ts.map +1 -1
  14. package/dest/rpc_translator.js +464 -164
  15. package/dest/state_machine/archiver.d.ts +3 -3
  16. package/dest/state_machine/archiver.d.ts.map +1 -1
  17. package/dest/state_machine/archiver.js +12 -12
  18. package/dest/state_machine/dummy_p2p_client.d.ts +8 -6
  19. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  20. package/dest/state_machine/dummy_p2p_client.js +12 -6
  21. package/dest/state_machine/global_variable_builder.d.ts +9 -4
  22. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  23. package/dest/state_machine/global_variable_builder.js +9 -3
  24. package/dest/state_machine/index.d.ts +4 -2
  25. package/dest/state_machine/index.d.ts.map +1 -1
  26. package/dest/state_machine/index.js +8 -4
  27. package/dest/state_machine/mock_epoch_cache.d.ts +18 -3
  28. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  29. package/dest/state_machine/mock_epoch_cache.js +35 -2
  30. package/dest/state_machine/synchronizer.d.ts +5 -5
  31. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  32. package/dest/state_machine/synchronizer.js +3 -3
  33. package/dest/txe_session.d.ts +54 -6
  34. package/dest/txe_session.d.ts.map +1 -1
  35. package/dest/txe_session.js +98 -29
  36. package/dest/util/encoding.d.ts +71 -1
  37. package/dest/util/encoding.d.ts.map +1 -1
  38. package/dest/util/encoding.js +4 -0
  39. package/dest/util/txe_public_contract_data_source.d.ts +2 -3
  40. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  41. package/dest/util/txe_public_contract_data_source.js +6 -25
  42. package/package.json +15 -15
  43. package/src/index.ts +89 -52
  44. package/src/oracle/interfaces.ts +33 -32
  45. package/src/oracle/txe_oracle_public_context.ts +12 -12
  46. package/src/oracle/txe_oracle_top_level_context.ts +108 -59
  47. package/src/rpc_translator.ts +539 -196
  48. package/src/state_machine/archiver.ts +9 -9
  49. package/src/state_machine/dummy_p2p_client.ts +17 -9
  50. package/src/state_machine/global_variable_builder.ts +18 -3
  51. package/src/state_machine/index.ts +10 -2
  52. package/src/state_machine/mock_epoch_cache.ts +46 -3
  53. package/src/state_machine/synchronizer.ts +4 -4
  54. package/src/txe_session.ts +167 -32
  55. package/src/util/encoding.ts +5 -0
  56. package/src/util/txe_public_contract_data_source.ts +10 -38
  57. package/dest/util/txe_contract_store.d.ts +0 -12
  58. package/dest/util/txe_contract_store.d.ts.map +0 -1
  59. package/dest/util/txe_contract_store.js +0 -22
  60. package/src/util/txe_contract_store.ts +0 -36
@@ -1,10 +1,10 @@
1
- import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT, DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
1
+ import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
2
2
  import { BlockNumber } from '@aztec/foundation/branded-types';
3
3
  import { Schnorr } from '@aztec/foundation/crypto/schnorr';
4
4
  import { Fr } from '@aztec/foundation/curves/bn254';
5
5
  import { LogLevels, applyStringFormatting, createLogger } from '@aztec/foundation/log';
6
6
  import { TestDateProvider } from '@aztec/foundation/timer';
7
- import { ORACLE_VERSION, enrichPublicSimulationError } from '@aztec/pxe/server';
7
+ import { CapsuleService, ORACLE_VERSION_MAJOR, enrichPublicSimulationError } from '@aztec/pxe/server';
8
8
  import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, Oracle, PrivateExecutionOracle, UtilityExecutionOracle, executePrivateFunction, generateSimulatedProvingResult } from '@aztec/pxe/simulator';
9
9
  import { ExecutionError, WASMSimulator, createSimulationError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness, witnessMapToFields } from '@aztec/simulator/client';
10
10
  import { CppPublicTxSimulator, GuardedMerkleTreeOperations, PublicContractsDB, PublicProcessor } from '@aztec/simulator/server';
@@ -13,7 +13,7 @@ import { AuthWitness } from '@aztec/stdlib/auth-witness';
13
13
  import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
14
14
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
15
15
  import { computePartialAddress } from '@aztec/stdlib/contract';
16
- import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
16
+ import { FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT, Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
17
17
  import { computeCalldataHash, computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
18
18
  import { PartialPrivateTailPublicInputsForPublic, PrivateKernelTailCircuitPublicInputs, PrivateToPublicAccumulatedData, PublicCallRequest } from '@aztec/stdlib/kernel';
19
19
  import { ChonkProof } from '@aztec/stdlib/proofs';
@@ -36,7 +36,6 @@ export class TXEOracleTopLevelContext {
36
36
  senderAddressBookStore;
37
37
  capsuleStore;
38
38
  privateEventStore;
39
- jobId;
40
39
  nextBlockTimestamp;
41
40
  version;
42
41
  chainId;
@@ -44,7 +43,7 @@ export class TXEOracleTopLevelContext {
44
43
  isMisc;
45
44
  isTxe;
46
45
  logger;
47
- constructor(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, jobId, nextBlockTimestamp, version, chainId, authwits){
46
+ constructor(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, nextBlockTimestamp, version, chainId, authwits){
48
47
  this.stateMachine = stateMachine;
49
48
  this.contractStore = contractStore;
50
49
  this.noteStore = noteStore;
@@ -56,7 +55,6 @@ export class TXEOracleTopLevelContext {
56
55
  this.senderAddressBookStore = senderAddressBookStore;
57
56
  this.capsuleStore = capsuleStore;
58
57
  this.privateEventStore = privateEventStore;
59
- this.jobId = jobId;
60
58
  this.nextBlockTimestamp = nextBlockTimestamp;
61
59
  this.version = version;
62
60
  this.chainId = chainId;
@@ -66,18 +64,28 @@ export class TXEOracleTopLevelContext {
66
64
  this.logger = createLogger('txe:top_level_context');
67
65
  this.logger.debug('Entering Top Level Context');
68
66
  }
69
- utilityAssertCompatibleOracleVersion(version) {
70
- if (version !== ORACLE_VERSION) {
71
- throw new Error(`Incompatible oracle version. TXE is using version '${ORACLE_VERSION}', but got a request for '${version}'.`);
67
+ contractOracleVersion;
68
+ assertCompatibleOracleVersion(major, minor) {
69
+ if (major !== ORACLE_VERSION_MAJOR) {
70
+ const hint = major > ORACLE_VERSION_MAJOR ? 'The contract was compiled with a newer version of Aztec.nr than this aztec cli version supports. Upgrade your aztec cli version to a compatible version.' : 'The contract was compiled with an older version of Aztec.nr than this aztec cli version supports. Recompile the contract with a compatible version of Aztec.nr.';
71
+ throw new Error(`Incompatible aztec cli version: ${hint} See https://docs.aztec.network/errors/8 (expected oracle major version ${ORACLE_VERSION_MAJOR}, got ${major})`);
72
72
  }
73
+ this.contractOracleVersion = {
74
+ major,
75
+ minor
76
+ };
77
+ }
78
+ // Prefixed with "nonOracleFunction" as it is not used as an oracle handler.
79
+ nonOracleFunctionGetContractOracleVersion() {
80
+ return this.contractOracleVersion;
73
81
  }
74
82
  // This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
75
83
  // setup.
76
- utilityGetRandomField() {
84
+ getRandomField() {
77
85
  return Fr.random();
78
86
  }
79
87
  // We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
80
- utilityLog(level, message, fields) {
88
+ log(level, message, fields) {
81
89
  if (!LogLevels[level]) {
82
90
  throw new Error(`Invalid log level: ${level}`);
83
91
  }
@@ -87,19 +95,19 @@ export class TXEOracleTopLevelContext {
87
95
  });
88
96
  return Promise.resolve();
89
97
  }
90
- txeGetDefaultAddress() {
98
+ getDefaultAddress() {
91
99
  return DEFAULT_ADDRESS;
92
100
  }
93
- async txeGetNextBlockNumber() {
101
+ async getNextBlockNumber() {
94
102
  return BlockNumber(await this.getLastBlockNumber() + 1);
95
103
  }
96
- txeGetNextBlockTimestamp() {
104
+ getNextBlockTimestamp() {
97
105
  return Promise.resolve(this.nextBlockTimestamp);
98
106
  }
99
- async txeGetLastBlockTimestamp() {
107
+ async getLastBlockTimestamp() {
100
108
  return (await this.stateMachine.node.getBlockHeader('latest')).globalVariables.timestamp;
101
109
  }
102
- async txeGetLastTxEffects() {
110
+ async getLastTxEffects() {
103
111
  const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
104
112
  const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
105
113
  if (block.body.txEffects.length != 1) {
@@ -113,7 +121,19 @@ export class TXEOracleTopLevelContext {
113
121
  nullifiers: txEffects.nullifiers
114
122
  };
115
123
  }
116
- async txeGetPrivateEvents(selector, contractAddress, scope) {
124
+ async syncContractNonOracleMethod(contractAddress, scope, jobId) {
125
+ if (contractAddress.equals(DEFAULT_ADDRESS)) {
126
+ this.logger.debug(`Skipping sync in getPrivateEvents because the events correspond to the default address.`);
127
+ return;
128
+ }
129
+ const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
130
+ await this.stateMachine.contractSyncService.ensureContractSynced(contractAddress, null, async (call, execScopes)=>{
131
+ await this.executeUtilityCall(call, execScopes, jobId);
132
+ }, blockHeader, jobId, [
133
+ scope
134
+ ]);
135
+ }
136
+ async getPrivateEvents(selector, contractAddress, scope) {
117
137
  return (await this.privateEventStore.getPrivateEvents(selector, {
118
138
  contractAddress,
119
139
  scopes: [
@@ -123,17 +143,17 @@ export class TXEOracleTopLevelContext {
123
143
  toBlock: await this.getLastBlockNumber() + 1
124
144
  })).map((e)=>e.packedEvent);
125
145
  }
126
- async txeAdvanceBlocksBy(blocks) {
146
+ async advanceBlocksBy(blocks) {
127
147
  this.logger.debug(`time traveling ${blocks} blocks`);
128
148
  for(let i = 0; i < blocks; i++){
129
149
  await this.mineBlock();
130
150
  }
131
151
  }
132
- txeAdvanceTimestampBy(duration) {
152
+ advanceTimestampBy(duration) {
133
153
  this.logger.debug(`time traveling ${duration} seconds`);
134
154
  this.nextBlockTimestamp += duration;
135
155
  }
136
- async txeDeploy(artifact, instance, secret) {
156
+ async deploy(artifact, instance, secret) {
137
157
  // Emit deployment nullifier
138
158
  await this.mineBlock({
139
159
  nullifiers: [
@@ -141,25 +161,25 @@ export class TXEOracleTopLevelContext {
141
161
  ]
142
162
  });
143
163
  if (!secret.equals(Fr.ZERO)) {
144
- await this.txeAddAccount(artifact, instance, secret);
164
+ await this.addAccount(artifact, instance, secret);
145
165
  } else {
146
166
  await this.contractStore.addContractInstance(instance);
147
- await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
167
+ await this.contractStore.addContractArtifact(artifact);
148
168
  this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
149
169
  }
150
170
  }
151
- async txeAddAccount(artifact, instance, secret) {
171
+ async addAccount(artifact, instance, secret) {
152
172
  const partialAddress = await computePartialAddress(instance);
153
173
  this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
154
174
  await this.contractStore.addContractInstance(instance);
155
- await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
175
+ await this.contractStore.addContractArtifact(artifact);
156
176
  const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
157
177
  await this.accountStore.setAccount(completeAddress.address, completeAddress);
158
178
  await this.addressStore.addCompleteAddress(completeAddress);
159
179
  this.logger.debug(`Created account ${completeAddress.address}`);
160
180
  return completeAddress;
161
181
  }
162
- async txeCreateAccount(secret) {
182
+ async createAccount(secret) {
163
183
  // This is a foot gun !
164
184
  const completeAddress = await this.keyStore.addAccount(secret, secret);
165
185
  await this.accountStore.setAccount(completeAddress.address, completeAddress);
@@ -167,7 +187,7 @@ export class TXEOracleTopLevelContext {
167
187
  this.logger.debug(`Created account ${completeAddress.address}`);
168
188
  return completeAddress;
169
189
  }
170
- async txeAddAuthWitness(address, messageHash) {
190
+ async addAuthWitness(address, messageHash) {
171
191
  const account = await this.accountStore.getAccount(address);
172
192
  const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
173
193
  const schnorr = new Schnorr();
@@ -178,7 +198,7 @@ export class TXEOracleTopLevelContext {
178
198
  this.authwits.set(authWitness.requestHash.toString(), authWitness);
179
199
  }
180
200
  async mineBlock(options = {}) {
181
- const blockNumber = await this.txeGetNextBlockNumber();
201
+ const blockNumber = await this.getNextBlockNumber();
182
202
  const txEffect = TxEffect.empty();
183
203
  txEffect.nullifiers = [
184
204
  getSingleTxBlockRequestHash(blockNumber),
@@ -200,7 +220,7 @@ export class TXEOracleTopLevelContext {
200
220
  this.logger.info(`Created block ${blockNumber} with timestamp ${block.header.globalVariables.timestamp}`);
201
221
  await this.stateMachine.handleL2Block(block);
202
222
  }
203
- async txePrivateCallNewFlow(from, targetContractAddress = AztecAddress.zero(), functionSelector = FunctionSelector.empty(), args, argsHash = Fr.zero(), isStaticCall = false) {
223
+ async privateCallNewFlow(from, targetContractAddress = AztecAddress.zero(), functionSelector = FunctionSelector.empty(), args, argsHash = Fr.zero(), isStaticCall = false, jobId) {
204
224
  this.logger.verbose(`Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`);
205
225
  const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
206
226
  if (!artifact) {
@@ -214,14 +234,14 @@ export class TXEOracleTopLevelContext {
214
234
  ];
215
235
  // Sync notes before executing private function to discover notes from previous transactions
216
236
  const utilityExecutor = async (call, execScopes)=>{
217
- await this.executeUtilityCall(call, execScopes);
237
+ await this.executeUtilityCall(call, execScopes, jobId);
218
238
  };
219
239
  const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
220
- await this.stateMachine.contractSyncService.ensureContractSynced(targetContractAddress, functionSelector, utilityExecutor, blockHeader, this.jobId, effectiveScopes);
221
- const blockNumber = await this.txeGetNextBlockNumber();
240
+ await this.stateMachine.contractSyncService.ensureContractSynced(targetContractAddress, functionSelector, utilityExecutor, blockHeader, jobId, effectiveScopes);
241
+ const blockNumber = await this.getNextBlockNumber();
222
242
  const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
223
- const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
224
- const teardownGasLimits = new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT);
243
+ const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
244
+ const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
225
245
  const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
226
246
  const txContext = new TxContext(this.chainId, this.version, gasSettings);
227
247
  const protocolNullifier = await computeProtocolNullifier(getSingleTxBlockRequestHash(blockNumber));
@@ -254,17 +274,19 @@ export class TXEOracleTopLevelContext {
254
274
  senderTaggingStore: this.senderTaggingStore,
255
275
  recipientTaggingStore: this.recipientTaggingStore,
256
276
  senderAddressBookStore: this.senderAddressBookStore,
257
- capsuleStore: this.capsuleStore,
277
+ capsuleService: new CapsuleService(this.capsuleStore, effectiveScopes),
258
278
  privateEventStore: this.privateEventStore,
259
279
  contractSyncService: this.stateMachine.contractSyncService,
260
- jobId: this.jobId,
280
+ jobId,
261
281
  totalPublicCalldataCount: 0,
262
282
  sideEffectCounter: minRevertibleSideEffectCounter,
263
283
  scopes: effectiveScopes,
264
284
  // In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
265
285
  // contract would perform, including setting senderForTags.
266
286
  senderForTags: from,
267
- simulator
287
+ simulator,
288
+ messageContextService: this.stateMachine.messageContextService,
289
+ l2TipsStore: this.stateMachine.node
268
290
  });
269
291
  // Note: This is a slight modification of simulator.run without any of the checks. Maybe we should modify simulator.run with a boolean value to skip checks.
270
292
  let result;
@@ -277,7 +299,7 @@ export class TXEOracleTopLevelContext {
277
299
  r.publicInputs.publicTeardownCallRequest
278
300
  ]));
279
301
  const publicFunctionsCalldata = await Promise.all(publicCallRequests.map(async (r)=>{
280
- const calldata = await privateExecutionOracle.privateLoadFromExecutionCache(r.calldataHash);
302
+ const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
281
303
  return new HashedValues(calldata, r.calldataHash);
282
304
  }));
283
305
  noteCache.finish();
@@ -336,10 +358,20 @@ export class TXEOracleTopLevelContext {
336
358
  throw new Error('Contract execution has reverted');
337
359
  }
338
360
  }
361
+ // Walk the nested private-call tree and collect every offchain effect the transaction emitted.
362
+ // PXE stores these on each `PrivateCallExecutionResult` and they never reach TXE via the
363
+ // `aztec_utl_emitOffchainEffect` foreign-call path (that path only fires at the top-level), so
364
+ // we pull them out here and the RPC wrapper will hand them to `TXESession` for buffering.
365
+ const offchainEffects = collectNested([
366
+ executionResult
367
+ ], (r)=>r.offchainEffects.map((e)=>e.data));
339
368
  if (isStaticCall) {
340
369
  await checkpoint.revert();
341
370
  await forkedWorldTrees.close();
342
- return executionResult.returnValues ?? [];
371
+ return {
372
+ returnValues: executionResult.returnValues ?? [],
373
+ offchainEffects
374
+ };
343
375
  }
344
376
  const txEffect = TxEffect.empty();
345
377
  txEffect.noteHashes = processedTx.txEffect.noteHashes;
@@ -355,13 +387,16 @@ export class TXEOracleTopLevelContext {
355
387
  ]);
356
388
  await this.stateMachine.handleL2Block(l2Block);
357
389
  await forkedWorldTrees.close();
358
- return executionResult.returnValues ?? [];
390
+ return {
391
+ returnValues: executionResult.returnValues ?? [],
392
+ offchainEffects
393
+ };
359
394
  }
360
- async txePublicCallNewFlow(from, targetContractAddress, calldata, isStaticCall) {
395
+ async publicCallNewFlow(from, targetContractAddress, calldata, isStaticCall) {
361
396
  this.logger.verbose(`Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`);
362
- const blockNumber = await this.txeGetNextBlockNumber();
363
- const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
364
- const teardownGasLimits = new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT);
397
+ const blockNumber = await this.getNextBlockNumber();
398
+ const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
399
+ const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
365
400
  const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
366
401
  const txContext = new TxContext(this.chainId, this.version, gasSettings);
367
402
  const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
@@ -398,7 +433,7 @@ export class TXEOracleTopLevelContext {
398
433
  revertibleAccumulatedData.publicCallRequests[0] = new PublicCallRequest(from, targetContractAddress, isStaticCall, calldataHash);
399
434
  const inputsForPublic = new PartialPrivateTailPublicInputsForPublic(nonRevertibleAccumulatedData, revertibleAccumulatedData, PublicCallRequest.empty());
400
435
  const constantData = new TxConstantData(anchorBlockHeader, txContext, Fr.zero(), Fr.zero());
401
- const txData = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ new Gas(0, 0), /*feePayer=*/ AztecAddress.zero(), /*includeByTimestamp=*/ 0n, inputsForPublic, undefined);
436
+ const txData = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ new Gas(0, 0), /*feePayer=*/ AztecAddress.zero(), /*expirationTimestamp=*/ 0n, inputsForPublic, undefined);
402
437
  const tx = await Tx.create({
403
438
  data: txData,
404
439
  chonkProof: ChonkProof.empty(),
@@ -451,7 +486,7 @@ export class TXEOracleTopLevelContext {
451
486
  await forkedWorldTrees.close();
452
487
  return returnValues ?? [];
453
488
  }
454
- async txeSimulateUtilityFunction(targetContractAddress, functionSelector, args) {
489
+ async executeUtilityFunction(targetContractAddress, functionSelector, args, jobId) {
455
490
  const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
456
491
  if (!artifact) {
457
492
  throw new Error(`Cannot call ${functionSelector} as there is no artifact found at ${targetContractAddress}.`);
@@ -459,8 +494,8 @@ export class TXEOracleTopLevelContext {
459
494
  // Sync notes before executing utility function to discover notes from previous transactions
460
495
  const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
461
496
  await this.stateMachine.contractSyncService.ensureContractSynced(targetContractAddress, functionSelector, async (call, execScopes)=>{
462
- await this.executeUtilityCall(call, execScopes);
463
- }, blockHeader, this.jobId, 'ALL_SCOPES');
497
+ await this.executeUtilityCall(call, execScopes, jobId);
498
+ }, blockHeader, jobId, await this.keyStore.getAccounts());
464
499
  const call = FunctionCall.from({
465
500
  name: artifact.name,
466
501
  to: targetContractAddress,
@@ -471,9 +506,9 @@ export class TXEOracleTopLevelContext {
471
506
  args,
472
507
  returnTypes: []
473
508
  });
474
- return this.executeUtilityCall(call, 'ALL_SCOPES');
509
+ return this.executeUtilityCall(call, await this.keyStore.getAccounts(), jobId);
475
510
  }
476
- async executeUtilityCall(call, scopes) {
511
+ async executeUtilityCall(call, scopes, jobId) {
477
512
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
478
513
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
479
514
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
@@ -484,6 +519,7 @@ export class TXEOracleTopLevelContext {
484
519
  });
485
520
  try {
486
521
  const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
522
+ const simulator = new WASMSimulator();
487
523
  const oracle = new UtilityExecutionOracle({
488
524
  contractAddress: call.to,
489
525
  authWitnesses: [],
@@ -496,12 +532,16 @@ export class TXEOracleTopLevelContext {
496
532
  aztecNode: this.stateMachine.node,
497
533
  recipientTaggingStore: this.recipientTaggingStore,
498
534
  senderAddressBookStore: this.senderAddressBookStore,
499
- capsuleStore: this.capsuleStore,
535
+ capsuleService: new CapsuleService(this.capsuleStore, scopes),
500
536
  privateEventStore: this.privateEventStore,
501
- jobId: this.jobId,
502
- scopes
537
+ messageContextService: this.stateMachine.messageContextService,
538
+ contractSyncService: this.stateMachine.contractSyncService,
539
+ l2TipsStore: this.stateMachine.node,
540
+ jobId,
541
+ scopes,
542
+ simulator
503
543
  });
504
- const acirExecutionResult = await new WASMSimulator().executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
544
+ const acirExecutionResult = await simulator.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
505
545
  err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
506
546
  throw new ExecutionError(err.message, {
507
547
  contractAddress: call.to,
@@ -510,10 +550,10 @@ export class TXEOracleTopLevelContext {
510
550
  cause: err
511
551
  });
512
552
  });
513
- this.logger.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
553
+ this.logger.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
514
554
  return witnessMapToFields(acirExecutionResult.returnWitness);
515
555
  } catch (err) {
516
- throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility simulation'));
556
+ throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility execution'));
517
557
  }
518
558
  }
519
559
  close() {