@aztec/txe 0.0.1-commit.d6f2b3f94 → 0.0.1-commit.d939eb5aa

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 +29 -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 +28 -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 +130 -61
  12. package/dest/rpc_translator.d.ts +120 -82
  13. package/dest/rpc_translator.d.ts.map +1 -1
  14. package/dest/rpc_translator.js +384 -162
  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 +7 -8
  18. package/dest/state_machine/dummy_p2p_client.d.ts +10 -6
  19. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  20. package/dest/state_machine/dummy_p2p_client.js +18 -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 +10 -6
  34. package/dest/txe_session.d.ts.map +1 -1
  35. package/dest/txe_session.js +92 -24
  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 +32 -31
  45. package/src/oracle/txe_oracle_public_context.ts +12 -12
  46. package/src/oracle/txe_oracle_top_level_context.ts +142 -103
  47. package/src/rpc_translator.ts +446 -183
  48. package/src/state_machine/archiver.ts +6 -5
  49. package/src/state_machine/dummy_p2p_client.ts +25 -9
  50. package/src/state_machine/global_variable_builder.ts +18 -3
  51. package/src/state_machine/index.ts +9 -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 +97 -72
  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,9 +1,7 @@
1
1
  import {
2
2
  CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS,
3
- DEFAULT_DA_GAS_LIMIT,
4
- DEFAULT_L2_GAS_LIMIT,
5
- DEFAULT_TEARDOWN_DA_GAS_LIMIT,
6
- DEFAULT_TEARDOWN_L2_GAS_LIMIT,
3
+ MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT,
4
+ MAX_PROCESSABLE_L2_GAS,
7
5
  NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
8
6
  } from '@aztec/constants';
9
7
  import { BlockNumber } from '@aztec/foundation/branded-types';
@@ -14,9 +12,12 @@ import { TestDateProvider } from '@aztec/foundation/timer';
14
12
  import type { KeyStore } from '@aztec/key-store';
