@aztec/pxe 0.0.1-commit.358457c → 0.0.1-commit.3750d92a7

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 (197) hide show
  1. package/dest/bin/check_oracle_version.js +4 -4
  2. package/dest/block_synchronizer/block_synchronizer.d.ts +1 -1
  3. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  4. package/dest/block_synchronizer/block_synchronizer.js +6 -0
  5. package/dest/config/index.d.ts +2 -2
  6. package/dest/config/index.d.ts.map +1 -1
  7. package/dest/config/index.js +8 -15
  8. package/dest/contract_function_simulator/contract_function_simulator.d.ts +10 -5
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  10. package/dest/contract_function_simulator/contract_function_simulator.js +31 -8
  11. package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
  12. package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
  13. package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
  14. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
  15. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  16. package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
  17. package/dest/contract_function_simulator/index.d.ts +2 -1
  18. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  19. package/dest/contract_function_simulator/index.js +1 -0
  20. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -6
  21. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +8 -10
  23. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
  24. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
  25. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
  26. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  27. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +2 -4
  28. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +4 -7
  29. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  30. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +6 -11
  31. package/dest/contract_function_simulator/oracle/interfaces.d.ts +61 -45
  32. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  33. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
  34. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
  35. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +47 -0
  36. package/dest/contract_function_simulator/oracle/oracle.d.ts +75 -44
  37. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  38. package/dest/contract_function_simulator/oracle/oracle.js +281 -96
  39. package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
  40. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +23 -49
  41. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  42. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +48 -71
  43. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +89 -56
  44. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  45. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +272 -107
  46. package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
  47. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  48. package/dest/contract_function_simulator/pick_notes.js +9 -2
  49. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
  50. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  51. package/dest/contract_function_simulator/proxied_contract_data_source.js +3 -0
  52. package/dest/contract_logging.d.ts +9 -4
  53. package/dest/contract_logging.d.ts.map +1 -1
  54. package/dest/contract_logging.js +21 -6
  55. package/dest/contract_sync/contract_sync_service.d.ts +6 -5
  56. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
  57. package/dest/contract_sync/contract_sync_service.js +44 -37
  58. package/dest/contract_sync/helpers.d.ts +2 -3
  59. package/dest/contract_sync/helpers.d.ts.map +1 -1
  60. package/dest/contract_sync/helpers.js +7 -2
  61. package/dest/debug/pxe_debug_utils.d.ts +3 -3
  62. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  63. package/dest/entrypoints/client/bundle/index.d.ts +1 -2
  64. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  65. package/dest/entrypoints/client/bundle/index.js +0 -1
  66. package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
  67. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  68. package/dest/entrypoints/client/bundle/utils.js +2 -2
  69. package/dest/entrypoints/client/lazy/index.d.ts +1 -2
  70. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  71. package/dest/entrypoints/client/lazy/index.js +0 -1
  72. package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
  73. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  74. package/dest/entrypoints/client/lazy/utils.js +2 -2
  75. package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
  76. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  77. package/dest/entrypoints/pxe_creation_options.js +3 -1
  78. package/dest/entrypoints/server/index.d.ts +2 -3
  79. package/dest/entrypoints/server/index.d.ts.map +1 -1
  80. package/dest/entrypoints/server/index.js +1 -2
  81. package/dest/entrypoints/server/utils.d.ts +2 -2
  82. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  83. package/dest/entrypoints/server/utils.js +2 -2
  84. package/dest/events/event_service.d.ts +3 -2
  85. package/dest/events/event_service.d.ts.map +1 -1
  86. package/dest/events/event_service.js +16 -4
  87. package/dest/logs/log_service.d.ts +5 -8
  88. package/dest/logs/log_service.d.ts.map +1 -1
  89. package/dest/logs/log_service.js +25 -39
  90. package/dest/messages/message_context_service.d.ts +17 -0
  91. package/dest/messages/message_context_service.d.ts.map +1 -0
  92. package/dest/messages/message_context_service.js +36 -0
  93. package/dest/notes/note_service.d.ts +4 -5
  94. package/dest/notes/note_service.d.ts.map +1 -1
  95. package/dest/notes/note_service.js +14 -5
  96. package/dest/notes_filter.d.ts +2 -3
  97. package/dest/notes_filter.d.ts.map +1 -1
  98. package/dest/oracle_version.d.ts +4 -3
  99. package/dest/oracle_version.d.ts.map +1 -1
  100. package/dest/oracle_version.js +20 -10
  101. package/dest/pxe.d.ts +11 -8
  102. package/dest/pxe.d.ts.map +1 -1
  103. package/dest/pxe.js +50 -27
  104. package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
  105. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
  106. package/dest/storage/capsule_store/capsule_service.js +50 -0
  107. package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
  108. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  109. package/dest/storage/capsule_store/capsule_store.js +33 -28
  110. package/dest/storage/capsule_store/index.d.ts +2 -1
  111. package/dest/storage/capsule_store/index.d.ts.map +1 -1
  112. package/dest/storage/capsule_store/index.js +1 -0
  113. package/dest/storage/metadata.d.ts +1 -1
  114. package/dest/storage/metadata.js +1 -1
  115. package/dest/storage/note_store/note_store.d.ts +1 -1
  116. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  117. package/dest/storage/note_store/note_store.js +2 -2
  118. package/dest/storage/private_event_store/stored_private_event.js +1 -1
  119. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  120. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  121. package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
  122. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  123. package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
  124. package/dest/tagging/index.d.ts +3 -3
  125. package/dest/tagging/index.d.ts.map +1 -1
  126. package/dest/tagging/index.js +1 -1
  127. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
  128. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  129. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +3 -3
  130. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
  131. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  132. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
  133. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
  134. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  135. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +13 -7
  136. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
  137. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  138. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +20 -10
  139. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -7
  140. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  141. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -24
  142. package/package.json +16 -16
  143. package/src/bin/check_oracle_version.ts +4 -4
  144. package/src/block_synchronizer/block_synchronizer.ts +6 -0
  145. package/src/config/index.ts +3 -9
  146. package/src/contract_function_simulator/contract_function_simulator.ts +44 -12
  147. package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
  148. package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
  149. package/src/contract_function_simulator/index.ts +1 -0
  150. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +9 -9
  151. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
  152. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
  153. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -10
  154. package/src/contract_function_simulator/oracle/interfaces.ts +82 -54
  155. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
  156. package/src/contract_function_simulator/oracle/oracle.ts +363 -139
  157. package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
  158. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +56 -92
  159. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +444 -143
  160. package/src/contract_function_simulator/pick_notes.ts +9 -2
  161. package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
  162. package/src/contract_logging.ts +18 -5
  163. package/src/contract_sync/contract_sync_service.ts +77 -59
  164. package/src/contract_sync/helpers.ts +4 -4
  165. package/src/debug/pxe_debug_utils.ts +3 -3
  166. package/src/entrypoints/client/bundle/index.ts +0 -1
  167. package/src/entrypoints/client/bundle/utils.ts +2 -3
  168. package/src/entrypoints/client/lazy/index.ts +0 -1
  169. package/src/entrypoints/client/lazy/utils.ts +2 -3
  170. package/src/entrypoints/pxe_creation_options.ts +7 -0
  171. package/src/entrypoints/server/index.ts +1 -2
  172. package/src/entrypoints/server/utils.ts +2 -3
  173. package/src/events/event_service.ts +17 -4
  174. package/src/logs/log_service.ts +53 -75
  175. package/src/messages/message_context_service.ts +44 -0
  176. package/src/notes/note_service.ts +18 -8
  177. package/src/notes_filter.ts +1 -3
  178. package/src/oracle_version.ts +20 -10
  179. package/src/pxe.ts +76 -32
  180. package/src/storage/capsule_store/capsule_service.ts +90 -0
  181. package/src/storage/capsule_store/capsule_store.ts +34 -26
  182. package/src/storage/capsule_store/index.ts +1 -0
  183. package/src/storage/metadata.ts +1 -1
  184. package/src/storage/note_store/note_store.ts +2 -5
  185. package/src/storage/private_event_store/stored_private_event.ts +1 -1
  186. package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
  187. package/src/storage/tagging_store/sender_tagging_store.ts +185 -138
  188. package/src/tagging/index.ts +2 -2
  189. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +3 -6
  190. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
  191. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +23 -10
  192. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
  193. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +27 -26
  194. package/dest/access_scopes.d.ts +0 -9
  195. package/dest/access_scopes.d.ts.map +0 -1
  196. package/dest/access_scopes.js +0 -6
  197. package/src/access_scopes.ts +0 -9
