@aztec/archiver 0.0.1-commit.2ed92850 → 0.0.1-commit.3469e52
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 +0 -9
- package/dest/archiver.d.ts +4 -4
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +20 -19
- package/dest/errors.d.ts +1 -6
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +0 -8
- package/dest/factory.d.ts +2 -3
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +3 -5
- package/dest/l1/bin/retrieve-calldata.js +2 -2
- package/dest/l1/data_retrieval.d.ts +1 -1
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +2 -2
- package/dest/modules/data_source_base.d.ts +17 -16
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +52 -21
- package/dest/modules/data_store_updater.d.ts +19 -23
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +49 -47
- package/dest/modules/instrumentation.d.ts +3 -3
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +7 -7
- package/dest/store/block_store.d.ts +19 -33
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +39 -80
- package/dest/store/kv_archiver_store.d.ts +22 -26
- package/dest/store/kv_archiver_store.d.ts.map +1 -1
- package/dest/store/kv_archiver_store.js +14 -18
- package/dest/store/log_store.d.ts +4 -4
- package/dest/store/log_store.d.ts.map +1 -1
- package/dest/test/fake_l1_state.d.ts +4 -4
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +1 -1
- package/dest/test/mock_l2_block_source.d.ts +18 -18
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +40 -39
- package/dest/test/mock_structs.js +4 -4
- package/package.json +13 -13
- package/src/archiver.ts +26 -24
- package/src/errors.ts +0 -12
- package/src/factory.ts +2 -4
- package/src/l1/bin/retrieve-calldata.ts +2 -7
- package/src/l1/data_retrieval.ts +3 -3
- package/src/modules/data_source_base.ts +76 -25
- package/src/modules/data_store_updater.ts +55 -59
- package/src/modules/instrumentation.ts +2 -2
- package/src/modules/l1_synchronizer.ts +9 -9
- package/src/store/block_store.ts +56 -103
- package/src/store/kv_archiver_store.ts +24 -32
- package/src/store/log_store.ts +8 -8
- package/src/test/fake_l1_state.ts +2 -2
- package/src/test/mock_archiver.ts +1 -1
- package/src/test/mock_l2_block_source.ts +60 -50
- package/src/test/mock_structs.ts +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { isDefined } from '@aztec/foundation/types';
|
|
3
|
-
import { CommitteeAttestation } from '@aztec/stdlib/block';
|
|
3
|
+
import { CheckpointedL2Block, CommitteeAttestation } from '@aztec/stdlib/block';
|
|
4
4
|
import { Checkpoint, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
5
5
|
import { getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
6
6
|
/**
|
|
@@ -40,12 +40,9 @@ import { getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
|
40
40
|
getCheckpointedBlock(number) {
|
|
41
41
|
return this.store.getCheckpointedBlock(number);
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
getCheckpointedBlockNumber() {
|
|
44
44
|
return this.store.getCheckpointedL2BlockNumber();
|
|
45
45
|
}
|
|
46
|
-
getFinalizedL2BlockNumber() {
|
|
47
|
-
return this.store.getFinalizedL2BlockNumber();
|
|
48
|
-
}
|
|
49
46
|
async getCheckpointHeader(number) {
|
|
50
47
|
if (number === 'latest') {
|
|
51
48
|
number = await this.store.getSynchedCheckpointNumber();
|
|
@@ -66,8 +63,13 @@ import { getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
|
66
63
|
}
|
|
67
64
|
return BlockNumber(checkpointData.startBlock + checkpointData.numBlocks - 1);
|
|
68
65
|
}
|
|
69
|
-
getCheckpointedBlocks(from, limit) {
|
|
70
|
-
|
|
66
|
+
async getCheckpointedBlocks(from, limit, proven) {
|
|
67
|
+
const blocks = await this.store.getCheckpointedBlocks(from, limit);
|
|
68
|
+
if (proven === true) {
|
|
69
|
+
const provenBlockNumber = await this.store.getProvenBlockNumber();
|
|
70
|
+
return blocks.filter((b)=>b.block.number <= provenBlockNumber);
|
|
71
|
+
}
|
|
72
|
+
return blocks;
|
|
71
73
|
}
|
|
72
74
|
getBlockHeaderByHash(blockHash) {
|
|
73
75
|
return this.store.getBlockHeaderByHash(blockHash);
|
|
@@ -75,7 +77,7 @@ import { getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
|
75
77
|
getBlockHeaderByArchive(archive) {
|
|
76
78
|
return this.store.getBlockHeaderByArchive(archive);
|
|
77
79
|
}
|
|
78
|
-
async
|
|
80
|
+
async getL2BlockNew(number) {
|
|
79
81
|
// If the number provided is -ve, then return the latest block.
|
|
80
82
|
if (number < 0) {
|
|
81
83
|
number = await this.store.getLatestBlockNumber();
|
|
@@ -100,6 +102,14 @@ import { getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
|
100
102
|
valid: true
|
|
101
103
|
};
|
|
102
104
|
}
|
|
105
|
+
async getL2BlocksNew(from, limit, proven) {
|
|
106
|
+
const blocks = await this.store.getBlocks(from, limit);
|
|
107
|
+
if (proven === true) {
|
|
108
|
+
const provenBlockNumber = await this.store.getProvenBlockNumber();
|
|
109
|
+
return blocks.filter((b)=>b.number <= provenBlockNumber);
|
|
110
|
+
}
|
|
111
|
+
return blocks;
|
|
112
|
+
}
|
|
103
113
|
getPrivateLogsByTags(tags, page) {
|
|
104
114
|
return this.store.getPrivateLogsByTags(tags, page);
|
|
105
115
|
}
|
|
@@ -144,7 +154,7 @@ import { getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
|
144
154
|
getL1ToL2MessageIndex(l1ToL2Message) {
|
|
145
155
|
return this.store.getL1ToL2MessageIndex(l1ToL2Message);
|
|
146
156
|
}
|
|
147
|
-
async
|
|
157
|
+
async getPublishedCheckpoints(checkpointNumber, limit) {
|
|
148
158
|
const checkpoints = await this.store.getRangeOfCheckpoints(checkpointNumber, limit);
|
|
149
159
|
const blocks = (await Promise.all(checkpoints.map((ch)=>this.store.getBlocksForCheckpoint(ch.checkpointNumber)))).filter(isDefined);
|
|
150
160
|
const fullCheckpoints = [];
|
|
@@ -160,7 +170,7 @@ import { getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
|
160
170
|
getBlocksForSlot(slotNumber) {
|
|
161
171
|
return this.store.getBlocksForSlot(slotNumber);
|
|
162
172
|
}
|
|
163
|
-
async
|
|
173
|
+
async getBlocksForEpoch(epochNumber) {
|
|
164
174
|
if (!this.l1Constants) {
|
|
165
175
|
throw new Error('L1 constants not set');
|
|
166
176
|
}
|
|
@@ -175,9 +185,9 @@ import { getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
|
175
185
|
// push the blocks on backwards
|
|
176
186
|
const endBlock = checkpoint.startBlock + checkpoint.numBlocks - 1;
|
|
177
187
|
for(let i = endBlock; i >= checkpoint.startBlock; i--){
|
|
178
|
-
const
|
|
179
|
-
if (
|
|
180
|
-
blocks.push(
|
|
188
|
+
const block = await this.getBlock(BlockNumber(i));
|
|
189
|
+
if (block) {
|
|
190
|
+
blocks.push(block);
|
|
181
191
|
}
|
|
182
192
|
}
|
|
183
193
|
}
|
|
@@ -185,7 +195,7 @@ import { getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
|
185
195
|
}
|
|
186
196
|
return blocks.reverse();
|
|
187
197
|
}
|
|
188
|
-
async
|
|
198
|
+
async getBlockHeadersForEpoch(epochNumber) {
|
|
189
199
|
if (!this.l1Constants) {
|
|
190
200
|
throw new Error('L1 constants not set');
|
|
191
201
|
}
|
|
@@ -223,13 +233,29 @@ import { getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
|
223
233
|
while(checkpointData && slot(checkpointData) >= start){
|
|
224
234
|
if (slot(checkpointData) <= end) {
|
|
225
235
|
// push the checkpoints on backwards
|
|
226
|
-
const [checkpoint] = await this.
|
|
236
|
+
const [checkpoint] = await this.getPublishedCheckpoints(checkpointData.checkpointNumber, 1);
|
|
227
237
|
checkpoints.push(checkpoint.checkpoint);
|
|
228
238
|
}
|
|
229
239
|
checkpointData = await this.store.getCheckpointData(CheckpointNumber(checkpointData.checkpointNumber - 1));
|
|
230
240
|
}
|
|
231
241
|
return checkpoints.reverse();
|
|
232
242
|
}
|
|
243
|
+
async getPublishedBlocks(from, limit, proven) {
|
|
244
|
+
const checkpoints = await this.store.getRangeOfCheckpoints(CheckpointNumber(from), limit);
|
|
245
|
+
const provenCheckpointNumber = await this.store.getProvenCheckpointNumber();
|
|
246
|
+
const blocks = (await Promise.all(checkpoints.map((ch)=>this.store.getBlocksForCheckpoint(ch.checkpointNumber)))).filter(isDefined);
|
|
247
|
+
const publishedBlocks = [];
|
|
248
|
+
for(let i = 0; i < checkpoints.length; i++){
|
|
249
|
+
const blockForCheckpoint = blocks[i][0];
|
|
250
|
+
const checkpoint = checkpoints[i];
|
|
251
|
+
if (checkpoint.checkpointNumber > provenCheckpointNumber && proven === true) {
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
const publishedBlock = new CheckpointedL2Block(checkpoint.checkpointNumber, blockForCheckpoint, checkpoint.l1, checkpoint.attestations.map((x)=>CommitteeAttestation.fromBuffer(x)));
|
|
255
|
+
publishedBlocks.push(publishedBlock);
|
|
256
|
+
}
|
|
257
|
+
return publishedBlocks;
|
|
258
|
+
}
|
|
233
259
|
async getBlock(number) {
|
|
234
260
|
// If the number provided is -ve, then return the latest block.
|
|
235
261
|
if (number < 0) {
|
|
@@ -240,20 +266,25 @@ import { getSlotRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
|
240
266
|
}
|
|
241
267
|
return this.store.getBlock(number);
|
|
242
268
|
}
|
|
243
|
-
getBlocks(from, limit) {
|
|
244
|
-
|
|
269
|
+
async getBlocks(from, limit, proven) {
|
|
270
|
+
const blocks = await this.store.getBlocks(from, limit);
|
|
271
|
+
if (proven === true) {
|
|
272
|
+
const provenBlockNumber = await this.store.getProvenBlockNumber();
|
|
273
|
+
return blocks.filter((b)=>b.number <= provenBlockNumber);
|
|
274
|
+
}
|
|
275
|
+
return blocks;
|
|
245
276
|
}
|
|
246
|
-
|
|
277
|
+
getPublishedBlockByHash(blockHash) {
|
|
247
278
|
return this.store.getCheckpointedBlockByHash(blockHash);
|
|
248
279
|
}
|
|
249
|
-
|
|
280
|
+
getPublishedBlockByArchive(archive) {
|
|
250
281
|
return this.store.getCheckpointedBlockByArchive(archive);
|
|
251
282
|
}
|
|
252
|
-
async
|
|
283
|
+
async getL2BlockNewByHash(blockHash) {
|
|
253
284
|
const checkpointedBlock = await this.store.getCheckpointedBlockByHash(blockHash);
|
|
254
285
|
return checkpointedBlock?.block;
|
|
255
286
|
}
|
|
256
|
-
async
|
|
287
|
+
async getL2BlockNewByArchive(archive) {
|
|
257
288
|
const checkpointedBlock = await this.store.getCheckpointedBlockByArchive(archive);
|
|
258
289
|
return checkpointedBlock?.block;
|
|
259
290
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import type {
|
|
1
|
+
import { BlockNumber, type CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { L2BlockNew, ValidateCheckpointResult } from '@aztec/stdlib/block';
|
|
3
3
|
import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
4
4
|
import type { KVArchiverDataStore } from '../store/kv_archiver_store.js';
|
|
5
5
|
/** Result of adding checkpoints with information about any pruned blocks. */
|
|
6
6
|
type ReconcileCheckpointsResult = {
|
|
7
7
|
/** Blocks that were pruned due to conflict with L1 checkpoints. */
|
|
8
|
-
prunedBlocks:
|
|
8
|
+
prunedBlocks: L2BlockNew[] | undefined;
|
|
9
9
|
/** Last block number that was already inserted locally, or undefined if none. */
|
|
10
10
|
lastAlreadyInsertedBlockNumber: BlockNumber | undefined;
|
|
11
11
|
};
|
|
@@ -15,19 +15,18 @@ export declare class ArchiverDataStoreUpdater {
|
|
|
15
15
|
private readonly log;
|
|
16
16
|
constructor(store: KVArchiverDataStore);
|
|
17
17
|
/**
|
|
18
|
-
* Adds
|
|
19
|
-
* These are uncheckpointed blocks that have been proposed by the sequencer but not yet included in a checkpoint on L1.
|
|
18
|
+
* Adds blocks to the store with contract class/instance extraction from logs.
|
|
20
19
|
* Extracts ContractClassPublished, ContractInstancePublished, ContractInstanceUpdated events,
|
|
21
20
|
* and individually broadcasted functions from the block logs.
|
|
22
21
|
*
|
|
23
|
-
* @param blocks - The
|
|
22
|
+
* @param blocks - The L2 blocks to add.
|
|
24
23
|
* @param pendingChainValidationStatus - Optional validation status to set.
|
|
25
24
|
* @returns True if the operation is successful.
|
|
26
25
|
*/
|
|
27
|
-
|
|
26
|
+
addBlocks(blocks: L2BlockNew[], pendingChainValidationStatus?: ValidateCheckpointResult): Promise<boolean>;
|
|
28
27
|
/**
|
|
29
28
|
* Reconciles local blocks with incoming checkpoints from L1.
|
|
30
|
-
* Adds
|
|
29
|
+
* Adds checkpoints to the store with contract class/instance extraction from logs.
|
|
31
30
|
* Prunes any local blocks that conflict with checkpoint data (by comparing archive roots).
|
|
32
31
|
* Extracts ContractClassPublished, ContractInstancePublished, ContractInstanceUpdated events,
|
|
33
32
|
* and individually broadcasted functions from the checkpoint block logs.
|
|
@@ -36,38 +35,35 @@ export declare class ArchiverDataStoreUpdater {
|
|
|
36
35
|
* @param pendingChainValidationStatus - Optional validation status to set.
|
|
37
36
|
* @returns Result with information about any pruned blocks.
|
|
38
37
|
*/
|
|
39
|
-
|
|
38
|
+
setNewCheckpointData(checkpoints: PublishedCheckpoint[], pendingChainValidationStatus?: ValidateCheckpointResult): Promise<ReconcileCheckpointsResult>;
|
|
40
39
|
private pruneMismatchingLocalBlocks;
|
|
41
40
|
/**
|
|
42
|
-
* Removes all
|
|
41
|
+
* Removes all blocks strictly after the specified block number and cleans up associated contract data.
|
|
43
42
|
* This handles removal of provisionally added blocks along with their contract classes/instances.
|
|
44
|
-
* Verifies that each block being removed is not part of a stored checkpoint.
|
|
45
43
|
*
|
|
46
44
|
* @param blockNumber - Remove all blocks with number greater than this.
|
|
47
45
|
* @returns The removed blocks.
|
|
48
|
-
* @throws Error if any block to be removed is checkpointed.
|
|
49
46
|
*/
|
|
50
|
-
|
|
51
|
-
private removeBlocksAfter;
|
|
47
|
+
removeBlocksAfter(blockNumber: BlockNumber): Promise<L2BlockNew[]>;
|
|
52
48
|
/**
|
|
53
|
-
*
|
|
49
|
+
* Unwinds checkpoints from the store with reverse contract extraction.
|
|
54
50
|
* Deletes ContractClassPublished, ContractInstancePublished, ContractInstanceUpdated data
|
|
55
|
-
* that was stored for the
|
|
56
|
-
* and uncheckpointed) after the last block of the given checkpoint.
|
|
51
|
+
* that was stored for the unwound checkpoints.
|
|
57
52
|
*
|
|
58
|
-
* @param
|
|
53
|
+
* @param from - The checkpoint number to unwind from (must be the current tip).
|
|
54
|
+
* @param checkpointsToUnwind - The number of checkpoints to unwind.
|
|
59
55
|
* @returns True if the operation is successful.
|
|
60
56
|
*/
|
|
61
|
-
|
|
57
|
+
unwindCheckpoints(from: CheckpointNumber, checkpointsToUnwind: number): Promise<boolean>;
|
|
62
58
|
/** Extracts and stores contract data from a single block. */
|
|
63
|
-
private
|
|
59
|
+
private addBlockDataToDB;
|
|
64
60
|
/** Removes contract data associated with a block. */
|
|
65
|
-
private
|
|
66
|
-
private
|
|
61
|
+
private removeBlockDataFromDB;
|
|
62
|
+
private editContractBlockData;
|
|
67
63
|
private updatePublishedContractClasses;
|
|
68
64
|
private updateDeployedContractInstances;
|
|
69
65
|
private updateUpdatedContractInstances;
|
|
70
66
|
private storeBroadcastedIndividualFunctions;
|
|
71
67
|
}
|
|
72
68
|
export {};
|
|
73
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
69
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0YV9zdG9yZV91cGRhdGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbW9kdWxlcy9kYXRhX3N0b3JlX3VwZGF0ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBRSxLQUFLLGdCQUFnQixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFZckYsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLHdCQUF3QixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDaEYsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQWFwRSxPQUFPLEtBQUssRUFBRSxtQkFBbUIsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBUXpFLDZFQUE2RTtBQUM3RSxLQUFLLDBCQUEwQixHQUFHO0lBQ2hDLG1FQUFtRTtJQUNuRSxZQUFZLEVBQUUsVUFBVSxFQUFFLEdBQUcsU0FBUyxDQUFDO0lBQ3ZDLGlGQUFpRjtJQUNqRiw4QkFBOEIsRUFBRSxXQUFXLEdBQUcsU0FBUyxDQUFDO0NBQ3pELENBQUM7QUFFRixrRUFBa0U7QUFDbEUscUJBQWEsd0JBQXdCO0lBR3ZCLE9BQU8sQ0FBQyxLQUFLO0lBRnpCLE9BQU8sQ0FBQyxRQUFRLENBQUMsR0FBRyxDQUEwQztJQUU5RCxZQUFvQixLQUFLLEVBQUUsbUJBQW1CLEVBQUk7SUFFbEQ7Ozs7Ozs7O09BUUc7SUFDSSxTQUFTLENBQUMsTUFBTSxFQUFFLFVBQVUsRUFBRSxFQUFFLDRCQUE0QixDQUFDLEVBQUUsd0JBQXdCLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQWVoSDtJQUVEOzs7Ozs7Ozs7O09BVUc7SUFDSSxvQkFBb0IsQ0FDekIsV0FBVyxFQUFFLG1CQUFtQixFQUFFLEVBQ2xDLDRCQUE0QixDQUFDLEVBQUUsd0JBQXdCLEdBQ3RELE9BQU8sQ0FBQywwQkFBMEIsQ0FBQyxDQXVCckM7WUFRYSwyQkFBMkI7SUFtRXpDOzs7Ozs7T0FNRztJQUNJLGlCQUFpQixDQUFDLFdBQVcsRUFBRSxXQUFXLEdBQUcsT0FBTyxDQUFDLFVBQVUsRUFBRSxDQUFDLENBYXhFO0lBRUQ7Ozs7Ozs7O09BUUc7SUFDVSxpQkFBaUIsQ0FBQyxJQUFJLEVBQUUsZ0JBQWdCLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0E4QnBHO0lBRUQsNkRBQTZEO0lBQzdELE9BQU8sQ0FBQyxnQkFBZ0I7SUFJeEIscURBQXFEO0lBQ3JELE9BQU8sQ0FBQyxxQkFBcUI7WUFLZixxQkFBcUI7WUFvQnJCLDhCQUE4QjtZQTRCOUIsK0JBQStCO1lBeUIvQiw4QkFBOEI7WUE2QjlCLG1DQUFtQztDQXdEbEQifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data_store_updater.d.ts","sourceRoot":"","sources":["../../src/modules/data_store_updater.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"data_store_updater.d.ts","sourceRoot":"","sources":["../../src/modules/data_store_updater.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAYr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 'lodash.groupby';
|
|
|
18
18
|
this.log = createLogger('archiver:store_updater');
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* Adds
|
|
22
|
-
* These are uncheckpointed blocks that have been proposed by the sequencer but not yet included in a checkpoint on L1.
|
|
21
|
+
* Adds blocks to the store with contract class/instance extraction from logs.
|
|
23
22
|
* Extracts ContractClassPublished, ContractInstancePublished, ContractInstanceUpdated events,
|
|
24
23
|
* and individually broadcasted functions from the block logs.
|
|
25
24
|
*
|
|
26
|
-
* @param blocks - The
|
|
25
|
+
* @param blocks - The L2 blocks to add.
|
|
27
26
|
* @param pendingChainValidationStatus - Optional validation status to set.
|
|
28
27
|
* @returns True if the operation is successful.
|
|
29
|
-
*/
|
|
28
|
+
*/ addBlocks(blocks, pendingChainValidationStatus) {
|
|
30
29
|
return this.store.transactionAsync(async ()=>{
|
|
31
|
-
await this.store.
|
|
30
|
+
await this.store.addBlocks(blocks);
|
|
32
31
|
const opResults = await Promise.all([
|
|
33
32
|
// Update the pending chain validation status if provided
|
|
34
33
|
pendingChainValidationStatus && this.store.setPendingChainValidationStatus(pendingChainValidationStatus),
|
|
35
34
|
// Add any logs emitted during the retrieved blocks
|
|
36
35
|
this.store.addLogs(blocks),
|
|
37
36
|
// Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
|
|
38
|
-
...blocks.map((block)=>this.
|
|
37
|
+
...blocks.map((block)=>this.addBlockDataToDB(block))
|
|
39
38
|
]);
|
|
40
39
|
return opResults.every(Boolean);
|
|
41
40
|
});
|
|
42
41
|
}
|
|
43
42
|
/**
|
|
44
43
|
* Reconciles local blocks with incoming checkpoints from L1.
|
|
45
|
-
* Adds
|
|
44
|
+
* Adds checkpoints to the store with contract class/instance extraction from logs.
|
|
46
45
|
* Prunes any local blocks that conflict with checkpoint data (by comparing archive roots).
|
|
47
46
|
* Extracts ContractClassPublished, ContractInstancePublished, ContractInstanceUpdated events,
|
|
48
47
|
* and individually broadcasted functions from the checkpoint block logs.
|
|
@@ -50,12 +49,12 @@ import groupBy from 'lodash.groupby';
|
|
|
50
49
|
* @param checkpoints - The published checkpoints to add.
|
|
51
50
|
* @param pendingChainValidationStatus - Optional validation status to set.
|
|
52
51
|
* @returns Result with information about any pruned blocks.
|
|
53
|
-
*/
|
|
52
|
+
*/ setNewCheckpointData(checkpoints, pendingChainValidationStatus) {
|
|
54
53
|
return this.store.transactionAsync(async ()=>{
|
|
55
54
|
// Before adding checkpoints, check for conflicts with local blocks if any
|
|
56
55
|
const { prunedBlocks, lastAlreadyInsertedBlockNumber } = await this.pruneMismatchingLocalBlocks(checkpoints);
|
|
57
56
|
await this.store.addCheckpoints(checkpoints);
|
|
58
|
-
// Filter out blocks that were already inserted via
|
|
57
|
+
// Filter out blocks that were already inserted via addBlocks() to avoid duplicating logs/contract data
|
|
59
58
|
const newBlocks = checkpoints.flatMap((ch)=>ch.checkpoint.blocks).filter((b)=>lastAlreadyInsertedBlockNumber === undefined || b.number > lastAlreadyInsertedBlockNumber);
|
|
60
59
|
await Promise.all([
|
|
61
60
|
// Update the pending chain validation status if provided
|
|
@@ -63,7 +62,7 @@ import groupBy from 'lodash.groupby';
|
|
|
63
62
|
// Add any logs emitted during the retrieved blocks
|
|
64
63
|
this.store.addLogs(newBlocks),
|
|
65
64
|
// Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
|
|
66
|
-
...newBlocks.map((block)=>this.
|
|
65
|
+
...newBlocks.map((block)=>this.addBlockDataToDB(block))
|
|
67
66
|
]);
|
|
68
67
|
return {
|
|
69
68
|
prunedBlocks,
|
|
@@ -140,64 +139,67 @@ import groupBy from 'lodash.groupby';
|
|
|
140
139
|
};
|
|
141
140
|
}
|
|
142
141
|
/**
|
|
143
|
-
* Removes all
|
|
142
|
+
* Removes all blocks strictly after the specified block number and cleans up associated contract data.
|
|
144
143
|
* This handles removal of provisionally added blocks along with their contract classes/instances.
|
|
145
|
-
* Verifies that each block being removed is not part of a stored checkpoint.
|
|
146
144
|
*
|
|
147
145
|
* @param blockNumber - Remove all blocks with number greater than this.
|
|
148
146
|
* @returns The removed blocks.
|
|
149
|
-
|
|
150
|
-
*/ removeUncheckpointedBlocksAfter(blockNumber) {
|
|
147
|
+
*/ removeBlocksAfter(blockNumber) {
|
|
151
148
|
return this.store.transactionAsync(async ()=>{
|
|
152
|
-
//
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
149
|
+
// First get the blocks to be removed so we can clean up contract data
|
|
150
|
+
const removedBlocks = await this.store.removeBlocksAfter(blockNumber);
|
|
151
|
+
// Clean up contract data and logs for the removed blocks
|
|
152
|
+
await Promise.all([
|
|
153
|
+
this.store.deleteLogs(removedBlocks),
|
|
154
|
+
...removedBlocks.map((block)=>this.removeBlockDataFromDB(block))
|
|
155
|
+
]);
|
|
156
|
+
return removedBlocks;
|
|
158
157
|
});
|
|
159
158
|
}
|
|
160
159
|
/**
|
|
161
|
-
*
|
|
162
|
-
* Does not remove their checkpoints.
|
|
163
|
-
*/ async removeBlocksAfter(blockNumber) {
|
|
164
|
-
// First get the blocks to be removed so we can clean up contract data
|
|
165
|
-
const removedBlocks = await this.store.removeBlocksAfter(blockNumber);
|
|
166
|
-
// Clean up contract data and logs for the removed blocks
|
|
167
|
-
await Promise.all([
|
|
168
|
-
this.store.deleteLogs(removedBlocks),
|
|
169
|
-
...removedBlocks.map((block)=>this.removeContractDataFromDb(block))
|
|
170
|
-
]);
|
|
171
|
-
return removedBlocks;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Removes all checkpoints after the given checkpoint number.
|
|
160
|
+
* Unwinds checkpoints from the store with reverse contract extraction.
|
|
175
161
|
* Deletes ContractClassPublished, ContractInstancePublished, ContractInstanceUpdated data
|
|
176
|
-
* that was stored for the
|
|
177
|
-
* and uncheckpointed) after the last block of the given checkpoint.
|
|
162
|
+
* that was stored for the unwound checkpoints.
|
|
178
163
|
*
|
|
179
|
-
* @param
|
|
164
|
+
* @param from - The checkpoint number to unwind from (must be the current tip).
|
|
165
|
+
* @param checkpointsToUnwind - The number of checkpoints to unwind.
|
|
180
166
|
* @returns True if the operation is successful.
|
|
181
|
-
*/ async
|
|
182
|
-
|
|
167
|
+
*/ async unwindCheckpoints(from, checkpointsToUnwind) {
|
|
168
|
+
if (checkpointsToUnwind <= 0) {
|
|
169
|
+
throw new Error(`Cannot unwind ${checkpointsToUnwind} blocks`);
|
|
170
|
+
}
|
|
171
|
+
const last = await this.store.getSynchedCheckpointNumber();
|
|
172
|
+
if (from != last) {
|
|
173
|
+
throw new Error(`Cannot unwind checkpoints from checkpoint ${from} when the last checkpoint is ${last}`);
|
|
174
|
+
}
|
|
175
|
+
const blocks = [];
|
|
176
|
+
const lastCheckpointNumber = from + checkpointsToUnwind - 1;
|
|
177
|
+
for(let checkpointNumber = from; checkpointNumber <= lastCheckpointNumber; checkpointNumber++){
|
|
178
|
+
const blocksForCheckpoint = await this.store.getBlocksForCheckpoint(checkpointNumber);
|
|
179
|
+
if (!blocksForCheckpoint) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
blocks.push(...blocksForCheckpoint);
|
|
183
|
+
}
|
|
183
184
|
const opResults = await Promise.all([
|
|
184
185
|
// Prune rolls back to the last proven block, which is by definition valid
|
|
185
186
|
this.store.setPendingChainValidationStatus({
|
|
186
187
|
valid: true
|
|
187
188
|
}),
|
|
188
|
-
// Remove contract data for all blocks being
|
|
189
|
-
...
|
|
190
|
-
this.store.deleteLogs(
|
|
189
|
+
// Remove contract data for all blocks being unwound
|
|
190
|
+
...blocks.map((block)=>this.removeBlockDataFromDB(block)),
|
|
191
|
+
this.store.deleteLogs(blocks),
|
|
192
|
+
this.store.unwindCheckpoints(from, checkpointsToUnwind)
|
|
191
193
|
]);
|
|
192
194
|
return opResults.every(Boolean);
|
|
193
195
|
}
|
|
194
|
-
/** Extracts and stores contract data from a single block. */
|
|
195
|
-
return this.
|
|
196
|
+
/** Extracts and stores contract data from a single block. */ addBlockDataToDB(block) {
|
|
197
|
+
return this.editContractBlockData(block, 0);
|
|
196
198
|
}
|
|
197
|
-
/** Removes contract data associated with a block. */
|
|
198
|
-
return this.
|
|
199
|
+
/** Removes contract data associated with a block. */ removeBlockDataFromDB(block) {
|
|
200
|
+
return this.editContractBlockData(block, 1);
|
|
199
201
|
}
|
|
200
|
-
/** Adds or remove contract data associated with a block. */ async
|
|
202
|
+
/** Adds or remove contract data associated with a block. */ async editContractBlockData(block, operation) {
|
|
201
203
|
const contractClassLogs = block.body.txEffects.flatMap((txEffect)=>txEffect.contractClassLogs);
|
|
202
204
|
const privateLogs = block.body.txEffects.flatMap((txEffect)=>txEffect.privateLogs);
|
|
203
205
|
const publicLogs = block.body.txEffects.flatMap((txEffect)=>txEffect.publicLogs);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { L2BlockNew } from '@aztec/stdlib/block';
|
|
2
2
|
import { type LmdbStatsCallback, type TelemetryClient, type Tracer } from '@aztec/telemetry-client';
|
|
3
3
|
export declare class ArchiverInstrumentation {
|
|
4
4
|
private telemetry;
|
|
@@ -22,7 +22,7 @@ export declare class ArchiverInstrumentation {
|
|
|
22
22
|
private constructor();
|
|
23
23
|
static new(telemetry: TelemetryClient, lmdbStats?: LmdbStatsCallback): Promise<ArchiverInstrumentation>;
|
|
24
24
|
isEnabled(): boolean;
|
|
25
|
-
processNewBlocks(syncTimePerBlock: number, blocks:
|
|
25
|
+
processNewBlocks(syncTimePerBlock: number, blocks: L2BlockNew[]): void;
|
|
26
26
|
processNewMessages(count: number, syncPerMessageMs: number): void;
|
|
27
27
|
processPrune(duration: number): void;
|
|
28
28
|
updateLastProvenBlock(blockNumber: number): void;
|
|
@@ -34,4 +34,4 @@ export declare class ArchiverInstrumentation {
|
|
|
34
34
|
updateL1BlockHeight(blockNumber: bigint): void;
|
|
35
35
|
recordBlockProposalTxTarget(target: string, usedTrace: boolean): void;
|
|
36
36
|
}
|
|
37
|
-
//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7SUFFbEQsT0FBTyxDQUFDLEdBQUcsQ0FBNEM7SUFFdkQsT0FBTyxlQTBDTjtJQUVELE9BQW9CLEdBQUcsQ0FBQyxTQUFTLEVBQUUsZUFBZSxFQUFFLFNBQVMsQ0FBQyxFQUFFLGlCQUFpQixvQ0FVaEY7SUFFTSxTQUFTLElBQUksT0FBTyxDQUUxQjtJQUVNLGdCQUFnQixDQUFDLGdCQUFnQixFQUFFLE1BQU0sRUFBRSxNQUFNLEVBQUUsVUFBVSxFQUFFLFFBVXJFO0lBRU0sa0JBQWtCLENBQUMsS0FBSyxFQUFFLE1BQU0sRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLFFBTWhFO0lBRU0sWUFBWSxDQUFDLFFBQVEsRUFBRSxNQUFNLFFBR25DO0lBRU0scUJBQXFCLENBQUMsV0FBVyxFQUFFLE1BQU0sUUFFL0M7SUFFTSxxQkFBcUIsQ0FBQyxJQUFJLEVBQUU7UUFBRSxRQUFRLEVBQUUsTUFBTSxDQUFDO1FBQUMsYUFBYSxFQUFFLE1BQU0sQ0FBQztRQUFDLEtBQUssRUFBRSxNQUFNLENBQUE7S0FBRSxFQUFFLFFBVzlGO0lBRU0sbUJBQW1CLENBQUMsV0FBVyxFQUFFLE1BQU0sUUFFN0M7SUFFTSwyQkFBMkIsQ0FBQyxNQUFNLEVBQUUsTUFBTSxFQUFFLFNBQVMsRUFBRSxPQUFPLFFBS3BFO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/modules/instrumentation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/modules/instrumentation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAKL,KAAK,iBAAiB,EAEtB,KAAK,eAAe,EACpB,KAAK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AAE,MAAM,EAAE,SAAS,EAAE,OAAO,QAKpE;CACF"}
|
|
@@ -591,7 +591,7 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
591
591
|
firstUncheckpointedBlockHeader: firstUncheckpointedBlockHeader.toInspect(),
|
|
592
592
|
slotAtNextL1Block
|
|
593
593
|
});
|
|
594
|
-
const prunedBlocks = await this.updater.
|
|
594
|
+
const prunedBlocks = await this.updater.removeBlocksAfter(lastCheckpointedBlockNumber);
|
|
595
595
|
if (prunedBlocks.length > 0) {
|
|
596
596
|
this.events.emit(L2BlockSourceEvents.L2PruneUncheckpointed, {
|
|
597
597
|
type: L2BlockSourceEvents.L2PruneUncheckpointed,
|
|
@@ -642,8 +642,8 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
642
642
|
blocks: newBlocks
|
|
643
643
|
});
|
|
644
644
|
this.log.debug(`L2 prune from ${provenCheckpointNumber + 1} to ${localPendingCheckpointNumber} will occur on next checkpoint submission.`);
|
|
645
|
-
await this.updater.
|
|
646
|
-
this.log.warn(`
|
|
645
|
+
await this.updater.unwindCheckpoints(localPendingCheckpointNumber, checkpointsToUnwind);
|
|
646
|
+
this.log.warn(`Unwound ${count(checkpointsToUnwind, 'checkpoint')} from checkpoint ${localPendingCheckpointNumber} ` + `to ${provenCheckpointNumber} due to predicted reorg at L1 block ${currentL1BlockNumber}. ` + `Updated latest checkpoint is ${await this.store.getSynchedCheckpointNumber()}.`);
|
|
647
647
|
this.instrumentation.processPrune(timer.ms());
|
|
648
648
|
// TODO(palla/reorg): Do we need to set the block synched L1 block number here?
|
|
649
649
|
// Seems like the next iteration should handle this.
|
|
@@ -931,9 +931,9 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
931
931
|
}
|
|
932
932
|
tipAfterUnwind--;
|
|
933
933
|
}
|
|
934
|
-
const
|
|
935
|
-
await this.updater.
|
|
936
|
-
this.log.warn(`
|
|
934
|
+
const checkpointsToUnwind = localPendingCheckpointNumber - tipAfterUnwind;
|
|
935
|
+
await this.updater.unwindCheckpoints(localPendingCheckpointNumber, checkpointsToUnwind);
|
|
936
|
+
this.log.warn(`Unwound ${count(checkpointsToUnwind, 'checkpoint')} from checkpoint ${localPendingCheckpointNumber} ` + `due to mismatched checkpoint hashes at L1 block ${currentL1BlockNumber}. ` + `Updated L2 latest checkpoint is ${await this.store.getSynchedCheckpointNumber()}.`);
|
|
937
937
|
}
|
|
938
938
|
}
|
|
939
939
|
// Retrieve checkpoints in batches. Each batch is estimated to accommodate up to 'blockBatchSize' L1 blocks,
|
|
@@ -1011,7 +1011,7 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
1011
1011
|
}
|
|
1012
1012
|
try {
|
|
1013
1013
|
const updatedValidationResult = rollupStatus.validationResult === initialValidationResult ? undefined : rollupStatus.validationResult;
|
|
1014
|
-
const [processDuration, result] = await elapsed(()=>execInSpan(this.tracer, 'Archiver.
|
|
1014
|
+
const [processDuration, result] = await elapsed(()=>execInSpan(this.tracer, 'Archiver.setCheckpointData', ()=>this.updater.setNewCheckpointData(validCheckpoints, updatedValidationResult)));
|
|
1015
1015
|
this.instrumentation.processNewBlocks(processDuration / validCheckpoints.length, validCheckpoints.flatMap((c)=>c.checkpoint.blocks));
|
|
1016
1016
|
// If blocks were pruned due to conflict with L1 checkpoints, emit event
|
|
1017
1017
|
if (result.prunedBlocks && result.prunedBlocks.length > 0) {
|