@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
package/dest/pxe.js CHANGED
@@ -5,41 +5,44 @@ import { Timer } from '@aztec/foundation/timer';
5
5
  import { KeyStore } from '@aztec/key-store';
6
6
  import { L2TipsKVStore } from '@aztec/kv-store/stores';
7
7
  import { protocolContractNames } from '@aztec/protocol-contracts';
8
- import { FunctionSelector, FunctionType, decodeFunctionSignature, encodeArguments } from '@aztec/stdlib/abi';
8
+ import { FunctionType, decodeFunctionSignature } from '@aztec/stdlib/abi';
9
9
  import { computeContractAddressFromInstance, getContractClassFromArtifact } from '@aztec/stdlib/contract';
10
10
  import { SimulationError } from '@aztec/stdlib/errors';
11
11
  import { computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
12
12
  import { PrivateSimulationResult, TxProfileResult, TxProvingResult, TxSimulationResult } from '@aztec/stdlib/tx';
13
13
  import { inspect } from 'util';
14
+ import { BlockSynchronizer } from './block_synchronizer/index.js';
14
15
  import { ContractFunctionSimulator, generateSimulatedProvingResult } from './contract_function_simulator/contract_function_simulator.js';
15
16
  import { readCurrentClassId } from './contract_function_simulator/oracle/private_execution.js';
16
17
  import { ProxiedContractDataProviderFactory } from './contract_function_simulator/proxied_contract_data_source.js';
17
18
  import { ProxiedNodeFactory } from './contract_function_simulator/proxied_node.js';
18
19
  import { PXEOracleInterface } from './contract_function_simulator/pxe_oracle_interface.js';
20
+ import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
19
21
  import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
20
22
  import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
21
23
  import { PrivateKernelExecutionProver } from './private_kernel/private_kernel_execution_prover.js';
22
24
  import { PrivateKernelOracleImpl } from './private_kernel/private_kernel_oracle_impl.js';
23
25
  import { AddressDataProvider } from './storage/address_data_provider/address_data_provider.js';
26
+ import { AnchorBlockDataProvider } from './storage/anchor_block_data_provider/anchor_block_data_provider.js';
24
27
  import { CapsuleDataProvider } from './storage/capsule_data_provider/capsule_data_provider.js';
25
28
  import { ContractDataProvider } from './storage/contract_data_provider/contract_data_provider.js';
26
29
  import { NoteDataProvider } from './storage/note_data_provider/note_data_provider.js';
27
30
  import { PrivateEventDataProvider } from './storage/private_event_data_provider/private_event_data_provider.js';
28
- import { SyncDataProvider } from './storage/sync_data_provider/sync_data_provider.js';
29
- import { TaggingDataProvider } from './storage/tagging_data_provider/tagging_data_provider.js';
30
- import { Synchronizer } from './synchronizer/index.js';
31
+ import { RecipientTaggingDataProvider } from './storage/tagging_data_provider/recipient_tagging_data_provider.js';
32
+ import { SenderTaggingDataProvider } from './storage/tagging_data_provider/sender_tagging_data_provider.js';
31
33
  /**
32
34
  * Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
33
35
  * manage private state of users.
34
36
  */ export class PXE {
35
37
  node;
36
- synchronizer;
38
+ blockStateSynchronizer;
37
39
  keyStore;
38
40
  contractDataProvider;
39
41
  noteDataProvider;
40
42
  capsuleDataProvider;
41
- syncDataProvider;
42
- taggingDataProvider;
43
+ anchorBlockDataProvider;
44
+ senderTaggingDataProvider;
45
+ recipientTaggingDataProvider;
43
46
  addressDataProvider;
44
47
  privateEventDataProvider;
45
48
  simulator;
@@ -48,15 +51,17 @@ import { Synchronizer } from './synchronizer/index.js';
48
51
  protocolContractsProvider;
49
52
  log;
50
53
  jobQueue;
51
- constructor(node, synchronizer, keyStore, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider, privateEventDataProvider, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue){
54
+ debug;
55
+ constructor(node, blockStateSynchronizer, keyStore, contractDataProvider, noteDataProvider, capsuleDataProvider, anchorBlockDataProvider, senderTaggingDataProvider, recipientTaggingDataProvider, addressDataProvider, privateEventDataProvider, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, debug){
52
56
  this.node = node;
53
- this.synchronizer = synchronizer;
57
+ this.blockStateSynchronizer = blockStateSynchronizer;
54
58
  this.keyStore = keyStore;
55
59
  this.contractDataProvider = contractDataProvider;
56
60
  this.noteDataProvider = noteDataProvider;
57
61
  this.capsuleDataProvider = capsuleDataProvider;
58
- this.syncDataProvider = syncDataProvider;
59
- this.taggingDataProvider = taggingDataProvider;
62
+ this.anchorBlockDataProvider = anchorBlockDataProvider;
63
+ this.senderTaggingDataProvider = senderTaggingDataProvider;
64
+ this.recipientTaggingDataProvider = recipientTaggingDataProvider;
60
65
  this.addressDataProvider = addressDataProvider;
61
66
  this.privateEventDataProvider = privateEventDataProvider;
62
67
  this.simulator = simulator;
@@ -65,6 +70,7 @@ import { Synchronizer } from './synchronizer/index.js';
65
70
  this.protocolContractsProvider = protocolContractsProvider;
66
71
  this.log = log;
67
72
  this.jobQueue = jobQueue;
73
+ this.debug = debug;
68
74
  }
69
75
  /**
70
76
  * Creates an instance of a PXE by instantiating all the necessary data providers and services.
@@ -79,14 +85,17 @@ import { Synchronizer } from './synchronizer/index.js';
79
85
  const privateEventDataProvider = new PrivateEventDataProvider(store);
80
86
  const contractDataProvider = new ContractDataProvider(store);
81
87
  const noteDataProvider = await NoteDataProvider.create(store);
82
- const syncDataProvider = new SyncDataProvider(store);
83
- const taggingDataProvider = new TaggingDataProvider(store);
88
+ const anchorBlockDataProvider = new AnchorBlockDataProvider(store);
89
+ const senderTaggingDataProvider = new SenderTaggingDataProvider(store);
90
+ const recipientTaggingDataProvider = new RecipientTaggingDataProvider(store);
84
91
  const capsuleDataProvider = new CapsuleDataProvider(store);
85
92
  const keyStore = new KeyStore(store);
86
93
  const tipsStore = new L2TipsKVStore(store, 'pxe');
87
- const synchronizer = new Synchronizer(node, syncDataProvider, noteDataProvider, taggingDataProvider, tipsStore, config, loggerOrSuffix);
94
+ const synchronizer = new BlockSynchronizer(node, anchorBlockDataProvider, noteDataProvider, recipientTaggingDataProvider, tipsStore, config, loggerOrSuffix);
95
+ const debugUtils = new PXEDebugUtils(contractDataProvider, noteDataProvider);
88
96
  const jobQueue = new SerialQueue();
89
- const pxe = new PXE(node, synchronizer, keyStore, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider, privateEventDataProvider, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue);
97
+ const pxe = new PXE(node, synchronizer, keyStore, contractDataProvider, noteDataProvider, capsuleDataProvider, anchorBlockDataProvider, senderTaggingDataProvider, recipientTaggingDataProvider, addressDataProvider, privateEventDataProvider, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, debugUtils);
98
+ debugUtils.setPXE(pxe);
90
99
  pxe.jobQueue.start();
91
100
  await pxe.#registerProtocolContracts();
92
101
  const info = await node.getNodeInfo();
@@ -95,7 +104,7 @@ import { Synchronizer } from './synchronizer/index.js';
95
104
  }
96
105
  // Internal methods
97
106
  #getSimulatorForTx(overrides) {
98
- const pxeOracleInterface = new PXEOracleInterface(ProxiedNodeFactory.create(this.node), this.keyStore, ProxiedContractDataProviderFactory.create(this.contractDataProvider, overrides?.contracts), this.noteDataProvider, this.capsuleDataProvider, this.syncDataProvider, this.taggingDataProvider, this.addressDataProvider, this.privateEventDataProvider, this.log);
107
+ const pxeOracleInterface = new PXEOracleInterface(ProxiedNodeFactory.create(this.node), this.keyStore, ProxiedContractDataProviderFactory.create(this.contractDataProvider, overrides?.contracts), this.noteDataProvider, this.capsuleDataProvider, this.anchorBlockDataProvider, this.senderTaggingDataProvider, this.recipientTaggingDataProvider, this.addressDataProvider, this.privateEventDataProvider, this.log);
99
108
  return new ContractFunctionSimulator(pxeOracleInterface, this.simulator);
100
109
  }
101
110
  #contextualizeError(err, ...context) {
@@ -143,32 +152,13 @@ import { Synchronizer } from './synchronizer/index.js';
143
152
  const initNullifier = await siloNullifier(address, address.toField());
144
153
  return !!await this.node.getNullifierMembershipWitness('latest', initNullifier);
145
154
  }
146
- async #getFunctionCall(functionName, args, to) {
147
- const contract = await this.contractDataProvider.getContract(to);
148
- if (!contract) {
149
- throw new Error(`Unknown contract ${to}: add it to PXE by calling server.addContracts(...).\nSee docs for context: https://docs.aztec.network/developers/resources/debugging/aztecnr-errors#unknown-contract-0x0-add-it-to-pxe-by-calling-serveraddcontracts`);
150
- }
151
- const functionDao = contract.functions.find((f)=>f.name === functionName);
152
- if (!functionDao) {
153
- throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
154
- }
155
- return {
156
- name: functionDao.name,
157
- args: encodeArguments(functionDao, args),
158
- selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
159
- type: functionDao.functionType,
160
- to,
161
- hideMsgSender: false,
162
- isStatic: functionDao.isStatic,
163
- returnTypes: functionDao.returnTypes
164
- };
165
- }
166
155
  // Executes the entrypoint private function, as well as all nested private
167
156
  // functions that might arise.
168
157
  async #executePrivate(contractFunctionSimulator, txRequest, scopes) {
169
158
  const { origin: contractAddress, functionSelector } = txRequest;
170
159
  try {
171
- const result = await contractFunctionSimulator.run(txRequest, contractAddress, functionSelector, undefined, // The sender for tags is set by contracts, typically by an account
160
+ const anchorBlockHeader = await this.anchorBlockDataProvider.getBlockHeader();
161
+ const result = await contractFunctionSimulator.run(txRequest, contractAddress, functionSelector, undefined, anchorBlockHeader, // The sender for tags is set by contracts, typically by an account
172
162
  // contract entrypoint
173
163
  undefined, scopes);
174
164
  this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
@@ -190,7 +180,8 @@ import { Synchronizer } from './synchronizer/index.js';
190
180
  * @returns The simulation result containing the outputs of the utility function.
191
181
  */ async #simulateUtility(contractFunctionSimulator, call, authWitnesses, scopes) {
192
182
  try {
193
- return contractFunctionSimulator.runUtility(call, authWitnesses ?? [], scopes);
183
+ const anchorBlockHeader = await this.anchorBlockDataProvider.getBlockHeader();
184
+ return contractFunctionSimulator.runUtility(call, authWitnesses ?? [], anchorBlockHeader, scopes);
194
185
  } catch (err) {
195
186
  if (err instanceof SimulationError) {
196
187
  await enrichSimulationError(err, this.contractDataProvider, this.log);
@@ -315,41 +306,43 @@ import { Synchronizer } from './synchronizer/index.js';
315
306
  return accountCompleteAddress;
316
307
  }
317
308
  /**
318
- * Registers a user contact in PXE.
309
+ * Registers a sender in this PXE.
319
310
  *
320
- * Once a new contact is registered, the PXE will be able to receive notes tagged from this contact.
321
- * Will do nothing if the account is already registered.
311
+ * After registering a new sender, the PXE will sync private logs that are tagged with this sender's address.
312
+ * Will do nothing if the address is already registered.
322
313
  *
323
- * @param address - Address of the user to add to the address book
324
- * @returns The address address of the account.
325
- */ async registerSender(address) {
314
+ * @param sender - Address of the sender to register.
315
+ * @returns The address of the sender.
316
+ * TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
317
+ */ async registerSender(sender) {
326
318
  const accounts = await this.keyStore.getAccounts();
327
- if (accounts.includes(address)) {
328
- this.log.info(`Sender:\n "${address.toString()}"\n already registered.`);
329
- return address;
319
+ if (accounts.includes(sender)) {
320
+ this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
321
+ return sender;
330
322
  }
331
- const wasAdded = await this.taggingDataProvider.addSenderAddress(address);
323
+ const wasAdded = await this.recipientTaggingDataProvider.addSenderAddress(sender);
332
324
  if (wasAdded) {
333
- this.log.info(`Added sender:\n ${address.toString()}`);
325
+ this.log.info(`Added sender:\n ${sender.toString()}`);
334
326
  } else {
335
- this.log.info(`Sender:\n "${address.toString()}"\n already registered.`);
327
+ this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
336
328
  }
337
- return address;
329
+ return sender;
338
330
  }
339
331
  /**
340
- * Retrieves the addresses stored as senders on this PXE.
341
- * @returns An array of the senders on this PXE.
332
+ * Retrieves senders registered in this PXE.
333
+ * @returns Senders registered in this PXE.
342
334
  */ getSenders() {
343
- return this.taggingDataProvider.getSenderAddresses();
335
+ return this.recipientTaggingDataProvider.getSenderAddresses();
344
336
  }
345
337
  /**
346
- * Removes a sender in the address book.
347
- */ async removeSender(address) {
348
- const wasRemoved = await this.taggingDataProvider.removeSenderAddress(address);
338
+ * Removes a sender registered in this PXE.
339
+ * @param sender - The address of the sender to remove.
340
+ */ async removeSender(sender) {
341
+ const wasRemoved = await this.recipientTaggingDataProvider.removeSenderAddress(sender);
349
342
  if (wasRemoved) {
350
- this.log.info(`Removed sender:\n ${address.toString()}`);
343
+ this.log.info(`Removed sender:\n ${sender.toString()}`);
351
344
  } else {
352
- this.log.info(`Sender:\n "${address.toString()}"\n not in address book.`);
345
+ this.log.info(`Sender:\n "${sender.toString()}"\n not registered in PXE.`);
353
346
  }
354
347
  }
355
348
  /**
@@ -422,8 +415,8 @@ import { Synchronizer } from './synchronizer/index.js';
422
415
  throw new Error(`Instance not found when updating a contract. Contract address: ${contractAddress}.`);
423
416
  }
424
417
  const contractClass = await getContractClassFromArtifact(artifact);
425
- await this.synchronizer.sync();
426
- const header = await this.syncDataProvider.getBlockHeader();
418
+ await this.blockStateSynchronizer.sync();
419
+ const header = await this.anchorBlockDataProvider.getBlockHeader();
427
420
  const currentClassId = await readCurrentClassId(contractAddress, currentInstance, this.node, header.globalVariables.blockNumber, header.globalVariables.timestamp);
428
421
  if (!contractClass.id.equals(currentClassId)) {
429
422
  throw new Error('Could not update contract to a class different from the current one.');
@@ -443,22 +436,6 @@ import { Synchronizer } from './synchronizer/index.js';
443
436
  return this.contractDataProvider.getContractsAddresses();
444
437
  }
445
438
  /**
446
- * A debugging utility to get notes based on the provided filter.
447
- *
448
- * Note that this should not be used in production code because the structure of notes is considered to be
449
- * an implementation detail of contracts. This is only meant to be used for debugging purposes. If you need to obtain
450
- * note-related information in production code, please implement a custom utility function on your contract and call
451
- * that function instead (e.g. `get_balance(owner: AztecAddress) -> u128` utility function on a Token contract).
452
- *
453
- * @param filter - The filter to apply to the notes.
454
- * @returns The requested notes.
455
- */ async getNotes(filter) {
456
- // We need to manually trigger private state sync to have a guarantee that all the notes are available.
457
- const call = await this.#getFunctionCall('sync_private_state', [], filter.contractAddress);
458
- await this.simulateUtility(call);
459
- return this.noteDataProvider.getNotes(filter);
460
- }
461
- /**
462
439
  * Proves the private portion of a simulated transaction, ready to send to the network
463
440
  * (where validators prove the public portion).
464
441
  *
@@ -474,7 +451,7 @@ import { Synchronizer } from './synchronizer/index.js';
474
451
  const totalTimer = new Timer();
475
452
  try {
476
453
  const syncTimer = new Timer();
477
- await this.synchronizer.sync();
454
+ await this.blockStateSynchronizer.sync();
478
455
  const syncTime = syncTimer.ms();
479
456
  const contractFunctionSimulator = this.#getSimulatorForTx();
480
457
  privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest);
@@ -503,14 +480,21 @@ import { Synchronizer } from './synchronizer/index.js';
503
480
  timings,
504
481
  nodeRPCCalls: contractFunctionSimulator?.getStats().nodeRPCCalls
505
482
  });
483
+ // While not strictly necessary to store tagging cache contents in the DB since we sync tagging indexes from
484
+ // chain before sending new logs, the sync can only see logs already included in blocks. If we send another
485
+ // transaction before this one is included in a block from this PXE, and that transaction contains a log with
486
+ // a tag derived from the same secret, we would reuse the tag and the transactions would be linked. Hence
487
+ // storing the tags here prevents linkage of txs sent from the same PXE.
506
488
  const preTagsUsedInTheTx = privateExecutionResult.entrypoint.preTags;
507
489
  if (preTagsUsedInTheTx.length > 0) {
508
- await this.taggingDataProvider.setLastUsedIndexesAsSender(preTagsUsedInTheTx);
509
- this.log.debug(`Stored used pre tags as sender for the tx`, {
490
+ // TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
491
+ const txHash = (await txProvingResult.toTx()).txHash;
492
+ await this.senderTaggingDataProvider.storePendingIndexes(preTagsUsedInTheTx, txHash);
493
+ this.log.debug(`Stored used pre-tags as sender for the tx`, {
510
494
  preTagsUsedInTheTx
511
495
  });
512
496
  } else {
513
- this.log.debug(`No pre tags used in the tx`);
497
+ this.log.debug(`No pre-tags used in the tx`);
514
498
  }
515
499
  return txProvingResult;
516
500
  } catch (err) {
@@ -541,7 +525,7 @@ import { Synchronizer } from './synchronizer/index.js';
541
525
  };
542
526
  this.log.info(`Profiling transaction execution request to ${txRequest.functionSelector} at ${txRequest.origin}`, txInfo);
543
527
  const syncTimer = new Timer();
544
- await this.synchronizer.sync();
528
+ await this.blockStateSynchronizer.sync();
545
529
  const syncTime = syncTimer.ms();
546
530
  const contractFunctionSimulator = this.#getSimulatorForTx();
547
531
  const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest);
@@ -617,7 +601,7 @@ import { Synchronizer } from './synchronizer/index.js';
617
601
  };
618
602
  this.log.info(`Simulating transaction execution request to ${txRequest.functionSelector} at ${txRequest.origin}`, txInfo);
619
603
  const syncTimer = new Timer();
620
- await this.synchronizer.sync();
604
+ await this.blockStateSynchronizer.sync();
621
605
  const syncTime = syncTimer.ms();
622
606
  const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
623
607
  // Temporary: in case there are overrides, we have to skip the kernels or validations
@@ -712,7 +696,7 @@ import { Synchronizer } from './synchronizer/index.js';
712
696
  try {
713
697
  const totalTimer = new Timer();
714
698
  const syncTimer = new Timer();
715
- await this.synchronizer.sync();
699
+ await this.blockStateSynchronizer.sync();
716
700
  const syncTime = syncTimer.ms();
717
701
  const functionTimer = new Timer();
718
702
  const contractFunctionSimulator = this.#getSimulatorForTx();
@@ -760,9 +744,9 @@ import { Synchronizer } from './synchronizer/index.js';
760
744
  * @returns - The packed events with block and tx metadata.
761
745
  */ async getPrivateEvents(eventSelector, filter) {
762
746
  // We need to manually trigger private state sync to have a guarantee that all the events are available.
763
- const call = await this.#getFunctionCall('sync_private_state', [], filter.contractAddress);
747
+ const call = await this.contractDataProvider.getFunctionCall('sync_private_state', [], filter.contractAddress);
764
748
  await this.simulateUtility(call);
765
- const sanitizedFilter = await new PrivateEventFilterValidator(this.syncDataProvider).validate(filter);
749
+ const sanitizedFilter = await new PrivateEventFilterValidator(this.anchorBlockDataProvider).validate(filter);
766
750
  this.log.error(`Getting private events for ${sanitizedFilter.contractAddress.toString()} from ${sanitizedFilter.fromBlock} to ${sanitizedFilter.toBlock}`);
767
751
  return this.privateEventDataProvider.getPrivateEvents(eventSelector, sanitizedFilter);
768
752
  }
@@ -0,0 +1,9 @@
1
+ import type { AztecAsyncKVStore } from '@aztec/kv-store';
2
+ import { BlockHeader } from '@aztec/stdlib/tx';
3
+ export declare class AnchorBlockDataProvider {
4
+ #private;
5
+ constructor(store: AztecAsyncKVStore);
6
+ setHeader(header: BlockHeader): Promise<void>;
7
+ getBlockHeader(): Promise<BlockHeader>;
8
+ }
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5jaG9yX2Jsb2NrX2RhdGFfcHJvdmlkZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL2FuY2hvcl9ibG9ja19kYXRhX3Byb3ZpZGVyL2FuY2hvcl9ibG9ja19kYXRhX3Byb3ZpZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUF1QixNQUFNLGlCQUFpQixDQUFDO0FBQzlFLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUUvQyxxQkFBYSx1QkFBdUI7O0lBSWxDLFlBQVksS0FBSyxFQUFFLGlCQUFpQixFQUduQztJQUVLLFNBQVMsQ0FBQyxNQUFNLEVBQUUsV0FBVyxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FFbEQ7SUFFSyxjQUFjLElBQUksT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQU8zQztDQUNGIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor_block_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/anchor_block_data_provider/anchor_block_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,qBAAa,uBAAuB;;IAIlC,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,5 +1,5 @@
1
1
  import { BlockHeader } from '@aztec/stdlib/tx';
2
- export class SyncDataProvider {
2
+ export class AnchorBlockDataProvider {
3
3
  #store;
4
4
  #synchronizedHeader;
5
5
  constructor(store){
@@ -9,17 +9,10 @@ export class SyncDataProvider {
9
9
  async setHeader(header) {
10
10
  await this.#synchronizedHeader.set(header.toBuffer());
11
11
  }
12
- async getBlockNumber() {
13
- const headerBuffer = await this.#synchronizedHeader.getAsync();
14
- if (!headerBuffer) {
15
- throw new Error(`Trying to get block number with a not-yet-synchronized PXE - this should never happen`);
16
- }
17
- return BlockHeader.fromBuffer(headerBuffer).globalVariables.blockNumber;
18
- }
19
12
  async getBlockHeader() {
20
13
  const headerBuffer = await this.#synchronizedHeader.getAsync();
21
14
  if (!headerBuffer) {
22
- throw new Error(`Header not set`);
15
+ throw new Error(`Trying to get block header with a not-yet-synchronized PXE - this should never happen`);
23
16
  }
24
17
  return BlockHeader.fromBuffer(headerBuffer);
25
18
  }
@@ -0,0 +1,2 @@
1
+ export { AnchorBlockDataProvider } from './anchor_block_data_provider.js';
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL2FuY2hvcl9ibG9ja19kYXRhX3Byb3ZpZGVyL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSx1QkFBdUIsRUFBRSxNQUFNLGlDQUFpQyxDQUFDIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/anchor_block_data_provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC"}
@@ -0,0 +1 @@
1
+ export { AnchorBlockDataProvider } from './anchor_block_data_provider.js';
@@ -2,7 +2,7 @@ import type { FUNCTION_TREE_HEIGHT } from '@aztec/constants';
2
2
  import type { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { MembershipWitness } from '@aztec/foundation/trees';
4
4
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
5
- import { type ContractArtifact, type FunctionAbi, type FunctionArtifactWithContractName, type FunctionDebugMetadata, FunctionSelector } from '@aztec/stdlib/abi';
5
+ import { type ContractArtifact, type FunctionAbi, type FunctionArtifactWithContractName, FunctionCall, type FunctionDebugMetadata, FunctionSelector } from '@aztec/stdlib/abi';
6
6
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
7
7
  import { type ContractClass, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
8
8
  /**
@@ -60,5 +60,6 @@ export declare class ContractDataProvider {
60
60
  getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT> | undefined>;
61
61
  getDebugContractName(contractAddress: AztecAddress): Promise<string | undefined>;
62
62
  getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string>;
63
+ getFunctionCall(functionName: string, args: any[], to: AztecAddress): Promise<FunctionCall>;
63
64
  }
64
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RfZGF0YV9wcm92aWRlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2UvY29udHJhY3RfZGF0YV9wcm92aWRlci9jb250cmFjd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2RztDQUNGIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"contract_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/contract_data_provider/contract_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAEhB,KAAK,gCAAgC,EACrC,KAAK,qBAAqB,EAC1B,gBAAgB,EAKjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,2BAA2B,EAGjC,MAAM,wBAAwB,CAAC;AAIhC;;;;;;GAMG;AACH,qBAAa,oBAAoB;;IAW/B,YAAY,KAAK,EAAE,iBAAiB,EAGnC;IAIY,mBAAmB,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBlF;IAEK,mBAAmB,CAAC,QAAQ,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAO9E;IA4CK,qBAAqB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAGrD;IAED,4EAA4E;IAC/D,mBAAmB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC,CAGhH;IAEY,mBAAmB,CAAC,eAAe,EAAE,EAAE,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAI3F;IAED,0EAA0E;IAC7D,gBAAgB,CAAC,eAAe,EAAE,EAAE,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAGrF;IAEY,WAAW,CACtB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,CAAC,2BAA2B,GAAG,gBAAgB,CAAC,GAAG,SAAS,CAAC,CAUvE;IAED;;;;;;;;OAQG;IACU,mBAAmB,CAC9B,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,gCAAgC,GAAG,SAAS,CAAC,CAIvD;IAEY,yBAAyB,CACpC,eAAe,EAAE,YAAY,GAC5B,OAAO,CAAC,gCAAgC,GAAG,SAAS,CAAC,CAIvD;IAEY,cAAc,CACzB,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAGlC;IAED;;;;;;;;;OASG;IACU,wBAAwB,CACnC,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAI5C;IAEY,8BAA8B,CACzC,eAAe,EAAE,YAAY,GAC5B,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAI5C;IAED;;;;;;;;OAQG;IACU,4BAA4B,CACvC,eAAe,EAAE,EAAE,EACnB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,iBAAiB,CAAC,OAAO,oBAAoB,CAAC,GAAG,SAAS,CAAC,CAGrE;IAEY,oBAAoB,CAAC,eAAe,EAAE,YAAY,+BAG9D;IAEY,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,mBAI1F;CA6BF"}
1
+ {"version":3,"file":"contract_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/contract_data_provider/contract_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEzD,OAAO,KAAK,EAA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AS,CAAC,CAIvD;IAEY,yBAAyB,CACpC,eAAe,EAAE,YAAY,GAC5B,OAAO,CAAC,gCAAgC,GAAG,SAAS,CAAC,CAIvD;IAEY,cAAc,CACzB,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAGlC;IAED;;;;;;;;;OASG;IACU,wBAAwB,CACnC,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAI5C;IAEY,8BAA8B,CACzC,eAAe,EAAE,YAAY,GAC5B,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAI5C;IAED;;;;;;;;OAQG;IACU,4BAA4B,CACvC,eAAe,EAAE,EAAE,EACnB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,iBAAiB,CAAC,OAAO,oBAAoB,CAAC,GAAG,SAAS,CAAC,CAGrE;IAEY,oBAAoB,CAAC,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, getFunctionDebugMetadata } from '@aztec/stdlib/abi';
2
+ import { 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';
@@ -190,4 +190,24 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
190
190
  }
191
191
  }
192
192
  }
193
+ async getFunctionCall(functionName, args, to) {
194
+ const contract = await this.getContract(to);
195
+ if (!contract) {
196
+ throw new Error(`Unknown contract ${to}: add it to PXE by calling server.addContracts(...).\nSee docs for context: https://docs.aztec.network/developers/resources/debugging/aztecnr-errors#unknown-contract-0x0-add-it-to-pxe-by-calling-serveraddcontracts`);
197
+ }
198
+ const functionDao = contract.functions.find((f)=>f.name === functionName);
199
+ if (!functionDao) {
200
+ throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
201
+ }
202
+ return {
203
+ name: functionDao.name,
204
+ args: encodeArguments(functionDao, args),
205
+ selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
206
+ type: functionDao.functionType,
207
+ to,
208
+ hideMsgSender: false,
209
+ isStatic: functionDao.isStatic,
210
+ returnTypes: functionDao.returnTypes
211
+ };
212
+ }
193
213
  }
@@ -2,8 +2,8 @@ export * from './address_data_provider/index.js';
2
2
  export * from './capsule_data_provider/index.js';
3
3
  export * from './contract_data_provider/index.js';
4
4
  export * from './note_data_provider/index.js';
5
- export * from './sync_data_provider/index.js';
5
+ export * from './anchor_block_data_provider/index.js';
6
6
  export * from './tagging_data_provider/index.js';
7
7
  export * from './metadata.js';
8
8
  export * from './private_event_data_provider/private_event_data_provider.js';
9
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdG9yYWdlL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsa0NBQWtDLENBQUM7QUFDakQsY0FBYyxrQ0FBa0MsQ0FBQztBQUNqRCxjQUFjLG1DQUFtQyxDQUFDO0FBQ2xELGNBQWMsK0JBQStCLENBQUM7QUFDOUMsY0FBYywrQkFBK0IsQ0FBQztBQUM5QyxjQUFjLGtDQUFrQyxDQUFDO0FBQ2pELGNBQWMsZUFBZSxDQUFDO0FBQzlCLGNBQWMsOERBQThELENBQUMifQ==
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdG9yYWdlL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsa0NBQWtDLENBQUM7QUFDakQsY0FBYyxrQ0FBa0MsQ0FBQztBQUNqRCxjQUFjLG1DQUFtQyxDQUFDO0FBQ2xELGNBQWMsK0JBQStCLENBQUM7QUFDOUMsY0FBYyx1Q0FBdUMsQ0FBQztBQUN0RCxjQUFjLGtDQUFrQyxDQUFDO0FBQ2pELGNBQWMsZUFBZSxDQUFDO0FBQzlCLGNBQWMsOERBQThELENBQUMifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,eAAe,CAAC;AAC9B,cAAc,8DAA8D,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uCAAuC,CAAC;AACtD,cAAc,kCAAkC,CAAC;AACjD,cAAc,eAAe,CAAC;AAC9B,cAAc,8DAA8D,CAAC"}
@@ -2,7 +2,7 @@ export * from './address_data_provider/index.js';
2
2
  export * from './capsule_data_provider/index.js';
3
3
  export * from './contract_data_provider/index.js';
4
4
  export * from './note_data_provider/index.js';
5
- export * from './sync_data_provider/index.js';
5
+ export * from './anchor_block_data_provider/index.js';
6
6
  export * from './tagging_data_provider/index.js';
7
7
  export * from './metadata.js';
8
8
  export * from './private_event_data_provider/private_event_data_provider.js';
@@ -1,2 +1,3 @@
1
- export { TaggingDataProvider } from './tagging_data_provider.js';
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL3RhZ2dpbmdfZGF0YV9wcm92aWRlci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQyJ9
1
+ export { SenderTaggingDataProvider } from './sender_tagging_data_provider.js';
2
+ export { RecipientTaggingDataProvider } from './recipient_tagging_data_provider.js';
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL3RhZ2dpbmdfZGF0YV9wcm92aWRlci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUseUJBQXlCLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUM5RSxPQUFPLEVBQUUsNEJBQTRCLEVBQUUsTUFBTSxzQ0FBc0MsQ0FBQyJ9
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_data_provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_data_provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC"}
@@ -1 +1,2 @@
1
- export { TaggingDataProvider } from './tagging_data_provider.js';
1
+ export { SenderTaggingDataProvider } from './sender_tagging_data_provider.js';
2
+ export { RecipientTaggingDataProvider } from './recipient_tagging_data_provider.js';
@@ -0,0 +1,31 @@
1
+ import type { AztecAsyncKVStore } from '@aztec/kv-store';
2
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { DirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
4
+ /**
5
+ * Data provider of tagging data used when syncing the logs as a recipient. The sender counterpart of this class is
6
+ * called SenderTaggingDataProvider. We have the providers separate for the sender and recipient because
7
+ * the algorithms are completely disjoint and there is not data reuse between the 2.
8
+ */
9
+ export declare class RecipientTaggingDataProvider {
10
+ #private;
11
+ constructor(store: AztecAsyncKVStore);
12
+ /**
13
+ * Sets the last used indexes when looking for logs.
14
+ * @param preTags - The pre-tags containing the directional app tagging secrets and the indexes that are to be
15
+ * updated in the db.
16
+ * @throws If any two pre-tags contain the same directional app tagging secret
17
+ */
18
+ setLastUsedIndexes(preTags: PreTag[]): Promise<void[]>;
19
+ /**
20
+ * Returns the last used indexes when looking for logs.
21
+ * @param secrets - The directional app tagging secrets to obtain the indexes for.
22
+ * @returns The last used indexes for the given directional app tagging secrets, or undefined if have never yet found
23
+ * a log for a given secret.
24
+ */
25
+ getLastUsedIndexes(secrets: DirectionalAppTaggingSecret[]): Promise<(number | undefined)[]>;
26
+ resetNoteSyncData(): Promise<void>;
27
+ addSenderAddress(address: AztecAddress): Promise<boolean>;
28
+ getSenderAddresses(): Promise<AztecAddress[]>;
29
+ removeSenderAddress(address: AztecAddress): Promise<boolean>;
30
+ }
31
+ //#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DQUFDLE9BQU8sQ0FBQyxDQVFqRTtDQUNGIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipient_tagging_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_data_provider/recipient_tagging_data_provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE9E;;;;GAIG;AACH,qBAAa,4BAA4B;;IAOvC,YAAY,KAAK,EAAE,iBAAiB,EAKnC;IAED;;;;;OAKG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,mBAQnC;IAED;;;;;OAKG;IACH,kBAAkB,CAAC,OAAO,EAAE,2BAA2B,EAAE,GAAG,OAAO,CAAC,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC,CAE1F;IAED,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAKjC;IAOK,gBAAgB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAQ9D;IAEK,kBAAkB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAElD;IAEK,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAQjE;CACF"}
@@ -0,0 +1,65 @@
1
+ import { toArray } from '@aztec/foundation/iterable';
2
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ /**
4
+ * Data provider of tagging data used when syncing the logs as a recipient. The sender counterpart of this class is
5
+ * called SenderTaggingDataProvider. We have the providers separate for the sender and recipient because
6
+ * the algorithms are completely disjoint and there is not data reuse between the 2.
7
+ */ export class RecipientTaggingDataProvider {
8
+ #store;
9
+ #addressBook;
10
+ // Stores the last used index for each directional app tagging secret.
11
+ #lastUsedIndexes;
12
+ constructor(store){
13
+ this.#store = store;
14
+ this.#addressBook = this.#store.openMap('address_book');
15
+ this.#lastUsedIndexes = this.#store.openMap('last_used_indexes');
16
+ }
17
+ /**
18
+ * Sets the last used indexes when looking for logs.
19
+ * @param preTags - The pre-tags containing the directional app tagging secrets and the indexes that are to be
20
+ * updated in the db.
21
+ * @throws If any two pre-tags contain the same directional app tagging secret
22
+ */ setLastUsedIndexes(preTags) {
23
+ // Non-unique secrets would indicate a bug in the caller function.
24
+ const secretsSet = new Set(preTags.map((preTag)=>preTag.secret.toString()));
25
+ if (secretsSet.size !== preTags.length) {
26
+ throw new Error(`Duplicate secrets found when setting last used indexes`);
27
+ }
28
+ return Promise.all(preTags.map(({ secret, index })=>this.#lastUsedIndexes.set(secret.toString(), index)));
29
+ }
30
+ /**
31
+ * Returns the last used indexes when looking for logs.
32
+ * @param secrets - The directional app tagging secrets to obtain the indexes for.
33
+ * @returns The last used indexes for the given directional app tagging secrets, or undefined if have never yet found
34
+ * a log for a given secret.
35
+ */ getLastUsedIndexes(secrets) {
36
+ return Promise.all(secrets.map((secret)=>this.#lastUsedIndexes.getAsync(secret.toString())));
37
+ }
38
+ resetNoteSyncData() {
39
+ return this.#store.transactionAsync(async ()=>{
40
+ const keys = await toArray(this.#lastUsedIndexes.keysAsync());
41
+ await Promise.all(keys.map((secret)=>this.#lastUsedIndexes.delete(secret)));
42
+ });
43
+ }
44
+ // It might seem weird that the following 3 methods are in RecipientTaggingDataProvider and not
45
+ // in SenderTaggingDataProvider but that is because this data is truly only used for the purposes of syncing logs
46
+ // as a recipient. When sending logs or when syncing sender tagging indexes we only receive directional app tagging
47
+ // secret from Aztec.nr via an oracle and we don't need to access sender addresses.
48
+ async addSenderAddress(address) {
49
+ if (await this.#addressBook.hasAsync(address.toString())) {
50
+ return false;
51
+ }
52
+ await this.#addressBook.set(address.toString(), true);
53
+ return true;
54
+ }
55
+ async getSenderAddresses() {
56
+ return (await toArray(this.#addressBook.keysAsync())).map(AztecAddress.fromString);
57
+ }
58
+ async removeSenderAddress(address) {
59
+ if (!await this.#addressBook.hasAsync(address.toString())) {
60
+ return false;
61
+ }
62
+ await this.#addressBook.delete(address.toString());
63
+ return true;
64
+ }
65
+ }