@aztec/pxe 0.62.0 → 0.63.1

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 (100) hide show
  1. package/dest/config/index.d.ts +2 -3
  2. package/dest/config/index.d.ts.map +1 -1
  3. package/dest/config/index.js +4 -5
  4. package/dest/contract_data_oracle/index.d.ts +1 -0
  5. package/dest/contract_data_oracle/index.d.ts.map +1 -1
  6. package/dest/contract_data_oracle/index.js +5 -1
  7. package/dest/database/incoming_note_dao.d.ts +1 -1
  8. package/dest/database/incoming_note_dao.d.ts.map +1 -1
  9. package/dest/database/kv_pxe_database.d.ts +5 -12
  10. package/dest/database/kv_pxe_database.d.ts.map +1 -1
  11. package/dest/database/kv_pxe_database.js +31 -62
  12. package/dest/database/outgoing_note_dao.d.ts +1 -1
  13. package/dest/database/outgoing_note_dao.d.ts.map +1 -1
  14. package/dest/database/pxe_database.d.ts +17 -25
  15. package/dest/database/pxe_database.d.ts.map +1 -1
  16. package/dest/kernel_oracle/index.d.ts +3 -3
  17. package/dest/kernel_oracle/index.d.ts.map +1 -1
  18. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
  19. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +12 -4
  20. package/dest/kernel_prover/kernel_prover.d.ts +3 -1
  21. package/dest/kernel_prover/kernel_prover.d.ts.map +1 -1
  22. package/dest/kernel_prover/kernel_prover.js +39 -7
  23. package/dest/kernel_prover/test/test_circuit_prover.d.ts +1 -0
  24. package/dest/kernel_prover/test/test_circuit_prover.d.ts.map +1 -1
  25. package/dest/kernel_prover/test/test_circuit_prover.js +5 -1
  26. package/dest/{note_processor/utils → note_decryption_utils}/add_public_values_to_payload.d.ts +1 -1
  27. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +1 -0
  28. package/dest/{note_processor/utils → note_decryption_utils}/add_public_values_to_payload.js +1 -1
  29. package/dest/note_decryption_utils/brute_force_note_info.d.ts.map +1 -0
  30. package/dest/{note_processor/utils → note_decryption_utils}/brute_force_note_info.js +1 -1
  31. package/dest/note_decryption_utils/index.d.ts.map +1 -0
  32. package/dest/{note_processor/utils → note_decryption_utils}/index.js +1 -1
  33. package/dest/{note_processor/utils → note_decryption_utils}/produce_note_daos.d.ts +5 -8
  34. package/dest/note_decryption_utils/produce_note_daos.d.ts.map +1 -0
  35. package/dest/note_decryption_utils/produce_note_daos.js +47 -0
  36. package/dest/note_decryption_utils/produce_note_daos_for_key.d.ts +8 -0
  37. package/dest/note_decryption_utils/produce_note_daos_for_key.d.ts.map +1 -0
  38. package/dest/note_decryption_utils/produce_note_daos_for_key.js +17 -0
  39. package/dest/pxe_http/pxe_http_server.d.ts +1 -2
  40. package/dest/pxe_http/pxe_http_server.d.ts.map +1 -1
  41. package/dest/pxe_http/pxe_http_server.js +5 -51
  42. package/dest/pxe_service/create_pxe_service.d.ts.map +1 -1
  43. package/dest/pxe_service/create_pxe_service.js +7 -4
  44. package/dest/pxe_service/error_enriching.d.ts.map +1 -1
  45. package/dest/pxe_service/error_enriching.js +7 -6
  46. package/dest/pxe_service/pxe_service.d.ts +11 -25
  47. package/dest/pxe_service/pxe_service.d.ts.map +1 -1
  48. package/dest/pxe_service/pxe_service.js +45 -48
  49. package/dest/pxe_service/test/pxe_test_suite.d.ts.map +1 -1
  50. package/dest/pxe_service/test/pxe_test_suite.js +4 -3
  51. package/dest/simulator_oracle/index.d.ts +15 -16
  52. package/dest/simulator_oracle/index.d.ts.map +1 -1
  53. package/dest/simulator_oracle/index.js +195 -65
  54. package/dest/synchronizer/synchronizer.d.ts +0 -48
  55. package/dest/synchronizer/synchronizer.d.ts.map +1 -1
  56. package/dest/synchronizer/synchronizer.js +3 -201
  57. package/package.json +14 -14
  58. package/src/config/index.ts +4 -7
  59. package/src/contract_data_oracle/index.ts +5 -0
  60. package/src/database/incoming_note_dao.ts +1 -1
  61. package/src/database/kv_pxe_database.ts +33 -70
  62. package/src/database/outgoing_note_dao.ts +1 -1
  63. package/src/database/pxe_database.ts +19 -28
  64. package/src/kernel_prover/hints/build_private_kernel_reset_private_inputs.ts +13 -3
  65. package/src/kernel_prover/kernel_prover.ts +49 -5
  66. package/src/kernel_prover/test/test_circuit_prover.ts +8 -4
  67. package/src/{note_processor/utils → note_decryption_utils}/add_public_values_to_payload.ts +1 -1
  68. package/src/{note_processor/utils → note_decryption_utils}/produce_note_daos.ts +6 -16
  69. package/src/{note_processor/utils → note_decryption_utils}/produce_note_daos_for_key.ts +6 -15
  70. package/src/pxe_http/pxe_http_server.ts +5 -84
  71. package/src/pxe_service/create_pxe_service.ts +9 -3
  72. package/src/pxe_service/error_enriching.ts +12 -5
  73. package/src/pxe_service/pxe_service.ts +61 -78
  74. package/src/pxe_service/test/pxe_test_suite.ts +6 -2
  75. package/src/simulator_oracle/index.ts +280 -60
  76. package/src/synchronizer/synchronizer.ts +3 -253
  77. package/dest/database/deferred_note_dao.d.ts +0 -40
  78. package/dest/database/deferred_note_dao.d.ts.map +0 -1
  79. package/dest/database/deferred_note_dao.js +0 -38
  80. package/dest/note_processor/index.d.ts +0 -2
  81. package/dest/note_processor/index.d.ts.map +0 -1
  82. package/dest/note_processor/index.js +0 -2
  83. package/dest/note_processor/note_processor.d.ts +0 -83
  84. package/dest/note_processor/note_processor.d.ts.map +0 -1
  85. package/dest/note_processor/note_processor.js +0 -231
  86. package/dest/note_processor/utils/add_public_values_to_payload.d.ts.map +0 -1
  87. package/dest/note_processor/utils/brute_force_note_info.d.ts.map +0 -1
  88. package/dest/note_processor/utils/index.d.ts.map +0 -1
  89. package/dest/note_processor/utils/produce_note_daos.d.ts.map +0 -1
  90. package/dest/note_processor/utils/produce_note_daos.js +0 -51
  91. package/dest/note_processor/utils/produce_note_daos_for_key.d.ts +0 -9
  92. package/dest/note_processor/utils/produce_note_daos_for_key.d.ts.map +0 -1
  93. package/dest/note_processor/utils/produce_note_daos_for_key.js +0 -26
  94. package/src/database/deferred_note_dao.ts +0 -47
  95. package/src/note_processor/index.ts +0 -1
  96. package/src/note_processor/note_processor.ts +0 -358
  97. /package/dest/{note_processor/utils → note_decryption_utils}/brute_force_note_info.d.ts +0 -0
  98. /package/dest/{note_processor/utils → note_decryption_utils}/index.d.ts +0 -0
  99. /package/src/{note_processor/utils → note_decryption_utils}/brute_force_note_info.ts +0 -0
  100. /package/src/{note_processor/utils → note_decryption_utils}/index.ts +0 -0
