@aztec/txe 0.0.1-commit.6d63667d → 0.0.1-commit.71324e566

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 +141 -62
  12. package/dest/rpc_translator.d.ts +121 -83
  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 +18 -13
  19. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  20. package/dest/state_machine/dummy_p2p_client.js +33 -18
  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 +20 -3
  28. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  29. package/dest/state_machine/mock_epoch_cache.js +39 -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 +153 -113
  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 +46 -24
  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 +51 -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,57 +112,70 @@ 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[]): 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
 
140
158
  this.logger[levelName](`${applyStringFormatting(message, fields)}`, { module: `${this.logger.module}:debug_log` });
159
+ return Promise.resolve();
141
160
  }
142
161
 
143
- txeGetDefaultAddress(): AztecAddress {
162
+ getDefaultAddress(): AztecAddress {
144
163
  return DEFAULT_ADDRESS;
145
164
  }
146
165
 
147
- async txeGetNextBlockNumber(): Promise<BlockNumber> {
166
+ async getNextBlockNumber(): Promise<BlockNumber> {
148
167
  return BlockNumber((await this.getLastBlockNumber()) + 1);
149
168
  }
150
169
 
151
- txeGetNextBlockTimestamp(): Promise<bigint> {
170
+ getNextBlockTimestamp(): Promise<bigint> {
152
171
  return Promise.resolve(this.nextBlockTimestamp);
153
172
  }
154
173
 
155
- async txeGetLastBlockTimestamp() {
174
+ async getLastBlockTimestamp() {
156
175
  return (await this.stateMachine.node.getBlockHeader('latest'))!.globalVariables.timestamp;
157
176
  }
158
177
 
159
- async txeGetLastTxEffects() {
178
+ async getLastTxEffects() {
160
179
  const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
161
180
  const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
162
181
 
@@ -170,7 +189,26 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
170
189
  return { txHash: txEffects.txHash, noteHashes: txEffects.noteHashes, nullifiers: txEffects.nullifiers };
171
190
  }
172
191
 
173
- 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) {
174
212
  return (
175
213
  await this.privateEventStore.getPrivateEvents(selector, {
176
214
  contractAddress,
@@ -181,7 +219,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
181
219
  ).map(e => e.packedEvent);
182
220
  }
183
221
 
184
- async txeAdvanceBlocksBy(blocks: number) {
222
+ async advanceBlocksBy(blocks: number) {
185
223
  this.logger.debug(`time traveling ${blocks} blocks`);
186
224
 
187
225
  for (let i = 0; i < blocks; i++) {
@@ -189,12 +227,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
189
227
  }
190
228
  }
191
229
 
192
- txeAdvanceTimestampBy(duration: UInt64) {
230
+ advanceTimestampBy(duration: UInt64) {
193
231
  this.logger.debug(`time traveling ${duration} seconds`);
194
232
  this.nextBlockTimestamp += duration;
195
233
  }
196
234
 
197
- async txeDeploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
235
+ async deploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
198
236
  // Emit deployment nullifier
199
237
  await this.mineBlock({
200
238
  nullifiers: [
@@ -206,20 +244,20 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
206
244
  });
207
245
 
208
246
  if (!secret.equals(Fr.ZERO)) {
209
- await this.txeAddAccount(artifact, instance, secret);
247
+ await this.addAccount(artifact, instance, secret);
210
248
  } else {
211
249
  await this.contractStore.addContractInstance(instance);
212
- await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
250
+ await this.contractStore.addContractArtifact(artifact);
213
251
  this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
214
252
  }
215
253
  }
216
254
 
217
- async txeAddAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
255
+ async addAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
218
256
  const partialAddress = await computePartialAddress(instance);
219
257
 
220
258
  this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
221
259
  await this.contractStore.addContractInstance(instance);
222
- await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
260
+ await this.contractStore.addContractArtifact(artifact);
223
261
 
224
262
  const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
225
263
  await this.accountStore.setAccount(completeAddress.address, completeAddress);
@@ -229,7 +267,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
229
267
  return completeAddress;
230
268
  }
231
269
 
232
- async txeCreateAccount(secret: Fr) {
270
+ async createAccount(secret: Fr) {
233
271
  // This is a foot gun !
234
272
  const completeAddress = await this.keyStore.addAccount(secret, secret);
235
273
  await this.accountStore.setAccount(completeAddress.address, completeAddress);
@@ -239,7 +277,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
239
277
  return completeAddress;
240
278
  }
241
279
 
242
- async txeAddAuthWitness(address: AztecAddress, messageHash: Fr) {
280
+ async addAuthWitness(address: AztecAddress, messageHash: Fr) {
243
281
  const account = await this.accountStore.getAccount(address);
244
282
  const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
245
283
 
@@ -252,7 +290,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
252
290
  }
253
291
 
254
292
  async mineBlock(options: { nullifiers?: Fr[] } = {}) {
255
- const blockNumber = await this.txeGetNextBlockNumber();
293
+ const blockNumber = await this.getNextBlockNumber();
256
294
 
257
295
  const txEffect = TxEffect.empty();
258
296
  txEffect.nullifiers = [getSingleTxBlockRequestHash(blockNumber), ...(options.nullifiers ?? [])];
@@ -276,13 +314,14 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
276
314
  await this.stateMachine.handleL2Block(block);
277
315
  }
278
316
 
279
- async txePrivateCallNewFlow(
317
+ async privateCallNewFlow(
280
318
  from: AztecAddress,
281
319
  targetContractAddress: AztecAddress = AztecAddress.zero(),
282
320
  functionSelector: FunctionSelector = FunctionSelector.empty(),
283
321
  args: Fr[],
284
322
  argsHash: Fr = Fr.zero(),
285
323
  isStaticCall: boolean = false,
324
+ jobId: string,
286
325
  ) {
287
326
  this.logger.verbose(
288
327
  `Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
@@ -296,14 +335,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
296
335
  throw new Error(message);
297
336
  }
298
337
 
299
- // When `from` is the zero address (used when creating a new contract account for example),
300
- // we disable scope filtering by setting effectiveScopes to undefined. This allows these operations
301
- // to proceed without requiring keys registered for the zero address.
302
- 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];
303
341
 
304
342
  // Sync notes before executing private function to discover notes from previous transactions
305
- const utilityExecutor = async (call: FunctionCall) => {
306
- await this.executeUtilityCall(call, effectiveScopes);
343
+ const utilityExecutor = async (call: FunctionCall, execScopes: AztecAddress[]) => {
344
+ await this.executeUtilityCall(call, execScopes, jobId);
307
345
  };
308
346
 
309
347
  const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
@@ -312,15 +350,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
312
350
  functionSelector,
313
351
  utilityExecutor,
314
352
  blockHeader,
315
- this.jobId,
353
+ jobId,
354
+ effectiveScopes,
316
355
  );
317
356
 
318
- const blockNumber = await this.txeGetNextBlockNumber();
357
+ const blockNumber = await this.getNextBlockNumber();
319
358
 
320
359
  const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
321
360
 
322
- const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
323
- 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);
324
363
  const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
325
364
 
326
365
  const txContext = new TxContext(this.chainId, this.version, gasSettings);
@@ -336,43 +375,39 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
336
375
 
337
376
  const simulator = new WASMSimulator();
338
377
 
339
- const privateExecutionOracle = new PrivateExecutionOracle(
378
+ const privateExecutionOracle = new PrivateExecutionOracle({
340
379
  argsHash,
341
380
  txContext,
342
381
  callContext,
343
- /** Header of a block whose state is used during private execution (not the block the transaction is included in). */
344
- blockHeader,
382
+ anchorBlockHeader: blockHeader,
345
383
  utilityExecutor,
346
- /** List of transient auth witnesses to be used during this simulation */
347
- Array.from(this.authwits.values()),
348
- /** List of transient auth witnesses to be used during this simulation */
349
- [],
350
- HashedValuesCache.create([new HashedValues(args, argsHash)]),
384
+ authWitnesses: Array.from(this.authwits.values()),
385
+ capsules: [],
386
+ executionCache: HashedValuesCache.create([new HashedValues(args, argsHash)]),
351
387
  noteCache,
352
388
  taggingIndexCache,
353
- this.contractStore,
354
- this.noteStore,
355
- this.keyStore,
356
- this.addressStore,
357
- this.stateMachine.node,
358
- this.senderTaggingStore,
359
- this.recipientTaggingStore,
360
- this.senderAddressBookStore,
361
- this.capsuleStore,
362
- this.privateEventStore,
363
- this.stateMachine.contractSyncService,
364
- this.jobId,
365
- 0, // totalPublicArgsCount
366
- minRevertibleSideEffectCounter, // (start) sideEffectCounter
367
- undefined, // log
368
- effectiveScopes, // scopes
369
- /**
370
- * In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
371
- * contract would perform, including setting senderForTags.
372
- */
373
- 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,
374
407
  simulator,
375
- );
408
+ messageContextService: this.stateMachine.messageContextService,
409
+ l2TipsStore: this.stateMachine.node,
410
+ });
376
411
 
377
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.
378
413
  let result: PrivateExecutionResult;
@@ -394,7 +429,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
394
429
  );
395
430
  const publicFunctionsCalldata = await Promise.all(
396
431
  publicCallRequests.map(async r => {
397
- const calldata = await privateExecutionOracle.privateLoadFromExecutionCache(r.calldataHash);
432
+ const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
398
433
  return new HashedValues(calldata, r.calldataHash);
399
434
  }),
400
435
  );
@@ -411,7 +446,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
411
446
  // We pass the non-zero minRevertibleSideEffectCounter to make sure the side effects are split correctly.
412
447
  const { publicInputs } = await generateSimulatedProvingResult(
413
448
  result,
414
- this.contractStore,
449
+ (addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
450
+ this.stateMachine.node,
415
451
  minRevertibleSideEffectCounter,
416
452
  );
417
453
 
@@ -507,7 +543,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
507
543
  return executionResult.returnValues ?? [];
508
544
  }
509
545
 
510
- async txePublicCallNewFlow(
546
+ async publicCallNewFlow(
511
547
  from: AztecAddress,
512
548
  targetContractAddress: AztecAddress,
513
549
  calldata: Fr[],
@@ -517,11 +553,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
517
553
  `Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
518
554
  );
519
555
 
520
- const blockNumber = await this.txeGetNextBlockNumber();
556
+ const blockNumber = await this.getNextBlockNumber();
521
557
 
522
- 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);
523
559
 
524
- 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);
525
561
 
526
562
  const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
527
563
 
@@ -594,7 +630,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
594
630
  constantData,
595
631
  /*gasUsed=*/ new Gas(0, 0),
596
632
  /*feePayer=*/ AztecAddress.zero(),
597
- /*includeByTimestamp=*/ 0n,
633
+ /*expirationTimestamp=*/ 0n,
598
634
  inputsForPublic,
599
635
  undefined,
600
636
  );
@@ -662,10 +698,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
662
698
  return returnValues ?? [];
663
699
  }
664
700
 
665
- async txeSimulateUtilityFunction(
701
+ async executeUtilityFunction(
666
702
  targetContractAddress: AztecAddress,
667
703
  functionSelector: FunctionSelector,
668
704
  args: Fr[],
705
+ jobId: string,
669
706
  ) {
670
707
  const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
671
708
  if (!artifact) {
@@ -677,28 +714,29 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
677
714
  await this.stateMachine.contractSyncService.ensureContractSynced(
678
715
  targetContractAddress,
679
716
  functionSelector,
680
- async call => {
681
- await this.executeUtilityCall(call);
717
+ async (call, execScopes) => {
718
+ await this.executeUtilityCall(call, execScopes, jobId);
682
719
  },
683
720
  blockHeader,
684
- this.jobId,
721
+ jobId,
722
+ await this.keyStore.getAccounts(),
685
723
  );
686
724
 
687
- const call = new FunctionCall(
688
- artifact.name,
689
- targetContractAddress,
690
- functionSelector,
691
- FunctionType.UTILITY,
692
- false,
693
- false,
725
+ const call = FunctionCall.from({
726
+ name: artifact.name,
727
+ to: targetContractAddress,
728
+ selector: functionSelector,
729
+ type: FunctionType.UTILITY,
730
+ hideMsgSender: false,
731
+ isStatic: false,
694
732
  args,
695
- [],
696
- );
733
+ returnTypes: [],
734
+ });
697
735
 
698
- return this.executeUtilityCall(call);
736
+ return this.executeUtilityCall(call, await this.keyStore.getAccounts(), jobId);
699
737
  }
700
738
 
701
- private async executeUtilityCall(call: FunctionCall, scopes?: AztecAddress[]): Promise<Fr[]> {
739
+ private async executeUtilityCall(call: FunctionCall, scopes: AztecAddress[], jobId: string): Promise<Fr[]> {
702
740
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
703
741
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
704
742
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
@@ -711,24 +749,26 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
711
749
 
712
750
  try {
713
751
  const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
714
- const oracle = new UtilityExecutionOracle(
715
- call.to,
716
- [],
717
- [],
752
+ const oracle = new UtilityExecutionOracle({
753
+ contractAddress: call.to,
754
+ authWitnesses: [],
755
+ capsules: [],
718
756
  anchorBlockHeader,
719
- this.contractStore,
720
- this.noteStore,
721
- this.keyStore,
722
- this.addressStore,
723
- this.stateMachine.node,
724
- this.recipientTaggingStore,
725
- this.senderAddressBookStore,
726
- this.capsuleStore,
727
- this.privateEventStore,
728
- this.jobId,
729
- undefined, // log
730
- scopes, // scopes - used to filter notes by account
731
- );
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
+ });
732
772
  const acirExecutionResult = await new WASMSimulator()
733
773
  .executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
734
774
  .catch((err: Error) => {
@@ -744,10 +784,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
744
784
  );
745
785
  });
746
786
 
747
- this.logger.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
787
+ this.logger.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
748
788
  return witnessMapToFields(acirExecutionResult.returnWitness);
749
789
  } catch (err) {
750
- 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'));
751
791
  }
752
792
  }
753
793