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