@aztec/txe 0.0.1-commit.e558bd1c → 0.0.1-commit.e588bc7e5

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 (58) 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 +23 -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 +123 -55
  12. package/dest/rpc_translator.d.ts +88 -83
  13. package/dest/rpc_translator.d.ts.map +1 -1
  14. package/dest/rpc_translator.js +285 -152
  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 +16 -12
  19. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  20. package/dest/state_machine/dummy_p2p_client.js +28 -16
  21. package/dest/state_machine/global_variable_builder.d.ts +3 -3
  22. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  23. package/dest/state_machine/global_variable_builder.js +1 -1
  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 +7 -3
  27. package/dest/state_machine/mock_epoch_cache.d.ts +19 -3
  28. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  29. package/dest/state_machine/mock_epoch_cache.js +36 -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 +89 -24
  36. package/dest/util/encoding.d.ts +69 -1
  37. package/dest/util/encoding.d.ts.map +1 -1
  38. package/dest/util/txe_public_contract_data_source.d.ts +2 -3
  39. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  40. package/dest/util/txe_public_contract_data_source.js +6 -25
  41. package/package.json +15 -15
  42. package/src/index.ts +89 -52
  43. package/src/oracle/interfaces.ts +32 -31
  44. package/src/oracle/txe_oracle_public_context.ts +12 -12
  45. package/src/oracle/txe_oracle_top_level_context.ts +128 -102
  46. package/src/rpc_translator.ts +332 -174
  47. package/src/state_machine/archiver.ts +6 -5
  48. package/src/state_machine/dummy_p2p_client.ts +39 -22
  49. package/src/state_machine/global_variable_builder.ts +7 -1
  50. package/src/state_machine/index.ts +7 -1
  51. package/src/state_machine/mock_epoch_cache.ts +47 -3
  52. package/src/state_machine/synchronizer.ts +4 -4
  53. package/src/txe_session.ts +94 -72
  54. package/src/util/txe_public_contract_data_source.ts +10 -38
  55. package/dest/util/txe_contract_store.d.ts +0 -12
  56. package/dest/util/txe_contract_store.d.ts.map +0 -1
  57. package/dest/util/txe_contract_store.js +0 -22
  58. package/src/util/txe_contract_store.ts +0 -36
@@ -14,7 +14,10 @@ import { TestDateProvider } from '@aztec/foundation/timer';
14
14
  import type { KeyStore } from '@aztec/key-store';