package/src/pxe.ts CHANGED
@@ -52,7 +52,6 @@ import {
52
52
 
53
53
  import { inspect } from 'util';
54
54
 
55
- import type { AccessScopes } from './access_scopes.js';
56
55
  import { BlockSynchronizer } from './block_synchronizer/index.js';
57
56
  import type { PXEConfig } from './config/index.js';
58
57
  import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
@@ -68,6 +67,7 @@ import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
68
67
  import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
69
68
  import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
70
69
  import { JobCoordinator } from './job_coordinator/job_coordinator.js';
70
+ import { MessageContextService } from './messages/message_context_service.js';
71
71
  import {
72
72
  PrivateKernelExecutionProver,
73
73
  type PrivateKernelExecutionProverConfig,
@@ -95,7 +95,7 @@ export type ProfileTxOpts = {
95
95
  /** If true, proof generation is skipped during profiling. Defaults to true. */
96
96
  skipProofGeneration?: boolean;
97
97
  /** Addresses whose private state and keys are accessible during private execution. */
98
- scopes: AccessScopes;
98
+ scopes: AztecAddress[];
99
99
  };
100
100
 
101
101
  /** Options for PXE.simulateTx. */
@@ -106,10 +106,12 @@ export type SimulateTxOpts = {
106
106
  skipTxValidation?: boolean;
107
107
  /** If false, fees are enforced. */
108
108
  skipFeeEnforcement?: boolean;
109
- /** State overrides for the simulation, such as contract instances and artifacts. */
109
+ /** If true, kernel logic is emulated in TS for simulation */
110
+ skipKernels?: boolean;
111
+ /** State overrides for the simulation, such as contract instances and artifacts. Requires skipKernels: true */
110
112
  overrides?: SimulationOverrides;
111
113
  /** Addresses whose private state and keys are accessible during private execution */
112
- scopes: AccessScopes;
114
+ scopes: AztecAddress[];
113
115
  };
114
116
 
115
117
  /** Options for PXE.executeUtility. */
@@ -117,7 +119,7 @@ export type ExecuteUtilityOpts = {
117
119
  /** The authentication witnesses required for the function call. */
118
120
  authwits?: AuthWitness[];
119
121
  /** The accounts whose notes we can access in this call */
120
- scopes: AccessScopes;
122
+ scopes: AztecAddress[];
121
123
  };
122
124
 
123
125
  /** Args for PXE.create. */
@@ -145,6 +147,7 @@ export type PXECreateArgs = {
145
147
  export class PXE {
146
148
  private constructor(
147
149
  private node: AztecNode,
150
+ private db: AztecAsyncKVStore,
148
151
  private blockStateSynchronizer: BlockSynchronizer,
149
152
  private keyStore: KeyStore,
150
153
  private contractStore: ContractStore,
@@ -157,6 +160,7 @@ export class PXE {
157
160
  private addressStore: AddressStore,
158
161
  private privateEventStore: PrivateEventStore,
159
162
  private contractSyncService: ContractSyncService,
163
+ private messageContextService: MessageContextService,
160
164
  private simulator: CircuitSimulator,
161
165
  private proverEnabled: boolean,
162
166
  private proofCreator: PrivateKernelProver,
@@ -212,6 +216,8 @@ export class PXE {
212
216
  noteStore,
213
217
  createLogger('pxe:contract_sync', bindings),
214
218
  );
219
+ const messageContextService = new MessageContextService(node);
220
+
215
221
  const synchronizer = new BlockSynchronizer(
216
222
  node,
217
223
  store,
@@ -240,6 +246,7 @@ export class PXE {
240
246
 
241
247
  const pxe = new PXE(
242
248
  node,
249
+ store,
243
250
  synchronizer,
244
251
  keyStore,
245
252
  contractStore,
@@ -252,6 +259,7 @@ export class PXE {
252
259
  addressStore,
253
260
  privateEventStore,
254
261
  contractSyncService,
262
+ messageContextService,
255
263
  simulator,
256
264
  proverEnabled,
257
265
  proofCreator,
@@ -293,6 +301,7 @@ export class PXE {
293
301
  privateEventStore: this.privateEventStore,
294
302
  simulator: this.simulator,
295
303
  contractSyncService: this.contractSyncService,
304
+ messageContextService: this.messageContextService,
296
305
  });
297
306
  }
298
307
 
@@ -358,7 +367,7 @@ export class PXE {
358
367
  async #executePrivate(
359
368
  contractFunctionSimulator: ContractFunctionSimulator,
360
369
  txRequest: TxExecutionRequest,
361
- scopes: AccessScopes,
370
+ scopes: AztecAddress[],
362
371
  jobId: string,
363
372
  ): Promise<PrivateExecutionResult> {
364
373
  const { origin: contractAddress, functionSelector } = txRequest;
@@ -407,12 +416,19 @@ export class PXE {
407
416
  contractFunctionSimulator: ContractFunctionSimulator,
408
417
  call: FunctionCall,
409
418
  authWitnesses: AuthWitness[] | undefined,
410
- scopes: AccessScopes,
419
+ scopes: AztecAddress[],
411
420
  jobId: string,
412
421
  ) {
413
422
  try {
414
423
  const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
415
- return contractFunctionSimulator.runUtility(call, authWitnesses ?? [], anchorBlockHeader, scopes, jobId);
424
+ const { result, offchainEffects } = await contractFunctionSimulator.runUtility(
425
+ call,
426
+ authWitnesses ?? [],
427
+ anchorBlockHeader,
428
+ scopes,
429
+ jobId,
430
+ );
431
+ return { result, offchainEffects };
416
432
  } catch (err) {
417
433
  if (err instanceof SimulationError) {
418
434
  await enrichSimulationError(err, this.contractStore, this.log);
@@ -485,7 +501,9 @@ export class PXE {
485
501
  * @returns The synced block header
486
502
  */
487
503
  public getSyncedBlockHeader(): Promise<BlockHeader> {
488
- return this.anchorBlockStore.getBlockHeader();
504
+ return this.#putInJobQueue(() => {
505
+ return this.anchorBlockStore.getBlockHeader();
506
+ });
489
507
  }
490
508
 
491
509
  /**
@@ -542,6 +560,12 @@ export class PXE {
542
560
  * TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
543
561
  */
544
562
  public async registerSender(sender: AztecAddress): Promise<AztecAddress> {
563
+ if (!(await sender.isValid())) {
564
+ throw new Error(
565
+ `Address ${sender} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`,
566
+ );
567
+ }
568
+
545
569
  const accounts = await this.keyStore.getAccounts();
546
570
  if (accounts.includes(sender)) {
547
571
  this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
@@ -552,6 +576,9 @@ export class PXE {
552
576
 
553
577
  if (wasAdded) {
554
578
  this.log.info(`Added sender:\n ${sender.toString()}`);
579
+ // Wipe the entire sync cache: the new sender's tagged logs could contain notes/events for any contract, so
580
+ // all contracts must re-sync to discover them.
581
+ this.contractSyncService.wipe();
555
582
  } else {
556
583
  this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
557
584
  }
@@ -764,17 +791,17 @@ export class PXE {
764
791
  // transaction before this one is included in a block from this PXE, and that transaction contains a log with
765
792
  // a tag derived from the same secret, we would reuse the tag and the transactions would be linked. Hence
766
793
  // storing the tags here prevents linkage of txs sent from the same PXE.
767
- const preTagsUsedInTheTx = privateExecutionResult.entrypoint.preTags;
768
- if (preTagsUsedInTheTx.length > 0) {
794
+ const taggingIndexRangesUsedInTheTx = privateExecutionResult.entrypoint.taggingIndexRanges;
795
+ if (taggingIndexRangesUsedInTheTx.length > 0) {
769
796
  // TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
770
797
  const txHash = (await txProvingResult.toTx()).txHash;
771
798
 
772
- await this.senderTaggingStore.storePendingIndexes(preTagsUsedInTheTx, txHash, jobId);
773
- this.log.debug(`Stored used pre-tags as sender for the tx`, {
774
- preTagsUsedInTheTx,
799
+ await this.senderTaggingStore.storePendingIndexes(taggingIndexRangesUsedInTheTx, txHash, jobId);
800
+ this.log.debug(`Stored used tagging index ranges as sender for the tx`, {
801
+ taggingIndexRangesUsedInTheTx,
775
802
  });
776
803
  } else {
777
- this.log.debug(`No pre-tags used in the tx`);
804
+ this.log.debug(`No tagging index ranges used in the tx`);
778
805
  }
779
806
 
780
807
  return txProvingResult;
@@ -881,7 +908,14 @@ export class PXE {
881
908
  */
882
909
  public simulateTx(
883
910
  txRequest: TxExecutionRequest,
884
- { simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes }: SimulateTxOpts,
911
+ {
912
+ simulatePublic,
913
+ skipTxValidation = false,
914
+ skipFeeEnforcement = false,
915
+ skipKernels = true,
916
+ overrides,
917
+ scopes,
918
+ }: SimulateTxOpts,
885
919
  ): Promise<TxSimulationResult> {
886
920
  // We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
887
921
  // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
@@ -905,17 +939,20 @@ export class PXE {
905
939
  await this.blockStateSynchronizer.sync();
906
940
  const syncTime = syncTimer.ms();
907
941
 
908
- const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
909
- // Temporary: in case there are overrides, we have to skip the kernels or validations
910
- // will fail. Consider handing control to the user/wallet on whether they want to run them
911
- // or not.
912
942
  const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
913
943
  const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
914
- const skipKernels = hasOverriddenContracts;
915
944
 
916
- // Set overridden contracts on the sync service so it knows to skip syncing them
945
+ if (hasOverriddenContracts && !skipKernels) {
946
+ throw new Error(
947
+ 'Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.',
948
+ );
949
+ }
950
+ const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
951
+
917
952
  if (hasOverriddenContracts) {
918
- this.contractSyncService.setOverriddenContracts(jobId, overriddenContracts);
953
+ // Overridden contracts don't have a sync function, so calling sync on them would fail.
954
+ // We exclude them so the sync service skips them entirely.
955
+ this.contractSyncService.setExcludedFromSync(jobId, overriddenContracts);
919
956
  }
920
957
 
921
958
  // Execution of private functions only; no proving, and no kernel logic.
@@ -958,7 +995,8 @@ export class PXE {
958
995
  const validationResult = await this.node.isValidTx(simulatedTx, { isSimulation: true, skipFeeEnforcement });
959
996
  validationTime = validationTimer.ms();
960
997
  if (validationResult.result === 'invalid') {
961
- throw new Error('The simulated transaction is unable to be added to state and is invalid.');
998
+ const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
999
+ throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
962
1000
  }
963
1001
  }
964
1002
 
@@ -1009,7 +1047,7 @@ export class PXE {
1009
1047
  inspect(txRequest),
1010
1048
  `simulatePublic=${simulatePublic}`,
1011
1049
  `skipTxValidation=${skipTxValidation}`,
1012
- `scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
1050
+ `scopes=${scopes.map(s => s.toString()).join(', ')}`,
1013
1051
  );
1014
1052
  }
1015
1053
  });
@@ -1021,7 +1059,7 @@ export class PXE {
1021
1059
  */
1022
1060
  public executeUtility(
1023
1061
  call: FunctionCall,
1024
- { authwits, scopes }: ExecuteUtilityOpts = { scopes: 'ALL_SCOPES' },
1062
+ { authwits, scopes }: ExecuteUtilityOpts = { scopes: [] },
1025
1063
  ): Promise<UtilityExecutionResult> {
1026
1064
  // We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
1027
1065
  // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
@@ -1046,7 +1084,7 @@ export class PXE {
1046
1084
  scopes,
1047
1085
  );
1048
1086
 
1049
- const executionResult = await this.#executeUtility(
1087
+ const { result: executionResult, offchainEffects } = await this.#executeUtility(
1050
1088
  contractFunctionSimulator,
1051
1089
  call,
1052
1090
  authwits ?? [],
@@ -1067,14 +1105,19 @@ export class PXE {
1067
1105
  };
1068
1106
 
1069
1107
  const simulationStats = contractFunctionSimulator.getStats();
1070
- return { result: executionResult, stats: { timings, nodeRPCCalls: simulationStats.nodeRPCCalls } };
1108
+ return {
1109
+ result: executionResult,
1110
+ offchainEffects,
1111
+ anchorBlockTimestamp: anchorBlockHeader.globalVariables.timestamp,
1112
+ stats: { timings, nodeRPCCalls: simulationStats.nodeRPCCalls },
1113
+ };
1071
1114
  } catch (err: any) {
1072
1115
  const { to, name, args } = call;
1073
1116
  const stringifiedArgs = args.map(arg => arg.toString()).join(', ');
1074
1117
  throw this.#contextualizeError(
1075
1118
  err,
1076
1119
  `executeUtility ${to}:${name}(${stringifiedArgs})`,
1077
- `scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
1120
+ `scopes=${scopes.map(s => s.toString()).join(', ')}`,
1078
1121
  );
1079
1122
  }
1080
1123
  });
@@ -1129,9 +1172,10 @@ export class PXE {
1129
1172
  }
1130
1173
 
1131
1174
  /**
1132
- * Stops the PXE's job queue.
1175
+ * Stops the PXE's job queue and closes the backing store.
1133
1176
  */
1134
- public stop(): Promise<void> {
1135
- return this.jobQueue.end();
1177
+ public async stop(): Promise<void> {
1178
+ await this.jobQueue.end();
1179
+ await this.db.close();
1136
1180
  }
1137
1181
  }
@@ -0,0 +1,90 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { Capsule } from '@aztec/stdlib/tx';
4
+
5
+ import type { CapsuleStore } from './capsule_store.js';
6
+
7
+ /**
8
+ * Wraps a CapsuleStore with scope-based access control. Each operation asserts that the requested scope is in the
9
+ * allowed scopes list before delegating to the underlying store.
10
+ */
11
+ export class CapsuleService {
12
+ constructor(
13
+ private readonly capsuleStore: CapsuleStore,
14
+ private readonly allowedScopes: AztecAddress[],
15
+ ) {}
16
+
17
+ setCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[], jobId: string, scope: AztecAddress) {
18
+ assertAllowedScope(scope, this.allowedScopes);
19
+ this.capsuleStore.setCapsule(contractAddress, slot, capsule, jobId, scope);
20
+ }
21
+
22
+ async getCapsule(
23
+ contractAddress: AztecAddress,
24
+ slot: Fr,
25
+ jobId: string,
26
+ scope: AztecAddress,
27
+ transientCapsules?: Capsule[],
28
+ ): Promise<Fr[] | null> {
29
+ assertAllowedScope(scope, this.allowedScopes);
30
+
31
+ // TODO(#12425): On the following line, the pertinent capsule gets overshadowed by the transient one. Tackle this.
32
+ const maybeTransientCapsule = transientCapsules?.find(
33
+ c =>
34
+ c.contractAddress.equals(contractAddress) &&
35
+ c.storageSlot.equals(slot) &&
36
+ (c.scope ?? AztecAddress.ZERO).equals(scope),
37
+ )?.data;
38
+
39
+ return maybeTransientCapsule ?? (await this.capsuleStore.getCapsule(contractAddress, slot, jobId, scope));
40
+ }
41
+
42
+ deleteCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string, scope: AztecAddress) {
43
+ assertAllowedScope(scope, this.allowedScopes);
44
+ this.capsuleStore.deleteCapsule(contractAddress, slot, jobId, scope);
45
+ }
46
+
47
+ copyCapsule(
48
+ contractAddress: AztecAddress,
49
+ srcSlot: Fr,
50
+ dstSlot: Fr,
51
+ numEntries: number,
52
+ jobId: string,
53
+ scope: AztecAddress,
54
+ ): Promise<void> {
55
+ assertAllowedScope(scope, this.allowedScopes);
56
+ return this.capsuleStore.copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, jobId, scope);
57
+ }
58
+
59
+ appendToCapsuleArray(
60
+ contractAddress: AztecAddress,
61
+ baseSlot: Fr,
62
+ content: Fr[][],
63
+ jobId: string,
64
+ scope: AztecAddress,
65
+ ): Promise<void> {
66
+ assertAllowedScope(scope, this.allowedScopes);
67
+ return this.capsuleStore.appendToCapsuleArray(contractAddress, baseSlot, content, jobId, scope);
68
+ }
69
+
70
+ readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, jobId: string, scope: AztecAddress): Promise<Fr[][]> {
71
+ assertAllowedScope(scope, this.allowedScopes);
72
+ return this.capsuleStore.readCapsuleArray(contractAddress, baseSlot, jobId, scope);
73
+ }
74
+
75
+ setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string, scope: AztecAddress) {
76
+ assertAllowedScope(scope, this.allowedScopes);
77
+ return this.capsuleStore.setCapsuleArray(contractAddress, baseSlot, content, jobId, scope);
78
+ }
79
+ }
80
+
81
+ function assertAllowedScope(scope: AztecAddress, allowedScopes: AztecAddress[]) {
82
+ if (scope.equals(AztecAddress.ZERO)) {
83
+ return;
84
+ }
85
+ if (!allowedScopes.some((allowed: AztecAddress) => allowed.equals(scope))) {
86
+ throw new Error(
87
+ `Scope ${scope.toString()} is not in the allowed scopes list: [${allowedScopes.map((s: AztecAddress) => s.toString()).join(', ')}]. See https://docs.aztec.network/errors/10`,
88
+ );
89
+ }
90
+ }
@@ -1,7 +1,7 @@
1
1
  import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { type Logger, createLogger } from '@aztec/foundation/log';
3
3
  import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
4
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
5
 
6
6
  import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
7
7
 
@@ -10,11 +10,12 @@ export class CapsuleStore implements StagedStore {
10
10
 
11
11
  #store: AztecAsyncKVStore;
12
12
 
13
- // Arbitrary data stored by contracts. Key is computed as `${contractAddress}:${key}`
13
+ // Arbitrary data stored by contracts. Key is computed as `${contractAddress}:${scope}:${key}`, using the zero
14
+ // address for the global scope.
14
15
  #capsules: AztecAsyncMap<string, Buffer>;
15
16
 
16
- // jobId => `${contractAddress}:${key}` => capsule data
17
- // when `#stagedCapsules.get('some-job-id').get('${some-contract-address:some-key') === null`,
17
+ // jobId => `${contractAddress}:${scope}:${key}` => capsule data
18
+ // when `#stagedCapsules.get('some-job-id').get('${some-contract-address}:${some-scope}:${some-key}') === null`,
18
19
  // it signals that the capsule was deleted during the job, so it needs to be deleted on commit
19
20
  #stagedCapsules: Map<string, Map<string, Buffer | null>>;
20
21
 
@@ -134,8 +135,8 @@ export class CapsuleStore implements StagedStore {
134
135
  * to public contract storage in that it's indexed by the contract address and storage slot but instead of the global
135
136
  * network state it's backed by local PXE db.
136
137
  */
137
- storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[], jobId: string) {
138
- const dbSlotKey = dbSlotToKey(contractAddress, slot);
138
+ setCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[], jobId: string, scope: AztecAddress) {
139
+ const dbSlotKey = dbSlotToKey(contractAddress, slot, scope);
139
140
 
140
141
  // A store overrides any pre-existing data on the slot
141
142
  this.#setOnStage(jobId, dbSlotKey, Buffer.concat(capsule.map(value => value.toBuffer())));
@@ -147,8 +148,8 @@ export class CapsuleStore implements StagedStore {
147
148
  * @param slot - The slot in the database to read.
148
149
  * @returns The stored data or `null` if no data is stored under the slot.
149
150
  */
150
- async loadCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string): Promise<Fr[] | null> {
151
- const dataBuffer = await this.#getFromStage(jobId, dbSlotToKey(contractAddress, slot));
151
+ async getCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string, scope: AztecAddress): Promise<Fr[] | null> {
152
+ const dataBuffer = await this.#getFromStage(jobId, dbSlotToKey(contractAddress, slot, scope));
152
153
  if (!dataBuffer) {
153
154
  this.logger.trace(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
154
155
  return null;
@@ -165,9 +166,9 @@ export class CapsuleStore implements StagedStore {
165
166
  * @param contractAddress - The contract address under which the data is scoped.
166
167
  * @param slot - The slot in the database to delete.
167
168
  */
168
- deleteCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string) {
169
+ deleteCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string, scope: AztecAddress) {
169
170
  // When we commit this, we will interpret null as a deletion, so we'll propagate the delete to the KV store
170
- this.#deleteOnStage(jobId, dbSlotToKey(contractAddress, slot));
171
+ this.#deleteOnStage(jobId, dbSlotToKey(contractAddress, slot, scope));
171
172
  }
172
173
 
173
174
  /**
@@ -187,6 +188,7 @@ export class CapsuleStore implements StagedStore {
187
188
  dstSlot: Fr,
188
189
  numEntries: number,
189
190
  jobId: string,
191
+ scope: AztecAddress,
190
192
  ): Promise<void> {
191
193
  // This transactional context gives us "copy atomicity":
192
194
  // there shouldn't be concurrent writes to what's being copied here.
@@ -203,8 +205,8 @@ export class CapsuleStore implements StagedStore {
203
205
  }
204
206
 
205
207
  for (const i of indexes) {
206
- const currentSrcSlot = dbSlotToKey(contractAddress, srcSlot.add(new Fr(i)));
207
- const currentDstSlot = dbSlotToKey(contractAddress, dstSlot.add(new Fr(i)));
208
+ const currentSrcSlot = dbSlotToKey(contractAddress, srcSlot.add(new Fr(i)), scope);
209
+ const currentDstSlot = dbSlotToKey(contractAddress, dstSlot.add(new Fr(i)), scope);
208
210
 
209
211
  const toCopy = await this.#getFromStage(jobId, currentSrcSlot);
210
212
  if (!toCopy) {
@@ -224,7 +226,13 @@ export class CapsuleStore implements StagedStore {
224
226
  * @param baseSlot - The slot where the array length is stored
225
227
  * @param content - Array of capsule data to append
226
228
  */
227
- appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string): Promise<void> {
229
+ appendToCapsuleArray(
230
+ contractAddress: AztecAddress,
231
+ baseSlot: Fr,
232
+ content: Fr[][],
233
+ jobId: string,
234
+ scope: AztecAddress,
235
+ ): Promise<void> {
228
236
  // We wrap this in a transaction to serialize concurrent calls from Promise.all.
229
237
  // Without this, concurrent appends to the same array could race: both read length=0,
230
238
  // both write at the same slots, one overwrites the other.
@@ -232,22 +240,22 @@ export class CapsuleStore implements StagedStore {
232
240
  // and not using a transaction here would heavily impact performance.
233
241
  return this.#store.transactionAsync(async () => {
234
242
  // Load current length, defaulting to 0 if not found
235
- const lengthData = await this.loadCapsule(contractAddress, baseSlot, jobId);
243
+ const lengthData = await this.getCapsule(contractAddress, baseSlot, jobId, scope);
236
244
  const currentLength = lengthData ? lengthData[0].toNumber() : 0;
237
245
 
238
246
  // Store each capsule at consecutive slots after baseSlot + 1 + currentLength
239
247
  for (let i = 0; i < content.length; i++) {
240
248
  const nextSlot = arraySlot(baseSlot, currentLength + i);
241
- this.storeCapsule(contractAddress, nextSlot, content[i], jobId);
249
+ this.setCapsule(contractAddress, nextSlot, content[i], jobId, scope);
242
250
  }
243
251
 
244
252
  // Update length to include all new capsules
245
253
  const newLength = currentLength + content.length;
246
- this.storeCapsule(contractAddress, baseSlot, [new Fr(newLength)], jobId);
254
+ this.setCapsule(contractAddress, baseSlot, [new Fr(newLength)], jobId, scope);
247
255
  });
248
256
  }
249
257
 
250
- readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, jobId: string): Promise<Fr[][]> {
258
+ readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, jobId: string, scope: AztecAddress): Promise<Fr[][]> {
251
259
  // I'm leaving this transactional context here though because I'm assuming this
252
260
  // gives us "read array atomicity": there shouldn't be concurrent writes to what's being copied
253
261
  // here.
@@ -255,14 +263,14 @@ export class CapsuleStore implements StagedStore {
255
263
  // of jobs: different calls running concurrently on the same contract may cause trouble.
256
264
  return this.#store.transactionAsync(async () => {
257
265
  // Load length, defaulting to 0 if not found
258
- const maybeLength = await this.loadCapsule(contractAddress, baseSlot, jobId);
266
+ const maybeLength = await this.getCapsule(contractAddress, baseSlot, jobId, scope);
259
267
  const length = maybeLength ? maybeLength[0].toBigInt() : 0n;
260
268
 
261
269
  const values: Fr[][] = [];
262
270
 
263
271
  // Read each capsule at consecutive slots after baseSlot
264
272
  for (let i = 0; i < length; i++) {
265
- const currentValue = await this.loadCapsule(contractAddress, arraySlot(baseSlot, i), jobId);
273
+ const currentValue = await this.getCapsule(contractAddress, arraySlot(baseSlot, i), jobId, scope);
266
274
  if (currentValue == undefined) {
267
275
  throw new Error(
268
276
  `Expected non-empty value at capsule array in base slot ${baseSlot} at index ${i} for contract ${contractAddress}`,
@@ -276,7 +284,7 @@ export class CapsuleStore implements StagedStore {
276
284
  });
277
285
  }
278
286
 
279
- setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string) {
287
+ setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string, scope: AztecAddress) {
280
288
  // This transactional context in theory isn't so critical now because we aren't
281
289
  // writing to DB so if there's exceptions midway and it blows up, no visible impact
282
290
  // to persistent storage will happen.
@@ -287,27 +295,27 @@ export class CapsuleStore implements StagedStore {
287
295
  // of jobs: different calls running concurrently on the same contract may cause trouble.
288
296
  return this.#store.transactionAsync(async () => {
289
297
  // Load current length, defaulting to 0 if not found
290
- const maybeLength = await this.loadCapsule(contractAddress, baseSlot, jobId);
298
+ const maybeLength = await this.getCapsule(contractAddress, baseSlot, jobId, scope);
291
299
  const originalLength = maybeLength ? maybeLength[0].toNumber() : 0;
292
300
 
293
301
  // Set the new length
294
- this.storeCapsule(contractAddress, baseSlot, [new Fr(content.length)], jobId);
302
+ this.setCapsule(contractAddress, baseSlot, [new Fr(content.length)], jobId, scope);
295
303
 
296
304
  // Store the new content, possibly overwriting existing values
297
305
  for (let i = 0; i < content.length; i++) {
298
- this.storeCapsule(contractAddress, arraySlot(baseSlot, i), content[i], jobId);
306
+ this.setCapsule(contractAddress, arraySlot(baseSlot, i), content[i], jobId, scope);
299
307
  }
300
308
 
301
309
  // Clear any stragglers
302
310
  for (let i = content.length; i < originalLength; i++) {
303
- this.deleteCapsule(contractAddress, arraySlot(baseSlot, i), jobId);
311
+ this.deleteCapsule(contractAddress, arraySlot(baseSlot, i), jobId, scope);
304
312
  }
305
313
  });
306
314
  }
307
315
  }
308
316
 
309
- function dbSlotToKey(contractAddress: AztecAddress, slot: Fr): string {
310
- return `${contractAddress.toString()}:${slot.toString()}`;
317
+ function dbSlotToKey(contractAddress: AztecAddress, slot: Fr, scope: AztecAddress): string {
318
+ return [contractAddress.toString(), scope.toString(), slot.toString()].join(':');
311
319
  }
312
320
 
313
321
  function arraySlot(baseSlot: Fr, index: number) {
@@ -1 +1,2 @@
1
+ export { CapsuleService } from './capsule_service.js';
1
2
  export { CapsuleStore } from './capsule_store.js';
@@ -1 +1 @@
1
- export const PXE_DATA_SCHEMA_VERSION = 3;
1
+ export const PXE_DATA_SCHEMA_VERSION = 5;
@@ -106,7 +106,7 @@ export class NoteStore implements StagedStore {
106
106
  * returned once if this is the case)
107
107
  */
108
108
  getNotes(filter: NotesFilter, jobId: string): Promise<NoteDao[]> {
109
- if (filter.scopes !== 'ALL_SCOPES' && filter.scopes.length === 0) {
109
+ if (filter.scopes.length === 0) {
110
110
  return Promise.resolve([]);
111
111
  }
112
112
 
@@ -180,10 +180,7 @@ export class NoteStore implements StagedStore {
180
180
  continue;
181
181
  }
182
182
 
183
- if (
184
- filter.scopes !== 'ALL_SCOPES' &&
185
- note.scopes.intersection(new Set(filter.scopes.map(s => s.toString()))).size === 0
186
- ) {
183
+ if (note.scopes.intersection(new Set(filter.scopes.map(s => s.toString()))).size === 0) {
187
184
  continue;
188
185
  }
189
186
 
@@ -49,7 +49,7 @@ export class StoredPrivateEvent {
49
49
  const msgContentLength = reader.readNumber();
50
50
  const msgContent = reader.readArray(msgContentLength, Fr);
51
51
  const l2BlockNumber = reader.readNumber();
52
- const l2BlockHash = new BlockHash(Fr.fromBuffer(reader));
52
+ const l2BlockHash = BlockHash.fromBuffer(reader);
53
53
  const txHash = TxHash.fromBuffer(reader);
54
54
  const txIndexInBlock = reader.readNumber();
55
55
  const eventIndexInTx = reader.readNumber();
@@ -1,5 +1,5 @@
1
1
  import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
2
- import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
2
+ import type { ExtendedDirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
3
3
 
4
4
  import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
5
5
 
@@ -106,11 +106,11 @@ export class RecipientTaggingStore implements StagedStore {
106
106
  return Promise.resolve();
107
107
  }
108
108
 
109
- getHighestAgedIndex(secret: DirectionalAppTaggingSecret, jobId: string): Promise<number | undefined> {
109
+ getHighestAgedIndex(secret: ExtendedDirectionalAppTaggingSecret, jobId: string): Promise<number | undefined> {
110
110
  return this.#store.transactionAsync(() => this.#readHighestAgedIndex(jobId, secret.toString()));
111
111
  }
112
112
 
113
- updateHighestAgedIndex(secret: DirectionalAppTaggingSecret, index: number, jobId: string): Promise<void> {
113
+ updateHighestAgedIndex(secret: ExtendedDirectionalAppTaggingSecret, index: number, jobId: string): Promise<void> {
114
114
  return this.#store.transactionAsync(async () => {
115
115
  const currentIndex = await this.#readHighestAgedIndex(jobId, secret.toString());
116
116
  if (currentIndex !== undefined && index <= currentIndex) {
@@ -121,11 +121,15 @@ export class RecipientTaggingStore implements StagedStore {
121
121
  });
122
122
  }
123
123
 
124
- getHighestFinalizedIndex(secret: DirectionalAppTaggingSecret, jobId: string): Promise<number | undefined> {
124
+ getHighestFinalizedIndex(secret: ExtendedDirectionalAppTaggingSecret, jobId: string): Promise<number | undefined> {
125
125
  return this.#store.transactionAsync(() => this.#readHighestFinalizedIndex(jobId, secret.toString()));
126
126
  }
127
127
 
128
- updateHighestFinalizedIndex(secret: DirectionalAppTaggingSecret, index: number, jobId: string): Promise<void> {
128
+ updateHighestFinalizedIndex(
129
+ secret: ExtendedDirectionalAppTaggingSecret,
130
+ index: number,
131
+ jobId: string,
132
+ ): Promise<void> {
129
133
  return this.#store.transactionAsync(async () => {
130
134
  const currentIndex = await this.#readHighestFinalizedIndex(jobId, secret.toString());
131
135
  if (currentIndex !== undefined && index < currentIndex) {