15
13
  import {
16
14
  AddressStore,
15
+ CapsuleService,
17
16
  CapsuleStore,
17
+ type ContractStore,
18
+ type ContractSyncService,
18
19
  NoteStore,
19
- ORACLE_VERSION,
20
+ ORACLE_VERSION_MAJOR,
20
21
  PrivateEventStore,
21
22
  RecipientTaggingStore,
22
23
  SenderAddressBookStore,
@@ -54,7 +55,13 @@ import { AuthWitness } from '@aztec/stdlib/auth-witness';
54
55
  import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
55
56
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
56
57
  import { type ContractInstanceWithAddress, computePartialAddress } from '@aztec/stdlib/contract';
57
- import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
58
+ import {
59
+ FALLBACK_TEARDOWN_DA_GAS_LIMIT,
60
+ FALLBACK_TEARDOWN_L2_GAS_LIMIT,
61
+ Gas,
62
+ GasFees,
63
+ GasSettings,
64
+ } from '@aztec/stdlib/gas';
58
65
  import { computeCalldataHash, computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
59
66
  import {
60
67
  PartialPrivateTailPublicInputsForPublic,
@@ -83,7 +90,6 @@ import { ForkCheckpoint } from '@aztec/world-state';
83
90
  import { DEFAULT_ADDRESS } from '../constants.js';
84
91
  import type { TXEStateMachine } from '../state_machine/index.js';
85
92
  import type { TXEAccountStore } from '../util/txe_account_store.js';
86
- import type { TXEContractStore } from '../util/txe_contract_store.js';
87
93
  import { TXEPublicContractDataSource } from '../util/txe_public_contract_data_source.js';
88
94
  import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
89
95
  import type { ITxeExecutionOracle } from './interfaces.js';
@@ -96,7 +102,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
96
102
 
97
103
  constructor(
98
104
  private stateMachine: TXEStateMachine,
99
- private contractStore: TXEContractStore,
105
+ private contractStore: ContractStore,
100
106
  private noteStore: NoteStore,
101
107
  private keyStore: KeyStore,
102
108
  private addressStore: AddressStore,
@@ -106,34 +112,46 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
106
112
  private senderAddressBookStore: SenderAddressBookStore,
107
113
  private capsuleStore: CapsuleStore,
108
114
  private privateEventStore: PrivateEventStore,
109
- private jobId: string,
110
115
  private nextBlockTimestamp: bigint,
111
116
  private version: Fr,
112
117
  private chainId: Fr,
113
118
  private authwits: Map<string, AuthWitness>,
119
+ private readonly contractSyncService: ContractSyncService,
114
120
  ) {
115
121
  this.logger = createLogger('txe:top_level_context');
116
122
  this.logger.debug('Entering Top Level Context');
117
123
  }
118
124
 
119
- utilityAssertCompatibleOracleVersion(version: number): void {
120
- if (version !== ORACLE_VERSION) {
125
+ private contractOracleVersion: { major: number; minor: number } | undefined;
126
+
127
+ assertCompatibleOracleVersion(major: number, minor: number): void {
128
+ if (major !== ORACLE_VERSION_MAJOR) {
129
+ const hint =
130
+ major > ORACLE_VERSION_MAJOR
131
+ ? '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.'
132
+ : '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.';
121
133
  throw new Error(
122
- `Incompatible oracle version. TXE is using version '${ORACLE_VERSION}', but got a request for '${version}'.`,
134
+ `Incompatible aztec cli version: ${hint} See https://docs.aztec.network/errors/8 (expected oracle major version ${ORACLE_VERSION_MAJOR}, got ${major})`,
123
135
  );
124
136
  }
137
+ this.contractOracleVersion = { major, minor };
138
+ }
139
+
140
+ // Prefixed with "nonOracleFunction" as it is not used as an oracle handler.
141
+ nonOracleFunctionGetContractOracleVersion(): { major: number; minor: number } | undefined {
142
+ return this.contractOracleVersion;
125
143
  }
126
144
 
127
145
  // This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
128
146
  // setup.
129
- utilityGetRandomField(): Fr {
147
+ getRandomField(): Fr {
130
148
  return Fr.random();
131
149
  }
132
150
 
133
151
  // We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
134
- utilityDebugLog(level: number, message: string, fields: Fr[]): Promise<void> {
152
+ log(level: number, message: string, fields: Fr[]): Promise<void> {
135
153
  if (!LogLevels[level]) {
136
- throw new Error(`Invalid debug log level: ${level}`);
154
+ throw new Error(`Invalid log level: ${level}`);
137
155
  }
138
156
  const levelName = LogLevels[level];
139
157
 
@@ -141,23 +159,23 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
141
159
  return Promise.resolve();
142
160
  }
143
161
 
144
- txeGetDefaultAddress(): AztecAddress {
162
+ getDefaultAddress(): AztecAddress {
145
163
  return DEFAULT_ADDRESS;
146
164
  }
147
165
 
148
- async txeGetNextBlockNumber(): Promise<BlockNumber> {
166
+ async getNextBlockNumber(): Promise<BlockNumber> {
149
167
  return BlockNumber((await this.getLastBlockNumber()) + 1);
150
168
  }
151
169
 
152
- txeGetNextBlockTimestamp(): Promise<bigint> {
170
+ getNextBlockTimestamp(): Promise<bigint> {
153
171
  return Promise.resolve(this.nextBlockTimestamp);
154
172
  }
155
173
 
156
- async txeGetLastBlockTimestamp() {
174
+ async getLastBlockTimestamp() {
157
175
  return (await this.stateMachine.node.getBlockHeader('latest'))!.globalVariables.timestamp;
158
176
  }
159
177
 
160
- async txeGetLastTxEffects() {
178
+ async getLastTxEffects() {
161
179
  const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
162
180
  const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
163
181
 
@@ -171,7 +189,26 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
171
189
  return { txHash: txEffects.txHash, noteHashes: txEffects.noteHashes, nullifiers: txEffects.nullifiers };
172
190
  }
173
191
 
174
- async txeGetPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) {
192
+ async syncContractNonOracleMethod(contractAddress: AztecAddress, scope: AztecAddress, jobId: string) {
193
+ if (contractAddress.equals(DEFAULT_ADDRESS)) {
194
+ this.logger.debug(`Skipping sync in getPrivateEvents because the events correspond to the default address.`);
195
+ return;
196
+ }
197
+
198
+ const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
199
+ await this.stateMachine.contractSyncService.ensureContractSynced(
200
+ contractAddress,
201
+ null,
202
+ async (call, execScopes) => {
203
+ await this.executeUtilityCall(call, execScopes, jobId);
204
+ },
205
+ blockHeader,
206
+ jobId,
207
+ [scope],
208
+ );
209
+ }
210
+
211
+ async getPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) {
175
212
  return (
176
213
  await this.privateEventStore.getPrivateEvents(selector, {
177
214
  contractAddress,
@@ -182,7 +219,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
182
219
  ).map(e => e.packedEvent);
183
220
  }
184
221
 
185
- async txeAdvanceBlocksBy(blocks: number) {
222
+ async advanceBlocksBy(blocks: number) {
186
223
  this.logger.debug(`time traveling ${blocks} blocks`);
187
224
 
188
225
  for (let i = 0; i < blocks; i++) {
@@ -190,12 +227,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
190
227
  }
191
228
  }
192
229
 
193
- txeAdvanceTimestampBy(duration: UInt64) {
230
+ advanceTimestampBy(duration: UInt64) {
194
231
  this.logger.debug(`time traveling ${duration} seconds`);
195
232
  this.nextBlockTimestamp += duration;
196
233
  }
197
234
 
198
- async txeDeploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
235
+ async deploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
199
236
  // Emit deployment nullifier
200
237
  await this.mineBlock({
201
238
  nullifiers: [
@@ -207,20 +244,20 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
207
244
  });
208
245
 
209
246
  if (!secret.equals(Fr.ZERO)) {
210
- await this.txeAddAccount(artifact, instance, secret);
247
+ await this.addAccount(artifact, instance, secret);
211
248
  } else {
212
249
  await this.contractStore.addContractInstance(instance);
213
- await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
250
+ await this.contractStore.addContractArtifact(artifact);
214
251
  this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
215
252
  }
216
253
  }
217
254
 
218
- async txeAddAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
255
+ async addAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
219
256
  const partialAddress = await computePartialAddress(instance);
220
257
 
221
258
  this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
222
259
  await this.contractStore.addContractInstance(instance);
223
- await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
260
+ await this.contractStore.addContractArtifact(artifact);
224
261
 
225
262
  const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
226
263
  await this.accountStore.setAccount(completeAddress.address, completeAddress);
@@ -230,7 +267,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
230
267
  return completeAddress;
231
268
  }
232
269
 
233
- async txeCreateAccount(secret: Fr) {
270
+ async createAccount(secret: Fr) {
234
271
  // This is a foot gun !
235
272
  const completeAddress = await this.keyStore.addAccount(secret, secret);
236
273
  await this.accountStore.setAccount(completeAddress.address, completeAddress);
@@ -240,7 +277,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
240
277
  return completeAddress;
241
278
  }
242
279
 
243
- async txeAddAuthWitness(address: AztecAddress, messageHash: Fr) {
280
+ async addAuthWitness(address: AztecAddress, messageHash: Fr) {
244
281
  const account = await this.accountStore.getAccount(address);
245
282
  const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
246
283
 
@@ -253,7 +290,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
253
290
  }
254
291
 
255
292
  async mineBlock(options: { nullifiers?: Fr[] } = {}) {
256
- const blockNumber = await this.txeGetNextBlockNumber();
293
+ const blockNumber = await this.getNextBlockNumber();
257
294
 
258
295
  const txEffect = TxEffect.empty();
259
296
  txEffect.nullifiers = [getSingleTxBlockRequestHash(blockNumber), ...(options.nullifiers ?? [])];
@@ -277,13 +314,14 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
277
314
  await this.stateMachine.handleL2Block(block);
278
315
  }
279
316
 
280
- async txePrivateCallNewFlow(
317
+ async privateCallNewFlow(
281
318
  from: AztecAddress,
282
319
  targetContractAddress: AztecAddress = AztecAddress.zero(),
283
320
  functionSelector: FunctionSelector = FunctionSelector.empty(),
284
321
  args: Fr[],
285
322
  argsHash: Fr = Fr.zero(),
286
323
  isStaticCall: boolean = false,
324
+ jobId: string,
287
325
  ) {
288
326
  this.logger.verbose(
289
327
  `Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
@@ -297,14 +335,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
297
335
  throw new Error(message);
298
336
  }
299
337
 
300
- // When `from` is the zero address (used when creating a new contract account for example),
301
- // we disable scope filtering by setting effectiveScopes to undefined. This allows these operations
302
- // to proceed without requiring keys registered for the zero address.
303
- const effectiveScopes = from.isZero() ? undefined : [from];
338
+ // When `from` is the zero address (e.g. when deploying a new account contract), we return an
339
+ // empty scope list which acts as deny-all: no notes are visible and no keys are accessible.
340
+ const effectiveScopes = from.isZero() ? [] : [from];
304
341
 
305
342
  // Sync notes before executing private function to discover notes from previous transactions
306
- const utilityExecutor = async (call: FunctionCall) => {
307
- await this.executeUtilityCall(call, effectiveScopes);
343
+ const utilityExecutor = async (call: FunctionCall, execScopes: AztecAddress[]) => {
344
+ await this.executeUtilityCall(call, execScopes, jobId);
308
345
  };
309
346
 
310
347
  const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
@@ -313,15 +350,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
313
350
  functionSelector,
314
351
  utilityExecutor,
315
352
  blockHeader,
316
- this.jobId,
353
+ jobId,
354
+ effectiveScopes,
317
355
  );
318
356
 
319
- const blockNumber = await this.txeGetNextBlockNumber();
357
+ const blockNumber = await this.getNextBlockNumber();
320
358
 
321
359
  const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
322
360
 
323
- const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
324
- const teardownGasLimits = new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT);
361
+ const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
362
+ const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
325
363
  const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
326
364
 
327
365
  const txContext = new TxContext(this.chainId, this.version, gasSettings);
@@ -337,43 +375,39 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
337
375
 
338
376
  const simulator = new WASMSimulator();
339
377
 
340
- const privateExecutionOracle = new PrivateExecutionOracle(
378
+ const privateExecutionOracle = new PrivateExecutionOracle({
341
379
  argsHash,
342
380
  txContext,
343
381
  callContext,
344
- /** Header of a block whose state is used during private execution (not the block the transaction is included in). */
345
- blockHeader,
382
+ anchorBlockHeader: blockHeader,
346
383
  utilityExecutor,
347
- /** List of transient auth witnesses to be used during this simulation */
348
- Array.from(this.authwits.values()),
349
- /** List of transient auth witnesses to be used during this simulation */
350
- [],
351
- HashedValuesCache.create([new HashedValues(args, argsHash)]),
384
+ authWitnesses: Array.from(this.authwits.values()),
385
+ capsules: [],
386
+ executionCache: HashedValuesCache.create([new HashedValues(args, argsHash)]),
352
387
  noteCache,
353
388
  taggingIndexCache,
354
- this.contractStore,
355
- this.noteStore,
356
- this.keyStore,
357
- this.addressStore,
358
- this.stateMachine.node,
359
- this.senderTaggingStore,
360
- this.recipientTaggingStore,
361
- this.senderAddressBookStore,
362
- this.capsuleStore,
363
- this.privateEventStore,
364
- this.stateMachine.contractSyncService,
365
- this.jobId,
366
- 0, // totalPublicArgsCount
367
- minRevertibleSideEffectCounter, // (start) sideEffectCounter
368
- undefined, // log
369
- effectiveScopes, // scopes
370
- /**
371
- * In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
372
- * contract would perform, including setting senderForTags.
373
- */
374
- from,
389
+ contractStore: this.contractStore,
390
+ noteStore: this.noteStore,
391
+ keyStore: this.keyStore,
392
+ addressStore: this.addressStore,
393
+ aztecNode: this.stateMachine.node,
394
+ senderTaggingStore: this.senderTaggingStore,
395
+ recipientTaggingStore: this.recipientTaggingStore,
396
+ senderAddressBookStore: this.senderAddressBookStore,
397
+ capsuleService: new CapsuleService(this.capsuleStore, effectiveScopes),
398
+ privateEventStore: this.privateEventStore,
399
+ contractSyncService: this.stateMachine.contractSyncService,
400
+ jobId,
401
+ totalPublicCalldataCount: 0,
402
+ sideEffectCounter: minRevertibleSideEffectCounter,
403
+ scopes: effectiveScopes,
404
+ // In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
405
+ // contract would perform, including setting senderForTags.
406
+ senderForTags: from,
375
407
  simulator,
376
- );
408
+ messageContextService: this.stateMachine.messageContextService,
409
+ l2TipsStore: this.stateMachine.node,
410
+ });
377
411
 
378
412
  // 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.
379
413
  let result: PrivateExecutionResult;
@@ -395,7 +429,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
395
429
  );
396
430
  const publicFunctionsCalldata = await Promise.all(
397
431
  publicCallRequests.map(async r => {
398
- const calldata = await privateExecutionOracle.privateLoadFromExecutionCache(r.calldataHash);
432
+ const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
399
433
  return new HashedValues(calldata, r.calldataHash);
400
434
  }),
401
435
  );
@@ -413,6 +447,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
413
447
  const { publicInputs } = await generateSimulatedProvingResult(
414
448
  result,
415
449
  (addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
450
+ this.stateMachine.node,
416
451
  minRevertibleSideEffectCounter,
417
452
  );
418
453
 
@@ -508,7 +543,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
508
543
  return executionResult.returnValues ?? [];
509
544
  }
510
545
 
511
- async txePublicCallNewFlow(
546
+ async publicCallNewFlow(
512
547
  from: AztecAddress,
513
548
  targetContractAddress: AztecAddress,
514
549
  calldata: Fr[],
@@ -518,11 +553,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
518
553
  `Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
519
554
  );
520
555
 
521
- const blockNumber = await this.txeGetNextBlockNumber();
556
+ const blockNumber = await this.getNextBlockNumber();
522
557
 
523
- const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
558
+ const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
524
559
 
525
- const teardownGasLimits = new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT);
560
+ const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
526
561
 
527
562
  const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
528
563
 
@@ -595,7 +630,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
595
630
  constantData,
596
631
  /*gasUsed=*/ new Gas(0, 0),
597
632
  /*feePayer=*/ AztecAddress.zero(),
598
- /*includeByTimestamp=*/ 0n,
633
+ /*expirationTimestamp=*/ 0n,
599
634
  inputsForPublic,
600
635
  undefined,
601
636
  );
@@ -663,10 +698,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
663
698
  return returnValues ?? [];
664
699
  }
665
700
 
666
- async txeSimulateUtilityFunction(
701
+ async executeUtilityFunction(
667
702
  targetContractAddress: AztecAddress,
668
703
  functionSelector: FunctionSelector,
669
704
  args: Fr[],
705
+ jobId: string,
670
706
  ) {
671
707
  const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
672
708
  if (!artifact) {
@@ -678,11 +714,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
678
714
  await this.stateMachine.contractSyncService.ensureContractSynced(
679
715
  targetContractAddress,
680
716
  functionSelector,
681
- async call => {
682
- await this.executeUtilityCall(call);
717
+ async (call, execScopes) => {
718
+ await this.executeUtilityCall(call, execScopes, jobId);
683
719
  },
684
720
  blockHeader,
685
- this.jobId,
721
+ jobId,
722
+ await this.keyStore.getAccounts(),
686
723
  );
687
724
 
688
725
  const call = FunctionCall.from({
@@ -696,10 +733,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
696
733
  returnTypes: [],
697
734
  });
698
735
 
699
- return this.executeUtilityCall(call);
736
+ return this.executeUtilityCall(call, await this.keyStore.getAccounts(), jobId);
700
737
  }
701
738
 
702
- private async executeUtilityCall(call: FunctionCall, scopes?: AztecAddress[]): Promise<Fr[]> {
739
+ private async executeUtilityCall(call: FunctionCall, scopes: AztecAddress[], jobId: string): Promise<Fr[]> {
703
740
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
704
741
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
705
742
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
@@ -712,24 +749,26 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
712
749
 
713
750
  try {
714
751
  const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
715
- const oracle = new UtilityExecutionOracle(
716
- call.to,
717
- [],
718
- [],
752
+ const oracle = new UtilityExecutionOracle({
753
+ contractAddress: call.to,
754
+ authWitnesses: [],
755
+ capsules: [],
719
756
  anchorBlockHeader,
720
- this.contractStore,
721
- this.noteStore,
722
- this.keyStore,
723
- this.addressStore,
724
- this.stateMachine.node,
725
- this.recipientTaggingStore,
726
- this.senderAddressBookStore,
727
- this.capsuleStore,
728
- this.privateEventStore,
729
- this.jobId,
730
- undefined, // log
731
- scopes, // scopes - used to filter notes by account
732
- );
757
+ contractStore: this.contractStore,
758
+ noteStore: this.noteStore,
759
+ keyStore: this.keyStore,
760
+ addressStore: this.addressStore,
761
+ aztecNode: this.stateMachine.node,
762
+ recipientTaggingStore: this.recipientTaggingStore,
763
+ senderAddressBookStore: this.senderAddressBookStore,
764
+ capsuleService: new CapsuleService(this.capsuleStore, scopes),
765
+ privateEventStore: this.privateEventStore,
766
+ messageContextService: this.stateMachine.messageContextService,
767
+ contractSyncService: this.contractSyncService,
768
+ l2TipsStore: this.stateMachine.node,
769
+ jobId,
770
+ scopes,
771
+ });
733
772
  const acirExecutionResult = await new WASMSimulator()
734
773
  .executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
735
774
  .catch((err: Error) => {
@@ -745,10 +784,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
745
784
  );
746
785
  });
747
786
 
748
- this.logger.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
787
+ this.logger.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
749
788
  return witnessMapToFields(acirExecutionResult.returnWitness);
750
789
  } catch (err) {
751
- throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility simulation'));
790
+ throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility execution'));
752
791
  }
753
792
  }
754
793