@aztec/txe 0.0.1-commit.87a0206 → 0.0.1-commit.88c5703d4

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 (52) 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 +22 -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 +107 -52
  12. package/dest/rpc_translator.d.ts +85 -83
  13. package/dest/rpc_translator.d.ts.map +1 -1
  14. package/dest/rpc_translator.js +250 -150
  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 +5 -7
  18. package/dest/state_machine/dummy_p2p_client.d.ts +14 -11
  19. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  20. package/dest/state_machine/dummy_p2p_client.js +23 -14
  21. package/dest/state_machine/index.d.ts +4 -2
  22. package/dest/state_machine/index.d.ts.map +1 -1
  23. package/dest/state_machine/index.js +7 -3
  24. package/dest/state_machine/mock_epoch_cache.d.ts +3 -1
  25. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  26. package/dest/state_machine/mock_epoch_cache.js +4 -0
  27. package/dest/state_machine/synchronizer.d.ts +5 -5
  28. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  29. package/dest/state_machine/synchronizer.js +3 -3
  30. package/dest/txe_session.d.ts +9 -6
  31. package/dest/txe_session.d.ts.map +1 -1
  32. package/dest/txe_session.js +80 -21
  33. package/dest/util/txe_public_contract_data_source.d.ts +2 -3
  34. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  35. package/dest/util/txe_public_contract_data_source.js +5 -22
  36. package/package.json +15 -15
  37. package/src/index.ts +89 -52
  38. package/src/oracle/interfaces.ts +32 -31
  39. package/src/oracle/txe_oracle_public_context.ts +12 -12
  40. package/src/oracle/txe_oracle_top_level_context.ts +110 -91
  41. package/src/rpc_translator.ts +278 -169
  42. package/src/state_machine/archiver.ts +5 -5
  43. package/src/state_machine/dummy_p2p_client.ts +33 -20
  44. package/src/state_machine/index.ts +6 -1
  45. package/src/state_machine/mock_epoch_cache.ts +5 -0
  46. package/src/state_machine/synchronizer.ts +4 -4
  47. package/src/txe_session.ts +83 -71
  48. package/src/util/txe_public_contract_data_source.ts +10 -36
  49. package/dest/util/txe_contract_store.d.ts +0 -12
  50. package/dest/util/txe_contract_store.d.ts.map +0 -1
  51. package/dest/util/txe_contract_store.js +0 -22
  52. package/src/util/txe_contract_store.ts +0 -36
@@ -39,46 +39,46 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
39
39
  });
40
40
  }
41
41
 
