@aztec/archiver 0.0.0-test.1 → 0.0.1-commit.5476d83
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.
- package/README.md +27 -6
- package/dest/archiver/archiver.d.ts +147 -57
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +841 -333
- package/dest/archiver/archiver_store.d.ts +85 -50
- package/dest/archiver/archiver_store.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.js +708 -213
- package/dest/archiver/config.d.ts +5 -21
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +21 -12
- package/dest/archiver/data_retrieval.d.ts +32 -27
- package/dest/archiver/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/data_retrieval.js +197 -94
- package/dest/archiver/errors.d.ts +9 -1
- package/dest/archiver/errors.d.ts.map +1 -1
- package/dest/archiver/errors.js +12 -0
- package/dest/archiver/index.d.ts +3 -4
- package/dest/archiver/index.d.ts.map +1 -1
- package/dest/archiver/index.js +1 -2
- package/dest/archiver/instrumentation.d.ts +12 -6
- package/dest/archiver/instrumentation.d.ts.map +1 -1
- package/dest/archiver/instrumentation.js +58 -17
- package/dest/archiver/kv_archiver_store/block_store.d.ts +48 -11
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +216 -63
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +3 -3
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.js +12 -18
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +11 -8
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.js +30 -16
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +50 -35
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +88 -46
- package/dest/archiver/kv_archiver_store/log_store.d.ts +2 -2
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +18 -46
- package/dest/archiver/kv_archiver_store/message_store.d.ts +23 -17
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/message_store.js +150 -48
- package/dest/archiver/structs/data_retrieval.d.ts +1 -1
- package/dest/archiver/structs/inbox_message.d.ts +15 -0
- package/dest/archiver/structs/inbox_message.d.ts.map +1 -0
- package/dest/archiver/structs/inbox_message.js +38 -0
- package/dest/archiver/structs/published.d.ts +3 -11
- package/dest/archiver/structs/published.d.ts.map +1 -1
- package/dest/archiver/structs/published.js +1 -1
- package/dest/archiver/validation.d.ts +17 -0
- package/dest/archiver/validation.d.ts.map +1 -0
- package/dest/archiver/validation.js +98 -0
- package/dest/factory.d.ts +8 -13
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +18 -49
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/rpc/index.d.ts +2 -3
- package/dest/rpc/index.d.ts.map +1 -1
- package/dest/rpc/index.js +1 -4
- package/dest/test/index.d.ts +1 -1
- package/dest/test/mock_archiver.d.ts +2 -2
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.d.ts +5 -3
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +14 -1
- package/dest/test/mock_l2_block_source.d.ts +38 -10
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +119 -8
- package/dest/test/mock_structs.d.ts +9 -0
- package/dest/test/mock_structs.d.ts.map +1 -0
- package/dest/test/mock_structs.js +37 -0
- package/package.json +28 -30
- package/src/archiver/archiver.ts +1087 -410
- package/src/archiver/archiver_store.ts +97 -55
- package/src/archiver/archiver_store_test_suite.ts +664 -210
- package/src/archiver/config.ts +28 -41
- package/src/archiver/data_retrieval.ts +279 -125
- package/src/archiver/errors.ts +21 -0
- package/src/archiver/index.ts +2 -3
- package/src/archiver/instrumentation.ts +77 -22
- package/src/archiver/kv_archiver_store/block_store.ts +270 -72
- package/src/archiver/kv_archiver_store/contract_class_store.ts +13 -23
- package/src/archiver/kv_archiver_store/contract_instance_store.ts +35 -27
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +127 -63
- package/src/archiver/kv_archiver_store/log_store.ts +24 -62
- package/src/archiver/kv_archiver_store/message_store.ts +209 -53
- package/src/archiver/structs/inbox_message.ts +41 -0
- package/src/archiver/structs/published.ts +2 -11
- package/src/archiver/validation.ts +124 -0
- package/src/factory.ts +24 -66
- package/src/index.ts +1 -1
- package/src/rpc/index.ts +1 -5
- package/src/test/mock_archiver.ts +1 -1
- package/src/test/mock_l1_to_l2_message_source.ts +14 -3
- package/src/test/mock_l2_block_source.ts +158 -13
- package/src/test/mock_structs.ts +49 -0
- package/dest/archiver/kv_archiver_store/nullifier_store.d.ts +0 -12
- package/dest/archiver/kv_archiver_store/nullifier_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/nullifier_store.js +0 -73
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +0 -23
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts.map +0 -1
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.js +0 -49
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +0 -175
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +0 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.js +0 -636
- package/src/archiver/kv_archiver_store/nullifier_store.ts +0 -97
- package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +0 -61
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +0 -801
|
@@ -1,21 +1,23 @@
|
|
|
1
|
+
import type { L1BlockId } from '@aztec/ethereum';
|
|
1
2
|
import type { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import type { CustomRange } from '@aztec/kv-store';
|
|
2
4
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import type {
|
|
6
|
+
import type { L2Block, ValidateBlockResult } from '@aztec/stdlib/block';
|
|
5
7
|
import type {
|
|
6
8
|
ContractClassPublic,
|
|
7
9
|
ContractInstanceUpdateWithAddress,
|
|
8
10
|
ContractInstanceWithAddress,
|
|
9
11
|
ExecutablePrivateFunctionWithMembershipProof,
|
|
10
|
-
|
|
12
|
+
UtilityFunctionWithMembershipProof,
|
|
11
13
|
} from '@aztec/stdlib/contract';
|
|
12
14
|
import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
|
|
13
15
|
import type { LogFilter, PrivateLog, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
14
|
-
import type
|
|
15
|
-
import
|
|
16
|
+
import { BlockHeader, type IndexedTxEffect, type TxHash, type TxReceipt } from '@aztec/stdlib/tx';
|
|
17
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
16
18
|
|
|
17
|
-
import type {
|
|
18
|
-
import type {
|
|
19
|
+
import type { InboxMessage } from './structs/inbox_message.js';
|
|
20
|
+
import type { PublishedL2Block } from './structs/published.js';
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* Represents the latest L1 block processed by the archiver for various objects in L2.
|
|
@@ -23,10 +25,8 @@ import type { L1Published } from './structs/published.js';
|
|
|
23
25
|
export type ArchiverL1SynchPoint = {
|
|
24
26
|
/** Number of the last L1 block that added a new L2 block metadata. */
|
|
25
27
|
blocksSynchedTo?: bigint;
|
|
26
|
-
/**
|
|
27
|
-
messagesSynchedTo?:
|
|
28
|
-
/** Number of the last L1 block that added a new proven block. */
|
|
29
|
-
provenLogsSynchedTo?: bigint;
|
|
28
|
+
/** Last L1 block checked for L1 to L2 messages. */
|
|
29
|
+
messagesSynchedTo?: L1BlockId;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
/**
|
|
@@ -34,12 +34,17 @@ export type ArchiverL1SynchPoint = {
|
|
|
34
34
|
* (blocks, encrypted logs, aztec contract data extended contract data).
|
|
35
35
|
*/
|
|
36
36
|
export interface ArchiverDataStore {
|
|
37
|
+
/** Opens a new transaction to the underlying store and runs all operations within it. */
|
|
38
|
+
transactionAsync<T>(callback: () => Promise<T>): Promise<T>;
|
|
39
|
+
|
|
37
40
|
/**
|
|
38
41
|
* Append new blocks to the store's list.
|
|
39
42
|
* @param blocks - The L2 blocks to be added to the store and the last processed L1 block.
|
|
43
|
+
* @param opts - Options for the operation.
|
|
44
|
+
* @param opts.force - If true, the blocks will be added even if they have gaps.
|
|
40
45
|
* @returns True if the operation is successful.
|
|
41
46
|
*/
|
|
42
|
-
addBlocks(blocks:
|
|
47
|
+
addBlocks(blocks: PublishedL2Block[], opts?: { force?: boolean }): Promise<boolean>;
|
|
43
48
|
|
|
44
49
|
/**
|
|
45
50
|
* Unwinds blocks from the database
|
|
@@ -51,12 +56,30 @@ export interface ArchiverDataStore {
|
|
|
51
56
|
unwindBlocks(from: number, blocksToUnwind: number): Promise<boolean>;
|
|
52
57
|
|
|
53
58
|
/**
|
|
54
|
-
*
|
|
59
|
+
* Returns the block for the given number, or undefined if not exists.
|
|
60
|
+
* @param number - The block number to return.
|
|
61
|
+
*/
|
|
62
|
+
getPublishedBlock(number: number): Promise<PublishedL2Block | undefined>;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Returns the block for the given hash, or undefined if not exists.
|
|
66
|
+
* @param blockHash - The block hash to return.
|
|
67
|
+
*/
|
|
68
|
+
getPublishedBlockByHash(blockHash: Fr): Promise<PublishedL2Block | undefined>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Returns the block for the given archive root, or undefined if not exists.
|
|
72
|
+
* @param archive - The archive root to return.
|
|
73
|
+
*/
|
|
74
|
+
getPublishedBlockByArchive(archive: Fr): Promise<PublishedL2Block | undefined>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Gets up to `limit` amount of published L2 blocks starting from `from`.
|
|
55
78
|
* @param from - Number of the first block to return (inclusive).
|
|
56
79
|
* @param limit - The number of blocks to return.
|
|
57
80
|
* @returns The requested L2 blocks.
|
|
58
81
|
*/
|
|
59
|
-
|
|
82
|
+
getPublishedBlocks(from: number, limit: number): Promise<PublishedL2Block[]>;
|
|
60
83
|
|
|
61
84
|
/**
|
|
62
85
|
* Gets up to `limit` amount of L2 block headers starting from `from`.
|
|
@@ -66,12 +89,24 @@ export interface ArchiverDataStore {
|
|
|
66
89
|
*/
|
|
67
90
|
getBlockHeaders(from: number, limit: number): Promise<BlockHeader[]>;
|
|
68
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Returns the block header for the given hash, or undefined if not exists.
|
|
94
|
+
* @param blockHash - The block hash to return.
|
|
95
|
+
*/
|
|
96
|
+
getBlockHeaderByHash(blockHash: Fr): Promise<BlockHeader | undefined>;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Returns the block header for the given archive root, or undefined if not exists.
|
|
100
|
+
* @param archive - The archive root to return.
|
|
101
|
+
*/
|
|
102
|
+
getBlockHeaderByArchive(archive: Fr): Promise<BlockHeader | undefined>;
|
|
103
|
+
|
|
69
104
|
/**
|
|
70
105
|
* Gets a tx effect.
|
|
71
|
-
* @param txHash - The
|
|
72
|
-
* @returns The requested tx effect (or undefined if not found).
|
|
106
|
+
* @param txHash - The hash of the tx corresponding to the tx effect.
|
|
107
|
+
* @returns The requested tx effect with block info (or undefined if not found).
|
|
73
108
|
*/
|
|
74
|
-
getTxEffect(txHash: TxHash): Promise<
|
|
109
|
+
getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined>;
|
|
75
110
|
|
|
76
111
|
/**
|
|
77
112
|
* Gets a receipt of a settled tx.
|
|
@@ -88,36 +123,19 @@ export interface ArchiverDataStore {
|
|
|
88
123
|
addLogs(blocks: L2Block[]): Promise<boolean>;
|
|
89
124
|
deleteLogs(blocks: L2Block[]): Promise<boolean>;
|
|
90
125
|
|
|
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)[]>;
|
|
107
|
-
|
|
108
126
|
/**
|
|
109
127
|
* Append L1 to L2 messages to the store.
|
|
110
|
-
* @param messages - The L1 to L2 messages to be added to the store
|
|
128
|
+
* @param messages - The L1 to L2 messages to be added to the store.
|
|
111
129
|
* @returns True if the operation is successful.
|
|
112
130
|
*/
|
|
113
|
-
addL1ToL2Messages(messages:
|
|
131
|
+
addL1ToL2Messages(messages: InboxMessage[]): Promise<void>;
|
|
114
132
|
|
|
115
133
|
/**
|
|
116
134
|
* Gets L1 to L2 message (to be) included in a given block.
|
|
117
135
|
* @param blockNumber - L2 block number to get messages for.
|
|
118
136
|
* @returns The L1 to L2 messages/leaves of the messages subtree (throws if not found).
|
|
119
137
|
*/
|
|
120
|
-
getL1ToL2Messages(blockNumber:
|
|
138
|
+
getL1ToL2Messages(blockNumber: number): Promise<Fr[]>;
|
|
121
139
|
|
|
122
140
|
/**
|
|
123
141
|
* Gets the L1 to L2 message index in the L1 to L2 message tree.
|
|
@@ -143,10 +161,11 @@ export interface ArchiverDataStore {
|
|
|
143
161
|
/**
|
|
144
162
|
* Gets all logs that match any of the received tags (i.e. logs with their first field equal to a tag).
|
|
145
163
|
* @param tags - The tags to filter the logs by.
|
|
164
|
+
* @param logsPerTag - The number of logs to return per tag. Defaults to everything
|
|
146
165
|
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
|
|
147
166
|
* that tag.
|
|
148
167
|
*/
|
|
149
|
-
getLogsByTags(tags: Fr[]): Promise<TxScopedL2Log[][]>;
|
|
168
|
+
getLogsByTags(tags: Fr[], logsPerTag?: number): Promise<TxScopedL2Log[][]>;
|
|
150
169
|
|
|
151
170
|
/**
|
|
152
171
|
* Gets public logs based on the provided filter.
|
|
@@ -187,10 +206,9 @@ export interface ArchiverDataStore {
|
|
|
187
206
|
setBlockSynchedL1BlockNumber(l1BlockNumber: bigint): Promise<void>;
|
|
188
207
|
|
|
189
208
|
/**
|
|
190
|
-
* Stores the l1 block
|
|
191
|
-
* @param l1BlockNumber - The l1 block number
|
|
209
|
+
* Stores the l1 block that messages have been synched until
|
|
192
210
|
*/
|
|
193
|
-
|
|
211
|
+
setMessageSynchedL1Block(l1Block: L1BlockId): Promise<void>;
|
|
194
212
|
|
|
195
213
|
/**
|
|
196
214
|
* Gets the synch point of the archiver
|
|
@@ -227,37 +245,61 @@ export interface ArchiverDataStore {
|
|
|
227
245
|
/**
|
|
228
246
|
* Add new contract instance updates
|
|
229
247
|
* @param data - List of contract updates to be added.
|
|
230
|
-
* @param
|
|
248
|
+
* @param timestamp - Timestamp at which the updates were scheduled.
|
|
231
249
|
* @returns True if the operation is successful.
|
|
232
250
|
*/
|
|
233
|
-
addContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[],
|
|
234
|
-
deleteContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[],
|
|
251
|
+
addContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[], timestamp: UInt64): Promise<boolean>;
|
|
252
|
+
deleteContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[], timestamp: UInt64): Promise<boolean>;
|
|
235
253
|
/**
|
|
236
254
|
* Adds private functions to a contract class.
|
|
237
255
|
*/
|
|
238
256
|
addFunctions(
|
|
239
257
|
contractClassId: Fr,
|
|
240
258
|
privateFunctions: ExecutablePrivateFunctionWithMembershipProof[],
|
|
241
|
-
|
|
259
|
+
utilityFunctions: UtilityFunctionWithMembershipProof[],
|
|
242
260
|
): Promise<boolean>;
|
|
243
261
|
|
|
244
262
|
/**
|
|
245
|
-
* Returns a contract instance given its address and the given
|
|
263
|
+
* Returns a contract instance given its address and the given timestamp, or undefined if not exists.
|
|
246
264
|
* @param address - Address of the contract.
|
|
265
|
+
* @param timestamp - Timestamp to get the contract instance at. Contract updates might change the instance.
|
|
266
|
+
* @returns The contract instance or undefined if not found.
|
|
247
267
|
*/
|
|
248
|
-
getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
|
|
268
|
+
getContractInstance(address: AztecAddress, timestamp: UInt64): Promise<ContractInstanceWithAddress | undefined>;
|
|
249
269
|
|
|
250
270
|
/** Returns the list of all class ids known by the archiver. */
|
|
251
271
|
getContractClassIds(): Promise<Fr[]>;
|
|
252
272
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
// the node api cleanup process.
|
|
256
|
-
registerContractFunctionSignatures(address: AztecAddress, signatures: string[]): Promise<void>;
|
|
257
|
-
getContractFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
273
|
+
/** Register a public function signature, so it can be looked up by selector. */
|
|
274
|
+
registerContractFunctionSignatures(signatures: string[]): Promise<void>;
|
|
258
275
|
|
|
259
|
-
/**
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
276
|
+
/** Looks up a public function name given a selector. */
|
|
277
|
+
getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
278
|
+
|
|
279
|
+
/** Estimates the size of the store in bytes. */
|
|
280
|
+
estimateSize(): Promise<{ mappingSize: number; physicalFileSize: number; actualSize: number; numItems: number }>;
|
|
281
|
+
|
|
282
|
+
/** Backups the archiver db to the target folder. Returns the path to the db file. */
|
|
283
|
+
backupTo(path: string): Promise<string>;
|
|
284
|
+
|
|
285
|
+
/** Closes the underlying data store. */
|
|
286
|
+
close(): Promise<void>;
|
|
287
|
+
|
|
288
|
+
/** Deletes all L1 to L2 messages up until (excluding) the target L2 block number. */
|
|
289
|
+
rollbackL1ToL2MessagesToL2Block(targetBlockNumber: number): Promise<void>;
|
|
290
|
+
|
|
291
|
+
/** Returns an async iterator to all L1 to L2 messages on the range. */
|
|
292
|
+
iterateL1ToL2Messages(range?: CustomRange<bigint>): AsyncIterableIterator<InboxMessage>;
|
|
293
|
+
|
|
294
|
+
/** Removes all L1 to L2 messages starting from the given index (inclusive). */
|
|
295
|
+
removeL1ToL2Messages(startIndex: bigint): Promise<void>;
|
|
296
|
+
|
|
297
|
+
/** Returns the last L1 to L2 message stored. */
|
|
298
|
+
getLastL1ToL2Message(): Promise<InboxMessage | undefined>;
|
|
299
|
+
|
|
300
|
+
/** Returns the last synced validation status of the pending chain. */
|
|
301
|
+
getPendingChainValidationStatus(): Promise<ValidateBlockResult | undefined>;
|
|
302
|
+
|
|
303
|
+
/** Sets the last synced validation status of the pending chain. */
|
|
304
|
+
setPendingChainValidationStatus(status: ValidateBlockResult | undefined): Promise<void>;
|
|
263
305
|
}
|