@aztec/archiver 0.55.1 → 0.57.0

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 (78) hide show
  1. package/README.md +1 -1
  2. package/dest/archiver/archiver.d.ts +27 -25
  3. package/dest/archiver/archiver.d.ts.map +1 -1
  4. package/dest/archiver/archiver.js +391 -169
  5. package/dest/archiver/archiver_store.d.ts +47 -23
  6. package/dest/archiver/archiver_store.d.ts.map +1 -1
  7. package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
  8. package/dest/archiver/archiver_store_test_suite.js +75 -42
  9. package/dest/archiver/config.js +6 -6
  10. package/dest/archiver/data_retrieval.d.ts +32 -5
  11. package/dest/archiver/data_retrieval.d.ts.map +1 -1
  12. package/dest/archiver/data_retrieval.js +126 -16
  13. package/dest/archiver/epoch_helpers.d.ts +15 -0
  14. package/dest/archiver/epoch_helpers.d.ts.map +1 -0
  15. package/dest/archiver/epoch_helpers.js +23 -0
  16. package/dest/archiver/kv_archiver_store/block_store.d.ts +22 -3
  17. package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
  18. package/dest/archiver/kv_archiver_store/block_store.js +75 -12
  19. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +2 -1
  20. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
  21. package/dest/archiver/kv_archiver_store/contract_class_store.js +11 -4
  22. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +1 -0
  23. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +1 -1
  24. package/dest/archiver/kv_archiver_store/contract_instance_store.js +4 -1
  25. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +31 -23
  26. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
  27. package/dest/archiver/kv_archiver_store/kv_archiver_store.js +65 -38
  28. package/dest/archiver/kv_archiver_store/log_store.d.ts +4 -5
  29. package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
  30. package/dest/archiver/kv_archiver_store/log_store.js +18 -14
  31. package/dest/archiver/kv_archiver_store/message_store.d.ts +2 -0
  32. package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
  33. package/dest/archiver/kv_archiver_store/message_store.js +18 -8
  34. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +1 -0
  35. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts.map +1 -1
  36. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.js +4 -1
  37. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +23 -39
  38. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +1 -1
  39. package/dest/archiver/memory_archiver_store/memory_archiver_store.js +132 -91
  40. package/dest/index.d.ts +0 -1
  41. package/dest/index.d.ts.map +1 -1
  42. package/dest/index.js +2 -2
  43. package/dest/test/index.d.ts +2 -0
  44. package/dest/test/index.d.ts.map +1 -0
  45. package/dest/test/index.js +2 -0
  46. package/dest/test/mock_l2_block_source.d.ts +73 -0
  47. package/dest/test/mock_l2_block_source.d.ts.map +1 -0
  48. package/dest/test/mock_l2_block_source.js +134 -0
  49. package/package.json +15 -11
  50. package/src/archiver/archiver.ts +531 -248
  51. package/src/archiver/archiver_store.ts +53 -31
  52. package/src/archiver/archiver_store_test_suite.ts +93 -81
  53. package/src/archiver/config.ts +5 -5
  54. package/src/archiver/data_retrieval.ts +189 -30
  55. package/src/archiver/epoch_helpers.ts +26 -0
  56. package/src/archiver/kv_archiver_store/block_store.ts +87 -12
  57. package/src/archiver/kv_archiver_store/contract_class_store.ts +18 -5
  58. package/src/archiver/kv_archiver_store/contract_instance_store.ts +4 -0
  59. package/src/archiver/kv_archiver_store/kv_archiver_store.ts +74 -47
  60. package/src/archiver/kv_archiver_store/log_store.ts +18 -18
  61. package/src/archiver/kv_archiver_store/message_store.ts +18 -5
  62. package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +4 -0
  63. package/src/archiver/memory_archiver_store/memory_archiver_store.ts +155 -108
  64. package/src/index.ts +1 -2
  65. package/src/test/index.ts +1 -0
  66. package/src/test/mock_l2_block_source.ts +165 -0
  67. package/dest/archiver/eth_log_handlers.d.ts +0 -59
  68. package/dest/archiver/eth_log_handlers.d.ts.map +0 -1
  69. package/dest/archiver/eth_log_handlers.js +0 -155
  70. package/dest/archiver/kv_archiver_store/block_body_store.d.ts +0 -34
  71. package/dest/archiver/kv_archiver_store/block_body_store.d.ts.map +0 -1
  72. package/dest/archiver/kv_archiver_store/block_body_store.js +0 -65
  73. package/dest/archiver/kv_archiver_store/proven_store.d.ts +0 -14
  74. package/dest/archiver/kv_archiver_store/proven_store.d.ts.map +0 -1
  75. package/dest/archiver/kv_archiver_store/proven_store.js +0 -30
  76. package/src/archiver/eth_log_handlers.ts +0 -213
  77. package/src/archiver/kv_archiver_store/block_body_store.ts +0 -74
  78. package/src/archiver/kv_archiver_store/proven_store.ts +0 -34
