@aztec/pxe 0.0.1-commit.c80b6263 → 0.0.1-commit.cf93bcc56

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 (154) 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 -30
  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 -66
  10. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
  11. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -2
  12. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  13. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
  14. package/dest/contract_function_simulator/oracle/interfaces.d.ts +9 -9
  15. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  16. package/dest/contract_function_simulator/oracle/oracle.d.ts +5 -5
  17. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  18. package/dest/contract_function_simulator/oracle/oracle.js +32 -20
  19. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +36 -36
  20. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  21. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +74 -21
  22. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +48 -24
  23. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  24. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +85 -61
  25. package/dest/contract_sync/contract_sync_service.d.ts +43 -0
  26. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  27. package/dest/contract_sync/contract_sync_service.js +97 -0
  28. package/dest/contract_sync/helpers.d.ts +29 -0
  29. package/dest/contract_sync/helpers.d.ts.map +1 -0
  30. package/dest/contract_sync/{index.js → helpers.js} +13 -12
  31. package/dest/debug/pxe_debug_utils.d.ts +14 -10
  32. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  33. package/dest/debug/pxe_debug_utils.js +16 -15
  34. package/dest/entrypoints/client/bundle/index.d.ts +3 -1
  35. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  36. package/dest/entrypoints/client/bundle/index.js +2 -0
  37. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  38. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  39. package/dest/entrypoints/client/bundle/utils.js +11 -2
  40. package/dest/entrypoints/client/lazy/index.d.ts +3 -1
  41. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  42. package/dest/entrypoints/client/lazy/index.js +2 -0
  43. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  44. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  45. package/dest/entrypoints/client/lazy/utils.js +11 -2
  46. package/dest/entrypoints/server/index.d.ts +4 -2
  47. package/dest/entrypoints/server/index.d.ts.map +1 -1
  48. package/dest/entrypoints/server/index.js +3 -1
  49. package/dest/entrypoints/server/utils.js +9 -1
  50. package/dest/events/event_service.d.ts +4 -5
  51. package/dest/events/event_service.d.ts.map +1 -1
  52. package/dest/events/event_service.js +5 -6
  53. package/dest/logs/log_service.d.ts +6 -5
  54. package/dest/logs/log_service.d.ts.map +1 -1
  55. package/dest/logs/log_service.js +14 -24
  56. package/dest/notes/note_service.d.ts +7 -7
  57. package/dest/notes/note_service.d.ts.map +1 -1
  58. package/dest/notes/note_service.js +9 -9
  59. package/dest/notes_filter.d.ts +25 -0
  60. package/dest/notes_filter.d.ts.map +1 -0
  61. package/dest/notes_filter.js +4 -0
  62. package/dest/oracle_version.d.ts +3 -3
  63. package/dest/oracle_version.d.ts.map +1 -1
  64. package/dest/oracle_version.js +2 -2
  65. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  66. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  67. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  68. package/dest/private_kernel/hints/index.d.ts +1 -1
  69. package/dest/private_kernel/hints/index.js +1 -1
  70. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +4 -4
  71. package/dest/private_kernel/private_kernel_execution_prover.js +6 -6
  72. package/dest/pxe.d.ts +69 -23
  73. package/dest/pxe.d.ts.map +1 -1
  74. package/dest/pxe.js +72 -44
  75. package/dest/storage/address_store/address_store.d.ts +1 -1
  76. package/dest/storage/address_store/address_store.d.ts.map +1 -1
  77. package/dest/storage/address_store/address_store.js +12 -11
  78. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
  79. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  80. package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
  81. package/dest/storage/capsule_store/capsule_store.js +6 -8
  82. package/dest/storage/contract_store/contract_store.d.ts +1 -1
  83. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  84. package/dest/storage/contract_store/contract_store.js +27 -18
  85. package/dest/storage/metadata.d.ts +1 -1
  86. package/dest/storage/metadata.js +1 -1
  87. package/dest/storage/note_store/note_store.d.ts +13 -3
  88. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  89. package/dest/storage/note_store/note_store.js +147 -107
  90. package/dest/storage/private_event_store/private_event_store.d.ts +1 -1
  91. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  92. package/dest/storage/private_event_store/private_event_store.js +84 -61
  93. package/dest/storage/private_event_store/stored_private_event.js +1 -1
  94. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +1 -1
  95. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  96. package/dest/storage/tagging_store/recipient_tagging_store.js +31 -19
  97. package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
  98. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
  99. package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
  100. package/dest/storage/tagging_store/sender_tagging_store.d.ts +1 -1
  101. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  102. package/dest/storage/tagging_store/sender_tagging_store.js +183 -113
  103. package/dest/tagging/get_all_logs_by_tags.d.ts +1 -1
  104. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
  105. package/dest/tagging/get_all_logs_by_tags.js +17 -3
  106. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +4 -4
  107. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  108. package/package.json +25 -16
  109. package/src/access_scopes.ts +9 -0
  110. package/src/block_synchronizer/block_synchronizer.ts +6 -0
  111. package/src/contract_function_simulator/contract_function_simulator.ts +318 -121
  112. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  113. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
  114. package/src/contract_function_simulator/oracle/interfaces.ts +10 -10
  115. package/src/contract_function_simulator/oracle/oracle.ts +35 -18
  116. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +97 -101
  117. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +129 -63
  118. package/src/contract_sync/contract_sync_service.ts +152 -0
  119. package/src/contract_sync/{index.ts → helpers.ts} +21 -21
  120. package/src/debug/pxe_debug_utils.ts +48 -18
  121. package/src/entrypoints/client/bundle/index.ts +2 -0
  122. package/src/entrypoints/client/bundle/utils.ts +12 -2
  123. package/src/entrypoints/client/lazy/index.ts +2 -0
  124. package/src/entrypoints/client/lazy/utils.ts +12 -2
  125. package/src/entrypoints/server/index.ts +3 -1
  126. package/src/entrypoints/server/utils.ts +7 -7
  127. package/src/events/event_service.ts +4 -6
  128. package/src/logs/log_service.ts +14 -29
  129. package/src/notes/note_service.ts +9 -10
  130. package/src/notes_filter.ts +26 -0
  131. package/src/oracle_version.ts +2 -2
  132. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  133. package/src/private_kernel/hints/index.ts +1 -1
  134. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +7 -7
  135. package/src/private_kernel/private_kernel_execution_prover.ts +6 -6
  136. package/src/pxe.ts +151 -88
  137. package/src/storage/address_store/address_store.ts +15 -15
  138. package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
  139. package/src/storage/capsule_store/capsule_store.ts +8 -8
  140. package/src/storage/contract_store/contract_store.ts +26 -15
  141. package/src/storage/metadata.ts +1 -1
  142. package/src/storage/note_store/note_store.ts +169 -132
  143. package/src/storage/private_event_store/private_event_store.ts +102 -81
  144. package/src/storage/private_event_store/stored_private_event.ts +1 -1
  145. package/src/storage/tagging_store/recipient_tagging_store.ts +31 -21
  146. package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
  147. package/src/storage/tagging_store/sender_tagging_store.ts +210 -126
  148. package/src/tagging/get_all_logs_by_tags.ts +28 -4
  149. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +4 -4
  150. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  151. package/dest/contract_sync/index.d.ts +0 -23
  152. package/dest/contract_sync/index.d.ts.map +0 -1
  153. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  154. 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.anchorBlockStore, 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, anchorBlockHeader);
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, anchorBlockHeader);
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, anchorBlockHeader);
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);
@@ -8,4 +8,4 @@ export declare class AddressStore {
8
8
  getCompleteAddress(account: AztecAddress): Promise<CompleteAddress | undefined>;
9
9
  getCompleteAddresses(): Promise<CompleteAddress[]>;
10
10
  }
