@aztec/pxe 0.0.1-commit.023c3e5 → 0.0.1-commit.08c5969dc

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 (69) hide show
  1. package/dest/block_synchronizer/block_synchronizer.d.ts +4 -2
  2. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  3. package/dest/block_synchronizer/block_synchronizer.js +7 -1
  4. package/dest/contract_function_simulator/contract_function_simulator.d.ts +52 -27
  5. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  6. package/dest/contract_function_simulator/contract_function_simulator.js +169 -63
  7. package/dest/contract_function_simulator/oracle/interfaces.d.ts +3 -3
  8. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  9. package/dest/contract_function_simulator/oracle/oracle.d.ts +3 -3
  10. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  11. package/dest/contract_function_simulator/oracle/oracle.js +23 -11
  12. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +35 -35
  13. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  14. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +73 -20
  15. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +34 -15
  16. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +64 -44
  18. package/dest/contract_sync/contract_sync_service.d.ts +42 -0
  19. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  20. package/dest/contract_sync/contract_sync_service.js +97 -0
  21. package/dest/contract_sync/helpers.d.ts +28 -0
  22. package/dest/contract_sync/helpers.d.ts.map +1 -0
  23. package/dest/contract_sync/{index.js → helpers.js} +13 -12
  24. package/dest/debug/pxe_debug_utils.d.ts +12 -9
  25. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  26. package/dest/debug/pxe_debug_utils.js +16 -15
  27. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  28. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  29. package/dest/entrypoints/client/bundle/utils.js +9 -1
  30. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  31. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  32. package/dest/entrypoints/client/lazy/utils.js +9 -1
  33. package/dest/entrypoints/server/index.d.ts +2 -2
  34. package/dest/entrypoints/server/index.d.ts.map +1 -1
  35. package/dest/entrypoints/server/index.js +1 -1
  36. package/dest/entrypoints/server/utils.js +9 -1
  37. package/dest/logs/log_service.d.ts +2 -2
  38. package/dest/logs/log_service.d.ts.map +1 -1
  39. package/dest/logs/log_service.js +6 -13
  40. package/dest/oracle_version.d.ts +2 -2
  41. package/dest/oracle_version.js +2 -2
  42. package/dest/pxe.d.ts +68 -23
  43. package/dest/pxe.d.ts.map +1 -1
  44. package/dest/pxe.js +68 -42
  45. package/dest/storage/contract_store/contract_store.js +5 -5
  46. package/dest/storage/note_store/note_store.d.ts +1 -2
  47. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  48. package/dest/storage/note_store/note_store.js +4 -2
  49. package/package.json +25 -16
  50. package/src/block_synchronizer/block_synchronizer.ts +6 -0
  51. package/src/contract_function_simulator/contract_function_simulator.ts +315 -119
  52. package/src/contract_function_simulator/oracle/interfaces.ts +2 -2
  53. package/src/contract_function_simulator/oracle/oracle.ts +14 -7
  54. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +95 -96
  55. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +105 -44
  56. package/src/contract_sync/contract_sync_service.ts +145 -0
  57. package/src/contract_sync/{index.ts → helpers.ts} +15 -20
  58. package/src/debug/pxe_debug_utils.ts +46 -17
  59. package/src/entrypoints/client/bundle/utils.ts +9 -1
  60. package/src/entrypoints/client/lazy/utils.ts +9 -1
  61. package/src/entrypoints/server/index.ts +1 -1
  62. package/src/entrypoints/server/utils.ts +7 -7
  63. package/src/logs/log_service.ts +6 -15
  64. package/src/oracle_version.ts +2 -2
  65. package/src/pxe.ts +146 -83
  66. package/src/storage/contract_store/contract_store.ts +4 -4
  67. package/src/storage/note_store/note_store.ts +5 -2
  68. package/dest/contract_sync/index.d.ts +0 -23
  69. package/dest/contract_sync/index.d.ts.map +0 -1
package/src/pxe.ts CHANGED
@@ -33,6 +33,7 @@ import type {
33
33
  PrivateKernelTailCircuitPublicInputs,
34
34
  } from '@aztec/stdlib/kernel';
