@aztec/archiver 0.0.0-test.1 → 0.0.1-commit.0208eb9
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 +164 -9
- package/dest/archiver.d.ts +136 -0
- package/dest/archiver.d.ts.map +1 -0
- package/dest/archiver.js +781 -0
- package/dest/config.d.ts +30 -0
- package/dest/config.d.ts.map +1 -0
- package/dest/config.js +71 -0
- package/dest/errors.d.ts +41 -0
- package/dest/errors.d.ts.map +1 -0
- package/dest/errors.js +62 -0
- package/dest/factory.d.ts +13 -16
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +103 -55
- package/dest/index.d.ts +10 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +8 -3
- package/dest/interfaces.d.ts +9 -0
- package/dest/interfaces.d.ts.map +1 -0
- package/dest/interfaces.js +3 -0
- package/dest/l1/bin/retrieve-calldata.d.ts +3 -0
- package/dest/l1/bin/retrieve-calldata.d.ts.map +1 -0
- package/dest/l1/bin/retrieve-calldata.js +149 -0
- package/dest/l1/calldata_retriever.d.ts +112 -0
- package/dest/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/l1/calldata_retriever.js +471 -0
- package/dest/l1/data_retrieval.d.ts +88 -0
- package/dest/l1/data_retrieval.d.ts.map +1 -0
- package/dest/l1/data_retrieval.js +312 -0
- package/dest/l1/debug_tx.d.ts +19 -0
- package/dest/l1/debug_tx.d.ts.map +1 -0
- package/dest/l1/debug_tx.js +73 -0
- package/dest/l1/spire_proposer.d.ts +70 -0
- package/dest/l1/spire_proposer.d.ts.map +1 -0
- package/dest/l1/spire_proposer.js +157 -0
- package/dest/l1/trace_tx.d.ts +97 -0
- package/dest/l1/trace_tx.d.ts.map +1 -0
- package/dest/l1/trace_tx.js +91 -0
- package/dest/l1/types.d.ts +12 -0
- package/dest/l1/types.d.ts.map +1 -0
- package/dest/l1/types.js +3 -0
- package/dest/l1/validate_trace.d.ts +32 -0
- package/dest/l1/validate_trace.d.ts.map +1 -0
- package/dest/l1/validate_trace.js +154 -0
- package/dest/modules/data_source_base.d.ts +84 -0
- package/dest/modules/data_source_base.d.ts.map +1 -0
- package/dest/modules/data_source_base.js +260 -0
- package/dest/modules/data_store_updater.d.ts +73 -0
- package/dest/modules/data_store_updater.d.ts.map +1 -0
- package/dest/modules/data_store_updater.js +302 -0
- package/dest/modules/instrumentation.d.ts +37 -0
- package/dest/modules/instrumentation.d.ts.map +1 -0
- package/dest/modules/instrumentation.js +110 -0
- package/dest/modules/l1_synchronizer.d.ts +75 -0
- package/dest/modules/l1_synchronizer.d.ts.map +1 -0
- package/dest/modules/l1_synchronizer.js +1112 -0
- package/dest/modules/validation.d.ts +17 -0
- package/dest/modules/validation.d.ts.map +1 -0
- package/dest/modules/validation.js +104 -0
- package/dest/store/block_store.d.ts +192 -0
- package/dest/store/block_store.d.ts.map +1 -0
- package/dest/store/block_store.js +721 -0
- package/dest/store/contract_class_store.d.ts +18 -0
- package/dest/store/contract_class_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/contract_class_store.js +25 -27
- package/dest/store/contract_instance_store.d.ts +24 -0
- package/dest/store/contract_instance_store.d.ts.map +1 -0
- package/dest/store/contract_instance_store.js +77 -0
- package/dest/store/kv_archiver_store.d.ts +340 -0
- package/dest/store/kv_archiver_store.d.ts.map +1 -0
- package/dest/store/kv_archiver_store.js +446 -0
- package/dest/store/log_store.d.ts +54 -0
- package/dest/store/log_store.d.ts.map +1 -0
- package/dest/store/log_store.js +436 -0
- package/dest/store/message_store.d.ts +40 -0
- package/dest/store/message_store.d.ts.map +1 -0
- package/dest/store/message_store.js +188 -0
- package/dest/structs/data_retrieval.d.ts +27 -0
- package/dest/structs/data_retrieval.d.ts.map +1 -0
- package/dest/structs/inbox_message.d.ts +15 -0
- package/dest/structs/inbox_message.d.ts.map +1 -0
- package/dest/structs/inbox_message.js +39 -0
- package/dest/structs/published.d.ts +2 -0
- package/dest/structs/published.d.ts.map +1 -0
- package/dest/structs/published.js +1 -0
- package/dest/test/fake_l1_state.d.ts +190 -0
- package/dest/test/fake_l1_state.d.ts.map +1 -0
- package/dest/test/fake_l1_state.js +383 -0
- package/dest/test/index.d.ts +2 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +4 -1
- package/dest/test/mock_archiver.d.ts +16 -8
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +18 -14
- package/dest/test/mock_l1_to_l2_message_source.d.ts +9 -6
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +30 -7
- package/dest/test/mock_l2_block_source.d.ts +62 -16
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +263 -32
- package/dest/test/mock_structs.d.ts +85 -0
- package/dest/test/mock_structs.d.ts.map +1 -0
- package/dest/test/mock_structs.js +171 -0
- package/dest/test/noop_l1_archiver.d.ts +23 -0
- package/dest/test/noop_l1_archiver.d.ts.map +1 -0
- package/dest/test/noop_l1_archiver.js +68 -0
- package/package.json +31 -33
- package/src/archiver.ts +543 -0
- package/src/config.ts +95 -0
- package/src/errors.ts +102 -0
- package/src/factory.ts +144 -71
- package/src/index.ts +10 -3
- package/src/interfaces.ts +9 -0
- package/src/l1/README.md +98 -0
- package/src/l1/bin/retrieve-calldata.ts +187 -0
- package/src/l1/calldata_retriever.ts +641 -0
- package/src/l1/data_retrieval.ts +495 -0
- package/src/l1/debug_tx.ts +99 -0
- package/src/l1/spire_proposer.ts +160 -0
- package/src/l1/trace_tx.ts +128 -0
- package/src/l1/types.ts +13 -0
- package/src/l1/validate_trace.ts +229 -0
- package/src/modules/data_source_base.ts +367 -0
- package/src/modules/data_store_updater.ts +423 -0
- package/src/modules/instrumentation.ts +157 -0
- package/src/modules/l1_synchronizer.ts +930 -0
- package/src/modules/validation.ts +129 -0
- package/src/store/block_store.ts +966 -0
- package/src/{archiver/kv_archiver_store → store}/contract_class_store.ts +26 -32
- package/src/{archiver/kv_archiver_store → store}/contract_instance_store.ts +37 -29
- package/src/store/kv_archiver_store.ts +639 -0
- package/src/store/log_store.ts +575 -0
- package/src/store/message_store.ts +261 -0
- package/src/structs/inbox_message.ts +41 -0
- package/src/structs/published.ts +1 -0
- package/src/test/fake_l1_state.ts +599 -0
- package/src/test/fixtures/debug_traceTransaction-multicall3.json +88 -0
- package/src/test/fixtures/debug_traceTransaction-multiplePropose.json +153 -0
- package/src/test/fixtures/debug_traceTransaction-proxied.json +122 -0
- package/src/test/fixtures/trace_transaction-multicall3.json +65 -0
- package/src/test/fixtures/trace_transaction-multiplePropose.json +319 -0
- package/src/test/fixtures/trace_transaction-proxied.json +128 -0
- package/src/test/fixtures/trace_transaction-randomRevert.json +216 -0
- package/src/test/index.ts +4 -0
- package/src/test/mock_archiver.ts +22 -16
- package/src/test/mock_l1_to_l2_message_source.ts +26 -8
- package/src/test/mock_l2_block_source.ts +313 -42
- package/src/test/mock_structs.ts +311 -0
- package/src/test/noop_l1_archiver.ts +109 -0
- package/dest/archiver/archiver.d.ts +0 -197
- package/dest/archiver/archiver.d.ts.map +0 -1
- package/dest/archiver/archiver.js +0 -900
- package/dest/archiver/archiver_store.d.ts +0 -220
- package/dest/archiver/archiver_store.d.ts.map +0 -1
- package/dest/archiver/archiver_store.js +0 -4
- package/dest/archiver/archiver_store_test_suite.d.ts +0 -8
- package/dest/archiver/archiver_store_test_suite.d.ts.map +0 -1
- package/dest/archiver/archiver_store_test_suite.js +0 -794
- package/dest/archiver/config.d.ts +0 -37
- package/dest/archiver/config.d.ts.map +0 -1
- package/dest/archiver/config.js +0 -46
- package/dest/archiver/data_retrieval.d.ts +0 -74
- package/dest/archiver/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/data_retrieval.js +0 -283
- package/dest/archiver/errors.d.ts +0 -4
- package/dest/archiver/errors.d.ts.map +0 -1
- package/dest/archiver/errors.js +0 -5
- package/dest/archiver/index.d.ts +0 -8
- package/dest/archiver/index.d.ts.map +0 -1
- package/dest/archiver/index.js +0 -5
- package/dest/archiver/instrumentation.d.ts +0 -29
- package/dest/archiver/instrumentation.d.ts.map +0 -1
- package/dest/archiver/instrumentation.js +0 -99
- package/dest/archiver/kv_archiver_store/block_store.d.ts +0 -87
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/block_store.js +0 -217
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +0 -18
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +0 -21
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.js +0 -63
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +0 -153
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +0 -254
- package/dest/archiver/kv_archiver_store/log_store.d.ts +0 -49
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/log_store.js +0 -364
- package/dest/archiver/kv_archiver_store/message_store.d.ts +0 -33
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/message_store.js +0 -85
- 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/dest/archiver/structs/data_retrieval.d.ts +0 -27
- package/dest/archiver/structs/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/structs/published.d.ts +0 -11
- package/dest/archiver/structs/published.d.ts.map +0 -1
- package/dest/archiver/structs/published.js +0 -1
- package/dest/rpc/index.d.ts +0 -10
- package/dest/rpc/index.d.ts.map +0 -1
- package/dest/rpc/index.js +0 -18
- package/src/archiver/archiver.ts +0 -1181
- package/src/archiver/archiver_store.ts +0 -263
- package/src/archiver/archiver_store_test_suite.ts +0 -810
- package/src/archiver/config.ts +0 -92
- package/src/archiver/data_retrieval.ts +0 -422
- package/src/archiver/errors.ts +0 -5
- package/src/archiver/index.ts +0 -7
- package/src/archiver/instrumentation.ts +0 -132
- package/src/archiver/kv_archiver_store/block_store.ts +0 -283
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +0 -358
- package/src/archiver/kv_archiver_store/log_store.ts +0 -444
- package/src/archiver/kv_archiver_store/message_store.ts +0 -102
- 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
- package/src/archiver/structs/published.ts +0 -11
- package/src/rpc/index.ts +0 -20
- /package/dest/{archiver/structs → structs}/data_retrieval.js +0 -0
- /package/src/{archiver/structs → structs}/data_retrieval.ts +0 -0
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
2
|
-
import { toArray } from '@aztec/foundation/iterable';
|
|
3
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncSingleton, Range } from '@aztec/kv-store';
|
|
5
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import { Body, type InBlock, L2Block, L2BlockHash } from '@aztec/stdlib/block';
|
|
7
|
-
import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
8
|
-
import { BlockHeader, TxEffect, TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
9
|
-
|
|
10
|
-
import type { L1Published, L1PublishedData } from '../structs/published.js';
|
|
11
|
-
|
|
12
|
-
export { type TxEffect, type TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
13
|
-
|
|
14
|
-
type BlockIndexValue = [blockNumber: number, index: number];
|
|
15
|
-
|
|
16
|
-
type BlockStorage = {
|
|
17
|
-
header: Buffer;
|
|
18
|
-
archive: Buffer;
|
|
19
|
-
l1: L1PublishedData;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* LMDB implementation of the ArchiverDataStore interface.
|
|
24
|
-
*/
|
|
25
|
-
export class BlockStore {
|
|
26
|
-
/** Map block number to block data */
|
|
27
|
-
#blocks: AztecAsyncMap<number, BlockStorage>;
|
|
28
|
-
|
|
29
|
-
/** Map block hash to block body */
|
|
30
|
-
#blockBodies: AztecAsyncMap<string, Buffer>;
|
|
31
|
-
|
|
32
|
-
/** Stores L1 block number in which the last processed L2 block was included */
|
|
33
|
-
#lastSynchedL1Block: AztecAsyncSingleton<bigint>;
|
|
34
|
-
|
|
35
|
-
/** Stores l2 block number of the last proven block */
|
|
36
|
-
#lastProvenL2Block: AztecAsyncSingleton<number>;
|
|
37
|
-
|
|
38
|
-
/** Stores l2 epoch number of the last proven epoch */
|
|
39
|
-
#lastProvenL2Epoch: AztecAsyncSingleton<number>;
|
|
40
|
-
|
|
41
|
-
/** Index mapping transaction hash (as a string) to its location in a block */
|
|
42
|
-
#txIndex: AztecAsyncMap<string, BlockIndexValue>;
|
|
43
|
-
|
|
44
|
-
/** Index mapping a contract's address (as a string) to its location in a block */
|
|
45
|
-
#contractIndex: AztecAsyncMap<string, BlockIndexValue>;
|
|
46
|
-
|
|
47
|
-
#log = createLogger('archiver:block_store');
|
|
48
|
-
|
|
49
|
-
constructor(private db: AztecAsyncKVStore) {
|
|
50
|
-
this.#blocks = db.openMap('archiver_blocks');
|
|
51
|
-
this.#blockBodies = db.openMap('archiver_block_bodies');
|
|
52
|
-
this.#txIndex = db.openMap('archiver_tx_index');
|
|
53
|
-
this.#contractIndex = db.openMap('archiver_contract_index');
|
|
54
|
-
this.#lastSynchedL1Block = db.openSingleton('archiver_last_synched_l1_block');
|
|
55
|
-
this.#lastProvenL2Block = db.openSingleton('archiver_last_proven_l2_block');
|
|
56
|
-
this.#lastProvenL2Epoch = db.openSingleton('archiver_last_proven_l2_epoch');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Append new blocks to the store's list.
|
|
61
|
-
* @param blocks - The L2 blocks to be added to the store.
|
|
62
|
-
* @returns True if the operation is successful.
|
|
63
|
-
*/
|
|
64
|
-
async addBlocks(blocks: L1Published<L2Block>[]): Promise<boolean> {
|
|
65
|
-
if (blocks.length === 0) {
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return await this.db.transactionAsync(async () => {
|
|
70
|
-
for (const block of blocks) {
|
|
71
|
-
await this.#blocks.set(block.data.number, {
|
|
72
|
-
header: block.data.header.toBuffer(),
|
|
73
|
-
archive: block.data.archive.toBuffer(),
|
|
74
|
-
l1: block.l1,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
for (let i = 0; i < block.data.body.txEffects.length; i++) {
|
|
78
|
-
const txEffect = block.data.body.txEffects[i];
|
|
79
|
-
await this.#txIndex.set(txEffect.txHash.toString(), [block.data.number, i]);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
await this.#blockBodies.set((await block.data.hash()).toString(), block.data.body.toBuffer());
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
await this.#lastSynchedL1Block.set(blocks[blocks.length - 1].l1.blockNumber);
|
|
86
|
-
return true;
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Unwinds blocks from the database
|
|
92
|
-
* @param from - The tip of the chain, passed for verification purposes,
|
|
93
|
-
* ensuring that we don't end up deleting something we did not intend
|
|
94
|
-
* @param blocksToUnwind - The number of blocks we are to unwind
|
|
95
|
-
* @returns True if the operation is successful
|
|
96
|
-
*/
|
|
97
|
-
async unwindBlocks(from: number, blocksToUnwind: number) {
|
|
98
|
-
return await this.db.transactionAsync(async () => {
|
|
99
|
-
const last = await this.getSynchedL2BlockNumber();
|
|
100
|
-
if (from !== last) {
|
|
101
|
-
throw new Error(`Can only unwind blocks from the tip (requested ${from} but current tip is ${last})`);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
for (let i = 0; i < blocksToUnwind; i++) {
|
|
105
|
-
const blockNumber = from - i;
|
|
106
|
-
const block = await this.getBlock(blockNumber);
|
|
107
|
-
|
|
108
|
-
if (block === undefined) {
|
|
109
|
-
this.#log.warn(`Cannot remove block ${blockNumber} from the store since we don't have it`);
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
await this.#blocks.delete(block.data.number);
|
|
113
|
-
await Promise.all(block.data.body.txEffects.map(tx => this.#txIndex.delete(tx.txHash.toString())));
|
|
114
|
-
const blockHash = (await block.data.hash()).toString();
|
|
115
|
-
await this.#blockBodies.delete(blockHash);
|
|
116
|
-
this.#log.debug(`Unwound block ${blockNumber} ${blockHash}`);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return true;
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Gets up to `limit` amount of L2 blocks starting from `from`.
|
|
125
|
-
* @param start - Number of the first block to return (inclusive).
|
|
126
|
-
* @param limit - The number of blocks to return.
|
|
127
|
-
* @returns The requested L2 blocks
|
|
128
|
-
*/
|
|
129
|
-
async *getBlocks(start: number, limit: number): AsyncIterableIterator<L1Published<L2Block>> {
|
|
130
|
-
for await (const blockStorage of this.#blocks.valuesAsync(this.#computeBlockRange(start, limit))) {
|
|
131
|
-
const block = await this.getBlockFromBlockStorage(blockStorage);
|
|
132
|
-
yield block;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Gets an L2 block.
|
|
138
|
-
* @param blockNumber - The number of the block to return.
|
|
139
|
-
* @returns The requested L2 block.
|
|
140
|
-
*/
|
|
141
|
-
async getBlock(blockNumber: number): Promise<L1Published<L2Block> | undefined> {
|
|
142
|
-
const blockStorage = await this.#blocks.getAsync(blockNumber);
|
|
143
|
-
if (!blockStorage || !blockStorage.header) {
|
|
144
|
-
return Promise.resolve(undefined);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return this.getBlockFromBlockStorage(blockStorage);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Gets the headers for a sequence of L2 blocks.
|
|
152
|
-
* @param start - Number of the first block to return (inclusive).
|
|
153
|
-
* @param limit - The number of blocks to return.
|
|
154
|
-
* @returns The requested L2 block headers
|
|
155
|
-
*/
|
|
156
|
-
async *getBlockHeaders(start: number, limit: number): AsyncIterableIterator<BlockHeader> {
|
|
157
|
-
for await (const blockStorage of this.#blocks.valuesAsync(this.#computeBlockRange(start, limit))) {
|
|
158
|
-
yield BlockHeader.fromBuffer(blockStorage.header);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
private async getBlockFromBlockStorage(blockStorage: BlockStorage) {
|
|
163
|
-
const header = BlockHeader.fromBuffer(blockStorage.header);
|
|
164
|
-
const archive = AppendOnlyTreeSnapshot.fromBuffer(blockStorage.archive);
|
|
165
|
-
const blockHash = (await header.hash()).toString();
|
|
166
|
-
const blockBodyBuffer = await this.#blockBodies.getAsync(blockHash);
|
|
167
|
-
if (blockBodyBuffer === undefined) {
|
|
168
|
-
throw new Error(
|
|
169
|
-
`Could not retrieve body for block ${header.globalVariables.blockNumber.toNumber()} ${blockHash}`,
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
const body = Body.fromBuffer(blockBodyBuffer);
|
|
173
|
-
|
|
174
|
-
const l2Block = new L2Block(archive, header, body);
|
|
175
|
-
return { data: l2Block, l1: blockStorage.l1 };
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Gets a tx effect.
|
|
180
|
-
* @param txHash - The txHash of the tx corresponding to the tx effect.
|
|
181
|
-
* @returns The requested tx effect (or undefined if not found).
|
|
182
|
-
*/
|
|
183
|
-
async getTxEffect(txHash: TxHash): Promise<InBlock<TxEffect> | undefined> {
|
|
184
|
-
const [blockNumber, txIndex] = (await this.getTxLocation(txHash)) ?? [];
|
|
185
|
-
if (typeof blockNumber !== 'number' || typeof txIndex !== 'number') {
|
|
186
|
-
return undefined;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const block = await this.getBlock(blockNumber);
|
|
190
|
-
if (!block) {
|
|
191
|
-
return undefined;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return {
|
|
195
|
-
data: block.data.body.txEffects[txIndex],
|
|
196
|
-
l2BlockNumber: block.data.number,
|
|
197
|
-
l2BlockHash: (await block.data.hash()).toString(),
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Gets a receipt of a settled tx.
|
|
203
|
-
* @param txHash - The hash of a tx we try to get the receipt for.
|
|
204
|
-
* @returns The requested tx receipt (or undefined if not found).
|
|
205
|
-
*/
|
|
206
|
-
async getSettledTxReceipt(txHash: TxHash): Promise<TxReceipt | undefined> {
|
|
207
|
-
const [blockNumber, txIndex] = (await this.getTxLocation(txHash)) ?? [];
|
|
208
|
-
if (typeof blockNumber !== 'number' || typeof txIndex !== 'number') {
|
|
209
|
-
return undefined;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const block = (await this.getBlock(blockNumber))!;
|
|
213
|
-
const tx = block.data.body.txEffects[txIndex];
|
|
214
|
-
|
|
215
|
-
return new TxReceipt(
|
|
216
|
-
txHash,
|
|
217
|
-
TxReceipt.statusFromRevertCode(tx.revertCode),
|
|
218
|
-
'',
|
|
219
|
-
tx.transactionFee.toBigInt(),
|
|
220
|
-
L2BlockHash.fromField(await block.data.hash()),
|
|
221
|
-
block.data.number,
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Looks up which block included the requested tx effect.
|
|
227
|
-
* @param txHash - The txHash of the tx.
|
|
228
|
-
* @returns The block number and index of the tx.
|
|
229
|
-
*/
|
|
230
|
-
getTxLocation(txHash: TxHash): Promise<[blockNumber: number, txIndex: number] | undefined> {
|
|
231
|
-
return this.#txIndex.getAsync(txHash.toString());
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Looks up which block deployed a particular contract.
|
|
236
|
-
* @param contractAddress - The address of the contract to look up.
|
|
237
|
-
* @returns The block number and index of the contract.
|
|
238
|
-
*/
|
|
239
|
-
getContractLocation(contractAddress: AztecAddress): Promise<[blockNumber: number, index: number] | undefined> {
|
|
240
|
-
return this.#contractIndex.getAsync(contractAddress.toString());
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Gets the number of the latest L2 block processed.
|
|
245
|
-
* @returns The number of the latest L2 block processed.
|
|
246
|
-
*/
|
|
247
|
-
async getSynchedL2BlockNumber(): Promise<number> {
|
|
248
|
-
const [lastBlockNumber] = await toArray(this.#blocks.keysAsync({ reverse: true, limit: 1 }));
|
|
249
|
-
return typeof lastBlockNumber === 'number' ? lastBlockNumber : INITIAL_L2_BLOCK_NUM - 1;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Gets the most recent L1 block processed.
|
|
254
|
-
* @returns The L1 block that published the latest L2 block
|
|
255
|
-
*/
|
|
256
|
-
getSynchedL1BlockNumber(): Promise<bigint | undefined> {
|
|
257
|
-
return this.#lastSynchedL1Block.getAsync();
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
setSynchedL1BlockNumber(l1BlockNumber: bigint) {
|
|
261
|
-
return this.#lastSynchedL1Block.set(l1BlockNumber);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
async getProvenL2BlockNumber(): Promise<number> {
|
|
265
|
-
return (await this.#lastProvenL2Block.getAsync()) ?? 0;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
setProvenL2BlockNumber(blockNumber: number) {
|
|
269
|
-
return this.#lastProvenL2Block.set(blockNumber);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
#computeBlockRange(start: number, limit: number): Required<Pick<Range<number>, 'start' | 'limit'>> {
|
|
273
|
-
if (limit < 1) {
|
|
274
|
-
throw new Error(`Invalid limit: ${limit}`);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
if (start < INITIAL_L2_BLOCK_NUM) {
|
|
278
|
-
throw new Error(`Invalid start: ${start}`);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
return { start, limit };
|
|
282
|
-
}
|
|
283
|
-
}
|
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import { toArray } from '@aztec/foundation/iterable';
|
|
3
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import type { AztecAsyncKVStore, StoreSize } from '@aztec/kv-store';
|
|
5
|
-
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
6
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
-
import type { InBlock, L2Block } from '@aztec/stdlib/block';
|
|
8
|
-
import type {
|
|
9
|
-
ContractClassPublic,
|
|
10
|
-
ContractInstanceUpdateWithAddress,
|
|
11
|
-
ContractInstanceWithAddress,
|
|
12
|
-
ExecutablePrivateFunctionWithMembershipProof,
|
|
13
|
-
UnconstrainedFunctionWithMembershipProof,
|
|
14
|
-
} from '@aztec/stdlib/contract';
|
|
15
|
-
import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
|
|
16
|
-
import { type LogFilter, PrivateLog, type TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
17
|
-
import type { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
18
|
-
import type { BlockHeader, TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
19
|
-
|
|
20
|
-
import type { ArchiverDataStore, ArchiverL1SynchPoint } from '../archiver_store.js';
|
|
21
|
-
import type { DataRetrieval } from '../structs/data_retrieval.js';
|
|
22
|
-
import type { L1Published } from '../structs/published.js';
|
|
23
|
-
import { BlockStore } from './block_store.js';
|
|
24
|
-
import { ContractClassStore } from './contract_class_store.js';
|
|
25
|
-
import { ContractInstanceStore } from './contract_instance_store.js';
|
|
26
|
-
import { LogStore } from './log_store.js';
|
|
27
|
-
import { MessageStore } from './message_store.js';
|
|
28
|
-
import { NullifierStore } from './nullifier_store.js';
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* LMDB implementation of the ArchiverDataStore interface.
|
|
32
|
-
*/
|
|
33
|
-
export class KVArchiverDataStore implements ArchiverDataStore {
|
|
34
|
-
public static readonly SCHEMA_VERSION = 1;
|
|
35
|
-
|
|
36
|
-
#blockStore: BlockStore;
|
|
37
|
-
#logStore: LogStore;
|
|
38
|
-
#nullifierStore: NullifierStore;
|
|
39
|
-
#messageStore: MessageStore;
|
|
40
|
-
#contractClassStore: ContractClassStore;
|
|
41
|
-
#contractInstanceStore: ContractInstanceStore;
|
|
42
|
-
private functionNames = new Map<string, string>();
|
|
43
|
-
|
|
44
|
-
#log = createLogger('archiver:data-store');
|
|
45
|
-
|
|
46
|
-
constructor(private db: AztecAsyncKVStore, logsMaxPageSize: number = 1000) {
|
|
47
|
-
this.#blockStore = new BlockStore(db);
|
|
48
|
-
this.#logStore = new LogStore(db, this.#blockStore, logsMaxPageSize);
|
|
49
|
-
this.#messageStore = new MessageStore(db);
|
|
50
|
-
this.#contractClassStore = new ContractClassStore(db);
|
|
51
|
-
this.#contractInstanceStore = new ContractInstanceStore(db);
|
|
52
|
-
this.#nullifierStore = new NullifierStore(db);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// TODO: These function names are in memory only as they are for development/debugging. They require the full contract
|
|
56
|
-
// artifact supplied to the node out of band. This should be reviewed and potentially removed as part of
|
|
57
|
-
// the node api cleanup process.
|
|
58
|
-
getContractFunctionName(_address: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
|
|
59
|
-
return Promise.resolve(this.functionNames.get(selector.toString()));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async registerContractFunctionSignatures(_address: AztecAddress, signatures: string[]): Promise<void> {
|
|
63
|
-
for (const sig of signatures) {
|
|
64
|
-
try {
|
|
65
|
-
const selector = await FunctionSelector.fromSignature(sig);
|
|
66
|
-
this.functionNames.set(selector.toString(), sig.slice(0, sig.indexOf('(')));
|
|
67
|
-
} catch {
|
|
68
|
-
this.#log.warn(`Failed to parse signature: ${sig}. Ignoring`);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
|
|
74
|
-
return this.#contractClassStore.getContractClass(id);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
getContractClassIds(): Promise<Fr[]> {
|
|
78
|
-
return this.#contractClassStore.getContractClassIds();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
|
|
82
|
-
const contract = this.#contractInstanceStore.getContractInstance(address, await this.getSynchedL2BlockNumber());
|
|
83
|
-
return contract;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async addContractClasses(
|
|
87
|
-
data: ContractClassPublic[],
|
|
88
|
-
bytecodeCommitments: Fr[],
|
|
89
|
-
blockNumber: number,
|
|
90
|
-
): Promise<boolean> {
|
|
91
|
-
return (
|
|
92
|
-
await Promise.all(
|
|
93
|
-
data.map((c, i) => this.#contractClassStore.addContractClass(c, bytecodeCommitments[i], blockNumber)),
|
|
94
|
-
)
|
|
95
|
-
).every(Boolean);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async deleteContractClasses(data: ContractClassPublic[], blockNumber: number): Promise<boolean> {
|
|
99
|
-
return (await Promise.all(data.map(c => this.#contractClassStore.deleteContractClasses(c, blockNumber)))).every(
|
|
100
|
-
Boolean,
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
getBytecodeCommitment(contractClassId: Fr): Promise<Fr | undefined> {
|
|
105
|
-
return this.#contractClassStore.getBytecodeCommitment(contractClassId);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
addFunctions(
|
|
109
|
-
contractClassId: Fr,
|
|
110
|
-
privateFunctions: ExecutablePrivateFunctionWithMembershipProof[],
|
|
111
|
-
unconstrainedFunctions: UnconstrainedFunctionWithMembershipProof[],
|
|
112
|
-
): Promise<boolean> {
|
|
113
|
-
return this.#contractClassStore.addFunctions(contractClassId, privateFunctions, unconstrainedFunctions);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async addContractInstances(data: ContractInstanceWithAddress[], _blockNumber: number): Promise<boolean> {
|
|
117
|
-
return (await Promise.all(data.map(c => this.#contractInstanceStore.addContractInstance(c)))).every(Boolean);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
async deleteContractInstances(data: ContractInstanceWithAddress[], _blockNumber: number): Promise<boolean> {
|
|
121
|
-
return (await Promise.all(data.map(c => this.#contractInstanceStore.deleteContractInstance(c)))).every(Boolean);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
async addContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[], blockNumber: number): Promise<boolean> {
|
|
125
|
-
return (
|
|
126
|
-
await Promise.all(
|
|
127
|
-
data.map((update, logIndex) =>
|
|
128
|
-
this.#contractInstanceStore.addContractInstanceUpdate(update, blockNumber, logIndex),
|
|
129
|
-
),
|
|
130
|
-
)
|
|
131
|
-
).every(Boolean);
|
|
132
|
-
}
|
|
133
|
-
async deleteContractInstanceUpdates(
|
|
134
|
-
data: ContractInstanceUpdateWithAddress[],
|
|
135
|
-
blockNumber: number,
|
|
136
|
-
): Promise<boolean> {
|
|
137
|
-
return (
|
|
138
|
-
await Promise.all(
|
|
139
|
-
data.map((update, logIndex) =>
|
|
140
|
-
this.#contractInstanceStore.deleteContractInstanceUpdate(update, blockNumber, logIndex),
|
|
141
|
-
),
|
|
142
|
-
)
|
|
143
|
-
).every(Boolean);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Append new blocks to the store's list.
|
|
148
|
-
* @param blocks - The L2 blocks to be added to the store and the last processed L1 block.
|
|
149
|
-
* @returns True if the operation is successful.
|
|
150
|
-
*/
|
|
151
|
-
addBlocks(blocks: L1Published<L2Block>[]): Promise<boolean> {
|
|
152
|
-
return this.#blockStore.addBlocks(blocks);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Unwinds blocks from the database
|
|
157
|
-
* @param from - The tip of the chain, passed for verification purposes,
|
|
158
|
-
* ensuring that we don't end up deleting something we did not intend
|
|
159
|
-
* @param blocksToUnwind - The number of blocks we are to unwind
|
|
160
|
-
* @returns True if the operation is successful
|
|
161
|
-
*/
|
|
162
|
-
unwindBlocks(from: number, blocksToUnwind: number): Promise<boolean> {
|
|
163
|
-
return this.#blockStore.unwindBlocks(from, blocksToUnwind);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Gets up to `limit` amount of L2 blocks starting from `from`.
|
|
168
|
-
*
|
|
169
|
-
* @param start - Number of the first block to return (inclusive).
|
|
170
|
-
* @param limit - The number of blocks to return.
|
|
171
|
-
* @returns The requested L2 blocks
|
|
172
|
-
*/
|
|
173
|
-
getBlocks(start: number, limit: number): Promise<L1Published<L2Block>[]> {
|
|
174
|
-
return toArray(this.#blockStore.getBlocks(start, limit));
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Gets up to `limit` amount of L2 blocks headers starting from `from`.
|
|
179
|
-
*
|
|
180
|
-
* @param start - Number of the first block to return (inclusive).
|
|
181
|
-
* @param limit - The number of blocks to return.
|
|
182
|
-
* @returns The requested L2 blocks
|
|
183
|
-
*/
|
|
184
|
-
getBlockHeaders(start: number, limit: number): Promise<BlockHeader[]> {
|
|
185
|
-
return toArray(this.#blockStore.getBlockHeaders(start, limit));
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Gets a tx effect.
|
|
190
|
-
* @param txHash - The txHash of the tx corresponding to the tx effect.
|
|
191
|
-
* @returns The requested tx effect (or undefined if not found).
|
|
192
|
-
*/
|
|
193
|
-
getTxEffect(txHash: TxHash) {
|
|
194
|
-
return this.#blockStore.getTxEffect(txHash);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Gets a receipt of a settled tx.
|
|
199
|
-
* @param txHash - The hash of a tx we try to get the receipt for.
|
|
200
|
-
* @returns The requested tx receipt (or undefined if not found).
|
|
201
|
-
*/
|
|
202
|
-
getSettledTxReceipt(txHash: TxHash): Promise<TxReceipt | undefined> {
|
|
203
|
-
return this.#blockStore.getSettledTxReceipt(txHash);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Append new logs to the store's list.
|
|
208
|
-
* @param blocks - The blocks for which to add the logs.
|
|
209
|
-
* @returns True if the operation is successful.
|
|
210
|
-
*/
|
|
211
|
-
addLogs(blocks: L2Block[]): Promise<boolean> {
|
|
212
|
-
return this.#logStore.addLogs(blocks);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
deleteLogs(blocks: L2Block[]): Promise<boolean> {
|
|
216
|
-
return this.#logStore.deleteLogs(blocks);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Append new nullifiers to the store's list.
|
|
221
|
-
* @param blocks - The blocks for which to add the nullifiers.
|
|
222
|
-
* @returns True if the operation is successful.
|
|
223
|
-
*/
|
|
224
|
-
addNullifiers(blocks: L2Block[]): Promise<boolean> {
|
|
225
|
-
return this.#nullifierStore.addNullifiers(blocks);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
deleteNullifiers(blocks: L2Block[]): Promise<boolean> {
|
|
229
|
-
return this.#nullifierStore.deleteNullifiers(blocks);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
findNullifiersIndexesWithBlock(blockNumber: number, nullifiers: Fr[]): Promise<(InBlock<bigint> | undefined)[]> {
|
|
233
|
-
return this.#nullifierStore.findNullifiersIndexesWithBlock(blockNumber, nullifiers);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
getTotalL1ToL2MessageCount(): Promise<bigint> {
|
|
237
|
-
return this.#messageStore.getTotalL1ToL2MessageCount();
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Append L1 to L2 messages to the store.
|
|
242
|
-
* @param messages - The L1 to L2 messages to be added to the store and the last processed L1 block.
|
|
243
|
-
* @returns True if the operation is successful.
|
|
244
|
-
*/
|
|
245
|
-
addL1ToL2Messages(messages: DataRetrieval<InboxLeaf>): Promise<boolean> {
|
|
246
|
-
return this.#messageStore.addL1ToL2Messages(messages);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Gets the L1 to L2 message index in the L1 to L2 message tree.
|
|
251
|
-
* @param l1ToL2Message - The L1 to L2 message.
|
|
252
|
-
* @returns The index of the L1 to L2 message in the L1 to L2 message tree (undefined if not found).
|
|
253
|
-
*/
|
|
254
|
-
getL1ToL2MessageIndex(l1ToL2Message: Fr): Promise<bigint | undefined> {
|
|
255
|
-
return this.#messageStore.getL1ToL2MessageIndex(l1ToL2Message);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Gets L1 to L2 message (to be) included in a given block.
|
|
260
|
-
* @param blockNumber - L2 block number to get messages for.
|
|
261
|
-
* @returns The L1 to L2 messages/leaves of the messages subtree (throws if not found).
|
|
262
|
-
*/
|
|
263
|
-
getL1ToL2Messages(blockNumber: bigint): Promise<Fr[]> {
|
|
264
|
-
return this.#messageStore.getL1ToL2Messages(blockNumber);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Retrieves all private logs from up to `limit` blocks, starting from the block number `from`.
|
|
269
|
-
* @param from - The block number from which to begin retrieving logs.
|
|
270
|
-
* @param limit - The maximum number of blocks to retrieve logs from.
|
|
271
|
-
* @returns An array of private logs from the specified range of blocks.
|
|
272
|
-
*/
|
|
273
|
-
getPrivateLogs(from: number, limit: number): Promise<PrivateLog[]> {
|
|
274
|
-
return this.#logStore.getPrivateLogs(from, limit);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Gets all logs that match any of the received tags (i.e. logs with their first field equal to a tag).
|
|
279
|
-
* @param tags - The tags to filter the logs by.
|
|
280
|
-
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
|
|
281
|
-
* that tag.
|
|
282
|
-
*/
|
|
283
|
-
getLogsByTags(tags: Fr[]): Promise<TxScopedL2Log[][]> {
|
|
284
|
-
try {
|
|
285
|
-
return this.#logStore.getLogsByTags(tags);
|
|
286
|
-
} catch (err) {
|
|
287
|
-
return Promise.reject(err);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* Gets public logs based on the provided filter.
|
|
293
|
-
* @param filter - The filter to apply to the logs.
|
|
294
|
-
* @returns The requested logs.
|
|
295
|
-
*/
|
|
296
|
-
getPublicLogs(filter: LogFilter): Promise<GetPublicLogsResponse> {
|
|
297
|
-
try {
|
|
298
|
-
return this.#logStore.getPublicLogs(filter);
|
|
299
|
-
} catch (err) {
|
|
300
|
-
return Promise.reject(err);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Gets contract class logs based on the provided filter.
|
|
306
|
-
* @param filter - The filter to apply to the logs.
|
|
307
|
-
* @returns The requested logs.
|
|
308
|
-
*/
|
|
309
|
-
getContractClassLogs(filter: LogFilter): Promise<GetContractClassLogsResponse> {
|
|
310
|
-
try {
|
|
311
|
-
return this.#logStore.getContractClassLogs(filter);
|
|
312
|
-
} catch (err) {
|
|
313
|
-
return Promise.reject(err);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Gets the number of the latest L2 block processed.
|
|
319
|
-
* @returns The number of the latest L2 block processed.
|
|
320
|
-
*/
|
|
321
|
-
getSynchedL2BlockNumber(): Promise<number> {
|
|
322
|
-
return this.#blockStore.getSynchedL2BlockNumber();
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
getProvenL2BlockNumber(): Promise<number> {
|
|
326
|
-
return this.#blockStore.getProvenL2BlockNumber();
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
async setProvenL2BlockNumber(blockNumber: number) {
|
|
330
|
-
await this.#blockStore.setProvenL2BlockNumber(blockNumber);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
async setBlockSynchedL1BlockNumber(l1BlockNumber: bigint) {
|
|
334
|
-
await this.#blockStore.setSynchedL1BlockNumber(l1BlockNumber);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
async setMessageSynchedL1BlockNumber(l1BlockNumber: bigint) {
|
|
338
|
-
await this.#messageStore.setSynchedL1BlockNumber(l1BlockNumber);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* Gets the last L1 block number processed by the archiver
|
|
343
|
-
*/
|
|
344
|
-
async getSynchPoint(): Promise<ArchiverL1SynchPoint> {
|
|
345
|
-
const [blocksSynchedTo, messagesSynchedTo] = await Promise.all([
|
|
346
|
-
this.#blockStore.getSynchedL1BlockNumber(),
|
|
347
|
-
this.#messageStore.getSynchedL1BlockNumber(),
|
|
348
|
-
]);
|
|
349
|
-
return {
|
|
350
|
-
blocksSynchedTo,
|
|
351
|
-
messagesSynchedTo,
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
public estimateSize(): Promise<StoreSize> {
|
|
356
|
-
return this.db.estimateSize();
|
|
357
|
-
}
|
|
358
|
-
}
|