@aztec/archiver 0.0.1-commit.a072138 → 0.0.1-commit.a89ec08
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 +7 -4
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +73 -110
- package/dest/errors.d.ts +7 -9
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +9 -14
- package/dest/factory.d.ts +3 -4
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +31 -24
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/l1/bin/retrieve-calldata.js +36 -33
- package/dest/l1/calldata_retriever.d.ts +73 -50
- package/dest/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/l1/calldata_retriever.js +190 -259
- package/dest/l1/data_retrieval.d.ts +4 -7
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +9 -13
- package/dest/l1/spire_proposer.d.ts +5 -5
- package/dest/l1/spire_proposer.d.ts.map +1 -1
- package/dest/l1/spire_proposer.js +9 -17
- package/dest/modules/data_source_base.d.ts +10 -5
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +29 -73
- package/dest/modules/data_store_updater.d.ts +22 -7
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +113 -40
- package/dest/modules/instrumentation.d.ts +4 -2
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +9 -2
- package/dest/modules/l1_synchronizer.d.ts +5 -8
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +40 -10
- package/dest/store/block_store.d.ts +30 -26
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +180 -83
- package/dest/store/contract_class_store.d.ts +1 -1
- package/dest/store/contract_class_store.d.ts.map +1 -1
- package/dest/store/contract_class_store.js +6 -2
- package/dest/store/contract_instance_store.d.ts +1 -1
- package/dest/store/contract_instance_store.d.ts.map +1 -1
- package/dest/store/contract_instance_store.js +6 -2
- package/dest/store/kv_archiver_store.d.ts +37 -15
- package/dest/store/kv_archiver_store.d.ts.map +1 -1
- package/dest/store/kv_archiver_store.js +42 -13
- package/dest/store/l2_tips_cache.d.ts +19 -0
- package/dest/store/l2_tips_cache.d.ts.map +1 -0
- package/dest/store/l2_tips_cache.js +89 -0
- package/dest/store/log_store.d.ts +1 -1
- package/dest/store/log_store.d.ts.map +1 -1
- package/dest/store/log_store.js +103 -45
- package/dest/store/message_store.js +1 -1
- package/dest/test/fake_l1_state.d.ts +20 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +97 -20
- package/dest/test/mock_archiver.d.ts +1 -1
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +3 -2
- package/dest/test/mock_l2_block_source.d.ts +21 -5
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +132 -86
- package/dest/test/mock_structs.d.ts +4 -1
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +13 -1
- package/dest/test/noop_l1_archiver.d.ts +4 -1
- package/dest/test/noop_l1_archiver.d.ts.map +1 -1
- package/dest/test/noop_l1_archiver.js +5 -1
- package/package.json +13 -13
- package/src/archiver.ts +88 -130
- package/src/errors.ts +10 -24
- package/src/factory.ts +45 -21
- package/src/index.ts +1 -0
- package/src/l1/README.md +25 -68
- package/src/l1/bin/retrieve-calldata.ts +46 -39
- package/src/l1/calldata_retriever.ts +249 -379
- package/src/l1/data_retrieval.ts +6 -16
- package/src/l1/spire_proposer.ts +7 -15
- package/src/modules/data_source_base.ts +56 -95
- package/src/modules/data_store_updater.ts +123 -43
- package/src/modules/instrumentation.ts +9 -2
- package/src/modules/l1_synchronizer.ts +47 -14
- package/src/store/block_store.ts +219 -110
- package/src/store/contract_class_store.ts +7 -3
- package/src/store/contract_instance_store.ts +8 -5
- package/src/store/kv_archiver_store.ts +66 -20
- package/src/store/l2_tips_cache.ts +89 -0
- package/src/store/log_store.ts +159 -43
- package/src/store/message_store.ts +1 -1
- package/src/test/fake_l1_state.ts +125 -21
- package/src/test/mock_archiver.ts +3 -2
- package/src/test/mock_l2_block_source.ts +173 -81
- package/src/test/mock_structs.ts +20 -6
- package/src/test/noop_l1_archiver.ts +7 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { filterAsync } from '@aztec/foundation/collection';
|
|
2
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
5
|
import { ContractClassPublishedEvent, PrivateFunctionBroadcastedEvent, UtilityFunctionBroadcastedEvent } from '@aztec/protocol-contracts/class-registry';
|
|
5
6
|
import { ContractInstancePublishedEvent, ContractInstanceUpdatedEvent } from '@aztec/protocol-contracts/instance-registry';
|
|
6
|
-
import {
|
|
7
|
+
import { validateCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
8
|
+
import { computeContractAddressFromInstance, computeContractClassId, isValidPrivateFunctionMembershipProof, isValidUtilityFunctionMembershipProof } from '@aztec/stdlib/contract';
|
|
7
9
|
import groupBy from 'lodash.groupby';
|
|
8
10
|
/** Operation type for contract data updates. */ var Operation = /*#__PURE__*/ function(Operation) {
|
|
9
11
|
Operation[Operation["Store"] = 0] = "Store";
|
|
@@ -12,33 +14,41 @@ import groupBy from 'lodash.groupby';
|
|
|
12
14
|
}(Operation || {});
|
|
13
15
|
/** Archiver helper module to handle updates to the data store. */ export class ArchiverDataStoreUpdater {
|
|
14
16
|
store;
|
|
17
|
+
l2TipsCache;
|
|
18
|
+
opts;
|
|
15
19
|
log;
|
|
16
|
-
constructor(store){
|
|
20
|
+
constructor(store, l2TipsCache, opts = {}){
|
|
17
21
|
this.store = store;
|
|
22
|
+
this.l2TipsCache = l2TipsCache;
|
|
23
|
+
this.opts = opts;
|
|
18
24
|
this.log = createLogger('archiver:store_updater');
|
|
19
25
|
}
|
|
20
26
|
/**
|
|
21
|
-
* Adds proposed
|
|
22
|
-
*
|
|
27
|
+
* Adds a proposed block to the store with contract class/instance extraction from logs.
|
|
28
|
+
* This is an uncheckpointed block that has been proposed by the sequencer but not yet included in a checkpoint on L1.
|
|
23
29
|
* Extracts ContractClassPublished, ContractInstancePublished, ContractInstanceUpdated events,
|
|
24
30
|
* and individually broadcasted functions from the block logs.
|
|
25
31
|
*
|
|
26
|
-
* @param
|
|
32
|
+
* @param block - The proposed L2 block to add.
|
|
27
33
|
* @param pendingChainValidationStatus - Optional validation status to set.
|
|
28
34
|
* @returns True if the operation is successful.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
await this.store.
|
|
35
|
+
*/ async addProposedBlock(block, pendingChainValidationStatus) {
|
|
36
|
+
const result = await this.store.transactionAsync(async ()=>{
|
|
37
|
+
await this.store.addProposedBlock(block);
|
|
32
38
|
const opResults = await Promise.all([
|
|
33
39
|
// Update the pending chain validation status if provided
|
|
34
40
|
pendingChainValidationStatus && this.store.setPendingChainValidationStatus(pendingChainValidationStatus),
|
|
35
|
-
// Add any logs emitted during the retrieved
|
|
36
|
-
this.store.addLogs(
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
// Add any logs emitted during the retrieved block
|
|
42
|
+
this.store.addLogs([
|
|
43
|
+
block
|
|
44
|
+
]),
|
|
45
|
+
// Unroll all logs emitted during the retrieved block and extract any contract classes and instances from it
|
|
46
|
+
this.addContractDataToDb(block)
|
|
39
47
|
]);
|
|
48
|
+
await this.l2TipsCache?.refresh();
|
|
40
49
|
return opResults.every(Boolean);
|
|
41
50
|
});
|
|
51
|
+
return result;
|
|
42
52
|
}
|
|
43
53
|
/**
|
|
44
54
|
* Reconciles local blocks with incoming checkpoints from L1.
|
|
@@ -50,12 +60,17 @@ import groupBy from 'lodash.groupby';
|
|
|
50
60
|
* @param checkpoints - The published checkpoints to add.
|
|
51
61
|
* @param pendingChainValidationStatus - Optional validation status to set.
|
|
52
62
|
* @returns Result with information about any pruned blocks.
|
|
53
|
-
*/ addCheckpoints(checkpoints, pendingChainValidationStatus) {
|
|
54
|
-
|
|
63
|
+
*/ async addCheckpoints(checkpoints, pendingChainValidationStatus) {
|
|
64
|
+
for (const checkpoint of checkpoints){
|
|
65
|
+
validateCheckpoint(checkpoint.checkpoint, {
|
|
66
|
+
rollupManaLimit: this.opts?.rollupManaLimit
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const result = await this.store.transactionAsync(async ()=>{
|
|
55
70
|
// Before adding checkpoints, check for conflicts with local blocks if any
|
|
56
71
|
const { prunedBlocks, lastAlreadyInsertedBlockNumber } = await this.pruneMismatchingLocalBlocks(checkpoints);
|
|
57
72
|
await this.store.addCheckpoints(checkpoints);
|
|
58
|
-
// Filter out blocks that were already inserted via
|
|
73
|
+
// Filter out blocks that were already inserted via addProposedBlock() to avoid duplicating logs/contract data
|
|
59
74
|
const newBlocks = checkpoints.flatMap((ch)=>ch.checkpoint.blocks).filter((b)=>lastAlreadyInsertedBlockNumber === undefined || b.number > lastAlreadyInsertedBlockNumber);
|
|
60
75
|
await Promise.all([
|
|
61
76
|
// Update the pending chain validation status if provided
|
|
@@ -65,11 +80,13 @@ import groupBy from 'lodash.groupby';
|
|
|
65
80
|
// Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
|
|
66
81
|
...newBlocks.map((block)=>this.addContractDataToDb(block))
|
|
67
82
|
]);
|
|
83
|
+
await this.l2TipsCache?.refresh();
|
|
68
84
|
return {
|
|
69
85
|
prunedBlocks,
|
|
70
86
|
lastAlreadyInsertedBlockNumber
|
|
71
87
|
};
|
|
72
88
|
});
|
|
89
|
+
return result;
|
|
73
90
|
}
|
|
74
91
|
/**
|
|
75
92
|
* Checks for local proposed blocks that do not match the ones to be checkpointed and prunes them.
|
|
@@ -113,7 +130,7 @@ import groupBy from 'lodash.groupby';
|
|
|
113
130
|
this.log.verbose(`Block number ${blockNumber} already inserted and matches checkpoint`, blockInfos);
|
|
114
131
|
lastAlreadyInsertedBlockNumber = blockNumber;
|
|
115
132
|
} else {
|
|
116
|
-
this.log.
|
|
133
|
+
this.log.info(`Conflict detected at block ${blockNumber} between checkpointed and local block`, blockInfos);
|
|
117
134
|
const prunedBlocks = await this.removeBlocksAfter(BlockNumber(blockNumber - 1));
|
|
118
135
|
return {
|
|
119
136
|
prunedBlocks,
|
|
@@ -147,15 +164,18 @@ import groupBy from 'lodash.groupby';
|
|
|
147
164
|
* @param blockNumber - Remove all blocks with number greater than this.
|
|
148
165
|
* @returns The removed blocks.
|
|
149
166
|
* @throws Error if any block to be removed is checkpointed.
|
|
150
|
-
*/ removeUncheckpointedBlocksAfter(blockNumber) {
|
|
151
|
-
|
|
167
|
+
*/ async removeUncheckpointedBlocksAfter(blockNumber) {
|
|
168
|
+
const result = await this.store.transactionAsync(async ()=>{
|
|
152
169
|
// Verify we're only removing uncheckpointed blocks
|
|
153
170
|
const lastCheckpointedBlockNumber = await this.store.getCheckpointedL2BlockNumber();
|
|
154
171
|
if (blockNumber < lastCheckpointedBlockNumber) {
|
|
155
172
|
throw new Error(`Cannot remove blocks after ${blockNumber} because checkpointed blocks exist up to ${lastCheckpointedBlockNumber}`);
|
|
156
173
|
}
|
|
157
|
-
|
|
174
|
+
const result = await this.removeBlocksAfter(blockNumber);
|
|
175
|
+
await this.l2TipsCache?.refresh();
|
|
176
|
+
return result;
|
|
158
177
|
});
|
|
178
|
+
return result;
|
|
159
179
|
}
|
|
160
180
|
/**
|
|
161
181
|
* Removes all blocks strictly after the given block number along with any logs and contract data.
|
|
@@ -179,17 +199,38 @@ import groupBy from 'lodash.groupby';
|
|
|
179
199
|
* @param checkpointNumber - Remove all checkpoints strictly after this one.
|
|
180
200
|
* @returns True if the operation is successful.
|
|
181
201
|
*/ async removeCheckpointsAfter(checkpointNumber) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
202
|
+
return await this.store.transactionAsync(async ()=>{
|
|
203
|
+
const { blocksRemoved = [] } = await this.store.removeCheckpointsAfter(checkpointNumber);
|
|
204
|
+
const opResults = await Promise.all([
|
|
205
|
+
// Prune rolls back to the last proven block, which is by definition valid
|
|
206
|
+
this.store.setPendingChainValidationStatus({
|
|
207
|
+
valid: true
|
|
208
|
+
}),
|
|
209
|
+
// Remove contract data for all blocks being removed
|
|
210
|
+
...blocksRemoved.map((block)=>this.removeContractDataFromDb(block)),
|
|
211
|
+
this.store.deleteLogs(blocksRemoved)
|
|
212
|
+
]);
|
|
213
|
+
await this.l2TipsCache?.refresh();
|
|
214
|
+
return opResults.every(Boolean);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Updates the proven checkpoint number and refreshes the L2 tips cache.
|
|
219
|
+
* @param checkpointNumber - The checkpoint number to set as proven.
|
|
220
|
+
*/ async setProvenCheckpointNumber(checkpointNumber) {
|
|
221
|
+
await this.store.transactionAsync(async ()=>{
|
|
222
|
+
await this.store.setProvenCheckpointNumber(checkpointNumber);
|
|
223
|
+
await this.l2TipsCache?.refresh();
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Updates the finalized checkpoint number and refreshes the L2 tips cache.
|
|
228
|
+
* @param checkpointNumber - The checkpoint number to set as finalized.
|
|
229
|
+
*/ async setFinalizedCheckpointNumber(checkpointNumber) {
|
|
230
|
+
await this.store.transactionAsync(async ()=>{
|
|
231
|
+
await this.store.setFinalizedCheckpointNumber(checkpointNumber);
|
|
232
|
+
await this.l2TipsCache?.refresh();
|
|
233
|
+
});
|
|
193
234
|
}
|
|
194
235
|
/** Extracts and stores contract data from a single block. */ addContractDataToDb(block) {
|
|
195
236
|
return this.updateContractDataOnDb(block, 0);
|
|
@@ -212,23 +253,55 @@ import groupBy from 'lodash.groupby';
|
|
|
212
253
|
* Extracts and stores contract classes out of ContractClassPublished events emitted by the class registry contract.
|
|
213
254
|
*/ async updatePublishedContractClasses(allLogs, blockNum, operation) {
|
|
214
255
|
const contractClassPublishedEvents = allLogs.filter((log)=>ContractClassPublishedEvent.isContractClassPublishedEvent(log)).map((log)=>ContractClassPublishedEvent.fromLog(log));
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
contractClasses.
|
|
218
|
-
|
|
219
|
-
// TODO: Will probably want to create some worker threads to compute these bytecode commitments as they are expensive
|
|
220
|
-
const commitments = await Promise.all(contractClasses.map((c)=>computePublicBytecodeCommitment(c.packedBytecode)));
|
|
221
|
-
return await this.store.addContractClasses(contractClasses, commitments, blockNum);
|
|
222
|
-
} else if (operation == 1) {
|
|
256
|
+
if (operation == 1) {
|
|
257
|
+
const contractClasses = contractClassPublishedEvents.map((e)=>e.toContractClassPublic());
|
|
258
|
+
if (contractClasses.length > 0) {
|
|
259
|
+
contractClasses.forEach((c)=>this.log.verbose(`${Operation[operation]} contract class ${c.id.toString()}`));
|
|
223
260
|
return await this.store.deleteContractClasses(contractClasses, blockNum);
|
|
224
261
|
}
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
// Compute bytecode commitments and validate class IDs in a single pass.
|
|
265
|
+
const contractClasses = [];
|
|
266
|
+
for (const event of contractClassPublishedEvents){
|
|
267
|
+
const contractClass = await event.toContractClassPublicWithBytecodeCommitment();
|
|
268
|
+
const computedClassId = await computeContractClassId({
|
|
269
|
+
artifactHash: contractClass.artifactHash,
|
|
270
|
+
privateFunctionsRoot: contractClass.privateFunctionsRoot,
|
|
271
|
+
publicBytecodeCommitment: contractClass.publicBytecodeCommitment
|
|
272
|
+
});
|
|
273
|
+
if (!computedClassId.equals(contractClass.id)) {
|
|
274
|
+
this.log.warn(`Skipping contract class with mismatched id at block ${blockNum}. Claimed ${contractClass.id}, computed ${computedClassId}`, {
|
|
275
|
+
blockNum,
|
|
276
|
+
contractClassId: event.contractClassId.toString()
|
|
277
|
+
});
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
contractClasses.push(contractClass);
|
|
281
|
+
}
|
|
282
|
+
if (contractClasses.length > 0) {
|
|
283
|
+
contractClasses.forEach((c)=>this.log.verbose(`${Operation[operation]} contract class ${c.id.toString()}`));
|
|
284
|
+
return await this.store.addContractClasses(contractClasses, blockNum);
|
|
225
285
|
}
|
|
226
286
|
return true;
|
|
227
287
|
}
|
|
228
288
|
/**
|
|
229
289
|
* Extracts and stores contract instances out of ContractInstancePublished events emitted by the canonical deployer contract.
|
|
230
290
|
*/ async updateDeployedContractInstances(allLogs, blockNum, operation) {
|
|
231
|
-
const
|
|
291
|
+
const allInstances = allLogs.filter((log)=>ContractInstancePublishedEvent.isContractInstancePublishedEvent(log)).map((log)=>ContractInstancePublishedEvent.fromLog(log)).map((e)=>e.toContractInstance());
|
|
292
|
+
// Verify that each instance's address matches the one derived from its fields if we're adding
|
|
293
|
+
const contractInstances = operation === 1 ? allInstances : await filterAsync(allInstances, async (instance)=>{
|
|
294
|
+
const computedAddress = await computeContractAddressFromInstance(instance);
|
|
295
|
+
if (!computedAddress.equals(instance.address)) {
|
|
296
|
+
this.log.warn(`Found contract instance with mismatched address at block ${blockNum}. Claimed ${instance.address} but computed ${computedAddress}.`, {
|
|
297
|
+
instanceAddress: instance.address.toString(),
|
|
298
|
+
computedAddress: computedAddress.toString(),
|
|
299
|
+
blockNum
|
|
300
|
+
});
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
return true;
|
|
304
|
+
});
|
|
232
305
|
if (contractInstances.length > 0) {
|
|
233
306
|
contractInstances.forEach((c)=>this.log.verbose(`${Operation[operation]} contract instance at ${c.address.toString()}`));
|
|
234
307
|
if (operation == 0) {
|
|
@@ -295,7 +368,7 @@ import groupBy from 'lodash.groupby';
|
|
|
295
368
|
if (validFnCount > 0) {
|
|
296
369
|
this.log.verbose(`Storing ${validFnCount} functions for contract class ${contractClassId.toString()}`);
|
|
297
370
|
}
|
|
298
|
-
|
|
371
|
+
await this.store.addFunctions(contractClassId, validPrivateFns, validUtilityFns);
|
|
299
372
|
}
|
|
300
373
|
return true;
|
|
301
374
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { L2Block } from '@aztec/stdlib/block';
|
|
2
|
+
import type { CheckpointData } from '@aztec/stdlib/checkpoint';
|
|
2
3
|
import { type LmdbStatsCallback, type TelemetryClient, type Tracer } from '@aztec/telemetry-client';
|
|
3
4
|
export declare class ArchiverInstrumentation {
|
|
4
5
|
private telemetry;
|
|
5
6
|
readonly tracer: Tracer;
|
|
6
7
|
private blockHeight;
|
|
8
|
+
private checkpointHeight;
|
|
7
9
|
private txCount;
|
|
8
10
|
private l1BlockHeight;
|
|
9
11
|
private proofsSubmittedDelay;
|
|
@@ -25,7 +27,7 @@ export declare class ArchiverInstrumentation {
|
|
|
25
27
|
processNewBlocks(syncTimePerBlock: number, blocks: L2Block[]): void;
|
|
26
28
|
processNewMessages(count: number, syncPerMessageMs: number): void;
|
|
27
29
|
processPrune(duration: number): void;
|
|
28
|
-
|
|
30
|
+
updateLastProvenCheckpoint(checkpoint: CheckpointData): void;
|
|
29
31
|
processProofsVerified(logs: {
|
|
30
32
|
proverId: string;
|
|
31
33
|
l2BlockNumber: bigint;
|
|
@@ -34,4 +36,4 @@ export declare class ArchiverInstrumentation {
|
|
|
34
36
|
updateL1BlockHeight(blockNumber: bigint): void;
|
|
35
37
|
recordBlockProposalTxTarget(target: string, usedTrace: boolean): void;
|
|
36
38
|
}
|
|
37
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
39
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5zdHJ1bWVudGF0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcm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UFFRCxPQUFvQixHQUFHLENBQUMsU0FBUyxFQUFFLGVBQWUsRUFBRSxTQUFTLENBQUMsRUFBRSxpQkFBaUIsb0NBTWhGO0lBRU0sU0FBUyxJQUFJLE9BQU8sQ0FFMUI7SUFFTSxnQkFBZ0IsQ0FBQyxnQkFBZ0IsRUFBRSxNQUFNLEVBQUUsTUFBTSxFQUFFLE9BQU8sRUFBRSxRQVdsRTtJQUVNLGtCQUFrQixDQUFDLEtBQUssRUFBRSxNQUFNLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxRQU1oRTtJQUVNLFlBQVksQ0FBQyxRQUFRLEVBQUUsTUFBTSxRQUduQztJQUVNLDBCQUEwQixDQUFDLFVBQVUsRUFBRSxjQUFjLFFBSTNEO0lBRU0scUJBQXFCLENBQUMsSUFBSSxFQUFFO1FBQUUsUUFBUSxFQUFFLE1BQU0sQ0FBQztRQUFDLGFBQWEsRUFBRSxNQUFNLENBQUM7UUFBQyxLQUFLLEVBQUUsTUFBTSxDQUFBO0tBQUUsRUFBRSxRQVc5RjtJQUVNLG1CQUFtQixDQUFDLFdBQVcsRUFBRSxNQUFNLFFBRTdDO0lBRU0sMkJBQTJCLENBQUMsTUFBTSxFQUFFLE1BQU0sRUFBRSxTQUFTLEVBQUUsT0FBTyxRQUtwRTtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/modules/instrumentation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAKL,KAAK,iBAAiB,EAEtB,KAAK,eAAe,EACpB,KAAK,MAAM,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,uBAAuB;
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/modules/instrumentation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,q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E,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,QAW9F;IAEM,mBAAmB,CAAC,WAAW,EAAE,MAAM,QAE7C;IAEM,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,QAKpE;CACF"}
|
|
@@ -4,6 +4,7 @@ export class ArchiverInstrumentation {
|
|
|
4
4
|
telemetry;
|
|
5
5
|
tracer;
|
|
6
6
|
blockHeight;
|
|
7
|
+
checkpointHeight;
|
|
7
8
|
txCount;
|
|
8
9
|
l1BlockHeight;
|
|
9
10
|
proofsSubmittedDelay;
|
|
@@ -25,6 +26,7 @@ export class ArchiverInstrumentation {
|
|
|
25
26
|
this.tracer = telemetry.getTracer('Archiver');
|
|
26
27
|
const meter = telemetry.getMeter('Archiver');
|
|
27
28
|
this.blockHeight = meter.createGauge(Metrics.ARCHIVER_BLOCK_HEIGHT);
|
|
29
|
+
this.checkpointHeight = meter.createGauge(Metrics.ARCHIVER_CHECKPOINT_HEIGHT);
|
|
28
30
|
this.l1BlockHeight = meter.createGauge(Metrics.ARCHIVER_L1_BLOCK_HEIGHT);
|
|
29
31
|
this.txCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_TOTAL_TXS);
|
|
30
32
|
this.proofsSubmittedCount = createUpDownCounterWithDefault(meter, Metrics.ARCHIVER_ROLLUP_PROOF_COUNT, {
|
|
@@ -63,6 +65,7 @@ export class ArchiverInstrumentation {
|
|
|
63
65
|
processNewBlocks(syncTimePerBlock, blocks) {
|
|
64
66
|
this.syncDurationPerBlock.record(Math.ceil(syncTimePerBlock));
|
|
65
67
|
this.blockHeight.record(Math.max(...blocks.map((b)=>b.number)));
|
|
68
|
+
this.checkpointHeight.record(Math.max(...blocks.map((b)=>b.checkpointNumber)));
|
|
66
69
|
this.syncBlockCount.add(blocks.length);
|
|
67
70
|
for (const block of blocks){
|
|
68
71
|
this.txCount.add(block.body.txEffects.length);
|
|
@@ -81,8 +84,12 @@ export class ArchiverInstrumentation {
|
|
|
81
84
|
this.pruneCount.add(1);
|
|
82
85
|
this.pruneDuration.record(Math.ceil(duration));
|
|
83
86
|
}
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
updateLastProvenCheckpoint(checkpoint) {
|
|
88
|
+
const lastBlockNumberInCheckpoint = checkpoint.startBlock + checkpoint.blockCount - 1;
|
|
89
|
+
this.blockHeight.record(lastBlockNumberInCheckpoint, {
|
|
90
|
+
[Attributes.STATUS]: 'proven'
|
|
91
|
+
});
|
|
92
|
+
this.checkpointHeight.record(checkpoint.checkpointNumber, {
|
|
86
93
|
[Attributes.STATUS]: 'proven'
|
|
87
94
|
});
|
|
88
95
|
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
2
2
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
3
3
|
import { InboxContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
4
|
-
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
5
4
|
import type { ViemPublicClient, ViemPublicDebugClient } from '@aztec/ethereum/types';
|
|
6
5
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
7
6
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
7
|
import { type Logger } from '@aztec/foundation/log';
|
|
10
8
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
11
9
|
import { type ArchiverEmitter } from '@aztec/stdlib/block';
|
|
12
10
|
import { type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
13
11
|
import { type Traceable, type Tracer } from '@aztec/telemetry-client';
|
|
14
12
|
import type { KVArchiverDataStore } from '../store/kv_archiver_store.js';
|
|
13
|
+
import type { L2TipsCache } from '../store/l2_tips_cache.js';
|
|
15
14
|
import type { ArchiverInstrumentation } from './instrumentation.js';
|
|
16
15
|
/**
|
|
17
16
|
* Handles L1 synchronization for the archiver.
|
|
@@ -22,7 +21,6 @@ export declare class ArchiverL1Synchronizer implements Traceable {
|
|
|
22
21
|
private readonly debugClient;
|
|
23
22
|
private readonly rollup;
|
|
24
23
|
private readonly inbox;
|
|
25
|
-
private readonly l1Addresses;
|
|
26
24
|
private readonly store;
|
|
27
25
|
private config;
|
|
28
26
|
private readonly blobClient;
|
|
@@ -37,16 +35,14 @@ export declare class ArchiverL1Synchronizer implements Traceable {
|
|
|
37
35
|
private l1Timestamp;
|
|
38
36
|
private readonly updater;
|
|
39
37
|
readonly tracer: Tracer;
|
|
40
|
-
constructor(publicClient: ViemPublicClient, debugClient: ViemPublicDebugClient, rollup: RollupContract, inbox: InboxContract,
|
|
41
|
-
slashingProposerAddress: EthAddress;
|
|
42
|
-
}, store: KVArchiverDataStore, config: {
|
|
38
|
+
constructor(publicClient: ViemPublicClient, debugClient: ViemPublicDebugClient, rollup: RollupContract, inbox: InboxContract, store: KVArchiverDataStore, config: {
|
|
43
39
|
batchSize: number;
|
|
44
40
|
skipValidateCheckpointAttestations?: boolean;
|
|
45
41
|
maxAllowedEthClientDriftSeconds: number;
|
|
46
42
|
}, blobClient: BlobClientInterface, epochCache: EpochCache, dateProvider: DateProvider, instrumentation: ArchiverInstrumentation, l1Constants: L1RollupConstants & {
|
|
47
43
|
l1StartBlockHash: Buffer32;
|
|
48
44
|
genesisArchiveRoot: Fr;
|
|
49
|
-
}, events: ArchiverEmitter, tracer: Tracer, log?: Logger);
|
|
45
|
+
}, events: ArchiverEmitter, tracer: Tracer, l2TipsCache?: L2TipsCache, log?: Logger);
|
|
50
46
|
/** Sets new config */
|
|
51
47
|
setConfig(newConfig: {
|
|
52
48
|
batchSize: number;
|
|
@@ -60,6 +56,7 @@ export declare class ArchiverL1Synchronizer implements Traceable {
|
|
|
60
56
|
/** Checks that the ethereum node we are connected to has a latest timestamp no more than the allowed drift. Throw if not. */
|
|
61
57
|
testEthereumNodeSynced(): Promise<void>;
|
|
62
58
|
syncFromL1(initialSyncComplete: boolean): Promise<void>;
|
|
59
|
+
private updateFinalizedCheckpoint;
|
|
63
60
|
private pruneUncheckpointedBlocks;
|
|
64
61
|
private canPrune;
|
|
65
62
|
private handleEpochPrune;
|
|
@@ -72,4 +69,4 @@ export declare class ArchiverL1Synchronizer implements Traceable {
|
|
|
72
69
|
private checkForNewCheckpointsBeforeL1SyncPoint;
|
|
73
70
|
private getCheckpointHeader;
|
|
74
71
|
}
|
|
75
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
72
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibDFfc3luY2hyb25pemVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbW9kdWxlcy9sMV9zeW5jaHJvbml6ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUNyRSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDaEQsT0FBTyxFQUFFLGFBQWEsRUFBRSxjQUFjLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUUxRSxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxxQkFBcUIsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBR3JGLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUVwRCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFnQixNQUFNLHVCQUF1QixDQUFDO0FBRWxFLE9BQU8sRUFBRSxZQUFZLEVBQWtCLE1BQU0seUJBQXlCLENBQUM7QUFFdkUsT0FBTyxFQUFFLEtBQUssZUFBZSxFQUFzRCxNQU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lBQzlDLGNBQWMsSUFBSSxNQUFNLEdBQUcsU0FBUyxDQUUxQztJQUVELDZIQUE2SDtJQUNoSCxzQkFBc0IsSUFBSSxPQUFPLENBQUMsSUFBSSxDQUFDLENBWW5EO0lBR1ksVUFBVSxDQUFDLG1CQUFtQixFQUFFLE9BQU8sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBaUhuRTtZQUdhLHlCQUF5QjtZQThCekIseUJBQXlCO1lBdUN6QixRQUFRO1lBZVIsZ0JBQWdCO0lBNEQ5QixPQUFPLENBQUMsU0FBUztZQVdILG9CQUFvQjtZQXVGcEIscUJBQXFCO1lBa0JyQixzQkFBc0I7WUF5Q3RCLGNBQWM7WUFTZCxpQkFBaUI7WUEwV2pCLHVDQUF1QztZQThDdkMsbUJBQW1CO0NBT2xDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"l1_synchronizer.d.ts","sourceRoot":"","sources":["../../src/modules/l1_synchronizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"l1_synchronizer.d.ts","sourceRoot":"","sources":["../../src/modules/l1_synchronizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAGrF,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,EAAE,EAAE,MAAM,gCA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ackSpan('Archiver.handleEpoch
|
|
|
396
396
|
debugClient;
|
|
397
397
|
rollup;
|
|
398
398
|
inbox;
|
|
399
|
-
l1Addresses;
|
|
400
399
|
store;
|
|
401
400
|
config;
|
|
402
401
|
blobClient;
|
|
@@ -435,12 +434,11 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
435
434
|
l1Timestamp;
|
|
436
435
|
updater;
|
|
437
436
|
tracer;
|
|
438
|
-
constructor(publicClient, debugClient, rollup, inbox,
|
|
437
|
+
constructor(publicClient, debugClient, rollup, inbox, store, config, blobClient, epochCache, dateProvider, instrumentation, l1Constants, events, tracer, l2TipsCache, log = createLogger('archiver:l1-sync')){
|
|
439
438
|
this.publicClient = publicClient;
|
|
440
439
|
this.debugClient = debugClient;
|
|
441
440
|
this.rollup = rollup;
|
|
442
441
|
this.inbox = inbox;
|
|
443
|
-
this.l1Addresses = l1Addresses;
|
|
444
442
|
this.store = store;
|
|
445
443
|
this.config = config;
|
|
446
444
|
this.blobClient = blobClient;
|
|
@@ -451,7 +449,9 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
451
449
|
this.events = events;
|
|
452
450
|
this.log = log;
|
|
453
451
|
_initProto(this);
|
|
454
|
-
this.updater = new ArchiverDataStoreUpdater(this.store
|
|
452
|
+
this.updater = new ArchiverDataStoreUpdater(this.store, l2TipsCache, {
|
|
453
|
+
rollupManaLimit: l1Constants.rollupManaLimit
|
|
454
|
+
});
|
|
455
455
|
this.tracer = tracer;
|
|
456
456
|
}
|
|
457
457
|
/** Sets new config */ setConfig(newConfig) {
|
|
@@ -555,6 +555,8 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
555
555
|
}
|
|
556
556
|
this.instrumentation.updateL1BlockHeight(currentL1BlockNumber);
|
|
557
557
|
}
|
|
558
|
+
// Update the finalized L2 checkpoint based on L1 finality.
|
|
559
|
+
await this.updateFinalizedCheckpoint();
|
|
558
560
|
// After syncing has completed, update the current l1 block number and timestamp,
|
|
559
561
|
// otherwise we risk announcing to the world that we've synced to a given point,
|
|
560
562
|
// but the corresponding blocks have not been processed (see #12631).
|
|
@@ -568,6 +570,34 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
568
570
|
l1BlockNumberAtEnd
|
|
569
571
|
});
|
|
570
572
|
}
|
|
573
|
+
/** Query L1 for its finalized block and update the finalized checkpoint accordingly. */ async updateFinalizedCheckpoint() {
|
|
574
|
+
try {
|
|
575
|
+
const finalizedL1Block = await this.publicClient.getBlock({
|
|
576
|
+
blockTag: 'finalized',
|
|
577
|
+
includeTransactions: false
|
|
578
|
+
});
|
|
579
|
+
const finalizedL1BlockNumber = finalizedL1Block.number;
|
|
580
|
+
const finalizedCheckpointNumber = await this.rollup.getProvenCheckpointNumber({
|
|
581
|
+
blockNumber: finalizedL1BlockNumber
|
|
582
|
+
});
|
|
583
|
+
const localFinalizedCheckpointNumber = await this.store.getFinalizedCheckpointNumber();
|
|
584
|
+
if (localFinalizedCheckpointNumber !== finalizedCheckpointNumber) {
|
|
585
|
+
await this.updater.setFinalizedCheckpointNumber(finalizedCheckpointNumber);
|
|
586
|
+
const finalizedL2BlockNumber = await this.store.getFinalizedL2BlockNumber();
|
|
587
|
+
this.log.info(`Updated finalized chain to checkpoint ${finalizedCheckpointNumber} (L2 block ${finalizedL2BlockNumber})`, {
|
|
588
|
+
finalizedCheckpointNumber,
|
|
589
|
+
previousFinalizedCheckpointNumber: localFinalizedCheckpointNumber,
|
|
590
|
+
finalizedL2BlockNumber,
|
|
591
|
+
finalizedL1BlockNumber
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
} catch (err) {
|
|
595
|
+
// The rollup contract may not exist at the finalized L1 block right after deployment.
|
|
596
|
+
if (!err?.message?.includes('returned no data')) {
|
|
597
|
+
this.log.warn(`Failed to update finalized checkpoint: ${err}`);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
571
601
|
/** Prune all proposed local blocks that should have been checkpointed by now. */ async pruneUncheckpointedBlocks(currentL1Timestamp) {
|
|
572
602
|
const [lastCheckpointedBlockNumber, lastProposedBlockNumber] = await Promise.all([
|
|
573
603
|
this.store.getCheckpointedL2BlockNumber(),
|
|
@@ -837,7 +867,7 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
837
867
|
if (provenCheckpointNumber === 0) {
|
|
838
868
|
const localProvenCheckpointNumber = await this.store.getProvenCheckpointNumber();
|
|
839
869
|
if (localProvenCheckpointNumber !== provenCheckpointNumber) {
|
|
840
|
-
await this.
|
|
870
|
+
await this.updater.setProvenCheckpointNumber(provenCheckpointNumber);
|
|
841
871
|
this.log.info(`Rolled back proven chain to checkpoint ${provenCheckpointNumber}`, {
|
|
842
872
|
provenCheckpointNumber
|
|
843
873
|
});
|
|
@@ -854,20 +884,20 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
854
884
|
if (localCheckpointForDestinationProvenCheckpointNumber && provenArchive.equals(localCheckpointForDestinationProvenCheckpointNumber.archive.root)) {
|
|
855
885
|
const localProvenCheckpointNumber = await this.store.getProvenCheckpointNumber();
|
|
856
886
|
if (localProvenCheckpointNumber !== provenCheckpointNumber) {
|
|
857
|
-
await this.
|
|
887
|
+
await this.updater.setProvenCheckpointNumber(provenCheckpointNumber);
|
|
858
888
|
this.log.info(`Updated proven chain to checkpoint ${provenCheckpointNumber}`, {
|
|
859
889
|
provenCheckpointNumber
|
|
860
890
|
});
|
|
861
891
|
const provenSlotNumber = localCheckpointForDestinationProvenCheckpointNumber.header.slotNumber;
|
|
862
892
|
const provenEpochNumber = getEpochAtSlot(provenSlotNumber, this.l1Constants);
|
|
863
|
-
const lastBlockNumberInCheckpoint = localCheckpointForDestinationProvenCheckpointNumber.startBlock + localCheckpointForDestinationProvenCheckpointNumber.
|
|
893
|
+
const lastBlockNumberInCheckpoint = localCheckpointForDestinationProvenCheckpointNumber.startBlock + localCheckpointForDestinationProvenCheckpointNumber.blockCount - 1;
|
|
864
894
|
this.events.emit(L2BlockSourceEvents.L2BlockProven, {
|
|
865
895
|
type: L2BlockSourceEvents.L2BlockProven,
|
|
866
896
|
blockNumber: BlockNumber(lastBlockNumberInCheckpoint),
|
|
867
897
|
slotNumber: provenSlotNumber,
|
|
868
898
|
epochNumber: provenEpochNumber
|
|
869
899
|
});
|
|
870
|
-
this.instrumentation.
|
|
900
|
+
this.instrumentation.updateLastProvenCheckpoint(localCheckpointForDestinationProvenCheckpointNumber);
|
|
871
901
|
} else {
|
|
872
902
|
this.log.trace(`Proven checkpoint ${provenCheckpointNumber} already stored.`);
|
|
873
903
|
}
|
|
@@ -945,7 +975,7 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
945
975
|
[searchStartBlock, searchEndBlock] = this.nextRange(searchEndBlock, currentL1BlockNumber);
|
|
946
976
|
this.log.trace(`Retrieving checkpoints from L1 block ${searchStartBlock} to ${searchEndBlock}`);
|
|
947
977
|
// TODO(md): Retrieve from blob client then from consensus client, then from peers
|
|
948
|
-
const retrievedCheckpoints = await execInSpan(this.tracer, 'Archiver.retrieveCheckpointsFromRollup', ()=>retrieveCheckpointsFromRollup(this.rollup, this.publicClient, this.debugClient, this.blobClient, searchStartBlock, searchEndBlock, this.
|
|
978
|
+
const retrievedCheckpoints = await execInSpan(this.tracer, 'Archiver.retrieveCheckpointsFromRollup', ()=>retrieveCheckpointsFromRollup(this.rollup, this.publicClient, this.debugClient, this.blobClient, searchStartBlock, searchEndBlock, this.instrumentation, this.log, !initialSyncComplete));
|
|
949
979
|
if (retrievedCheckpoints.length === 0) {
|
|
950
980
|
// We are not calling `setBlockSynchedL1BlockNumber` because it may cause sync issues if based off infura.
|
|
951
981
|
// See further details in earlier comments.
|
|
@@ -1016,7 +1046,7 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
1016
1046
|
if (result.prunedBlocks && result.prunedBlocks.length > 0) {
|
|
1017
1047
|
const prunedCheckpointNumber = result.prunedBlocks[0].checkpointNumber;
|
|
1018
1048
|
const prunedSlotNumber = result.prunedBlocks[0].header.globalVariables.slotNumber;
|
|
1019
|
-
this.log.
|
|
1049
|
+
this.log.info(`Pruned ${result.prunedBlocks.length} mismatching blocks for checkpoint ${prunedCheckpointNumber}`, {
|
|
1020
1050
|
prunedBlocks: result.prunedBlocks.map((b)=>b.toBlockInfo()),
|
|
1021
1051
|
prunedSlotNumber,
|
|
1022
1052
|
prunedCheckpointNumber
|