@@ -1,21 +1,10 @@
1
- import { type AztecNode, type L2Block, MerkleTreeId, type TxHash } from '@aztec/circuit-types';
2
- import { type NoteProcessorCaughtUpStats } from '@aztec/circuit-types/stats';
3
- import {
4
- type AztecAddress,
5
- type CompleteAddress,
6
- type Fr,
7
- INITIAL_L2_BLOCK_NUM,
8
- type PublicKey,
9
- } from '@aztec/circuits.js';
1
+ import { type AztecNode, type L2Block } from '@aztec/circuit-types';
2
+ import { INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js';
10
3
  import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log';
11
4
  import { type SerialQueue } from '@aztec/foundation/queue';
12
5
  import { RunningPromise } from '@aztec/foundation/running-promise';
13
- import { type KeyStore } from '@aztec/key-store';
14
6
 
15
- import { type DeferredNoteDao } from '../database/deferred_note_dao.js';
16
- import { type IncomingNoteDao } from '../database/incoming_note_dao.js';
17
7
  import { type PxeDatabase } from '../database/index.js';
18
- import { NoteProcessor } from '../note_processor/index.js';
19
8
 
20
9
  /**
21
10
  * The Synchronizer class manages the synchronization of note processors and interacts with the Aztec node
@@ -26,11 +15,9 @@ import { NoteProcessor } from '../note_processor/index.js';
26
15
  */
27
16
  export class Synchronizer {
28
17
  private runningPromise?: RunningPromise;
29
- private noteProcessors: NoteProcessor[] = [];
30
18
  private running = false;
31
19
  private initialSyncBlockNumber = INITIAL_L2_BLOCK_NUM - 1;
32
20
  private log: DebugLogger;
33
- private noteProcessorsToCatchUp: NoteProcessor[] = [];
34
21
 
35
22
  constructor(private node: AztecNode, private db: PxeDatabase, private jobQueue: SerialQueue, logSuffix = '') {
36
23
  this.log = createDebugLogger(logSuffix ? `aztec:pxe_synchronizer_${logSuffix}` : 'aztec:pxe_synchronizer');
@@ -80,13 +67,7 @@ export class Synchronizer {
80
67
  let moreWork = true;
81
68
  // keep external this.running flag to interrupt greedy sync
82
69
  while (moreWork && this.running) {
83
- if (this.noteProcessorsToCatchUp.length > 0) {
84
- // There is a note processor that needs to catch up. We hijack the main loop to catch up the note processor.
85
- moreWork = await this.workNoteProcessorCatchUp(limit);
86
- } else {
87
- // No note processor needs to catch up. We continue with the normal flow.
88
- moreWork = await this.work(limit);
89
- }
70
+ moreWork = await this.work(limit);
90
71
  }
91
72
  });
92
73
  }
@@ -108,11 +89,6 @@ export class Synchronizer {
108
89
  // Update latest tree roots from the most recent block
109
90
  const latestBlock = blocks[blocks.length - 1];
110
91
  await this.setHeaderFromBlock(latestBlock);
111
-
112
- this.log.debug(`Forwarding ${blocks.length} blocks to ${this.noteProcessors.length} note processors`);
113
- for (const noteProcessor of this.noteProcessors) {
114
- await noteProcessor.process(blocks);
115
- }
116
92
  return true;
117
93
  } catch (err) {
118
94
  this.log.error(`Error in synchronizer work`, err);
@@ -120,104 +96,6 @@ export class Synchronizer {
120
96
  }
121
97
  }
122
98
 
123
- /**
124
- * Catch up note processors that are lagging behind the main sync.
125
- * e.g. because we just added a new account.
126
- *
127
- * @param limit - the maximum number of encrypted, unencrypted logs and blocks to fetch in each iteration.
128
- * @returns true if there could be more work, false if there was an error which allows a retry with delay.
129
- */
130
- protected async workNoteProcessorCatchUp(limit = 1): Promise<boolean> {
131
- const toBlockNumber = this.getSynchedBlockNumber();
132
-
133
- // filter out note processors that are already caught up
134
- // and sort them by the block number they are lagging behind in ascending order
135
- const noteProcessorsToCatchUp: NoteProcessor[] = [];
136
-
137
- this.noteProcessorsToCatchUp.forEach(noteProcessor => {
138
- if (noteProcessor.status.syncedToBlock >= toBlockNumber) {
139
- // Note processor is ahead of main sync, nothing to do
140
- this.noteProcessors.push(noteProcessor);
141
- } else {
142
- noteProcessorsToCatchUp.push(noteProcessor);
143
- }
144
- });
145
-
146
- this.noteProcessorsToCatchUp = noteProcessorsToCatchUp;
147
-
148
- if (!this.noteProcessorsToCatchUp.length) {
149
- // No note processors to catch up, nothing to do here,
150
- // but we return true to continue with the normal flow.
151
- return true;
152
- }
153
-
154
- // create a copy so that:
155
- // 1. we can modify the original array while iterating over it
156
- // 2. we don't need to serialize insertions into the array
157
- const catchUpGroup = this.noteProcessorsToCatchUp
158
- .slice()
159
- // sort by the block number they are lagging behind
160
- .sort((a, b) => a.status.syncedToBlock - b.status.syncedToBlock);
161
-
162
- // grab the note processor that is lagging behind the most
163
- const from = catchUpGroup[0].status.syncedToBlock + 1;
164
- // Ensuring that the note processor does not sync further than the main sync.
165
- limit = Math.min(limit, toBlockNumber - from + 1);
166
- // this.log(`Catching up ${catchUpGroup.length} note processors by up to ${limit} blocks starting at block ${from}`);
167
-
168
- if (limit < 1) {
169
- throw new Error(`Unexpected limit ${limit} for note processor catch up`);
170
- }
171
-
172
- try {
173
- const blocks = await this.node.getBlocks(from, limit);
174
- if (!blocks.length) {
175
- // This should never happen because this function should only be called when the note processor is lagging
176
- // behind main sync.
177
- throw new Error('No blocks in processor catch up mode');
178
- }
179
-
180
- for (const noteProcessor of catchUpGroup) {
181
- // find the index of the first block that the note processor is not yet synced to
182
- const index = blocks.findIndex(block => block.number > noteProcessor.status.syncedToBlock);
183
- if (index === -1) {
184
- // Due to the limit, we might not have fetched a new enough block for the note processor.
185
- // And since the group is sorted, we break as soon as we find a note processor
186
- // that needs blocks newer than the newest block we fetched.
187
- break;
188
- }
189
-
190
- this.log.debug(
191
- `Catching up note processor ${noteProcessor.account.toString()} by processing ${
192
- blocks.length - index
193
- } blocks`,
194
- );
195
- await noteProcessor.process(blocks.slice(index));
196
-
197
- if (noteProcessor.status.syncedToBlock === toBlockNumber) {
198
- // Note processor caught up, move it to `noteProcessors` from `noteProcessorsToCatchUp`.
199
- this.log.debug(`Note processor for ${noteProcessor.account.toString()} has caught up`, {
200
- eventName: 'note-processor-caught-up',
201
- account: noteProcessor.account.toString(),
202
- duration: noteProcessor.timer.ms(),
203
- dbSize: await this.db.estimateSize(),
204
- ...noteProcessor.stats,
205
- } satisfies NoteProcessorCaughtUpStats);
206
-
207
- this.noteProcessorsToCatchUp = this.noteProcessorsToCatchUp.filter(
208
- np => !np.account.equals(noteProcessor.account),
209
- );
210
- this.noteProcessors.push(noteProcessor);
211
- }
212
- }
213
-
214
- return true; // could be more work, immediately continue syncing
215
- } catch (err) {
216
- this.log.error(`Error in synchronizer workNoteProcessorCatchUp`, err);
217
- return false;
218
- }
219
- }
220
-
221
99
  private async setHeaderFromBlock(latestBlock: L2Block) {
222
100
  if (latestBlock.number < this.initialSyncBlockNumber) {
223
101
  return;
@@ -239,46 +117,6 @@ export class Synchronizer {
239
117
  this.log.info('Stopped');
240
118
  }
241
119
 
242
- /**
243
- * Add a new account to the Synchronizer with the specified private key.
244
- * Creates a NoteProcessor instance for the account and pushes it into the noteProcessors array.
245
- * The method resolves immediately after pushing the new note processor.
246
- *
247
- * @param publicKey - The public key for the account.
248
- * @param keyStore - The key store.
249
- * @param startingBlock - The block where to start scanning for notes for this accounts.
250
- * @returns A promise that resolves once the account is added to the Synchronizer.
251
- */
252
- public addAccount(account: CompleteAddress, keyStore: KeyStore, startingBlock: number) {
253
- const predicate = (x: NoteProcessor) => x.account.equals(account);
254
- const processor = this.noteProcessors.find(predicate) ?? this.noteProcessorsToCatchUp.find(predicate);
255
- if (processor) {
256
- return;
257
- }
258
-
259
- this.noteProcessorsToCatchUp.push(NoteProcessor.create(account, keyStore, this.db, this.node, startingBlock));
260
- }
261
-
262
- /**
263
- * Checks if the specified account is synchronized.
264
- * @param account - The aztec address for which to query the sync status.
265
- * @returns True if the account is fully synched, false otherwise.
266
- * @remarks Checks whether all the notes from all the blocks have been processed. If it is not the case, the
267
- * retrieved information from contracts might be old/stale (e.g. old token balance).
268
- * @throws If checking a sync status of account which is not registered.
269
- */
270
- public async isAccountStateSynchronized(account: AztecAddress) {
271
- const findByAccountAddress = (x: NoteProcessor) => x.account.address.equals(account);
272
- const processor =
273
- this.noteProcessors.find(findByAccountAddress) ?? this.noteProcessorsToCatchUp.find(findByAccountAddress);
274
- if (!processor) {
275
- throw new Error(
276
- `Checking if account is synched is not possible for ${account} because it is only registered as a recipient.`,
277
- );
278
- }
279
- return await processor.isSynchronized();
280
- }
281
-
282
120
  private getSynchedBlockNumber() {
283
121
  return this.db.getBlockNumber() ?? this.initialSyncBlockNumber;
284
122
  }
@@ -302,94 +140,6 @@ export class Synchronizer {
302
140
  const lastBlockNumber = this.getSynchedBlockNumber();
303
141
  return {
304
142
  blocks: lastBlockNumber,
305
- notes: Object.fromEntries(this.noteProcessors.map(n => [n.account.address.toString(), n.status.syncedToBlock])),
306
143
  };
307
144
  }
308
-
309
- /**
310
- * Returns the note processor stats.
311
- * @returns The note processor stats for notes for each public key being tracked.
312
- */
313
- public getSyncStats() {
314
- return Object.fromEntries(this.noteProcessors.map(n => [n.account.address.toString(), n.stats]));
315
- }
316
-
317
- /**
318
- * Retry decoding any deferred notes for the specified contract address.
319
- * @param contractAddress - the contract address that has just been added
320
- */
321
- public reprocessDeferredNotesForContract(contractAddress: AztecAddress): Promise<void> {
322
- return this.jobQueue.put(() => this.#reprocessDeferredNotesForContract(contractAddress));
323
- }
324
-
325
- async #reprocessDeferredNotesForContract(contractAddress: AztecAddress): Promise<void> {
326
- const deferredNotes = await this.db.getDeferredNotesByContract(contractAddress);
327
-
328
- // group deferred notes by txHash to properly deal with possible duplicates
329
- const txHashToDeferredNotes: Map<TxHash, DeferredNoteDao[]> = new Map();
330
- for (const note of deferredNotes) {
331
- const notesForTx = txHashToDeferredNotes.get(note.txHash) ?? [];
332
- notesForTx.push(note);
333
- txHashToDeferredNotes.set(note.txHash, notesForTx);
334
- }
335
-
336
- // keep track of decoded notes
337
- const incomingNotes: IncomingNoteDao[] = [];
338
-
339
- // now process each txHash
340
- for (const deferredNotes of txHashToDeferredNotes.values()) {
341
- // to be safe, try each note processor in case the deferred notes are for different accounts.
342
- for (const processor of this.noteProcessors) {
343
- const { incomingNotes: inNotes, outgoingNotes: outNotes } = await processor.decodeDeferredNotes(deferredNotes);
344
- incomingNotes.push(...inNotes);
345
-
346
- await this.db.addNotes(inNotes, outNotes, processor.account.address);
347
-
348
- inNotes.forEach(noteDao => {
349
- this.log.debug(
350
- `Decoded deferred incoming note under account ${processor.account.toString()} for contract ${
351
- noteDao.contractAddress
352
- } at slot ${noteDao.storageSlot} with nullifier ${noteDao.siloedNullifier.toString()}`,
353
- );
354
- });
355
-
356
- outNotes.forEach(noteDao => {
357
- this.log.debug(
358
- `Decoded deferred outgoing note under account ${processor.account.toString()} for contract ${
359
- noteDao.contractAddress
360
- } at slot ${noteDao.storageSlot}`,
361
- );
362
- });
363
- }
364
- }
365
-
366
- // now drop the deferred notes, and add the decoded notes
367
- await this.db.removeDeferredNotesByContract(contractAddress);
368
-
369
- await this.#removeNullifiedNotes(incomingNotes);
370
- }
371
-
372
- async #removeNullifiedNotes(notes: IncomingNoteDao[]) {
373
- // now group the decoded incoming notes by public key
374
- const addressPointToIncomingNotes: Map<PublicKey, IncomingNoteDao[]> = new Map();
375
- for (const noteDao of notes) {
376
- const notesForAddressPoint = addressPointToIncomingNotes.get(noteDao.addressPoint) ?? [];
377
- notesForAddressPoint.push(noteDao);
378
- addressPointToIncomingNotes.set(noteDao.addressPoint, notesForAddressPoint);
379
- }
380
-
381
- // now for each group, look for the nullifiers in the nullifier tree
382
- for (const [publicKey, notes] of addressPointToIncomingNotes.entries()) {
383
- const nullifiers = notes.map(n => n.siloedNullifier);
384
- const relevantNullifiers: Fr[] = [];
385
- for (const nullifier of nullifiers) {
386
- // NOTE: this leaks information about the nullifiers I'm interested in to the node.
387
- const found = await this.node.findLeafIndex('latest', MerkleTreeId.NULLIFIER_TREE, nullifier);
388
- if (found) {
389
- relevantNullifiers.push(nullifier);
390
- }
391
- }
392
- await this.db.removeNullifiedNotes(relevantNullifiers, publicKey);
393
- }
394
- }
395
145
  }
@@ -1,40 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- import { L1NotePayload, TxHash, UnencryptedTxL2Logs } from '@aztec/circuit-types';
4
- import { Fr, type PublicKey } from '@aztec/circuits.js';
5
- import { BufferReader } from '@aztec/foundation/serialize';
6
- /**
7
- * A note that is intended for us, but we cannot decode it yet because the contract is not yet in our database.
8
- *
9
- * So keep the state that we need to decode it later.
10
- */
11
- export declare class DeferredNoteDao {
12
- /** Address Point or OvpkM (depending on if incoming or outgoing) the note was encrypted with. */
13
- publicKey: PublicKey;
14
- /** The note payload delivered via L1. */
15
- payload: L1NotePayload;
16
- /** The hash of the tx the note was created in. Equal to the first nullifier */
17
- txHash: TxHash;
18
- /** New note hashes in this transaction, one of which belongs to this note */
19
- noteHashes: Fr[];
20
- /** The next available leaf index for the note hash tree for this transaction */
21
- dataStartIndexForTx: number;
22
- /** Unencrypted logs for the transaction (used to complete partial notes) */
23
- unencryptedLogs: UnencryptedTxL2Logs;
24
- constructor(
25
- /** Address Point or OvpkM (depending on if incoming or outgoing) the note was encrypted with. */
26
- publicKey: PublicKey,
27
- /** The note payload delivered via L1. */
28
- payload: L1NotePayload,
29
- /** The hash of the tx the note was created in. Equal to the first nullifier */
30
- txHash: TxHash,
31
- /** New note hashes in this transaction, one of which belongs to this note */
32
- noteHashes: Fr[],
33
- /** The next available leaf index for the note hash tree for this transaction */
34
- dataStartIndexForTx: number,
35
- /** Unencrypted logs for the transaction (used to complete partial notes) */
36
- unencryptedLogs: UnencryptedTxL2Logs);
37
- toBuffer(): Buffer;
38
- static fromBuffer(buffer: Buffer | BufferReader): DeferredNoteDao;
39
- }
40
- //# sourceMappingURL=deferred_note_dao.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deferred_note_dao.d.ts","sourceRoot":"","sources":["../../src/database/deferred_note_dao.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,EAAE,EAAS,KAAK,SAAS,EAAU,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAE9E;;;;GAIG;AACH,qBAAa,eAAe;IAExB,iGAAiG;IAC1F,SAAS,EAAE,SAAS;IAC3B,yCAAyC;IAClC,OAAO,EAAE,aAAa;IAC7B,+EAA+E;IACxE,MAAM,EAAE,MAAM;IACrB,6EAA6E;IACtE,UAAU,EAAE,EAAE,EAAE;IACvB,gFAAgF;IACzE,mBAAmB,EAAE,MAAM;IAClC,4EAA4E;IACrE,eAAe,EAAE,mBAAmB;;IAX3C,iGAAiG;IAC1F,SAAS,EAAE,SAAS;IAC3B,yCAAyC;IAClC,OAAO,EAAE,aAAa;IAC7B,+EAA+E;IACxE,MAAM,EAAE,MAAM;IACrB,6EAA6E;IACtE,UAAU,EAAE,EAAE,EAAE;IACvB,gFAAgF;IACzE,mBAAmB,EAAE,MAAM;IAClC,4EAA4E;IACrE,eAAe,EAAE,mBAAmB;IAG7C,QAAQ,IAAI,MAAM;IAUlB,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;CAWhD"}
@@ -1,38 +0,0 @@
1
- import { L1NotePayload, TxHash, UnencryptedTxL2Logs } from '@aztec/circuit-types';
2
- import { Fr, Point, Vector } from '@aztec/circuits.js';
3
- import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
- /**
5
- * A note that is intended for us, but we cannot decode it yet because the contract is not yet in our database.
6
- *
7
- * So keep the state that we need to decode it later.
8
- */
9
- export class DeferredNoteDao {
10
- constructor(
11
- /** Address Point or OvpkM (depending on if incoming or outgoing) the note was encrypted with. */
12
- publicKey,
13
- /** The note payload delivered via L1. */
14
- payload,
15
- /** The hash of the tx the note was created in. Equal to the first nullifier */
16
- txHash,
17
- /** New note hashes in this transaction, one of which belongs to this note */
18
- noteHashes,
19
- /** The next available leaf index for the note hash tree for this transaction */
20
- dataStartIndexForTx,
21
- /** Unencrypted logs for the transaction (used to complete partial notes) */
22
- unencryptedLogs) {
23
- this.publicKey = publicKey;
24
- this.payload = payload;
25
- this.txHash = txHash;
26
- this.noteHashes = noteHashes;
27
- this.dataStartIndexForTx = dataStartIndexForTx;
28
- this.unencryptedLogs = unencryptedLogs;
29
- }
30
- toBuffer() {
31
- return serializeToBuffer(this.publicKey, this.payload, this.txHash, new Vector(this.noteHashes), this.dataStartIndexForTx, this.unencryptedLogs);
32
- }
33
- static fromBuffer(buffer) {
34
- const reader = BufferReader.asReader(buffer);
35
- return new DeferredNoteDao(reader.readObject(Point), reader.readObject(L1NotePayload), reader.readObject(TxHash), reader.readVector(Fr), reader.readNumber(), reader.readObject(UnencryptedTxL2Logs));
36
- }
37
- }
38
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVmZXJyZWRfbm90ZV9kYW8uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZGF0YWJhc2UvZGVmZXJyZWRfbm90ZV9kYW8udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUNsRixPQUFPLEVBQUUsRUFBRSxFQUFFLEtBQUssRUFBa0IsTUFBTSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDdkUsT0FBTyxFQUFFLFlBQVksRUFBRSxpQkFBaUIsRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRTlFOzs7O0dBSUc7QUFDSCxNQUFNLE9BQU8sZUFBZTtJQUMxQjtJQUNFLGlHQUFpRztJQUMxRixTQUFvQjtJQUMzQix5Q0FBeUM7SUFDbEMsT0FBc0I7SUFDN0IsK0VBQStFO0lBQ3hFLE1BQWM7SUFDckIsNkVBQTZFO0lBQ3RFLFVBQWdCO0lBQ3ZCLGdGQUFnRjtJQUN6RSxtQkFBMkI7SUFDbEMsNEVBQTRFO0lBQ3JFLGVBQW9DO1FBVnBDLGNBQVMsR0FBVCxTQUFTLENBQVc7UUFFcEIsWUFBTyxHQUFQLE9BQU8sQ0FBZTtRQUV0QixXQUFNLEdBQU4sTUFBTSxDQUFRO1FBRWQsZUFBVSxHQUFWLFVBQVUsQ0FBTTtRQUVoQix3QkFBbUIsR0FBbkIsbUJBQW1CLENBQVE7UUFFM0Isb0JBQWUsR0FBZixlQUFlLENBQXFCO0lBQzFDLENBQUM7SUFFSixRQUFRO1FBQ04sT0FBTyxpQkFBaUIsQ0FDdEIsSUFBSSxDQUFDLFNBQVMsRUFDZCxJQUFJLENBQUMsT0FBTyxFQUNaLElBQUksQ0FBQyxNQUFNLEVBQ1gsSUFBSSxNQUFNLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxFQUMzQixJQUFJLENBQUMsbUJBQW1CLEVBQ3hCLElBQUksQ0FBQyxlQUFlLENBQ3JCLENBQUM7SUFDSixDQUFDO0lBQ0QsTUFBTSxDQUFDLFVBQVUsQ0FBQyxNQUE2QjtRQUM3QyxNQUFNLE1BQU0sR0FBRyxZQUFZLENBQUMsUUFBUSxDQUFDLE1BQU0sQ0FBQyxDQUFDO1FBQzdDLE9BQU8sSUFBSSxlQUFlLENBQ3hCLE1BQU0sQ0FBQyxVQUFVLENBQUMsS0FBSyxDQUFDLEVBQ3hCLE1BQU0sQ0FBQyxVQUFVLENBQUMsYUFBYSxDQUFDLEVBQ2hDLE1BQU0sQ0FBQyxVQUFVLENBQUMsTUFBTSxDQUFDLEVBQ3pCLE1BQU0sQ0FBQyxVQUFVLENBQUMsRUFBRSxDQUFDLEVBQ3JCLE1BQU0sQ0FBQyxVQUFVLEVBQUUsRUFDbkIsTUFBTSxDQUFDLFVBQVUsQ0FBQyxtQkFBbUIsQ0FBQyxDQUN2QyxDQUFDO0lBQ0osQ0FBQztDQUNGIn0=
@@ -1,2 +0,0 @@
1
- export * from './note_processor.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/note_processor/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './note_processor.js';
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbm90ZV9wcm9jZXNzb3IvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxxQkFBcUIsQ0FBQyJ9
@@ -1,83 +0,0 @@
1
- import { type AztecNode, type L2Block } from '@aztec/circuit-types';
2
- import { type NoteProcessorStats } from '@aztec/circuit-types/stats';
3
- import { type CompleteAddress } from '@aztec/circuits.js';
4
- import { type Logger } from '@aztec/foundation/log';
5
- import { Timer } from '@aztec/foundation/timer';
6
- import { type KeyStore } from '@aztec/key-store';
7
- import { type AcirSimulator } from '@aztec/simulator';
8
- import { type DeferredNoteDao } from '../database/deferred_note_dao.js';
9
- import { type IncomingNoteDao } from '../database/incoming_note_dao.js';
10
- import { type PxeDatabase } from '../database/index.js';
11
- import { type OutgoingNoteDao } from '../database/outgoing_note_dao.js';
12
- /**
13
- * NoteProcessor is responsible for decrypting logs and converting them to notes via their originating contracts
14
- * before storing them against their owner.
15
- */
16
- export declare class NoteProcessor {
17
- readonly account: CompleteAddress;
18
- private keyStore;
19
- private db;
20
- private node;
21
- private startingBlock;
22
- private simulator;
23
- private log;
24
- /** Keeps track of processing time since an instance is created. */
25
- readonly timer: Timer;
26
- /** Stats accumulated for this processor. */
27
- readonly stats: NoteProcessorStats;
28
- private constructor();
29
- static create(account: CompleteAddress, keyStore: KeyStore, db: PxeDatabase, node: AztecNode, startingBlock?: number, simulator?: AcirSimulator, log?: Logger): NoteProcessor;
30
- /**
31
- * Check if the NoteProcessor is synchronized with the remote block number.
32
- * The function queries the remote block number from the AztecNode and compares it with the syncedToBlock value in the NoteProcessor.
33
- * If the values are equal, then the NoteProcessor is considered to be synchronized, otherwise not.
34
- *
35
- * @returns A boolean indicating whether the NoteProcessor is synchronized with the remote block number or not.
36
- */
37
- isSynchronized(): Promise<boolean>;
38
- /**
39
- * Returns synchronization status (ie up to which block has been synced ) for this note processor.
40
- */
41
- get status(): {
42
- syncedToBlock: number;
43
- };
44
- private getSyncedToBlock;
45
- /**
46
- * Extracts new user-relevant notes from the information contained in the provided L2 blocks and encrypted logs.
47
- *
48
- * @param blocks - L2 blocks to be processed.
49
- * @returns A promise that resolves once the processing is completed.
50
- */
51
- process(blocks: L2Block[]): Promise<void>;
52
- /**
53
- * Process the given blocks and their associated transaction auxiliary data.
54
- * This function updates the database with information about new transactions,
55
- * user-pertaining transaction indices, and auxiliary data. It also removes nullified
56
- * transaction auxiliary data from the database. This function keeps track of new nullifiers
57
- * and ensures all other transactions are updated with newly settled block information.
58
- *
59
- * @param blocksAndNotes - Array of objects containing L2 blocks, user-pertaining transaction indices, and NoteDaos.
60
- */
61
- private processBlocksAndNotes;
62
- /**
63
- * Store the given deferred notes in the database for later decoding.
64
- *
65
- * @param deferredIncomingNotes - incoming notes that are intended for us but we couldn't process because the contract was not found.
66
- * @param deferredOutgoingNotes - outgoing notes that we couldn't process because the contract was not found.
67
- */
68
- private processDeferredNotes;
69
- /**
70
- * Retry decoding the given deferred notes because we now have the contract code.
71
- *
72
- * @param deferredNoteDaos - notes that we have previously deferred because the contract was not found
73
- * @returns An object containing arrays of incoming and outgoing notes that were successfully decoded.
74
- *
75
- * @remarks Caller is responsible for making sure that we have the contract for the
76
- * deferred notes provided: we will not retry notes that fail again.
77
- */
78
- decodeDeferredNotes(deferredNoteDaos: DeferredNoteDao[]): Promise<{
79
- incomingNotes: IncomingNoteDao[];
80
- outgoingNotes: OutgoingNoteDao[];
81
- }>;
82
- }
83
- //# sourceMappingURL=note_processor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"note_processor.d.ts","sourceRoot":"","sources":["../../src/note_processor/note_processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAiB,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EACL,KAAK,eAAe,EAKrB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,KAAK,MAAM,EAAqB,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAgBxE;;;GAGG;AACH,qBAAa,aAAa;aAiBN,OAAO,EAAE,eAAe;IACxC,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,GAAG;IAtBb,mEAAmE;IACnE,SAAgB,KAAK,EAAE,KAAK,CAAe;IAE3C,4CAA4C;IAC5C,SAAgB,KAAK,EAAE,kBAAkB,CASvC;IAEF,OAAO;WAUO,MAAM,CAClB,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,WAAW,EACf,IAAI,EAAE,SAAS,EACf,aAAa,GAAE,MAA6B,EAC5C,SAAS,gBAAuC,EAChD,GAAG,SAA4C;IAKjD;;;;;;OAMG;IACU,cAAc;IAK3B;;OAEG;IACH,IAAW,MAAM;;MAEhB;IAED,OAAO,CAAC,gBAAgB;IAIxB;;;;;OAKG;IACU,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA4HtD;;;;;;;;OAQG;YACW,qBAAqB;IA8BnC;;;;;OAKG;YACW,oBAAoB;IAuBlC;;;;;;;;OAQG;IACU,mBAAmB,CAAC,gBAAgB,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;QAC7E,aAAa,EAAE,eAAe,EAAE,CAAC;QACjC,aAAa,EAAE,eAAe,EAAE,CAAC;KAClC,CAAC;CAgDH"}