@aztec/archiver 0.0.0-test.1 → 0.0.1-commit.03f7ef2

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 (151) hide show
  1. package/README.md +27 -6
  2. package/dest/archiver/archiver.d.ts +201 -94
  3. package/dest/archiver/archiver.d.ts.map +1 -1
  4. package/dest/archiver/archiver.js +1141 -396
  5. package/dest/archiver/archiver_store.d.ts +171 -83
  6. package/dest/archiver/archiver_store.d.ts.map +1 -1
  7. package/dest/archiver/archiver_store_test_suite.d.ts +1 -1
  8. package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
  9. package/dest/archiver/archiver_store_test_suite.js +2389 -393
  10. package/dest/archiver/config.d.ts +7 -22
  11. package/dest/archiver/config.d.ts.map +1 -1
  12. package/dest/archiver/config.js +30 -14
  13. package/dest/archiver/errors.d.ts +33 -1
  14. package/dest/archiver/errors.d.ts.map +1 -1
  15. package/dest/archiver/errors.js +49 -0
  16. package/dest/archiver/index.d.ts +3 -4
  17. package/dest/archiver/index.d.ts.map +1 -1
  18. package/dest/archiver/index.js +1 -2
  19. package/dest/archiver/instrumentation.d.ts +14 -6
  20. package/dest/archiver/instrumentation.d.ts.map +1 -1
  21. package/dest/archiver/instrumentation.js +69 -17
  22. package/dest/archiver/kv_archiver_store/block_store.d.ts +91 -21
  23. package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
  24. package/dest/archiver/kv_archiver_store/block_store.js +476 -86
  25. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +4 -4
  26. package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
  27. package/dest/archiver/kv_archiver_store/contract_class_store.js +13 -19
  28. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +12 -9
  29. package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +1 -1
  30. package/dest/archiver/kv_archiver_store/contract_instance_store.js +30 -16
  31. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +80 -75
  32. package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
  33. package/dest/archiver/kv_archiver_store/kv_archiver_store.js +142 -83
  34. package/dest/archiver/kv_archiver_store/log_store.d.ts +12 -16
  35. package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
  36. package/dest/archiver/kv_archiver_store/log_store.js +153 -113
  37. package/dest/archiver/kv_archiver_store/message_store.d.ts +25 -18
  38. package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
  39. package/dest/archiver/kv_archiver_store/message_store.js +152 -49
  40. package/dest/archiver/l1/bin/retrieve-calldata.d.ts +3 -0
  41. package/dest/archiver/l1/bin/retrieve-calldata.d.ts.map +1 -0
  42. package/dest/archiver/l1/bin/retrieve-calldata.js +149 -0
  43. package/dest/archiver/l1/calldata_retriever.d.ts +112 -0
  44. package/dest/archiver/l1/calldata_retriever.d.ts.map +1 -0
  45. package/dest/archiver/l1/calldata_retriever.js +471 -0
  46. package/dest/archiver/l1/data_retrieval.d.ts +90 -0
  47. package/dest/archiver/l1/data_retrieval.d.ts.map +1 -0
  48. package/dest/archiver/l1/data_retrieval.js +331 -0
  49. package/dest/archiver/l1/debug_tx.d.ts +19 -0
  50. package/dest/archiver/l1/debug_tx.d.ts.map +1 -0
  51. package/dest/archiver/l1/debug_tx.js +73 -0
  52. package/dest/archiver/l1/spire_proposer.d.ts +70 -0
  53. package/dest/archiver/l1/spire_proposer.d.ts.map +1 -0
  54. package/dest/archiver/l1/spire_proposer.js +157 -0
  55. package/dest/archiver/l1/trace_tx.d.ts +97 -0
  56. package/dest/archiver/l1/trace_tx.d.ts.map +1 -0
  57. package/dest/archiver/l1/trace_tx.js +91 -0
  58. package/dest/archiver/l1/types.d.ts +12 -0
  59. package/dest/archiver/l1/types.d.ts.map +1 -0
  60. package/dest/archiver/l1/types.js +3 -0
  61. package/dest/archiver/l1/validate_trace.d.ts +29 -0
  62. package/dest/archiver/l1/validate_trace.d.ts.map +1 -0
  63. package/dest/archiver/l1/validate_trace.js +150 -0
  64. package/dest/archiver/structs/data_retrieval.d.ts +1 -1
  65. package/dest/archiver/structs/inbox_message.d.ts +15 -0
  66. package/dest/archiver/structs/inbox_message.d.ts.map +1 -0
  67. package/dest/archiver/structs/inbox_message.js +39 -0
  68. package/dest/archiver/structs/published.d.ts +2 -11
  69. package/dest/archiver/structs/published.d.ts.map +1 -1
  70. package/dest/archiver/structs/published.js +1 -1
  71. package/dest/archiver/validation.d.ts +17 -0
  72. package/dest/archiver/validation.d.ts.map +1 -0
  73. package/dest/archiver/validation.js +98 -0
  74. package/dest/factory.d.ts +9 -14
  75. package/dest/factory.d.ts.map +1 -1
  76. package/dest/factory.js +22 -52
  77. package/dest/index.d.ts +2 -2
  78. package/dest/index.d.ts.map +1 -1
  79. package/dest/index.js +1 -1
  80. package/dest/rpc/index.d.ts +2 -3
  81. package/dest/rpc/index.d.ts.map +1 -1
  82. package/dest/rpc/index.js +1 -4
  83. package/dest/test/index.d.ts +1 -1
  84. package/dest/test/mock_archiver.d.ts +16 -8
  85. package/dest/test/mock_archiver.d.ts.map +1 -1
  86. package/dest/test/mock_archiver.js +19 -14
  87. package/dest/test/mock_l1_to_l2_message_source.d.ts +9 -6
  88. package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
  89. package/dest/test/mock_l1_to_l2_message_source.js +21 -7
  90. package/dest/test/mock_l2_block_source.d.ts +52 -13
  91. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  92. package/dest/test/mock_l2_block_source.js +140 -15
  93. package/dest/test/mock_structs.d.ts +10 -0
  94. package/dest/test/mock_structs.d.ts.map +1 -0
  95. package/dest/test/mock_structs.js +38 -0
  96. package/package.json +29 -30
  97. package/src/archiver/archiver.ts +1477 -501
  98. package/src/archiver/archiver_store.ts +197 -88
  99. package/src/archiver/archiver_store_test_suite.ts +2403 -350
  100. package/src/archiver/config.ts +38 -46
  101. package/src/archiver/errors.ts +85 -0
  102. package/src/archiver/index.ts +2 -3
  103. package/src/archiver/instrumentation.ts +91 -22
  104. package/src/archiver/kv_archiver_store/block_store.ts +640 -101
  105. package/src/archiver/kv_archiver_store/contract_class_store.ts +14 -24
  106. package/src/archiver/kv_archiver_store/contract_instance_store.ts +36 -28
  107. package/src/archiver/kv_archiver_store/kv_archiver_store.ts +193 -113
  108. package/src/archiver/kv_archiver_store/log_store.ts +205 -127
  109. package/src/archiver/kv_archiver_store/message_store.ts +213 -54
  110. package/src/archiver/l1/README.md +98 -0
  111. package/src/archiver/l1/bin/retrieve-calldata.ts +182 -0
  112. package/src/archiver/l1/calldata_retriever.ts +641 -0
  113. package/src/archiver/l1/data_retrieval.ts +512 -0
  114. package/src/archiver/l1/debug_tx.ts +99 -0
  115. package/src/archiver/l1/spire_proposer.ts +160 -0
  116. package/src/archiver/l1/trace_tx.ts +128 -0
  117. package/src/archiver/l1/types.ts +13 -0
  118. package/src/archiver/l1/validate_trace.ts +211 -0
  119. package/src/archiver/structs/inbox_message.ts +41 -0
  120. package/src/archiver/structs/published.ts +1 -11
  121. package/src/archiver/validation.ts +124 -0
  122. package/src/factory.ts +28 -69
  123. package/src/index.ts +1 -1
  124. package/src/rpc/index.ts +1 -5
  125. package/src/test/fixtures/debug_traceTransaction-multicall3.json +88 -0
  126. package/src/test/fixtures/debug_traceTransaction-multiplePropose.json +153 -0
  127. package/src/test/fixtures/debug_traceTransaction-proxied.json +122 -0
  128. package/src/test/fixtures/trace_transaction-multicall3.json +65 -0
  129. package/src/test/fixtures/trace_transaction-multiplePropose.json +319 -0
  130. package/src/test/fixtures/trace_transaction-proxied.json +128 -0
  131. package/src/test/fixtures/trace_transaction-randomRevert.json +216 -0
  132. package/src/test/mock_archiver.ts +22 -16
  133. package/src/test/mock_l1_to_l2_message_source.ts +20 -8
  134. package/src/test/mock_l2_block_source.ts +186 -21
  135. package/src/test/mock_structs.ts +50 -0
  136. package/dest/archiver/data_retrieval.d.ts +0 -74
  137. package/dest/archiver/data_retrieval.d.ts.map +0 -1
  138. package/dest/archiver/data_retrieval.js +0 -283
  139. package/dest/archiver/kv_archiver_store/nullifier_store.d.ts +0 -12
  140. package/dest/archiver/kv_archiver_store/nullifier_store.d.ts.map +0 -1
  141. package/dest/archiver/kv_archiver_store/nullifier_store.js +0 -73
  142. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +0 -23
  143. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts.map +0 -1
  144. package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.js +0 -49
  145. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +0 -175
  146. package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +0 -1
  147. package/dest/archiver/memory_archiver_store/memory_archiver_store.js +0 -636
  148. package/src/archiver/data_retrieval.ts +0 -422
  149. package/src/archiver/kv_archiver_store/nullifier_store.ts +0 -97
  150. package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +0 -61
  151. package/src/archiver/memory_archiver_store/memory_archiver_store.ts +0 -801
