@aztec/archiver 0.0.1-commit.d3ec352c → 0.0.1-commit.f295ac2
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 +147 -22
- package/dest/archiver.d.ts +135 -0
- package/dest/archiver.d.ts.map +1 -0
- package/dest/archiver.js +769 -0
- package/dest/config.d.ts +30 -0
- package/dest/config.d.ts.map +1 -0
- package/dest/{archiver/config.js → config.js} +21 -5
- package/dest/errors.d.ts +36 -0
- package/dest/errors.d.ts.map +1 -0
- package/dest/errors.js +54 -0
- package/dest/factory.d.ts +5 -6
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +82 -5
- 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/{archiver → l1}/data_retrieval.js +75 -150
- 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 +29 -0
- package/dest/l1/validate_trace.d.ts.map +1 -0
- package/dest/l1/validate_trace.js +150 -0
- package/dest/modules/data_source_base.d.ts +85 -0
- package/dest/modules/data_source_base.d.ts.map +1 -0
- package/dest/modules/data_source_base.js +291 -0
- package/dest/modules/data_store_updater.d.ts +69 -0
- package/dest/modules/data_store_updater.d.ts.map +1 -0
- package/dest/modules/data_store_updater.js +304 -0
- package/dest/modules/instrumentation.d.ts +37 -0
- package/dest/modules/instrumentation.d.ts.map +1 -0
- package/dest/{archiver → modules}/instrumentation.js +22 -59
- 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 +1113 -0
- package/dest/modules/validation.d.ts +17 -0
- package/dest/modules/validation.d.ts.map +1 -0
- package/dest/{archiver → modules}/validation.js +7 -1
- package/dest/store/block_store.d.ts +178 -0
- package/dest/store/block_store.d.ts.map +1 -0
- package/dest/store/block_store.js +680 -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 +2 -2
- 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 +331 -0
- package/dest/store/kv_archiver_store.d.ts.map +1 -0
- package/dest/store/kv_archiver_store.js +438 -0
- package/dest/store/log_store.d.ts +45 -0
- package/dest/store/log_store.d.ts.map +1 -0
- package/dest/store/log_store.js +422 -0
- package/dest/store/message_store.d.ts +40 -0
- package/dest/store/message_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/message_store.js +15 -14
- 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}/inbox_message.js +6 -6
- package/dest/structs/published.d.ts +2 -0
- package/dest/structs/published.d.ts.map +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 +1 -0
- package/dest/test/mock_archiver.d.ts +5 -6
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +6 -11
- package/dest/test/mock_l1_to_l2_message_source.d.ts +6 -7
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +19 -14
- package/dest/test/mock_l2_block_source.d.ts +28 -14
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +160 -52
- package/dest/test/mock_structs.d.ts +78 -3
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +141 -10
- package/package.json +17 -18
- package/src/archiver.ts +525 -0
- package/src/{archiver/config.ts → config.ts} +28 -12
- package/src/errors.ts +90 -0
- package/src/factory.ts +118 -6
- 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 +182 -0
- package/src/l1/calldata_retriever.ts +641 -0
- package/src/{archiver → l1}/data_retrieval.ts +136 -218
- 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 +211 -0
- package/src/modules/data_source_base.ts +414 -0
- package/src/modules/data_store_updater.ts +419 -0
- package/src/{archiver → modules}/instrumentation.ts +24 -59
- package/src/modules/l1_synchronizer.ts +931 -0
- package/src/{archiver → modules}/validation.ts +11 -6
- package/src/store/block_store.ts +919 -0
- package/src/{archiver/kv_archiver_store → store}/contract_class_store.ts +2 -2
- package/src/{archiver/kv_archiver_store → store}/contract_instance_store.ts +2 -2
- package/src/store/kv_archiver_store.ts +622 -0
- package/src/store/log_store.ts +552 -0
- package/src/{archiver/kv_archiver_store → store}/message_store.ts +21 -18
- package/src/{archiver/structs → structs}/inbox_message.ts +7 -8
- package/src/{archiver/structs → structs}/published.ts +0 -1
- 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 +1 -0
- package/src/test/mock_archiver.ts +8 -13
- package/src/test/mock_l1_to_l2_message_source.ts +16 -15
- package/src/test/mock_l2_block_source.ts +184 -64
- package/src/test/mock_structs.ts +256 -11
- package/dest/archiver/archiver.d.ts +0 -290
- package/dest/archiver/archiver.d.ts.map +0 -1
- package/dest/archiver/archiver.js +0 -1434
- package/dest/archiver/archiver_store.d.ts +0 -256
- 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 -1289
- package/dest/archiver/config.d.ts +0 -21
- package/dest/archiver/config.d.ts.map +0 -1
- package/dest/archiver/data_retrieval.d.ts +0 -80
- package/dest/archiver/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/errors.d.ts +0 -12
- package/dest/archiver/errors.d.ts.map +0 -1
- package/dest/archiver/errors.js +0 -17
- 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 -35
- package/dest/archiver/instrumentation.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/block_store.d.ts +0 -125
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/block_store.js +0 -371
- 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 -169
- 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 -296
- 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 -337
- package/dest/archiver/kv_archiver_store/message_store.d.ts +0 -39
- package/dest/archiver/kv_archiver_store/message_store.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 +0 -3
- package/dest/archiver/structs/published.d.ts.map +0 -1
- package/dest/archiver/validation.d.ts +0 -17
- 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 -1880
- package/src/archiver/archiver_store.ts +0 -310
- package/src/archiver/archiver_store_test_suite.ts +0 -1295
- package/src/archiver/errors.ts +0 -26
- package/src/archiver/index.ts +0 -6
- package/src/archiver/kv_archiver_store/block_store.ts +0 -482
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +0 -423
- package/src/archiver/kv_archiver_store/log_store.ts +0 -407
- package/src/rpc/index.ts +0 -16
- /package/dest/{archiver/structs → structs}/data_retrieval.js +0 -0
- /package/dest/{archiver/structs → structs}/published.js +0 -0
- /package/src/{archiver/structs → structs}/data_retrieval.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { toArray } from '@aztec/foundation/iterable';
|
|
3
3
|
import { BufferReader, numToUInt8, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
4
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
@@ -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>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import {
|
|
@@ -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>;
|
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
import type { L1BlockId } from '@aztec/ethereum/l1-types';
|
|
2
|
+
import type { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import { toArray } from '@aztec/foundation/iterable';
|
|
5
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
+
import type { AztecAsyncKVStore, CustomRange, StoreSize } from '@aztec/kv-store';
|
|
7
|
+
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
8
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
|
+
import { CheckpointedL2Block, L2BlockHash, L2BlockNew, type ValidateCheckpointResult } from '@aztec/stdlib/block';
|
|
10
|
+
import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
11
|
+
import type {
|
|
12
|
+
ContractClassPublic,
|
|
13
|
+
ContractDataSource,
|
|
14
|
+
ContractInstanceUpdateWithAddress,
|
|
15
|
+
ContractInstanceWithAddress,
|
|
16
|
+
ExecutablePrivateFunctionWithMembershipProof,
|
|
17
|
+
UtilityFunctionWithMembershipProof,
|
|
18
|
+
} from '@aztec/stdlib/contract';
|
|
19
|
+
import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
|
|
20
|
+
import type { LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
21
|
+
import type { BlockHeader, TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
22
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
23
|
+
|
|
24
|
+
import { join } from 'path';
|
|
25
|
+
|
|
26
|
+
import type { InboxMessage } from '../structs/inbox_message.js';
|
|
27
|
+
import { BlockStore, type CheckpointData } from './block_store.js';
|
|
28
|
+
import { ContractClassStore } from './contract_class_store.js';
|
|
29
|
+
import { ContractInstanceStore } from './contract_instance_store.js';
|
|
30
|
+
import { LogStore } from './log_store.js';
|
|
31
|
+
import { MessageStore } from './message_store.js';
|
|
32
|
+
|
|
33
|
+
export const ARCHIVER_DB_VERSION = 5;
|
|
34
|
+
export const MAX_FUNCTION_SIGNATURES = 1000;
|
|
35
|
+
export const MAX_FUNCTION_NAME_LEN = 256;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Represents the latest L1 block processed by the archiver for various objects in L2.
|
|
39
|
+
*/
|
|
40
|
+
export type ArchiverL1SynchPoint = {
|
|
41
|
+
/** Number of the last L1 block that added a new L2 checkpoint metadata. */
|
|
42
|
+
blocksSynchedTo?: bigint;
|
|
43
|
+
/** Last L1 block checked for L1 to L2 messages. */
|
|
44
|
+
messagesSynchedTo?: L1BlockId;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* LMDB-based data store for the archiver.
|
|
49
|
+
* Stores all archiver data including blocks, logs, contract classes/instances, and L1 to L2 messages.
|
|
50
|
+
*/
|
|
51
|
+
export class KVArchiverDataStore implements ContractDataSource {
|
|
52
|
+
public static readonly SCHEMA_VERSION = ARCHIVER_DB_VERSION;
|
|
53
|
+
|
|
54
|
+
#blockStore: BlockStore;
|
|
55
|
+
#logStore: LogStore;
|
|
56
|
+
#messageStore: MessageStore;
|
|
57
|
+
#contractClassStore: ContractClassStore;
|
|
58
|
+
#contractInstanceStore: ContractInstanceStore;
|
|
59
|
+
|
|
60
|
+
private functionNames = new Map<string, string>();
|
|
61
|
+
|
|
62
|
+
#log = createLogger('archiver:data-store');
|
|
63
|
+
|
|
64
|
+
constructor(
|
|
65
|
+
private db: AztecAsyncKVStore,
|
|
66
|
+
logsMaxPageSize: number = 1000,
|
|
67
|
+
) {
|
|
68
|
+
this.#blockStore = new BlockStore(db);
|
|
69
|
+
this.#logStore = new LogStore(db, this.#blockStore, logsMaxPageSize);
|
|
70
|
+
this.#messageStore = new MessageStore(db);
|
|
71
|
+
this.#contractClassStore = new ContractClassStore(db);
|
|
72
|
+
this.#contractInstanceStore = new ContractInstanceStore(db);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Opens a new transaction to the underlying store and runs all operations within it. */
|
|
76
|
+
public transactionAsync<T>(callback: () => Promise<T>): Promise<T> {
|
|
77
|
+
return this.db.transactionAsync(callback);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public getBlockNumber(): Promise<BlockNumber> {
|
|
81
|
+
return this.#blockStore.getLatestL2BlockNumber();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public async getContract(
|
|
85
|
+
address: AztecAddress,
|
|
86
|
+
maybeTimestamp?: UInt64,
|
|
87
|
+
): Promise<ContractInstanceWithAddress | undefined> {
|
|
88
|
+
const [header] = await this.getBlockHeaders(await this.getBlockNumber(), 1);
|
|
89
|
+
const timestamp = maybeTimestamp ?? header!.globalVariables.timestamp;
|
|
90
|
+
return this.getContractInstance(address, timestamp);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Backups the archiver db to the target folder. Returns the path to the db file. */
|
|
94
|
+
public async backupTo(path: string, compress = true): Promise<string> {
|
|
95
|
+
await this.db.backupTo(path, compress);
|
|
96
|
+
return join(path, 'data.mdb');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Closes the underlying data store. */
|
|
100
|
+
public close() {
|
|
101
|
+
return this.db.close();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Looks up a public function name given a selector. */
|
|
105
|
+
getDebugFunctionName(_address: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
|
|
106
|
+
return Promise.resolve(this.functionNames.get(selector.toString()));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Register a public function signature, so it can be looked up by selector. */
|
|
110
|
+
async registerContractFunctionSignatures(signatures: string[]): Promise<void> {
|
|
111
|
+
for (const sig of signatures) {
|
|
112
|
+
if (this.functionNames.size > MAX_FUNCTION_SIGNATURES) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
const selector = await FunctionSelector.fromSignature(sig);
|
|
117
|
+
this.functionNames.set(selector.toString(), sig.slice(0, sig.indexOf('(')).slice(0, MAX_FUNCTION_NAME_LEN));
|
|
118
|
+
} catch {
|
|
119
|
+
this.#log.warn(`Failed to parse signature: ${sig}. Ignoring`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Returns a contract class given its id, or undefined if not exists.
|
|
126
|
+
* @param id - Id of the contract class.
|
|
127
|
+
*/
|
|
128
|
+
getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
|
|
129
|
+
return this.#contractClassStore.getContractClass(id);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Returns the list of all class ids known by the archiver. */
|
|
133
|
+
getContractClassIds(): Promise<Fr[]> {
|
|
134
|
+
return this.#contractClassStore.getContractClassIds();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Returns a contract instance given its address and the given timestamp, or undefined if not exists.
|
|
139
|
+
* @param address - Address of the contract.
|
|
140
|
+
* @param timestamp - Timestamp to get the contract instance at. Contract updates might change the instance.
|
|
141
|
+
* @returns The contract instance or undefined if not found.
|
|
142
|
+
*/
|
|
143
|
+
getContractInstance(address: AztecAddress, timestamp: UInt64): Promise<ContractInstanceWithAddress | undefined> {
|
|
144
|
+
return this.#contractInstanceStore.getContractInstance(address, timestamp);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
getContractInstanceDeploymentBlockNumber(address: AztecAddress): Promise<number | undefined> {
|
|
148
|
+
return this.#contractInstanceStore.getContractInstanceDeploymentBlockNumber(address);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Add new contract classes from an L2 block to the store's list.
|
|
153
|
+
* @param data - List of contract classes to be added.
|
|
154
|
+
* @param bytecodeCommitments - Bytecode commitments for the contract classes.
|
|
155
|
+
* @param blockNumber - Number of the L2 block the contracts were registered in.
|
|
156
|
+
* @returns True if the operation is successful.
|
|
157
|
+
*/
|
|
158
|
+
async addContractClasses(
|
|
159
|
+
data: ContractClassPublic[],
|
|
160
|
+
bytecodeCommitments: Fr[],
|
|
161
|
+
blockNumber: BlockNumber,
|
|
162
|
+
): Promise<boolean> {
|
|
163
|
+
return (
|
|
164
|
+
await Promise.all(
|
|
165
|
+
data.map((c, i) => this.#contractClassStore.addContractClass(c, bytecodeCommitments[i], blockNumber)),
|
|
166
|
+
)
|
|
167
|
+
).every(Boolean);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async deleteContractClasses(data: ContractClassPublic[], blockNumber: BlockNumber): Promise<boolean> {
|
|
171
|
+
return (await Promise.all(data.map(c => this.#contractClassStore.deleteContractClasses(c, blockNumber)))).every(
|
|
172
|
+
Boolean,
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
getBytecodeCommitment(contractClassId: Fr): Promise<Fr | undefined> {
|
|
177
|
+
return this.#contractClassStore.getBytecodeCommitment(contractClassId);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Adds private functions to a contract class. */
|
|
181
|
+
addFunctions(
|
|
182
|
+
contractClassId: Fr,
|
|
183
|
+
privateFunctions: ExecutablePrivateFunctionWithMembershipProof[],
|
|
184
|
+
utilityFunctions: UtilityFunctionWithMembershipProof[],
|
|
185
|
+
): Promise<boolean> {
|
|
186
|
+
return this.#contractClassStore.addFunctions(contractClassId, privateFunctions, utilityFunctions);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Add new contract instances from an L2 block to the store's list.
|
|
191
|
+
* @param data - List of contract instances to be added.
|
|
192
|
+
* @param blockNumber - Number of the L2 block the instances were deployed in.
|
|
193
|
+
* @returns True if the operation is successful.
|
|
194
|
+
*/
|
|
195
|
+
async addContractInstances(data: ContractInstanceWithAddress[], blockNumber: BlockNumber): Promise<boolean> {
|
|
196
|
+
return (await Promise.all(data.map(c => this.#contractInstanceStore.addContractInstance(c, blockNumber)))).every(
|
|
197
|
+
Boolean,
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async deleteContractInstances(data: ContractInstanceWithAddress[], _blockNumber: BlockNumber): Promise<boolean> {
|
|
202
|
+
return (await Promise.all(data.map(c => this.#contractInstanceStore.deleteContractInstance(c)))).every(Boolean);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Add new contract instance updates
|
|
207
|
+
* @param data - List of contract updates to be added.
|
|
208
|
+
* @param timestamp - Timestamp at which the updates were scheduled.
|
|
209
|
+
* @returns True if the operation is successful.
|
|
210
|
+
*/
|
|
211
|
+
async addContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[], timestamp: UInt64): Promise<boolean> {
|
|
212
|
+
return (
|
|
213
|
+
await Promise.all(
|
|
214
|
+
data.map((update, logIndex) =>
|
|
215
|
+
this.#contractInstanceStore.addContractInstanceUpdate(update, timestamp, logIndex),
|
|
216
|
+
),
|
|
217
|
+
)
|
|
218
|
+
).every(Boolean);
|
|
219
|
+
}
|
|
220
|
+
async deleteContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[], timestamp: UInt64): Promise<boolean> {
|
|
221
|
+
return (
|
|
222
|
+
await Promise.all(
|
|
223
|
+
data.map((update, logIndex) =>
|
|
224
|
+
this.#contractInstanceStore.deleteContractInstanceUpdate(update, timestamp, logIndex),
|
|
225
|
+
),
|
|
226
|
+
)
|
|
227
|
+
).every(Boolean);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Append new blocks to the store's list.
|
|
232
|
+
* @param blocks - The L2 blocks to be added to the store and the last processed L1 block.
|
|
233
|
+
* @returns True if the operation is successful.
|
|
234
|
+
*/
|
|
235
|
+
addBlocks(blocks: L2BlockNew[], opts: { force?: boolean; checkpointNumber?: number } = {}): Promise<boolean> {
|
|
236
|
+
return this.#blockStore.addBlocks(blocks, opts);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Returns an array of checkpoint objects
|
|
241
|
+
* @param from The first checkpoint number to be retrieved
|
|
242
|
+
* @param limit The maximum number of checkpoints to retrieve
|
|
243
|
+
* @returns The array of requested checkpoint data objects
|
|
244
|
+
*/
|
|
245
|
+
getRangeOfCheckpoints(from: CheckpointNumber, limit: number): Promise<CheckpointData[]> {
|
|
246
|
+
return this.#blockStore.getRangeOfCheckpoints(from, limit);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Returns the number of the latest block
|
|
250
|
+
* @returns The number of the latest block
|
|
251
|
+
*/
|
|
252
|
+
getLatestBlockNumber(): Promise<BlockNumber> {
|
|
253
|
+
return this.#blockStore.getLatestBlockNumber();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Unwinds checkpoints from the database
|
|
258
|
+
* @param from - The tip of the chain, passed for verification purposes,
|
|
259
|
+
* ensuring that we don't end up deleting something we did not intend
|
|
260
|
+
* @param checkpointsToUnwind - The number of checkpoints we are to unwind
|
|
261
|
+
* @returns True if the operation is successful
|
|
262
|
+
*/
|
|
263
|
+
unwindCheckpoints(from: CheckpointNumber, checkpointsToUnwind: number): Promise<boolean> {
|
|
264
|
+
return this.#blockStore.unwindCheckpoints(from, checkpointsToUnwind);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Appends new checkpoints, and their blocks to the store's collection
|
|
269
|
+
* @param checkpoints The collection of checkpoints to be added
|
|
270
|
+
* @returns True if the operation is successful
|
|
271
|
+
*/
|
|
272
|
+
addCheckpoints(checkpoints: PublishedCheckpoint[]): Promise<boolean> {
|
|
273
|
+
return this.#blockStore.addCheckpoints(checkpoints);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Returns the block for the given number, or undefined if not exists.
|
|
278
|
+
* @param number - The block number to return.
|
|
279
|
+
*/
|
|
280
|
+
getCheckpointedBlock(number: BlockNumber): Promise<CheckpointedL2Block | undefined> {
|
|
281
|
+
return this.#blockStore.getCheckpointedBlock(number);
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Returns the block for the given hash, or undefined if not exists.
|
|
285
|
+
* @param blockHash - The block hash to return.
|
|
286
|
+
*/
|
|
287
|
+
getCheckpointedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined> {
|
|
288
|
+
return this.#blockStore.getCheckpointedBlockByHash(blockHash);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Returns the block for the given archive root, or undefined if not exists.
|
|
292
|
+
* @param archive - The archive root to return.
|
|
293
|
+
*/
|
|
294
|
+
getCheckpointedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined> {
|
|
295
|
+
return this.#blockStore.getCheckpointedBlockByArchive(archive);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Returns the block for the given number, or undefined if not exists.
|
|
299
|
+
* @param number - The block number to return.
|
|
300
|
+
*/
|
|
301
|
+
getBlock(number: BlockNumber): Promise<L2BlockNew | undefined> {
|
|
302
|
+
return this.#blockStore.getBlock(number);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Returns the block for the given hash, or undefined if not exists.
|
|
306
|
+
* @param blockHash - The block hash to return.
|
|
307
|
+
*/
|
|
308
|
+
getBlockByHash(blockHash: Fr): Promise<L2BlockNew | undefined> {
|
|
309
|
+
return this.#blockStore.getBlockByHash(L2BlockHash.fromField(blockHash));
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Returns the block for the given archive root, or undefined if not exists.
|
|
313
|
+
* @param archive - The archive root to return.
|
|
314
|
+
*/
|
|
315
|
+
getBlockByArchive(archive: Fr): Promise<L2BlockNew | undefined> {
|
|
316
|
+
return this.#blockStore.getBlockByArchive(archive);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Gets up to `limit` amount of published L2 blocks starting from `from`.
|
|
321
|
+
* @param from - Number of the first block to return (inclusive).
|
|
322
|
+
* @param limit - The number of blocks to return.
|
|
323
|
+
* @returns The requested L2 blocks.
|
|
324
|
+
*/
|
|
325
|
+
getBlocks(from: BlockNumber, limit: number): Promise<L2BlockNew[]> {
|
|
326
|
+
return toArray(this.#blockStore.getBlocks(from, limit));
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Gets up to `limit` amount of checkpointed L2 blocks starting from `from`.
|
|
331
|
+
* @param from - Number of the first block to return (inclusive).
|
|
332
|
+
* @param limit - The number of blocks to return.
|
|
333
|
+
* @returns The requested checkpointed L2 blocks.
|
|
334
|
+
*/
|
|
335
|
+
getCheckpointedBlocks(from: BlockNumber, limit: number): Promise<CheckpointedL2Block[]> {
|
|
336
|
+
return toArray(this.#blockStore.getCheckpointedBlocks(from, limit));
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Gets up to `limit` amount of L2 block headers starting from `from`.
|
|
341
|
+
* @param start - Number of the first block to return (inclusive).
|
|
342
|
+
* @param limit - The number of blocks to return.
|
|
343
|
+
* @returns The requested L2 block headers.
|
|
344
|
+
*/
|
|
345
|
+
getBlockHeaders(start: BlockNumber, limit: number): Promise<BlockHeader[]> {
|
|
346
|
+
return toArray(this.#blockStore.getBlockHeaders(start, limit));
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Returns the block header for the given hash, or undefined if not exists.
|
|
351
|
+
* @param blockHash - The block hash to return.
|
|
352
|
+
*/
|
|
353
|
+
getBlockHeaderByHash(blockHash: Fr): Promise<BlockHeader | undefined> {
|
|
354
|
+
return this.#blockStore.getBlockHeaderByHash(L2BlockHash.fromField(blockHash));
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Returns the block header for the given archive root, or undefined if not exists.
|
|
359
|
+
* @param archive - The archive root to return.
|
|
360
|
+
*/
|
|
361
|
+
getBlockHeaderByArchive(archive: Fr): Promise<BlockHeader | undefined> {
|
|
362
|
+
return this.#blockStore.getBlockHeaderByArchive(archive);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Gets a tx effect.
|
|
367
|
+
* @param txHash - The hash of the tx corresponding to the tx effect.
|
|
368
|
+
* @returns The requested tx effect with block info (or undefined if not found).
|
|
369
|
+
*/
|
|
370
|
+
getTxEffect(txHash: TxHash) {
|
|
371
|
+
return this.#blockStore.getTxEffect(txHash);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Gets a receipt of a settled tx.
|
|
376
|
+
* @param txHash - The hash of a tx we try to get the receipt for.
|
|
377
|
+
* @returns The requested tx receipt (or undefined if not found).
|
|
378
|
+
*/
|
|
379
|
+
getSettledTxReceipt(txHash: TxHash): Promise<TxReceipt | undefined> {
|
|
380
|
+
return this.#blockStore.getSettledTxReceipt(txHash);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Append new logs to the store's list.
|
|
385
|
+
* @param blocks - The blocks for which to add the logs.
|
|
386
|
+
* @returns True if the operation is successful.
|
|
387
|
+
*/
|
|
388
|
+
addLogs(blocks: L2BlockNew[]): Promise<boolean> {
|
|
389
|
+
return this.#logStore.addLogs(blocks);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
deleteLogs(blocks: L2BlockNew[]): Promise<boolean> {
|
|
393
|
+
return this.#logStore.deleteLogs(blocks);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Get the total number of L1 to L2 messages
|
|
398
|
+
* @returns The number of L1 to L2 messages in the store
|
|
399
|
+
*/
|
|
400
|
+
getTotalL1ToL2MessageCount(): Promise<bigint> {
|
|
401
|
+
return this.#messageStore.getTotalL1ToL2MessageCount();
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/** Returns the last L1 to L2 message stored. */
|
|
405
|
+
getLastL1ToL2Message(): Promise<InboxMessage | undefined> {
|
|
406
|
+
return this.#messageStore.getLastMessage();
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Append L1 to L2 messages to the store.
|
|
411
|
+
* @param messages - The L1 to L2 messages to be added to the store.
|
|
412
|
+
* @returns True if the operation is successful.
|
|
413
|
+
*/
|
|
414
|
+
addL1ToL2Messages(messages: InboxMessage[]): Promise<void> {
|
|
415
|
+
return this.#messageStore.addL1ToL2Messages(messages);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Gets the L1 to L2 message index in the L1 to L2 message tree.
|
|
420
|
+
* @param l1ToL2Message - The L1 to L2 message.
|
|
421
|
+
* @returns The index of the L1 to L2 message in the L1 to L2 message tree (undefined if not found).
|
|
422
|
+
*/
|
|
423
|
+
getL1ToL2MessageIndex(l1ToL2Message: Fr): Promise<bigint | undefined> {
|
|
424
|
+
return this.#messageStore.getL1ToL2MessageIndex(l1ToL2Message);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Gets L1 to L2 message (to be) included in a given checkpoint.
|
|
429
|
+
* @param checkpointNumber - Checkpoint number to get messages for.
|
|
430
|
+
* @returns The L1 to L2 messages/leaves of the messages subtree (throws if not found).
|
|
431
|
+
*/
|
|
432
|
+
getL1ToL2Messages(checkpointNumber: CheckpointNumber): Promise<Fr[]> {
|
|
433
|
+
return this.#messageStore.getL1ToL2Messages(checkpointNumber);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Gets all private logs that match any of the `tags`. For each tag, an array of matching logs is returned. An empty
|
|
438
|
+
* array implies no logs match that tag.
|
|
439
|
+
*/
|
|
440
|
+
getPrivateLogsByTags(tags: SiloedTag[]): Promise<TxScopedL2Log[][]> {
|
|
441
|
+
try {
|
|
442
|
+
return this.#logStore.getPrivateLogsByTags(tags);
|
|
443
|
+
} catch (err) {
|
|
444
|
+
return Promise.reject(err);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Gets all public logs that match any of the `tags` from the specified contract. For each tag, an array of matching
|
|
450
|
+
* logs is returned. An empty array implies no logs match that tag.
|
|
451
|
+
*/
|
|
452
|
+
getPublicLogsByTagsFromContract(contractAddress: AztecAddress, tags: Tag[]): Promise<TxScopedL2Log[][]> {
|
|
453
|
+
try {
|
|
454
|
+
return this.#logStore.getPublicLogsByTagsFromContract(contractAddress, tags);
|
|
455
|
+
} catch (err) {
|
|
456
|
+
return Promise.reject(err);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Gets public logs based on the provided filter.
|
|
462
|
+
* @param filter - The filter to apply to the logs.
|
|
463
|
+
* @returns The requested logs.
|
|
464
|
+
*/
|
|
465
|
+
getPublicLogs(filter: LogFilter): Promise<GetPublicLogsResponse> {
|
|
466
|
+
try {
|
|
467
|
+
return this.#logStore.getPublicLogs(filter);
|
|
468
|
+
} catch (err) {
|
|
469
|
+
return Promise.reject(err);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Gets contract class logs based on the provided filter.
|
|
475
|
+
* @param filter - The filter to apply to the logs.
|
|
476
|
+
* @returns The requested logs.
|
|
477
|
+
*/
|
|
478
|
+
getContractClassLogs(filter: LogFilter): Promise<GetContractClassLogsResponse> {
|
|
479
|
+
try {
|
|
480
|
+
return this.#logStore.getContractClassLogs(filter);
|
|
481
|
+
} catch (err) {
|
|
482
|
+
return Promise.reject(err);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Gets the number of the latest proven checkpoint processed.
|
|
488
|
+
* @returns The number of the latest proven checkpoint processed.
|
|
489
|
+
*/
|
|
490
|
+
getProvenCheckpointNumber(): Promise<CheckpointNumber> {
|
|
491
|
+
return this.#blockStore.getProvenCheckpointNumber();
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Stores the number of the latest proven checkpoint processed.
|
|
496
|
+
* @param checkpointNumber - The number of the latest proven checkpoint processed.
|
|
497
|
+
*/
|
|
498
|
+
async setProvenCheckpointNumber(checkpointNumber: CheckpointNumber) {
|
|
499
|
+
await this.#blockStore.setProvenCheckpointNumber(checkpointNumber);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
async setBlockSynchedL1BlockNumber(l1BlockNumber: bigint) {
|
|
503
|
+
await this.#blockStore.setSynchedL1BlockNumber(l1BlockNumber);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Stores the l1 block that messages have been synched until
|
|
508
|
+
*/
|
|
509
|
+
async setMessageSynchedL1Block(l1Block: L1BlockId) {
|
|
510
|
+
await this.#messageStore.setSynchedL1Block(l1Block);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Returns the number of the most recent proven block
|
|
515
|
+
* @returns The number of the most recent proven block
|
|
516
|
+
*/
|
|
517
|
+
getProvenBlockNumber(): Promise<BlockNumber> {
|
|
518
|
+
return this.#blockStore.getProvenBlockNumber();
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Gets the synch point of the archiver
|
|
523
|
+
*/
|
|
524
|
+
async getSynchPoint(): Promise<ArchiverL1SynchPoint> {
|
|
525
|
+
const [blocksSynchedTo, messagesSynchedTo] = await Promise.all([
|
|
526
|
+
this.#blockStore.getSynchedL1BlockNumber(),
|
|
527
|
+
this.#messageStore.getSynchedL1Block(),
|
|
528
|
+
]);
|
|
529
|
+
return {
|
|
530
|
+
blocksSynchedTo,
|
|
531
|
+
messagesSynchedTo,
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/** Estimates the size of the store in bytes. */
|
|
536
|
+
public estimateSize(): Promise<StoreSize> {
|
|
537
|
+
return this.db.estimateSize();
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/** Deletes all L1 to L2 messages up until (excluding) the target checkpoint number. */
|
|
541
|
+
public rollbackL1ToL2MessagesToCheckpoint(targetCheckpointNumber: CheckpointNumber): Promise<void> {
|
|
542
|
+
return this.#messageStore.rollbackL1ToL2MessagesToCheckpoint(targetCheckpointNumber);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/** Returns an async iterator to all L1 to L2 messages on the range. */
|
|
546
|
+
public iterateL1ToL2Messages(range: CustomRange<bigint> = {}): AsyncIterableIterator<InboxMessage> {
|
|
547
|
+
return this.#messageStore.iterateL1ToL2Messages(range);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/** Removes all L1 to L2 messages starting from the given index (inclusive). */
|
|
551
|
+
public removeL1ToL2Messages(startIndex: bigint): Promise<void> {
|
|
552
|
+
return this.#messageStore.removeL1ToL2Messages(startIndex);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/** Returns the last synced validation status of the pending chain. */
|
|
556
|
+
public getPendingChainValidationStatus(): Promise<ValidateCheckpointResult | undefined> {
|
|
557
|
+
return this.#blockStore.getPendingChainValidationStatus();
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/** Sets the last synced validation status of the pending chain. */
|
|
561
|
+
public setPendingChainValidationStatus(status: ValidateCheckpointResult | undefined): Promise<void> {
|
|
562
|
+
return this.#blockStore.setPendingChainValidationStatus(status);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Gets the number of the latest L2 block processed.
|
|
567
|
+
* @returns The number of the latest L2 block processed.
|
|
568
|
+
*/
|
|
569
|
+
public getCheckpointedL2BlockNumber(): Promise<BlockNumber> {
|
|
570
|
+
return this.#blockStore.getCheckpointedL2BlockNumber();
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Gets the number of the latest published checkpoint processed.
|
|
574
|
+
* @returns The number of the latest published checkpoint processed
|
|
575
|
+
*/
|
|
576
|
+
public getSynchedCheckpointNumber(): Promise<CheckpointNumber> {
|
|
577
|
+
return this.#blockStore.getLatestCheckpointNumber();
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Stores the l1 block number that checkpoints have been synched until
|
|
581
|
+
* @param l1BlockNumber - The l1 block number
|
|
582
|
+
*/
|
|
583
|
+
async setCheckpointSynchedL1BlockNumber(l1BlockNumber: bigint): Promise<void> {
|
|
584
|
+
await this.#blockStore.setSynchedL1BlockNumber(l1BlockNumber);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Retrieves all blocks for the requested checkpoint
|
|
589
|
+
* @param checkpointNumber Retrieves all blocks for the given checkpoint
|
|
590
|
+
* @returns The collection of blocks for the requested checkpoint if available (undefined otherwise)
|
|
591
|
+
*/
|
|
592
|
+
getBlocksForCheckpoint(checkpointNumber: CheckpointNumber): Promise<L2BlockNew[] | undefined> {
|
|
593
|
+
return this.#blockStore.getBlocksForCheckpoint(checkpointNumber);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Returns checkpoint data for the requested checkpoint number
|
|
598
|
+
* @param checkpointNumber - The checkpoint requested
|
|
599
|
+
* @returns The checkpoint data or undefined if not found
|
|
600
|
+
*/
|
|
601
|
+
getCheckpointData(checkpointNumber: CheckpointNumber): Promise<CheckpointData | undefined> {
|
|
602
|
+
return this.#blockStore.getCheckpointData(checkpointNumber);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Gets all blocks that have the given slot number.
|
|
607
|
+
* @param slotNumber - The slot number to search for.
|
|
608
|
+
* @returns All blocks with the given slot number.
|
|
609
|
+
*/
|
|
610
|
+
getBlocksForSlot(slotNumber: SlotNumber): Promise<L2BlockNew[]> {
|
|
611
|
+
return this.#blockStore.getBlocksForSlot(slotNumber);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Removes all blocks with block number > blockNumber.
|
|
616
|
+
* @param blockNumber - The block number to remove after.
|
|
617
|
+
* @returns The removed blocks (for event emission).
|
|
618
|
+
*/
|
|
619
|
+
removeBlocksAfter(blockNumber: BlockNumber): Promise<L2BlockNew[]> {
|
|
620
|
+
return this.#blockStore.unwindBlocksAfter(blockNumber);
|
|
621
|
+
}
|
|
622
|
+
}
|