@aztec/archiver 0.0.1-commit.6d3c34e → 0.0.1-commit.7035c9bd6
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 +156 -22
- package/dest/archiver.d.ts +138 -0
- package/dest/archiver.d.ts.map +1 -0
- package/dest/archiver.js +732 -0
- package/dest/config.d.ts +30 -0
- package/dest/config.d.ts.map +1 -0
- package/dest/{archiver/config.js → config.js} +11 -1
- package/dest/errors.d.ts +53 -0
- package/dest/errors.d.ts.map +1 -0
- package/dest/errors.js +75 -0
- package/dest/factory.d.ts +8 -7
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +90 -8
- package/dest/index.d.ts +11 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +9 -3
- package/dest/interfaces.d.ts +9 -0
- package/dest/interfaces.d.ts.map +1 -0
- package/dest/interfaces.js +3 -0
- package/dest/{archiver/l1 → l1}/bin/retrieve-calldata.d.ts +1 -1
- package/dest/l1/bin/retrieve-calldata.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/bin/retrieve-calldata.js +35 -32
- package/dest/l1/calldata_retriever.d.ts +135 -0
- package/dest/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/l1/calldata_retriever.js +402 -0
- package/dest/l1/data_retrieval.d.ts +88 -0
- package/dest/l1/data_retrieval.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/data_retrieval.js +54 -71
- package/dest/{archiver/l1 → l1}/debug_tx.d.ts +1 -1
- package/dest/l1/debug_tx.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/spire_proposer.d.ts +5 -5
- package/dest/l1/spire_proposer.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/spire_proposer.js +9 -17
- package/dest/{archiver/l1 → l1}/trace_tx.d.ts +1 -1
- package/dest/l1/trace_tx.d.ts.map +1 -0
- package/dest/l1/types.d.ts +12 -0
- package/dest/l1/types.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/validate_trace.d.ts +6 -3
- package/dest/l1/validate_trace.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/validate_trace.js +13 -9
- package/dest/modules/data_source_base.d.ts +89 -0
- package/dest/modules/data_source_base.d.ts.map +1 -0
- package/dest/modules/data_source_base.js +216 -0
- package/dest/modules/data_store_updater.d.ts +88 -0
- package/dest/modules/data_store_updater.d.ts.map +1 -0
- package/dest/modules/data_store_updater.js +342 -0
- package/dest/modules/instrumentation.d.ts +50 -0
- package/dest/modules/instrumentation.d.ts.map +1 -0
- package/dest/{archiver → modules}/instrumentation.js +36 -12
- package/dest/modules/l1_synchronizer.d.ts +72 -0
- package/dest/modules/l1_synchronizer.d.ts.map +1 -0
- package/dest/modules/l1_synchronizer.js +1147 -0
- package/dest/{archiver → modules}/validation.d.ts +1 -1
- package/dest/modules/validation.d.ts.map +1 -0
- package/dest/{archiver → modules}/validation.js +6 -0
- package/dest/store/block_store.d.ts +195 -0
- package/dest/store/block_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/block_store.js +248 -101
- 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 +12 -8
- package/dest/store/contract_instance_store.d.ts +24 -0
- package/dest/store/contract_instance_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/contract_instance_store.js +1 -1
- package/dest/store/kv_archiver_store.d.ts +367 -0
- package/dest/store/kv_archiver_store.d.ts.map +1 -0
- package/dest/store/kv_archiver_store.js +481 -0
- package/dest/store/l2_tips_cache.d.ts +19 -0
- package/dest/store/l2_tips_cache.d.ts.map +1 -0
- package/dest/store/l2_tips_cache.js +89 -0
- package/dest/store/log_store.d.ts +57 -0
- package/dest/store/log_store.d.ts.map +1 -0
- package/dest/store/log_store.js +533 -0
- package/dest/store/message_store.d.ts +44 -0
- package/dest/store/message_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/message_store.js +14 -1
- package/dest/{archiver/structs → structs}/data_retrieval.d.ts +1 -1
- 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/{archiver/structs → structs}/published.d.ts +1 -1
- package/dest/structs/published.d.ts.map +1 -0
- package/dest/test/fake_l1_state.d.ts +202 -0
- package/dest/test/fake_l1_state.d.ts.map +1 -0
- package/dest/test/fake_l1_state.js +455 -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 +2 -2
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +3 -3
- package/dest/test/mock_l2_block_source.d.ts +38 -19
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +183 -77
- package/dest/test/mock_structs.d.ts +81 -3
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +152 -7
- package/dest/test/noop_l1_archiver.d.ts +26 -0
- package/dest/test/noop_l1_archiver.d.ts.map +1 -0
- package/dest/test/noop_l1_archiver.js +72 -0
- package/package.json +16 -17
- package/src/archiver.ts +486 -0
- package/src/{archiver/config.ts → config.ts} +19 -1
- package/src/{archiver/errors.ts → errors.ts} +52 -24
- package/src/factory.ts +141 -10
- package/src/index.ts +11 -3
- package/src/interfaces.ts +9 -0
- package/src/l1/README.md +55 -0
- package/src/{archiver/l1 → l1}/bin/retrieve-calldata.ts +45 -33
- package/src/l1/calldata_retriever.ts +511 -0
- package/src/{archiver/l1 → l1}/data_retrieval.ts +75 -94
- package/src/{archiver/l1 → l1}/spire_proposer.ts +7 -15
- package/src/{archiver/l1 → l1}/validate_trace.ts +24 -6
- package/src/modules/data_source_base.ts +333 -0
- package/src/modules/data_store_updater.ts +464 -0
- package/src/{archiver → modules}/instrumentation.ts +46 -14
- package/src/modules/l1_synchronizer.ts +967 -0
- package/src/{archiver → modules}/validation.ts +5 -0
- package/src/{archiver/kv_archiver_store → store}/block_store.ts +309 -141
- package/src/{archiver/kv_archiver_store → store}/contract_class_store.ts +12 -8
- package/src/{archiver/kv_archiver_store → store}/contract_instance_store.ts +1 -1
- package/src/{archiver/kv_archiver_store → store}/kv_archiver_store.ts +294 -39
- package/src/store/l2_tips_cache.ts +89 -0
- package/src/store/log_store.ts +736 -0
- package/src/{archiver/kv_archiver_store → store}/message_store.ts +20 -1
- package/src/test/fake_l1_state.ts +698 -0
- package/src/test/index.ts +4 -0
- package/src/test/mock_archiver.ts +4 -3
- package/src/test/mock_l2_block_source.ts +233 -93
- package/src/test/mock_structs.ts +283 -8
- package/src/test/noop_l1_archiver.ts +115 -0
- package/dest/archiver/archiver.d.ts +0 -307
- package/dest/archiver/archiver.d.ts.map +0 -1
- package/dest/archiver/archiver.js +0 -2102
- package/dest/archiver/archiver_store.d.ts +0 -315
- 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 -2770
- package/dest/archiver/config.d.ts +0 -22
- package/dest/archiver/config.d.ts.map +0 -1
- package/dest/archiver/errors.d.ts +0 -36
- package/dest/archiver/errors.d.ts.map +0 -1
- package/dest/archiver/errors.js +0 -54
- package/dest/archiver/index.d.ts +0 -7
- package/dest/archiver/index.d.ts.map +0 -1
- package/dest/archiver/index.js +0 -4
- package/dest/archiver/instrumentation.d.ts +0 -37
- package/dest/archiver/instrumentation.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/block_store.d.ts +0 -164
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
- 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 -24
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +0 -159
- 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 -316
- package/dest/archiver/kv_archiver_store/log_store.d.ts +0 -45
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/log_store.js +0 -401
- package/dest/archiver/kv_archiver_store/message_store.d.ts +0 -40
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +0 -1
- package/dest/archiver/l1/bin/retrieve-calldata.d.ts.map +0 -1
- package/dest/archiver/l1/calldata_retriever.d.ts +0 -112
- package/dest/archiver/l1/calldata_retriever.d.ts.map +0 -1
- package/dest/archiver/l1/calldata_retriever.js +0 -471
- package/dest/archiver/l1/data_retrieval.d.ts +0 -90
- package/dest/archiver/l1/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/l1/debug_tx.d.ts.map +0 -1
- package/dest/archiver/l1/spire_proposer.d.ts.map +0 -1
- package/dest/archiver/l1/trace_tx.d.ts.map +0 -1
- package/dest/archiver/l1/types.d.ts +0 -12
- package/dest/archiver/l1/types.d.ts.map +0 -1
- package/dest/archiver/l1/validate_trace.d.ts.map +0 -1
- package/dest/archiver/structs/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/structs/inbox_message.d.ts +0 -15
- package/dest/archiver/structs/inbox_message.d.ts.map +0 -1
- package/dest/archiver/structs/published.d.ts.map +0 -1
- package/dest/archiver/validation.d.ts.map +0 -1
- package/dest/rpc/index.d.ts +0 -9
- package/dest/rpc/index.d.ts.map +0 -1
- package/dest/rpc/index.js +0 -15
- package/src/archiver/archiver.ts +0 -2265
- package/src/archiver/archiver_store.ts +0 -380
- package/src/archiver/archiver_store_test_suite.ts +0 -2842
- package/src/archiver/index.ts +0 -6
- package/src/archiver/kv_archiver_store/log_store.ts +0 -516
- package/src/archiver/l1/README.md +0 -98
- package/src/archiver/l1/calldata_retriever.ts +0 -641
- package/src/rpc/index.ts +0 -16
- /package/dest/{archiver/l1 → l1}/debug_tx.js +0 -0
- /package/dest/{archiver/l1 → l1}/trace_tx.js +0 -0
- /package/dest/{archiver/l1 → l1}/types.js +0 -0
- /package/dest/{archiver/structs → structs}/data_retrieval.js +0 -0
- /package/dest/{archiver/structs → structs}/inbox_message.js +0 -0
- /package/dest/{archiver/structs → structs}/published.js +0 -0
- /package/src/{archiver/l1 → l1}/debug_tx.ts +0 -0
- /package/src/{archiver/l1 → l1}/trace_tx.ts +0 -0
- /package/src/{archiver/l1 → l1}/types.ts +0 -0
- /package/src/{archiver/structs → structs}/data_retrieval.ts +0 -0
- /package/src/{archiver/structs → structs}/inbox_message.ts +0 -0
- /package/src/{archiver/structs → structs}/published.ts +0 -0
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
import { Vector } from '@aztec/stdlib/types';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* LMDB
|
|
15
|
+
* LMDB-based contract class storage for the archiver.
|
|
16
16
|
*/
|
|
17
17
|
export class ContractClassStore {
|
|
18
18
|
#contractClasses: AztecAsyncMap<string, Buffer>;
|
|
@@ -28,18 +28,22 @@ export class ContractClassStore {
|
|
|
28
28
|
bytecodeCommitment: Fr,
|
|
29
29
|
blockNumber: number,
|
|
30
30
|
): Promise<void> {
|
|
31
|
-
await this
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
await this.db.transactionAsync(async () => {
|
|
32
|
+
await this.#contractClasses.setIfNotExists(
|
|
33
|
+
contractClass.id.toString(),
|
|
34
|
+
serializeContractClassPublic({ ...contractClass, l2BlockNumber: blockNumber }),
|
|
35
|
+
);
|
|
36
|
+
await this.#bytecodeCommitments.setIfNotExists(contractClass.id.toString(), bytecodeCommitment.toBuffer());
|
|
37
|
+
});
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
async deleteContractClasses(contractClass: ContractClassPublic, blockNumber: number): Promise<void> {
|
|
39
41
|
const restoredContractClass = await this.#contractClasses.getAsync(contractClass.id.toString());
|
|
40
42
|
if (restoredContractClass && deserializeContractClassPublic(restoredContractClass).l2BlockNumber >= blockNumber) {
|
|
41
|
-
await this
|
|
42
|
-
|
|
43
|
+
await this.db.transactionAsync(async () => {
|
|
44
|
+
await this.#contractClasses.delete(contractClass.id.toString());
|
|
45
|
+
await this.#bytecodeCommitments.delete(contractClass.id.toString());
|
|
46
|
+
});
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
49
|
|
|
@@ -12,7 +12,7 @@ import type { UInt64 } from '@aztec/stdlib/types';
|
|
|
12
12
|
type ContractInstanceUpdateKey = [string, string] | [string, string, number];
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* LMDB
|
|
15
|
+
* LMDB-based contract instance storage for the archiver.
|
|
16
16
|
*/
|
|
17
17
|
export class ContractInstanceStore {
|
|
18
18
|
#contractInstances: AztecAsyncMap<string, Buffer>;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import type { L1BlockId } from '@aztec/ethereum/l1-types';
|
|
2
|
-
import type { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import { toArray } from '@aztec/foundation/iterable';
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
6
|
import type { AztecAsyncKVStore, CustomRange, StoreSize } from '@aztec/kv-store';
|
|
7
7
|
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
8
8
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
|
-
import {
|
|
10
|
-
|
|
9
|
+
import {
|
|
10
|
+
type BlockData,
|
|
11
|
+
BlockHash,
|
|
12
|
+
CheckpointedL2Block,
|
|
13
|
+
L2Block,
|
|
14
|
+
type ValidateCheckpointResult,
|
|
15
|
+
} from '@aztec/stdlib/block';
|
|
16
|
+
import type { CheckpointData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
11
17
|
import type {
|
|
12
18
|
ContractClassPublic,
|
|
13
19
|
ContractDataSource,
|
|
@@ -16,6 +22,7 @@ import type {
|
|
|
16
22
|
ExecutablePrivateFunctionWithMembershipProof,
|
|
17
23
|
UtilityFunctionWithMembershipProof,
|
|
18
24
|
} from '@aztec/stdlib/contract';
|
|
25
|
+
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
19
26
|
import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
|
|
20
27
|
import type { LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
21
28
|
import type { BlockHeader, TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
@@ -23,9 +30,8 @@ import type { UInt64 } from '@aztec/stdlib/types';
|
|
|
23
30
|
|
|
24
31
|
import { join } from 'path';
|
|
25
32
|
|
|
26
|
-
import type { ArchiverDataStore, ArchiverL1SynchPoint } from '../archiver_store.js';
|
|
27
33
|
import type { InboxMessage } from '../structs/inbox_message.js';
|
|
28
|
-
import { BlockStore, type
|
|
34
|
+
import { BlockStore, type RemoveCheckpointsResult } from './block_store.js';
|
|
29
35
|
import { ContractClassStore } from './contract_class_store.js';
|
|
30
36
|
import { ContractInstanceStore } from './contract_instance_store.js';
|
|
31
37
|
import { LogStore } from './log_store.js';
|
|
@@ -36,9 +42,20 @@ export const MAX_FUNCTION_SIGNATURES = 1000;
|
|
|
36
42
|
export const MAX_FUNCTION_NAME_LEN = 256;
|
|
37
43
|
|
|
38
44
|
/**
|
|
39
|
-
*
|
|
45
|
+
* Represents the latest L1 block processed by the archiver for various objects in L2.
|
|
40
46
|
*/
|
|
41
|
-
export
|
|
47
|
+
export type ArchiverL1SynchPoint = {
|
|
48
|
+
/** Number of the last L1 block that added a new L2 checkpoint metadata. */
|
|
49
|
+
blocksSynchedTo?: bigint;
|
|
50
|
+
/** Last L1 block checked for L1 to L2 messages. */
|
|
51
|
+
messagesSynchedTo?: L1BlockId;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* LMDB-based data store for the archiver.
|
|
56
|
+
* Stores all archiver data including blocks, logs, contract classes/instances, and L1 to L2 messages.
|
|
57
|
+
*/
|
|
58
|
+
export class KVArchiverDataStore implements ContractDataSource {
|
|
42
59
|
public static readonly SCHEMA_VERSION = ARCHIVER_DB_VERSION;
|
|
43
60
|
|
|
44
61
|
#blockStore: BlockStore;
|
|
@@ -62,6 +79,12 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
62
79
|
this.#contractInstanceStore = new ContractInstanceStore(db);
|
|
63
80
|
}
|
|
64
81
|
|
|
82
|
+
/** Returns the underlying block store. Used by L2TipsCache. */
|
|
83
|
+
get blockStore(): BlockStore {
|
|
84
|
+
return this.#blockStore;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Opens a new transaction to the underlying store and runs all operations within it. */
|
|
65
88
|
public transactionAsync<T>(callback: () => Promise<T>): Promise<T> {
|
|
66
89
|
return this.db.transactionAsync(callback);
|
|
67
90
|
}
|
|
@@ -79,19 +102,28 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
79
102
|
return this.getContractInstance(address, timestamp);
|
|
80
103
|
}
|
|
81
104
|
|
|
105
|
+
/** Backups the archiver db to the target folder. Returns the path to the db file. */
|
|
82
106
|
public async backupTo(path: string, compress = true): Promise<string> {
|
|
83
107
|
await this.db.backupTo(path, compress);
|
|
84
108
|
return join(path, 'data.mdb');
|
|
85
109
|
}
|
|
86
110
|
|
|
111
|
+
/** Closes the underlying data store. */
|
|
87
112
|
public close() {
|
|
88
113
|
return this.db.close();
|
|
89
114
|
}
|
|
90
115
|
|
|
116
|
+
/** Computes the finalized block number based on the proven block number. */
|
|
117
|
+
getFinalizedL2BlockNumber(): Promise<BlockNumber> {
|
|
118
|
+
return this.#blockStore.getFinalizedL2BlockNumber();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Looks up a public function name given a selector. */
|
|
91
122
|
getDebugFunctionName(_address: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
|
|
92
123
|
return Promise.resolve(this.functionNames.get(selector.toString()));
|
|
93
124
|
}
|
|
94
125
|
|
|
126
|
+
/** Register a public function signature, so it can be looked up by selector. */
|
|
95
127
|
async registerContractFunctionSignatures(signatures: string[]): Promise<void> {
|
|
96
128
|
for (const sig of signatures) {
|
|
97
129
|
if (this.functionNames.size > MAX_FUNCTION_SIGNATURES) {
|
|
@@ -106,14 +138,25 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
106
138
|
}
|
|
107
139
|
}
|
|
108
140
|
|
|
141
|
+
/**
|
|
142
|
+
* Returns a contract class given its id, or undefined if not exists.
|
|
143
|
+
* @param id - Id of the contract class.
|
|
144
|
+
*/
|
|
109
145
|
getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
|
|
110
146
|
return this.#contractClassStore.getContractClass(id);
|
|
111
147
|
}
|
|
112
148
|
|
|
149
|
+
/** Returns the list of all class ids known by the archiver. */
|
|
113
150
|
getContractClassIds(): Promise<Fr[]> {
|
|
114
151
|
return this.#contractClassStore.getContractClassIds();
|
|
115
152
|
}
|
|
116
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Returns a contract instance given its address and the given timestamp, or undefined if not exists.
|
|
156
|
+
* @param address - Address of the contract.
|
|
157
|
+
* @param timestamp - Timestamp to get the contract instance at. Contract updates might change the instance.
|
|
158
|
+
* @returns The contract instance or undefined if not found.
|
|
159
|
+
*/
|
|
117
160
|
getContractInstance(address: AztecAddress, timestamp: UInt64): Promise<ContractInstanceWithAddress | undefined> {
|
|
118
161
|
return this.#contractInstanceStore.getContractInstance(address, timestamp);
|
|
119
162
|
}
|
|
@@ -122,6 +165,13 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
122
165
|
return this.#contractInstanceStore.getContractInstanceDeploymentBlockNumber(address);
|
|
123
166
|
}
|
|
124
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Add new contract classes from an L2 block to the store's list.
|
|
170
|
+
* @param data - List of contract classes to be added.
|
|
171
|
+
* @param bytecodeCommitments - Bytecode commitments for the contract classes.
|
|
172
|
+
* @param blockNumber - Number of the L2 block the contracts were registered in.
|
|
173
|
+
* @returns True if the operation is successful.
|
|
174
|
+
*/
|
|
125
175
|
async addContractClasses(
|
|
126
176
|
data: ContractClassPublic[],
|
|
127
177
|
bytecodeCommitments: Fr[],
|
|
@@ -144,6 +194,7 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
144
194
|
return this.#contractClassStore.getBytecodeCommitment(contractClassId);
|
|
145
195
|
}
|
|
146
196
|
|
|
197
|
+
/** Adds private functions to a contract class. */
|
|
147
198
|
addFunctions(
|
|
148
199
|
contractClassId: Fr,
|
|
149
200
|
privateFunctions: ExecutablePrivateFunctionWithMembershipProof[],
|
|
@@ -152,6 +203,12 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
152
203
|
return this.#contractClassStore.addFunctions(contractClassId, privateFunctions, utilityFunctions);
|
|
153
204
|
}
|
|
154
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Add new contract instances from an L2 block to the store's list.
|
|
208
|
+
* @param data - List of contract instances to be added.
|
|
209
|
+
* @param blockNumber - Number of the L2 block the instances were deployed in.
|
|
210
|
+
* @returns True if the operation is successful.
|
|
211
|
+
*/
|
|
155
212
|
async addContractInstances(data: ContractInstanceWithAddress[], blockNumber: BlockNumber): Promise<boolean> {
|
|
156
213
|
return (await Promise.all(data.map(c => this.#contractInstanceStore.addContractInstance(c, blockNumber)))).every(
|
|
157
214
|
Boolean,
|
|
@@ -162,6 +219,12 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
162
219
|
return (await Promise.all(data.map(c => this.#contractInstanceStore.deleteContractInstance(c)))).every(Boolean);
|
|
163
220
|
}
|
|
164
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Add new contract instance updates
|
|
224
|
+
* @param data - List of contract updates to be added.
|
|
225
|
+
* @param timestamp - Timestamp at which the updates were scheduled.
|
|
226
|
+
* @returns True if the operation is successful.
|
|
227
|
+
*/
|
|
165
228
|
async addContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[], timestamp: UInt64): Promise<boolean> {
|
|
166
229
|
return (
|
|
167
230
|
await Promise.all(
|
|
@@ -182,81 +245,156 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
182
245
|
}
|
|
183
246
|
|
|
184
247
|
/**
|
|
185
|
-
* Append new
|
|
186
|
-
*
|
|
248
|
+
* Append a new proposed block to the store.
|
|
249
|
+
* This is an uncheckpointed block that has been proposed by the sequencer but not yet included in a checkpoint on L1.
|
|
250
|
+
* For checkpointed blocks (already published to L1), use addCheckpoints() instead.
|
|
251
|
+
* @param block - The proposed L2 block to be added to the store.
|
|
187
252
|
* @returns True if the operation is successful.
|
|
188
253
|
*/
|
|
189
|
-
|
|
190
|
-
return this.#blockStore.
|
|
254
|
+
addProposedBlock(block: L2Block, opts: { force?: boolean } = {}): Promise<boolean> {
|
|
255
|
+
return this.#blockStore.addProposedBlock(block, opts);
|
|
191
256
|
}
|
|
192
257
|
|
|
258
|
+
/**
|
|
259
|
+
* Returns an array of checkpoint objects
|
|
260
|
+
* @param from The first checkpoint number to be retrieved
|
|
261
|
+
* @param limit The maximum number of checkpoints to retrieve
|
|
262
|
+
* @returns The array of requested checkpoint data objects
|
|
263
|
+
*/
|
|
193
264
|
getRangeOfCheckpoints(from: CheckpointNumber, limit: number): Promise<CheckpointData[]> {
|
|
194
265
|
return this.#blockStore.getRangeOfCheckpoints(from, limit);
|
|
195
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* Returns the number of the latest block
|
|
269
|
+
* @returns The number of the latest block
|
|
270
|
+
*/
|
|
196
271
|
getLatestBlockNumber(): Promise<BlockNumber> {
|
|
197
272
|
return this.#blockStore.getLatestBlockNumber();
|
|
198
273
|
}
|
|
199
274
|
|
|
200
275
|
/**
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
* @param checkpointsToUnwind - The number of checkpoints we are to unwind
|
|
205
|
-
* @returns True if the operation is successful
|
|
276
|
+
* Removes all checkpoints with checkpoint number > checkpointNumber.
|
|
277
|
+
* Also removes ALL blocks (both checkpointed and uncheckpointed) after the last block of the given checkpoint.
|
|
278
|
+
* @param checkpointNumber - Remove all checkpoints strictly after this one.
|
|
206
279
|
*/
|
|
207
|
-
|
|
208
|
-
return this.#blockStore.
|
|
280
|
+
removeCheckpointsAfter(checkpointNumber: CheckpointNumber): Promise<RemoveCheckpointsResult> {
|
|
281
|
+
return this.#blockStore.removeCheckpointsAfter(checkpointNumber);
|
|
209
282
|
}
|
|
210
283
|
|
|
284
|
+
/**
|
|
285
|
+
* Appends new checkpoints, and their blocks to the store's collection
|
|
286
|
+
* @param checkpoints The collection of checkpoints to be added
|
|
287
|
+
* @returns True if the operation is successful
|
|
288
|
+
*/
|
|
211
289
|
addCheckpoints(checkpoints: PublishedCheckpoint[]): Promise<boolean> {
|
|
212
290
|
return this.#blockStore.addCheckpoints(checkpoints);
|
|
213
291
|
}
|
|
214
292
|
|
|
293
|
+
/**
|
|
294
|
+
* Returns the block for the given number, or undefined if not exists.
|
|
295
|
+
* @param number - The block number to return.
|
|
296
|
+
*/
|
|
215
297
|
getCheckpointedBlock(number: BlockNumber): Promise<CheckpointedL2Block | undefined> {
|
|
216
298
|
return this.#blockStore.getCheckpointedBlock(number);
|
|
217
299
|
}
|
|
218
|
-
|
|
300
|
+
/**
|
|
301
|
+
* Returns the block for the given hash, or undefined if not exists.
|
|
302
|
+
* @param blockHash - The block hash to return.
|
|
303
|
+
*/
|
|
304
|
+
getCheckpointedBlockByHash(blockHash: BlockHash): Promise<CheckpointedL2Block | undefined> {
|
|
219
305
|
return this.#blockStore.getCheckpointedBlockByHash(blockHash);
|
|
220
306
|
}
|
|
307
|
+
/**
|
|
308
|
+
* Returns the block for the given archive root, or undefined if not exists.
|
|
309
|
+
* @param archive - The archive root to return.
|
|
310
|
+
*/
|
|
221
311
|
getCheckpointedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined> {
|
|
222
312
|
return this.#blockStore.getCheckpointedBlockByArchive(archive);
|
|
223
313
|
}
|
|
224
|
-
|
|
314
|
+
/**
|
|
315
|
+
* Returns the block for the given number, or undefined if not exists.
|
|
316
|
+
* @param number - The block number to return.
|
|
317
|
+
*/
|
|
318
|
+
getBlock(number: BlockNumber): Promise<L2Block | undefined> {
|
|
225
319
|
return this.#blockStore.getBlock(number);
|
|
226
320
|
}
|
|
227
|
-
|
|
228
|
-
|
|
321
|
+
/**
|
|
322
|
+
* Returns the block for the given hash, or undefined if not exists.
|
|
323
|
+
* @param blockHash - The block hash to return.
|
|
324
|
+
*/
|
|
325
|
+
getBlockByHash(blockHash: BlockHash): Promise<L2Block | undefined> {
|
|
326
|
+
return this.#blockStore.getBlockByHash(blockHash);
|
|
229
327
|
}
|
|
230
|
-
|
|
328
|
+
/**
|
|
329
|
+
* Returns the block for the given archive root, or undefined if not exists.
|
|
330
|
+
* @param archive - The archive root to return.
|
|
331
|
+
*/
|
|
332
|
+
getBlockByArchive(archive: Fr): Promise<L2Block | undefined> {
|
|
231
333
|
return this.#blockStore.getBlockByArchive(archive);
|
|
232
334
|
}
|
|
233
|
-
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Gets up to `limit` amount of published L2 blocks starting from `from`.
|
|
338
|
+
* @param from - Number of the first block to return (inclusive).
|
|
339
|
+
* @param limit - The number of blocks to return.
|
|
340
|
+
* @returns The requested L2 blocks.
|
|
341
|
+
*/
|
|
342
|
+
getBlocks(from: BlockNumber, limit: number): Promise<L2Block[]> {
|
|
234
343
|
return toArray(this.#blockStore.getBlocks(from, limit));
|
|
235
344
|
}
|
|
236
345
|
|
|
346
|
+
/**
|
|
347
|
+
* Gets up to `limit` amount of checkpointed L2 blocks starting from `from`.
|
|
348
|
+
* @param from - Number of the first block to return (inclusive).
|
|
349
|
+
* @param limit - The number of blocks to return.
|
|
350
|
+
* @returns The requested checkpointed L2 blocks.
|
|
351
|
+
*/
|
|
237
352
|
getCheckpointedBlocks(from: BlockNumber, limit: number): Promise<CheckpointedL2Block[]> {
|
|
238
353
|
return toArray(this.#blockStore.getCheckpointedBlocks(from, limit));
|
|
239
354
|
}
|
|
240
355
|
|
|
241
356
|
/**
|
|
242
|
-
* Gets up to `limit` amount of L2
|
|
243
|
-
*
|
|
357
|
+
* Gets up to `limit` amount of L2 block headers starting from `from`.
|
|
244
358
|
* @param start - Number of the first block to return (inclusive).
|
|
245
359
|
* @param limit - The number of blocks to return.
|
|
246
|
-
* @returns The requested L2
|
|
360
|
+
* @returns The requested L2 block headers.
|
|
247
361
|
*/
|
|
248
362
|
getBlockHeaders(start: BlockNumber, limit: number): Promise<BlockHeader[]> {
|
|
249
363
|
return toArray(this.#blockStore.getBlockHeaders(start, limit));
|
|
250
364
|
}
|
|
251
365
|
|
|
252
|
-
|
|
253
|
-
|
|
366
|
+
/**
|
|
367
|
+
* Returns the block header for the given hash, or undefined if not exists.
|
|
368
|
+
* @param blockHash - The block hash to return.
|
|
369
|
+
*/
|
|
370
|
+
getBlockHeaderByHash(blockHash: BlockHash): Promise<BlockHeader | undefined> {
|
|
371
|
+
return this.#blockStore.getBlockHeaderByHash(blockHash);
|
|
254
372
|
}
|
|
255
373
|
|
|
374
|
+
/**
|
|
375
|
+
* Returns the block header for the given archive root, or undefined if not exists.
|
|
376
|
+
* @param archive - The archive root to return.
|
|
377
|
+
*/
|
|
256
378
|
getBlockHeaderByArchive(archive: Fr): Promise<BlockHeader | undefined> {
|
|
257
379
|
return this.#blockStore.getBlockHeaderByArchive(archive);
|
|
258
380
|
}
|
|
259
381
|
|
|
382
|
+
/**
|
|
383
|
+
* Gets block metadata (without tx data) by block number.
|
|
384
|
+
* @param blockNumber - The block number to return.
|
|
385
|
+
*/
|
|
386
|
+
getBlockData(blockNumber: BlockNumber): Promise<BlockData | undefined> {
|
|
387
|
+
return this.#blockStore.getBlockData(blockNumber);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Gets block metadata (without tx data) by archive root.
|
|
392
|
+
* @param archive - The archive root to return.
|
|
393
|
+
*/
|
|
394
|
+
getBlockDataByArchive(archive: Fr): Promise<BlockData | undefined> {
|
|
395
|
+
return this.#blockStore.getBlockDataByArchive(archive);
|
|
396
|
+
}
|
|
397
|
+
|
|
260
398
|
/**
|
|
261
399
|
* Gets a tx effect.
|
|
262
400
|
* @param txHash - The hash of the tx corresponding to the tx effect.
|
|
@@ -271,8 +409,11 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
271
409
|
* @param txHash - The hash of a tx we try to get the receipt for.
|
|
272
410
|
* @returns The requested tx receipt (or undefined if not found).
|
|
273
411
|
*/
|
|
274
|
-
getSettledTxReceipt(
|
|
275
|
-
|
|
412
|
+
getSettledTxReceipt(
|
|
413
|
+
txHash: TxHash,
|
|
414
|
+
l1Constants?: Pick<L1RollupConstants, 'epochDuration'>,
|
|
415
|
+
): Promise<TxReceipt | undefined> {
|
|
416
|
+
return this.#blockStore.getSettledTxReceipt(txHash, l1Constants);
|
|
276
417
|
}
|
|
277
418
|
|
|
278
419
|
/**
|
|
@@ -280,18 +421,23 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
280
421
|
* @param blocks - The blocks for which to add the logs.
|
|
281
422
|
* @returns True if the operation is successful.
|
|
282
423
|
*/
|
|
283
|
-
addLogs(blocks:
|
|
424
|
+
addLogs(blocks: L2Block[]): Promise<boolean> {
|
|
284
425
|
return this.#logStore.addLogs(blocks);
|
|
285
426
|
}
|
|
286
427
|
|
|
287
|
-
deleteLogs(blocks:
|
|
428
|
+
deleteLogs(blocks: L2Block[]): Promise<boolean> {
|
|
288
429
|
return this.#logStore.deleteLogs(blocks);
|
|
289
430
|
}
|
|
290
431
|
|
|
432
|
+
/**
|
|
433
|
+
* Get the total number of L1 to L2 messages
|
|
434
|
+
* @returns The number of L1 to L2 messages in the store
|
|
435
|
+
*/
|
|
291
436
|
getTotalL1ToL2MessageCount(): Promise<bigint> {
|
|
292
437
|
return this.#messageStore.getTotalL1ToL2MessageCount();
|
|
293
438
|
}
|
|
294
439
|
|
|
440
|
+
/** Returns the last L1 to L2 message stored. */
|
|
295
441
|
getLastL1ToL2Message(): Promise<InboxMessage | undefined> {
|
|
296
442
|
return this.#messageStore.getLastMessage();
|
|
297
443
|
}
|
|
@@ -299,6 +445,7 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
299
445
|
/**
|
|
300
446
|
* Append L1 to L2 messages to the store.
|
|
301
447
|
* @param messages - The L1 to L2 messages to be added to the store.
|
|
448
|
+
* @returns True if the operation is successful.
|
|
302
449
|
*/
|
|
303
450
|
addL1ToL2Messages(messages: InboxMessage[]): Promise<void> {
|
|
304
451
|
return this.#messageStore.addL1ToL2Messages(messages);
|
|
@@ -322,17 +469,37 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
322
469
|
return this.#messageStore.getL1ToL2Messages(checkpointNumber);
|
|
323
470
|
}
|
|
324
471
|
|
|
325
|
-
|
|
472
|
+
/**
|
|
473
|
+
* Gets private logs that match any of the `tags`. For each tag, an array of matching logs is returned. An empty
|
|
474
|
+
* array implies no logs match that tag.
|
|
475
|
+
* @param tags - The tags to search for.
|
|
476
|
+
* @param page - The page number (0-indexed) for pagination. Returns at most 10 logs per tag per page.
|
|
477
|
+
* @param upToBlockNumber - If set, only return logs from blocks up to and including this block number.
|
|
478
|
+
*/
|
|
479
|
+
getPrivateLogsByTags(tags: SiloedTag[], page?: number, upToBlockNumber?: BlockNumber): Promise<TxScopedL2Log[][]> {
|
|
326
480
|
try {
|
|
327
|
-
return this.#logStore.getPrivateLogsByTags(tags);
|
|
481
|
+
return this.#logStore.getPrivateLogsByTags(tags, page, upToBlockNumber);
|
|
328
482
|
} catch (err) {
|
|
329
483
|
return Promise.reject(err);
|
|
330
484
|
}
|
|
331
485
|
}
|
|
332
486
|
|
|
333
|
-
|
|
487
|
+
/**
|
|
488
|
+
* Gets public logs that match any of the `tags` from the specified contract. For each tag, an array of matching
|
|
489
|
+
* logs is returned. An empty array implies no logs match that tag.
|
|
490
|
+
* @param contractAddress - The contract address to search logs for.
|
|
491
|
+
* @param tags - The tags to search for.
|
|
492
|
+
* @param page - The page number (0-indexed) for pagination. Returns at most 10 logs per tag per page.
|
|
493
|
+
* @param upToBlockNumber - If set, only return logs from blocks up to and including this block number.
|
|
494
|
+
*/
|
|
495
|
+
getPublicLogsByTagsFromContract(
|
|
496
|
+
contractAddress: AztecAddress,
|
|
497
|
+
tags: Tag[],
|
|
498
|
+
page?: number,
|
|
499
|
+
upToBlockNumber?: BlockNumber,
|
|
500
|
+
): Promise<TxScopedL2Log[][]> {
|
|
334
501
|
try {
|
|
335
|
-
return this.#logStore.getPublicLogsByTagsFromContract(contractAddress, tags);
|
|
502
|
+
return this.#logStore.getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber);
|
|
336
503
|
} catch (err) {
|
|
337
504
|
return Promise.reject(err);
|
|
338
505
|
}
|
|
@@ -364,28 +531,59 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
364
531
|
}
|
|
365
532
|
}
|
|
366
533
|
|
|
534
|
+
/**
|
|
535
|
+
* Gets the number of the latest proven checkpoint processed.
|
|
536
|
+
* @returns The number of the latest proven checkpoint processed.
|
|
537
|
+
*/
|
|
367
538
|
getProvenCheckpointNumber(): Promise<CheckpointNumber> {
|
|
368
539
|
return this.#blockStore.getProvenCheckpointNumber();
|
|
369
540
|
}
|
|
370
541
|
|
|
542
|
+
/**
|
|
543
|
+
* Stores the number of the latest proven checkpoint processed.
|
|
544
|
+
* @param checkpointNumber - The number of the latest proven checkpoint processed.
|
|
545
|
+
*/
|
|
371
546
|
async setProvenCheckpointNumber(checkpointNumber: CheckpointNumber) {
|
|
372
547
|
await this.#blockStore.setProvenCheckpointNumber(checkpointNumber);
|
|
373
548
|
}
|
|
374
549
|
|
|
550
|
+
/**
|
|
551
|
+
* Gets the number of the latest finalized checkpoint processed.
|
|
552
|
+
* @returns The number of the latest finalized checkpoint processed.
|
|
553
|
+
*/
|
|
554
|
+
getFinalizedCheckpointNumber(): Promise<CheckpointNumber> {
|
|
555
|
+
return this.#blockStore.getFinalizedCheckpointNumber();
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Stores the number of the latest finalized checkpoint processed.
|
|
560
|
+
* @param checkpointNumber - The number of the latest finalized checkpoint processed.
|
|
561
|
+
*/
|
|
562
|
+
async setFinalizedCheckpointNumber(checkpointNumber: CheckpointNumber) {
|
|
563
|
+
await this.#blockStore.setFinalizedCheckpointNumber(checkpointNumber);
|
|
564
|
+
}
|
|
565
|
+
|
|
375
566
|
async setBlockSynchedL1BlockNumber(l1BlockNumber: bigint) {
|
|
376
567
|
await this.#blockStore.setSynchedL1BlockNumber(l1BlockNumber);
|
|
377
568
|
}
|
|
378
569
|
|
|
570
|
+
/**
|
|
571
|
+
* Stores the l1 block that messages have been synched until
|
|
572
|
+
*/
|
|
379
573
|
async setMessageSynchedL1Block(l1Block: L1BlockId) {
|
|
380
574
|
await this.#messageStore.setSynchedL1Block(l1Block);
|
|
381
575
|
}
|
|
382
576
|
|
|
577
|
+
/**
|
|
578
|
+
* Returns the number of the most recent proven block
|
|
579
|
+
* @returns The number of the most recent proven block
|
|
580
|
+
*/
|
|
383
581
|
getProvenBlockNumber(): Promise<BlockNumber> {
|
|
384
582
|
return this.#blockStore.getProvenBlockNumber();
|
|
385
583
|
}
|
|
386
584
|
|
|
387
585
|
/**
|
|
388
|
-
* Gets the
|
|
586
|
+
* Gets the synch point of the archiver
|
|
389
587
|
*/
|
|
390
588
|
async getSynchPoint(): Promise<ArchiverL1SynchPoint> {
|
|
391
589
|
const [blocksSynchedTo, messagesSynchedTo] = await Promise.all([
|
|
@@ -398,45 +596,102 @@ export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSourc
|
|
|
398
596
|
};
|
|
399
597
|
}
|
|
400
598
|
|
|
599
|
+
/** Estimates the size of the store in bytes. */
|
|
401
600
|
public estimateSize(): Promise<StoreSize> {
|
|
402
601
|
return this.db.estimateSize();
|
|
403
602
|
}
|
|
404
603
|
|
|
604
|
+
/** Deletes all L1 to L2 messages up until (excluding) the target checkpoint number. */
|
|
405
605
|
public rollbackL1ToL2MessagesToCheckpoint(targetCheckpointNumber: CheckpointNumber): Promise<void> {
|
|
406
606
|
return this.#messageStore.rollbackL1ToL2MessagesToCheckpoint(targetCheckpointNumber);
|
|
407
607
|
}
|
|
408
608
|
|
|
609
|
+
/** Persists the inbox tree-in-progress checkpoint number from L1 state. */
|
|
610
|
+
public setInboxTreeInProgress(value: bigint): Promise<void> {
|
|
611
|
+
return this.#messageStore.setInboxTreeInProgress(value);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/** Returns an async iterator to all L1 to L2 messages on the range. */
|
|
409
615
|
public iterateL1ToL2Messages(range: CustomRange<bigint> = {}): AsyncIterableIterator<InboxMessage> {
|
|
410
616
|
return this.#messageStore.iterateL1ToL2Messages(range);
|
|
411
617
|
}
|
|
412
618
|
|
|
619
|
+
/** Removes all L1 to L2 messages starting from the given index (inclusive). */
|
|
413
620
|
public removeL1ToL2Messages(startIndex: bigint): Promise<void> {
|
|
414
621
|
return this.#messageStore.removeL1ToL2Messages(startIndex);
|
|
415
622
|
}
|
|
416
623
|
|
|
624
|
+
/** Returns the last synced validation status of the pending chain. */
|
|
417
625
|
public getPendingChainValidationStatus(): Promise<ValidateCheckpointResult | undefined> {
|
|
418
626
|
return this.#blockStore.getPendingChainValidationStatus();
|
|
419
627
|
}
|
|
420
628
|
|
|
629
|
+
/** Sets the last synced validation status of the pending chain. */
|
|
421
630
|
public setPendingChainValidationStatus(status: ValidateCheckpointResult | undefined): Promise<void> {
|
|
422
631
|
return this.#blockStore.setPendingChainValidationStatus(status);
|
|
423
632
|
}
|
|
424
633
|
|
|
634
|
+
/**
|
|
635
|
+
* Gets the number of the latest L2 block processed.
|
|
636
|
+
* @returns The number of the latest L2 block processed.
|
|
637
|
+
*/
|
|
425
638
|
public getCheckpointedL2BlockNumber(): Promise<BlockNumber> {
|
|
426
639
|
return this.#blockStore.getCheckpointedL2BlockNumber();
|
|
427
640
|
}
|
|
641
|
+
/**
|
|
642
|
+
* Gets the number of the latest published checkpoint processed.
|
|
643
|
+
* @returns The number of the latest published checkpoint processed
|
|
644
|
+
*/
|
|
428
645
|
public getSynchedCheckpointNumber(): Promise<CheckpointNumber> {
|
|
429
646
|
return this.#blockStore.getLatestCheckpointNumber();
|
|
430
647
|
}
|
|
648
|
+
/**
|
|
649
|
+
* Stores the l1 block number that checkpoints have been synched until
|
|
650
|
+
* @param l1BlockNumber - The l1 block number
|
|
651
|
+
*/
|
|
431
652
|
async setCheckpointSynchedL1BlockNumber(l1BlockNumber: bigint): Promise<void> {
|
|
432
653
|
await this.#blockStore.setSynchedL1BlockNumber(l1BlockNumber);
|
|
433
654
|
}
|
|
434
655
|
|
|
435
|
-
|
|
656
|
+
/**
|
|
657
|
+
* Retrieves all blocks for the requested checkpoint
|
|
658
|
+
* @param checkpointNumber Retrieves all blocks for the given checkpoint
|
|
659
|
+
* @returns The collection of blocks for the requested checkpoint if available (undefined otherwise)
|
|
660
|
+
*/
|
|
661
|
+
getBlocksForCheckpoint(checkpointNumber: CheckpointNumber): Promise<L2Block[] | undefined> {
|
|
436
662
|
return this.#blockStore.getBlocksForCheckpoint(checkpointNumber);
|
|
437
663
|
}
|
|
438
664
|
|
|
665
|
+
/**
|
|
666
|
+
* Returns checkpoint data for the requested checkpoint number
|
|
667
|
+
* @param checkpointNumber - The checkpoint requested
|
|
668
|
+
* @returns The checkpoint data or undefined if not found
|
|
669
|
+
*/
|
|
439
670
|
getCheckpointData(checkpointNumber: CheckpointNumber): Promise<CheckpointData | undefined> {
|
|
440
671
|
return this.#blockStore.getCheckpointData(checkpointNumber);
|
|
441
672
|
}
|
|
673
|
+
|
|
674
|
+
/** Returns checkpoint data for all checkpoints whose slot falls within the given range (inclusive). */
|
|
675
|
+
getCheckpointDataForSlotRange(startSlot: SlotNumber, endSlot: SlotNumber): Promise<CheckpointData[]> {
|
|
676
|
+
return this.#blockStore.getCheckpointDataForSlotRange(startSlot, endSlot);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Gets all blocks that have the given slot number.
|
|
681
|
+
* @param slotNumber - The slot number to search for.
|
|
682
|
+
* @returns All blocks with the given slot number.
|
|
683
|
+
*/
|
|
684
|
+
getBlocksForSlot(slotNumber: SlotNumber): Promise<L2Block[]> {
|
|
685
|
+
return this.#blockStore.getBlocksForSlot(slotNumber);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Removes all blocks with block number > blockNumber.
|
|
690
|
+
* Does not remove any associated checkpoints.
|
|
691
|
+
* @param blockNumber - The block number to remove after.
|
|
692
|
+
* @returns The removed blocks (for event emission).
|
|
693
|
+
*/
|
|
694
|
+
removeBlocksAfter(blockNumber: BlockNumber): Promise<L2Block[]> {
|
|
695
|
+
return this.#blockStore.removeBlocksAfter(blockNumber);
|
|
696
|
+
}
|
|
442
697
|
}
|