@aztec/archiver 0.0.1-commit.d3ec352c → 0.0.1-commit.fcb71a6

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 (122) hide show
  1. package/dest/archiver/archiver.d.ts +84 -70
  2. package/dest/archiver/archiver.d.ts.map +1 -1
  3. package/dest/archiver/archiver.js +439 -228
  4. package/dest/archiver/archiver_store.d.ts +95 -43
  5. package/dest/archiver/archiver_store.d.ts.map +1 -1
  6. package/dest/archiver/archiver_store_test_suite.d.ts +1 -1
  7. package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
  8. package/dest/archiver/archiver_store_test_suite.js +1847 -366
  9. package/dest/archiver/config.d.ts +5 -4
  10. package/dest/archiver/config.d.ts.map +1 -1
  11. package/dest/archiver/config.js +10 -3
  12. package/dest/archiver/errors.d.ts +25 -1
  13. package/dest/archiver/errors.d.ts.map +1 -1
  14. package/dest/archiver/errors.js +37 -0
  15. package/dest/archiver/index.d.ts +2 -2
  16. package/dest/archiver/index.d.ts.map +1 -1
  17. package/dest/archiver/instrumentation.d.ts +3 -1
  18. package/dest/archiver/instrumentation.d.ts.map +1 -1
  19. package/dest/archiver/instrumentation.js +11 -0
  20. package/dest/archiver/kv_archiver_store/block_store.d.ts +50 -18
  21. package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
  22. package/dest/archiver/kv_archiver_store/block_store.js +320 -84
  23. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +2 -2
  24. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
  25. package/dest/archiver/kv_archiver_store/contract_class_store.js +1 -1
  26. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +2 -2
  27. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +1 -1
  28. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +40 -51
  29. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
  30. package/dest/archiver/kv_archiver_store/kv_archiver_store.js +65 -48
  31. package/dest/archiver/kv_archiver_store/log_store.d.ts +12 -16
  32. package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
  33. package/dest/archiver/kv_archiver_store/log_store.js +148 -84
  34. package/dest/archiver/kv_archiver_store/message_store.d.ts +6 -5
  35. package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
  36. package/dest/archiver/kv_archiver_store/message_store.js +15 -14
  37. package/dest/archiver/l1/bin/retrieve-calldata.d.ts +3 -0
  38. package/dest/archiver/l1/bin/retrieve-calldata.d.ts.map +1 -0
  39. package/dest/archiver/l1/bin/retrieve-calldata.js +149 -0
  40. package/dest/archiver/l1/calldata_retriever.d.ts +112 -0
  41. package/dest/archiver/l1/calldata_retriever.d.ts.map +1 -0
  42. package/dest/archiver/l1/calldata_retriever.js +471 -0
  43. package/dest/archiver/l1/data_retrieval.d.ts +90 -0
  44. package/dest/archiver/l1/data_retrieval.d.ts.map +1 -0
  45. package/dest/archiver/{data_retrieval.js → l1/data_retrieval.js} +50 -106
  46. package/dest/archiver/l1/debug_tx.d.ts +19 -0
  47. package/dest/archiver/l1/debug_tx.d.ts.map +1 -0
  48. package/dest/archiver/l1/debug_tx.js +73 -0
  49. package/dest/archiver/l1/spire_proposer.d.ts +70 -0
  50. package/dest/archiver/l1/spire_proposer.d.ts.map +1 -0
  51. package/dest/archiver/l1/spire_proposer.js +157 -0
  52. package/dest/archiver/l1/trace_tx.d.ts +97 -0
  53. package/dest/archiver/l1/trace_tx.d.ts.map +1 -0
  54. package/dest/archiver/l1/trace_tx.js +91 -0
  55. package/dest/archiver/l1/types.d.ts +12 -0
  56. package/dest/archiver/l1/types.d.ts.map +1 -0
  57. package/dest/archiver/l1/types.js +3 -0
  58. package/dest/archiver/l1/validate_trace.d.ts +29 -0
  59. package/dest/archiver/l1/validate_trace.d.ts.map +1 -0
  60. package/dest/archiver/l1/validate_trace.js +150 -0
  61. package/dest/archiver/structs/inbox_message.d.ts +4 -4
  62. package/dest/archiver/structs/inbox_message.d.ts.map +1 -1
  63. package/dest/archiver/structs/inbox_message.js +6 -6
  64. package/dest/archiver/structs/published.d.ts +1 -2
  65. package/dest/archiver/structs/published.d.ts.map +1 -1
  66. package/dest/factory.d.ts +1 -1
  67. package/dest/factory.js +1 -1
  68. package/dest/index.d.ts +2 -2
  69. package/dest/index.d.ts.map +1 -1
  70. package/dest/index.js +1 -1
  71. package/dest/test/mock_archiver.d.ts +4 -5
  72. package/dest/test/mock_archiver.d.ts.map +1 -1
  73. package/dest/test/mock_archiver.js +5 -9
  74. package/dest/test/mock_l1_to_l2_message_source.d.ts +5 -6
  75. package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
  76. package/dest/test/mock_l1_to_l2_message_source.js +7 -11
  77. package/dest/test/mock_l2_block_source.d.ts +11 -4
  78. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  79. package/dest/test/mock_l2_block_source.js +18 -17
  80. package/dest/test/mock_structs.d.ts +3 -2
  81. package/dest/test/mock_structs.d.ts.map +1 -1
  82. package/dest/test/mock_structs.js +9 -9
  83. package/package.json +15 -14
  84. package/src/archiver/archiver.ts +567 -290
  85. package/src/archiver/archiver_store.ts +104 -42
  86. package/src/archiver/archiver_store_test_suite.ts +1895 -347
  87. package/src/archiver/config.ts +15 -10
  88. package/src/archiver/errors.ts +64 -0
  89. package/src/archiver/index.ts +1 -1
  90. package/src/archiver/instrumentation.ts +14 -0
  91. package/src/archiver/kv_archiver_store/block_store.ts +435 -95
  92. package/src/archiver/kv_archiver_store/contract_class_store.ts +1 -1
  93. package/src/archiver/kv_archiver_store/contract_instance_store.ts +1 -1
  94. package/src/archiver/kv_archiver_store/kv_archiver_store.ts +81 -66
  95. package/src/archiver/kv_archiver_store/log_store.ts +208 -99
  96. package/src/archiver/kv_archiver_store/message_store.ts +21 -18
  97. package/src/archiver/l1/README.md +98 -0
  98. package/src/archiver/l1/bin/retrieve-calldata.ts +182 -0
  99. package/src/archiver/l1/calldata_retriever.ts +641 -0
  100. package/src/archiver/{data_retrieval.ts → l1/data_retrieval.ts} +96 -161
  101. package/src/archiver/l1/debug_tx.ts +99 -0
  102. package/src/archiver/l1/spire_proposer.ts +160 -0
  103. package/src/archiver/l1/trace_tx.ts +128 -0
  104. package/src/archiver/l1/types.ts +13 -0
  105. package/src/archiver/l1/validate_trace.ts +211 -0
  106. package/src/archiver/structs/inbox_message.ts +7 -8
  107. package/src/archiver/structs/published.ts +0 -1
  108. package/src/factory.ts +1 -1
  109. package/src/index.ts +1 -1
  110. package/src/test/fixtures/debug_traceTransaction-multicall3.json +88 -0
  111. package/src/test/fixtures/debug_traceTransaction-multiplePropose.json +153 -0
  112. package/src/test/fixtures/debug_traceTransaction-proxied.json +122 -0
  113. package/src/test/fixtures/trace_transaction-multicall3.json +65 -0
  114. package/src/test/fixtures/trace_transaction-multiplePropose.json +319 -0
  115. package/src/test/fixtures/trace_transaction-proxied.json +128 -0
  116. package/src/test/fixtures/trace_transaction-randomRevert.json +216 -0
  117. package/src/test/mock_archiver.ts +6 -11
  118. package/src/test/mock_l1_to_l2_message_source.ts +6 -11
  119. package/src/test/mock_l2_block_source.ts +22 -18
  120. package/src/test/mock_structs.ts +10 -10
  121. package/dest/archiver/data_retrieval.d.ts +0 -80
  122. package/dest/archiver/data_retrieval.d.ts.map +0 -1