@@ -1,74 +0,0 @@
1
- import { Body } from '@aztec/circuit-types';
2
- import { createDebugLogger } from '@aztec/foundation/log';
3
- import { type AztecKVStore, type AztecMap, type AztecSingleton } from '@aztec/kv-store';
4
-
5
- import { type DataRetrieval } from '../structs/data_retrieval.js';
6
-
7
- export class BlockBodyStore {
8
- /** Map block body hash to block body */
9
- #blockBodies: AztecMap<string, Buffer>;
10
-
11
- /** Stores L1 block number in which the last processed L2 block body was included */
12
- #lastSynchedL1Block: AztecSingleton<bigint>;
13
-
14
- constructor(private db: AztecKVStore, private log = createDebugLogger('aztec:archiver:block_body_store')) {
15
- this.#blockBodies = db.openMap('archiver_block_bodies');
16
- this.#lastSynchedL1Block = db.openSingleton('archiver_block_bodies_last_synched_l1_block');
17
- }
18
-
19
- /**
20
- * Append new block bodies to the store's map.
21
- * @param blockBodies - The L2 block bodies to be added to the store.
22
- * @returns True if the operation is successful.
23
- */
24
- addBlockBodies(blockBodies: DataRetrieval<Body>): Promise<boolean> {
25
- return this.db.transaction(() => {
26
- for (const body of blockBodies.retrievedData) {
27
- void this.#blockBodies.set(body.getTxsEffectsHash().toString('hex'), body.toBuffer());
28
- }
29
- void this.#lastSynchedL1Block.set(blockBodies.lastProcessedL1BlockNumber);
30
- return true;
31
- });
32
- }
33
-
34
- /**
35
- * Gets a list of L2 block bodies with its associated txsEffectsHashes
36
- * @param txsEffectsHashes - The txsEffectsHashes list that corresponds to the blockBodies we want to retrieve
37
- * @returns The requested L2 block bodies
38
- */
39
- async getBlockBodies(txsEffectsHashes: Buffer[]): Promise<(Body | undefined)[]> {
40
- const blockBodiesBuffer = await this.db.transaction(() =>
41
- txsEffectsHashes.map(txsEffectsHash => this.#blockBodies.get(txsEffectsHash.toString('hex'))),
42
- );
43
-
44
- const blockBodies: (Body | undefined)[] = [];
45
- for (let i = 0; i < blockBodiesBuffer.length; i++) {
46
- const blockBodyBuffer = blockBodiesBuffer[i];
47
- if (blockBodyBuffer === undefined) {
48
- this.log.warn(`Block body buffer is undefined for txsEffectsHash: ${txsEffectsHashes[i].toString('hex')}`);
49
- }
50
- blockBodies.push(blockBodyBuffer ? Body.fromBuffer(blockBodyBuffer) : undefined);
51
- }
52
-
53
- return blockBodies;
54
- }
55
-
56
- /**
57
- * Gets an L2 block body.
58
- * @param txsEffectsHash - The txHash of the block body to return
59
- * @returns The requested L2 block body
60
- */
61
- getBlockBody(txsEffectsHash: Buffer): Body | undefined {
62
- const blockBody = this.#blockBodies.get(txsEffectsHash.toString('hex'));
63
-
64
- return blockBody && Body.fromBuffer(blockBody);
65
- }
66
-
67
- /**
68
- * Gets the last L1 block number in which a L2 block body was included
69
- * @returns The L1 block number
70
- */
71
- getSynchedL1BlockNumber(): bigint | undefined {
72
- return this.#lastSynchedL1Block.get();
73
- }
74
- }
@@ -1,34 +0,0 @@
1
- import { type AztecKVStore, type AztecSingleton } from '@aztec/kv-store';
2
-
3
- import { type SingletonDataRetrieval } from '../structs/data_retrieval.js';
4
-
5
- export class ProvenStore {
6
- /** Stores L1 block number in which the last processed L2 block was included */
7
- #lastSynchedL1Block: AztecSingleton<bigint>;
8
-
9
- /** Stores last proven L2 block number */
10
- #lastProvenL2Block: AztecSingleton<number>;
11
-
12
- constructor(private db: AztecKVStore) {
13
- this.#lastSynchedL1Block = db.openSingleton('archiver_last_l1_block_proven_logs');
14
- this.#lastProvenL2Block = db.openSingleton('archiver_last_proven_l2_block');
15
- }
16
-
17
- /**
18
- * Gets the most recent L1 block processed.
19
- */
20
- getSynchedL1BlockNumber(): bigint | undefined {
21
- return this.#lastSynchedL1Block.get();
22
- }
23
-
24
- getProvenL2BlockNumber(): number {
25
- return this.#lastProvenL2Block.get() ?? 0;
26
- }
27
-
28
- async setProvenL2BlockNumber(blockNumber: SingletonDataRetrieval<number>) {
29
- await this.db.transaction(() => {
30
- void this.#lastProvenL2Block.set(blockNumber.retrievedData);
31
- void this.#lastSynchedL1Block.set(blockNumber.lastProcessedL1BlockNumber);
32
- });
33
- }
34
- }