@aztec/pxe 0.0.1-commit.f2ce05ee → 0.0.1-commit.f8ca9b2f3

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 (37) hide show
  1. package/dest/contract_function_simulator/contract_function_simulator.d.ts +48 -26
  2. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  3. package/dest/contract_function_simulator/contract_function_simulator.js +63 -29
  4. package/dest/contract_function_simulator/oracle/interfaces.d.ts +2 -2
  5. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  6. package/dest/contract_function_simulator/oracle/oracle.d.ts +2 -2
  7. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  8. package/dest/contract_function_simulator/oracle/oracle.js +2 -2
  9. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +34 -36
  10. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  11. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +62 -17
  12. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +29 -12
  13. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  14. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +22 -24
  15. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  16. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  17. package/dest/entrypoints/client/bundle/utils.js +9 -1
  18. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  19. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  20. package/dest/entrypoints/client/lazy/utils.js +9 -1
  21. package/dest/entrypoints/server/utils.js +9 -1
  22. package/dest/oracle_version.d.ts +2 -2
  23. package/dest/oracle_version.js +2 -2
  24. package/dest/pxe.d.ts +52 -21
  25. package/dest/pxe.d.ts.map +1 -1
  26. package/dest/pxe.js +30 -26
  27. package/package.json +16 -16
  28. package/src/contract_function_simulator/contract_function_simulator.ts +106 -71
  29. package/src/contract_function_simulator/oracle/interfaces.ts +1 -1
  30. package/src/contract_function_simulator/oracle/oracle.ts +2 -2
  31. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +81 -93
  32. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +58 -21
  33. package/src/entrypoints/client/bundle/utils.ts +9 -1
  34. package/src/entrypoints/client/lazy/utils.ts +9 -1
  35. package/src/entrypoints/server/utils.ts +7 -7
  36. package/src/oracle_version.ts +2 -2
  37. package/src/pxe.ts +83 -58
package/dest/pxe.js CHANGED
@@ -84,11 +84,12 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
84
84
  * can be contacted.
85
85
  *
86
86
  * @returns A promise that resolves PXE is ready to be used.
