@aztec/archiver 0.0.0-test.1 → 0.0.1-commit.03f7ef2
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 +27 -6
- package/dest/archiver/archiver.d.ts +201 -94
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +1141 -396
- package/dest/archiver/archiver_store.d.ts +171 -83
- package/dest/archiver/archiver_store.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.js +2389 -393
- package/dest/archiver/config.d.ts +7 -22
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +30 -14
- package/dest/archiver/errors.d.ts +33 -1
- package/dest/archiver/errors.d.ts.map +1 -1
- package/dest/archiver/errors.js +49 -0
- package/dest/archiver/index.d.ts +3 -4
- package/dest/archiver/index.d.ts.map +1 -1
- package/dest/archiver/index.js +1 -2
- package/dest/archiver/instrumentation.d.ts +14 -6
- package/dest/archiver/instrumentation.d.ts.map +1 -1
- package/dest/archiver/instrumentation.js +69 -17
- package/dest/archiver/kv_archiver_store/block_store.d.ts +91 -21
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +476 -86
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +4 -4
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.js +13 -19
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +12 -9
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.js +30 -16
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +80 -75
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +142 -83
- package/dest/archiver/kv_archiver_store/log_store.d.ts +12 -16
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +153 -113
- package/dest/archiver/kv_archiver_store/message_store.d.ts +25 -18
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/message_store.js +152 -49
- package/dest/archiver/l1/bin/retrieve-calldata.d.ts +3 -0
- package/dest/archiver/l1/bin/retrieve-calldata.d.ts.map +1 -0
- package/dest/archiver/l1/bin/retrieve-calldata.js +149 -0
- package/dest/archiver/l1/calldata_retriever.d.ts +112 -0
- package/dest/archiver/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/archiver/l1/calldata_retriever.js +471 -0
- package/dest/archiver/l1/data_retrieval.d.ts +90 -0
- package/dest/archiver/l1/data_retrieval.d.ts.map +1 -0
- package/dest/archiver/l1/data_retrieval.js +331 -0
- package/dest/archiver/l1/debug_tx.d.ts +19 -0
- package/dest/archiver/l1/debug_tx.d.ts.map +1 -0
- package/dest/archiver/l1/debug_tx.js +73 -0
- package/dest/archiver/l1/spire_proposer.d.ts +70 -0
- package/dest/archiver/l1/spire_proposer.d.ts.map +1 -0
- package/dest/archiver/l1/spire_proposer.js +157 -0
- package/dest/archiver/l1/trace_tx.d.ts +97 -0
- package/dest/archiver/l1/trace_tx.d.ts.map +1 -0
- package/dest/archiver/l1/trace_tx.js +91 -0
- package/dest/archiver/l1/types.d.ts +12 -0
- package/dest/archiver/l1/types.d.ts.map +1 -0
- package/dest/archiver/l1/types.js +3 -0
- package/dest/archiver/l1/validate_trace.d.ts +29 -0
- package/dest/archiver/l1/validate_trace.d.ts.map +1 -0
- package/dest/archiver/l1/validate_trace.js +150 -0
- package/dest/archiver/structs/data_retrieval.d.ts +1 -1
- package/dest/archiver/structs/inbox_message.d.ts +15 -0
- package/dest/archiver/structs/inbox_message.d.ts.map +1 -0
- package/dest/archiver/structs/inbox_message.js +39 -0
- package/dest/archiver/structs/published.d.ts +2 -11
- package/dest/archiver/structs/published.d.ts.map +1 -1
- package/dest/archiver/structs/published.js +1 -1
- package/dest/archiver/validation.d.ts +17 -0
- package/dest/archiver/validation.d.ts.map +1 -0
- package/dest/archiver/validation.js +98 -0
- package/dest/factory.d.ts +9 -14
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +22 -52
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/rpc/index.d.ts +2 -3
- package/dest/rpc/index.d.ts.map +1 -1
- package/dest/rpc/index.js +1 -4
- package/dest/test/index.d.ts +1 -1
- package/dest/test/mock_archiver.d.ts +16 -8
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +19 -14
- package/dest/test/mock_l1_to_l2_message_source.d.ts +9 -6
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +21 -7
- package/dest/test/mock_l2_block_source.d.ts +52 -13
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +140 -15
- package/dest/test/mock_structs.d.ts +10 -0
- package/dest/test/mock_structs.d.ts.map +1 -0
- package/dest/test/mock_structs.js +38 -0
- package/package.json +29 -30
- package/src/archiver/archiver.ts +1477 -501
- package/src/archiver/archiver_store.ts +197 -88
- package/src/archiver/archiver_store_test_suite.ts +2403 -350
- package/src/archiver/config.ts +38 -46
- package/src/archiver/errors.ts +85 -0
- package/src/archiver/index.ts +2 -3
- package/src/archiver/instrumentation.ts +91 -22
- package/src/archiver/kv_archiver_store/block_store.ts +640 -101
- package/src/archiver/kv_archiver_store/contract_class_store.ts +14 -24
- package/src/archiver/kv_archiver_store/contract_instance_store.ts +36 -28
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +193 -113
- package/src/archiver/kv_archiver_store/log_store.ts +205 -127
- package/src/archiver/kv_archiver_store/message_store.ts +213 -54
- package/src/archiver/l1/README.md +98 -0
- package/src/archiver/l1/bin/retrieve-calldata.ts +182 -0
- package/src/archiver/l1/calldata_retriever.ts +641 -0
- package/src/archiver/l1/data_retrieval.ts +512 -0
- package/src/archiver/l1/debug_tx.ts +99 -0
- package/src/archiver/l1/spire_proposer.ts +160 -0
- package/src/archiver/l1/trace_tx.ts +128 -0
- package/src/archiver/l1/types.ts +13 -0
- package/src/archiver/l1/validate_trace.ts +211 -0
- package/src/archiver/structs/inbox_message.ts +41 -0
- package/src/archiver/structs/published.ts +1 -11
- package/src/archiver/validation.ts +124 -0
- package/src/factory.ts +28 -69
- package/src/index.ts +1 -1
- package/src/rpc/index.ts +1 -5
- 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/mock_archiver.ts +22 -16
- package/src/test/mock_l1_to_l2_message_source.ts +20 -8
- package/src/test/mock_l2_block_source.ts +186 -21
- package/src/test/mock_structs.ts +50 -0
- package/dest/archiver/data_retrieval.d.ts +0 -74
- package/dest/archiver/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/data_retrieval.js +0 -283
- package/dest/archiver/kv_archiver_store/nullifier_store.d.ts +0 -12
- package/dest/archiver/kv_archiver_store/nullifier_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/nullifier_store.js +0 -73
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +0 -23
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts.map +0 -1
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.js +0 -49
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +0 -175
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +0 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.js +0 -636
- package/src/archiver/data_retrieval.ts +0 -422
- package/src/archiver/kv_archiver_store/nullifier_store.ts +0 -97
- package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +0 -61
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +0 -801
|
@@ -1,69 +1,105 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { L1BlockId } from '@aztec/ethereum/l1-types';
|
|
2
|
+
import type { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
4
|
import { toArray } from '@aztec/foundation/iterable';
|
|
3
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import type { AztecAsyncKVStore, StoreSize } from '@aztec/kv-store';
|
|
6
|
+
import type { AztecAsyncKVStore, CustomRange, StoreSize } from '@aztec/kv-store';
|
|
5
7
|
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
6
8
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
-
import
|
|
9
|
+
import { CheckpointedL2Block, L2BlockHash, L2BlockNew, type ValidateBlockResult } from '@aztec/stdlib/block';
|
|
10
|
+
import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
8
11
|
import type {
|
|
9
12
|
ContractClassPublic,
|
|
13
|
+
ContractDataSource,
|
|
10
14
|
ContractInstanceUpdateWithAddress,
|
|
11
15
|
ContractInstanceWithAddress,
|
|
12
16
|
ExecutablePrivateFunctionWithMembershipProof,
|
|
13
|
-
|
|
17
|
+
UtilityFunctionWithMembershipProof,
|
|
14
18
|
} from '@aztec/stdlib/contract';
|
|
15
19
|
import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
|
|
16
|
-
import {
|
|
17
|
-
import type { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
20
|
+
import type { LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
18
21
|
import type { BlockHeader, TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
22
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
23
|
+
|
|
24
|
+
import { join } from 'path';
|
|
19
25
|
|
|
20
26
|
import type { ArchiverDataStore, ArchiverL1SynchPoint } from '../archiver_store.js';
|
|
21
|
-
import type {
|
|
22
|
-
import type
|
|
23
|
-
import { BlockStore } from './block_store.js';
|
|
27
|
+
import type { InboxMessage } from '../structs/inbox_message.js';
|
|
28
|
+
import { BlockStore, type CheckpointData } from './block_store.js';
|
|
24
29
|
import { ContractClassStore } from './contract_class_store.js';
|
|
25
30
|
import { ContractInstanceStore } from './contract_instance_store.js';
|
|
26
31
|
import { LogStore } from './log_store.js';
|
|
27
32
|
import { MessageStore } from './message_store.js';
|
|
28
|
-
|
|
33
|
+
|
|
34
|
+
export const ARCHIVER_DB_VERSION = 5;
|
|
35
|
+
export const MAX_FUNCTION_SIGNATURES = 1000;
|
|
36
|
+
export const MAX_FUNCTION_NAME_LEN = 256;
|
|
29
37
|
|
|
30
38
|
/**
|
|
31
39
|
* LMDB implementation of the ArchiverDataStore interface.
|
|
32
40
|
*/
|
|
33
|
-
export class KVArchiverDataStore implements ArchiverDataStore {
|
|
34
|
-
public static readonly SCHEMA_VERSION =
|
|
41
|
+
export class KVArchiverDataStore implements ArchiverDataStore, ContractDataSource {
|
|
42
|
+
public static readonly SCHEMA_VERSION = ARCHIVER_DB_VERSION;
|
|
35
43
|
|
|
36
44
|
#blockStore: BlockStore;
|
|
37
45
|
#logStore: LogStore;
|
|
38
|
-
#nullifierStore: NullifierStore;
|
|
39
46
|
#messageStore: MessageStore;
|
|
40
47
|
#contractClassStore: ContractClassStore;
|
|
41
48
|
#contractInstanceStore: ContractInstanceStore;
|
|
49
|
+
|
|
42
50
|
private functionNames = new Map<string, string>();
|
|
43
51
|
|
|
44
52
|
#log = createLogger('archiver:data-store');
|
|
45
53
|
|
|
46
|
-
constructor(
|
|
54
|
+
constructor(
|
|
55
|
+
private db: AztecAsyncKVStore,
|
|
56
|
+
logsMaxPageSize: number = 1000,
|
|
57
|
+
) {
|
|
47
58
|
this.#blockStore = new BlockStore(db);
|
|
48
59
|
this.#logStore = new LogStore(db, this.#blockStore, logsMaxPageSize);
|
|
49
60
|
this.#messageStore = new MessageStore(db);
|
|
50
61
|
this.#contractClassStore = new ContractClassStore(db);
|
|
51
62
|
this.#contractInstanceStore = new ContractInstanceStore(db);
|
|
52
|
-
this.#nullifierStore = new NullifierStore(db);
|
|
53
63
|
}
|
|
54
64
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
public transactionAsync<T>(callback: () => Promise<T>): Promise<T> {
|
|
66
|
+
return this.db.transactionAsync(callback);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public getBlockNumber(): Promise<BlockNumber> {
|
|
70
|
+
return this.#blockStore.getLatestL2BlockNumber();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public async getContract(
|
|
74
|
+
address: AztecAddress,
|
|
75
|
+
maybeTimestamp?: UInt64,
|
|
76
|
+
): Promise<ContractInstanceWithAddress | undefined> {
|
|
77
|
+
const [header] = await this.getBlockHeaders(await this.getBlockNumber(), 1);
|
|
78
|
+
const timestamp = maybeTimestamp ?? header!.globalVariables.timestamp;
|
|
79
|
+
return this.getContractInstance(address, timestamp);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public async backupTo(path: string, compress = true): Promise<string> {
|
|
83
|
+
await this.db.backupTo(path, compress);
|
|
84
|
+
return join(path, 'data.mdb');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public close() {
|
|
88
|
+
return this.db.close();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
getDebugFunctionName(_address: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
|
|
59
92
|
return Promise.resolve(this.functionNames.get(selector.toString()));
|
|
60
93
|
}
|
|
61
94
|
|
|
62
|
-
async registerContractFunctionSignatures(
|
|
95
|
+
async registerContractFunctionSignatures(signatures: string[]): Promise<void> {
|
|
63
96
|
for (const sig of signatures) {
|
|
97
|
+
if (this.functionNames.size > MAX_FUNCTION_SIGNATURES) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
64
100
|
try {
|
|
65
101
|
const selector = await FunctionSelector.fromSignature(sig);
|
|
66
|
-
this.functionNames.set(selector.toString(), sig.slice(0, sig.indexOf('(')));
|
|
102
|
+
this.functionNames.set(selector.toString(), sig.slice(0, sig.indexOf('(')).slice(0, MAX_FUNCTION_NAME_LEN));
|
|
67
103
|
} catch {
|
|
68
104
|
this.#log.warn(`Failed to parse signature: ${sig}. Ignoring`);
|
|
69
105
|
}
|
|
@@ -78,15 +114,18 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
78
114
|
return this.#contractClassStore.getContractClassIds();
|
|
79
115
|
}
|
|
80
116
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
117
|
+
getContractInstance(address: AztecAddress, timestamp: UInt64): Promise<ContractInstanceWithAddress | undefined> {
|
|
118
|
+
return this.#contractInstanceStore.getContractInstance(address, timestamp);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
getContractInstanceDeploymentBlockNumber(address: AztecAddress): Promise<number | undefined> {
|
|
122
|
+
return this.#contractInstanceStore.getContractInstanceDeploymentBlockNumber(address);
|
|
84
123
|
}
|
|
85
124
|
|
|
86
125
|
async addContractClasses(
|
|
87
126
|
data: ContractClassPublic[],
|
|
88
127
|
bytecodeCommitments: Fr[],
|
|
89
|
-
blockNumber:
|
|
128
|
+
blockNumber: BlockNumber,
|
|
90
129
|
): Promise<boolean> {
|
|
91
130
|
return (
|
|
92
131
|
await Promise.all(
|
|
@@ -95,7 +134,7 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
95
134
|
).every(Boolean);
|
|
96
135
|
}
|
|
97
136
|
|
|
98
|
-
async deleteContractClasses(data: ContractClassPublic[], blockNumber:
|
|
137
|
+
async deleteContractClasses(data: ContractClassPublic[], blockNumber: BlockNumber): Promise<boolean> {
|
|
99
138
|
return (await Promise.all(data.map(c => this.#contractClassStore.deleteContractClasses(c, blockNumber)))).every(
|
|
100
139
|
Boolean,
|
|
101
140
|
);
|
|
@@ -108,36 +147,35 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
108
147
|
addFunctions(
|
|
109
148
|
contractClassId: Fr,
|
|
110
149
|
privateFunctions: ExecutablePrivateFunctionWithMembershipProof[],
|
|
111
|
-
|
|
150
|
+
utilityFunctions: UtilityFunctionWithMembershipProof[],
|
|
112
151
|
): Promise<boolean> {
|
|
113
|
-
return this.#contractClassStore.addFunctions(contractClassId, privateFunctions,
|
|
152
|
+
return this.#contractClassStore.addFunctions(contractClassId, privateFunctions, utilityFunctions);
|
|
114
153
|
}
|
|
115
154
|
|
|
116
|
-
async addContractInstances(data: ContractInstanceWithAddress[],
|
|
117
|
-
return (await Promise.all(data.map(c => this.#contractInstanceStore.addContractInstance(c)))).every(
|
|
155
|
+
async addContractInstances(data: ContractInstanceWithAddress[], blockNumber: BlockNumber): Promise<boolean> {
|
|
156
|
+
return (await Promise.all(data.map(c => this.#contractInstanceStore.addContractInstance(c, blockNumber)))).every(
|
|
157
|
+
Boolean,
|
|
158
|
+
);
|
|
118
159
|
}
|
|
119
160
|
|
|
120
|
-
async deleteContractInstances(data: ContractInstanceWithAddress[], _blockNumber:
|
|
161
|
+
async deleteContractInstances(data: ContractInstanceWithAddress[], _blockNumber: BlockNumber): Promise<boolean> {
|
|
121
162
|
return (await Promise.all(data.map(c => this.#contractInstanceStore.deleteContractInstance(c)))).every(Boolean);
|
|
122
163
|
}
|
|
123
164
|
|
|
124
|
-
async addContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[],
|
|
165
|
+
async addContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[], timestamp: UInt64): Promise<boolean> {
|
|
125
166
|
return (
|
|
126
167
|
await Promise.all(
|
|
127
168
|
data.map((update, logIndex) =>
|
|
128
|
-
this.#contractInstanceStore.addContractInstanceUpdate(update,
|
|
169
|
+
this.#contractInstanceStore.addContractInstanceUpdate(update, timestamp, logIndex),
|
|
129
170
|
),
|
|
130
171
|
)
|
|
131
172
|
).every(Boolean);
|
|
132
173
|
}
|
|
133
|
-
async deleteContractInstanceUpdates(
|
|
134
|
-
data: ContractInstanceUpdateWithAddress[],
|
|
135
|
-
blockNumber: number,
|
|
136
|
-
): Promise<boolean> {
|
|
174
|
+
async deleteContractInstanceUpdates(data: ContractInstanceUpdateWithAddress[], timestamp: UInt64): Promise<boolean> {
|
|
137
175
|
return (
|
|
138
176
|
await Promise.all(
|
|
139
177
|
data.map((update, logIndex) =>
|
|
140
|
-
this.#contractInstanceStore.deleteContractInstanceUpdate(update,
|
|
178
|
+
this.#contractInstanceStore.deleteContractInstanceUpdate(update, timestamp, logIndex),
|
|
141
179
|
),
|
|
142
180
|
)
|
|
143
181
|
).every(Boolean);
|
|
@@ -148,30 +186,52 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
148
186
|
* @param blocks - The L2 blocks to be added to the store and the last processed L1 block.
|
|
149
187
|
* @returns True if the operation is successful.
|
|
150
188
|
*/
|
|
151
|
-
addBlocks(blocks:
|
|
152
|
-
return this.#blockStore.addBlocks(blocks);
|
|
189
|
+
addBlocks(blocks: L2BlockNew[], opts: { force?: boolean; checkpointNumber?: number } = {}): Promise<boolean> {
|
|
190
|
+
return this.#blockStore.addBlocks(blocks, opts);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
getRangeOfCheckpoints(from: CheckpointNumber, limit: number): Promise<CheckpointData[]> {
|
|
194
|
+
return this.#blockStore.getRangeOfCheckpoints(from, limit);
|
|
195
|
+
}
|
|
196
|
+
getLatestBlockNumber(): Promise<BlockNumber> {
|
|
197
|
+
return this.#blockStore.getLatestBlockNumber();
|
|
153
198
|
}
|
|
154
199
|
|
|
155
200
|
/**
|
|
156
|
-
* Unwinds
|
|
201
|
+
* Unwinds checkpoints from the database
|
|
157
202
|
* @param from - The tip of the chain, passed for verification purposes,
|
|
158
203
|
* ensuring that we don't end up deleting something we did not intend
|
|
159
|
-
* @param
|
|
204
|
+
* @param checkpointsToUnwind - The number of checkpoints we are to unwind
|
|
160
205
|
* @returns True if the operation is successful
|
|
161
206
|
*/
|
|
162
|
-
|
|
163
|
-
return this.#blockStore.
|
|
207
|
+
unwindCheckpoints(from: CheckpointNumber, checkpointsToUnwind: number): Promise<boolean> {
|
|
208
|
+
return this.#blockStore.unwindCheckpoints(from, checkpointsToUnwind);
|
|
164
209
|
}
|
|
165
210
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return
|
|
211
|
+
addCheckpoints(checkpoints: PublishedCheckpoint[]): Promise<boolean> {
|
|
212
|
+
return this.#blockStore.addCheckpoints(checkpoints);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
getCheckpointedBlock(number: BlockNumber): Promise<CheckpointedL2Block | undefined> {
|
|
216
|
+
return this.#blockStore.getCheckpointedBlock(number);
|
|
217
|
+
}
|
|
218
|
+
getCheckpointedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined> {
|
|
219
|
+
return this.#blockStore.getCheckpointedBlockByHash(blockHash);
|
|
220
|
+
}
|
|
221
|
+
getCheckpointedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined> {
|
|
222
|
+
return this.#blockStore.getCheckpointedBlockByArchive(archive);
|
|
223
|
+
}
|
|
224
|
+
getBlock(number: BlockNumber): Promise<L2BlockNew | undefined> {
|
|
225
|
+
return this.#blockStore.getBlock(number);
|
|
226
|
+
}
|
|
227
|
+
getBlockByHash(blockHash: Fr): Promise<L2BlockNew | undefined> {
|
|
228
|
+
return this.#blockStore.getBlockByHash(L2BlockHash.fromField(blockHash));
|
|
229
|
+
}
|
|
230
|
+
getBlockByArchive(archive: Fr): Promise<L2BlockNew | undefined> {
|
|
231
|
+
return this.#blockStore.getBlockByArchive(archive);
|
|
232
|
+
}
|
|
233
|
+
getBlocks(from: BlockNumber, limit: BlockNumber): Promise<L2BlockNew[]> {
|
|
234
|
+
return toArray(this.#blockStore.getBlocks(from, limit));
|
|
175
235
|
}
|
|
176
236
|
|
|
177
237
|
/**
|
|
@@ -181,14 +241,22 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
181
241
|
* @param limit - The number of blocks to return.
|
|
182
242
|
* @returns The requested L2 blocks
|
|
183
243
|
*/
|
|
184
|
-
getBlockHeaders(start:
|
|
244
|
+
getBlockHeaders(start: BlockNumber, limit: number): Promise<BlockHeader[]> {
|
|
185
245
|
return toArray(this.#blockStore.getBlockHeaders(start, limit));
|
|
186
246
|
}
|
|
187
247
|
|
|
248
|
+
getBlockHeaderByHash(blockHash: Fr): Promise<BlockHeader | undefined> {
|
|
249
|
+
return this.#blockStore.getBlockHeaderByHash(L2BlockHash.fromField(blockHash));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
getBlockHeaderByArchive(archive: Fr): Promise<BlockHeader | undefined> {
|
|
253
|
+
return this.#blockStore.getBlockHeaderByArchive(archive);
|
|
254
|
+
}
|
|
255
|
+
|
|
188
256
|
/**
|
|
189
257
|
* Gets a tx effect.
|
|
190
|
-
* @param txHash - The
|
|
191
|
-
* @returns The requested tx effect (or undefined if not found).
|
|
258
|
+
* @param txHash - The hash of the tx corresponding to the tx effect.
|
|
259
|
+
* @returns The requested tx effect with block info (or undefined if not found).
|
|
192
260
|
*/
|
|
193
261
|
getTxEffect(txHash: TxHash) {
|
|
194
262
|
return this.#blockStore.getTxEffect(txHash);
|
|
@@ -208,41 +276,27 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
208
276
|
* @param blocks - The blocks for which to add the logs.
|
|
209
277
|
* @returns True if the operation is successful.
|
|
210
278
|
*/
|
|
211
|
-
addLogs(blocks:
|
|
279
|
+
addLogs(blocks: L2BlockNew[]): Promise<boolean> {
|
|
212
280
|
return this.#logStore.addLogs(blocks);
|
|
213
281
|
}
|
|
214
282
|
|
|
215
|
-
deleteLogs(blocks:
|
|
283
|
+
deleteLogs(blocks: L2BlockNew[]): Promise<boolean> {
|
|
216
284
|
return this.#logStore.deleteLogs(blocks);
|
|
217
285
|
}
|
|
218
286
|
|
|
219
|
-
/**
|
|
220
|
-
* Append new nullifiers to the store's list.
|
|
221
|
-
* @param blocks - The blocks for which to add the nullifiers.
|
|
222
|
-
* @returns True if the operation is successful.
|
|
223
|
-
*/
|
|
224
|
-
addNullifiers(blocks: L2Block[]): Promise<boolean> {
|
|
225
|
-
return this.#nullifierStore.addNullifiers(blocks);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
deleteNullifiers(blocks: L2Block[]): Promise<boolean> {
|
|
229
|
-
return this.#nullifierStore.deleteNullifiers(blocks);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
findNullifiersIndexesWithBlock(blockNumber: number, nullifiers: Fr[]): Promise<(InBlock<bigint> | undefined)[]> {
|
|
233
|
-
return this.#nullifierStore.findNullifiersIndexesWithBlock(blockNumber, nullifiers);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
287
|
getTotalL1ToL2MessageCount(): Promise<bigint> {
|
|
237
288
|
return this.#messageStore.getTotalL1ToL2MessageCount();
|
|
238
289
|
}
|
|
239
290
|
|
|
291
|
+
getLastL1ToL2Message(): Promise<InboxMessage | undefined> {
|
|
292
|
+
return this.#messageStore.getLastMessage();
|
|
293
|
+
}
|
|
294
|
+
|
|
240
295
|
/**
|
|
241
296
|
* Append L1 to L2 messages to the store.
|
|
242
|
-
* @param messages - The L1 to L2 messages to be added to the store
|
|
243
|
-
* @returns True if the operation is successful.
|
|
297
|
+
* @param messages - The L1 to L2 messages to be added to the store.
|
|
244
298
|
*/
|
|
245
|
-
addL1ToL2Messages(messages:
|
|
299
|
+
addL1ToL2Messages(messages: InboxMessage[]): Promise<void> {
|
|
246
300
|
return this.#messageStore.addL1ToL2Messages(messages);
|
|
247
301
|
}
|
|
248
302
|
|
|
@@ -256,33 +310,25 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
256
310
|
}
|
|
257
311
|
|
|
258
312
|
/**
|
|
259
|
-
* Gets L1 to L2 message (to be) included in a given
|
|
260
|
-
* @param
|
|
313
|
+
* Gets L1 to L2 message (to be) included in a given checkpoint.
|
|
314
|
+
* @param checkpointNumber - Checkpoint number to get messages for.
|
|
261
315
|
* @returns The L1 to L2 messages/leaves of the messages subtree (throws if not found).
|
|
262
316
|
*/
|
|
263
|
-
getL1ToL2Messages(
|
|
264
|
-
return this.#messageStore.getL1ToL2Messages(
|
|
317
|
+
getL1ToL2Messages(checkpointNumber: CheckpointNumber): Promise<Fr[]> {
|
|
318
|
+
return this.#messageStore.getL1ToL2Messages(checkpointNumber);
|
|
265
319
|
}
|
|
266
320
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
getPrivateLogs(from: number, limit: number): Promise<PrivateLog[]> {
|
|
274
|
-
return this.#logStore.getPrivateLogs(from, limit);
|
|
321
|
+
getPrivateLogsByTags(tags: SiloedTag[]): Promise<TxScopedL2Log[][]> {
|
|
322
|
+
try {
|
|
323
|
+
return this.#logStore.getPrivateLogsByTags(tags);
|
|
324
|
+
} catch (err) {
|
|
325
|
+
return Promise.reject(err);
|
|
326
|
+
}
|
|
275
327
|
}
|
|
276
328
|
|
|
277
|
-
|
|
278
|
-
* Gets all logs that match any of the received tags (i.e. logs with their first field equal to a tag).
|
|
279
|
-
* @param tags - The tags to filter the logs by.
|
|
280
|
-
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
|
|
281
|
-
* that tag.
|
|
282
|
-
*/
|
|
283
|
-
getLogsByTags(tags: Fr[]): Promise<TxScopedL2Log[][]> {
|
|
329
|
+
getPublicLogsByTagsFromContract(contractAddress: AztecAddress, tags: Tag[]): Promise<TxScopedL2Log[][]> {
|
|
284
330
|
try {
|
|
285
|
-
return this.#logStore.
|
|
331
|
+
return this.#logStore.getPublicLogsByTagsFromContract(contractAddress, tags);
|
|
286
332
|
} catch (err) {
|
|
287
333
|
return Promise.reject(err);
|
|
288
334
|
}
|
|
@@ -314,28 +360,24 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
314
360
|
}
|
|
315
361
|
}
|
|
316
362
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
* @returns The number of the latest L2 block processed.
|
|
320
|
-
*/
|
|
321
|
-
getSynchedL2BlockNumber(): Promise<number> {
|
|
322
|
-
return this.#blockStore.getSynchedL2BlockNumber();
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
getProvenL2BlockNumber(): Promise<number> {
|
|
326
|
-
return this.#blockStore.getProvenL2BlockNumber();
|
|
363
|
+
getProvenCheckpointNumber(): Promise<CheckpointNumber> {
|
|
364
|
+
return this.#blockStore.getProvenCheckpointNumber();
|
|
327
365
|
}
|
|
328
366
|
|
|
329
|
-
async
|
|
330
|
-
await this.#blockStore.
|
|
367
|
+
async setProvenCheckpointNumber(checkpointNumber: CheckpointNumber) {
|
|
368
|
+
await this.#blockStore.setProvenCheckpointNumber(checkpointNumber);
|
|
331
369
|
}
|
|
332
370
|
|
|
333
371
|
async setBlockSynchedL1BlockNumber(l1BlockNumber: bigint) {
|
|
334
372
|
await this.#blockStore.setSynchedL1BlockNumber(l1BlockNumber);
|
|
335
373
|
}
|
|
336
374
|
|
|
337
|
-
async
|
|
338
|
-
await this.#messageStore.
|
|
375
|
+
async setMessageSynchedL1Block(l1Block: L1BlockId) {
|
|
376
|
+
await this.#messageStore.setSynchedL1Block(l1Block);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
getProvenBlockNumber(): Promise<BlockNumber> {
|
|
380
|
+
return this.#blockStore.getProvenBlockNumber();
|
|
339
381
|
}
|
|
340
382
|
|
|
341
383
|
/**
|
|
@@ -344,7 +386,7 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
344
386
|
async getSynchPoint(): Promise<ArchiverL1SynchPoint> {
|
|
345
387
|
const [blocksSynchedTo, messagesSynchedTo] = await Promise.all([
|
|
346
388
|
this.#blockStore.getSynchedL1BlockNumber(),
|
|
347
|
-
this.#messageStore.
|
|
389
|
+
this.#messageStore.getSynchedL1Block(),
|
|
348
390
|
]);
|
|
349
391
|
return {
|
|
350
392
|
blocksSynchedTo,
|
|
@@ -355,4 +397,42 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
355
397
|
public estimateSize(): Promise<StoreSize> {
|
|
356
398
|
return this.db.estimateSize();
|
|
357
399
|
}
|
|
400
|
+
|
|
401
|
+
public rollbackL1ToL2MessagesToCheckpoint(targetCheckpointNumber: CheckpointNumber): Promise<void> {
|
|
402
|
+
return this.#messageStore.rollbackL1ToL2MessagesToCheckpoint(targetCheckpointNumber);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
public iterateL1ToL2Messages(range: CustomRange<bigint> = {}): AsyncIterableIterator<InboxMessage> {
|
|
406
|
+
return this.#messageStore.iterateL1ToL2Messages(range);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
public removeL1ToL2Messages(startIndex: bigint): Promise<void> {
|
|
410
|
+
return this.#messageStore.removeL1ToL2Messages(startIndex);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
public getPendingChainValidationStatus(): Promise<ValidateBlockResult | undefined> {
|
|
414
|
+
return this.#blockStore.getPendingChainValidationStatus();
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
public setPendingChainValidationStatus(status: ValidateBlockResult | undefined): Promise<void> {
|
|
418
|
+
return this.#blockStore.setPendingChainValidationStatus(status);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
public getCheckpointedL2BlockNumber(): Promise<BlockNumber> {
|
|
422
|
+
return this.#blockStore.getCheckpointedL2BlockNumber();
|
|
423
|
+
}
|
|
424
|
+
public getSynchedCheckpointNumber(): Promise<CheckpointNumber> {
|
|
425
|
+
return this.#blockStore.getLatestCheckpointNumber();
|
|
426
|
+
}
|
|
427
|
+
async setCheckpointSynchedL1BlockNumber(l1BlockNumber: bigint): Promise<void> {
|
|
428
|
+
await this.#blockStore.setSynchedL1BlockNumber(l1BlockNumber);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
getBlocksForCheckpoint(checkpointNumber: CheckpointNumber): Promise<L2BlockNew[] | undefined> {
|
|
432
|
+
return this.#blockStore.getBlocksForCheckpoint(checkpointNumber);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
getCheckpointData(checkpointNumber: CheckpointNumber): Promise<CheckpointData | undefined> {
|
|
436
|
+
return this.#blockStore.getCheckpointData(checkpointNumber);
|
|
437
|
+
}
|
|
358
438
|
}
|