42
- avmOpcodeAddress(): Promise<AztecAddress> {
42
+ address(): Promise<AztecAddress> {
43
43
  return Promise.resolve(this.contractAddress);
44
44
  }
45
45
 
46
- avmOpcodeSender(): Promise<AztecAddress> {
46
+ sender(): Promise<AztecAddress> {
47
47
  return Promise.resolve(AztecAddress.ZERO); // todo: change?
48
48
  }
49
49
 
50
- avmOpcodeBlockNumber(): Promise<BlockNumber> {
50
+ blockNumber(): Promise<BlockNumber> {
51
51
  return Promise.resolve(this.globalVariables.blockNumber);
52
52
  }
53
53
 
54
- avmOpcodeTimestamp(): Promise<bigint> {
54
+ timestamp(): Promise<bigint> {
55
55
  return Promise.resolve(this.globalVariables.timestamp);
56
56
  }
57
57
 
58
- avmOpcodeIsStaticCall(): Promise<boolean> {
58
+ isStaticCall(): Promise<boolean> {
59
59
  return Promise.resolve(false);
60
60
  }
61
61
 
62
- avmOpcodeChainId(): Promise<Fr> {
62
+ chainId(): Promise<Fr> {
63
63
  return Promise.resolve(this.globalVariables.chainId);
64
64
  }
65
65
 
66
- avmOpcodeVersion(): Promise<Fr> {
66
+ version(): Promise<Fr> {
67
67
  return Promise.resolve(this.globalVariables.version);
68
68
  }
69
69
 
70
- async avmOpcodeEmitNullifier(nullifier: Fr) {
70
+ async emitNullifier(nullifier: Fr) {
71
71
  const siloedNullifier = await siloNullifier(this.contractAddress, nullifier);
72
72
  this.transientSiloedNullifiers.push(siloedNullifier);
73
73
  }
74
74
 
75
- async avmOpcodeEmitNoteHash(noteHash: Fr) {
75
+ async emitNoteHash(noteHash: Fr) {
76
76
  const siloedNoteHash = await siloNoteHash(this.contractAddress, noteHash);
77
77
  // TODO: make the note hash unique - they are only siloed right now
78
78
  this.transientUniqueNoteHashes.push(siloedNoteHash);
79
79
  }
80
80
 
81
- async avmOpcodeNullifierExists(siloedNullifier: Fr): Promise<boolean> {
81
+ async nullifierExists(siloedNullifier: Fr): Promise<boolean> {
82
82
  const treeIndex = (
83
83
  await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [siloedNullifier.toBuffer()])
84
84
  )[0];
@@ -87,7 +87,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
87
87
  return treeIndex !== undefined || transientIndex !== undefined;
88
88
  }
89
89
 
90
- async avmOpcodeStorageWrite(slot: Fr, value: Fr) {
90
+ async storageWrite(slot: Fr, value: Fr) {
91
91
  this.logger.debug('AVM storage write', { slot, value });
92
92
 
93
93
  const dataWrite = new PublicDataWrite(await computePublicDataTreeLeafSlot(this.contractAddress, slot), value);
@@ -99,7 +99,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
99
99
  ]);
100
100
  }
101
101
 
102
- async avmOpcodeStorageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr> {
102
+ async storageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr> {
103
103
  const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, slot);
104
104
 
105
105
  const lowLeafResult = await this.forkedWorldTrees.getPreviousValueIndex(
@@ -12,9 +12,11 @@ import { Fr } from '@aztec/foundation/curves/bn254';
12
12
  import { LogLevels, type Logger, applyStringFormatting, createLogger } from '@aztec/foundation/log';
13
13
  import { TestDateProvider } from '@aztec/foundation/timer';
14
14
  import type { KeyStore } from '@aztec/key-store';
15
+ import type { AccessScopes } from '@aztec/pxe/client/lazy';
15
16
  import {
16
17
  AddressStore,
17
18
  CapsuleStore,
19
+ type ContractStore,
18
20
  NoteStore,
19
21
  ORACLE_VERSION,
20
22
  PrivateEventStore,
@@ -83,7 +85,6 @@ import { ForkCheckpoint } from '@aztec/world-state';
83
85
  import { DEFAULT_ADDRESS } from '../constants.js';
84
86
  import type { TXEStateMachine } from '../state_machine/index.js';
85
87
  import type { TXEAccountStore } from '../util/txe_account_store.js';
86
- import type { TXEContractStore } from '../util/txe_contract_store.js';
87
88
  import { TXEPublicContractDataSource } from '../util/txe_public_contract_data_source.js';
88
89
  import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
89
90
  import type { ITxeExecutionOracle } from './interfaces.js';
@@ -96,7 +97,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
96
97
 
97
98
  constructor(
98
99
  private stateMachine: TXEStateMachine,
99
- private contractStore: TXEContractStore,
100
+ private contractStore: ContractStore,
100
101
  private noteStore: NoteStore,
101
102
  private keyStore: KeyStore,
102
103
  private addressStore: AddressStore,
@@ -106,7 +107,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
106
107
  private senderAddressBookStore: SenderAddressBookStore,
107
108
  private capsuleStore: CapsuleStore,
108
109
  private privateEventStore: PrivateEventStore,
109
- private jobId: string,
110
110
  private nextBlockTimestamp: bigint,
111
111
  private version: Fr,
112
112
  private chainId: Fr,
@@ -116,7 +116,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
116
116
  this.logger.debug('Entering Top Level Context');
117
117
  }
118
118
 
119
- utilityAssertCompatibleOracleVersion(version: number): void {
119
+ assertCompatibleOracleVersion(version: number): void {
120
120
  if (version !== ORACLE_VERSION) {
121
121
  throw new Error(
122
122
  `Incompatible oracle version. TXE is using version '${ORACLE_VERSION}', but got a request for '${version}'.`,
@@ -126,37 +126,38 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
126
126
 
127
127
  // This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
128
128
  // setup.
129
- utilityGetRandomField(): Fr {
129
+ getRandomField(): Fr {
130
130
  return Fr.random();
131
131
  }
132
132
 
133
133
  // 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 {
134
+ log(level: number, message: string, fields: Fr[]): Promise<void> {
135
135
  if (!LogLevels[level]) {
136
- throw new Error(`Invalid debug log level: ${level}`);
136
+ throw new Error(`Invalid log level: ${level}`);
137
137
  }
138
138
  const levelName = LogLevels[level];
139
139
 
140
140
  this.logger[levelName](`${applyStringFormatting(message, fields)}`, { module: `${this.logger.module}:debug_log` });
141
+ return Promise.resolve();
141
142
  }
142
143
 
143
- txeGetDefaultAddress(): AztecAddress {
144
+ getDefaultAddress(): AztecAddress {
144
145
  return DEFAULT_ADDRESS;
145
146
  }
146
147
 
147
- async txeGetNextBlockNumber(): Promise<BlockNumber> {
148
+ async getNextBlockNumber(): Promise<BlockNumber> {
148
149
  return BlockNumber((await this.getLastBlockNumber()) + 1);
149
150
  }
150
151
 
151
- txeGetNextBlockTimestamp(): Promise<bigint> {
152
+ getNextBlockTimestamp(): Promise<bigint> {
152
153
  return Promise.resolve(this.nextBlockTimestamp);
153
154
  }
154
155
 
155
- async txeGetLastBlockTimestamp() {
156
+ async getLastBlockTimestamp() {
156
157
  return (await this.stateMachine.node.getBlockHeader('latest'))!.globalVariables.timestamp;
157
158
  }
158
159
 
159
- async txeGetLastTxEffects() {
160
+ async getLastTxEffects() {
160
161
  const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
161
162
  const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
162
163
 
@@ -170,7 +171,26 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
170
171
  return { txHash: txEffects.txHash, noteHashes: txEffects.noteHashes, nullifiers: txEffects.nullifiers };
171
172
  }
172
173
 
173
- async txeGetPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) {
174
+ async syncContractNonOracleMethod(contractAddress: AztecAddress, scope: AztecAddress, jobId: string) {
175
+ if (contractAddress.equals(DEFAULT_ADDRESS)) {
176
+ this.logger.debug(`Skipping sync in getPrivateEvents because the events correspond to the default address.`);
177
+ return;
178
+ }
179
+
180
+ const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
181
+ await this.stateMachine.contractSyncService.ensureContractSynced(
182
+ contractAddress,
183
+ null,
184
+ async (call, execScopes) => {
185
+ await this.executeUtilityCall(call, execScopes, jobId);
186
+ },
187
+ blockHeader,
188
+ jobId,
189
+ [scope],
190
+ );
191
+ }
192
+
193
+ async getPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) {
174
194
  return (
175
195
  await this.privateEventStore.getPrivateEvents(selector, {
176
196
  contractAddress,
@@ -181,7 +201,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
181
201
  ).map(e => e.packedEvent);
182
202
  }
183
203
 
184
- async txeAdvanceBlocksBy(blocks: number) {
204
+ async advanceBlocksBy(blocks: number) {
185
205
  this.logger.debug(`time traveling ${blocks} blocks`);
186
206
 
187
207
  for (let i = 0; i < blocks; i++) {
@@ -189,12 +209,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
189
209
  }
190
210
  }
191
211
 
192
- txeAdvanceTimestampBy(duration: UInt64) {
212
+ advanceTimestampBy(duration: UInt64) {
193
213
  this.logger.debug(`time traveling ${duration} seconds`);
194
214
  this.nextBlockTimestamp += duration;
195
215
  }
196
216
 
197
- async txeDeploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
217
+ async deploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
198
218
  // Emit deployment nullifier
199
219
  await this.mineBlock({
200
220
  nullifiers: [
@@ -206,20 +226,20 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
206
226
  });
207
227
 
208
228
  if (!secret.equals(Fr.ZERO)) {
209
- await this.txeAddAccount(artifact, instance, secret);
229
+ await this.addAccount(artifact, instance, secret);
210
230
  } else {
211
231
  await this.contractStore.addContractInstance(instance);
212
- await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
232
+ await this.contractStore.addContractArtifact(artifact);
213
233
  this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
214
234
  }
215
235
  }
216
236
 
217
- async txeAddAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
237
+ async addAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
218
238
  const partialAddress = await computePartialAddress(instance);
219
239
 
220
240
  this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
221
241
  await this.contractStore.addContractInstance(instance);
222
- await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
242
+ await this.contractStore.addContractArtifact(artifact);
223
243
 
224
244
  const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
225
245
  await this.accountStore.setAccount(completeAddress.address, completeAddress);
@@ -229,7 +249,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
229
249
  return completeAddress;
230
250
  }
231
251
 
232
- async txeCreateAccount(secret: Fr) {
252
+ async createAccount(secret: Fr) {
233
253
  // This is a foot gun !
234
254
  const completeAddress = await this.keyStore.addAccount(secret, secret);
235
255
  await this.accountStore.setAccount(completeAddress.address, completeAddress);
@@ -239,7 +259,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
239
259
  return completeAddress;
240
260
  }
241
261
 
242
- async txeAddAuthWitness(address: AztecAddress, messageHash: Fr) {
262
+ async addAuthWitness(address: AztecAddress, messageHash: Fr) {
243
263
  const account = await this.accountStore.getAccount(address);
244
264
  const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
245
265
 
@@ -252,7 +272,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
252
272
  }
253
273
 
254
274
  async mineBlock(options: { nullifiers?: Fr[] } = {}) {
255
- const blockNumber = await this.txeGetNextBlockNumber();
275
+ const blockNumber = await this.getNextBlockNumber();
256
276
 
257
277
  const txEffect = TxEffect.empty();
258
278
  txEffect.nullifiers = [getSingleTxBlockRequestHash(blockNumber), ...(options.nullifiers ?? [])];
@@ -276,13 +296,14 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
276
296
  await this.stateMachine.handleL2Block(block);
277
297
  }
278
298
 
279
- async txePrivateCallNewFlow(
299
+ async privateCallNewFlow(
280
300
  from: AztecAddress,
281
301
  targetContractAddress: AztecAddress = AztecAddress.zero(),
282
302
  functionSelector: FunctionSelector = FunctionSelector.empty(),
283
303
  args: Fr[],
284
304
  argsHash: Fr = Fr.zero(),
285
305
  isStaticCall: boolean = false,
306
+ jobId: string,
286
307
  ) {
287
308
  this.logger.verbose(
288
309
  `Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
@@ -296,14 +317,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
296
317
  throw new Error(message);
297
318
  }
298
319
 
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];
320
+ // When `from` is the zero address (e.g. when deploying a new account contract), we return an
321
+ // empty scope list which acts as deny-all: no notes are visible and no keys are accessible.
322
+ const effectiveScopes = from.isZero() ? [] : [from];
303
323
 
304
324
  // Sync notes before executing private function to discover notes from previous transactions
305
- const utilityExecutor = async (call: FunctionCall) => {
306
- await this.executeUtilityCall(call, effectiveScopes);
325
+ const utilityExecutor = async (call: FunctionCall, execScopes: AccessScopes) => {
326
+ await this.executeUtilityCall(call, execScopes, jobId);
307
327
  };
308
328
 
309
329
  const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
@@ -312,10 +332,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
312
332
  functionSelector,
313
333
  utilityExecutor,
314
334
  blockHeader,
315
- this.jobId,
335
+ jobId,
336
+ effectiveScopes,
316
337
  );
317
338
 
318
- const blockNumber = await this.txeGetNextBlockNumber();
339
+ const blockNumber = await this.getNextBlockNumber();
319
340
 
320
341
  const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
321
342
 
@@ -336,43 +357,38 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
336
357
 
337
358
  const simulator = new WASMSimulator();
338
359
 
339
- const privateExecutionOracle = new PrivateExecutionOracle(
360
+ const privateExecutionOracle = new PrivateExecutionOracle({
340
361
  argsHash,
341
362
  txContext,
342
363
  callContext,
343
- /** Header of a block whose state is used during private execution (not the block the transaction is included in). */
344
- blockHeader,
364
+ anchorBlockHeader: blockHeader,
345
365
  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)]),
366
+ authWitnesses: Array.from(this.authwits.values()),
367
+ capsules: [],
368
+ executionCache: HashedValuesCache.create([new HashedValues(args, argsHash)]),
351
369
  noteCache,
352
370
  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,
371
+ contractStore: this.contractStore,
372
+ noteStore: this.noteStore,
373
+ keyStore: this.keyStore,
374
+ addressStore: this.addressStore,
375
+ aztecNode: this.stateMachine.node,
376
+ senderTaggingStore: this.senderTaggingStore,
377
+ recipientTaggingStore: this.recipientTaggingStore,
378
+ senderAddressBookStore: this.senderAddressBookStore,
379
+ capsuleStore: this.capsuleStore,
380
+ privateEventStore: this.privateEventStore,
381
+ contractSyncService: this.stateMachine.contractSyncService,
382
+ jobId,
383
+ totalPublicCalldataCount: 0,
384
+ sideEffectCounter: minRevertibleSideEffectCounter,
385
+ scopes: effectiveScopes,
386
+ // In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
387
+ // contract would perform, including setting senderForTags.
388
+ senderForTags: from,
374
389
  simulator,
375
- );
390
+ messageContextService: this.stateMachine.messageContextService,
391
+ });
376
392
 
377
393
  // 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
394
  let result: PrivateExecutionResult;
@@ -394,7 +410,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
394
410
  );
395
411
  const publicFunctionsCalldata = await Promise.all(
396
412
  publicCallRequests.map(async r => {
397
- const calldata = await privateExecutionOracle.privateLoadFromExecutionCache(r.calldataHash);
413
+ const calldata = await privateExecutionOracle.loadFromExecutionCache(r.calldataHash);
398
414
  return new HashedValues(calldata, r.calldataHash);
399
415
  }),
400
416
  );
@@ -412,6 +428,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
412
428
  const { publicInputs } = await generateSimulatedProvingResult(
413
429
  result,
414
430
  (addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
431
+ this.stateMachine.node,
415
432
  minRevertibleSideEffectCounter,
416
433
  );
417
434
 
@@ -507,7 +524,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
507
524
  return executionResult.returnValues ?? [];
508
525
  }
509
526
 
510
- async txePublicCallNewFlow(
527
+ async publicCallNewFlow(
511
528
  from: AztecAddress,
512
529
  targetContractAddress: AztecAddress,
513
530
  calldata: Fr[],
@@ -517,7 +534,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
517
534
  `Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
518
535
  );
519
536
 
520
- const blockNumber = await this.txeGetNextBlockNumber();
537
+ const blockNumber = await this.getNextBlockNumber();
521
538
 
522
539
  const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
523
540
 
@@ -594,7 +611,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
594
611
  constantData,
595
612
  /*gasUsed=*/ new Gas(0, 0),
596
613
  /*feePayer=*/ AztecAddress.zero(),
597
- /*includeByTimestamp=*/ 0n,
614
+ /*expirationTimestamp=*/ 0n,
598
615
  inputsForPublic,
599
616
  undefined,
600
617
  );
@@ -662,10 +679,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
662
679
  return returnValues ?? [];
663
680
  }
664
681
 
665
- async txeSimulateUtilityFunction(
682
+ async executeUtilityFunction(
666
683
  targetContractAddress: AztecAddress,
667
684
  functionSelector: FunctionSelector,
668
685
  args: Fr[],
686
+ jobId: string,
669
687
  ) {
670
688
  const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
671
689
  if (!artifact) {
@@ -677,11 +695,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
677
695
  await this.stateMachine.contractSyncService.ensureContractSynced(
678
696
  targetContractAddress,
679
697
  functionSelector,
680
- async call => {
681
- await this.executeUtilityCall(call);
698
+ async (call, execScopes) => {
699
+ await this.executeUtilityCall(call, execScopes, jobId);
682
700
  },
683
701
  blockHeader,
684
- this.jobId,
702
+ jobId,
703
+ 'ALL_SCOPES',
685
704
  );
686
705
 
687
706
  const call = FunctionCall.from({
@@ -695,10 +714,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
695
714
  returnTypes: [],
696
715
  });
697
716
 
698
- return this.executeUtilityCall(call);
717
+ return this.executeUtilityCall(call, 'ALL_SCOPES', jobId);
699
718
  }
700
719
 
701
- private async executeUtilityCall(call: FunctionCall, scopes?: AztecAddress[]): Promise<Fr[]> {
720
+ private async executeUtilityCall(call: FunctionCall, scopes: AccessScopes, jobId: string): Promise<Fr[]> {
702
721
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
703
722
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
704
723
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
@@ -711,24 +730,24 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
711
730
 
712
731
  try {
713
732
  const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
714
- const oracle = new UtilityExecutionOracle(
715
- call.to,
716
- [],
717
- [],
733
+ const oracle = new UtilityExecutionOracle({
734
+ contractAddress: call.to,
735
+ authWitnesses: [],
736
+ capsules: [],
718
737
  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
- );
738
+ contractStore: this.contractStore,
739
+ noteStore: this.noteStore,
740
+ keyStore: this.keyStore,
741
+ addressStore: this.addressStore,
742
+ aztecNode: this.stateMachine.node,
743
+ recipientTaggingStore: this.recipientTaggingStore,
744
+ senderAddressBookStore: this.senderAddressBookStore,
745
+ capsuleStore: this.capsuleStore,
746
+ privateEventStore: this.privateEventStore,
747
+ messageContextService: this.stateMachine.messageContextService,
748
+ jobId,
749
+ scopes,
750
+ });
732
751
  const acirExecutionResult = await new WASMSimulator()
733
752
  .executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
734
753
  .catch((err: Error) => {
@@ -744,10 +763,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
744
763
  );
745
764
  });
746
765
 
747
- this.logger.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
766
+ this.logger.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
748
767
  return witnessMapToFields(acirExecutionResult.returnWitness);
749
768
  } catch (err) {
750
- throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility simulation'));
769
+ throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility execution'));
751
770
  }
752
771
  }
753
772