@aztec/archiver 0.23.0 → 0.26.1
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/dest/archiver/archiver.d.ts +15 -11
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +67 -72
- package/dest/archiver/archiver_store.d.ts +37 -15
- package/dest/archiver/archiver_store.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.js +70 -54
- package/dest/archiver/data_retrieval.d.ts +18 -8
- package/dest/archiver/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/data_retrieval.js +39 -14
- package/dest/archiver/eth_log_handlers.d.ts +25 -23
- package/dest/archiver/eth_log_handlers.d.ts.map +1 -1
- package/dest/archiver/eth_log_handlers.js +98 -57
- package/dest/archiver/kv_archiver_store/block_body_store.d.ts +27 -0
- package/dest/archiver/kv_archiver_store/block_body_store.d.ts.map +1 -0
- package/dest/archiver/kv_archiver_store/block_body_store.js +47 -0
- package/dest/archiver/kv_archiver_store/block_store.d.ts +19 -11
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +58 -30
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +1 -0
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.js +4 -1
- package/dest/archiver/kv_archiver_store/contract_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_store.js +6 -3
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +36 -16
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +52 -22
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +4 -3
- package/dest/archiver/kv_archiver_store/message_store.d.ts +9 -9
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/message_store.js +34 -31
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +6 -6
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts.map +1 -1
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.js +18 -18
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +41 -16
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +1 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.js +78 -29
- package/dest/index.js +2 -2
- package/dest/rpc/archiver_client.d.ts.map +1 -1
- package/dest/rpc/archiver_client.js +3 -3
- package/dest/rpc/archiver_server.d.ts.map +1 -1
- package/dest/rpc/archiver_server.js +4 -3
- package/package.json +10 -10
- package/src/archiver/archiver.ts +625 -0
- package/src/archiver/archiver_store.ts +226 -0
- package/src/archiver/archiver_store_test_suite.ts +676 -0
- package/src/archiver/config.ts +89 -0
- package/src/archiver/data_retrieval.ts +232 -0
- package/src/archiver/eth_log_handlers.ts +342 -0
- package/src/archiver/index.ts +5 -0
- package/src/archiver/kv_archiver_store/block_body_store.ts +54 -0
- package/src/archiver/kv_archiver_store/block_store.ts +199 -0
- package/src/archiver/kv_archiver_store/contract_class_store.ts +68 -0
- package/src/archiver/kv_archiver_store/contract_instance_store.ts +26 -0
- package/src/archiver/kv_archiver_store/contract_store.ts +98 -0
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +300 -0
- package/src/archiver/kv_archiver_store/log_store.ts +174 -0
- package/src/archiver/kv_archiver_store/message_store.ts +174 -0
- package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +91 -0
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +506 -0
- package/src/index.ts +55 -0
- package/src/rpc/archiver_client.ts +35 -0
- package/src/rpc/archiver_server.ts +41 -0
- package/src/rpc/index.ts +2 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Body,
|
|
3
|
+
ContractData,
|
|
4
|
+
ExtendedContractData,
|
|
5
|
+
GetUnencryptedLogsResponse,
|
|
6
|
+
L1ToL2Message,
|
|
7
|
+
L2Block,
|
|
8
|
+
L2BlockL2Logs,
|
|
9
|
+
LogFilter,
|
|
10
|
+
LogType,
|
|
11
|
+
TxEffect,
|
|
12
|
+
TxHash,
|
|
13
|
+
TxReceipt,
|
|
14
|
+
} from '@aztec/circuit-types';
|
|
15
|
+
import { Fr } from '@aztec/circuits.js';
|
|
16
|
+
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
17
|
+
import { ContractClassPublic, ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Represents the latest L1 block processed by the archiver for various objects in L2.
|
|
21
|
+
*/
|
|
22
|
+
export type ArchiverL1SynchPoint = {
|
|
23
|
+
/** The last L1 block that added a new L2 block. */
|
|
24
|
+
addedBlock: bigint;
|
|
25
|
+
/** The last L1 block that added pending messages */
|
|
26
|
+
addedMessages: bigint;
|
|
27
|
+
/** The last L1 block that cancelled messages */
|
|
28
|
+
cancelledMessages: bigint;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Interface describing a data store to be used by the archiver to store all its relevant data
|
|
33
|
+
* (blocks, encrypted logs, aztec contract data extended contract data).
|
|
34
|
+
*/
|
|
35
|
+
export interface ArchiverDataStore {
|
|
36
|
+
/**
|
|
37
|
+
* Append new blocks to the store's list.
|
|
38
|
+
* @param blocks - The L2 blocks to be added to the store.
|
|
39
|
+
* @returns True if the operation is successful.
|
|
40
|
+
*/
|
|
41
|
+
addBlocks(blocks: L2Block[]): Promise<boolean>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Append new block bodies to the store's list.
|
|
45
|
+
* @param blockBodies - The L2 block bodies to be added to the store.
|
|
46
|
+
* @returns True if the operation is successful.
|
|
47
|
+
*/
|
|
48
|
+
addBlockBodies(blockBodies: Body[]): Promise<boolean>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Gets block bodies that have the same txsHashes as we supply.
|
|
52
|
+
*
|
|
53
|
+
* @param txsHashes - A list of txsHashes (body hashes).
|
|
54
|
+
* @returns The requested L2 block bodies
|
|
55
|
+
*/
|
|
56
|
+
getBlockBodies(txsHashes: Buffer[]): Promise<Body[]>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Gets up to `limit` amount of L2 blocks starting from `from`.
|
|
60
|
+
* @param from - Number of the first block to return (inclusive).
|
|
61
|
+
* @param limit - The number of blocks to return.
|
|
62
|
+
* @returns The requested L2 blocks.
|
|
63
|
+
*/
|
|
64
|
+
getBlocks(from: number, limit: number): Promise<L2Block[]>;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Gets a tx effect.
|
|
68
|
+
* @param txHash - The txHash of the tx corresponding to the tx effect.
|
|
69
|
+
* @returns The requested tx effect (or undefined if not found).
|
|
70
|
+
*/
|
|
71
|
+
getTxEffect(txHash: TxHash): Promise<TxEffect | undefined>;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets a receipt of a settled tx.
|
|
75
|
+
* @param txHash - The hash of a tx we try to get the receipt for.
|
|
76
|
+
* @returns The requested tx receipt (or undefined if not found).
|
|
77
|
+
*/
|
|
78
|
+
getSettledTxReceipt(txHash: TxHash): Promise<TxReceipt | undefined>;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Append new logs to the store's list.
|
|
82
|
+
* @param encryptedLogs - The encrypted logs to be added to the store.
|
|
83
|
+
* @param unencryptedLogs - The unencrypted logs to be added to the store.
|
|
84
|
+
* @param blockNumber - The block for which to add the logs.
|
|
85
|
+
* @returns True if the operation is successful.
|
|
86
|
+
*/
|
|
87
|
+
addLogs(
|
|
88
|
+
encryptedLogs: L2BlockL2Logs | undefined,
|
|
89
|
+
unencryptedLogs: L2BlockL2Logs | undefined,
|
|
90
|
+
blockNumber: number,
|
|
91
|
+
): Promise<boolean>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Append new pending L1 to L2 messages to the store.
|
|
95
|
+
* @param messages - The L1 to L2 messages to be added to the store.
|
|
96
|
+
* @param l1BlockNumber - The block number of the L1 block that added the messages.
|
|
97
|
+
* @returns True if the operation is successful.
|
|
98
|
+
*/
|
|
99
|
+
addPendingL1ToL2Messages(messages: L1ToL2Message[], l1BlockNumber: bigint): Promise<boolean>;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Remove pending L1 to L2 messages from the store (if they were cancelled).
|
|
103
|
+
* @param entryKeys - The entry keys to be removed from the store.
|
|
104
|
+
* @param l1BlockNumber - The block number of the L1 block that cancelled the messages.
|
|
105
|
+
* @returns True if the operation is successful.
|
|
106
|
+
*/
|
|
107
|
+
cancelPendingL1ToL2EntryKeys(entryKeys: Fr[], l1BlockNumber: bigint): Promise<boolean>;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Messages that have been published in an L2 block are confirmed.
|
|
111
|
+
* Add them to the confirmed store, also remove them from the pending store.
|
|
112
|
+
* @param entryKeys - The entry keys to be removed from the store.
|
|
113
|
+
* @returns True if the operation is successful.
|
|
114
|
+
*/
|
|
115
|
+
confirmL1ToL2EntryKeys(entryKeys: Fr[]): Promise<boolean>;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Gets up to `limit` amount of pending L1 to L2 messages, sorted by fee
|
|
119
|
+
* @param limit - The number of entries to return (by default NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).
|
|
120
|
+
* @returns The requested L1 to L2 entry keys.
|
|
121
|
+
*/
|
|
122
|
+
getPendingL1ToL2EntryKeys(limit: number): Promise<Fr[]>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Gets the confirmed L1 to L2 message corresponding to the given entry key.
|
|
126
|
+
* @param entryKey - The entry key to look up.
|
|
127
|
+
* @returns The requested L1 to L2 message or throws if not found.
|
|
128
|
+
*/
|
|
129
|
+
getConfirmedL1ToL2Message(entryKey: Fr): Promise<L1ToL2Message>;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Gets up to `limit` amount of logs starting from `from`.
|
|
133
|
+
* @param from - Number of the L2 block to which corresponds the first logs to be returned.
|
|
134
|
+
* @param limit - The number of logs to return.
|
|
135
|
+
* @param logType - Specifies whether to return encrypted or unencrypted logs.
|
|
136
|
+
* @returns The requested logs.
|
|
137
|
+
*/
|
|
138
|
+
getLogs(from: number, limit: number, logType: LogType): Promise<L2BlockL2Logs[]>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Gets unencrypted logs based on the provided filter.
|
|
142
|
+
* @param filter - The filter to apply to the logs.
|
|
143
|
+
* @returns The requested logs.
|
|
144
|
+
*/
|
|
145
|
+
getUnencryptedLogs(filter: LogFilter): Promise<GetUnencryptedLogsResponse>;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Add new extended contract data from an L2 block to the store's list.
|
|
149
|
+
* @param data - List of contracts' data to be added.
|
|
150
|
+
* @param blockNum - Number of the L2 block the contract data was deployed in.
|
|
151
|
+
* @returns True if the operation is successful.
|
|
152
|
+
*/
|
|
153
|
+
addExtendedContractData(data: ExtendedContractData[], blockNum: number): Promise<boolean>;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Get the extended contract data for this contract.
|
|
157
|
+
* @param contractAddress - The contract data address.
|
|
158
|
+
* @returns The extended contract data or undefined if not found.
|
|
159
|
+
*/
|
|
160
|
+
getExtendedContractData(contractAddress: AztecAddress): Promise<ExtendedContractData | undefined>;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Lookup all extended contract data in an L2 block.
|
|
164
|
+
* @param blockNum - The block number to get all contract data from.
|
|
165
|
+
* @returns All extended contract data in the block (if found).
|
|
166
|
+
*/
|
|
167
|
+
getExtendedContractDataInBlock(blockNum: number): Promise<ExtendedContractData[]>;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Get basic info for an L2 contract.
|
|
171
|
+
* Contains contract address & the ethereum portal address.
|
|
172
|
+
* @param contractAddress - The contract data address.
|
|
173
|
+
* @returns ContractData with the portal address (if we didn't throw an error).
|
|
174
|
+
*/
|
|
175
|
+
getContractData(contractAddress: AztecAddress): Promise<ContractData | undefined>;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Get basic info for an all L2 contracts deployed in a block.
|
|
179
|
+
* Contains contract address & the ethereum portal address.
|
|
180
|
+
* @param l2BlockNum - Number of the L2 block where contracts were deployed.
|
|
181
|
+
* @returns ContractData with the portal address (if we didn't throw an error).
|
|
182
|
+
*/
|
|
183
|
+
getContractDataInBlock(l2BlockNum: number): Promise<ContractData[] | undefined>;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Gets the number of the latest L2 block processed.
|
|
187
|
+
* @returns The number of the latest L2 block processed.
|
|
188
|
+
*/
|
|
189
|
+
getBlockNumber(): Promise<number>;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Gets the last L1 block number processed by the archiver
|
|
193
|
+
*/
|
|
194
|
+
getL1BlockNumber(): Promise<ArchiverL1SynchPoint>;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Add new contract classes from an L2 block to the store's list.
|
|
198
|
+
* @param data - List of contract classes to be added.
|
|
199
|
+
* @param blockNumber - Number of the L2 block the contracts were registered in.
|
|
200
|
+
* @returns True if the operation is successful.
|
|
201
|
+
*/
|
|
202
|
+
addContractClasses(data: ContractClassPublic[], blockNumber: number): Promise<boolean>;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Returns a contract class given its id, or undefined if not exists.
|
|
206
|
+
* @param id - Id of the contract class.
|
|
207
|
+
*/
|
|
208
|
+
getContractClass(id: Fr): Promise<ContractClassPublic | undefined>;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Add new contract instances from an L2 block to the store's list.
|
|
212
|
+
* @param data - List of contract instances to be added.
|
|
213
|
+
* @param blockNumber - Number of the L2 block the instances were deployed in.
|
|
214
|
+
* @returns True if the operation is successful.
|
|
215
|
+
*/
|
|
216
|
+
addContractInstances(data: ContractInstanceWithAddress[], blockNumber: number): Promise<boolean>;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Returns a contract instance given its address, or undefined if not exists.
|
|
220
|
+
* @param address - Address of the contract.
|
|
221
|
+
*/
|
|
222
|
+
getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
|
|
223
|
+
|
|
224
|
+
/** Returns the list of all class ids known by the archiver. */
|
|
225
|
+
getContractClassIds(): Promise<Fr[]>;
|
|
226
|
+
}
|