@@ -1,32 +1,34 @@
1
- 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
+ import type { CustomRange } from '@aztec/kv-store';
2
5
  import type { FunctionSelector } from '@aztec/stdlib/abi';
3
6
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
- import type { InBlock, L2Block } from '@aztec/stdlib/block';
7
+ import type { CheckpointedL2Block, L2BlockNew, ValidateBlockResult } from '@aztec/stdlib/block';
8
+ import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
5
9
  import type {
6
10
  ContractClassPublic,
7
11
  ContractInstanceUpdateWithAddress,
8
12
  ContractInstanceWithAddress,
9
13
  ExecutablePrivateFunctionWithMembershipProof,
10
- UnconstrainedFunctionWithMembershipProof,
14
+ UtilityFunctionWithMembershipProof,
11
15
  } from '@aztec/stdlib/contract';
12
16
  import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
13
- import type { LogFilter, PrivateLog, TxScopedL2Log } from '@aztec/stdlib/logs';
14
- import type { InboxLeaf } from '@aztec/stdlib/messaging';
15
- import { BlockHeader, type TxEffect, type TxHash, type TxReceipt } from '@aztec/stdlib/tx';
17
+ import type { LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
18
+ import { BlockHeader, type IndexedTxEffect, type TxHash, type TxReceipt } from '@aztec/stdlib/tx';
19
+ import type { UInt64 } from '@aztec/stdlib/types';
16
20
 
17
- import type { DataRetrieval } from './structs/data_retrieval.js';
18
- import type { L1Published } from './structs/published.js';
21
+ import type { CheckpointData } from './kv_archiver_store/block_store.js';
22
+ import type { InboxMessage } from './structs/inbox_message.js';
19
23
 
20
24
  /**
21
25
  * Represents the latest L1 block processed by the archiver for various objects in L2.
22
26
  */
23
27
  export type ArchiverL1SynchPoint = {
24
- /** 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. */
25
29
  blocksSynchedTo?: bigint;
26
- /** Number of the last L1 block that added L1 -> L2 messages from the Inbox. */
27
- messagesSynchedTo?: bigint;
28
- /** Number of the last L1 block that added a new proven block. */
29
- provenLogsSynchedTo?: bigint;
30
+ /** Last L1 block checked for L1 to L2 messages. */
31
+ messagesSynchedTo?: L1BlockId;
30
32
  };
31
33
 
32
34
  /**
@@ -34,29 +36,105 @@ export type ArchiverL1SynchPoint = {
34
36
  * (blocks, encrypted logs, aztec contract data extended contract data).
35
37
  */
36
38
  export interface ArchiverDataStore {
39
+ /** Opens a new transaction to the underlying store and runs all operations within it. */
40
+ transactionAsync<T>(callback: () => Promise<T>): Promise<T>;
41
+
37
42
  /**
38
43
  * Append new blocks to the store's list.
39
44
  * @param blocks - The L2 blocks to be added to the store and the last processed L1 block.
45
+ * @param opts - Options for the operation.
46
+ * @param opts.force - If true, the blocks will be added even if they have gaps.
40
47
  * @returns True if the operation is successful.
41
48
  */
42
- addBlocks(blocks: L1Published<L2Block>[]): Promise<boolean>;
49
+ addBlocks(blocks: L2BlockNew[], opts?: { force?: boolean }): Promise<boolean>;
50
+
51
+ /**
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>;
43
57
 
44
58
  /**
45
- * Unwinds blocks from the database
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
46
75
  * @param from - The tip of the chain, passed for verification purposes,
47
76
  * ensuring that we don't end up deleting something we did not intend
48
- * @param blocksToUnwind - The number of blocks we are to unwind
77
+ * @param checkpointsToUnwind - The number of checkpoints we are to unwind
49
78
  * @returns True if the operation is successful
50
79
  */
51
- unwindBlocks(from: number, 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>;
112
+
113
+ /**
114
+ * Returns the block for the given number, or undefined if not exists.
115
+ * @param number - The block number to return.
116
+ */
117
+ getBlock(number: number): Promise<L2BlockNew | undefined>;
118
+
119
+ /**
120
+ * Returns the block for the given hash, or undefined if not exists.
121
+ * @param blockHash - The block hash to return.
122
+ */
123
+ getBlockByHash(blockHash: Fr): Promise<L2BlockNew | undefined>;
124
+
125
+ /**
126
+ * Returns the block for the given archive root, or undefined if not exists.
127
+ * @param archive - The archive root to return.
128
+ */
129
+ getBlockByArchive(archive: Fr): Promise<L2BlockNew | undefined>;
52
130
 
53
131
  /**
54
- * Gets up to `limit` amount of L2 blocks starting from `from`.
132
+ * Gets up to `limit` amount of published L2 blocks starting from `from`.
55
133
  * @param from - Number of the first block to return (inclusive).
56
134
  * @param limit - The number of blocks to return.
57
135
  * @returns The requested L2 blocks.
58
136
  */
59
- getBlocks(from: number, limit: number): Promise<L1Published<L2Block>[]>;
137
+ getBlocks(from: number, limit: number): Promise<L2BlockNew[]>;
60
138
 
61
139
  /**
62
140
  * Gets up to `limit` amount of L2 block headers starting from `from`.
@@ -64,14 +142,26 @@ export interface ArchiverDataStore {
64
142
  * @param limit - The number of blocks to return.
65
143
  * @returns The requested L2 block headers.
66
144
  */
67
- getBlockHeaders(from: number, limit: number): Promise<BlockHeader[]>;
145
+ getBlockHeaders(from: BlockNumber, limit: number): Promise<BlockHeader[]>;
146
+
147
+ /**
148
+ * Returns the block header for the given hash, or undefined if not exists.
149
+ * @param blockHash - The block hash to return.
150
+ */
151
+ getBlockHeaderByHash(blockHash: Fr): Promise<BlockHeader | undefined>;
152
+
153
+ /**
154
+ * Returns the block header for the given archive root, or undefined if not exists.
155
+ * @param archive - The archive root to return.
156
+ */
157
+ getBlockHeaderByArchive(archive: Fr): Promise<BlockHeader | undefined>;
68
158
 
69
159
  /**
70
160
  * Gets a tx effect.
71
- * @param txHash - The txHash of the tx corresponding to the tx effect.
72
- * @returns The requested tx effect (or undefined if not found).
161
+ * @param txHash - The hash of the tx corresponding to the tx effect.
162
+ * @returns The requested tx effect with block info (or undefined if not found).
73
163
  */
74
- getTxEffect(txHash: TxHash): Promise<InBlock<TxEffect> | undefined>;
164
+ getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined>;
75
165
 
76
166
  /**
77
167
  * Gets a receipt of a settled tx.
@@ -85,39 +175,22 @@ export interface ArchiverDataStore {
85
175
  * @param blocks - The blocks for which to add the logs.
86
176
  * @returns True if the operation is successful.
87
177
  */
88
- addLogs(blocks: L2Block[]): Promise<boolean>;
89
- deleteLogs(blocks: L2Block[]): Promise<boolean>;
90
-
91
- /**
92
- * Append new nullifiers to the store's list.
93
- * @param blocks - The blocks for which to add the nullifiers.
94
- * @returns True if the operation is successful.
95
- */
96
- addNullifiers(blocks: L2Block[]): Promise<boolean>;
97
- deleteNullifiers(blocks: L2Block[]): Promise<boolean>;
98
-
99
- /**
100
- * Returns the provided nullifier indexes scoped to the block
101
- * they were first included in, or undefined if they're not present in the tree
102
- * @param blockNumber Max block number to search for the nullifiers
103
- * @param nullifiers Nullifiers to get
104
- * @returns The block scoped indexes of the provided nullifiers, or undefined if the nullifier doesn't exist in the tree
105
- */
106
- findNullifiersIndexesWithBlock(blockNumber: number, nullifiers: Fr[]): Promise<(InBlock<bigint> | undefined)[]>;
178
+ addLogs(blocks: L2BlockNew[]): Promise<boolean>;
179
+ deleteLogs(blocks: L2BlockNew[]): Promise<boolean>;
107
180
 
108
181
  /**
109
182
  * Append L1 to L2 messages to the store.
110
- * @param messages - The L1 to L2 messages to be added to the store and the last processed L1 block.
183
+ * @param messages - The L1 to L2 messages to be added to the store.
111
184
  * @returns True if the operation is successful.
112
185
  */
113
- addL1ToL2Messages(messages: DataRetrieval<InboxLeaf>): Promise<boolean>;
186
+ addL1ToL2Messages(messages: InboxMessage[]): Promise<void>;
114
187
 
115
188
  /**
116
- * Gets L1 to L2 message (to be) included in a given block.
117
- * @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.
118
191
  * @returns The L1 to L2 messages/leaves of the messages subtree (throws if not found).
119
192
  */
120
- getL1ToL2Messages(blockNumber: bigint): Promise<Fr[]>;
193
+ getL1ToL2Messages(checkpointNumber: CheckpointNumber): Promise<Fr[]>;
121
194
 
122
195
  /**
123
196
  * Gets the L1 to L2 message index in the L1 to L2 message tree.
@@ -133,20 +206,17 @@ export interface ArchiverDataStore {
133
206
  getTotalL1ToL2MessageCount(): Promise<bigint>;
134
207
 
135
208
  /**
136
- * Retrieves all private logs from up to `limit` blocks, starting from the block number `from`.
137
- * @param from - The block number from which to begin retrieving logs.
138
- * @param limit - The maximum number of blocks to retrieve logs from.
139
- * @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.
140
212
  */
141
- getPrivateLogs(from: number, limit: number): Promise<PrivateLog[]>;
213
+ getPrivateLogsByTags(tags: SiloedTag[]): Promise<TxScopedL2Log[][]>;
142
214
 
143
215
  /**
144
- * Gets all logs that match any of the received tags (i.e. logs with their first field equal to a tag).
145
- * @param tags - The tags to filter the logs by.
146
- * @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
147
- * 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.
148
218
  */
149
- getLogsByTags(tags: Fr[]): Promise<TxScopedL2Log[][]>;
219
+ getPublicLogsByTagsFromContract(contractAddress: AztecAddress, tags: Tag[]): Promise<TxScopedL2Log[][]>;
150
220
 
151
221
  /**
152
222
  * Gets public logs based on the provided filter.
@@ -166,31 +236,42 @@ export interface ArchiverDataStore {
166
236
  * Gets the number of the latest L2 block processed.
167
237
  * @returns The number of the latest L2 block processed.
168
238
  */
169
- getSynchedL2BlockNumber(): Promise<number>;
239
+ getCheckpointedL2BlockNumber(): Promise<BlockNumber>;
170
240
 
171
241
  /**
172
- * Gets the number of the latest proven L2 block processed.
173
- * @returns The number of the latest proven L2 block processed.
242
+ * Gets the number of the latest published checkpoint processed.
243
+ * @returns The number of the latest published checkpoint processed
174
244
  */
175
- getProvenL2BlockNumber(): Promise<number>;
245
+ getSynchedCheckpointNumber(): Promise<CheckpointNumber>;
176
246
 
177
247
  /**
178
- * Stores the number of the latest proven L2 block processed.
179
- * @param l2BlockNumber - The number of the latest proven L2 block processed.
248
+ * Gets the number of the latest proven checkpoint processed.
249
+ * @returns The number of the latest proven checkpoint processed.
180
250
  */
181
- setProvenL2BlockNumber(l2BlockNumber: number): Promise<void>;
251
+ getProvenCheckpointNumber(): Promise<CheckpointNumber>;
182
252
 
183
253
  /**
184
- * Stores the l1 block number that blocks have been synched until
185
- * @param l1BlockNumber - The l1 block number
254
+ * Returns the number of the most recent proven block
255
+ * @returns The number of the most recent proven block
256
+ */
257
+ getProvenBlockNumber(): Promise<BlockNumber>;
258
+
259
+ /**
260
+ * Stores the number of the latest proven checkpoint processed.
261
+ * @param checkpointNumber - The number of the latest proven checkpoint processed.
186
262
  */
187
- setBlockSynchedL1BlockNumber(l1BlockNumber: bigint): Promise<void>;
263
+ setProvenCheckpointNumber(checkpointNumber: CheckpointNumber): Promise<void>;
188
264
 
189
265
  /**
190
- * Stores the l1 block number that messages have been synched until
266
+ * Stores the l1 block number that checkpoints have been synched until
191
267
  * @param l1BlockNumber - The l1 block number
192
268
  */
193
- setMessageSynchedL1BlockNumber(l1BlockNumber: bigint): Promise<void>;
269
+ setCheckpointSynchedL1BlockNumber(l1BlockNumber: bigint): Promise<void>;
270
+
271
+ /**
272
+ * Stores the l1 block that messages have been synched until
273
+ */
274
+ setMessageSynchedL1Block(l1Block: L1BlockId): Promise<void>;
194
275
 
195
276
  /**
196
277
  * Gets the synch point of the archiver
@@ -203,9 +284,13 @@ export interface ArchiverDataStore {
203
284
  * @param blockNumber - Number of the L2 block the contracts were registered in.
204
285
  * @returns True if the operation is successful.
205
286
  */
206
- addContractClasses(data: ContractClassPublic[], bytecodeCommitments: Fr[], blockNumber: number): Promise<boolean>;
287
+ addContractClasses(
288
+ data: ContractClassPublic[],
289
+ bytecodeCommitments: Fr[],
290
+ blockNumber: BlockNumber,
291
+ ): Promise<boolean>;
207
292
 
208
- deleteContractClasses(data: ContractClassPublic[], blockNumber: number): Promise<boolean>;
293
+ deleteContractClasses(data: ContractClassPublic[], blockNumber: BlockNumber): Promise<boolean>;
209
294
 
210
295
  getBytecodeCommitment(contractClassId: Fr): Promise<Fr | undefined>;
211
296
 
@@ -221,43 +306,67 @@ export interface ArchiverDataStore {
221
306
  * @param blockNumber - Number of the L2 block the instances were deployed in.
222
307
  * @returns True if the operation is successful.
223
308
  */
224
- addContractInstances(data: ContractInstanceWithAddress[], blockNumber: number): Promise<boolean>;
225
- deleteContractInstances(data: ContractInstanceWithAddress[], blockNumber: number): Promise<boolean>;
309
+ addContractInstances(data: ContractInstanceWithAddress[], blockNumber: BlockNumber): Promise<boolean>;
310
+ deleteContractInstances(data: ContractInstanceWithAddress[], blockNumber: BlockNumber): Promise<boolean>;
226
311
 
227
312
  /**
228
313
  * Add new contract instance updates
229
314
  * @param data - List of contract updates to be added.
230
- * @param blockNumber - Number of the L2 block the updates were scheduled in.
315
+ * @param timestamp - Timestamp at which the updates were scheduled.
231
316
  * @returns True if the operation is successful.
232
317
  */
233
- addContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[], blockNumber: number): Promise<boolean>;
234
- deleteContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[], blockNumber: number): Promise<boolean>;
318
+ addContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[], timestamp: UInt64): Promise<boolean>;
319
+ deleteContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[], timestamp: UInt64): Promise<boolean>;
235
320
  /**
236
321
  * Adds private functions to a contract class.
237
322
  */
