@aztec/txe 0.0.1-commit.43c09e3f → 0.0.1-commit.4d3c002

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 +125 -51
  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 +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 +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 +129 -96
  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 +46 -24
  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,9 +323,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
296
323
  throw new Error(message);
297
324
  }
298
325
 
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];
329
+
299
330
  // Sync notes before executing private function to discover notes from previous transactions
300
- const utilityExecutor = async (call: FunctionCall) => {
301
- await this.executeUtilityCall(call);
331
+ const utilityExecutor = async (call: FunctionCall, execScopes: AztecAddress[]) => {
332
+ await this.executeUtilityCall(call, execScopes, jobId);
302
333
  };
303
334
 
304
335
  const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
@@ -307,10 +338,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
307
338
  functionSelector,
308
339
  utilityExecutor,
309
340
  blockHeader,
310
- this.jobId,
341
+ jobId,
342
+ effectiveScopes,
311
343
  );
312
344
 
313
- const blockNumber = await this.txeGetNextBlockNumber();
345
+ const blockNumber = await this.getNextBlockNumber();
314
346
 
315
347
  const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
316
348
 
@@ -331,43 +363,38 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
331
363
 
332
364
  const simulator = new WASMSimulator();
333
365
 
334
- const privateExecutionOracle = new PrivateExecutionOracle(
366
+ const privateExecutionOracle = new PrivateExecutionOracle({
335
367
  argsHash,
336
368
  txContext,
337
369
  callContext,
338
- /** Header of a block whose state is used during private execution (not the block the transaction is included in). */
339
- blockHeader,
370
+ anchorBlockHeader: blockHeader,
340
371
  utilityExecutor,
341
- /** List of transient auth witnesses to be used during this simulation */
342
- Array.from(this.authwits.values()),
343
- /** List of transient auth witnesses to be used during this simulation */
344
- [],
345
- HashedValuesCache.create([new HashedValues(args, argsHash)]),
372
+ authWitnesses: Array.from(this.authwits.values()),
373
+ capsules: [],
374
+ executionCache: HashedValuesCache.create([new HashedValues(args, argsHash)]),
346
375
  noteCache,
347
376
  taggingIndexCache,
348
- this.contractStore,
349
- this.noteStore,
350
- this.keyStore,
351
- this.addressStore,
352
- this.stateMachine.node,
353
- this.senderTaggingStore,
354
- this.recipientTaggingStore,
355
- this.senderAddressBookStore,
356
- this.capsuleStore,
357
- this.privateEventStore,
358
- this.stateMachine.contractSyncService,
359
- this.jobId,
360
- 0, // totalPublicArgsCount
361
- minRevertibleSideEffectCounter, // (start) sideEffectCounter
362
- undefined, // log
363
- undefined, // scopes
364
- /**
365
- * In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
366
- * contract would perform, including setting senderForTags.
367
- */
368
- 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,
369
395
  simulator,
370
- );
396
+ messageContextService: this.stateMachine.messageContextService,
397
+ });
371
398
 
372
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.
373
400
  let result: PrivateExecutionResult;
@@ -389,7 +416,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
389
416
  );
390
417
  const publicFunctionsCalldata = await Promise.all(
391
418
  publicCallRequests.map(async r => {
392
- const calldata = await privateExecutionOracle.privateLoadFromExecutionCache(r.calldataHash);
419
+ const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
393
420
  return new HashedValues(calldata, r.calldataHash);
394
421
  }),
395
422
  );
@@ -406,7 +433,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
406
433
  // We pass the non-zero minRevertibleSideEffectCounter to make sure the side effects are split correctly.
407
434
  const { publicInputs } = await generateSimulatedProvingResult(
408
435
  result,
409
- this.contractStore,
436
+ (addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
437
+ this.stateMachine.node,
410
438
  minRevertibleSideEffectCounter,
411
439
  );
412
440
 
@@ -502,7 +530,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
502
530
  return executionResult.returnValues ?? [];
503
531
  }