11
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWRkcmVzc19zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2UvYWRkcmVzc19zdG9yZS9hZGRyZXNzX3N0b3JlLnRzIl0sIm5hbWV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FFLGVBQWUsR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLENBMEJyRTtJQUVELGtCQUFrQixDQUFDLE9BQU8sRUFBRSxZQUFZLEdBQUcsT0FBTyxDQUFDLGVBQWUsR0FBRyxTQUFTLENBQUMsQ0FVOUU7SUFFRCxvQkFBb0IsSUFBSSxPQUFPLENBQUMsZUFBZSxFQUFFLENBQUMsQ0FNakQ7Q0FDRiJ9
@@ -1 +1 @@
1
- {"version":3,"file":"address_store.d.ts","sourceRoot":"","sources":["../../../src/storage/address_store/address_store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,YAAY;;IAKvB,YAAY,KAAK,EAAE,iBAAiB,EAKnC;IAED,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CA0BrE;IAYD,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAE9E;IAEK,oBAAoB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAIvD;CACF"}
1
+ {"version":3,"file":"address_store.d.ts","sourceRoot":"","sources":["../../../src/storage/address_store/address_store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,YAAY;;IAKvB,YAAY,KAAK,EAAE,iBAAiB,EAKnC;IAED,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CA0BrE;IAED,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAU9E;IAED,oBAAoB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAMjD;CACF"}
@@ -30,18 +30,19 @@ export class AddressStore {
30
30
  }
31
31
  });