238
323
  addFunctions(
239
324
  contractClassId: Fr,
240
325
  privateFunctions: ExecutablePrivateFunctionWithMembershipProof[],
241
- unconstrainedFunctions: UnconstrainedFunctionWithMembershipProof[],
326
+ utilityFunctions: UtilityFunctionWithMembershipProof[],
242
327
  ): Promise<boolean>;
243
328
 
244
329
  /**
245
- * Returns a contract instance given its address and the given block number, or undefined if not exists.
330
+ * Returns a contract instance given its address and the given timestamp, or undefined if not exists.
246
331
  * @param address - Address of the contract.
332
+ * @param timestamp - Timestamp to get the contract instance at. Contract updates might change the instance.
333
+ * @returns The contract instance or undefined if not found.
247
334
  */
248
- getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
335
+ getContractInstance(address: AztecAddress, timestamp: UInt64): Promise<ContractInstanceWithAddress | undefined>;
249
336
 
250
337
  /** Returns the list of all class ids known by the archiver. */
251
338
  getContractClassIds(): Promise<Fr[]>;
252
339
 
253
- // TODO: These function names are in memory only as they are for development/debugging. They require the full contract
254
- // artifact supplied to the node out of band. This should be reviewed and potentially removed as part of
255
- // the node api cleanup process.
256
- registerContractFunctionSignatures(address: AztecAddress, signatures: string[]): Promise<void>;
257
- getContractFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
340
+ /** Register a public function signature, so it can be looked up by selector. */
341
+ registerContractFunctionSignatures(signatures: string[]): Promise<void>;
258
342
 