35
35
  import {
36
+ BlockHeader,
36
37
  type ContractOverrides,
37
38
  type InTx,
38
39
  PrivateExecutionResult,
@@ -59,7 +60,8 @@ import {
59
60
  generateSimulatedProvingResult,
60
61
  } from './contract_function_simulator/contract_function_simulator.js';
61
62
  import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
62
- import { ensureContractSynced, readCurrentClassId } from './contract_sync/index.js';
63
+ import { ContractSyncService } from './contract_sync/contract_sync_service.js';
64
+ import { readCurrentClassId } from './contract_sync/helpers.js';
63
65
  import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
64
66
  import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
65
67
  import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
@@ -84,6 +86,56 @@ export type PackedPrivateEvent = InTx & {
84
86
  eventSelector: EventSelector;
85
87
  };
86
88
 
89
+ /** Options for PXE.profileTx. */
90
+ export type ProfileTxOpts = {
91
+ /** The profiling mode to use. */
92
+ profileMode: 'full' | 'execution-steps' | 'gates';
93
+ /** If true, proof generation is skipped during profiling. Defaults to true. */
94
+ skipProofGeneration?: boolean;
95
+ /** Addresses whose private state and keys are accessible during private execution. */
96
+ scopes?: AztecAddress[];
97
+ };
98
+
99
+ /** Options for PXE.simulateTx. */
100
+ export type SimulateTxOpts = {
101
+ /** Whether to simulate the public part of the transaction. */
102
+ simulatePublic: boolean;
103
+ /** If false, this function throws if the transaction is unable to be included in a block at the current state. */
104
+ skipTxValidation?: boolean;
105
+ /** If false, fees are enforced. */
106
+ skipFeeEnforcement?: boolean;
107
+ /** State overrides for the simulation, such as contract instances and artifacts. */
108
+ overrides?: SimulationOverrides;
109
+ /** Addresses whose private state and keys are accessible during private execution. Defaults to all. */
110
+ scopes?: AztecAddress[];
111
+ };
112
+
113
+ /** Options for PXE.simulateUtility. */
114
+ export type SimulateUtilityOpts = {
115
+ /** The authentication witnesses required for the function call. */
116
+ authwits?: AuthWitness[];
117
+ /** The accounts whose notes we can access in this call. Defaults to all. */
118
+ scopes?: AztecAddress[];
119
+ };
120
+
121
+ /** Args for PXE.create. */
122
+ export type PXECreateArgs = {
123
+ /** The Aztec node to connect to. */
124
+ node: AztecNode;
125
+ /** The key-value store for persisting PXE state. */
126
+ store: AztecAsyncKVStore;
127
+ /** The prover for generating private kernel proofs. */
128
+ proofCreator: PrivateKernelProver;
129
+ /** The circuit simulator for executing ACIR circuits. */
130
+ simulator: CircuitSimulator;
131
+ /** Provider for protocol contract artifacts and instances. */
132
+ protocolContractsProvider: ProtocolContractsProvider;
133
+ /** PXE configuration options. */
134
+ config: PXEConfig;
135
+ /** Optional logger instance or string suffix for the logger name. */
136
+ loggerOrSuffix?: string | Logger;
137
+ };
138
+
87
139
  /**
88
140
  * Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
89
141
  * manage private state of users.
@@ -102,6 +154,7 @@ export class PXE {
102
154
  private recipientTaggingStore: RecipientTaggingStore,
103
155
  private addressStore: AddressStore,
104
156
  private privateEventStore: PrivateEventStore,
157
+ private contractSyncService: ContractSyncService,
105
158
  private simulator: CircuitSimulator,
106
159
  private proverEnabled: boolean,
107
160
  private proofCreator: PrivateKernelProver,
@@ -119,15 +172,15 @@ export class PXE {
119
172
  *
120
173
  * @returns A promise that resolves PXE is ready to be used.
121
174
  */
122
- public static async create(
123
- node: AztecNode,
124
- store: AztecAsyncKVStore,
125
- proofCreator: PrivateKernelProver,
126
- simulator: CircuitSimulator,
127
- protocolContractsProvider: ProtocolContractsProvider,
128
- config: PXEConfig,
129
- loggerOrSuffix?: string | Logger,
130
- ) {
175
+ public static async create({
176
+ node,
177
+ store,
178
+ proofCreator,
179
+ simulator,
180
+ protocolContractsProvider,
181
+ config,
182
+ loggerOrSuffix,
183
+ }: PXECreateArgs) {
131
184
  // Extract bindings from the logger, or use empty bindings if a string suffix is provided.
132
185
  const bindings: LoggerBindings | undefined =
133
186
  loggerOrSuffix && typeof loggerOrSuffix !== 'string' ? loggerOrSuffix.getBindings() : undefined;
@@ -137,7 +190,9 @@ export class PXE {
137
190
  ? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`)
138
191
  : loggerOrSuffix;
139
192
 
140
- const proverEnabled = !!config.proverEnabled;
193
+ const info = await node.getNodeInfo();
194
+
195
+ const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
141
196
  const addressStore = new AddressStore(store);
142
197
  const privateEventStore = new PrivateEventStore(store);
143
198
  const contractStore = new ContractStore(store);
@@ -149,6 +204,12 @@ export class PXE {
149
204
  const capsuleStore = new CapsuleStore(store);
150
205
  const keyStore = new KeyStore(store);
151
206
  const tipsStore = new L2TipsKVStore(store, 'pxe');
207
+ const contractSyncService = new ContractSyncService(
208
+ node,
209
+ contractStore,
210
+ noteStore,
211
+ createLogger('pxe:contract_sync', bindings),
212
+ );
152
213
  const synchronizer = new BlockSynchronizer(
153
214
  node,
154
215
  store,
@@ -156,6 +217,7 @@ export class PXE {
156
217
  noteStore,
157
218
  privateEventStore,
158
219
  tipsStore,
220
+ contractSyncService,
159
221
  config,
160
222
  bindings,
161
223
  );
@@ -167,9 +229,10 @@ export class PXE {
167
229
  recipientTaggingStore,
168
230
  privateEventStore,
169
231
  noteStore,
232
+ contractSyncService,
170
233
  ]);
171
234
 
172
- const debugUtils = new PXEDebugUtils(contractStore, noteStore, synchronizer, anchorBlockStore);
235
+ const debugUtils = new PXEDebugUtils(contractSyncService, noteStore, synchronizer, anchorBlockStore);
173
236
 
174
237
  const jobQueue = new SerialQueue();
175
238
 
@@ -186,6 +249,7 @@ export class PXE {
186
249
  recipientTaggingStore,
187
250
  addressStore,
188
251
  privateEventStore,
252
+ contractSyncService,
189
253
  simulator,
190
254
  proverEnabled,
191
255
  proofCreator,
@@ -196,12 +260,15 @@ export class PXE {
196
260
  debugUtils,
197
261
  );
198
262
 
199
- debugUtils.setPXE(pxe, pxe.#putInJobQueue.bind(pxe));
263
+ debugUtils.setPXEHelpers(
264
+ pxe.#putInJobQueue.bind(pxe),
265
+ pxe.#getSimulatorForTx.bind(pxe),
266
+ pxe.#simulateUtility.bind(pxe),
267
+ );
200
268
 
201
269
  pxe.jobQueue.start();
202
270
 
203
271
  await pxe.#registerProtocolContracts();
204
- const info = await node.getNodeInfo();
205
272
  log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
206
273
  return pxe;
207
274
  }
@@ -211,19 +278,20 @@ export class PXE {
211
278
  #getSimulatorForTx(overrides?: { contracts?: ContractOverrides }) {
212
279
  const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
213
280
 
214
- return new ContractFunctionSimulator(
215
- proxyContractStore,
216
- this.noteStore,
217
- this.keyStore,
218
- this.addressStore,
219
- BenchmarkedNodeFactory.create(this.node),
220
- this.senderTaggingStore,
221
- this.recipientTaggingStore,
222
- this.senderAddressBookStore,
223
- this.capsuleStore,
224
- this.privateEventStore,
225
- this.simulator,
226
- );
281
+ return new ContractFunctionSimulator({
282
+ contractStore: proxyContractStore,
283
+ noteStore: this.noteStore,
284
+ keyStore: this.keyStore,
285
+ addressStore: this.addressStore,
286
+ aztecNode: BenchmarkedNodeFactory.create(this.node),
287
+ senderTaggingStore: this.senderTaggingStore,
288
+ recipientTaggingStore: this.recipientTaggingStore,
289
+ senderAddressBookStore: this.senderAddressBookStore,
290
+ capsuleStore: this.capsuleStore,
291
+ privateEventStore: this.privateEventStore,
292
+ simulator: this.simulator,
293
+ contractSyncService: this.contractSyncService,
294
+ });
227
295
  }
228
296
 
229
297
  #contextualizeError(err: Error, ...context: string[]): Error {
@@ -297,27 +365,23 @@ export class PXE {
297
365
  try {
298
366
  const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
299
367
 
300
- await ensureContractSynced(
368
+ await this.contractSyncService.ensureContractSynced(
301
369
  contractAddress,
302
370
  functionSelector,
303
- privateSyncCall => this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
304
- this.node,
305
- this.contractStore,
371
+ (privateSyncCall, execScopes) =>
372
+ this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
306
373
  anchorBlockHeader,
374
+ jobId,
375
+ scopes,
307
376
  );
308
377
 
309
- const result = await contractFunctionSimulator.run(
310
- txRequest,
378
+ const result = await contractFunctionSimulator.run(txRequest, {
311
379
  contractAddress,
312
- functionSelector,
313
- undefined,
380
+ selector: functionSelector,
314
381
  anchorBlockHeader,
315
- // The sender for tags is set by contracts, typically by an account
316
- // contract entrypoint
317
- undefined, // senderForTags
318
382
  scopes,
319
383
  jobId,
320
- );
384
+ });
321
385
  this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
322
386
  return result;
323
387
  } catch (err) {
@@ -415,6 +479,19 @@ export class PXE {
415
479
 
416
480
  // Public API
417
481
 
482
+ /**
483
+ * Returns the block header up to which the PXE has synced.
484
+ * @returns The synced block header
485
+ */
486
+ public getSyncedBlockHeader(): Promise<BlockHeader> {
487
+ return this.anchorBlockStore.getBlockHeader();
488
+ }
489
+
490
+ /**
491
+ * Returns the contract instance for a given address, if it's registered in the PXE.
492
+ * @param address - The contract address.
493
+ * @returns The contract instance if found, undefined otherwise.
494
+ */
418
495
  public getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
419
496
  return this.contractStore.getContractInstance(address);
420
497
  }
@@ -628,11 +705,12 @@ export class PXE {
628
705
  * (where validators prove the public portion).
629
706
  *
630
707
  * @param txRequest - An authenticated tx request ready for proving
708
+ * @param scopes - Addresses whose private state and keys are accessible during private execution.
631
709
  * @returns A result containing the proof and public inputs of the tail circuit.
632
710
  * @throws If contract code not found, or public simulation reverts.
633
711
  * Also throws if simulatePublic is true and public simulation reverts.
634
712
  */
635
- public proveTx(txRequest: TxExecutionRequest): Promise<TxProvingResult> {
713
+ public proveTx(txRequest: TxExecutionRequest, scopes: AztecAddress[]): Promise<TxProvingResult> {
636
714
  let privateExecutionResult: PrivateExecutionResult;
637
715
  // We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
638
716
  // computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
@@ -643,7 +721,7 @@ export class PXE {
643
721
  await this.blockStateSynchronizer.sync();
644
722
  const syncTime = syncTimer.ms();
645
723
  const contractFunctionSimulator = this.#getSimulatorForTx();
646
- privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, undefined, jobId);
724
+ privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
647
725
 
648
726
  const {
649
727
  publicInputs,
@@ -707,17 +785,13 @@ export class PXE {
707
785
 
708
786
  /**
709
787
  * Profiles a transaction, reporting gate counts (unless disabled) and returns an execution trace.
710
- *
711
- * @param txRequest - An authenticated tx request ready for simulation
712
- * @param msgSender - (Optional) The message sender to use for the simulation.
713
- * @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
788
+ * @param txRequest - An authenticated tx request ready for simulation.
714
789
  * @returns A trace of the program execution with gate counts.
715
790
  * @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
716
791
  */
717
792
  public profileTx(
718
793
  txRequest: TxExecutionRequest,
719
- profileMode: 'full' | 'execution-steps' | 'gates',
720
- skipProofGeneration: boolean = true,
794
+ { profileMode, skipProofGeneration = true, scopes }: ProfileTxOpts,
721
795
  ): Promise<TxProfileResult> {
722
796
  // We disable concurrent profiles for consistency with simulateTx.
723
797
  return this.#putInJobQueue(async jobId => {
@@ -740,12 +814,7 @@ export class PXE {
740
814
  const syncTime = syncTimer.ms();
741
815
 
742
816
  const contractFunctionSimulator = this.#getSimulatorForTx();
743
- const privateExecutionResult = await this.#executePrivate(
744
- contractFunctionSimulator,
745
- txRequest,
746
- undefined,
747
- jobId,
748
- );
817
+ const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
749
818
 
750
819
  const { executionSteps, timings: { proving } = {} } = await this.#prove(
751
820
  txRequest,
@@ -802,12 +871,7 @@ export class PXE {
802
871
  * In that case, the transaction returned is only potentially ready to be sent to the network for execution.
803
872
  *
804
873
  *
805
- * @param txRequest - An authenticated tx request ready for simulation
806
- * @param simulatePublic - Whether to simulate the public part of the transaction.
807
- * @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
808
- * @param skipFeeEnforcement - (Optional) If false, fees are enforced.
809
- * @param overrides - (Optional) State overrides for the simulation, such as msgSender, contract instances and artifacts.
810
- * @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
874
+ * @param txRequest - An authenticated tx request ready for simulation.
811
875
  * @returns A simulated transaction result object that includes public and private return values.
812
876
  * @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
813
877
  * Also throws if simulatePublic is true and public simulation reverts.
@@ -816,11 +880,7 @@ export class PXE {
816
880
  */
817
881
  public simulateTx(
818
882
  txRequest: TxExecutionRequest,
819
- simulatePublic: boolean,
820
- skipTxValidation: boolean = false,
821
- skipFeeEnforcement: boolean = false,
822
- overrides?: SimulationOverrides,
823
- scopes?: AztecAddress[],
883
+ { simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes }: SimulateTxOpts,
824
884
  ): Promise<TxSimulationResult> {
825
885
  // We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
826
886
  // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
@@ -848,7 +908,14 @@ export class PXE {
848
908
  // Temporary: in case there are overrides, we have to skip the kernels or validations
849
909
  // will fail. Consider handing control to the user/wallet on whether they want to run them
850
910
  // or not.
851
- const skipKernels = overrides?.contracts !== undefined && Object.keys(overrides.contracts ?? {}).length > 0;
911
+ const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
912
+ const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
913
+ const skipKernels = hasOverriddenContracts;
914
+
915
+ // Set overridden contracts on the sync service so it knows to skip syncing them
916
+ if (hasOverriddenContracts) {
917
+ this.contractSyncService.setOverriddenContracts(jobId, overriddenContracts);
918
+ }
852
919
 
853
920
  // Execution of private functions only; no proving, and no kernel logic.
854
921
  const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
@@ -859,7 +926,8 @@ export class PXE {
859
926
  if (skipKernels) {
860
927
  ({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
861
928
  privateExecutionResult,
862
- this.contractStore,
929
+ (addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
930
+ this.node,
863
931
  ));
864
932
  } else {
865
933
  // Kernel logic, plus proving of all private functions and kernels.
@@ -944,18 +1012,12 @@ export class PXE {
944
1012
  }
945
1013
 
946
1014
  /**
947
- * Simulate the execution of a contract utility function.
948
- *
1015
+ * Simulates the execution of a contract utility function.
949
1016
  * @param call - The function call containing the function details, arguments, and target contract address.
950
- * @param authwits - (Optional) The authentication witnesses required for the function call.
951
- * @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will
952
- * default to all.
953
- * @returns The result of the utility function call, structured based on the function ABI.
954
1017
  */
955
1018
  public simulateUtility(
956
1019
  call: FunctionCall,
957
- authwits?: AuthWitness[],
958
- scopes?: AztecAddress[],
1020
+ { authwits, scopes }: SimulateUtilityOpts = {},
959
1021
  ): Promise<UtilitySimulationResult> {
960
1022
  // We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
961
1023
  // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
@@ -970,13 +1032,14 @@ export class PXE {
970
1032
  const contractFunctionSimulator = this.#getSimulatorForTx();
971
1033
 
972
1034
  const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
973
- await ensureContractSynced(
1035
+ await this.contractSyncService.ensureContractSynced(
974
1036
  call.to,
975
1037
  call.selector,
976
- privateSyncCall => this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
977
- this.node,
978
- this.contractStore,
1038
+ (privateSyncCall, execScopes) =>
1039
+ this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
979
1040
  anchorBlockHeader,
1041
+ jobId,
1042
+ scopes,
980
1043
  );
981
1044
 
982
1045
  const executionResult = await this.#simulateUtility(
@@ -1040,14 +1103,14 @@ export class PXE {
1040
1103
 
1041
1104
  const contractFunctionSimulator = this.#getSimulatorForTx();
1042
1105
 
1043
- await ensureContractSynced(
1106
+ await this.contractSyncService.ensureContractSynced(
1044
1107
  filter.contractAddress,
1045
1108
  null,
1046
- async privateSyncCall =>
1047
- await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
1048
- this.node,
1049
- this.contractStore,
1109
+ async (privateSyncCall, execScopes) =>
1110
+ await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
1050
1111
  anchorBlockHeader,
1112
+ jobId,
1113
+ filter.scopes,
1051
1114
  );
1052
1115
  });
1053
1116
 
@@ -316,15 +316,15 @@ export class ContractStore {
316
316
  throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
317
317
  }
318
318
 
319
- return {
319
+ return FunctionCall.from({
320
320
  name: functionDao.name,
321
- args: encodeArguments(functionDao, args),
321
+ to,
322
322
  selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
323
323
  type: functionDao.functionType,
324
- to,
325
324
  hideMsgSender: false,
326
325
  isStatic: functionDao.isStatic,
326
+ args: encodeArguments(functionDao, args),
327
327
  returnTypes: functionDao.returnTypes,
328
- };
328
+ });
329
329
  }
330
330
  }
@@ -103,11 +103,10 @@ export class NoteStore implements StagedStore {
103
103
  * @params jobId - the job context to read from.
104
104
  * @returns Filtered and deduplicated notes (a note might be present in multiple scopes - we ensure it is only
105
105
  * returned once if this is the case)
106
- * @throws If filtering by an empty scopes array. Scopes have to be set to undefined or to a non-empty array.
107
106
  */
108
107
  getNotes(filter: NotesFilter, jobId: string): Promise<NoteDao[]> {
109
108
  if (filter.scopes !== undefined && filter.scopes.length === 0) {
110
- return Promise.reject(new Error('Trying to get notes with an empty scopes array'));
109
+ return Promise.resolve([]);
111
110
  }
112
111
 
113
112
  return this.#store.transactionAsync(async () => {
@@ -220,6 +219,10 @@ export class NoteStore implements StagedStore {
220
219
  return Promise.resolve([]);
221
220
  }
222
221
 
222
+ if (nullifiers.some(n => n.l2BlockNumber === 0)) {
223
+ return Promise.reject(new Error('applyNullifiers: nullifiers cannot have been emitted at block 0'));
224
+ }
225
+
223
226
  return this.#withJobLock(jobId, () =>
224
227
  this.#store.transactionAsync(async () => {
225
228
  const notesToNullify = await Promise.all(
@@ -1,23 +0,0 @@
1
- import type { FunctionCall, FunctionSelector } from '@aztec/stdlib/abi';
2
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
- import type { ContractInstance } from '@aztec/stdlib/contract';
4
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
5
- import type { BlockHeader } from '@aztec/stdlib/tx';
6
- import type { ContractStore } from '../storage/contract_store/contract_store.js';
7
- /**
8
- * Read the current class id of a contract from the execution data provider or AztecNode. If not found, class id
9
- * from the instance is used.
10
- * @param contractAddress - The address of the contract to read the class id for.
11
- * @param instance - The instance of the contract.
12
- * @param aztecNode - The Aztec node to query for storage.
13
- * @param header - The header of the block at which to load the DelayedPublicMutable storing the class id.
14
- * @returns The current class id.
15
- */
16
- export declare function readCurrentClassId(contractAddress: AztecAddress, instance: ContractInstance, aztecNode: AztecNode, header: BlockHeader): Promise<import("@aztec/foundation/schemas").Fr>;
17
- export declare function syncState(contractAddress: AztecAddress, contractStore: ContractStore, functionToInvokeAfterSync: FunctionSelector | null, utilityExecutor: (privateSyncCall: FunctionCall) => Promise<any>): Promise<any>;
18
- /**
19
- * Ensures the contract's private state is synchronized and that the PXE holds the current class artifact for
20
- * the contract.
21
- */
22
- export declare function ensureContractSynced(contractAddress: AztecAddress, functionToInvokeAfterSync: FunctionSelector | null, utilityExecutor: (call: FunctionCall) => Promise<any>, aztecNode: AztecNode, contractStore: ContractStore, header: BlockHeader): Promise<void>;
23
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdF9zeW5jL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ3hFLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2hFLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFL0QsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLE1BQU0sNkNBQTZDLENBQUM7QUFFakY7Ozs7Ozs7O0dBUUc7QUFDSCx3QkFBc0Isa0JBQWtCLENBQ3RDLGVBQWUsRUFBRSxZQUFZLEVBQzdCLFFBQVEsRUFBRSxnQkFBZ0IsRUFDMUIsU0FBUyxFQUFFLFNBQVMsRUFDcEIsTUFBTSxFQUFFLFdBQVcsbURBYXBCO0FBRUQsd0JBQXNCLFNBQVMsQ0FDN0IsZUFBZSxFQUFFLFlBQVksRUFDN0IsYUFBYSxFQUFFLGFBQWEsRUFDNUIseUJBQXlCLEVBQUUsZ0JBQWdCLEdBQUcsSUFBSSxFQUNsRCxlQUFlLEVBQUUsQ0FBQyxlQUFlLEVBQUUsWUFBWSxLQUFLLE9BQU8sQ0FBQyxHQUFHLENBQUMsZ0JBYWpFO0FBMEJEOzs7R0FHRztBQUNILHdCQUFzQixvQkFBb0IsQ0FDeEMsZUFBZSxFQUFFLFlBQVksRUFDN0IseUJBQXlCLEVBQUUsZ0JBQWdCLEdBQUcsSUFBSSxFQUNsRCxlQUFlLEVBQUUsQ0FBQyxJQUFJLEVBQUUsWUFBWSxLQUFLLE9BQU8sQ0FBQyxHQUFHLENBQUMsRUFDckQsU0FBUyxFQUFFLFNBQVMsRUFDcEIsYUFBYSxFQUFFLGFBQWEsRUFDNUIsTUFBTSxFQUFFLFdBQVcsR0FDbEIsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUtmIn0=
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract_sync/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAEjF;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACtC,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,WAAW,mDAapB;AAED,wBAAsB,SAAS,CAC7B,eAAe,EAAE,YAAY,EAC7B,aAAa,EAAE,aAAa,EAC5B,yBAAyB,EAAE,gBAAgB,GAAG,IAAI,EAClD,eAAe,EAAE,CAAC,eAAe,EAAE,YAAY,KAAK,OAAO,CAAC,GAAG,CAAC,gBAajE;AA0BD;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,eAAe,EAAE,YAAY,EAC7B,yBAAyB,EAAE,gBAAgB,GAAG,IAAI,EAClD,eAAe,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,GAAG,CAAC,EACrD,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,CAKf"}