@aztec/pxe 0.0.1-commit.8afd444 → 0.0.1-commit.8f9871590

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 (108) hide show
  1. package/dest/access_scopes.d.ts +9 -0
  2. package/dest/access_scopes.d.ts.map +1 -0
  3. package/dest/access_scopes.js +6 -0
  4. package/dest/block_synchronizer/block_synchronizer.d.ts +4 -2
  5. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  6. package/dest/block_synchronizer/block_synchronizer.js +7 -1
  7. package/dest/contract_function_simulator/contract_function_simulator.d.ts +54 -28
  8. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  9. package/dest/contract_function_simulator/contract_function_simulator.js +170 -64
  10. package/dest/contract_function_simulator/oracle/interfaces.d.ts +2 -2
  11. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  12. package/dest/contract_function_simulator/oracle/oracle.d.ts +2 -2
  13. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  14. package/dest/contract_function_simulator/oracle/oracle.js +3 -3
  15. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +36 -35
  16. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +72 -19
  18. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +32 -11
  19. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  20. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +58 -29
  21. package/dest/contract_sync/contract_sync_service.d.ts +43 -0
  22. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  23. package/dest/contract_sync/contract_sync_service.js +97 -0
  24. package/dest/contract_sync/helpers.d.ts +29 -0
  25. package/dest/contract_sync/helpers.d.ts.map +1 -0
  26. package/dest/contract_sync/{index.js → helpers.js} +8 -14
  27. package/dest/debug/pxe_debug_utils.d.ts +14 -10
  28. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  29. package/dest/debug/pxe_debug_utils.js +16 -15
  30. package/dest/entrypoints/client/bundle/index.d.ts +3 -1
  31. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  32. package/dest/entrypoints/client/bundle/index.js +2 -0
  33. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  34. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  35. package/dest/entrypoints/client/bundle/utils.js +9 -1
  36. package/dest/entrypoints/client/lazy/index.d.ts +3 -1
  37. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  38. package/dest/entrypoints/client/lazy/index.js +2 -0
  39. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  40. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  41. package/dest/entrypoints/client/lazy/utils.js +9 -1
  42. package/dest/entrypoints/server/index.d.ts +4 -2
  43. package/dest/entrypoints/server/index.d.ts.map +1 -1
  44. package/dest/entrypoints/server/index.js +3 -1
  45. package/dest/entrypoints/server/utils.js +9 -1
  46. package/dest/logs/log_service.d.ts +3 -2
  47. package/dest/logs/log_service.d.ts.map +1 -1
  48. package/dest/logs/log_service.js +5 -10
  49. package/dest/notes/note_service.d.ts +4 -3
  50. package/dest/notes/note_service.d.ts.map +1 -1
  51. package/dest/notes/note_service.js +3 -2
  52. package/dest/notes_filter.d.ts +25 -0
  53. package/dest/notes_filter.d.ts.map +1 -0
  54. package/dest/notes_filter.js +4 -0
  55. package/dest/oracle_version.d.ts +2 -2
  56. package/dest/oracle_version.js +2 -2
  57. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  58. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  59. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  60. package/dest/private_kernel/hints/index.d.ts +1 -1
  61. package/dest/private_kernel/hints/index.js +1 -1
  62. package/dest/private_kernel/private_kernel_execution_prover.js +6 -6
  63. package/dest/pxe.d.ts +69 -23
  64. package/dest/pxe.d.ts.map +1 -1
  65. package/dest/pxe.js +72 -44
  66. package/dest/storage/contract_store/contract_store.js +5 -5
  67. package/dest/storage/note_store/note_store.d.ts +3 -3
  68. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  69. package/dest/storage/note_store/note_store.js +6 -4
  70. package/dest/tagging/get_all_logs_by_tags.d.ts +1 -1
  71. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
  72. package/dest/tagging/get_all_logs_by_tags.js +17 -3
  73. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +4 -4
  74. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  75. package/package.json +25 -16
  76. package/src/access_scopes.ts +9 -0
  77. package/src/block_synchronizer/block_synchronizer.ts +6 -0
  78. package/src/contract_function_simulator/contract_function_simulator.ts +318 -121
  79. package/src/contract_function_simulator/oracle/interfaces.ts +1 -1
  80. package/src/contract_function_simulator/oracle/oracle.ts +3 -3
  81. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +94 -96
  82. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +100 -28
  83. package/src/contract_sync/contract_sync_service.ts +152 -0
  84. package/src/contract_sync/{index.ts → helpers.ts} +13 -34
  85. package/src/debug/pxe_debug_utils.ts +48 -18
  86. package/src/entrypoints/client/bundle/index.ts +2 -0
  87. package/src/entrypoints/client/bundle/utils.ts +9 -1
  88. package/src/entrypoints/client/lazy/index.ts +2 -0
  89. package/src/entrypoints/client/lazy/utils.ts +9 -1
  90. package/src/entrypoints/server/index.ts +3 -1
  91. package/src/entrypoints/server/utils.ts +7 -7
  92. package/src/logs/log_service.ts +7 -19
  93. package/src/notes/note_service.ts +4 -3
  94. package/src/notes_filter.ts +26 -0
  95. package/src/oracle_version.ts +2 -2
  96. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  97. package/src/private_kernel/hints/index.ts +1 -1
  98. package/src/private_kernel/private_kernel_execution_prover.ts +6 -6
  99. package/src/pxe.ts +148 -90
  100. package/src/storage/contract_store/contract_store.ts +4 -4
  101. package/src/storage/note_store/note_store.ts +12 -5
  102. package/src/tagging/get_all_logs_by_tags.ts +28 -4
  103. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +4 -4
  104. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  105. package/dest/contract_sync/index.d.ts +0 -24
  106. package/dest/contract_sync/index.d.ts.map +0 -1
  107. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  108. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