87
- */ static async create(node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix) {
87
+ */ static async create({ node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix }) {
88
88
  // Extract bindings from the logger, or use empty bindings if a string suffix is provided.
89
89
  const bindings = loggerOrSuffix && typeof loggerOrSuffix !== 'string' ? loggerOrSuffix.getBindings() : undefined;
90
90
  const log = !loggerOrSuffix || typeof loggerOrSuffix === 'string' ? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`) : loggerOrSuffix;
91
- const proverEnabled = !!config.proverEnabled;
91
+ const info = await node.getNodeInfo();
92
+ const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
92
93
  const addressStore = new AddressStore(store);
93
94
  const privateEventStore = new PrivateEventStore(store);
94
95
  const contractStore = new ContractStore(store);
@@ -117,14 +118,26 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
117
118
  debugUtils.setPXEHelpers(pxe.#putInJobQueue.bind(pxe), pxe.#getSimulatorForTx.bind(pxe), pxe.#simulateUtility.bind(pxe));
118
119
  pxe.jobQueue.start();
119
120
  await pxe.#registerProtocolContracts();
120
- const info = await node.getNodeInfo();
121
121
  log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
122
122
  return pxe;
123
123
  }
124
124
  // Internal methods
125
125
  #getSimulatorForTx(overrides) {
126
126
  const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
127
- return new ContractFunctionSimulator(proxyContractStore, this.noteStore, this.keyStore, this.addressStore, BenchmarkedNodeFactory.create(this.node), this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, this.simulator, this.contractSyncService);
127
+ return new ContractFunctionSimulator({
128
+ contractStore: proxyContractStore,
129
+ noteStore: this.noteStore,
130
+ keyStore: this.keyStore,
131
+ addressStore: this.addressStore,
132
+ aztecNode: BenchmarkedNodeFactory.create(this.node),
133
+ senderTaggingStore: this.senderTaggingStore,
134
+ recipientTaggingStore: this.recipientTaggingStore,
135
+ senderAddressBookStore: this.senderAddressBookStore,
136
+ capsuleStore: this.capsuleStore,
137
+ privateEventStore: this.privateEventStore,
138
+ simulator: this.simulator,
139
+ contractSyncService: this.contractSyncService
140
+ });
128
141
  }
129
142
  #contextualizeError(err, ...context) {
130
143
  let contextStr = '';
@@ -181,9 +194,13 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
181
194
  try {
182
195
  const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
183
196
  await this.contractSyncService.ensureContractSynced(contractAddress, functionSelector, (privateSyncCall)=>this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId), anchorBlockHeader, jobId);
184
- const result = await contractFunctionSimulator.run(txRequest, contractAddress, functionSelector, undefined, anchorBlockHeader, // The sender for tags is set by contracts, typically by an account
185
- // contract entrypoint
186
- undefined, scopes, jobId);
197
+ const result = await contractFunctionSimulator.run(txRequest, {
198
+ contractAddress,
199
+ selector: functionSelector,
200
+ anchorBlockHeader,
201
+ scopes,
202
+ jobId
203
+ });
187
204
  this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
188
205
  return result;
189
206
  } catch (err) {
@@ -498,13 +515,10 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
498
515
  }
499
516
  /**
500
517
  * Profiles a transaction, reporting gate counts (unless disabled) and returns an execution trace.
501
- *
502
- * @param txRequest - An authenticated tx request ready for simulation
503
- * @param msgSender - (Optional) The message sender to use for the simulation.
504
- * @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
518
+ * @param txRequest - An authenticated tx request ready for simulation.
505
519
  * @returns A trace of the program execution with gate counts.
506
520
  * @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
507
- */ profileTx(txRequest, profileMode, skipProofGeneration = true) {
521
+ */ profileTx(txRequest, { profileMode, skipProofGeneration = true }) {
508
522
  // We disable concurrent profiles for consistency with simulateTx.
509
523
  return this.#putInJobQueue(async (jobId)=>{
510
524
  const totalTimer = new Timer();
@@ -567,18 +581,13 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
567
581
  * In that case, the transaction returned is only potentially ready to be sent to the network for execution.
568
582
  *
569
583
  *
570
- * @param txRequest - An authenticated tx request ready for simulation
571
- * @param simulatePublic - Whether to simulate the public part of the transaction.
572
- * @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
573
- * @param skipFeeEnforcement - (Optional) If false, fees are enforced.
574
- * @param overrides - (Optional) State overrides for the simulation, such as msgSender, contract instances and artifacts.
575
- * @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
584
+ * @param txRequest - An authenticated tx request ready for simulation.
576
585
  * @returns A simulated transaction result object that includes public and private return values.
577
586
  * @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
578
587
  * Also throws if simulatePublic is true and public simulation reverts.
579
588
  *
580
589
  * TODO(#7456) Prevent msgSender being defined here for the first call
581
- */ simulateTx(txRequest, simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes) {
590
+ */ simulateTx(txRequest, { simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes }) {
582
591
  // We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
583
592
  // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
584
593
  // delete the same read value, or reading values that another simulation is currently modifying).
@@ -678,14 +687,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
678
687
  });
679
688
  }
680
689
  /**
681
- * Simulate the execution of a contract utility function.
682
- *
690
+ * Simulates the execution of a contract utility function.
683
691
  * @param call - The function call containing the function details, arguments, and target contract address.
684
- * @param authwits - (Optional) The authentication witnesses required for the function call.
685
- * @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will
686
- * default to all.
687
- * @returns The result of the utility function call, structured based on the function ABI.
688
- */ simulateUtility(call, authwits, scopes) {
692
+ */ simulateUtility(call, { authwits, scopes } = {}) {
689
693
  // We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
690
694
  // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
691
695
  // delete the same read value, or reading values that another simulation is currently modifying).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/pxe",
3
- "version": "0.0.1-commit.f2ce05ee",
3
+ "version": "0.0.1-commit.f8ca9b2f3",
4
4
  "type": "module",
5
5
  "typedocOptions": {
6
6
  "entryPoints": [
@@ -70,19 +70,19 @@
70
70
  ]
71
71
  },
72
72
  "dependencies": {
73
- "@aztec/bb-prover": "0.0.1-commit.f2ce05ee",
74
- "@aztec/bb.js": "0.0.1-commit.f2ce05ee",
75
- "@aztec/builder": "0.0.1-commit.f2ce05ee",
76
- "@aztec/constants": "0.0.1-commit.f2ce05ee",
77
- "@aztec/ethereum": "0.0.1-commit.f2ce05ee",
78
- "@aztec/foundation": "0.0.1-commit.f2ce05ee",
79
- "@aztec/key-store": "0.0.1-commit.f2ce05ee",
80
- "@aztec/kv-store": "0.0.1-commit.f2ce05ee",
81
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.f2ce05ee",
82
- "@aztec/noir-types": "0.0.1-commit.f2ce05ee",
83
- "@aztec/protocol-contracts": "0.0.1-commit.f2ce05ee",
84
- "@aztec/simulator": "0.0.1-commit.f2ce05ee",
85
- "@aztec/stdlib": "0.0.1-commit.f2ce05ee",
73
+ "@aztec/bb-prover": "0.0.1-commit.f8ca9b2f3",
74
+ "@aztec/bb.js": "0.0.1-commit.f8ca9b2f3",
75
+ "@aztec/builder": "0.0.1-commit.f8ca9b2f3",
76
+ "@aztec/constants": "0.0.1-commit.f8ca9b2f3",
77
+ "@aztec/ethereum": "0.0.1-commit.f8ca9b2f3",
78
+ "@aztec/foundation": "0.0.1-commit.f8ca9b2f3",
79
+ "@aztec/key-store": "0.0.1-commit.f8ca9b2f3",
80
+ "@aztec/kv-store": "0.0.1-commit.f8ca9b2f3",
81
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.f8ca9b2f3",
82
+ "@aztec/noir-types": "0.0.1-commit.f8ca9b2f3",
83
+ "@aztec/protocol-contracts": "0.0.1-commit.f8ca9b2f3",
84
+ "@aztec/simulator": "0.0.1-commit.f8ca9b2f3",
85
+ "@aztec/stdlib": "0.0.1-commit.f8ca9b2f3",
86
86
  "koa": "^2.16.1",
87
87
  "koa-router": "^13.1.1",
88
88
  "lodash.omit": "^4.5.0",
@@ -91,8 +91,8 @@
91
91
  "viem": "npm:@aztec/viem@2.38.2"
92
92
  },
93
93
  "devDependencies": {
94
- "@aztec/merkle-tree": "0.0.1-commit.f2ce05ee",
95
- "@aztec/noir-test-contracts.js": "0.0.1-commit.f2ce05ee",
94
+ "@aztec/merkle-tree": "0.0.1-commit.f8ca9b2f3",
95
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.f8ca9b2f3",
96
96
  "@jest/globals": "^30.0.0",
97
97
  "@types/jest": "^30.0.0",
98
98
  "@types/lodash.omit": "^4.5.7",
@@ -90,52 +90,89 @@ import { executePrivateFunction } from './oracle/private_execution.js';
90
90
  import { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
91
91
  import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
92
92
 
93
+ /** Options for ContractFunctionSimulator.run. */
94
+ export type ContractSimulatorRunOpts = {
95
+ /** The address of the contract (should match request.origin). */
96
+ contractAddress: AztecAddress;
97
+ /** The function selector of the entry point. */
98
+ selector: FunctionSelector;
99
+ /** The address calling the function. Can be replaced to simulate a call from another contract or account. */
100
+ msgSender?: AztecAddress;
101
+ /** The block header to use as base state for this run. */
102
+ anchorBlockHeader: BlockHeader;
103
+ /** The address used as a tagging sender when emitting private logs. */
104
+ senderForTags?: AztecAddress;
105
+ /** The accounts whose notes we can access in this call. Defaults to all. */
106
+ scopes?: AztecAddress[];
107
+ /** The job ID for staged writes. */
108
+ jobId: string;
109
+ };
110
+
111
+ /** Args for ContractFunctionSimulator constructor. */
112
+ export type ContractFunctionSimulatorArgs = {
113
+ contractStore: ContractStore;
114
+ noteStore: NoteStore;
115
+ keyStore: KeyStore;
116
+ addressStore: AddressStore;
117
+ aztecNode: AztecNode;
118
+ senderTaggingStore: SenderTaggingStore;
119
+ recipientTaggingStore: RecipientTaggingStore;
120
+ senderAddressBookStore: SenderAddressBookStore;
121
+ capsuleStore: CapsuleStore;
122
+ privateEventStore: PrivateEventStore;
123
+ simulator: CircuitSimulator;
124
+ contractSyncService: ContractSyncService;
125
+ };
126
+
93
127
  /**
94
128
  * The contract function simulator.
95
129
  */
96
130
  export class ContractFunctionSimulator {
97
- private log: Logger;
98
-
99
- constructor(
100
- private contractStore: ContractStore,
101
- private noteStore: NoteStore,
102
- private keyStore: KeyStore,
103
- private addressStore: AddressStore,
104
- private aztecNode: AztecNode,
105
- private senderTaggingStore: SenderTaggingStore,
106
- private recipientTaggingStore: RecipientTaggingStore,
107
- private senderAddressBookStore: SenderAddressBookStore,
108
- private capsuleStore: CapsuleStore,
109
- private privateEventStore: PrivateEventStore,
110
- private simulator: CircuitSimulator,
111
- private contractSyncService: ContractSyncService,
112
- ) {
131
+ private readonly log: Logger;
132
+ private readonly contractStore: ContractStore;
133
+ private readonly noteStore: NoteStore;
134
+ private readonly keyStore: KeyStore;
135
+ private readonly addressStore: AddressStore;
136
+ private readonly aztecNode: AztecNode;
137
+ private readonly senderTaggingStore: SenderTaggingStore;
138
+ private readonly recipientTaggingStore: RecipientTaggingStore;
139
+ private readonly senderAddressBookStore: SenderAddressBookStore;
140
+ private readonly capsuleStore: CapsuleStore;
141
+ private readonly privateEventStore: PrivateEventStore;
142
+ private readonly simulator: CircuitSimulator;
143
+ private readonly contractSyncService: ContractSyncService;
144
+
145
+ constructor(args: ContractFunctionSimulatorArgs) {
146
+ this.contractStore = args.contractStore;
147
+ this.noteStore = args.noteStore;
148
+ this.keyStore = args.keyStore;
149
+ this.addressStore = args.addressStore;
150
+ this.aztecNode = args.aztecNode;
151
+ this.senderTaggingStore = args.senderTaggingStore;
152
+ this.recipientTaggingStore = args.recipientTaggingStore;
153
+ this.senderAddressBookStore = args.senderAddressBookStore;
154
+ this.capsuleStore = args.capsuleStore;
155
+ this.privateEventStore = args.privateEventStore;
156
+ this.simulator = args.simulator;
157
+ this.contractSyncService = args.contractSyncService;
113
158
  this.log = createLogger('simulator');
114
159
  }
115
160
 
116
161
  /**
117
162
  * Runs a private function.
118
163
  * @param request - The transaction request.
119
- * @param entryPointArtifact - The artifact of the entry point function.
120
- * @param contractAddress - The address of the contract (should match request.origin)
121
- * @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract
122
- * or a specific account.
123
- * @param anchorBlockHeader - The block header to use as base state for this run.
124
- * @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
125
- * the `privateGetSenderForTags` oracle.
126
- * @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
127
- * @param jobId - The job ID for staged writes.
128
- * @returns The result of the execution.
129
164
  */
130
165
  public async run(
131
166
  request: TxExecutionRequest,
132
- contractAddress: AztecAddress,
133
- selector: FunctionSelector,
134
- msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE),
135
- anchorBlockHeader: BlockHeader,
136
- senderForTags: AztecAddress | undefined,
137
- scopes: AztecAddress[] | undefined,
138
- jobId: string,
167
+ {
168
+ contractAddress,
169
+ selector,
170
+ msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE),
171
+ anchorBlockHeader,
172
+ senderForTags,
173
+ scopes,
174
+ jobId,
175
+ }: ContractSimulatorRunOpts,
139
176
  ): Promise<PrivateExecutionResult> {
140
177
  const simulatorSetupTimer = new Timer();
141
178
 
@@ -165,38 +202,37 @@ export class ContractFunctionSimulator {
165
202
  const noteCache = new ExecutionNoteCache(protocolNullifier);
166
203
  const taggingIndexCache = new ExecutionTaggingIndexCache();
167
204
 
168
- const privateExecutionOracle = new PrivateExecutionOracle(
169
- request.firstCallArgsHash,
170
- request.txContext,
205
+ const privateExecutionOracle = new PrivateExecutionOracle({
206
+ argsHash: request.firstCallArgsHash,
207
+ txContext: request.txContext,
171
208
  callContext,
172
209
  anchorBlockHeader,
173
- async call => {
210
+ utilityExecutor: async call => {
174
211
  await this.runUtility(call, [], anchorBlockHeader, scopes, jobId);
175
212
  },
176
- request.authWitnesses,
177
- request.capsules,
178
- HashedValuesCache.create(request.argsOfCalls),
213
+ authWitnesses: request.authWitnesses,
214
+ capsules: request.capsules,
215
+ executionCache: HashedValuesCache.create(request.argsOfCalls),
179
216
  noteCache,
180
217
  taggingIndexCache,
181
- this.contractStore,
182
- this.noteStore,
183
- this.keyStore,
184
- this.addressStore,
185
- this.aztecNode,
186
- this.senderTaggingStore,
187
- this.recipientTaggingStore,
188
- this.senderAddressBookStore,
189
- this.capsuleStore,
190
- this.privateEventStore,
191
- this.contractSyncService,
218
+ contractStore: this.contractStore,
219
+ noteStore: this.noteStore,
220
+ keyStore: this.keyStore,
221
+ addressStore: this.addressStore,
222
+ aztecNode: this.aztecNode,
223
+ senderTaggingStore: this.senderTaggingStore,
224
+ recipientTaggingStore: this.recipientTaggingStore,
225
+ senderAddressBookStore: this.senderAddressBookStore,
226
+ capsuleStore: this.capsuleStore,
227
+ privateEventStore: this.privateEventStore,
228
+ contractSyncService: this.contractSyncService,
192
229
  jobId,
193
- 0, // totalPublicArgsCount
194
- startSideEffectCounter,
195
- undefined, // log
230
+ totalPublicCalldataCount: 0,
231
+ sideEffectCounter: startSideEffectCounter,
196
232
  scopes,
197
233
  senderForTags,
198
- this.simulator,
199
- );
234
+ simulator: this.simulator,
235
+ });
200
236
 
201
237
  const setupTime = simulatorSetupTimer.ms();
202
238
 
@@ -269,24 +305,23 @@ export class ContractFunctionSimulator {
269
305
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
270
306
  }
271
307
 
272
- const oracle = new UtilityExecutionOracle(
273
- call.to,
274
- authwits,
275
- [],
308
+ const oracle = new UtilityExecutionOracle({
309
+ contractAddress: call.to,
310
+ authWitnesses: authwits,
311
+ capsules: [],
276
312
  anchorBlockHeader,
277
- this.contractStore,
278
- this.noteStore,
279
- this.keyStore,
280
- this.addressStore,
281
- this.aztecNode,
282
- this.recipientTaggingStore,
283
- this.senderAddressBookStore,
284
- this.capsuleStore,
285
- this.privateEventStore,
313
+ contractStore: this.contractStore,
314
+ noteStore: this.noteStore,
315
+ keyStore: this.keyStore,
316
+ addressStore: this.addressStore,
317
+ aztecNode: this.aztecNode,
318
+ recipientTaggingStore: this.recipientTaggingStore,
319
+ senderAddressBookStore: this.senderAddressBookStore,
320
+ capsuleStore: this.capsuleStore,
321
+ privateEventStore: this.privateEventStore,
286
322
  jobId,
287
- undefined,
288
323
  scopes,
289
- );
324
+ });
290
325
 
291
326
  try {
292
327
  this.log.verbose(`Executing utility function ${entryPointArtifact.name}`, {
@@ -54,7 +54,7 @@ export interface IMiscOracle {
54
54
 
55
55
  utilityGetRandomField(): Fr;
56
56
  utilityAssertCompatibleOracleVersion(version: number): void;
57
- utilityDebugLog(level: number, message: string, fields: Fr[]): Promise<void>;
57
+ utilityLog(level: number, message: string, fields: Fr[]): Promise<void>;
58
58
  }
59
59
 
60
60
  /**
@@ -417,7 +417,7 @@ export class Oracle {
417
417
  return Promise.resolve([]);
418
418
  }
419
419
 
420
- async utilityDebugLog(
420
+ async utilityLog(
421
421
  level: ACVMField[],
422
422
  message: ACVMField[],
423
423
  _ignoredFieldsSize: ACVMField[],
@@ -426,7 +426,7 @@ export class Oracle {
426
426
  const levelFr = Fr.fromString(level[0]);
427
427
  const messageStr = message.map(acvmField => String.fromCharCode(Fr.fromString(acvmField).toNumber())).join('');
428
428
  const fieldsFr = fields.map(Fr.fromString);
429
- await this.handlerAsMisc().utilityDebugLog(levelFr.toNumber(), messageStr, fieldsFr);
429
+ await this.handlerAsMisc().utilityLog(levelFr.toNumber(), messageStr, fieldsFr);
430
430
  return [];
431
431
  }
432
432
 
@@ -2,7 +2,6 @@ import { MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS, PRIVATE_CONTEXT_INPUTS_LENGTH }
2
2
  import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { Timer } from '@aztec/foundation/timer';
5
- import type { KeyStore } from '@aztec/key-store';
6
5
  import { type CircuitSimulator, toACVMWitness } from '@aztec/simulator/client';
7
6
  import {
8
7
  type FunctionAbi,
@@ -12,18 +11,14 @@ import {
12
11
  type NoteSelector,
13
12
  countArgumentsSize,
14
13
  } from '@aztec/stdlib/abi';
15
- import type { AuthWitness } from '@aztec/stdlib/auth-witness';
16
14
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
17
15
  import { siloNullifier } from '@aztec/stdlib/hash';
18
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
19
16
  import { PrivateContextInputs } from '@aztec/stdlib/kernel';
20
17
  import { type ContractClassLog, DirectionalAppTaggingSecret, type PreTag } from '@aztec/stdlib/logs';
21
18
  import { Tag } from '@aztec/stdlib/logs';
22
19
  import { Note, type NoteStatus } from '@aztec/stdlib/note';
23
20
  import {
24
- type BlockHeader,
25
21
  CallContext,
26
- Capsule,
27
22
  CountedContractClassLog,
28
23
  NoteAndSlot,
29
24
  PrivateCallExecutionResult,
@@ -32,13 +27,6 @@ import {
32
27
 
33
28
  import type { ContractSyncService } from '../../contract_sync/contract_sync_service.js';
34
29
  import { NoteService } from '../../notes/note_service.js';
35
- import type { AddressStore } from '../../storage/address_store/address_store.js';
36
- import type { CapsuleStore } from '../../storage/capsule_store/capsule_store.js';
37
- import type { ContractStore } from '../../storage/contract_store/contract_store.js';
38
- import type { NoteStore } from '../../storage/note_store/note_store.js';
39
- import type { PrivateEventStore } from '../../storage/private_event_store/private_event_store.js';
40
- import type { RecipientTaggingStore } from '../../storage/tagging_store/recipient_tagging_store.js';
41
- import type { SenderAddressBookStore } from '../../storage/tagging_store/sender_address_book_store.js';
42
30
  import type { SenderTaggingStore } from '../../storage/tagging_store/sender_tagging_store.js';
43
31
  import { syncSenderTaggingIndexes } from '../../tagging/index.js';
44
32
  import type { ExecutionNoteCache } from '../execution_note_cache.js';
@@ -47,7 +35,25 @@ import type { HashedValuesCache } from '../hashed_values_cache.js';
47
35
  import { pickNotes } from '../pick_notes.js';
48
36
  import type { IPrivateExecutionOracle, NoteData } from './interfaces.js';
49
37
  import { executePrivateFunction } from './private_execution.js';
50
- import { UtilityExecutionOracle } from './utility_execution_oracle.js';
38
+ import { UtilityExecutionOracle, type UtilityExecutionOracleArgs } from './utility_execution_oracle.js';
39
+
40
+ /** Args for PrivateExecutionOracle constructor. */
41
+ export type PrivateExecutionOracleArgs = Omit<UtilityExecutionOracleArgs, 'contractAddress'> & {
42
+ argsHash: Fr;
43
+ txContext: TxContext;
44
+ callContext: CallContext;
45
+ /** Needed to trigger contract synchronization before nested calls */
46
+ utilityExecutor: (call: FunctionCall) => Promise<void>;
47
+ executionCache: HashedValuesCache;
48
+ noteCache: ExecutionNoteCache;
49
+ taggingIndexCache: ExecutionTaggingIndexCache;
50
+ senderTaggingStore: SenderTaggingStore;
51
+ contractSyncService: ContractSyncService;
52
+ totalPublicCalldataCount?: number;
53
+ sideEffectCounter?: number;
54
+ senderForTags?: AztecAddress;
55
+ simulator?: CircuitSimulator;
56
+ };
51
57
 
52
58
  /**
53
59
  * The execution oracle for the private part of a transaction.
@@ -69,57 +75,39 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
69
75
  private offchainEffects: { data: Fr[] }[] = [];
70
76
  private nestedExecutionResults: PrivateCallExecutionResult[] = [];
71
77
 
72
- constructor(
73
- private readonly argsHash: Fr,
74
- private readonly txContext: TxContext,
75
- private readonly callContext: CallContext,
76
- /** Header of a block whose state is used during private execution (not the block the transaction is included in). */
77
- protected override readonly anchorBlockHeader: BlockHeader,
78
- /** Needed to trigger contract synchronization before nested calls */
79
- private readonly utilityExecutor: (call: FunctionCall) => Promise<void>,
80
- /** List of transient auth witnesses to be used during this simulation */
81
- authWitnesses: AuthWitness[],
82
- capsules: Capsule[],
83
- private readonly executionCache: HashedValuesCache,
84
- private readonly noteCache: ExecutionNoteCache,
85
- private readonly taggingIndexCache: ExecutionTaggingIndexCache,
86
- contractStore: ContractStore,
87
- noteStore: NoteStore,
88
- keyStore: KeyStore,
89
- addressStore: AddressStore,
90
- aztecNode: AztecNode,
91
- private readonly senderTaggingStore: SenderTaggingStore,
92
- recipientTaggingStore: RecipientTaggingStore,
93
- senderAddressBookStore: SenderAddressBookStore,
94
- capsuleStore: CapsuleStore,
95
- privateEventStore: PrivateEventStore,
96
- private readonly contractSyncService: ContractSyncService,
97
- jobId: string,
98
- private totalPublicCalldataCount: number = 0,
99
- protected sideEffectCounter: number = 0,
100
- log = createLogger('simulator:client_execution_context'),
101
- scopes?: AztecAddress[],
102
- private senderForTags?: AztecAddress,
103
- private simulator?: CircuitSimulator,
104
- ) {
105
- super(
106
- callContext.contractAddress,
107
- authWitnesses,
108
- capsules,
109
- anchorBlockHeader,
110
- contractStore,
111
- noteStore,
112
- keyStore,
113
- addressStore,
114
- aztecNode,
115
- recipientTaggingStore,
116
- senderAddressBookStore,
117
- capsuleStore,
118
- privateEventStore,
119
- jobId,
120
- log,
121
- scopes,
122
- );
78
+ private readonly argsHash: Fr;
79
+ private readonly txContext: TxContext;
80
+ private readonly callContext: CallContext;
81
+ private readonly utilityExecutor: (call: FunctionCall) => Promise<void>;
82
+ private readonly executionCache: HashedValuesCache;
83
+ private readonly noteCache: ExecutionNoteCache;
84
+ private readonly taggingIndexCache: ExecutionTaggingIndexCache;
85
+ private readonly senderTaggingStore: SenderTaggingStore;
86
+ private readonly contractSyncService: ContractSyncService;
87
+ private totalPublicCalldataCount: number;
88
+ protected sideEffectCounter: number;
89
+ private senderForTags?: AztecAddress;
90
+ private readonly simulator?: CircuitSimulator;
91
+
92
+ constructor(args: PrivateExecutionOracleArgs) {
93
+ super({
94
+ ...args,
95
+ contractAddress: args.callContext.contractAddress,
96
+ log: args.log ?? createLogger('simulator:client_execution_context'),
97
+ });
98
+ this.argsHash = args.argsHash;
99
+ this.txContext = args.txContext;
100
+ this.callContext = args.callContext;
101
+ this.utilityExecutor = args.utilityExecutor;
102
+ this.executionCache = args.executionCache;
103
+ this.noteCache = args.noteCache;
104
+ this.taggingIndexCache = args.taggingIndexCache;
105
+ this.senderTaggingStore = args.senderTaggingStore;
106
+ this.contractSyncService = args.contractSyncService;
107
+ this.totalPublicCalldataCount = args.totalPublicCalldataCount ?? 0;
108
+ this.sideEffectCounter = args.sideEffectCounter ?? 0;
109
+ this.senderForTags = args.senderForTags;
110
+ this.simulator = args.simulator;
123
111
  }
124
112
 
125
113
  public getPrivateContextInputs(): PrivateContextInputs {
@@ -555,41 +543,41 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
555
543
 
556
544
  const derivedCallContext = await this.deriveCallContext(targetContractAddress, targetArtifact, isStaticCall);
557
545
 
558
- const privateExecutionOracle = new PrivateExecutionOracle(
546
+ const privateExecutionOracle = new PrivateExecutionOracle({
559
547
  argsHash,
560
- derivedTxContext,
561
- derivedCallContext,
562
- this.anchorBlockHeader,
563
- this.utilityExecutor,
564
- this.authWitnesses,
565
- this.capsules,
566
- this.executionCache,
567
- this.noteCache,
568
- this.taggingIndexCache,
569
- this.contractStore,
570
- this.noteStore,
571
- this.keyStore,
572
- this.addressStore,
573
- this.aztecNode,
574
- this.senderTaggingStore,
575
- this.recipientTaggingStore,
576
- this.senderAddressBookStore,
577
- this.capsuleStore,
578
- this.privateEventStore,
579
- this.contractSyncService,
580
- this.jobId,
581
- this.totalPublicCalldataCount,
548
+ txContext: derivedTxContext,
549
+ callContext: derivedCallContext,
550
+ anchorBlockHeader: this.anchorBlockHeader,
551
+ utilityExecutor: this.utilityExecutor,
552
+ authWitnesses: this.authWitnesses,
553
+ capsules: this.capsules,
554
+ executionCache: this.executionCache,
555
+ noteCache: this.noteCache,
556
+ taggingIndexCache: this.taggingIndexCache,
557
+ contractStore: this.contractStore,
558
+ noteStore: this.noteStore,
559
+ keyStore: this.keyStore,
560
+ addressStore: this.addressStore,
561
+ aztecNode: this.aztecNode,
562
+ senderTaggingStore: this.senderTaggingStore,
563
+ recipientTaggingStore: this.recipientTaggingStore,
564
+ senderAddressBookStore: this.senderAddressBookStore,
565
+ capsuleStore: this.capsuleStore,
566
+ privateEventStore: this.privateEventStore,
567
+ contractSyncService: this.contractSyncService,
568
+ jobId: this.jobId,
569
+ totalPublicCalldataCount: this.totalPublicCalldataCount,
582
570
  sideEffectCounter,
583
- this.log,
584
- this.scopes,
585
- this.senderForTags,
586
- this.simulator,
587
- );
571
+ log: this.log,
572
+ scopes: this.scopes,
573
+ senderForTags: this.senderForTags,
574
+ simulator: this.simulator!,
575
+ });
588
576
 
589
577
  const setupTime = simulatorSetupTimer.ms();
590
578
 
591
579
  const childExecutionResult = await executePrivateFunction(
592
- this.simulator,
580
+ this.simulator!,
593
581
  privateExecutionOracle,
594
582
  targetArtifact,
595
583
  targetContractAddress,