@aztec/archiver 4.0.0-nightly.20260113 → 4.0.0-nightly.20260115

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 (174) hide show
  1. package/README.md +139 -22
  2. package/dest/archiver.d.ts +134 -0
  3. package/dest/archiver.d.ts.map +1 -0
  4. package/dest/archiver.js +767 -0
  5. package/dest/{archiver/config.d.ts → config.d.ts} +9 -1
  6. package/dest/config.d.ts.map +1 -0
  7. package/dest/{archiver/config.js → config.js} +9 -0
  8. package/dest/{archiver/errors.d.ts → errors.d.ts} +1 -1
  9. package/dest/errors.d.ts.map +1 -0
  10. package/dest/factory.d.ts +5 -6
  11. package/dest/factory.d.ts.map +1 -1
  12. package/dest/factory.js +82 -5
  13. package/dest/index.d.ts +10 -4
  14. package/dest/index.d.ts.map +1 -1
  15. package/dest/index.js +8 -3
  16. package/dest/interfaces.d.ts +9 -0
  17. package/dest/interfaces.d.ts.map +1 -0
  18. package/dest/interfaces.js +3 -0
  19. package/dest/{archiver/l1 → l1}/bin/retrieve-calldata.d.ts +1 -1
  20. package/dest/l1/bin/retrieve-calldata.d.ts.map +1 -0
  21. package/dest/{archiver/l1 → l1}/calldata_retriever.d.ts +2 -2
  22. package/dest/l1/calldata_retriever.d.ts.map +1 -0
  23. package/dest/l1/data_retrieval.d.ts +88 -0
  24. package/dest/l1/data_retrieval.d.ts.map +1 -0
  25. package/dest/{archiver/l1 → l1}/data_retrieval.js +32 -51
  26. package/dest/{archiver/l1 → l1}/debug_tx.d.ts +1 -1
  27. package/dest/l1/debug_tx.d.ts.map +1 -0
  28. package/dest/{archiver/l1 → l1}/spire_proposer.d.ts +1 -1
  29. package/dest/l1/spire_proposer.d.ts.map +1 -0
  30. package/dest/{archiver/l1 → l1}/trace_tx.d.ts +1 -1
  31. package/dest/l1/trace_tx.d.ts.map +1 -0
  32. package/dest/l1/types.d.ts +12 -0
  33. package/dest/l1/types.d.ts.map +1 -0
  34. package/dest/{archiver/l1 → l1}/validate_trace.d.ts +1 -1
  35. package/dest/l1/validate_trace.d.ts.map +1 -0
  36. package/dest/modules/data_source_base.d.ts +83 -0
  37. package/dest/modules/data_source_base.d.ts.map +1 -0
  38. package/dest/modules/data_source_base.js +301 -0
  39. package/dest/modules/data_store_updater.d.ts +46 -0
  40. package/dest/modules/data_store_updater.d.ts.map +1 -0
  41. package/dest/modules/data_store_updater.js +216 -0
  42. package/dest/modules/instrumentation.d.ts +37 -0
  43. package/dest/modules/instrumentation.d.ts.map +1 -0
  44. package/dest/modules/l1_synchronizer.d.ts +67 -0
  45. package/dest/modules/l1_synchronizer.d.ts.map +1 -0
  46. package/dest/modules/l1_synchronizer.js +1064 -0
  47. package/dest/{archiver → modules}/validation.d.ts +1 -1
  48. package/dest/modules/validation.d.ts.map +1 -0
  49. package/dest/{archiver/kv_archiver_store → store}/block_store.d.ts +2 -2
  50. package/dest/store/block_store.d.ts.map +1 -0
  51. package/dest/{archiver/kv_archiver_store → store}/block_store.js +1 -1
  52. package/dest/store/contract_class_store.d.ts +18 -0
  53. package/dest/store/contract_class_store.d.ts.map +1 -0
  54. package/dest/{archiver/kv_archiver_store → store}/contract_class_store.js +1 -1
  55. package/dest/store/contract_instance_store.d.ts +24 -0
  56. package/dest/store/contract_instance_store.d.ts.map +1 -0
  57. package/dest/{archiver/kv_archiver_store → store}/contract_instance_store.js +1 -1
  58. package/dest/{archiver/archiver_store.d.ts → store/kv_archiver_store.d.ts} +143 -139
  59. package/dest/store/kv_archiver_store.d.ts.map +1 -0
  60. package/dest/{archiver/kv_archiver_store → store}/kv_archiver_store.js +157 -49
  61. package/dest/{archiver/kv_archiver_store → store}/log_store.d.ts +1 -1
  62. package/dest/store/log_store.d.ts.map +1 -0
  63. package/dest/{archiver/kv_archiver_store → store}/message_store.d.ts +1 -1
  64. package/dest/store/message_store.d.ts.map +1 -0
  65. package/dest/{archiver/structs → structs}/data_retrieval.d.ts +1 -1
  66. package/dest/structs/data_retrieval.d.ts.map +1 -0
  67. package/dest/structs/inbox_message.d.ts +15 -0
  68. package/dest/structs/inbox_message.d.ts.map +1 -0
  69. package/dest/{archiver/structs → structs}/published.d.ts +1 -1
  70. package/dest/structs/published.d.ts.map +1 -0
  71. package/dest/test/fake_l1_state.d.ts +173 -0
  72. package/dest/test/fake_l1_state.d.ts.map +1 -0
  73. package/dest/test/fake_l1_state.js +364 -0
  74. package/dest/test/index.d.ts +2 -1
  75. package/dest/test/index.d.ts.map +1 -1
  76. package/dest/test/index.js +1 -0
  77. package/dest/test/mock_structs.d.ts +76 -2
  78. package/dest/test/mock_structs.d.ts.map +1 -1
  79. package/dest/test/mock_structs.js +133 -2
  80. package/package.json +15 -17
  81. package/src/archiver.ts +522 -0
  82. package/src/{archiver/config.ts → config.ts} +11 -0
  83. package/src/factory.ts +118 -6
  84. package/src/index.ts +10 -3
  85. package/src/interfaces.ts +9 -0
  86. package/src/{archiver/l1 → l1}/calldata_retriever.ts +1 -1
  87. package/src/{archiver/l1 → l1}/data_retrieval.ts +52 -69
  88. package/src/modules/data_source_base.ts +439 -0
  89. package/src/modules/data_store_updater.ts +318 -0
  90. package/src/modules/l1_synchronizer.ts +870 -0
  91. package/src/{archiver/kv_archiver_store → store}/block_store.ts +1 -1
  92. package/src/{archiver/kv_archiver_store → store}/contract_class_store.ts +1 -1
  93. package/src/{archiver/kv_archiver_store → store}/contract_instance_store.ts +1 -1
  94. package/src/{archiver/kv_archiver_store → store}/kv_archiver_store.ts +170 -8
  95. package/src/test/fake_l1_state.ts +561 -0
  96. package/src/test/index.ts +1 -0
  97. package/src/test/mock_structs.ts +247 -2
  98. package/dest/archiver/archiver.d.ts +0 -307
  99. package/dest/archiver/archiver.d.ts.map +0 -1
  100. package/dest/archiver/archiver.js +0 -2102
  101. package/dest/archiver/archiver_store.d.ts.map +0 -1
  102. package/dest/archiver/archiver_store.js +0 -4
  103. package/dest/archiver/archiver_store_test_suite.d.ts +0 -8
  104. package/dest/archiver/archiver_store_test_suite.d.ts.map +0 -1
  105. package/dest/archiver/archiver_store_test_suite.js +0 -2770
  106. package/dest/archiver/config.d.ts.map +0 -1
  107. package/dest/archiver/errors.d.ts.map +0 -1
  108. package/dest/archiver/index.d.ts +0 -7
  109. package/dest/archiver/index.d.ts.map +0 -1
  110. package/dest/archiver/index.js +0 -4
  111. package/dest/archiver/instrumentation.d.ts +0 -37
  112. package/dest/archiver/instrumentation.d.ts.map +0 -1
  113. package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
  114. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +0 -18
  115. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +0 -1
  116. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +0 -24
  117. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +0 -1
  118. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +0 -159
  119. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +0 -1
  120. package/dest/archiver/kv_archiver_store/log_store.d.ts.map +0 -1
  121. package/dest/archiver/kv_archiver_store/message_store.d.ts.map +0 -1
  122. package/dest/archiver/l1/bin/retrieve-calldata.d.ts.map +0 -1
  123. package/dest/archiver/l1/calldata_retriever.d.ts.map +0 -1
  124. package/dest/archiver/l1/data_retrieval.d.ts +0 -90
  125. package/dest/archiver/l1/data_retrieval.d.ts.map +0 -1
  126. package/dest/archiver/l1/debug_tx.d.ts.map +0 -1
  127. package/dest/archiver/l1/spire_proposer.d.ts.map +0 -1
  128. package/dest/archiver/l1/trace_tx.d.ts.map +0 -1
  129. package/dest/archiver/l1/types.d.ts +0 -12
  130. package/dest/archiver/l1/types.d.ts.map +0 -1
  131. package/dest/archiver/l1/validate_trace.d.ts.map +0 -1
  132. package/dest/archiver/structs/data_retrieval.d.ts.map +0 -1
  133. package/dest/archiver/structs/inbox_message.d.ts +0 -15
  134. package/dest/archiver/structs/inbox_message.d.ts.map +0 -1
  135. package/dest/archiver/structs/published.d.ts.map +0 -1
  136. package/dest/archiver/validation.d.ts.map +0 -1
  137. package/dest/rpc/index.d.ts +0 -9
  138. package/dest/rpc/index.d.ts.map +0 -1
  139. package/dest/rpc/index.js +0 -15
  140. package/src/archiver/archiver.ts +0 -2265
  141. package/src/archiver/archiver_store.ts +0 -380
  142. package/src/archiver/archiver_store_test_suite.ts +0 -2842
  143. package/src/archiver/index.ts +0 -6
  144. package/src/rpc/index.ts +0 -16
  145. /package/dest/{archiver/errors.js → errors.js} +0 -0
  146. /package/dest/{archiver/l1 → l1}/bin/retrieve-calldata.js +0 -0
  147. /package/dest/{archiver/l1 → l1}/calldata_retriever.js +0 -0
  148. /package/dest/{archiver/l1 → l1}/debug_tx.js +0 -0
  149. /package/dest/{archiver/l1 → l1}/spire_proposer.js +0 -0
  150. /package/dest/{archiver/l1 → l1}/trace_tx.js +0 -0
  151. /package/dest/{archiver/l1 → l1}/types.js +0 -0
  152. /package/dest/{archiver/l1 → l1}/validate_trace.js +0 -0
  153. /package/dest/{archiver → modules}/instrumentation.js +0 -0
  154. /package/dest/{archiver → modules}/validation.js +0 -0
  155. /package/dest/{archiver/kv_archiver_store → store}/log_store.js +0 -0
  156. /package/dest/{archiver/kv_archiver_store → store}/message_store.js +0 -0
  157. /package/dest/{archiver/structs → structs}/data_retrieval.js +0 -0
  158. /package/dest/{archiver/structs → structs}/inbox_message.js +0 -0
  159. /package/dest/{archiver/structs → structs}/published.js +0 -0
  160. /package/src/{archiver/errors.ts → errors.ts} +0 -0
  161. /package/src/{archiver/l1 → l1}/README.md +0 -0
  162. /package/src/{archiver/l1 → l1}/bin/retrieve-calldata.ts +0 -0
  163. /package/src/{archiver/l1 → l1}/debug_tx.ts +0 -0
  164. /package/src/{archiver/l1 → l1}/spire_proposer.ts +0 -0
  165. /package/src/{archiver/l1 → l1}/trace_tx.ts +0 -0
  166. /package/src/{archiver/l1 → l1}/types.ts +0 -0
  167. /package/src/{archiver/l1 → l1}/validate_trace.ts +0 -0
  168. /package/src/{archiver → modules}/instrumentation.ts +0 -0
  169. /package/src/{archiver → modules}/validation.ts +0 -0
  170. /package/src/{archiver/kv_archiver_store → store}/log_store.ts +0 -0
  171. /package/src/{archiver/kv_archiver_store → store}/message_store.ts +0 -0
  172. /package/src/{archiver/structs → structs}/data_retrieval.ts +0 -0
  173. /package/src/{archiver/structs → structs}/inbox_message.ts +0 -0
  174. /package/src/{archiver/structs → structs}/published.ts +0 -0