@@ -1,10 +1,11 @@
1
- import type { L1BlockId } from '@aztec/ethereum';
2
- import { BlockNumber } from '@aztec/foundation/branded-types';
3
- import type { Fr } from '@aztec/foundation/fields';
1
+ import type { L1BlockId } from '@aztec/ethereum/l1-types';
2
+ import type { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
3
+ import type { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import type { CustomRange } from '@aztec/kv-store';
5
5
  import type { FunctionSelector } from '@aztec/stdlib/abi';
6
6
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
- import type { L2Block, ValidateBlockResult } from '@aztec/stdlib/block';
7
+ import type { CheckpointedL2Block, L2BlockNew, ValidateBlockResult } from '@aztec/stdlib/block';
8
+ import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
8
9
  import type {
9
10
  ContractClassPublic,
10
11
  ContractInstanceUpdateWithAddress,
@@ -13,18 +14,18 @@ import type {
13
14
  UtilityFunctionWithMembershipProof,
14
15
  } from '@aztec/stdlib/contract';
15
16
  import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
16
- import type { LogFilter, PrivateLog, TxScopedL2Log } from '@aztec/stdlib/logs';
17
+ import type { LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
17
18
  import { BlockHeader, type IndexedTxEffect, type TxHash, type TxReceipt } from '@aztec/stdlib/tx';
18
19
  import type { UInt64 } from '@aztec/stdlib/types';
19
20
 
21
+ import type { CheckpointData } from './kv_archiver_store/block_store.js';
20
22
  import type { InboxMessage } from './structs/inbox_message.js';
21
- import type { PublishedL2Block } from './structs/published.js';
22
23
 
23
24
  /**
24
25
  * Represents the latest L1 block processed by the archiver for various objects in L2.
25
26
  */
26
27
  export type ArchiverL1SynchPoint = {
27
- /** Number of the last L1 block that added a new L2 block metadata. */
28
+ /** Number of the last L1 block that added a new L2 checkpoint metadata. */
28
29
  blocksSynchedTo?: bigint;
29
30
  /** Last L1 block checked for L1 to L2 messages. */
30
31
  messagesSynchedTo?: L1BlockId;
@@ -45,34 +46,87 @@ export interface ArchiverDataStore {
45
46
  * @param opts.force - If true, the blocks will be added even if they have gaps.
46
47
  * @returns True if the operation is successful.
47
48
  */
48
- addBlocks(blocks: PublishedL2Block[], opts?: { force?: boolean }): Promise<boolean>;
49
+ addBlocks(blocks: L2BlockNew[], opts?: { force?: boolean }): Promise<boolean>;
49
50
 
50
51
  /**
51
- * Unwinds blocks from the database
52
+ * Appends new checkpoints, and their blocks to the store's collection
53
+ * @param checkpoints The collectionn of checkpoints to be added
54
+ * @returns True if the operation is successful
55
+ */
56
+ addCheckpoints(checkpoints: PublishedCheckpoint[]): Promise<boolean>;
57
+
58
+ /**
59
+ * Retrieves all blocks for the requested chackpoint
60
+ * @param checkpointNumber Retreieves all blocks for the given checkpoint
61
+ * @returns The collection of blocks for the requested checkpoint if available (undefined otherwise)
62
+ */
63
+ getBlocksForCheckpoint(checkpointNumber: CheckpointNumber): Promise<L2BlockNew[] | undefined>;
64
+
65
+ /**
66
+ * Returns an array of checkpoint objects
67
+ * @param from The first checkpoint number to be retrieved
68
+ * @param limit The maximum number of chackpoints to retrieve
69
+ * @returns The array of requested checkpoint data objects
70
+ */
71
+ getRangeOfCheckpoints(from: CheckpointNumber, limit: number): Promise<CheckpointData[]>;
72
+
73
+ /**
74
+ * Unwinds checkpoints from the database
52
75
  * @param from - The tip of the chain, passed for verification purposes,
53
76
  * ensuring that we don't end up deleting something we did not intend
54
- * @param blocksToUnwind - The number of blocks we are to unwind
77
+ * @param checkpointsToUnwind - The number of checkpoints we are to unwind
55
78
  * @returns True if the operation is successful
56
79
  */
57
- unwindBlocks(from: BlockNumber, blocksToUnwind: number): Promise<boolean>;
80
+ unwindCheckpoints(from: CheckpointNumber, checkpointsToUnwind: number): Promise<boolean>;
81
+
82
+ /**
83
+ * Returns the block for the given number, or undefined if not exists.
84
+ * @param number - The block number to return.
85
+ */
86
+ getCheckpointedBlock(number: number): Promise<CheckpointedL2Block | undefined>;
87
+
88
+ /**
89
+ * Returns the block for the given hash, or undefined if not exists.
90
+ * @param blockHash - The block hash to return.
91
+ */
92
+ getCheckpointedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined>;
93
+
94
+ /**
95
+ * Returns the block for the given archive root, or undefined if not exists.
96
+ * @param archive - The archive root to return.
97
+ */
98
+ getCheckpointedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined>;
99
+
100
+ /**
101
+ * Returns checkpoint data for the requested checkpoint number
102
+ * @param checkpointNumber - The checkpoint requested
103
+ * @returns The checkpoint data or undefined if not found
104
+ */
105
+ getCheckpointData(checkpointNumber: CheckpointNumber): Promise<CheckpointData | undefined>;
106
+
107
+ /**
108
+ * Returns the number of the latest block
109
+ * @returns The number of the latest block
110
+ */
111
+ getLatestBlockNumber(): Promise<BlockNumber>;
58
112
 
59
113
  /**
60
114
  * Returns the block for the given number, or undefined if not exists.
61
115
  * @param number - The block number to return.
62
116
  */
63
- getPublishedBlock(number: BlockNumber): Promise<PublishedL2Block | undefined>;
117
+ getBlock(number: number): Promise<L2BlockNew | undefined>;
64
118
 
65
119
  /**
66
120
  * Returns the block for the given hash, or undefined if not exists.
67
121
  * @param blockHash - The block hash to return.
68
122
  */
69
- getPublishedBlockByHash(blockHash: Fr): Promise<PublishedL2Block | undefined>;
123
+ getBlockByHash(blockHash: Fr): Promise<L2BlockNew | undefined>;
70
124
 
71
125
  /**
72
126
  * Returns the block for the given archive root, or undefined if not exists.
73
127
  * @param archive - The archive root to return.
74
128
  */
75
- getPublishedBlockByArchive(archive: Fr): Promise<PublishedL2Block | undefined>;
129
+ getBlockByArchive(archive: Fr): Promise<L2BlockNew | undefined>;
76
130
 
77
131
  /**
78
132
  * Gets up to `limit` amount of published L2 blocks starting from `from`.
@@ -80,7 +134,7 @@ export interface ArchiverDataStore {
80
134
  * @param limit - The number of blocks to return.
81
135
  * @returns The requested L2 blocks.
82
136
  */
83
- getPublishedBlocks(from: BlockNumber, limit: number): Promise<PublishedL2Block[]>;
137
+ getBlocks(from: number, limit: number): Promise<L2BlockNew[]>;
84
138
 
85
139
  /**
86
140
  * Gets up to `limit` amount of L2 block headers starting from `from`.
@@ -121,8 +175,8 @@ export interface ArchiverDataStore {
121
175
  * @param blocks - The blocks for which to add the logs.
122
176
  * @returns True if the operation is successful.
123
177
  */
124
- addLogs(blocks: L2Block[]): Promise<boolean>;
125
- deleteLogs(blocks: L2Block[]): Promise<boolean>;
178
+ addLogs(blocks: L2BlockNew[]): Promise<boolean>;
179
+ deleteLogs(blocks: L2BlockNew[]): Promise<boolean>;
126
180
 
127
181
  /**
128
182
  * Append L1 to L2 messages to the store.
@@ -132,11 +186,11 @@ export interface ArchiverDataStore {
132
186
  addL1ToL2Messages(messages: InboxMessage[]): Promise<void>;
133
187
 
134
188
  /**
135
- * Gets L1 to L2 message (to be) included in a given block.
136
- * @param blockNumber - L2 block number to get messages for.
189
+ * Gets L1 to L2 message (to be) included in a given checkpoint.
190
+ * @param checkpointNumber - Checkpoint number to get messages for.
137
191
  * @returns The L1 to L2 messages/leaves of the messages subtree (throws if not found).
138
192
  */
139
- getL1ToL2Messages(blockNumber: BlockNumber): Promise<Fr[]>;
193
+ getL1ToL2Messages(checkpointNumber: CheckpointNumber): Promise<Fr[]>;
140
194
 
141
195
  /**
142
196
  * Gets the L1 to L2 message index in the L1 to L2 message tree.
@@ -152,21 +206,17 @@ export interface ArchiverDataStore {
152
206
  getTotalL1ToL2MessageCount(): Promise<bigint>;
153
207
 
154
208
  /**
155
- * Retrieves all private logs from up to `limit` blocks, starting from the block number `from`.
156
- * @param from - The block number from which to begin retrieving logs.
157
- * @param limit - The maximum number of blocks to retrieve logs from.
158
- * @returns An array of private logs from the specified range of blocks.
209
+ /**
210
+ * Gets all private logs that match any of the `tags`. For each tag, an array of matching logs is returned. An empty
211
+ * array implies no logs match that tag.
159
212
  */
160
- getPrivateLogs(from: BlockNumber, limit: number): Promise<PrivateLog[]>;
213
+ getPrivateLogsByTags(tags: SiloedTag[]): Promise<TxScopedL2Log[][]>;
161
214
 
162
215
  /**
163
- * Gets all logs that match any of the received tags (i.e. logs with their first field equal to a tag).
164
- * @param tags - The tags to filter the logs by.
165
- * @param logsPerTag - The number of logs to return per tag. Defaults to everything
166
- * @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
167
- * that tag.
216
+ * Gets all public logs that match any of the `tags` from the specified contract. For each tag, an array of matching
217
+ * logs is returned. An empty array implies no logs match that tag.
168
218
  */
169
- getLogsByTags(tags: Fr[], logsPerTag?: number): Promise<TxScopedL2Log[][]>;
219
+ getPublicLogsByTagsFromContract(contractAddress: AztecAddress, tags: Tag[]): Promise<TxScopedL2Log[][]>;
170
220
 
171
221
  /**
172
222
  * Gets public logs based on the provided filter.
@@ -186,25 +236,37 @@ export interface ArchiverDataStore {
186
236
  * Gets the number of the latest L2 block processed.
187
237
  * @returns The number of the latest L2 block processed.
188
238
  */
189
- getSynchedL2BlockNumber(): Promise<BlockNumber>;
239
+ getCheckpointedL2BlockNumber(): Promise<BlockNumber>;
240
+
241
+ /**
242
+ * Gets the number of the latest published checkpoint processed.
243
+ * @returns The number of the latest published checkpoint processed
244
+ */
245
+ getSynchedCheckpointNumber(): Promise<CheckpointNumber>;
246
+
247
+ /**
248
+ * Gets the number of the latest proven checkpoint processed.
249
+ * @returns The number of the latest proven checkpoint processed.
250
+ */
251
+ getProvenCheckpointNumber(): Promise<CheckpointNumber>;
190
252
 
191
253
  /**
192
- * Gets the number of the latest proven L2 block processed.
193
- * @returns The number of the latest proven L2 block processed.
254
+ * Returns the number of the most recent proven block
255
+ * @returns The number of the most recent proven block
194
256
  */
195
- getProvenL2BlockNumber(): Promise<BlockNumber>;
257
+ getProvenBlockNumber(): Promise<BlockNumber>;
196
258
 
197
259
  /**
198
- * Stores the number of the latest proven L2 block processed.
199
- * @param l2BlockNumber - The number of the latest proven L2 block processed.
260
+ * Stores the number of the latest proven checkpoint processed.
261
+ * @param checkpointNumber - The number of the latest proven checkpoint processed.
200
262
  */
201
- setProvenL2BlockNumber(l2BlockNumber: BlockNumber): Promise<void>;
263
+ setProvenCheckpointNumber(checkpointNumber: CheckpointNumber): Promise<void>;
202
264
 
203
265
  /**
204
- * Stores the l1 block number that blocks have been synched until
266
+ * Stores the l1 block number that checkpoints have been synched until
205
267
  * @param l1BlockNumber - The l1 block number
206
268
  */
207
- setBlockSynchedL1BlockNumber(l1BlockNumber: bigint): Promise<void>;
269
+ setCheckpointSynchedL1BlockNumber(l1BlockNumber: bigint): Promise<void>;
208
270
 
209
271
  /**
210
272
  * Stores the l1 block that messages have been synched until
@@ -290,8 +352,8 @@ export interface ArchiverDataStore {
290
352
  /** Closes the underlying data store. */
291
353
  close(): Promise<void>;
292
354
 
293
- /** Deletes all L1 to L2 messages up until (excluding) the target L2 block number. */
294
- rollbackL1ToL2MessagesToL2Block(targetBlockNumber: BlockNumber): Promise<void>;
355
+ /** Deletes all L1 to L2 messages up until (excluding) the target checkpoint number. */
356
+ rollbackL1ToL2MessagesToCheckpoint(targetCheckpointNumber: CheckpointNumber): Promise<void>;
295
357
 
296
358
  /** Returns an async iterator to all L1 to L2 messages on the range. */
297
359
  iterateL1ToL2Messages(range?: CustomRange<bigint>): AsyncIterableIterator<InboxMessage>;