15
15
  import {
16
16
  AddressStore,
17
+ CapsuleService,
17
18
  CapsuleStore,
19
+ type ContractStore,
20
+ type ContractSyncService,
18
21
  NoteStore,
19
22
  ORACLE_VERSION,
20
23
  PrivateEventStore,
@@ -83,7 +86,6 @@ import { ForkCheckpoint } from '@aztec/world-state';
83
86
  import { DEFAULT_ADDRESS } from '../constants.js';
84
87
  import type { TXEStateMachine } from '../state_machine/index.js';
85
88
  import type { TXEAccountStore } from '../util/txe_account_store.js';
86
- import type { TXEContractStore } from '../util/txe_contract_store.js';
87
89
  import { TXEPublicContractDataSource } from '../util/txe_public_contract_data_source.js';
88
90
  import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
89
91
  import type { ITxeExecutionOracle } from './interfaces.js';
@@ -96,7 +98,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
96
98
 
97
99
  constructor(
98
100
  private stateMachine: TXEStateMachine,
99
- private contractStore: TXEContractStore,
101
+ private contractStore: ContractStore,
100
102
  private noteStore: NoteStore,
101
103
  private keyStore: KeyStore,
102
104
  private addressStore: AddressStore,
@@ -106,57 +108,62 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
106
108
  private senderAddressBookStore: SenderAddressBookStore,
107
109
  private capsuleStore: CapsuleStore,
108
110
  private privateEventStore: PrivateEventStore,
109
- private jobId: string,
110
111
  private nextBlockTimestamp: bigint,
111
112
  private version: Fr,
112
113
  private chainId: Fr,
113
114
  private authwits: Map<string, AuthWitness>,
115
+ private readonly contractSyncService: ContractSyncService,
114
116
  ) {
115
117
  this.logger = createLogger('txe:top_level_context');
116
118
  this.logger.debug('Entering Top Level Context');
117
119
  }
118
120
 
119
- utilityAssertCompatibleOracleVersion(version: number): void {
121
+ assertCompatibleOracleVersion(version: number): void {
120
122
  if (version !== ORACLE_VERSION) {
123
+ const hint =
124
+ version > ORACLE_VERSION
125
+ ? '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.'
126
+ : '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
127
  throw new Error(
122
- `Incompatible oracle version. TXE is using version '${ORACLE_VERSION}', but got a request for '${version}'.`,
128
+ `Incompatible aztec cli version: ${hint} See https://docs.aztec.network/errors/8 (expected oracle version ${ORACLE_VERSION}, got ${version})`,
123
129
  );
124
130
  }
125
131
  }
126
132
 
127
133
  // This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
128
134
  // setup.
129
- utilityGetRandomField(): Fr {
135
+ getRandomField(): Fr {
130
136
  return Fr.random();
131
137
  }
132
138
 
133
139
  // 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 {
140
+ log(level: number, message: string, fields: Fr[]): Promise<void> {
135
141
  if (!LogLevels[level]) {
136
- throw new Error(`Invalid debug log level: ${level}`);
142
+ throw new Error(`Invalid log level: ${level}`);
137
143
  }
138
144
  const levelName = LogLevels[level];
139
145
 
140
146
  this.logger[levelName](`${applyStringFormatting(message, fields)}`, { module: `${this.logger.module}:debug_log` });
147
+ return Promise.resolve();
141
148
  }
142
149
 
143
- txeGetDefaultAddress(): AztecAddress {
150
+ getDefaultAddress(): AztecAddress {
144
151
  return DEFAULT_ADDRESS;
145
152
  }
146
153
 
147
- async txeGetNextBlockNumber(): Promise<BlockNumber> {
154
+ async getNextBlockNumber(): Promise<BlockNumber> {
148
155
  return BlockNumber((await this.getLastBlockNumber()) + 1);
149
156
  }
150
157
 
151
- txeGetNextBlockTimestamp(): Promise<bigint> {
158
+ getNextBlockTimestamp(): Promise<bigint> {
152
159
  return Promise.resolve(this.nextBlockTimestamp);
153
160
  }
154
161
 
155
- async txeGetLastBlockTimestamp() {
162
+ async getLastBlockTimestamp() {
156
163
  return (await this.stateMachine.node.getBlockHeader('latest'))!.globalVariables.timestamp;
157
164
  }
158
165
 
159
- async txeGetLastTxEffects() {
166
+ async getLastTxEffects() {
160
167
  const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
161
168
  const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
162
169
 
@@ -170,7 +177,26 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
170
177
  return { txHash: txEffects.txHash, noteHashes: txEffects.noteHashes, nullifiers: txEffects.nullifiers };
171
178
  }
172
179
 
173
- async txeGetPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) {
180
+ async syncContractNonOracleMethod(contractAddress: AztecAddress, scope: AztecAddress, jobId: string) {
181
+ if (contractAddress.equals(DEFAULT_ADDRESS)) {
182
+ this.logger.debug(`Skipping sync in getPrivateEvents because the events correspond to the default address.`);
183
+ return;
184
+ }
185
+
186
+ const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
187
+ await this.stateMachine.contractSyncService.ensureContractSynced(
188
+ contractAddress,
189
+ null,
190
+ async (call, execScopes) => {
191
+ await this.executeUtilityCall(call, execScopes, jobId);
192
+ },
193
+ blockHeader,
194
+ jobId,
195
+ [scope],
196
+ );
197
+ }
198
+
199
+ async getPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) {
174
200
  return (
175
201
  await this.privateEventStore.getPrivateEvents(selector, {
176
202
  contractAddress,
@@ -181,7 +207,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
181
207
  ).map(e => e.packedEvent);
182
208
  }
183
209
 
184
- async txeAdvanceBlocksBy(blocks: number) {
210
+ async advanceBlocksBy(blocks: number) {
185
211
  this.logger.debug(`time traveling ${blocks} blocks`);
186
212
 
187
213
  for (let i = 0; i < blocks; i++) {
@@ -189,12 +215,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
189
215
  }
190
216
  }
191
217
 
192
- txeAdvanceTimestampBy(duration: UInt64) {
218
+ advanceTimestampBy(duration: UInt64) {
193
219
  this.logger.debug(`time traveling ${duration} seconds`);
194
220
  this.nextBlockTimestamp += duration;
195
221
  }
196
222
 
197
- async txeDeploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
223
+ async deploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
198
224
  // Emit deployment nullifier
199
225
  await this.mineBlock({
200
226
  nullifiers: [
@@ -206,20 +232,20 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
206
232
  });
207
233
 
208
234
  if (!secret.equals(Fr.ZERO)) {
209
- await this.txeAddAccount(artifact, instance, secret);
235
+ await this.addAccount(artifact, instance, secret);
210
236
  } else {
211
237
  await this.contractStore.addContractInstance(instance);
212
- await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
238
+ await this.contractStore.addContractArtifact(artifact);
213
239
  this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
214
240
  }
215
241
  }
216
242
 
217
- async txeAddAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
243
+ async addAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
218
244
  const partialAddress = await computePartialAddress(instance);
219
245
 
220
246
  this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
221
247
  await this.contractStore.addContractInstance(instance);
222
- await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
248
+ await this.contractStore.addContractArtifact(artifact);
223
249
 
224
250
  const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
225
251
  await this.accountStore.setAccount(completeAddress.address, completeAddress);
@@ -229,7 +255,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
229
255
  return completeAddress;
230
256
  }
231
257
 
232
- async txeCreateAccount(secret: Fr) {
258
+ async createAccount(secret: Fr) {
233
259
  // This is a foot gun !
234
260
  const completeAddress = await this.keyStore.addAccount(secret, secret);
235
261
  await this.accountStore.setAccount(completeAddress.address, completeAddress);
@@ -239,7 +265,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
239
265
  return completeAddress;
240
266
  }
241
267
 
242
- async txeAddAuthWitness(address: AztecAddress, messageHash: Fr) {
268
+ async addAuthWitness(address: AztecAddress, messageHash: Fr) {
243
269
  const account = await this.accountStore.getAccount(address);
244
270
  const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
245
271
 
@@ -252,7 +278,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
252
278
  }
253
279
 
254
280
  async mineBlock(options: { nullifiers?: Fr[] } = {}) {
255
- const blockNumber = await this.txeGetNextBlockNumber();
281
+ const blockNumber = await this.getNextBlockNumber();
256
282
 
257
283
  const txEffect = TxEffect.empty();
258
284
  txEffect.nullifiers = [getSingleTxBlockRequestHash(blockNumber), ...(options.nullifiers ?? [])];
@@ -276,13 +302,14 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
276
302
  await this.stateMachine.handleL2Block(block);
277
303
  }
278
304
 
279
- async txePrivateCallNewFlow(
305
+ async privateCallNewFlow(
280
306
  from: AztecAddress,
281
307
  targetContractAddress: AztecAddress = AztecAddress.zero(),
282
308
  functionSelector: FunctionSelector = FunctionSelector.empty(),
283
309
  args: Fr[],
284
310
  argsHash: Fr = Fr.zero(),
285
311
  isStaticCall: boolean = false,
312
+ jobId: string,
286
313
  ) {
287
314
  this.logger.verbose(
288
315
  `Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
@@ -296,14 +323,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
296
323
  throw new Error(message);
297
324
  }
298
325
 
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];
326
+ // When `from` is the zero address (e.g. when deploying a new account contract), we return an
327
+ // empty scope list which acts as deny-all: no notes are visible and no keys are accessible.
328
+ const effectiveScopes = from.isZero() ? [] : [from];
303
329
 
304
330
  // Sync notes before executing private function to discover notes from previous transactions
305
- const utilityExecutor = async (call: FunctionCall) => {
306
- await this.executeUtilityCall(call, effectiveScopes);
331
+ const utilityExecutor = async (call: FunctionCall, execScopes: AztecAddress[]) => {
332
+ await this.executeUtilityCall(call, execScopes, jobId);
307
333
  };
308
334
 
309
335
  const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
@@ -312,10 +338,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
312
338
  functionSelector,
313
339
  utilityExecutor,
314
340
  blockHeader,
315
- this.jobId,
341
+ jobId,
342
+ effectiveScopes,
316
343
  );
317
344
 
318
- const blockNumber = await this.txeGetNextBlockNumber();
345
+ const blockNumber = await this.getNextBlockNumber();
319
346
 
320
347
  const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
321
348
 
@@ -336,43 +363,38 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
336
363
 
337
364
  const simulator = new WASMSimulator();
338
365
 
339
- const privateExecutionOracle = new PrivateExecutionOracle(
366
+ const privateExecutionOracle = new PrivateExecutionOracle({
340
367
  argsHash,
341
368
  txContext,
342
369
  callContext,
343
- /** Header of a block whose state is used during private execution (not the block the transaction is included in). */
344
- blockHeader,
370
+ anchorBlockHeader: blockHeader,
345
371
  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)]),
372
+ authWitnesses: Array.from(this.authwits.values()),
373
+ capsules: [],
374
+ executionCache: HashedValuesCache.create([new HashedValues(args, argsHash)]),
351
375
  noteCache,
352
376
  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,
377
+ contractStore: this.contractStore,
378
+ noteStore: this.noteStore,
379
+ keyStore: this.keyStore,
380
+ addressStore: this.addressStore,
381
+ aztecNode: this.stateMachine.node,
382
+ senderTaggingStore: this.senderTaggingStore,
383
+ recipientTaggingStore: this.recipientTaggingStore,
384
+ senderAddressBookStore: this.senderAddressBookStore,
385
+ capsuleService: new CapsuleService(this.capsuleStore, effectiveScopes),
386
+ privateEventStore: this.privateEventStore,
387
+ contractSyncService: this.stateMachine.contractSyncService,
388
+ jobId,
389
+ totalPublicCalldataCount: 0,
390
+ sideEffectCounter: minRevertibleSideEffectCounter,
391
+ scopes: effectiveScopes,
392
+ // In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
393
+ // contract would perform, including setting senderForTags.
394
+ senderForTags: from,
374
395
  simulator,
375
- );
396
+ messageContextService: this.stateMachine.messageContextService,
397
+ });
376
398
 
377
399
  // 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
400
  let result: PrivateExecutionResult;
@@ -394,7 +416,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
394
416
  );
395
417
  const publicFunctionsCalldata = await Promise.all(
396
418
  publicCallRequests.map(async r => {
397
- const calldata = await privateExecutionOracle.privateLoadFromExecutionCache(r.calldataHash);
419
+ const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
398
420
  return new HashedValues(calldata, r.calldataHash);
399
421
  }),
400
422
  );
@@ -411,7 +433,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
411
433
  // We pass the non-zero minRevertibleSideEffectCounter to make sure the side effects are split correctly.
412
434
  const { publicInputs } = await generateSimulatedProvingResult(
413
435
  result,
414
- this.contractStore,
436
+ (addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
437
+ this.stateMachine.node,
415
438
  minRevertibleSideEffectCounter,
416
439
  );
417
440
 
@@ -507,7 +530,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
507
530
  return executionResult.returnValues ?? [];
508
531
  }
509
532
 
510
- async txePublicCallNewFlow(
533
+ async publicCallNewFlow(
511
534
  from: AztecAddress,
512
535
  targetContractAddress: AztecAddress,
513
536
  calldata: Fr[],
@@ -517,7 +540,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
517
540
  `Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
518
541
  );
519
542
 
520
- const blockNumber = await this.txeGetNextBlockNumber();
543
+ const blockNumber = await this.getNextBlockNumber();
521
544
 
522
545
  const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
523
546
 
@@ -594,7 +617,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
594
617
  constantData,
595
618
  /*gasUsed=*/ new Gas(0, 0),
596
619
  /*feePayer=*/ AztecAddress.zero(),
597
- /*includeByTimestamp=*/ 0n,
620
+ /*expirationTimestamp=*/ 0n,
598
621
  inputsForPublic,
599
622
  undefined,
600
623
  );
@@ -662,10 +685,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
662
685
  return returnValues ?? [];
663
686
  }
664
687
 
665
- async txeSimulateUtilityFunction(
688
+ async executeUtilityFunction(
666
689
  targetContractAddress: AztecAddress,
667
690
  functionSelector: FunctionSelector,
668
691
  args: Fr[],
692
+ jobId: string,
669
693
  ) {
670
694
  const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
671
695
  if (!artifact) {
@@ -677,28 +701,29 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
677
701
  await this.stateMachine.contractSyncService.ensureContractSynced(
678
702
  targetContractAddress,
679
703
  functionSelector,
680
- async call => {
681
- await this.executeUtilityCall(call);
704
+ async (call, execScopes) => {
705
+ await this.executeUtilityCall(call, execScopes, jobId);
682
706
  },
683
707
  blockHeader,
684
- this.jobId,
708
+ jobId,
709
+ await this.keyStore.getAccounts(),
685
710
  );
686
711
 
687
- const call = new FunctionCall(
688
- artifact.name,
689
- targetContractAddress,
690
- functionSelector,
691
- FunctionType.UTILITY,
692
- false,
693
- false,
712
+ const call = FunctionCall.from({
713
+ name: artifact.name,
714
+ to: targetContractAddress,
715
+ selector: functionSelector,
716
+ type: FunctionType.UTILITY,
717
+ hideMsgSender: false,
718
+ isStatic: false,
694
719
  args,
695
- [],
696
- );
720
+ returnTypes: [],
721
+ });
697
722
 
698
- return this.executeUtilityCall(call);
723
+ return this.executeUtilityCall(call, await this.keyStore.getAccounts(), jobId);
699
724
  }
700
725
 
701
- private async executeUtilityCall(call: FunctionCall, scopes?: AztecAddress[]): Promise<Fr[]> {
726
+ private async executeUtilityCall(call: FunctionCall, scopes: AztecAddress[], jobId: string): Promise<Fr[]> {
702
727
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
703
728
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
704
729
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
@@ -711,24 +736,25 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
711
736
 
712
737
  try {
713
738
  const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
714
- const oracle = new UtilityExecutionOracle(
715
- call.to,
716
- [],
717
- [],
739
+ const oracle = new UtilityExecutionOracle({
740
+ contractAddress: call.to,
741
+ authWitnesses: [],
742
+ capsules: [],
718
743
  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
- );
744
+ contractStore: this.contractStore,
745
+ noteStore: this.noteStore,
746
+ keyStore: this.keyStore,
747
+ addressStore: this.addressStore,
748
+ aztecNode: this.stateMachine.node,
749
+ recipientTaggingStore: this.recipientTaggingStore,
750
+ senderAddressBookStore: this.senderAddressBookStore,
751
+ capsuleService: new CapsuleService(this.capsuleStore, scopes),
752
+ privateEventStore: this.privateEventStore,
753
+ messageContextService: this.stateMachine.messageContextService,
754
+ contractSyncService: this.contractSyncService,
755
+ jobId,
756
+ scopes,
757
+ });
732
758
  const acirExecutionResult = await new WASMSimulator()
733
759
  .executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
734
760
  .catch((err: Error) => {
@@ -744,10 +770,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
744
770
  );
745
771
  });
746
772
 
747
- this.logger.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
773
+ this.logger.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
748
774
  return witnessMapToFields(acirExecutionResult.returnWitness);
749
775
  } catch (err) {
750
- throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility simulation'));
776
+ throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility execution'));
751
777
  }
752
778
  }
753
779