32
32
  }
33
- async #getCompleteAddress(address) {
34
- const index = await this.#completeAddressIndex.getAsync(address.toString());
35
- if (index === undefined) {
36
- return undefined;
37
- }
38
- const value = await this.#completeAddresses.atAsync(index);
39
- return value ? await CompleteAddress.fromBuffer(value) : undefined;
40
- }
41
33
  getCompleteAddress(account) {
42
- return this.#getCompleteAddress(account);
34
+ return this.#store.transactionAsync(async ()=>{
35
+ const index = await this.#completeAddressIndex.getAsync(account.toString());
36
+ if (index === undefined) {
37
+ return undefined;
38
+ }
39
+ const value = await this.#completeAddresses.atAsync(index);
40
+ return value ? await CompleteAddress.fromBuffer(value) : undefined;
41
+ });
43
42
  }
44
- async getCompleteAddresses() {
45
- return await Promise.all((await toArray(this.#completeAddresses.valuesAsync())).map((v)=>CompleteAddress.fromBuffer(v)));
43
+ getCompleteAddresses() {
44
+ return this.#store.transactionAsync(async ()=>{
45
+ return await Promise.all((await toArray(this.#completeAddresses.valuesAsync())).map((v)=>CompleteAddress.fromBuffer(v)));
46
+ });
46
47
  }
47
48
  }
@@ -3,7 +3,15 @@ import { BlockHeader } from '@aztec/stdlib/tx';
3
3
  export declare class AnchorBlockStore {
4
4
  #private;
5
5
  constructor(store: AztecAsyncKVStore);
6
+ /**
7
+ * Sets the currently synchronized block
8
+ *
9
+ * Important: this method is only called from BlockSynchronizer, and since we need it to run atomically with other
10
+ * stores in the case of a reorg, it MUST NOT be wrapped in a `transactionAsync` call. Doing so would result in a
11
+ * deadlock when the backend is IndexedDB, because `transactionAsync` is not designed to support reentrancy.
12
+ *
13
+ */
6
14
  setHeader(header: BlockHeader): Promise<void>;
7
15
  getBlockHeader(): Promise<BlockHeader>;
8
16
  }
9
- //# sourceMappingURL=data:application/json;base64,eyJ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VcsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBRWxEO0lBRUssY0FBYyxJQUFJLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FPM0M7Q0FDRiJ9
@@ -1 +1 @@
1
- {"version":3,"file":"anchor_block_store.d.ts","sourceRoot":"","sources":["../../../src/storage/anchor_block_store/anchor_block_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,qBAAa,gBAAgB;;IAI3B,YAAY,KAAK,EAAE,iBAAiB,EAGnC;IAEK,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAElD;IAEK,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC,CAO3C;CACF"}
1
+ {"version":3,"file":"anchor_block_store.d.ts","sourceRoot":"","sources":["../../../src/storage/anchor_block_store/anchor_block_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,qBAAa,gBAAgB;;IAI3B,YAAY,KAAK,EAAE,iBAAiB,EAGnC;IAED;;;;;;;OAOG;IACG,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAElD;IAEK,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC,CAO3C;CACF"}
@@ -6,7 +6,14 @@ export class AnchorBlockStore {
6
6
  this.#store = store;
7
7
  this.#synchronizedHeader = this.#store.openSingleton('header');
8
8
  }
9
- async setHeader(header) {
9
+ /**
10
+ * Sets the currently synchronized block
11
+ *
12
+ * Important: this method is only called from BlockSynchronizer, and since we need it to run atomically with other
13
+ * stores in the case of a reorg, it MUST NOT be wrapped in a `transactionAsync` call. Doing so would result in a
14
+ * deadlock when the backend is IndexedDB, because `transactionAsync` is not designed to support reentrancy.
15
+ *
16
+ */ async setHeader(header) {
10
17
  await this.#synchronizedHeader.set(header.toBuffer());
11
18
  }
12
19
  async getBlockHeader() {
@@ -40,14 +40,12 @@ export class CapsuleStore {
40
40
  * If it is not there, it reads it from the KV store.
41
41
  */ async #getFromStage(jobId, dbSlotKey) {
42
42
  const jobStagedCapsules = this.#getJobStagedCapsules(jobId);
43
- let staged = jobStagedCapsules.get(dbSlotKey);
44
- // Note that if staged === null, we marked it for deletion, so we don't want to
45
- // re-read it from DB
46
- if (staged === undefined) {
47
- // If we don't have a staged version of this dbSlotKey, first we check if there's one in DB
48
- staged = await this.#loadCapsuleFromDb(dbSlotKey);
49
- }
50
- return staged;
43
+ const staged = jobStagedCapsules.get(dbSlotKey);
44
+ // Always issue DB read to keep IndexedDB transaction alive, even if the value is in the job staged data. This
45
+ // keeps IndexedDB transactions alive (they auto-commit when a new micro-task starts and there are no pending read
46
+ // requests). The staged value still takes precedence if it exists (including null for deletions).
47
+ const dbValue = await this.#loadCapsuleFromDb(dbSlotKey);
48
+ return staged !== undefined ? staged : dbValue;
51
49
  }
52
50
  /**
53
51
  * Writes a capsule to the stage of a job.
@@ -63,4 +63,4 @@ export declare class ContractStore {
63
63
  getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string>;
64
64
  getFunctionCall(functionName: string, args: any[], to: AztecAddress): Promise<FunctionCall>;
65
65
  }
66
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3Rfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL2NvbnRyYWN0X3N0b3JlL2NvbnRyYWN0X3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sa0JBQWtCLENBQUM7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AAC,eAAe,EAAE,YAAY,+BAG9D;IAEY,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,mBAI1F;IA8BY,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAuBvG;CACF"}
@@ -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';
@@ -13,20 +13,23 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
13
13
  /** Map from contract class id to private function tree. */ // TODO: Update it to be LRU cache so that it doesn't keep all the data all the time.
14
14
  #privateFunctionTrees = new Map();
15
15
  /** Map from contract address to contract class id */ #contractClassIdMap = new Map();
16
+ #store;
16
17
  #contractArtifacts;
17
18
  #contractInstances;
18
19
  constructor(store){
20
+ this.#store = store;
19
21
  this.#contractArtifacts = store.openMap('contract_artifacts');
20
22
  this.#contractInstances = store.openMap('contracts_instances');
21
23
  }
22
24
  // Setters
23
25
  async addContractArtifact(id, contract) {
26
+ // Validation outside transactionAsync - these are not DB operations
24
27
  const privateFunctions = contract.functions.filter((functionArtifact)=>functionArtifact.functionType === FunctionType.PRIVATE);
25
28
  const privateSelectors = await Promise.all(privateFunctions.map(async (privateFunctionArtifact)=>(await FunctionSelector.fromNameAndParameters(privateFunctionArtifact.name, privateFunctionArtifact.parameters)).toString()));
26
29
  if (privateSelectors.length !== new Set(privateSelectors).size) {
27
30
  throw new Error('Repeated function selectors of private functions');
28
31
  }
29
- await this.#contractArtifacts.set(id.toString(), contractArtifactToBuffer(contract));
32
+ await this.#store.transactionAsync(()=>this.#contractArtifacts.set(id.toString(), contractArtifactToBuffer(contract)));
30
33
  }
31
34
  async addContractInstance(contract) {
32
35
  this.#contractClassIdMap.set(contract.address.toString(), contract.currentContractClassId);
@@ -68,18 +71,24 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
68
71
  return contractClassId && this.getContractArtifact(contractClassId);
69
72
  }
70
73
  // Public getters
71
- async getContractsAddresses() {
72
- const keys = await toArray(this.#contractInstances.keysAsync());
73
- return keys.map(AztecAddress.fromString);
74
- }
75
- /** Returns a contract instance for a given address. Throws if not found. */ async getContractInstance(contractAddress) {
76
- const contract = await this.#contractInstances.getAsync(contractAddress.toString());
77
- return contract && SerializableContractInstance.fromBuffer(contract).withAddress(contractAddress);
78
- }
79
- async getContractArtifact(contractClassId) {
80
- const contract = await this.#contractArtifacts.getAsync(contractClassId.toString());
81
- // TODO(@spalladino): AztecAsyncMap lies and returns Uint8Arrays instead of Buffers, hence the extra Buffer.from.
82
- return contract && contractArtifactFromBuffer(Buffer.from(contract));
74
+ getContractsAddresses() {
75
+ return this.#store.transactionAsync(async ()=>{
76
+ const keys = await toArray(this.#contractInstances.keysAsync());
77
+ return keys.map(AztecAddress.fromString);
78
+ });
79
+ }
80
+ /** Returns a contract instance for a given address. Throws if not found. */ getContractInstance(contractAddress) {
81
+ return this.#store.transactionAsync(async ()=>{
82
+ const contract = await this.#contractInstances.getAsync(contractAddress.toString());
83
+ return contract && SerializableContractInstance.fromBuffer(contract).withAddress(contractAddress);
84
+ });
85
+ }
86
+ getContractArtifact(contractClassId) {
87
+ return this.#store.transactionAsync(async ()=>{
88
+ const contract = await this.#contractArtifacts.getAsync(contractClassId.toString());
89
+ // TODO(@spalladino): AztecAsyncMap lies and returns Uint8Arrays instead of Buffers, hence the extra Buffer.from.
90
+ return contract && contractArtifactFromBuffer(Buffer.from(contract));
91
+ });
83
92
  }
84
93
  /** Returns a contract class for a given class id. Throws if not found. */ async getContractClass(contractClassId) {
85
94
  const artifact = await this.getContractArtifact(contractClassId);
@@ -210,15 +219,15 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
210
219
  if (!functionDao) {
211
220
  throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
212
221
  }
213
- return {
222
+ return FunctionCall.from({
214
223
  name: functionDao.name,
215
- args: encodeArguments(functionDao, args),
224
+ to,
216
225
  selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
217
226
  type: functionDao.functionType,
218
- to,
219
227
  hideMsgSender: false,
220
228
  isStatic: functionDao.isStatic,
229
+ args: encodeArguments(functionDao, args),
221
230
  returnTypes: functionDao.returnTypes
222
- };
231
+ });
223
232
  }
224
233
  }
@@ -1,2 +1,2 @@
1
- export declare const PXE_DATA_SCHEMA_VERSION = 2;
1
+ export declare const PXE_DATA_SCHEMA_VERSION = 3;
2
2
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWV0YWRhdGEuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdG9yYWdlL21ldGFkYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGVBQU8sTUFBTSx1QkFBdUIsSUFBSSxDQUFDIn0=
@@ -1 +1 @@
1
- export const PXE_DATA_SCHEMA_VERSION = 2;
1
+ export const PXE_DATA_SCHEMA_VERSION = 3;
@@ -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
  /**
@@ -67,7 +67,17 @@ export declare class NoteStore implements StagedStore {
67
67
  * @param synchedBlockNumber - The block number up to which PXE managed to sync before the reorg happened.
68
68
  */
69
69
  rollback(blockNumber: number, synchedBlockNumber: number): Promise<void>;
70
+ /**
71
+ * Commits in memory job data to persistent storage.
72
+ *
73
+ * Called by JobCoordinator when a job completes successfully.
74
+ *
75
+ * Note: JobCoordinator wraps all commits in a single transaction, so we don't need our own transactionAsync here
76
+ * (and using one would throw on IndexedDB as it does not support nested txs).
77
+ *
78
+ * @param jobId - The jobId identifying which staged data to commit
79
+ */
70
80
  commit(jobId: string): Promise<void>;
71
81
  discardStaged(jobId: string): Promise<void>;
72
82
  }
73
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm90ZV9zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2Uvbm90ZV9zdG9yZS9ub3RlX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFxQyxNQUFNLGlCQUFpQixDQUFDO0FBQzVGLE9BQU8sS0FBSyxFQUFFLFl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