504
532
 
505
- async txePublicCallNewFlow(
533
+ async publicCallNewFlow(
506
534
  from: AztecAddress,
507
535
  targetContractAddress: AztecAddress,
508
536
  calldata: Fr[],
@@ -512,7 +540,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
512
540
  `Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
513
541
  );
514
542
 
515
- const blockNumber = await this.txeGetNextBlockNumber();
543
+ const blockNumber = await this.getNextBlockNumber();
516
544
 
517
545
  const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
518
546
 
@@ -589,7 +617,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
589
617
  constantData,
590
618
  /*gasUsed=*/ new Gas(0, 0),
591
619
  /*feePayer=*/ AztecAddress.zero(),
592
- /*includeByTimestamp=*/ 0n,
620
+ /*expirationTimestamp=*/ 0n,
593
621
  inputsForPublic,
594
622
  undefined,
595
623
  );
@@ -657,10 +685,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
657
685
  return returnValues ?? [];
658
686
  }
659
687
 
660
- async txeSimulateUtilityFunction(
688
+ async executeUtilityFunction(
661
689
  targetContractAddress: AztecAddress,
662
690
  functionSelector: FunctionSelector,
663
691
  args: Fr[],
692
+ jobId: string,
664
693
  ) {
665
694
  const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
666
695
  if (!artifact) {
@@ -672,28 +701,29 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
672
701
  await this.stateMachine.contractSyncService.ensureContractSynced(
673
702
  targetContractAddress,
674
703
  functionSelector,
675
- async call => {
676
- await this.executeUtilityCall(call);
704
+ async (call, execScopes) => {
705
+ await this.executeUtilityCall(call, execScopes, jobId);
677
706
  },
678
707
  blockHeader,
679
- this.jobId,
708
+ jobId,
709
+ await this.keyStore.getAccounts(),
680
710
  );
681
711
 
682
- const call = new FunctionCall(
683
- artifact.name,
684
- targetContractAddress,
685
- functionSelector,
686
- FunctionType.UTILITY,
687
- false,
688
- 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,
689
719
  args,
690
- [],
691
- );
720
+ returnTypes: [],
721
+ });
692
722
 
693
- return this.executeUtilityCall(call);
723
+ return this.executeUtilityCall(call, await this.keyStore.getAccounts(), jobId);
694
724
  }
695
725
 
696
- private async executeUtilityCall(call: FunctionCall): Promise<Fr[]> {
726
+ private async executeUtilityCall(call: FunctionCall, scopes: AztecAddress[], jobId: string): Promise<Fr[]> {
697
727
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
698
728
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
699
729
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
@@ -706,22 +736,25 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
706
736
 
707
737
  try {
708
738
  const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
709
- const oracle = new UtilityExecutionOracle(
710
- call.to,
711
- [],
712
- [],
739
+ const oracle = new UtilityExecutionOracle({
740
+ contractAddress: call.to,
741
+ authWitnesses: [],
742
+ capsules: [],
713
743
  anchorBlockHeader,
714
- this.contractStore,
715
- this.noteStore,
716
- this.keyStore,
717
- this.addressStore,
718
- this.stateMachine.node,
719
- this.recipientTaggingStore,
720
- this.senderAddressBookStore,
721
- this.capsuleStore,
722
- this.privateEventStore,
723
- this.jobId,
724
- );
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
+ });
725
758
  const acirExecutionResult = await new WASMSimulator()
726
759
  .executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
727
760
  .catch((err: Error) => {
@@ -737,10 +770,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
737
770
  );
738
771
  });
739
772
 
740
- this.logger.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
773
+ this.logger.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
741
774
  return witnessMapToFields(acirExecutionResult.returnWitness);
742
775
  } catch (err) {
743
- 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'));
744
777
  }
745
778
  }
746
779