@aztec/pxe 3.0.0-nightly.20251214 → 3.0.0-nightly.20251217

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 (121) hide show
  1. package/dest/block_synchronizer/block_synchronizer.d.ts +39 -0
  2. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
  3. package/dest/{synchronizer/synchronizer.js → block_synchronizer/block_synchronizer.js} +22 -17
  4. package/dest/block_synchronizer/index.d.ts +2 -0
  5. package/dest/block_synchronizer/index.d.ts.map +1 -0
  6. package/dest/block_synchronizer/index.js +1 -0
  7. package/dest/config/index.d.ts +4 -4
  8. package/dest/config/index.d.ts.map +1 -1
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts +6 -4
  10. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  11. package/dest/contract_function_simulator/contract_function_simulator.js +7 -6
  12. package/dest/contract_function_simulator/execution_data_provider.d.ts +6 -26
  13. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -1
  14. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +1 -1
  15. package/dest/contract_function_simulator/execution_tagging_index_cache.js +1 -1
  16. package/dest/contract_function_simulator/oracle/interfaces.d.ts +2 -2
  17. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  18. package/dest/contract_function_simulator/oracle/oracle.d.ts +1 -1
  19. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  20. package/dest/contract_function_simulator/oracle/oracle.js +3 -3
  21. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -2
  22. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  23. package/dest/contract_function_simulator/oracle/private_execution.js +0 -1
  24. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +2 -3
  25. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  26. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +8 -4
  27. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +4 -3
  28. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  29. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +8 -7
  30. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +9 -20
  31. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -1
  32. package/dest/contract_function_simulator/pxe_oracle_interface.js +41 -106
  33. package/dest/debug/pxe_debug_utils.d.ts +30 -0
  34. package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
  35. package/dest/debug/pxe_debug_utils.js +37 -0
  36. package/dest/events/private_event_filter_validator.d.ts +4 -4
  37. package/dest/events/private_event_filter_validator.d.ts.map +1 -1
  38. package/dest/events/private_event_filter_validator.js +4 -4
  39. package/dest/pxe.d.ts +19 -28
  40. package/dest/pxe.d.ts.map +1 -1
  41. package/dest/pxe.js +70 -86
  42. package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts +9 -0
  43. package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts.map +1 -0
  44. package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_data_provider/anchor_block_data_provider.js} +2 -9
  45. package/dest/storage/anchor_block_data_provider/index.d.ts +2 -0
  46. package/dest/storage/anchor_block_data_provider/index.d.ts.map +1 -0
  47. package/dest/storage/anchor_block_data_provider/index.js +1 -0
  48. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +3 -2
  49. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
  50. package/dest/storage/contract_data_provider/contract_data_provider.js +21 -1
  51. package/dest/storage/index.d.ts +2 -2
  52. package/dest/storage/index.d.ts.map +1 -1
  53. package/dest/storage/index.js +1 -1
  54. package/dest/storage/tagging_data_provider/index.d.ts +3 -2
  55. package/dest/storage/tagging_data_provider/index.d.ts.map +1 -1
  56. package/dest/storage/tagging_data_provider/index.js +2 -1
  57. package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts +31 -0
  58. package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts.map +1 -0
  59. package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.js +65 -0
  60. package/dest/storage/tagging_data_provider/sender_tagging_data_provider.d.ts +67 -0
  61. package/dest/storage/tagging_data_provider/sender_tagging_data_provider.d.ts.map +1 -0
  62. package/dest/storage/tagging_data_provider/sender_tagging_data_provider.js +196 -0
  63. package/dest/tagging/constants.d.ts +1 -1
  64. package/dest/tagging/constants.d.ts.map +1 -1
  65. package/dest/tagging/constants.js +1 -0
  66. package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts +21 -0
  67. package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts.map +1 -0
  68. package/dest/tagging/sync/sync_sender_tagging_indexes.js +89 -0
  69. package/dest/tagging/sync/utils/get_status_change_of_pending.d.ts +11 -0
  70. package/dest/tagging/sync/utils/get_status_change_of_pending.d.ts.map +1 -0
  71. package/dest/tagging/sync/utils/get_status_change_of_pending.js +32 -0
  72. package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts +18 -0
  73. package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
  74. package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.js +57 -0
  75. package/dest/tagging/utils.d.ts +2 -2
  76. package/dest/tagging/utils.d.ts.map +1 -1
  77. package/dest/tagging/utils.js +3 -2
  78. package/package.json +16 -16
  79. package/src/{synchronizer/synchronizer.ts → block_synchronizer/block_synchronizer.ts} +21 -17
  80. package/src/block_synchronizer/index.ts +1 -0
  81. package/src/config/index.ts +3 -3
  82. package/src/contract_function_simulator/contract_function_simulator.ts +21 -5
  83. package/src/contract_function_simulator/execution_data_provider.ts +7 -28
  84. package/src/contract_function_simulator/execution_tagging_index_cache.ts +1 -1
  85. package/src/contract_function_simulator/oracle/interfaces.ts +1 -1
  86. package/src/contract_function_simulator/oracle/oracle.ts +3 -3
  87. package/src/contract_function_simulator/oracle/private_execution.ts +1 -3
  88. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +11 -5
  89. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +6 -6
  90. package/src/contract_function_simulator/pxe_oracle_interface.ts +41 -114
  91. package/src/debug/pxe_debug_utils.ts +47 -0
  92. package/src/events/private_event_filter_validator.ts +3 -3
  93. package/src/pxe.ts +74 -96
  94. package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_data_provider/anchor_block_data_provider.ts} +2 -12
  95. package/src/storage/anchor_block_data_provider/index.ts +1 -0
  96. package/src/storage/contract_data_provider/contract_data_provider.ts +27 -0
  97. package/src/storage/index.ts +1 -1
  98. package/src/storage/tagging_data_provider/index.ts +2 -1
  99. package/src/storage/tagging_data_provider/recipient_tagging_data_provider.ts +86 -0
  100. package/src/storage/tagging_data_provider/sender_tagging_data_provider.ts +244 -0
  101. package/src/tagging/constants.ts +1 -0
  102. package/src/tagging/sync/sync_sender_tagging_indexes.ts +112 -0
  103. package/src/tagging/sync/utils/get_status_change_of_pending.ts +44 -0
  104. package/src/tagging/sync/utils/load_and_store_new_tagging_indexes.ts +74 -0
  105. package/src/tagging/utils.ts +3 -2
  106. package/dest/storage/sync_data_provider/index.d.ts +0 -2
  107. package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
  108. package/dest/storage/sync_data_provider/index.js +0 -1
  109. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +0 -11
  110. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
  111. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -40
  112. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
  113. package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -89
  114. package/dest/synchronizer/index.d.ts +0 -2
  115. package/dest/synchronizer/index.d.ts.map +0 -1
  116. package/dest/synchronizer/index.js +0 -1
  117. package/dest/synchronizer/synchronizer.d.ts +0 -36
  118. package/dest/synchronizer/synchronizer.d.ts.map +0 -1
  119. package/src/storage/sync_data_provider/index.ts +0 -1
  120. package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -120
  121. package/src/synchronizer/index.ts +0 -1