259
- /**
260
- * Estimates the size of the store in bytes.
261
- */
262
- estimateSize(): Promise<{ mappingSize: number; actualSize: number; numItems: number }>;
343
+ /** Looks up a public function name given a selector. */
344
+ getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
345
+
346
+ /** Estimates the size of the store in bytes. */
347
+ estimateSize(): Promise<{ mappingSize: number; physicalFileSize: number; actualSize: number; numItems: number }>;
348
+
349
+ /** Backups the archiver db to the target folder. Returns the path to the db file. */
350
+ backupTo(path: string): Promise<string>;
351
+
352
+ /** Closes the underlying data store. */
353
+ close(): Promise<void>;
354
+
355
+ /** Deletes all L1 to L2 messages up until (excluding) the target checkpoint number. */
356
+ rollbackL1ToL2MessagesToCheckpoint(targetCheckpointNumber: CheckpointNumber): Promise<void>;
357
+
358
+ /** Returns an async iterator to all L1 to L2 messages on the range. */
359
+ iterateL1ToL2Messages(range?: CustomRange<bigint>): AsyncIterableIterator<InboxMessage>;
360
+
361
+ /** Removes all L1 to L2 messages starting from the given index (inclusive). */
362
+ removeL1ToL2Messages(startIndex: bigint): Promise<void>;
363
+
364
+ /** Returns the last L1 to L2 message stored. */
365
+ getLastL1ToL2Message(): Promise<InboxMessage | undefined>;
366
+
367
+ /** Returns the last synced validation status of the pending chain. */
368
+ getPendingChainValidationStatus(): Promise<ValidateBlockResult | undefined>;
369
+
370
+ /** Sets the last synced validation status of the pending chain. */
371
+ setPendingChainValidationStatus(status: ValidateBlockResult | undefined): Promise<void>;
263
372
  }