@@ -76,7 +76,7 @@ export type CheckpointData = {
76
76
  };
77
77
 
78
78
  /**
79
- * LMDB implementation of the ArchiverDataStore interface.
79
+ * LMDB-based block storage for the archiver.
80
80
  */
81
81
  export class BlockStore {
82
82
  /** Map block number to block data */
@@ -12,7 +12,7 @@ import type {
12
12
  import { Vector } from '@aztec/stdlib/types';
13
13
 
14
14
  /**
15
- * LMDB implementation of the ArchiverDataStore interface.
15
+ * LMDB-based contract class storage for the archiver.
16
16
  */
17
17
  export class ContractClassStore {
18
18
  #contractClasses: AztecAsyncMap<string, Buffer>;
@@ -12,7 +12,7 @@ import type { UInt64 } from '@aztec/stdlib/types';
12
12
  type ContractInstanceUpdateKey = [string, string] | [string, string, number];
13
13
 
14
14
  /**
15
- * LMDB implementation of the ArchiverDataStore interface.
15
+ * LMDB-based contract instance storage for the archiver.
16
16
  */
17
17
  export class ContractInstanceStore {
18
18
  #contractInstances: AztecAsyncMap<string, Buffer>;
@@ -23,7 +23,6 @@ import type { UInt64 } from '@aztec/stdlib/types';
23
23
 
24
24
  import { join } from 'path';
25
25
 
26
- import type { ArchiverDataStore, ArchiverL1SynchPoint } from '../archiver_store.js';
27
26
  import type { InboxMessage } from '../structs/inbox_message.js';
28
27
  import { BlockStore, type CheckpointData } from './block_store.js';
29
28
  import { ContractClassStore } from './contract_class_store.js';
@@ -36,9 +35,20 @@ export const MAX_FUNCTION_SIGNATURES = 1000;
36
35
  export const MAX_FUNCTION_NAME_LEN = 256;
37
36
 
38
37
  /**
39
- * LMDB implementation of the ArchiverDataStore interface.
38
+ * Represents the latest L1 block processed by the archiver for various objects in L2.
40
39
  */
41
- export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSource {
40
+ export type ArchiverL1SynchPoint = {
41
+ /** Number of the last L1 block that added a new L2 checkpoint metadata. */
42
+ blocksSynchedTo?: bigint;
43
+ /** Last L1 block checked for L1 to L2 messages. */
44
+ messagesSynchedTo?: L1BlockId;
45
+ };
46
+
47
+ /**
48
+ * LMDB-based data store for the archiver.
49
+ * Stores all archiver data including blocks, logs, contract classes/instances, and L1 to L2 messages.
50
+ */
51
+ export class KVArchiverDataStore implements ContractDataSource {
42
52
  public static readonly SCHEMA_VERSION = ARCHIVER_DB_VERSION;
43
53
 
44
54
  #blockStore: BlockStore;
@@ -62,6 +72,7 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
62
72
  this.#contractInstanceStore = new ContractInstanceStore(db);
63
73
  }
64
74
 
75
+ /** Opens a new transaction to the underlying store and runs all operations within it. */
65
76
  public transactionAsync<T>(callback: () => Promise<T>): Promise<T> {
66
77
  return this.db.transactionAsync(callback);
67
78
  }
@@ -79,19 +90,23 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
79
90
  return this.getContractInstance(address, timestamp);
80
91
  }
81
92
 
93
+ /** Backups the archiver db to the target folder. Returns the path to the db file. */
82
94
  public async backupTo(path: string, compress = true): Promise<string> {
83
95
  await this.db.backupTo(path, compress);
84
96
  return join(path, 'data.mdb');
85
97
  }
86
98
 
99
+ /** Closes the underlying data store. */
87
100
  public close() {
88
101
  return this.db.close();
89
102
  }
90
103
 
104
+ /** Looks up a public function name given a selector. */
91
105
  getDebugFunctionName(_address: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
92
106
  return Promise.resolve(this.functionNames.get(selector.toString()));
93
107
  }
94
108
 
109
+ /** Register a public function signature, so it can be looked up by selector. */
95
110
  async registerContractFunctionSignatures(signatures: string[]): Promise<void> {
96
111
  for (const sig of signatures) {
97
112
  if (this.functionNames.size > MAX_FUNCTION_SIGNATURES) {
@@ -106,14 +121,25 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
106
121
  }
107
122
  }
108
123
 
124
+ /**
125
+ * Returns a contract class given its id, or undefined if not exists.
126
+ * @param id - Id of the contract class.
127
+ */
109
128
  getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
110
129
  return this.#contractClassStore.getContractClass(id);
111
130
  }
112
131
 
132
+ /** Returns the list of all class ids known by the archiver. */
113
133
  getContractClassIds(): Promise<Fr[]> {
114
134
  return this.#contractClassStore.getContractClassIds();
115
135
  }
116
136
 
137
+ /**
138
+ * Returns a contract instance given its address and the given timestamp, or undefined if not exists.
139
+ * @param address - Address of the contract.
140
+ * @param timestamp - Timestamp to get the contract instance at. Contract updates might change the instance.
141
+ * @returns The contract instance or undefined if not found.
142
+ */
117
143
  getContractInstance(address: AztecAddress, timestamp: UInt64): Promise<ContractInstanceWithAddress | undefined> {
118
144
  return this.#contractInstanceStore.getContractInstance(address, timestamp);
119
145
  }
@@ -122,6 +148,13 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
122
148
  return this.#contractInstanceStore.getContractInstanceDeploymentBlockNumber(address);
123
149
  }
124
150
 
151
+ /**
152
+ * Add new contract classes from an L2 block to the store's list.
153
+ * @param data - List of contract classes to be added.
154
+ * @param bytecodeCommitments - Bytecode commitments for the contract classes.
155
+ * @param blockNumber - Number of the L2 block the contracts were registered in.
156
+ * @returns True if the operation is successful.
157
+ */
125
158
  async addContractClasses(
126
159
  data: ContractClassPublic[],
127
160
  bytecodeCommitments: Fr[],
@@ -144,6 +177,7 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
144
177
  return this.#contractClassStore.getBytecodeCommitment(contractClassId);
145
178
  }
146
179
 
180
+ /** Adds private functions to a contract class. */
147
181
  addFunctions(
148
182
  contractClassId: Fr,
149
183
  privateFunctions: ExecutablePrivateFunctionWithMembershipProof[],
@@ -152,6 +186,12 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
152
186
  return this.#contractClassStore.addFunctions(contractClassId, privateFunctions, utilityFunctions);
153
187
  }
154
188
 
189
+ /**
190
+ * Add new contract instances from an L2 block to the store's list.
191
+ * @param data - List of contract instances to be added.
192
+ * @param blockNumber - Number of the L2 block the instances were deployed in.
193
+ * @returns True if the operation is successful.
194
+ */
155
195
  async addContractInstances(data: ContractInstanceWithAddress[], blockNumber: BlockNumber): Promise<boolean> {
156
196
  return (await Promise.all(data.map(c => this.#contractInstanceStore.addContractInstance(c, blockNumber)))).every(
157
197
  Boolean,
@@ -162,6 +202,12 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
162
202
  return (await Promise.all(data.map(c => this.#contractInstanceStore.deleteContractInstance(c)))).every(Boolean);
163
203
  }
164
204
 
205
+ /**
206
+ * Add new contract instance updates
207
+ * @param data - List of contract updates to be added.
208
+ * @param timestamp - Timestamp at which the updates were scheduled.
209
+ * @returns True if the operation is successful.
210
+ */
165
211
  async addContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[], timestamp: UInt64): Promise<boolean> {
166
212
  return (
167
213
  await Promise.all(
@@ -190,9 +236,19 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
190
236
  return this.#blockStore.addBlocks(blocks, opts);
191
237
  }
192
238
 
239
+ /**
240
+ * Returns an array of checkpoint objects
241
+ * @param from The first checkpoint number to be retrieved
242
+ * @param limit The maximum number of checkpoints to retrieve
243
+ * @returns The array of requested checkpoint data objects
244
+ */
193
245
  getRangeOfCheckpoints(from: CheckpointNumber, limit: number): Promise<CheckpointData[]> {
194
246
  return this.#blockStore.getRangeOfCheckpoints(from, limit);
195
247
  }
248
+ /**
249
+ * Returns the number of the latest block
250
+ * @returns The number of the latest block
251
+ */
196
252
  getLatestBlockNumber(): Promise<BlockNumber> {
197
253
  return this.#blockStore.getLatestBlockNumber();
198
254
  }
@@ -208,51 +264,100 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
208
264
  return this.#blockStore.unwindCheckpoints(from, checkpointsToUnwind);
209
265
  }
210
266
 
267
+ /**
268
+ * Appends new checkpoints, and their blocks to the store's collection
269
+ * @param checkpoints The collection of checkpoints to be added
270
+ * @returns True if the operation is successful
271
+ */
211
272
  addCheckpoints(checkpoints: PublishedCheckpoint[]): Promise<boolean> {
212
273
  return this.#blockStore.addCheckpoints(checkpoints);
213
274
  }
214
275
 
276
+ /**
277
+ * Returns the block for the given number, or undefined if not exists.
278
+ * @param number - The block number to return.
279
+ */
215
280
  getCheckpointedBlock(number: BlockNumber): Promise<CheckpointedL2Block | undefined> {
216
281
  return this.#blockStore.getCheckpointedBlock(number);
217
282
  }
283
+ /**
284
+ * Returns the block for the given hash, or undefined if not exists.
285
+ * @param blockHash - The block hash to return.
286
+ */
218
287
  getCheckpointedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined> {
219
288
  return this.#blockStore.getCheckpointedBlockByHash(blockHash);
220
289
  }
290
+ /**
291
+ * Returns the block for the given archive root, or undefined if not exists.
292
+ * @param archive - The archive root to return.
293
+ */
221
294
  getCheckpointedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined> {
222
295
  return this.#blockStore.getCheckpointedBlockByArchive(archive);
223
296
  }
297
+ /**
298
+ * Returns the block for the given number, or undefined if not exists.
299
+ * @param number - The block number to return.
300
+ */
224
301
  getBlock(number: BlockNumber): Promise<L2BlockNew | undefined> {
225
302
  return this.#blockStore.getBlock(number);
226
303
  }
304
+ /**
305
+ * Returns the block for the given hash, or undefined if not exists.
306
+ * @param blockHash - The block hash to return.
307
+ */
227
308
  getBlockByHash(blockHash: Fr): Promise<L2BlockNew | undefined> {
228
309
  return this.#blockStore.getBlockByHash(L2BlockHash.fromField(blockHash));
229
310
  }
311
+ /**
312
+ * Returns the block for the given archive root, or undefined if not exists.
313
+ * @param archive - The archive root to return.
314
+ */
230
315
  getBlockByArchive(archive: Fr): Promise<L2BlockNew | undefined> {
231
316
  return this.#blockStore.getBlockByArchive(archive);
232
317
  }
233
- getBlocks(from: BlockNumber, limit: BlockNumber): Promise<L2BlockNew[]> {
318
+
319
+ /**
320
+ * Gets up to `limit` amount of published L2 blocks starting from `from`.
321
+ * @param from - Number of the first block to return (inclusive).
322
+ * @param limit - The number of blocks to return.
323
+ * @returns The requested L2 blocks.
324
+ */
325
+ getBlocks(from: BlockNumber, limit: number): Promise<L2BlockNew[]> {
234
326
  return toArray(this.#blockStore.getBlocks(from, limit));
235
327
  }
236
328
 
329
+ /**
330
+ * Gets up to `limit` amount of checkpointed L2 blocks starting from `from`.
331
+ * @param from - Number of the first block to return (inclusive).
332
+ * @param limit - The number of blocks to return.
333
+ * @returns The requested checkpointed L2 blocks.
334
+ */
237
335
  getCheckpointedBlocks(from: BlockNumber, limit: number): Promise<CheckpointedL2Block[]> {
238
336
  return toArray(this.#blockStore.getCheckpointedBlocks(from, limit));
239
337
  }
240
338
 
241
339
  /**
242
- * Gets up to `limit` amount of L2 blocks headers starting from `from`.
243
- *
340
+ * Gets up to `limit` amount of L2 block headers starting from `from`.
244
341
  * @param start - Number of the first block to return (inclusive).
245
342
  * @param limit - The number of blocks to return.
246
- * @returns The requested L2 blocks
343
+ * @returns The requested L2 block headers.
247
344
  */
248
345
  getBlockHeaders(start: BlockNumber, limit: number): Promise<BlockHeader[]> {
249
346
  return toArray(this.#blockStore.getBlockHeaders(start, limit));
250
347
  }
251
348
 
349
+ /**
350
+ * Returns the block header for the given hash, or undefined if not exists.
351
+ * @param blockHash - The block hash to return.
352
+ */
252
353
  getBlockHeaderByHash(blockHash: Fr): Promise<BlockHeader | undefined> {
253
354
  return this.#blockStore.getBlockHeaderByHash(L2BlockHash.fromField(blockHash));
254
355
  }
255
356
 
357
+ /**
358
+ * Returns the block header for the given archive root, or undefined if not exists.
359
+ * @param archive - The archive root to return.
360
+ */
256
361
  getBlockHeaderByArchive(archive: Fr): Promise<BlockHeader | undefined> {
257
362
  return this.#blockStore.getBlockHeaderByArchive(archive);
258
363
  }
@@ -288,10 +393,15 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
288
393
  return this.#logStore.deleteLogs(blocks);
289
394
  }
290
395
 
396
+ /**
397
+ * Get the total number of L1 to L2 messages
398
+ * @returns The number of L1 to L2 messages in the store
399
+ */
291
400
  getTotalL1ToL2MessageCount(): Promise<bigint> {
292
401
  return this.#messageStore.getTotalL1ToL2MessageCount();
293
402
  }
294
403
 
404
+ /** Returns the last L1 to L2 message stored. */
295
405
  getLastL1ToL2Message(): Promise<InboxMessage | undefined> {
296
406
  return this.#messageStore.getLastMessage();
297
407
  }
@@ -299,6 +409,7 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
299
409
  /**
300
410
  * Append L1 to L2 messages to the store.
301
411
  * @param messages - The L1 to L2 messages to be added to the store.
412
+ * @returns True if the operation is successful.
302
413
  */
303
414
  addL1ToL2Messages(messages: InboxMessage[]): Promise<void> {
304
415
  return this.#messageStore.addL1ToL2Messages(messages);
@@ -322,6 +433,10 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
322
433
  return this.#messageStore.getL1ToL2Messages(checkpointNumber);
323
434
  }
324
435
 
436
+ /**
437
+ * Gets all private logs that match any of the `tags`. For each tag, an array of matching logs is returned. An empty
438
+ * array implies no logs match that tag.
439
+ */
325
440
  getPrivateLogsByTags(tags: SiloedTag[]): Promise<TxScopedL2Log[][]> {
326
441
  try {
327
442
  return this.#logStore.getPrivateLogsByTags(tags);
@@ -330,6 +445,10 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
330
445
  }
331
446
  }
332
447
 
448
+ /**
449
+ * Gets all public logs that match any of the `tags` from the specified contract. For each tag, an array of matching
450
+ * logs is returned. An empty array implies no logs match that tag.
451
+ */
333
452
  getPublicLogsByTagsFromContract(contractAddress: AztecAddress, tags: Tag[]): Promise<TxScopedL2Log[][]> {
334
453
  try {
335
454
  return this.#logStore.getPublicLogsByTagsFromContract(contractAddress, tags);
@@ -364,10 +483,18 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
364
483
  }
365
484
  }
366
485
 
486
+ /**
487
+ * Gets the number of the latest proven checkpoint processed.
488
+ * @returns The number of the latest proven checkpoint processed.
489
+ */
367
490
  getProvenCheckpointNumber(): Promise<CheckpointNumber> {
368
491
  return this.#blockStore.getProvenCheckpointNumber();
369
492
  }
370
493
 
494
+ /**
495
+ * Stores the number of the latest proven checkpoint processed.
496
+ * @param checkpointNumber - The number of the latest proven checkpoint processed.
497
+ */
371
498
  async setProvenCheckpointNumber(checkpointNumber: CheckpointNumber) {
372
499
  await this.#blockStore.setProvenCheckpointNumber(checkpointNumber);
373
500
  }
@@ -376,16 +503,23 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
376
503
  await this.#blockStore.setSynchedL1BlockNumber(l1BlockNumber);
377
504
  }
378
505
 
506
+ /**
507
+ * Stores the l1 block that messages have been synched until
508
+ */
379
509
  async setMessageSynchedL1Block(l1Block: L1BlockId) {
380
510
  await this.#messageStore.setSynchedL1Block(l1Block);
381
511
  }
382
512
 
513
+ /**
514
+ * Returns the number of the most recent proven block
515
+ * @returns The number of the most recent proven block
516
+ */
383
517
  getProvenBlockNumber(): Promise<BlockNumber> {
384
518
  return this.#blockStore.getProvenBlockNumber();
385
519
  }
386
520
 
387
521
  /**
388
- * Gets the last L1 block number processed by the archiver
522
+ * Gets the synch point of the archiver
389
523
  */
390
524
  async getSynchPoint(): Promise<ArchiverL1SynchPoint> {
391
525
  const [blocksSynchedTo, messagesSynchedTo] = await Promise.all([
@@ -398,44 +532,72 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
398
532
  };
399
533
  }
400
534
 
535
+ /** Estimates the size of the store in bytes. */
401
536
  public estimateSize(): Promise<StoreSize> {
402
537
  return this.db.estimateSize();
403
538
  }
404
539
 
540
+ /** Deletes all L1 to L2 messages up until (excluding) the target checkpoint number. */
405
541
  public rollbackL1ToL2MessagesToCheckpoint(targetCheckpointNumber: CheckpointNumber): Promise<void> {
406
542
  return this.#messageStore.rollbackL1ToL2MessagesToCheckpoint(targetCheckpointNumber);
407
543
  }
408
544
 
545
+ /** Returns an async iterator to all L1 to L2 messages on the range. */
409
546
  public iterateL1ToL2Messages(range: CustomRange<bigint> = {}): AsyncIterableIterator<InboxMessage> {
410
547
  return this.#messageStore.iterateL1ToL2Messages(range);
411
548
  }
412
549
 
550
+ /** Removes all L1 to L2 messages starting from the given index (inclusive). */
413
551
  public removeL1ToL2Messages(startIndex: bigint): Promise<void> {
414
552
  return this.#messageStore.removeL1ToL2Messages(startIndex);
415
553
  }
416
554
 
555
+ /** Returns the last synced validation status of the pending chain. */
417
556
  public getPendingChainValidationStatus(): Promise<ValidateCheckpointResult | undefined> {
418
557
  return this.#blockStore.getPendingChainValidationStatus();
419
558
  }
420
559
 
560
+ /** Sets the last synced validation status of the pending chain. */
421
561
  public setPendingChainValidationStatus(status: ValidateCheckpointResult | undefined): Promise<void> {
422
562
  return this.#blockStore.setPendingChainValidationStatus(status);
423
563
  }
424
564
 
565
+ /**
566
+ * Gets the number of the latest L2 block processed.
567
+ * @returns The number of the latest L2 block processed.
568
+ */
425
569
  public getCheckpointedL2BlockNumber(): Promise<BlockNumber> {
426
570
  return this.#blockStore.getCheckpointedL2BlockNumber();
427
571
  }
572
+ /**
573
+ * Gets the number of the latest published checkpoint processed.
574
+ * @returns The number of the latest published checkpoint processed
575
+ */
428
576
  public getSynchedCheckpointNumber(): Promise<CheckpointNumber> {
429
577
  return this.#blockStore.getLatestCheckpointNumber();
430
578
  }
579
+ /**
580
+ * Stores the l1 block number that checkpoints have been synched until
581
+ * @param l1BlockNumber - The l1 block number
582
+ */
431
583
  async setCheckpointSynchedL1BlockNumber(l1BlockNumber: bigint): Promise<void> {
432
584
  await this.#blockStore.setSynchedL1BlockNumber(l1BlockNumber);
433
585
  }
434
586
 
587
+ /**
588
+ * Retrieves all blocks for the requested checkpoint
589
+ * @param checkpointNumber Retrieves all blocks for the given checkpoint
590
+ * @returns The collection of blocks for the requested checkpoint if available (undefined otherwise)
591
+ */
435
592
  getBlocksForCheckpoint(checkpointNumber: CheckpointNumber): Promise<L2BlockNew[] | undefined> {
436
593
  return this.#blockStore.getBlocksForCheckpoint(checkpointNumber);
437
594
  }
438
595
 
596
+ /**
597
+ * Returns checkpoint data for the requested checkpoint number
598
+ * @param checkpointNumber - The checkpoint requested
599
+ * @returns The checkpoint data or undefined if not found
600
+ */
439
601
  getCheckpointData(checkpointNumber: CheckpointNumber): Promise<CheckpointData | undefined> {
440
602
  return this.#blockStore.getCheckpointData(checkpointNumber);
441
603
  }