@aztec/archiver 0.0.1-commit.0dc957cde → 0.0.1-commit.0ec55a70b
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/dest/archiver.d.ts +15 -9
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +85 -53
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +2 -2
- package/dest/errors.d.ts +16 -5
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +29 -6
- package/dest/factory.d.ts +4 -4
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +11 -9
- package/dest/index.d.ts +8 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +7 -1
- package/dest/l1/calldata_retriever.d.ts +2 -1
- package/dest/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/l1/calldata_retriever.js +9 -4
- package/dest/modules/contract_data_source_adapter.d.ts +25 -0
- package/dest/modules/contract_data_source_adapter.d.ts.map +1 -0
- package/dest/modules/contract_data_source_adapter.js +42 -0
- package/dest/modules/data_source_base.d.ts +16 -10
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +71 -60
- package/dest/modules/data_store_updater.d.ts +6 -6
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +42 -40
- package/dest/modules/l1_synchronizer.d.ts +5 -4
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +79 -54
- package/dest/modules/validation.d.ts +4 -3
- package/dest/modules/validation.d.ts.map +1 -1
- package/dest/modules/validation.js +4 -4
- package/dest/store/block_store.d.ts +58 -27
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +152 -75
- package/dest/store/contract_class_store.d.ts +17 -3
- package/dest/store/contract_class_store.d.ts.map +1 -1
- package/dest/store/contract_class_store.js +17 -1
- package/dest/store/contract_instance_store.d.ts +28 -1
- package/dest/store/contract_instance_store.d.ts.map +1 -1
- package/dest/store/contract_instance_store.js +31 -0
- package/dest/store/data_stores.d.ts +68 -0
- package/dest/store/data_stores.d.ts.map +1 -0
- package/dest/store/data_stores.js +50 -0
- package/dest/store/function_names_cache.d.ts +17 -0
- package/dest/store/function_names_cache.d.ts.map +1 -0
- package/dest/store/function_names_cache.js +30 -0
- package/dest/store/l2_tips_cache.js +1 -1
- package/dest/test/fake_l1_state.d.ts +2 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +25 -8
- package/dest/test/mock_l2_block_source.d.ts +12 -3
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +24 -2
- package/dest/test/noop_l1_archiver.d.ts +4 -4
- package/dest/test/noop_l1_archiver.d.ts.map +1 -1
- package/dest/test/noop_l1_archiver.js +5 -5
- package/package.json +13 -13
- package/src/archiver.ts +91 -49
- package/src/config.ts +2 -1
- package/src/errors.ts +41 -8
- package/src/factory.ts +10 -10
- package/src/index.ts +15 -1
- package/src/l1/calldata_retriever.ts +15 -4
- package/src/modules/contract_data_source_adapter.ts +59 -0
- package/src/modules/data_source_base.ts +75 -57
- package/src/modules/data_store_updater.ts +46 -38
- package/src/modules/l1_synchronizer.ts +92 -60
- package/src/modules/validation.ts +8 -7
- package/src/store/block_store.ts +159 -80
- package/src/store/contract_class_store.ts +28 -2
- package/src/store/contract_instance_store.ts +43 -0
- package/src/store/data_stores.ts +108 -0
- package/src/store/function_names_cache.ts +37 -0
- package/src/store/l2_tips_cache.ts +1 -1
- package/src/test/fake_l1_state.ts +24 -14
- package/src/test/mock_l2_block_source.ts +23 -2
- package/src/test/noop_l1_archiver.ts +6 -6
- package/dest/store/kv_archiver_store.d.ts +0 -383
- package/dest/store/kv_archiver_store.d.ts.map +0 -1
- package/dest/store/kv_archiver_store.js +0 -501
- package/src/store/kv_archiver_store.ts +0 -728
|
@@ -4,131 +4,142 @@ import { isDefined } from '@aztec/foundation/types';
|
|
|
4
4
|
import { Checkpoint, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
5
5
|
import { getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
6
6
|
/**
|
|
7
|
-
* Abstract base class implementing ArchiverDataSource using a
|
|
8
|
-
* Provides implementations for all
|
|
9
|
-
*
|
|
7
|
+
* Abstract base class implementing ArchiverDataSource using a bundle of archiver substores.
|
|
8
|
+
* Provides implementations for all read-side methods and declares abstract methods for
|
|
9
|
+
* L1-dependent functionality that subclasses must implement.
|
|
10
10
|
*/ export class ArchiverDataSourceBase {
|
|
11
|
-
|
|
11
|
+
stores;
|
|
12
12
|
l1Constants;
|
|
13
|
-
constructor(
|
|
14
|
-
this.
|
|
13
|
+
constructor(stores, l1Constants){
|
|
14
|
+
this.stores = stores;
|
|
15
15
|
this.l1Constants = l1Constants;
|
|
16
16
|
}
|
|
17
17
|
getCheckpointNumber() {
|
|
18
|
-
return this.
|
|
18
|
+
return this.stores.blocks.getLatestCheckpointNumber();
|
|
19
19
|
}
|
|
20
20
|
getSynchedCheckpointNumber() {
|
|
21
|
-
return this.
|
|
21
|
+
return this.stores.blocks.getLatestCheckpointNumber();
|
|
22
22
|
}
|
|
23
23
|
getProvenCheckpointNumber() {
|
|
24
|
-
return this.
|
|
24
|
+
return this.stores.blocks.getProvenCheckpointNumber();
|
|
25
25
|
}
|
|
26
26
|
getBlockNumber() {
|
|
27
|
-
return this.
|
|
27
|
+
return this.stores.blocks.getLatestL2BlockNumber();
|
|
28
28
|
}
|
|
29
29
|
getProvenBlockNumber() {
|
|
30
|
-
return this.
|
|
30
|
+
return this.stores.blocks.getProvenBlockNumber();
|
|
31
31
|
}
|
|
32
32
|
async getBlockHeader(number) {
|
|
33
|
-
const blockNumber = number === 'latest' ? await this.
|
|
33
|
+
const blockNumber = number === 'latest' ? await this.stores.blocks.getLatestL2BlockNumber() : number;
|
|
34
34
|
if (blockNumber === 0) {
|
|
35
35
|
return undefined;
|
|
36
36
|
}
|
|
37
|
-
const headers = await this.
|
|
37
|
+
const headers = await this.stores.blocks.getBlockHeaders(blockNumber, 1);
|
|
38
38
|
return headers.length === 0 ? undefined : headers[0];
|
|
39
39
|
}
|
|
40
40
|
getCheckpointedBlock(number) {
|
|
41
|
-
return this.
|
|
41
|
+
return this.stores.blocks.getCheckpointedBlock(number);
|
|
42
42
|
}
|
|
43
43
|
getCheckpointedL2BlockNumber() {
|
|
44
|
-
return this.
|
|
44
|
+
return this.stores.blocks.getCheckpointedL2BlockNumber();
|
|
45
45
|
}
|
|
46
46
|
getFinalizedL2BlockNumber() {
|
|
47
|
-
return this.
|
|
47
|
+
return this.stores.blocks.getFinalizedL2BlockNumber();
|
|
48
48
|
}
|
|
49
49
|
async getCheckpointHeader(number) {
|
|
50
50
|
if (number === 'latest') {
|
|
51
|
-
number = await this.
|
|
51
|
+
number = await this.stores.blocks.getLatestCheckpointNumber();
|
|
52
52
|
}
|
|
53
53
|
if (number === 0) {
|
|
54
54
|
return undefined;
|
|
55
55
|
}
|
|
56
|
-
const checkpoint = await this.
|
|
56
|
+
const checkpoint = await this.stores.blocks.getCheckpointData(number);
|
|
57
57
|
if (!checkpoint) {
|
|
58
58
|
return undefined;
|
|
59
59
|
}
|
|
60
60
|
return checkpoint.header;
|
|
61
61
|
}
|
|
62
62
|
async getLastBlockNumberInCheckpoint(checkpointNumber) {
|
|
63
|
-
const checkpointData = await this.
|
|
63
|
+
const checkpointData = await this.stores.blocks.getCheckpointData(checkpointNumber);
|
|
64
64
|
if (!checkpointData) {
|
|
65
65
|
return undefined;
|
|
66
66
|
}
|
|
67
67
|
return BlockNumber(checkpointData.startBlock + checkpointData.blockCount - 1);
|
|
68
68
|
}
|
|
69
69
|
getCheckpointedBlocks(from, limit) {
|
|
70
|
-
return this.
|
|
70
|
+
return this.stores.blocks.getCheckpointedBlocks(from, limit);
|
|
71
|
+
}
|
|
72
|
+
getCheckpointData(checkpointNumber) {
|
|
73
|
+
return this.stores.blocks.getCheckpointData(checkpointNumber);
|
|
74
|
+
}
|
|
75
|
+
getCheckpointDataRange(from, limit) {
|
|
76
|
+
return this.stores.blocks.getRangeOfCheckpoints(from, limit);
|
|
77
|
+
}
|
|
78
|
+
getCheckpointNumberBySlot(slot) {
|
|
79
|
+
return this.stores.blocks.getCheckpointNumberBySlot(slot);
|
|
80
|
+
}
|
|
81
|
+
getBlockDataWithCheckpointContext(blockNumber) {
|
|
82
|
+
return this.stores.blocks.getBlockDataWithCheckpointContext(blockNumber);
|
|
71
83
|
}
|
|
72
84
|
getBlockHeaderByHash(blockHash) {
|
|
73
|
-
return this.
|
|
85
|
+
return this.stores.blocks.getBlockHeaderByHash(blockHash);
|
|
74
86
|
}
|
|
75
87
|
getBlockHeaderByArchive(archive) {
|
|
76
|
-
return this.
|
|
88
|
+
return this.stores.blocks.getBlockHeaderByArchive(archive);
|
|
77
89
|
}
|
|
78
90
|
getBlockData(number) {
|
|
79
|
-
return this.
|
|
91
|
+
return this.stores.blocks.getBlockData(number);
|
|
80
92
|
}
|
|
81
93
|
getBlockDataByArchive(archive) {
|
|
82
|
-
return this.
|
|
94
|
+
return this.stores.blocks.getBlockDataByArchive(archive);
|
|
83
95
|
}
|
|
84
96
|
async getL2Block(number) {
|
|
85
97
|
// If the number provided is -ve, then return the latest block.
|
|
86
98
|
if (number < 0) {
|
|
87
|
-
number = await this.
|
|
99
|
+
number = await this.stores.blocks.getLatestL2BlockNumber();
|
|
88
100
|
}
|
|
89
101
|
if (number === 0) {
|
|
90
102
|
return undefined;
|
|
91
103
|
}
|
|
92
|
-
|
|
93
|
-
return publishedBlock;
|
|
104
|
+
return this.stores.blocks.getBlock(number);
|
|
94
105
|
}
|
|
95
106
|
getTxEffect(txHash) {
|
|
96
|
-
return this.
|
|
107
|
+
return this.stores.blocks.getTxEffect(txHash);
|
|
97
108
|
}
|
|
98
109
|
getSettledTxReceipt(txHash) {
|
|
99
|
-
return this.
|
|
110
|
+
return this.stores.blocks.getSettledTxReceipt(txHash, this.l1Constants);
|
|
100
111
|
}
|
|
101
|
-
|
|
102
|
-
return this.
|
|
112
|
+
getLastCheckpoint() {
|
|
113
|
+
return this.stores.blocks.getLastCheckpoint();
|
|
103
114
|
}
|
|
104
|
-
|
|
105
|
-
return this.
|
|
115
|
+
getLastProposedCheckpoint() {
|
|
116
|
+
return this.stores.blocks.getLastProposedCheckpoint();
|
|
106
117
|
}
|
|
107
118
|
isPendingChainInvalid() {
|
|
108
119
|
return this.getPendingChainValidationStatus().then((status)=>!status.valid);
|
|
109
120
|
}
|
|
110
121
|
async getPendingChainValidationStatus() {
|
|
111
|
-
return await this.
|
|
122
|
+
return await this.stores.blocks.getPendingChainValidationStatus() ?? {
|
|
112
123
|
valid: true
|
|
113
124
|
};
|
|
114
125
|
}
|
|
115
126
|
getPrivateLogsByTags(tags, page, upToBlockNumber) {
|
|
116
|
-
return this.
|
|
127
|
+
return this.stores.logs.getPrivateLogsByTags(tags, page, upToBlockNumber);
|
|
117
128
|
}
|
|
118
129
|
getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber) {
|
|
119
|
-
return this.
|
|
130
|
+
return this.stores.logs.getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber);
|
|
120
131
|
}
|
|
121
132
|
getPublicLogs(filter) {
|
|
122
|
-
return this.
|
|
133
|
+
return this.stores.logs.getPublicLogs(filter);
|
|
123
134
|
}
|
|
124
135
|
getContractClassLogs(filter) {
|
|
125
|
-
return this.
|
|
136
|
+
return this.stores.logs.getContractClassLogs(filter);
|
|
126
137
|
}
|
|
127
138
|
getContractClass(id) {
|
|
128
|
-
return this.
|
|
139
|
+
return this.stores.contractClasses.getContractClass(id);
|
|
129
140
|
}
|
|
130
141
|
getBytecodeCommitment(id) {
|
|
131
|
-
return this.
|
|
142
|
+
return this.stores.contractClasses.getBytecodeCommitment(id);
|
|
132
143
|
}
|
|
133
144
|
async getContract(address, maybeTimestamp) {
|
|
134
145
|
let timestamp;
|
|
@@ -139,37 +150,37 @@ import { getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
|
139
150
|
} else {
|
|
140
151
|
timestamp = maybeTimestamp;
|
|
141
152
|
}
|
|
142
|
-
return this.
|
|
153
|
+
return this.stores.contractInstances.getContractInstance(address, timestamp);
|
|
143
154
|
}
|
|
144
155
|
getContractClassIds() {
|
|
145
|
-
return this.
|
|
156
|
+
return this.stores.contractClasses.getContractClassIds();
|
|
146
157
|
}
|
|
147
|
-
getDebugFunctionName(
|
|
148
|
-
return this.
|
|
158
|
+
/** Looks up a public function name given a selector. */ getDebugFunctionName(_address, selector) {
|
|
159
|
+
return Promise.resolve(this.stores.functionNames.get(selector));
|
|
149
160
|
}
|
|
150
|
-
registerContractFunctionSignatures(signatures) {
|
|
151
|
-
return this.
|
|
161
|
+
/** Register public function signatures so they can be looked up by selector. */ registerContractFunctionSignatures(signatures) {
|
|
162
|
+
return this.stores.functionNames.register(signatures);
|
|
152
163
|
}
|
|
153
164
|
getL1ToL2Messages(checkpointNumber) {
|
|
154
|
-
return this.
|
|
165
|
+
return this.stores.messages.getL1ToL2Messages(checkpointNumber);
|
|
155
166
|
}
|
|
156
167
|
getL1ToL2MessageIndex(l1ToL2Message) {
|
|
157
|
-
return this.
|
|
168
|
+
return this.stores.messages.getL1ToL2MessageIndex(l1ToL2Message);
|
|
158
169
|
}
|
|
159
170
|
async getCheckpoints(checkpointNumber, limit) {
|
|
160
|
-
const checkpoints = await this.
|
|
171
|
+
const checkpoints = await this.stores.blocks.getRangeOfCheckpoints(checkpointNumber, limit);
|
|
161
172
|
return Promise.all(checkpoints.map((ch)=>this.getPublishedCheckpointFromCheckpointData(ch)));
|
|
162
173
|
}
|
|
163
174
|
async getPublishedCheckpointFromCheckpointData(checkpoint) {
|
|
164
|
-
const blocksForCheckpoint = await this.
|
|
175
|
+
const blocksForCheckpoint = await this.stores.blocks.getBlocksForCheckpoint(checkpoint.checkpointNumber);
|
|
165
176
|
if (!blocksForCheckpoint) {
|
|
166
177
|
throw new Error(`Blocks for checkpoint ${checkpoint.checkpointNumber} not found`);
|
|
167
178
|
}
|
|
168
|
-
const fullCheckpoint = new Checkpoint(checkpoint.archive, checkpoint.header, blocksForCheckpoint, checkpoint.checkpointNumber);
|
|
179
|
+
const fullCheckpoint = new Checkpoint(checkpoint.archive, checkpoint.header, blocksForCheckpoint, checkpoint.checkpointNumber, checkpoint.feeAssetPriceModifier);
|
|
169
180
|
return new PublishedCheckpoint(fullCheckpoint, checkpoint.l1, checkpoint.attestations);
|
|
170
181
|
}
|
|
171
182
|
getBlocksForSlot(slotNumber) {
|
|
172
|
-
return this.
|
|
183
|
+
return this.stores.blocks.getBlocksForSlot(slotNumber);
|
|
173
184
|
}
|
|
174
185
|
async getCheckpointedBlocksForEpoch(epochNumber) {
|
|
175
186
|
const checkpointsData = await this.getCheckpointsDataForEpoch(epochNumber);
|
|
@@ -190,33 +201,33 @@ import { getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
|
190
201
|
throw new Error('L1 constants not set');
|
|
191
202
|
}
|
|
192
203
|
const [start, end] = getSlotRangeForEpoch(epochNumber, this.l1Constants);
|
|
193
|
-
return this.
|
|
204
|
+
return this.stores.blocks.getCheckpointDataForSlotRange(start, end);
|
|
194
205
|
}
|
|
195
206
|
async getBlock(number) {
|
|
196
207
|
// If the number provided is -ve, then return the latest block.
|
|
197
208
|
if (number < 0) {
|
|
198
|
-
number = await this.
|
|
209
|
+
number = await this.stores.blocks.getLatestL2BlockNumber();
|
|
199
210
|
}
|
|
200
211
|
if (number === 0) {
|
|
201
212
|
return undefined;
|
|
202
213
|
}
|
|
203
|
-
return this.
|
|
214
|
+
return this.stores.blocks.getBlock(number);
|
|
204
215
|
}
|
|
205
216
|
getBlocks(from, limit) {
|
|
206
|
-
return this.
|
|
217
|
+
return this.stores.blocks.getBlocks(from, limit);
|
|
207
218
|
}
|
|
208
219
|
getCheckpointedBlockByHash(blockHash) {
|
|
209
|
-
return this.
|
|
220
|
+
return this.stores.blocks.getCheckpointedBlockByHash(blockHash);
|
|
210
221
|
}
|
|
211
222
|
getCheckpointedBlockByArchive(archive) {
|
|
212
|
-
return this.
|
|
223
|
+
return this.stores.blocks.getCheckpointedBlockByArchive(archive);
|
|
213
224
|
}
|
|
214
225
|
async getL2BlockByHash(blockHash) {
|
|
215
|
-
const checkpointedBlock = await this.
|
|
226
|
+
const checkpointedBlock = await this.stores.blocks.getCheckpointedBlockByHash(blockHash);
|
|
216
227
|
return checkpointedBlock?.block;
|
|
217
228
|
}
|
|
218
229
|
async getL2BlockByArchive(archive) {
|
|
219
|
-
const checkpointedBlock = await this.
|
|
230
|
+
const checkpointedBlock = await this.stores.blocks.getCheckpointedBlockByArchive(archive);
|
|
220
231
|
return checkpointedBlock?.block;
|
|
221
232
|
}
|
|
222
233
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { CommitteeAttestation, L2Block, ValidateCheckpointResult } from '@aztec/stdlib/block';
|
|
3
3
|
import { type L1PublishedData, type ProposedCheckpointInput, type PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ArchiverDataStores } from '../store/data_stores.js';
|
|
5
5
|
import type { L2TipsCache } from '../store/l2_tips_cache.js';
|
|
6
6
|
/** Result of adding checkpoints with information about any pruned blocks. */
|
|
7
7
|
type ReconcileCheckpointsResult = {
|
|
@@ -12,11 +12,11 @@ type ReconcileCheckpointsResult = {
|
|
|
12
12
|
};
|
|
13
13
|
/** Archiver helper module to handle updates to the data store. */
|
|
14
14
|
export declare class ArchiverDataStoreUpdater {
|
|
15
|
-
private
|
|
15
|
+
private stores;
|
|
16
16
|
private l2TipsCache?;
|
|
17
17
|
private opts;
|
|
18
18
|
private readonly log;
|
|
19
|
-
constructor(
|
|
19
|
+
constructor(stores: ArchiverDataStores, l2TipsCache?: L2TipsCache | undefined, opts?: {
|
|
20
20
|
rollupManaLimit?: number;
|
|
21
21
|
});
|
|
22
22
|
/**
|
|
@@ -46,8 +46,8 @@ export declare class ArchiverDataStoreUpdater {
|
|
|
46
46
|
l1: L1PublishedData;
|
|
47
47
|
attestations: CommitteeAttestation[];
|
|
48
48
|
checkpoint: PublishedCheckpoint;
|
|
49
|
-
}): Promise<ReconcileCheckpointsResult>;
|
|
50
|
-
|
|
49
|
+
}, evictProposedFrom?: CheckpointNumber): Promise<ReconcileCheckpointsResult>;
|
|
50
|
+
addProposedCheckpoint(proposedCheckpoint: ProposedCheckpointInput): Promise<void>;
|
|
51
51
|
private pruneMismatchingLocalBlocks;
|
|
52
52
|
/**
|
|
53
53
|
* Removes all uncheckpointed blocks strictly after the specified block number and cleans up associated contract data.
|
|
@@ -90,4 +90,4 @@ export declare class ArchiverDataStoreUpdater {
|
|
|
90
90
|
private updateUpdatedContractInstances;
|
|
91
91
|
}
|
|
92
92
|
export {};
|
|
93
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
93
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0YV9zdG9yZV91cGRhdGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbW9kdWxlcy9kYXRhX3N0b3JlX3VwZGF0ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBUWhGLE9BQU8sS0FBSyxFQUFFLG9CQUFvQixFQUFFLE9BQU8sRUFBRSx3QkFBd0IsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ25HLE9BQU8sRUFDTCxLQUFLLGVBQWUsRUFDcEIsS0FBSyx1QkFBdUIsRUFDNUIsS0FBSyxtQkFBbUIsRUFFekIsTUFBTSwwQkFBMEIsQ0FBQztBQVNsQyxP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B,WAAW,EAAE,mBAAmB,EAAE,EAClC,4BAA4B,CAAC,EAAE,wBAAwB,EACvD,eAAe,CAAC,EAAE;QAChB,EAAE,EAAE,eAAe,CAAC;QACpB,YAAY,EAAE,oBAAoB,EAAE,CAAC;QACrC,UAAU,EAAE,mBAAmB,CAAC;KACjC,EACD,iBAAiB,CAAC,EAAE,gBAAgB,GACnC,OAAO,CAAC,0BAA0B,CAAC,CA8CrC;IAEY,qBAAqB,CAAC,kBAAkB,EAAE,uBAAuB,iBAO7E;YAQa,2BAA2B;IAmEzC;;;;;;;;OAQG;IACU,+BAA+B,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAmBzF;YAMa,iBAAiB;IAa/B;;;;;;;;OAQG;IACU,sBAAsB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAexF;IAED;;;OAGG;IACU,yBAAyB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAKxF;IAED;;;OAGG;IACU,4BAA4B,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAK3F;IAED,6DAA6D;IAC7D,OAAO,CAAC,mBAAmB;IAI3B,qDAAqD;IACrD,OAAO,CAAC,wBAAwB;YAKlB,sBAAsB;YAiBtB,8BAA8B;YA+C9B,+BAA+B;YA0C/B,8BAA8B;CAsB7C"}
|
|
@@ -11,12 +11,12 @@ import { computeContractAddressFromInstance, computeContractClassId } from '@azt
|
|
|
11
11
|
return Operation;
|
|
12
12
|
}(Operation || {});
|
|
13
13
|
/** Archiver helper module to handle updates to the data store. */ export class ArchiverDataStoreUpdater {
|
|
14
|
-
|
|
14
|
+
stores;
|
|
15
15
|
l2TipsCache;
|
|
16
16
|
opts;
|
|
17
17
|
log;
|
|
18
|
-
constructor(
|
|
19
|
-
this.
|
|
18
|
+
constructor(stores, l2TipsCache, opts = {}){
|
|
19
|
+
this.stores = stores;
|
|
20
20
|
this.l2TipsCache = l2TipsCache;
|
|
21
21
|
this.opts = opts;
|
|
22
22
|
this.log = createLogger('archiver:store_updater');
|
|
@@ -30,13 +30,13 @@ import { computeContractAddressFromInstance, computeContractClassId } from '@azt
|
|
|
30
30
|
* @param pendingChainValidationStatus - Optional validation status to set.
|
|
31
31
|
* @returns True if the operation is successful.
|
|
32
32
|
*/ async addProposedBlock(block, pendingChainValidationStatus) {
|
|
33
|
-
const result = await this.
|
|
34
|
-
await this.
|
|
33
|
+
const result = await this.stores.db.transactionAsync(async ()=>{
|
|
34
|
+
await this.stores.blocks.addProposedBlock(block);
|
|
35
35
|
const opResults = await Promise.all([
|
|
36
36
|
// Update the pending chain validation status if provided
|
|
37
|
-
pendingChainValidationStatus && this.
|
|
37
|
+
pendingChainValidationStatus && this.stores.blocks.setPendingChainValidationStatus(pendingChainValidationStatus),
|
|
38
38
|
// Add any logs emitted during the retrieved block
|
|
39
|
-
this.
|
|
39
|
+
this.stores.logs.addLogs([
|
|
40
40
|
block
|
|
41
41
|
]),
|
|
42
42
|
// Unroll all logs emitted during the retrieved block and extract any contract classes and instances from it
|
|
@@ -59,7 +59,7 @@ import { computeContractAddressFromInstance, computeContractClassId } from '@azt
|
|
|
59
59
|
* @param pendingChainValidationStatus - Optional validation status to set.
|
|
60
60
|
* @param promoteProposed - Optional promotion of the current proposed checkpoint (fast path when blocks are already local).
|
|
61
61
|
* @returns Result with information about any pruned blocks.
|
|
62
|
-
*/ async addCheckpoints(checkpoints, pendingChainValidationStatus, promoteProposed) {
|
|
62
|
+
*/ async addCheckpoints(checkpoints, pendingChainValidationStatus, promoteProposed, evictProposedFrom) {
|
|
63
63
|
for (const checkpoint of checkpoints){
|
|
64
64
|
validateCheckpoint(checkpoint.checkpoint, {
|
|
65
65
|
rollupManaLimit: this.opts?.rollupManaLimit
|
|
@@ -70,21 +70,23 @@ import { computeContractAddressFromInstance, computeContractClassId } from '@azt
|
|
|
70
70
|
rollupManaLimit: this.opts?.rollupManaLimit
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
-
const result = await this.
|
|
73
|
+
const result = await this.stores.db.transactionAsync(async ()=>{
|
|
74
74
|
// Before adding checkpoints, check for conflicts with local blocks if any
|
|
75
75
|
const { prunedBlocks, lastAlreadyInsertedBlockNumber } = await this.pruneMismatchingLocalBlocks(checkpoints);
|
|
76
|
-
await this.
|
|
76
|
+
await this.stores.blocks.addCheckpoints(checkpoints);
|
|
77
77
|
// Filter out blocks that were already inserted via addProposedBlock() to avoid duplicating logs/contract data
|
|
78
78
|
const newBlocks = checkpoints.flatMap((ch)=>ch.checkpoint.blocks).filter((b)=>lastAlreadyInsertedBlockNumber === undefined || b.number > lastAlreadyInsertedBlockNumber);
|
|
79
79
|
await Promise.all([
|
|
80
80
|
// Update the pending chain validation status if provided
|
|
81
|
-
pendingChainValidationStatus && this.
|
|
81
|
+
pendingChainValidationStatus && this.stores.blocks.setPendingChainValidationStatus(pendingChainValidationStatus),
|
|
82
82
|
// Add any logs emitted during the retrieved blocks
|
|
83
|
-
this.
|
|
83
|
+
this.stores.logs.addLogs(newBlocks),
|
|
84
84
|
// Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
|
|
85
85
|
...newBlocks.map((block)=>this.addContractDataToDb(block)),
|
|
86
|
-
// Promote the proposed checkpoint if requested
|
|
87
|
-
promoteProposed ? this.
|
|
86
|
+
// Promote the proposed checkpoint if requested (uses explicit checkpoint number)
|
|
87
|
+
promoteProposed ? this.stores.blocks.promoteProposedToCheckpointed(promoteProposed.checkpoint.checkpoint.number, promoteProposed.l1, promoteProposed.attestations, promoteProposed.checkpoint.checkpoint.archive.root) : undefined,
|
|
88
|
+
// Evict pending checkpoints that diverged from what L1 mined
|
|
89
|
+
evictProposedFrom !== undefined ? this.stores.blocks.evictProposedCheckpointsFrom(evictProposedFrom) : undefined
|
|
88
90
|
]);
|
|
89
91
|
await this.l2TipsCache?.refresh();
|
|
90
92
|
return {
|
|
@@ -94,9 +96,9 @@ import { computeContractAddressFromInstance, computeContractClassId } from '@azt
|
|
|
94
96
|
});
|
|
95
97
|
return result;
|
|
96
98
|
}
|
|
97
|
-
async
|
|
98
|
-
const result = await this.
|
|
99
|
-
await this.
|
|
99
|
+
async addProposedCheckpoint(proposedCheckpoint) {
|
|
100
|
+
const result = await this.stores.db.transactionAsync(async ()=>{
|
|
101
|
+
await this.stores.blocks.addProposedCheckpoint(proposedCheckpoint);
|
|
100
102
|
await this.l2TipsCache?.refresh();
|
|
101
103
|
});
|
|
102
104
|
return result;
|
|
@@ -108,8 +110,8 @@ import { computeContractAddressFromInstance, computeContractClassId } from '@azt
|
|
|
108
110
|
* and when checkpoints are added afterward, they include all the correct blocks.
|
|
109
111
|
*/ async pruneMismatchingLocalBlocks(checkpoints) {
|
|
110
112
|
const [lastCheckpointedBlockNumber, lastBlockNumber] = await Promise.all([
|
|
111
|
-
this.
|
|
112
|
-
this.
|
|
113
|
+
this.stores.blocks.getCheckpointedL2BlockNumber(),
|
|
114
|
+
this.stores.blocks.getLatestL2BlockNumber()
|
|
113
115
|
]);
|
|
114
116
|
// Exit early if there are no local uncheckpointed blocks
|
|
115
117
|
if (lastBlockNumber === lastCheckpointedBlockNumber) {
|
|
@@ -119,7 +121,7 @@ import { computeContractAddressFromInstance, computeContractClassId } from '@azt
|
|
|
119
121
|
};
|
|
120
122
|
}
|
|
121
123
|
// Get all uncheckpointed local blocks
|
|
122
|
-
const uncheckpointedLocalBlocks = await this.
|
|
124
|
+
const uncheckpointedLocalBlocks = await this.stores.blocks.getBlocks(BlockNumber.add(lastCheckpointedBlockNumber, 1), lastBlockNumber - lastCheckpointedBlockNumber);
|
|
123
125
|
let lastAlreadyInsertedBlockNumber;
|
|
124
126
|
for (const publishedCheckpoint of checkpoints){
|
|
125
127
|
const checkpointBlocks = publishedCheckpoint.checkpoint.blocks;
|
|
@@ -178,15 +180,15 @@ import { computeContractAddressFromInstance, computeContractClassId } from '@azt
|
|
|
178
180
|
* @returns The removed blocks.
|
|
179
181
|
* @throws Error if any block to be removed is checkpointed.
|
|
180
182
|
*/ async removeUncheckpointedBlocksAfter(blockNumber) {
|
|
181
|
-
const result = await this.
|
|
183
|
+
const result = await this.stores.db.transactionAsync(async ()=>{
|
|
182
184
|
// Verify we're only removing uncheckpointed blocks
|
|
183
|
-
const lastCheckpointedBlockNumber = await this.
|
|
185
|
+
const lastCheckpointedBlockNumber = await this.stores.blocks.getCheckpointedL2BlockNumber();
|
|
184
186
|
if (blockNumber < lastCheckpointedBlockNumber) {
|
|
185
187
|
throw new Error(`Cannot remove blocks after ${blockNumber} because checkpointed blocks exist up to ${lastCheckpointedBlockNumber}`);
|
|
186
188
|
}
|
|
187
189
|
const result = await this.removeBlocksAfter(blockNumber);
|
|
188
|
-
// Clear
|
|
189
|
-
await this.
|
|
190
|
+
// Clear all pending proposed checkpoints since their blocks have been pruned
|
|
191
|
+
await this.stores.blocks.deleteProposedCheckpoints();
|
|
190
192
|
await this.l2TipsCache?.refresh();
|
|
191
193
|
return result;
|
|
192
194
|
});
|
|
@@ -197,10 +199,10 @@ import { computeContractAddressFromInstance, computeContractClassId } from '@azt
|
|
|
197
199
|
* Does not remove their checkpoints.
|
|
198
200
|
*/ async removeBlocksAfter(blockNumber) {
|
|
199
201
|
// First get the blocks to be removed so we can clean up contract data
|
|
200
|
-
const removedBlocks = await this.
|
|
202
|
+
const removedBlocks = await this.stores.blocks.removeBlocksAfter(blockNumber);
|
|
201
203
|
// Clean up contract data and logs for the removed blocks
|
|
202
204
|
await Promise.all([
|
|
203
|
-
this.
|
|
205
|
+
this.stores.logs.deleteLogs(removedBlocks),
|
|
204
206
|
...removedBlocks.map((block)=>this.removeContractDataFromDb(block))
|
|
205
207
|
]);
|
|
206
208
|
return removedBlocks;
|
|
@@ -214,16 +216,16 @@ import { computeContractAddressFromInstance, computeContractClassId } from '@azt
|
|
|
214
216
|
* @param checkpointNumber - Remove all checkpoints strictly after this one.
|
|
215
217
|
* @returns True if the operation is successful.
|
|
216
218
|
*/ async removeCheckpointsAfter(checkpointNumber) {
|
|
217
|
-
return await this.
|
|
218
|
-
const { blocksRemoved = [] } = await this.
|
|
219
|
+
return await this.stores.db.transactionAsync(async ()=>{
|
|
220
|
+
const { blocksRemoved = [] } = await this.stores.blocks.removeCheckpointsAfter(checkpointNumber);
|
|
219
221
|
const opResults = await Promise.all([
|
|
220
222
|
// Prune rolls back to the last proven block, which is by definition valid
|
|
221
|
-
this.
|
|
223
|
+
this.stores.blocks.setPendingChainValidationStatus({
|
|
222
224
|
valid: true
|
|
223
225
|
}),
|
|
224
226
|
// Remove contract data for all blocks being removed
|
|
225
227
|
...blocksRemoved.map((block)=>this.removeContractDataFromDb(block)),
|
|
226
|
-
this.
|
|
228
|
+
this.stores.logs.deleteLogs(blocksRemoved)
|
|
227
229
|
]);
|
|
228
230
|
await this.l2TipsCache?.refresh();
|
|
229
231
|
return opResults.every(Boolean);
|
|
@@ -233,8 +235,8 @@ import { computeContractAddressFromInstance, computeContractClassId } from '@azt
|
|
|
233
235
|
* Updates the proven checkpoint number and refreshes the L2 tips cache.
|
|
234
236
|
* @param checkpointNumber - The checkpoint number to set as proven.
|
|
235
237
|
*/ async setProvenCheckpointNumber(checkpointNumber) {
|
|
236
|
-
await this.
|
|
237
|
-
await this.
|
|
238
|
+
await this.stores.db.transactionAsync(async ()=>{
|
|
239
|
+
await this.stores.blocks.setProvenCheckpointNumber(checkpointNumber);
|
|
238
240
|
await this.l2TipsCache?.refresh();
|
|
239
241
|
});
|
|
240
242
|
}
|
|
@@ -242,8 +244,8 @@ import { computeContractAddressFromInstance, computeContractClassId } from '@azt
|
|
|
242
244
|
* Updates the finalized checkpoint number and refreshes the L2 tips cache.
|
|
243
245
|
* @param checkpointNumber - The checkpoint number to set as finalized.
|
|
244
246
|
*/ async setFinalizedCheckpointNumber(checkpointNumber) {
|
|
245
|
-
await this.
|
|
246
|
-
await this.
|
|
247
|
+
await this.stores.db.transactionAsync(async ()=>{
|
|
248
|
+
await this.stores.blocks.setFinalizedCheckpointNumber(checkpointNumber);
|
|
247
249
|
await this.l2TipsCache?.refresh();
|
|
248
250
|
});
|
|
249
251
|
}
|
|
@@ -271,7 +273,7 @@ import { computeContractAddressFromInstance, computeContractClassId } from '@azt
|
|
|
271
273
|
const contractClasses = contractClassPublishedEvents.map((e)=>e.toContractClassPublic());
|
|
272
274
|
if (contractClasses.length > 0) {
|
|
273
275
|
contractClasses.forEach((c)=>this.log.verbose(`${Operation[operation]} contract class ${c.id.toString()}`));
|
|
274
|
-
return await this.
|
|
276
|
+
return await this.stores.contractClasses.deleteContractClasses(contractClasses, blockNum);
|
|
275
277
|
}
|
|
276
278
|
return true;
|
|
277
279
|
}
|
|
@@ -295,7 +297,7 @@ import { computeContractAddressFromInstance, computeContractClassId } from '@azt
|
|
|
295
297
|
}
|
|
296
298
|
if (contractClasses.length > 0) {
|
|
297
299
|
contractClasses.forEach((c)=>this.log.verbose(`${Operation[operation]} contract class ${c.id.toString()}`));
|
|
298
|
-
return await this.
|
|
300
|
+
return await this.stores.contractClasses.addContractClasses(contractClasses, blockNum);
|
|
299
301
|
}
|
|
300
302
|
return true;
|
|
301
303
|
}
|
|
@@ -319,9 +321,9 @@ import { computeContractAddressFromInstance, computeContractClassId } from '@azt
|
|
|
319
321
|
if (contractInstances.length > 0) {
|
|
320
322
|
contractInstances.forEach((c)=>this.log.verbose(`${Operation[operation]} contract instance at ${c.address.toString()}`));
|
|
321
323
|
if (operation == 0) {
|
|
322
|
-
return await this.
|
|
324
|
+
return await this.stores.contractInstances.addContractInstances(contractInstances, blockNum);
|
|
323
325
|
} else if (operation == 1) {
|
|
324
|
-
return await this.
|
|
326
|
+
return await this.stores.contractInstances.deleteContractInstances(contractInstances);
|
|
325
327
|
}
|
|
326
328
|
}
|
|
327
329
|
return true;
|
|
@@ -333,9 +335,9 @@ import { computeContractAddressFromInstance, computeContractClassId } from '@azt
|
|
|
333
335
|
if (contractUpdates.length > 0) {
|
|
334
336
|
contractUpdates.forEach((c)=>this.log.verbose(`${Operation[operation]} contract instance update at ${c.address.toString()}`));
|
|
335
337
|
if (operation == 0) {
|
|
336
|
-
return await this.
|
|
338
|
+
return await this.stores.contractInstances.addContractInstanceUpdates(contractUpdates, timestamp);
|
|
337
339
|
} else if (operation == 1) {
|
|
338
|
-
return await this.
|
|
340
|
+
return await this.stores.contractInstances.deleteContractInstanceUpdates(contractUpdates, timestamp);
|
|
339
341
|
}
|
|
340
342
|
}
|
|
341
343
|
return true;
|
|
@@ -9,7 +9,7 @@ import { DateProvider } from '@aztec/foundation/timer';
|
|
|
9
9
|
import { type ArchiverEmitter } from '@aztec/stdlib/block';
|
|
10
10
|
import { type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
11
11
|
import { type Traceable, type Tracer } from '@aztec/telemetry-client';
|
|
12
|
-
import type
|
|
12
|
+
import { type ArchiverDataStores } from '../store/data_stores.js';
|
|
13
13
|
import type { L2TipsCache } from '../store/l2_tips_cache.js';
|
|
14
14
|
import type { ArchiverInstrumentation } from './instrumentation.js';
|
|
15
15
|
/**
|
|
@@ -21,7 +21,7 @@ export declare class ArchiverL1Synchronizer implements Traceable {
|
|
|
21
21
|
private readonly debugClient;
|
|
22
22
|
private readonly rollup;
|
|
23
23
|
private readonly inbox;
|
|
24
|
-
private readonly
|
|
24
|
+
private readonly stores;
|
|
25
25
|
private config;
|
|
26
26
|
private readonly blobClient;
|
|
27
27
|
private readonly epochCache;
|
|
@@ -35,7 +35,7 @@ export declare class ArchiverL1Synchronizer implements Traceable {
|
|
|
35
35
|
private l1Timestamp;
|
|
36
36
|
private readonly updater;
|
|
37
37
|
readonly tracer: Tracer;
|
|
38
|
-
constructor(publicClient: ViemPublicClient, debugClient: ViemPublicDebugClient, rollup: RollupContract, inbox: InboxContract,
|
|
38
|
+
constructor(publicClient: ViemPublicClient, debugClient: ViemPublicDebugClient, rollup: RollupContract, inbox: InboxContract, stores: ArchiverDataStores, config: {
|
|
39
39
|
batchSize: number;
|
|
40
40
|
skipValidateCheckpointAttestations?: boolean;
|
|
41
41
|
skipPromoteProposedCheckpointDuringL1Sync?: boolean;
|
|
@@ -55,6 +55,7 @@ export declare class ArchiverL1Synchronizer implements Traceable {
|
|
|
55
55
|
getL1BlockNumber(): bigint | undefined;
|
|
56
56
|
/** Returns the last L1 timestamp that was synced. */
|
|
57
57
|
getL1Timestamp(): bigint | undefined;
|
|
58
|
+
private getSignatureContext;
|
|
58
59
|
/** Checks that the ethereum node we are connected to has a latest timestamp no more than the allowed drift. Throw if not. */
|
|
59
60
|
testEthereumNodeSynced(): Promise<void>;
|
|
60
61
|
syncFromL1(initialSyncComplete: boolean): Promise<void>;
|
|
@@ -73,4 +74,4 @@ export declare class ArchiverL1Synchronizer implements Traceable {
|
|
|
73
74
|
private checkForNewCheckpointsBeforeL1SyncPoint;
|
|
74
75
|
private getCheckpointHeader;
|
|
75
76
|
}
|
|
76
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
77
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibDFfc3luY2hyb25pemVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbW9kdWxlcy9sMV9zeW5jaHJvbml6ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUNyRSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDaEQsT0FBTyxFQUFFLGFBQWEsRUFBMkIsY0FBYyxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFHbkcsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUscUJBQXFCLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUlyRixPQUFPLEVBQVksUUFBUSxFQUFFLE1BQU0sMEJBQTBCLENBQUM7Q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