package/dest/pxe.js CHANGED
@@ -13,7 +13,8 @@ import { BlockSynchronizer } from './block_synchronizer/index.js';
13
13
  import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
14
14
  import { ContractFunctionSimulator, generateSimulatedProvingResult } from './contract_function_simulator/contract_function_simulator.js';
15
15
  import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
16
- import { ensureContractSynced, readCurrentClassId } from './contract_sync/index.js';
16
+ import { ContractSyncService } from './contract_sync/contract_sync_service.js';
17
+ import { readCurrentClassId } from './contract_sync/helpers.js';
17
18
  import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
18
19
  import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
19
20
  import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
@@ -45,6 +46,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
45
46
  recipientTaggingStore;
46
47
  addressStore;
47
48
  privateEventStore;
49
+ contractSyncService;
48
50
  simulator;
49
51
  proverEnabled;
50
52
  proofCreator;
@@ -53,7 +55,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
53
55
  jobQueue;
54
56
  jobCoordinator;
55
57
  debug;
56
- constructor(node, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debug){
58
+ constructor(node, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debug){
57
59
  this.node = node;
58
60
  this.blockStateSynchronizer = blockStateSynchronizer;
59
61
  this.keyStore = keyStore;
@@ -66,6 +68,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
66
68
  this.recipientTaggingStore = recipientTaggingStore;
67
69
  this.addressStore = addressStore;
68
70
  this.privateEventStore = privateEventStore;
71
+ this.contractSyncService = contractSyncService;
69
72
  this.simulator = simulator;
70
73
  this.proverEnabled = proverEnabled;
71
74
  this.proofCreator = proofCreator;
@@ -81,11 +84,12 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
81
84
  * can be contacted.
82
85
  *
83
86
  * @returns A promise that resolves PXE is ready to be used.
84
- */ static async create(node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix) {
87
+ */ static async create({ node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix }) {
85
88
  // Extract bindings from the logger, or use empty bindings if a string suffix is provided.
86
89
  const bindings = loggerOrSuffix && typeof loggerOrSuffix !== 'string' ? loggerOrSuffix.getBindings() : undefined;
87
90
  const log = !loggerOrSuffix || typeof loggerOrSuffix === 'string' ? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`) : loggerOrSuffix;
88
- const proverEnabled = !!config.proverEnabled;
91
+ const info = await node.getNodeInfo();
92
+ const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
89
93
  const addressStore = new AddressStore(store);
90
94
  const privateEventStore = new PrivateEventStore(store);
91
95
  const contractStore = new ContractStore(store);
@@ -97,29 +101,43 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
97
101
  const capsuleStore = new CapsuleStore(store);
98
102
  const keyStore = new KeyStore(store);
99
103
  const tipsStore = new L2TipsKVStore(store, 'pxe');
100
- const synchronizer = new BlockSynchronizer(node, store, anchorBlockStore, noteStore, privateEventStore, tipsStore, config, bindings);
104
+ const contractSyncService = new ContractSyncService(node, contractStore, noteStore, createLogger('pxe:contract_sync', bindings));
105
+ const synchronizer = new BlockSynchronizer(node, store, anchorBlockStore, noteStore, privateEventStore, tipsStore, contractSyncService, config, bindings);
101
106
  const jobCoordinator = new JobCoordinator(store, bindings);
102
107
  jobCoordinator.registerStores([
103
108
  capsuleStore,
104
109
  senderTaggingStore,
105
110
  recipientTaggingStore,
106
111
  privateEventStore,
107
- noteStore
112
+ noteStore,
113
+ contractSyncService
108
114
  ]);
109
- const debugUtils = new PXEDebugUtils(contractStore, noteStore, synchronizer, anchorBlockStore);
115
+ const debugUtils = new PXEDebugUtils(contractSyncService, noteStore, synchronizer, anchorBlockStore);
110
116
  const jobQueue = new SerialQueue();
111
- const pxe = new PXE(node, synchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debugUtils);
112
- debugUtils.setPXE(pxe, pxe.#putInJobQueue.bind(pxe));
117
+ const pxe = new PXE(node, synchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debugUtils);
118
+ debugUtils.setPXEHelpers(pxe.#putInJobQueue.bind(pxe), pxe.#getSimulatorForTx.bind(pxe), pxe.#simulateUtility.bind(pxe));
113
119
  pxe.jobQueue.start();
114
120
  await pxe.#registerProtocolContracts();
115
- const info = await node.getNodeInfo();
116
121
  log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
117
122
  return pxe;
118
123
  }
119
124
  // Internal methods
120
125
  #getSimulatorForTx(overrides) {
121
126
  const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
122
- 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);
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
+ });
123
141
  }
124
142
  #contextualizeError(err, ...context) {
125
143
  let contextStr = '';
@@ -175,10 +193,14 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
175
193
  const { origin: contractAddress, functionSelector } = txRequest;
176
194
  try {
177
195
  const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
178
- await ensureContractSynced(contractAddress, functionSelector, (privateSyncCall)=>this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId), this.node, this.contractStore, this.noteStore, anchorBlockHeader, jobId);
179
- const result = await contractFunctionSimulator.run(txRequest, contractAddress, functionSelector, undefined, anchorBlockHeader, // The sender for tags is set by contracts, typically by an account
180
- // contract entrypoint
181
- undefined, scopes, jobId);
196
+ await this.contractSyncService.ensureContractSynced(contractAddress, functionSelector, (privateSyncCall, execScopes)=>this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, scopes);
197
+ const result = await contractFunctionSimulator.run(txRequest, {
198
+ contractAddress,
199
+ selector: functionSelector,
200
+ anchorBlockHeader,
201
+ scopes,
202
+ jobId
203
+ });
182
204
  this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
183
205
  return result;
184
206
  } catch (err) {
@@ -252,7 +274,17 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
252
274
  return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
253
275
  }
254
276
  // Public API
255
- getContractInstance(address) {
277
+ /**
278
+ * Returns the block header up to which the PXE has synced.
279
+ * @returns The synced block header
280
+ */ getSyncedBlockHeader() {
281
+ return this.anchorBlockStore.getBlockHeader();
282
+ }
283
+ /**
284
+ * Returns the contract instance for a given address, if it's registered in the PXE.
285
+ * @param address - The contract address.
286
+ * @returns The contract instance if found, undefined otherwise.
287
+ */ getContractInstance(address) {
256
288
  return this.contractStore.getContractInstance(address);
257
289
  }
258
290
  /**
@@ -419,10 +451,11 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
419
451
  * (where validators prove the public portion).
420
452
  *
421
453
  * @param txRequest - An authenticated tx request ready for proving
454
+ * @param scopes - Addresses whose private state and keys are accessible during private execution.
422
455
  * @returns A result containing the proof and public inputs of the tail circuit.
423
456
  * @throws If contract code not found, or public simulation reverts.
424
457
  * Also throws if simulatePublic is true and public simulation reverts.
425
- */ proveTx(txRequest) {
458
+ */ proveTx(txRequest, scopes) {
426
459
  let privateExecutionResult;
427
460
  // We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
428
461
  // computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
@@ -433,7 +466,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
433
466
  await this.blockStateSynchronizer.sync();
434
467
  const syncTime = syncTimer.ms();
435
468
  const contractFunctionSimulator = this.#getSimulatorForTx();
436
- privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, undefined, jobId);
469
+ privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
437
470
  const { publicInputs, chonkProof, executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
438
471
  simulate: false,
439
472
  skipFeeEnforcement: false,
@@ -483,13 +516,10 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
483
516
  }
484
517
  /**
485
518
  * Profiles a transaction, reporting gate counts (unless disabled) and returns an execution trace.
486
- *
487
- * @param txRequest - An authenticated tx request ready for simulation
488
- * @param msgSender - (Optional) The message sender to use for the simulation.
489
- * @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
519
+ * @param txRequest - An authenticated tx request ready for simulation.
490
520
  * @returns A trace of the program execution with gate counts.
491
521
  * @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
492
- */ profileTx(txRequest, profileMode, skipProofGeneration = true) {
522
+ */ profileTx(txRequest, { profileMode, skipProofGeneration = true, scopes }) {
493
523
  // We disable concurrent profiles for consistency with simulateTx.
494
524
  return this.#putInJobQueue(async (jobId)=>{
495
525
  const totalTimer = new Timer();
@@ -507,7 +537,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
507
537
  await this.blockStateSynchronizer.sync();
508
538
  const syncTime = syncTimer.ms();
509
539
  const contractFunctionSimulator = this.#getSimulatorForTx();
510
- const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, undefined, jobId);
540
+ const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
511
541
  const { executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
512
542
  simulate: skipProofGeneration,
513
543
  skipFeeEnforcement: false,
@@ -552,18 +582,13 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
552
582
  * In that case, the transaction returned is only potentially ready to be sent to the network for execution.
553
583
  *
554
584
  *
555
- * @param txRequest - An authenticated tx request ready for simulation
556
- * @param simulatePublic - Whether to simulate the public part of the transaction.
557
- * @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
558
- * @param skipFeeEnforcement - (Optional) If false, fees are enforced.
559
- * @param overrides - (Optional) State overrides for the simulation, such as msgSender, contract instances and artifacts.
560
- * @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
585
+ * @param txRequest - An authenticated tx request ready for simulation.
561
586
  * @returns A simulated transaction result object that includes public and private return values.
562
587
  * @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
563
588
  * Also throws if simulatePublic is true and public simulation reverts.
564
589
  *
565
590
  * TODO(#7456) Prevent msgSender being defined here for the first call
566
- */ simulateTx(txRequest, simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes) {
591
+ */ simulateTx(txRequest, { simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes }) {
567
592
  // We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
568
593
  // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
569
594
  // delete the same read value, or reading values that another simulation is currently modifying).
@@ -586,13 +611,19 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
586
611
  // Temporary: in case there are overrides, we have to skip the kernels or validations
587
612
  // will fail. Consider handing control to the user/wallet on whether they want to run them
588
613
  // or not.
589
- const skipKernels = overrides?.contracts !== undefined && Object.keys(overrides.contracts ?? {}).length > 0;
614
+ const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
615
+ const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
616
+ const skipKernels = hasOverriddenContracts;
617
+ // Set overridden contracts on the sync service so it knows to skip syncing them
618
+ if (hasOverriddenContracts) {
619
+ this.contractSyncService.setOverriddenContracts(jobId, overriddenContracts);
620
+ }
590
621
  // Execution of private functions only; no proving, and no kernel logic.
591
622
  const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
592
623
  let publicInputs;
593
624
  let executionSteps = [];
594
625
  if (skipKernels) {
595
- ({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, this.contractStore));
626
+ ({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, (addr, sel)=>this.contractStore.getDebugFunctionName(addr, sel), this.node));
596
627
  } else {
597
628
  // Kernel logic, plus proving of all private functions and kernels.
598
629
  ({ publicInputs, executionSteps } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
@@ -652,19 +683,16 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
652
683
  nodeRPCCalls: simulatorStats.nodeRPCCalls
653
684
  });
654
685
  } catch (err) {
655
- throw this.#contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `skipTxValidation=${skipTxValidation}`, `scopes=${scopes?.map((s)=>s.toString()).join(', ') ?? 'undefined'}`);
686
+ throw this.#contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `skipTxValidation=${skipTxValidation}`, `scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map((s)=>s.toString()).join(', ')}`);
656
687
  }
657
688
  });
658
689
  }
659
690
  /**
660
- * Simulate the execution of a contract utility function.
661
- *
691
+ * Simulates the execution of a contract utility function.
662
692
  * @param call - The function call containing the function details, arguments, and target contract address.
663
- * @param authwits - (Optional) The authentication witnesses required for the function call.
664
- * @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will
665
- * default to all.
666
- * @returns The result of the utility function call, structured based on the function ABI.
667
- */ simulateUtility(call, authwits, scopes) {
693
+ */ simulateUtility(call, { authwits, scopes } = {
694
+ scopes: 'ALL_SCOPES'
695
+ }) {
668
696
  // We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
669
697
  // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
670
698
  // delete the same read value, or reading values that another simulation is currently modifying).
@@ -677,7 +705,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
677
705
  const functionTimer = new Timer();
678
706
  const contractFunctionSimulator = this.#getSimulatorForTx();
679
707
  const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
680
- await ensureContractSynced(call.to, call.selector, (privateSyncCall)=>this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId), this.node, this.contractStore, this.noteStore, anchorBlockHeader, jobId);
708
+ await this.contractSyncService.ensureContractSynced(call.to, call.selector, (privateSyncCall, execScopes)=>this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, scopes);
681
709
  const executionResult = await this.#simulateUtility(contractFunctionSimulator, call, authwits ?? [], scopes, jobId);
682
710
  const functionTime = functionTimer.ms();
683
711
  const totalTime = totalTimer.ms();
@@ -704,7 +732,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
704
732
  } catch (err) {
705
733
  const { to, name, args } = call;
706
734
  const stringifiedArgs = args.map((arg)=>arg.toString()).join(', ');
707
- throw this.#contextualizeError(err, `simulateUtility ${to}:${name}(${stringifiedArgs})`, `scopes=${scopes?.map((s)=>s.toString()).join(', ') ?? 'undefined'}`);
735
+ throw this.#contextualizeError(err, `simulateUtility ${to}:${name}(${stringifiedArgs})`, `scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map((s)=>s.toString()).join(', ')}`);
708
736
  }
709
737
  });
710
738
  }
@@ -727,7 +755,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
727
755
  const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
728
756
  anchorBlockNumber = anchorBlockHeader.getBlockNumber();
729
757
  const contractFunctionSimulator = this.#getSimulatorForTx();
730
- await ensureContractSynced(filter.contractAddress, null, async (privateSyncCall)=>await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId), this.node, this.contractStore, this.noteStore, anchorBlockHeader, jobId);
758
+ await this.contractSyncService.ensureContractSynced(filter.contractAddress, null, async (privateSyncCall, execScopes)=>await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, filter.scopes);
731
759
  });
732
760
  // anchorBlockNumber is set during the job and fixed to whatever it is after a block sync
733
761
  const sanitizedFilter = new PrivateEventFilterValidator(anchorBlockNumber).validate(filter);
@@ -1,5 +1,5 @@
1
1
  import { toArray } from '@aztec/foundation/iterable';
2
- import { FunctionSelector, FunctionType, contractArtifactFromBuffer, contractArtifactToBuffer, encodeArguments, getFunctionDebugMetadata } from '@aztec/stdlib/abi';
2
+ import { FunctionCall, FunctionSelector, FunctionType, contractArtifactFromBuffer, contractArtifactToBuffer, encodeArguments, getFunctionDebugMetadata } from '@aztec/stdlib/abi';
3
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import { SerializableContractInstance, getContractClassFromArtifact } from '@aztec/stdlib/contract';
5
5
  import { PrivateFunctionsTree } from './private_functions_tree.js';
@@ -219,15 +219,15 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
219
219
  if (!functionDao) {
220
220
  throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
221
221
  }
222
- return {
222
+ return FunctionCall.from({
223
223
  name: functionDao.name,
224
- args: encodeArguments(functionDao, args),
224
+ to,
225
225
  selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
226
226
  type: functionDao.functionType,
227
- to,
228
227
  hideMsgSender: false,
229
228
  isStatic: functionDao.isStatic,
229
+ args: encodeArguments(functionDao, args),
230
230
  returnTypes: functionDao.returnTypes
231
- };
231
+ });
232
232
  }
233
233
  }
@@ -2,8 +2,9 @@ import type { Fr } from '@aztec/foundation/schemas';
2
2
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
3
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import type { DataInBlock } from '@aztec/stdlib/block';
5
- import { NoteDao, type NotesFilter } from '@aztec/stdlib/note';
5
+ import { NoteDao } from '@aztec/stdlib/note';
6
6
  import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
7
+ import type { NotesFilter } from '../../notes_filter.js';
7
8
  /**
8
9
  * NoteStore manages the storage and retrieval of notes.
9
10
  *
@@ -35,7 +36,6 @@ export declare class NoteStore implements StagedStore {
35
36
  * @params jobId - the job context to read from.
36
37
  * @returns Filtered and deduplicated notes (a note might be present in multiple scopes - we ensure it is only
37
38
  * returned once if this is the case)
38
- * @throws If filtering by an empty scopes array. Scopes have to be set to undefined or to a non-empty array.
39
39
  */
40
40
  getNotes(filter: NotesFilter, jobId: string): Promise<NoteDao[]>;
41
41
  /**
@@ -80,4 +80,4 @@ export declare class NoteStore implements StagedStore {
80
80
  commit(jobId: string): Promise<void>;
81
81
  discardStaged(jobId: string): Promise<void>;
82
82
  }
83
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm90ZV9zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2Uvbm90ZV9zdG9yZS9ub3RlX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFxQyxNQUFNLGlCQUFpQixDQUFDO0FBQzVGLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2hFLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3ZELE9BQU8sRUFBRSxPQUFPLEVBQWMsS0FBSyxXQUFXLEVBQUUsTUFBT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AAW,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGzD;;;;;IAKI;AACJ,qBAAa,SAAU,YAAW,WAAW;;IAC3C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAU;IA+BpC,YAAY,KAAK,EAAE,iBAAiB,EAQnC;IAED;;;;;;;;;OASG;IACI,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAarF;IAcD;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAgG/D;IAED;;;;;;;;;;;;;;OAcG;IACH,eAAe,CAAC,UAAU,EAAE,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAyChF;IAED;;;;;;;;;;;OAWG;IACU,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMpF;IA6ED;;;;;;;;;OASG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUzC;IAED,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG1C;CAkCF"}
@@ -74,10 +74,9 @@ import { StoredNote } from './stored_note.js';
74
74
  * @params jobId - the job context to read from.
75
75
  * @returns Filtered and deduplicated notes (a note might be present in multiple scopes - we ensure it is only
76
76
  * returned once if this is the case)
77
- * @throws If filtering by an empty scopes array. Scopes have to be set to undefined or to a non-empty array.
78
77
  */ getNotes(filter, jobId) {
79
- if (filter.scopes !== undefined && filter.scopes.length === 0) {
80
- return Promise.reject(new Error('Trying to get notes with an empty scopes array'));
78
+ if (filter.scopes !== 'ALL_SCOPES' && filter.scopes.length === 0) {
79
+ return Promise.resolve([]);
81
80
  }
82
81
  return this.#store.transactionAsync(async ()=>{
83
82
  const targetStatus = filter.status ?? NoteStatus.ACTIVE;
@@ -136,7 +135,7 @@ import { StoredNote } from './stored_note.js';
136
135
  if (filter.siloedNullifier && !note.noteDao.siloedNullifier.equals(filter.siloedNullifier)) {
137
136
  continue;
138
137
  }
139
- if (filter.scopes && note.scopes.intersection(new Set(filter.scopes.map((s)=>s.toString()))).size === 0) {
138
+ if (filter.scopes !== 'ALL_SCOPES' && note.scopes.intersection(new Set(filter.scopes.map((s)=>s.toString()))).size === 0) {
140
139
  continue;
141
140
  }
142
141
  foundNotes.set(note.noteDao.siloedNullifier.toString(), note.noteDao);
@@ -173,6 +172,9 @@ import { StoredNote } from './stored_note.js';
173
172
  if (nullifiers.length === 0) {
174
173
  return Promise.resolve([]);
175
174
  }
175
+ if (nullifiers.some((n)=>n.l2BlockNumber === 0)) {
176
+ return Promise.reject(new Error('applyNullifiers: nullifiers cannot have been emitted at block 0'));
177
+ }
176
178
  return this.#withJobLock(jobId, ()=>this.#store.transactionAsync(async ()=>{
177
179
  const notesToNullify = await Promise.all(nullifiers.map(async (nullifierInBlock)=>{
178
180
  const nullifier = nullifierInBlock.data.toString();
@@ -21,4 +21,4 @@ export declare function getAllPrivateLogsByTags(aztecNode: AztecNode, tags: Silo
21
21
  * @returns An array of log arrays, one per tag, containing all logs across all pages.
22
22
  */
23
23
  export declare function getAllPublicLogsByTagsFromContract(aztecNode: AztecNode, contractAddress: AztecAddress, tags: Tag[], anchorBlockHash: BlockHash): Promise<TxScopedL2Log[][]>;
24
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0X2FsbF9sb2dzX2J5X3RhZ3MuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90YWdnaW5nL2dld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ACjB,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAE5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,kCAAkC,CAChD,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,YAAY,EAC7B,IAAI,EAAE,GAAG,EAAE,EACX,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAI5B"}
1
+ {"version":3,"file":"get_all_logs_by_tags.d.ts","sourceRoot":"","sources":["../../src/tagging/get_all_logs_by_tags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAiDxE;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,SAAS,EAAE,EACjB,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAI5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,kCAAkC,CAChD,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,YAAY,EAC7B,IAAI,EAAE,GAAG,EAAE,EACX,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAM5B"}
@@ -1,4 +1,4 @@
1
- import { MAX_LOGS_PER_TAG } from '@aztec/stdlib/interfaces/api-limit';
1
+ import { MAX_LOGS_PER_TAG, MAX_RPC_LEN } from '@aztec/stdlib/interfaces/api-limit';
2
2
  /**
3
3
  * Generic pagination helper that fetches all pages of results.
4
4
  * @param numTags - The number of tags being queried (determines result array size).
@@ -23,6 +23,20 @@ import { MAX_LOGS_PER_TAG } from '@aztec/stdlib/interfaces/api-limit';
23
23
  }
24
24
  return allResultsPerTag;
25
25
  }
26
+ /**
27
+ * Splits tags into chunks of MAX_RPC_LEN, fetches logs for each chunk using getAllPages, then stitches the results
28
+ * back into a single array preserving the original tag order.
29
+ */ async function getAllPagesInBatches(tags, fetchAllPagesForBatch) {
30
+ if (tags.length <= MAX_RPC_LEN) {
31
+ return fetchAllPagesForBatch(tags);
32
+ }
33
+ const batches = [];
34
+ for(let i = 0; i < tags.length; i += MAX_RPC_LEN){
35
+ batches.push(tags.slice(i, i + MAX_RPC_LEN));
36
+ }
37
+ const batchResults = await Promise.all(batches.map(fetchAllPagesForBatch));
38
+ return batchResults.flat();
39
+ }
26
40
  /**
27
41
  * Fetches all private logs for the given tags, automatically paginating through all pages.
28
42
  * @param aztecNode - The Aztec node to query.
@@ -31,7 +45,7 @@ import { MAX_LOGS_PER_TAG } from '@aztec/stdlib/interfaces/api-limit';
31
45
  * because of reorgs).
32
46
  * @returns An array of log arrays, one per tag, containing all logs across all pages.
33
47
  */ export function getAllPrivateLogsByTags(aztecNode, tags, anchorBlockHash) {
34
- return getAllPages(tags.length, (page)=>aztecNode.getPrivateLogsByTags(tags, page, anchorBlockHash));
48
+ return getAllPagesInBatches(tags, (batch)=>getAllPages(batch.length, (page)=>aztecNode.getPrivateLogsByTags(batch, page, anchorBlockHash)));
35
49
  }
36
50
  /**
37
51
  * Fetches all public logs for the given tags from a contract, automatically paginating through all pages.
@@ -42,5 +56,5 @@ import { MAX_LOGS_PER_TAG } from '@aztec/stdlib/interfaces/api-limit';
42
56
  * because of reorgs).
43
57
  * @returns An array of log arrays, one per tag, containing all logs across all pages.
44
58
  */ export function getAllPublicLogsByTagsFromContract(aztecNode, contractAddress, tags, anchorBlockHash) {
45
- return getAllPages(tags.length, (page)=>aztecNode.getPublicLogsByTagsFromContract(contractAddress, tags, page, anchorBlockHash));
59
+ return getAllPagesInBatches(tags, (batch)=>getAllPages(batch.length, (page)=>aztecNode.getPublicLogsByTagsFromContract(contractAddress, batch, page, anchorBlockHash)));
46
60
  }
@@ -13,7 +13,7 @@ import { loadLogsForRange } from './utils/load_logs_for_range.js';
13
13
  // (highestAgedIndex, highestFinalizedIndex + WINDOW_LEN]
14
14
  //
15
15
  // highestAgedIndex is the highest index that was used in a tx that is included in a block at least
16
- // `MAX_INCLUDE_BY_TIMESTAMP_DURATION` seconds ago.
16
+ // `MAX_TX_LIFETIME` seconds ago.
17
17
  // highestFinalizedIndex is the highest index that was used in a tx that is included in a finalized block.
18
18
  //
19
19
  // "(" denotes an open end of the range - the index is not included in the range.
@@ -25,19 +25,19 @@ import { loadLogsForRange } from './utils/load_logs_for_range.js';
25
25
  // ever appear.
26
26
  //
27
27
  // This relies on the "maximum inclusion timestamp" rule enforced by the kernel and rollup circuits:
28
- // - a transaction's maximum inclusion timestamp is at most `MAX_INCLUDE_BY_TIMESTAMP_DURATION` seconds after
28
+ // - a transaction's maximum inclusion timestamp is at most `MAX_TX_LIFETIME` seconds after
29
29
  // the timestamp of its anchor block; and
30
30
  // - a rollup only includes transactions whose inclusion timestamp is >= the L2 block's timestamp.
31
31
  //
32
32
  // Suppose some device used index `I` in a transaction anchored to block `B_N` at time `N`, and that block is now at
33
- // least `MAX_INCLUDE_BY_TIMESTAMP_DURATION` seconds in the past. Then there is no possibility of any *other* device
33
+ // least `MAX_TX_LIFETIME` seconds in the past. Then there is no possibility of any *other* device
34
34
  // trying to use an index <= `I` while anchoring to a *newer* block than `B_N` because if we were anchoring to
35
35
  // a newer block than `B_N` then we would already have seen the log with index `I` and hence the device would have
36
36
  // chosen a larger index.
37
37
  // If that *other* device would anchor to a block older than `B_N` then that tx could never be included in a block
38
38
  // because it would already have been expired.
39
39
  //
40
- // Therefore, once we see that index `I` has been used in a block that is at least `MAX_INCLUDE_BY_TIMESTAMP_DURATION`
40
+ // Therefore, once we see that index `I` has been used in a block that is at least `MAX_TX_LIFETIME`
41
41
  // seconds old, we can safely stop syncing logs for all indexes <= `I` and set highestAgedIndex = `I`.
42
42
  //
43
43
  // ## Explanation of the upper bound `highestFinalizedIndex + WINDOW_LEN`
@@ -1,4 +1,4 @@
1
- import { MAX_INCLUDE_BY_TIMESTAMP_DURATION } from '@aztec/constants';
1
+ import { MAX_TX_LIFETIME } from '@aztec/constants';
2
2
  /**
3
3
  * Finds the highest aged and the highest finalized tagging indexes.
4
4
  */ export function findHighestIndexes(privateLogsWithIndexes, currentTimestamp, finalizedBlockNumber) {
@@ -6,7 +6,7 @@ import { MAX_INCLUDE_BY_TIMESTAMP_DURATION } from '@aztec/constants';
6
6
  let highestFinalizedIndex = undefined;
7
7
  for (const { log, taggingIndex } of privateLogsWithIndexes){
8
8
  const ageInSeconds = currentTimestamp - log.blockTimestamp;
9
- if (ageInSeconds >= BigInt(MAX_INCLUDE_BY_TIMESTAMP_DURATION) && (highestAgedIndex === undefined || taggingIndex > highestAgedIndex)) {
9
+ if (ageInSeconds >= BigInt(MAX_TX_LIFETIME) && (highestAgedIndex === undefined || taggingIndex > highestAgedIndex)) {
10
10
  highestAgedIndex = taggingIndex;
11
11
  }
12
12
  if (log.blockNumber <= finalizedBlockNumber && (highestFinalizedIndex === undefined || taggingIndex > highestFinalizedIndex)) {
package/package.json CHANGED
@@ -1,7 +1,16 @@
1
1
  {
2
2
  "name": "@aztec/pxe",
3
- "version": "0.0.1-commit.8afd444",
3
+ "version": "0.0.1-commit.8f9871590",
4
4
  "type": "module",
5
+ "typedocOptions": {
6
+ "entryPoints": [
7
+ "./src/entrypoints/server/index.ts",
8
+ "./src/entrypoints/client/lazy/index.ts",
9
+ "./src/config/index.ts"
10
+ ],
11
+ "name": "PXE",
12
+ "tsconfig": "./tsconfig.json"
13
+ },
5
14
  "exports": {
6
15
  "./server": "./dest/entrypoints/server/index.js",
7
16
  "./client/lazy": "./dest/entrypoints/client/lazy/index.js",
@@ -61,19 +70,19 @@
61
70
  ]
62
71
  },
63
72
  "dependencies": {
64
- "@aztec/bb-prover": "0.0.1-commit.8afd444",
65
- "@aztec/bb.js": "0.0.1-commit.8afd444",
66
- "@aztec/builder": "0.0.1-commit.8afd444",
67
- "@aztec/constants": "0.0.1-commit.8afd444",
68
- "@aztec/ethereum": "0.0.1-commit.8afd444",
69
- "@aztec/foundation": "0.0.1-commit.8afd444",
70
- "@aztec/key-store": "0.0.1-commit.8afd444",
71
- "@aztec/kv-store": "0.0.1-commit.8afd444",
72
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.8afd444",
73
- "@aztec/noir-types": "0.0.1-commit.8afd444",
74
- "@aztec/protocol-contracts": "0.0.1-commit.8afd444",
75
- "@aztec/simulator": "0.0.1-commit.8afd444",
76
- "@aztec/stdlib": "0.0.1-commit.8afd444",
73
+ "@aztec/bb-prover": "0.0.1-commit.8f9871590",
74
+ "@aztec/bb.js": "0.0.1-commit.8f9871590",
75
+ "@aztec/builder": "0.0.1-commit.8f9871590",
76
+ "@aztec/constants": "0.0.1-commit.8f9871590",
77
+ "@aztec/ethereum": "0.0.1-commit.8f9871590",
78
+ "@aztec/foundation": "0.0.1-commit.8f9871590",
79
+ "@aztec/key-store": "0.0.1-commit.8f9871590",
80
+ "@aztec/kv-store": "0.0.1-commit.8f9871590",
81
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.8f9871590",
82
+ "@aztec/noir-types": "0.0.1-commit.8f9871590",
83
+ "@aztec/protocol-contracts": "0.0.1-commit.8f9871590",
84
+ "@aztec/simulator": "0.0.1-commit.8f9871590",
85
+ "@aztec/stdlib": "0.0.1-commit.8f9871590",
77
86
  "koa": "^2.16.1",
78
87
  "koa-router": "^13.1.1",
79
88
  "lodash.omit": "^4.5.0",
@@ -82,8 +91,8 @@
82
91
  "viem": "npm:@aztec/viem@2.38.2"
83
92
  },
84
93
  "devDependencies": {
85
- "@aztec/merkle-tree": "0.0.1-commit.8afd444",
86
- "@aztec/noir-test-contracts.js": "0.0.1-commit.8afd444",
94
+ "@aztec/merkle-tree": "0.0.1-commit.8f9871590",
95
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.8f9871590",
87
96
  "@jest/globals": "^30.0.0",
88
97
  "@types/jest": "^30.0.0",
89
98
  "@types/lodash.omit": "^4.5.7",
@@ -0,0 +1,9 @@
1
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+
3
+ /**
4
+ * Controls which accounts' private state and keys are accessible during execution.
5
+ * - `'ALL_SCOPES'`: All registered accounts' private state and keys are accessible.
6
+ * - `AztecAddress[]` with entries: Only the specified accounts' private state and keys are accessible.
7
+ * - `[]` (empty array): Deny-all. No private state is visible and no keys are accessible.
8
+ */
9
+ export type AccessScopes = 'ALL_SCOPES' | AztecAddress[];
@@ -7,6 +7,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
7
7
  import type { BlockHeader } from '@aztec/stdlib/tx';
8
8
 
9
9
  import type { BlockSynchronizerConfig } from '../config/index.js';
10
+ import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
10
11
  import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
11
12
  import type { NoteStore } from '../storage/note_store/note_store.js';
12
13
  import type { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
@@ -28,6 +29,7 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
28
29
  private noteStore: NoteStore,
29
30
  private privateEventStore: PrivateEventStore,
30
31
  private l2TipsStore: L2TipsKVStore,
32
+ private contractSyncService: ContractSyncService,
31
33
  private config: Partial<BlockSynchronizerConfig> = {},
32
34
  bindings?: LoggerBindings,
33
35
  ) {
@@ -125,6 +127,10 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
125
127
 
126
128
  /** Updates the anchor block header to the target block */
127
129
  private async updateAnchorBlockHeader(blockHeader: BlockHeader) {
130
+ // Whenever the anchor block header is updated, we need to synchronize the private state of contracts again.
131
+ // Therefore, we clear the contract synchronization cache here such that the sync is re-triggered upon new
132
+ // execution.
133
+ this.contractSyncService.wipe();
128
134
  this.log.verbose(`Updated pxe last block to ${blockHeader.getBlockNumber()}`, blockHeader.toInspect());
129
135
  await this.anchorBlockStore.setHeader(blockHeader);
130
136
  }