@@ -1,5 +1,4 @@
1
1
  import type { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
2
- import { timesParallel } from '@aztec/foundation/collection';
3
2
  import { Fr } from '@aztec/foundation/curves/bn254';
4
3
  import { Point } from '@aztec/foundation/curves/grumpkin';
5
4
  import { createLogger } from '@aztec/foundation/log';
@@ -24,19 +23,19 @@ import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
24
23
  import { Note, type NoteStatus } from '@aztec/stdlib/note';
25
24
  import { NoteDao } from '@aztec/stdlib/note';
26
25
  import { MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
27
- import type { BlockHeader } from '@aztec/stdlib/tx';
28
26
  import { TxHash } from '@aztec/stdlib/tx';
29
27
 
30
28
  import type { ExecutionDataProvider, ExecutionStats } from '../contract_function_simulator/execution_data_provider.js';
31
29
  import { MessageLoadOracleInputs } from '../contract_function_simulator/oracle/message_load_oracle_inputs.js';
32
30
  import { ORACLE_VERSION } from '../oracle_version.js';
33
31
  import type { AddressDataProvider } from '../storage/address_data_provider/address_data_provider.js';
32
+ import type { AnchorBlockDataProvider } from '../storage/anchor_block_data_provider/anchor_block_data_provider.js';
34
33
  import type { CapsuleDataProvider } from '../storage/capsule_data_provider/capsule_data_provider.js';
35
34
  import type { ContractDataProvider } from '../storage/contract_data_provider/contract_data_provider.js';
36
35
  import type { NoteDataProvider } from '../storage/note_data_provider/note_data_provider.js';
37
36
  import type { PrivateEventDataProvider } from '../storage/private_event_data_provider/private_event_data_provider.js';
38
- import type { SyncDataProvider } from '../storage/sync_data_provider/sync_data_provider.js';
39
- import type { TaggingDataProvider } from '../storage/tagging_data_provider/tagging_data_provider.js';
37
+ import type { RecipientTaggingDataProvider } from '../storage/tagging_data_provider/recipient_tagging_data_provider.js';
38
+ import type { SenderTaggingDataProvider } from '../storage/tagging_data_provider/sender_tagging_data_provider.js';
40
39
  import {
41
40
  DirectionalAppTaggingSecret,
42
41
  SiloedTag,
@@ -55,14 +54,19 @@ import type { ProxiedNode } from './proxied_node.js';
55
54
  * A data layer that provides and stores information needed for simulating/proving a transaction.
56
55
  */
57
56
  export class PXEOracleInterface implements ExecutionDataProvider {
57
+ // Note: The Aztec node and senderDataProvider are exposed publicly since PXEOracleInterface will be deprecated soon
58
+ // (issue #17776). When refactoring tagging, it made sense to align with this future change by moving the sender
59
+ // tagging index sync functionality elsewhere. This required exposing these two properties since there is currently
60
+ // no alternative way to access them in the PrivateExecutionOracle.
58
61
  constructor(
59
- private aztecNode: AztecNode | ProxiedNode,
62
+ public readonly aztecNode: AztecNode | ProxiedNode,
60
63
  private keyStore: KeyStore,
61
64
  private contractDataProvider: ContractDataProvider,
62
65
  private noteDataProvider: NoteDataProvider,
63
66
  private capsuleDataProvider: CapsuleDataProvider,
64
- private syncDataProvider: SyncDataProvider,
65
- private taggingDataProvider: TaggingDataProvider,
67
+ private anchorBlockDataProvider: AnchorBlockDataProvider,
68
+ public readonly senderTaggingDataProvider: SenderTaggingDataProvider,
69
+ private recipientTaggingDataProvider: RecipientTaggingDataProvider,
66
70
  private addressDataProvider: AddressDataProvider,
67
71
  private privateEventDataProvider: PrivateEventDataProvider,
68
72
  private log = createLogger('pxe:pxe_oracle_interface'),
@@ -197,7 +201,7 @@ export class PXEOracleInterface implements ExecutionDataProvider {
197
201
  }
198
202
 
199
203
  public async getNullifierMembershipWitnessAtLatestBlock(nullifier: Fr) {
200
- const blockNumber = (await this.getAnchorBlockHeader()).globalVariables.blockNumber;
204
+ const blockNumber = (await this.anchorBlockDataProvider.getBlockHeader()).getBlockNumber();
201
205
  return this.getNullifierMembershipWitness(blockNumber, nullifier);
202
206
  }
203
207
 
@@ -212,41 +216,37 @@ export class PXEOracleInterface implements ExecutionDataProvider {
212
216
  blockNumber: BlockParameter,
213
217
  nullifier: Fr,
214
218
  ): Promise<NullifierMembershipWitness | undefined> {
215
- const header = await this.getAnchorBlockHeader();
216
- if (blockNumber !== 'latest' && blockNumber > header.globalVariables.blockNumber) {
217
- throw new Error(`Block number ${blockNumber} is higher than current block ${header.globalVariables.blockNumber}`);
219
+ const anchorBlockNumber = (await this.anchorBlockDataProvider.getBlockHeader()).getBlockNumber();
220
+ if (blockNumber !== 'latest' && blockNumber > anchorBlockNumber) {
221
+ throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
218
222
  }
219
223
  return this.aztecNode.getLowNullifierMembershipWitness(blockNumber, nullifier);
220
224
  }
221
225
 
222
226
  public async getBlock(blockNumber: BlockParameter): Promise<L2Block | undefined> {
223
- const header = await this.getAnchorBlockHeader();
224
- if (blockNumber !== 'latest' && blockNumber > header.globalVariables.blockNumber) {
225
- throw new Error(`Block number ${blockNumber} is higher than current block ${header.globalVariables.blockNumber}`);
227
+ const anchorBlockNumber = (await this.anchorBlockDataProvider.getBlockHeader()).getBlockNumber();
228
+ if (blockNumber !== 'latest' && blockNumber > anchorBlockNumber) {
229
+ throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
226
230
  }
227
231
  return await this.aztecNode.getBlock(blockNumber);
228
232
  }
229
233
 
230
234
  public async getPublicDataWitness(blockNumber: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
231
- const header = await this.getAnchorBlockHeader();
232
- if (blockNumber !== 'latest' && blockNumber > header.globalVariables.blockNumber) {
233
- throw new Error(`Block number ${blockNumber} is higher than current block ${header.globalVariables.blockNumber}`);
235
+ const anchorBlockNumber = (await this.anchorBlockDataProvider.getBlockHeader()).getBlockNumber();
236
+ if (blockNumber !== 'latest' && blockNumber > anchorBlockNumber) {
237
+ throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
234
238
  }
235
239
  return await this.aztecNode.getPublicDataWitness(blockNumber, leafSlot);
236
240
  }
237
241
 
238
242
  public async getPublicStorageAt(blockNumber: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
239
- const header = await this.getAnchorBlockHeader();
240
- if (blockNumber !== 'latest' && blockNumber > header.globalVariables.blockNumber) {
241
- throw new Error(`Block number ${blockNumber} is higher than current block ${header.globalVariables.blockNumber}`);
243
+ const anchorBlockNumber = (await this.anchorBlockDataProvider.getBlockHeader()).getBlockNumber();
244
+ if (blockNumber !== 'latest' && blockNumber > anchorBlockNumber) {
245
+ throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
242
246
  }
243
247
  return await this.aztecNode.getPublicStorageAt(blockNumber, contract, slot);
244
248
  }
245
249
 
246
- getAnchorBlockHeader(): Promise<BlockHeader> {
247
- return this.syncDataProvider.getBlockHeader();
248
- }
249
-
250
250
  public assertCompatibleOracleVersion(version: number): void {
251
251
  if (version !== ORACLE_VERSION) {
252
252
  throw new Error(`Incompatible oracle version. Expected version ${ORACLE_VERSION}, got ${version}.`);
@@ -264,11 +264,7 @@ export class PXEOracleInterface implements ExecutionDataProvider {
264
264
  * @returns The full list of the users contact addresses.
265
265
  */
266
266
  public getSenders(): Promise<AztecAddress[]> {
267
- return this.taggingDataProvider.getSenderAddresses();
268
- }
269
-
270
- public getLastUsedIndexAsSender(secret: DirectionalAppTaggingSecret): Promise<number | undefined> {
271
- return this.taggingDataProvider.getLastUsedIndexesAsSender(secret);
267
+ return this.recipientTaggingDataProvider.getSenderAddresses();
272
268
  }
273
269
 
274
270
  public async calculateDirectionalAppTaggingSecret(
@@ -297,8 +293,8 @@ export class PXEOracleInterface implements ExecutionDataProvider {
297
293
  * @param recipient - The address receiving the notes
298
294
  * @returns A list of directional app tagging secrets along with the last used tagging indexes. If the corresponding
299
295
  * secret was never used, the index is undefined.
300
- * TODO(benesjan): The naming here is broken as the function name does not reflect the return type. Fix when associating
301
- * indexes with tx hash.
296
+ * TODO(#17775): The naming here is broken as the function name does not reflect the return type. Make sure this gets
297
+ * fixed when implementing the linked issue.
302
298
  */
303
299
  async #getLastUsedTaggingIndexesForSenders(
304
300
  contractAddress: AztecAddress,
@@ -310,7 +306,7 @@ export class PXEOracleInterface implements ExecutionDataProvider {
310
306
  // We implicitly add all PXE accounts as senders, this helps us decrypt tags on notes that we send to ourselves
311
307
  // (recipient = us, sender = us)
312
308
  const senders = [
313
- ...(await this.taggingDataProvider.getSenderAddresses()),
309
+ ...(await this.recipientTaggingDataProvider.getSenderAddresses()),
314
310
  ...(await this.keyStore.getAccounts()),
315
311
  ].filter((address, index, self) => index === self.findIndex(otherAddress => otherAddress.equals(address)));
316
312
  const secrets = await Promise.all(
@@ -324,7 +320,7 @@ export class PXEOracleInterface implements ExecutionDataProvider {
324
320
  );
325
321
  }),
326
322
  );
327
- const indexes = await this.taggingDataProvider.getLastUsedIndexesAsRecipient(secrets);
323
+ const indexes = await this.recipientTaggingDataProvider.getLastUsedIndexes(secrets);
328
324
  if (indexes.length !== secrets.length) {
329
325
  throw new Error('Indexes and directional app tagging secrets have different lengths');
330
326
  }
@@ -335,80 +331,9 @@ export class PXEOracleInterface implements ExecutionDataProvider {
335
331
  }));
336
332
  }
337
333
 
338
- public async syncTaggedLogsAsSender(
339
- secret: DirectionalAppTaggingSecret,
340
- contractAddress: AztecAddress,
341
- ): Promise<void> {
342
- const lastUsedIndex = await this.taggingDataProvider.getLastUsedIndexesAsSender(secret);
343
- // If lastUsedIndex is undefined, we've never used this secret, so start from 0
344
- // Otherwise, start from one past the last used index
345
- const startIndex = lastUsedIndex === undefined ? 0 : lastUsedIndex + 1;
346
-
347
- // This algorithm works such that:
348
- // 1. If we find minimum consecutive empty logs in a window of logs we set the index to the index of the last log
349
- // we found and quit.
350
- // 2. If we don't find minimum consecutive empty logs in a window of logs we slide the window to latest log index
351
- // and repeat the process.
352
- const MIN_CONSECUTIVE_EMPTY_LOGS = 10;
353
- const WINDOW_SIZE = MIN_CONSECUTIVE_EMPTY_LOGS * 2;
354
-
355
- let [numConsecutiveEmptyLogs, currentIndex] = [0, startIndex];
356
- let lastFoundLogIndex: number | undefined = undefined;
357
- do {
358
- // We compute the tags for the current window of indexes
359
- const currentTags = await timesParallel(WINDOW_SIZE, async i => {
360
- return SiloedTag.compute(await Tag.compute({ secret, index: currentIndex + i }), contractAddress);
361
- });
362
-
363
- // We fetch the logs for the tags
364
- // TODO: The following conversion is unfortunate and we should most likely just type the #getPrivateLogsByTags
365
- // to accept SiloedTag[] instead of Fr[]. That would result in a large change so I didn't do it yet.
366
- const tagsAsFr = currentTags.map(tag => tag.value);
367
- const possibleLogs = await this.#getPrivateLogsByTags(tagsAsFr);
368
-
369
- // We find the index of the last log in the window that is not empty
370
- const indexOfLastLogWithinArray = possibleLogs.findLastIndex(possibleLog => possibleLog.length !== 0);
371
-
372
- if (indexOfLastLogWithinArray === -1) {
373
- // We haven't found any logs in the current window so we stop looking
374
- break;
375
- }
376
-
377
- // We've found logs so we update the last found log index
378
- lastFoundLogIndex = (lastFoundLogIndex ?? 0) + indexOfLastLogWithinArray;
379
- // We move the current index to that of the log right after the last found log
380
- currentIndex = lastFoundLogIndex + 1;
381
-
382
- // We compute the number of consecutive empty logs we found and repeat the process if we haven't found enough.
383
- numConsecutiveEmptyLogs = WINDOW_SIZE - indexOfLastLogWithinArray - 1;
384
- } while (numConsecutiveEmptyLogs < MIN_CONSECUTIVE_EMPTY_LOGS);
385
-
386
- const contractName = await this.contractDataProvider.getDebugContractName(contractAddress);
387
- if (lastFoundLogIndex !== undefined) {
388
- // Last found index is defined meaning we have actually found logs so we update the last used index
389
- await this.taggingDataProvider.setLastUsedIndexesAsSender([{ secret, index: lastFoundLogIndex }]);
390
-
391
- this.log.debug(`Syncing logs for secret ${secret.toString()} at contract ${contractName}(${contractAddress})`, {
392
- index: currentIndex,
393
- contractName,
394
- contractAddress,
395
- });
396
- } else {
397
- this.log.debug(
398
- `No new logs found for secret ${secret.toString()} at contract ${contractName}(${contractAddress})`,
399
- );
400
- }
401
- }
402
-
403
- /**
404
- * Synchronizes the private logs tagged with scoped addresses and all the senders in the address book. Stores the found
405
- * logs in CapsuleArray ready for a later retrieval in Aztec.nr.
406
- * @param contractAddress - The address of the contract that the logs are tagged for.
407
- * @param pendingTaggedLogArrayBaseSlot - The base slot of the pending tagged logs capsule array in which
408
- * found logs will be stored.
409
- * @param scopes - The scoped addresses to sync logs for. If not provided, all accounts in the address book will be
410
- * synced.
411
- */
334
+ // TODO(#17775): Replace this implementation of this function with one implementing an approach similar
335
+ // to syncSenderTaggingIndexes. Not done yet due to re-prioritization to devex and this doesn't directly affect
336
+ // devex.
412
337
  public async syncTaggedLogs(
413
338
  contractAddress: AztecAddress,
414
339
  pendingTaggedLogArrayBaseSlot: Fr,
@@ -416,7 +341,7 @@ export class PXEOracleInterface implements ExecutionDataProvider {
416
341
  ) {
417
342
  this.log.verbose('Searching for tagged logs', { contract: contractAddress });
418
343
 
419
- const maxBlockNumber = await this.syncDataProvider.getBlockNumber();
344
+ const maxBlockNumber = (await this.anchorBlockDataProvider.getBlockHeader()).getBlockNumber();
420
345
 
421
346
  // Ideally this algorithm would be implemented in noir, exposing its building blocks as oracles.
422
347
  // However it is impossible at the moment due to the language not supporting nested slices.
@@ -498,7 +423,7 @@ export class PXEOracleInterface implements ExecutionDataProvider {
498
423
  filteredLogsByBlockNumber,
499
424
  );
500
425
 
501
- // We retrieve the pre tag corresponding to the log as I need that to evaluate whether
426
+ // We retrieve the pre-tag corresponding to the log as I need that to evaluate whether
502
427
  // a new largest index have been found.
503
428
  const preTagCorrespondingToLog = preTagsForTheWholeWindow[logIndex];
504
429
  const initialIndex = initialIndexesMap[preTagCorrespondingToLog.secret.toString()];
@@ -555,7 +480,7 @@ export class PXEOracleInterface implements ExecutionDataProvider {
555
480
  // At this point we have processed all the logs for the recipient so we store the last used indexes in the db.
556
481
  // newLargestIndexMapToStore contains "next" indexes to look for (one past the last found), so subtract 1 to get
557
482
  // last used.
558
- await this.taggingDataProvider.setLastUsedIndexesAsRecipient(
483
+ await this.recipientTaggingDataProvider.setLastUsedIndexes(
559
484
  Object.entries(newLargestIndexMapToStore).map(([directionalAppTaggingSecret, index]) => ({
560
485
  secret: DirectionalAppTaggingSecret.fromString(directionalAppTaggingSecret),
561
486
  index: index - 1,
@@ -673,7 +598,7 @@ export class PXEOracleInterface implements ExecutionDataProvider {
673
598
  // number which *should* be recent enough to be available, even for non-archive nodes.
674
599
  // Also note that the note should never be ahead of the synced block here since `fetchTaggedLogs` only processes
675
600
  // logs up to the synced block making this only an additional safety check.
676
- const syncedBlockNumber = await this.syncDataProvider.getBlockNumber();
601
+ const syncedBlockNumber = (await this.anchorBlockDataProvider.getBlockHeader()).getBlockNumber();
677
602
 
678
603
  // By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
679
604
  // of other contracts, which would constitute a security breach.
@@ -814,12 +739,14 @@ export class PXEOracleInterface implements ExecutionDataProvider {
814
739
  // (and thus we're less concerned about being ahead of the synced block), we use the synced block number to
815
740
  // maintain consistent behavior in the PXE. Additionally, events should never be ahead of the synced block here
816
741
  // since `fetchTaggedLogs` only processes logs up to the synced block.
817
- const [syncedBlockNumber, siloedEventCommitment, txEffect] = await Promise.all([
818
- this.syncDataProvider.getBlockNumber(),
742
+ const [syncedBlockHeader, siloedEventCommitment, txEffect] = await Promise.all([
743
+ this.anchorBlockDataProvider.getBlockHeader(),
819
744
  siloNullifier(contractAddress, eventCommitment),
820
745
  this.aztecNode.getTxEffect(txHash),
821
746
  ]);
822
747
 
748
+ const syncedBlockNumber = syncedBlockHeader.getBlockNumber();
749
+
823
750
  if (!txEffect) {
824
751
  throw new Error(`Could not find tx effect for tx hash ${txHash}`);
825
752
  }
@@ -942,7 +869,7 @@ export class PXEOracleInterface implements ExecutionDataProvider {
942
869
  public async syncNoteNullifiers(contractAddress: AztecAddress) {
943
870
  this.log.verbose('Searching for nullifiers of known notes', { contract: contractAddress });
944
871
 
945
- const syncedBlockNumber = await this.syncDataProvider.getBlockNumber();
872
+ const syncedBlockNumber = (await this.anchorBlockDataProvider.getBlockHeader()).getBlockNumber();
946
873
 
947
874
  const contractNotes = await this.noteDataProvider.getNotes({ contractAddress });
948
875
 
@@ -0,0 +1,47 @@
1
+ import type { NoteDao, NotesFilter } from '@aztec/stdlib/note';
2
+
3
+ import type { PXE } from '../pxe.js';
4
+ import type { ContractDataProvider, NoteDataProvider } from '../storage/index.js';
5
+
6
+ /**
7
+ * Methods provided by this class might help debugging but must not be used in production.
8
+ * No backwards compatibility or API stability should be expected. Use at your own risk.
9
+ */
10
+ export class PXEDebugUtils {
11
+ #pxe: PXE | undefined = undefined;
12
+
13
+ constructor(
14
+ private contractDataProvider: ContractDataProvider,
15
+ private noteDataProvider: NoteDataProvider,
16
+ ) {}
17
+
18
+ /**
19
+ * Not injected through constructor since they're are co-dependant.
20
+ */
21
+ public setPXE(pxe: PXE) {
22
+ this.#pxe = pxe;
23
+ }
24
+
25
+ /**
26
+ * A debugging utility to get notes based on the provided filter.
27
+ *
28
+ * Note that this should not be used in production code because the structure of notes is considered to be
29
+ * an implementation detail of contracts. This is only meant to be used for debugging purposes. If you need to obtain
30
+ * note-related information in production code, please implement a custom utility function on your contract and call
31
+ * that function instead (e.g. `get_balance(owner: AztecAddress) -> u128` utility function on a Token contract).
32
+ *
33
+ * @param filter - The filter to apply to the notes.
34
+ * @returns The requested notes.
35
+ */
36
+ public async getNotes(filter: NotesFilter): Promise<NoteDao[]> {
37
+ if (!this.#pxe) {
38
+ throw new Error('Cannot getNotes because no PXE is set');
39
+ }
40
+
41
+ // We need to manually trigger private state sync to have a guarantee that all the notes are available.
42
+ const call = await this.contractDataProvider.getFunctionCall('sync_private_state', [], filter.contractAddress);
43
+ await this.#pxe.simulateUtility(call);
44
+
45
+ return this.noteDataProvider.getNotes(filter);
46
+ }
47
+ }
@@ -2,10 +2,10 @@ import type { PrivateEventFilter } from '@aztec/aztec.js/wallet';
2
2
  import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
3
3
  import { BlockNumber } from '@aztec/foundation/branded-types';
4
4
 
5
- import type { PrivateEventDataProviderFilter, SyncDataProvider } from '../storage/index.js';
5
+ import type { AnchorBlockDataProvider, PrivateEventDataProviderFilter } from '../storage/index.js';
6
6
 
7
7
  export class PrivateEventFilterValidator {
8
- constructor(private syncDataProvider: SyncDataProvider) {}
8
+ constructor(private anchorBlockDataProvider: AnchorBlockDataProvider) {}
9
9
 
10
10
  async validate(filter: PrivateEventFilter): Promise<PrivateEventDataProviderFilter> {
11
11
  let { fromBlock, toBlock } = filter;
@@ -15,7 +15,7 @@ export class PrivateEventFilterValidator {
15
15
  // We then default to [INITIAL_L2_BLOCK_NUM, latestKnownBlock + 1), ie: by default return events from
16
16
  // the first block to the latest known block.
17
17
  if (!fromBlock || !toBlock) {
18
- const lastKnownBlock = await this.syncDataProvider.getBlockNumber();
18
+ const lastKnownBlock = (await this.anchorBlockDataProvider.getBlockHeader()).getBlockNumber();
19
19
  fromBlock = fromBlock ?? BlockNumber(INITIAL_L2_BLOCK_NUM);
20
20
  toBlock = toBlock ?? BlockNumber(lastKnownBlock + 1);
21
21
  }