@aztec/archiver 0.0.1-commit.e3c1de76 → 0.0.1-commit.e57c76e
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 +19 -11
- package/dest/archiver.d.ts +58 -18
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +284 -160
- package/dest/config.d.ts +4 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +21 -14
- package/dest/errors.d.ts +55 -9
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +81 -14
- package/dest/factory.d.ts +14 -9
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +55 -39
- package/dest/index.d.ts +12 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +11 -2
- package/dest/l1/bin/retrieve-calldata.js +36 -33
- package/dest/l1/calldata_retriever.d.ts +74 -50
- package/dest/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/l1/calldata_retriever.js +201 -260
- package/dest/l1/data_retrieval.d.ts +26 -17
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +43 -48
- 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/l1/trace_tx.d.ts +12 -66
- package/dest/l1/trace_tx.d.ts.map +1 -1
- package/dest/l1/validate_historical_logs.d.ts +23 -0
- package/dest/l1/validate_historical_logs.d.ts.map +1 -0
- package/dest/l1/validate_historical_logs.js +108 -0
- 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 +40 -0
- package/dest/modules/data_source_base.d.ts +74 -45
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +269 -181
- package/dest/modules/data_store_updater.d.ts +49 -17
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +211 -121
- package/dest/modules/instrumentation.d.ts +21 -3
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +44 -9
- package/dest/modules/l1_synchronizer.d.ts +14 -12
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +443 -211
- package/dest/modules/outbox_trees_resolver.d.ts +62 -0
- package/dest/modules/outbox_trees_resolver.d.ts.map +1 -0
- package/dest/modules/outbox_trees_resolver.js +162 -0
- package/dest/modules/validation.d.ts +4 -3
- package/dest/modules/validation.d.ts.map +1 -1
- package/dest/modules/validation.js +6 -6
- package/dest/store/block_store.d.ts +174 -72
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +739 -272
- package/dest/store/contract_class_store.d.ts +17 -4
- package/dest/store/contract_class_store.d.ts.map +1 -1
- package/dest/store/contract_class_store.js +24 -68
- 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 +37 -2
- 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 +54 -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.d.ts +25 -0
- package/dest/store/l2_tips_cache.d.ts.map +1 -0
- package/dest/store/l2_tips_cache.js +26 -0
- package/dest/store/log_store.d.ts +42 -37
- package/dest/store/log_store.d.ts.map +1 -1
- package/dest/store/log_store.js +262 -388
- package/dest/store/log_store_codec.d.ts +70 -0
- package/dest/store/log_store_codec.d.ts.map +1 -0
- package/dest/store/log_store_codec.js +101 -0
- package/dest/store/message_store.d.ts +11 -1
- package/dest/store/message_store.d.ts.map +1 -1
- package/dest/store/message_store.js +51 -9
- package/dest/test/fake_l1_state.d.ts +25 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +166 -32
- 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_l1_to_l2_message_source.d.ts +1 -1
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +2 -1
- package/dest/test/mock_l2_block_source.d.ts +64 -47
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +323 -214
- 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 +13 -6
- package/dest/test/noop_l1_archiver.d.ts.map +1 -1
- package/dest/test/noop_l1_archiver.js +27 -10
- package/package.json +14 -14
- package/src/archiver.ts +359 -183
- package/src/config.ts +24 -11
- package/src/errors.ts +122 -21
- package/src/factory.ts +79 -38
- package/src/index.ts +19 -2
- package/src/l1/README.md +25 -68
- package/src/l1/bin/retrieve-calldata.ts +46 -39
- package/src/l1/calldata_retriever.ts +260 -379
- package/src/l1/data_retrieval.ts +59 -70
- package/src/l1/spire_proposer.ts +7 -15
- package/src/l1/validate_historical_logs.ts +140 -0
- package/src/modules/contract_data_source_adapter.ts +55 -0
- package/src/modules/data_source_base.ts +354 -226
- package/src/modules/data_store_updater.ts +248 -153
- package/src/modules/instrumentation.ts +56 -9
- package/src/modules/l1_synchronizer.ts +585 -258
- package/src/modules/outbox_trees_resolver.ts +199 -0
- package/src/modules/validation.ts +10 -9
- package/src/store/block_store.ts +917 -343
- package/src/store/contract_class_store.ts +31 -103
- package/src/store/contract_instance_store.ts +51 -5
- package/src/store/data_stores.ts +104 -0
- package/src/store/function_names_cache.ts +37 -0
- package/src/store/l2_tips_cache.ts +35 -0
- package/src/store/log_store.ts +303 -499
- package/src/store/log_store_codec.ts +132 -0
- package/src/store/message_store.ts +60 -10
- package/src/structs/inbox_message.ts +1 -1
- package/src/test/fake_l1_state.ts +213 -42
- package/src/test/mock_archiver.ts +3 -2
- package/src/test/mock_l1_to_l2_message_source.ts +1 -0
- package/src/test/mock_l2_block_source.ts +391 -232
- package/src/test/mock_structs.ts +20 -6
- package/src/test/noop_l1_archiver.ts +49 -10
- package/dest/store/kv_archiver_store.d.ts +0 -340
- package/dest/store/kv_archiver_store.d.ts.map +0 -1
- package/dest/store/kv_archiver_store.js +0 -446
- package/src/store/kv_archiver_store.ts +0 -639
package/dest/archiver.js
CHANGED
|
@@ -371,23 +371,27 @@ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
371
371
|
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
372
372
|
}
|
|
373
373
|
var _dec, _initProto;
|
|
374
|
-
import {
|
|
374
|
+
import { PROPOSER_PIPELINING_SLOT_OFFSET } from '@aztec/epoch-cache';
|
|
375
375
|
import { BlockTagTooOldError } from '@aztec/ethereum/contracts';
|
|
376
|
-
import { BlockNumber,
|
|
376
|
+
import { BlockNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
377
377
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
378
|
-
import { merge } from '@aztec/foundation/collection';
|
|
378
|
+
import { merge, pick } from '@aztec/foundation/collection';
|
|
379
379
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
380
380
|
import { createLogger } from '@aztec/foundation/log';
|
|
381
381
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
382
382
|
import { RunningPromise, makeLoggingErrorHandler } from '@aztec/foundation/running-promise';
|
|
383
|
-
import {
|
|
384
|
-
import {
|
|
383
|
+
import { elapsed } from '@aztec/foundation/timer';
|
|
384
|
+
import { L2BlockSourceEvents } from '@aztec/stdlib/block';
|
|
385
|
+
import { getEpochAtSlot, getSlotAtNextL1Block, getSlotRangeForEpoch, getTimestampForSlot, getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
385
386
|
import { trackSpan } from '@aztec/telemetry-client';
|
|
386
387
|
import { mapArchiverConfig } from './config.js';
|
|
387
|
-
import { NoBlobBodiesFoundError } from './errors.js';
|
|
388
|
+
import { BlockAlreadyCheckpointedError, BlockOrCheckpointSlotExpiredError, NoBlobBodiesFoundError } from './errors.js';
|
|
389
|
+
import { validateAndLogHistoricalLogsAvailability } from './l1/validate_historical_logs.js';
|
|
388
390
|
import { validateAndLogTraceAvailability } from './l1/validate_trace.js';
|
|
389
391
|
import { ArchiverDataSourceBase } from './modules/data_source_base.js';
|
|
390
392
|
import { ArchiverDataStoreUpdater } from './modules/data_store_updater.js';
|
|
393
|
+
import { OutboxTreesResolver } from './modules/outbox_trees_resolver.js';
|
|
394
|
+
import { backupArchiverDataStores, getArchiverSynchPoint } from './store/data_stores.js';
|
|
391
395
|
_dec = trackSpan('Archiver.sync');
|
|
392
396
|
/**
|
|
393
397
|
* Pulls checkpoints in a non-blocking manner and provides interface for their retrieval.
|
|
@@ -397,11 +401,13 @@ _dec = trackSpan('Archiver.sync');
|
|
|
397
401
|
publicClient;
|
|
398
402
|
debugClient;
|
|
399
403
|
rollup;
|
|
404
|
+
outbox;
|
|
400
405
|
l1Addresses;
|
|
401
|
-
|
|
406
|
+
dataStores;
|
|
402
407
|
config;
|
|
403
408
|
blobClient;
|
|
404
409
|
l1Constants;
|
|
410
|
+
dateProvider;
|
|
405
411
|
log;
|
|
406
412
|
static{
|
|
407
413
|
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
@@ -415,37 +421,67 @@ _dec = trackSpan('Archiver.sync');
|
|
|
415
421
|
/** Event emitter for archiver events (L2BlockProven, L2PruneUnproven, L2PruneUncheckpointed, etc). */ events;
|
|
416
422
|
/** A loop in which we will be continually fetching new checkpoints. */ runningPromise;
|
|
417
423
|
/** L1 synchronizer that handles fetching checkpoints and messages from L1. */ synchronizer;
|
|
424
|
+
/** Resolver for L2-to-L1 message membership witnesses, built over this archiver's read view. */ outboxTreesResolver;
|
|
418
425
|
initialSyncComplete;
|
|
419
426
|
initialSyncPromise;
|
|
420
|
-
/** Queue of blocks to be added to the store, processed by the sync loop. */
|
|
427
|
+
/** Queue of blocks and checkpoints to be added to the store, processed by the sync loop. */ inboundQueue;
|
|
421
428
|
/** Helper to handle updates to the store */ updater;
|
|
429
|
+
/** In-memory cache for L2 chain tips. */ l2TipsCache;
|
|
422
430
|
tracer;
|
|
431
|
+
instrumentation;
|
|
423
432
|
/**
|
|
424
433
|
* Creates a new instance of the Archiver.
|
|
425
434
|
* @param publicClient - A client for interacting with the Ethereum node.
|
|
426
435
|
* @param debugClient - A client for interacting with the Ethereum node for debug/trace methods.
|
|
427
436
|
* @param rollup - Rollup contract instance.
|
|
437
|
+
* @param outbox - Outbox contract instance, used to read per-epoch L2-to-L1 message roots.
|
|
428
438
|
* @param inbox - Inbox contract instance.
|
|
429
|
-
* @param l1Addresses - L1 contract addresses (registry, governance proposer,
|
|
430
|
-
* @param
|
|
439
|
+
* @param l1Addresses - L1 contract addresses (registry, governance proposer, slashing proposer).
|
|
440
|
+
* @param dataStores - Archiver substores for storage & retrieval of blocks, encrypted logs & contract data.
|
|
431
441
|
* @param config - Archiver configuration options.
|
|
432
442
|
* @param blobClient - Client for retrieving blob data.
|
|
433
|
-
* @param epochCache - Cache for epoch-related data.
|
|
434
|
-
* @param dateProvider - Provider for current date/time.
|
|
435
443
|
* @param instrumentation - Instrumentation for metrics and tracing.
|
|
436
444
|
* @param l1Constants - L1 rollup constants.
|
|
445
|
+
* @param synchronizer - L1 synchronizer that handles fetching checkpoints and messages from L1.
|
|
446
|
+
* @param events - Event emitter shared with the synchronizer.
|
|
447
|
+
* @param initialHeader - Genesis block header.
|
|
448
|
+
* @param initialBlockHash - Precomputed hash of the genesis block header.
|
|
449
|
+
* @param l2TipsCache - In-memory cache for L2 chain tips.
|
|
450
|
+
* @param dateProvider - Provider for current date/time, used for wall-clock orphan-block pruning.
|
|
437
451
|
* @param log - A logger.
|
|
438
|
-
*/ constructor(publicClient, debugClient, rollup, l1Addresses,
|
|
439
|
-
super(
|
|
452
|
+
*/ constructor(publicClient, debugClient, rollup, outbox, l1Addresses, dataStores, config, blobClient, instrumentation, l1Constants, synchronizer, events, initialHeader, initialBlockHash, l2TipsCache, dateProvider, log = createLogger('archiver')){
|
|
453
|
+
super(dataStores, l1Constants, initialHeader, initialBlockHash, l1Constants.genesisArchiveRoot), this.publicClient = publicClient, this.debugClient = debugClient, this.rollup = rollup, this.outbox = outbox, this.l1Addresses = l1Addresses, this.dataStores = dataStores, this.config = config, this.blobClient = blobClient, this.l1Constants = l1Constants, this.dateProvider = dateProvider, this.log = log, this.initialSyncComplete = (_initProto(this), false), this.inboundQueue = [];
|
|
440
454
|
this.tracer = instrumentation.tracer;
|
|
455
|
+
this.instrumentation = instrumentation;
|
|
441
456
|
this.initialSyncPromise = promiseWithResolvers();
|
|
442
457
|
this.synchronizer = synchronizer;
|
|
443
458
|
this.events = events;
|
|
444
|
-
this.
|
|
459
|
+
this.l2TipsCache = l2TipsCache;
|
|
460
|
+
this.updater = new ArchiverDataStoreUpdater(this.dataStores, this.l2TipsCache, {
|
|
461
|
+
rollupManaLimit: l1Constants.rollupManaLimit
|
|
462
|
+
});
|
|
463
|
+
// The resolver reads its witness data from this archiver and pins its lazy Outbox-root fetches
|
|
464
|
+
// to the archiver's synced L1 block. No method on `this` is invoked during construction.
|
|
465
|
+
this.outboxTreesResolver = new OutboxTreesResolver(this.outbox, this, ()=>Promise.resolve(this.getL1BlockNumber()), l1Constants.epochDuration);
|
|
445
466
|
// Running promise starts with a small interval inbetween runs, so all iterations needed for the initial sync
|
|
446
467
|
// are done as fast as possible. This then gets updated once the initial sync completes.
|
|
447
468
|
this.runningPromise = new RunningPromise(()=>this.sync(), this.log, this.config.pollingIntervalMs / 10, makeLoggingErrorHandler(this.log, NoBlobBodiesFoundError, BlockTagTooOldError));
|
|
448
469
|
}
|
|
470
|
+
/**
|
|
471
|
+
* Returns the L2-to-L1 membership witness for `message` emitted by tx `txHash`. The node selects
|
|
472
|
+
* the smallest partial-proof root on the Outbox that covers the tx's checkpoint and builds the
|
|
473
|
+
* witness against it.
|
|
474
|
+
*
|
|
475
|
+
* The node reads the Outbox roots lazily, pinned to its synced L1 block, so the witness reflects
|
|
476
|
+
* the node's synced view. Returns `undefined` if the tx isn't yet in a block/epoch or no covering
|
|
477
|
+
* root has landed on L1 as of the synced block.
|
|
478
|
+
*
|
|
479
|
+
* Caveat: roots are cached only for the current synced L1 block and re-fetched once the node
|
|
480
|
+
* advances, so a reorg is picked up on the next synced-block advance rather than re-validated per
|
|
481
|
+
* request.
|
|
482
|
+
*/ getL2ToL1MembershipWitness(txHash, message, messageIndexInTx) {
|
|
483
|
+
return this.outboxTreesResolver.getL2ToL1MembershipWitness(txHash, message, messageIndexInTx);
|
|
484
|
+
}
|
|
449
485
|
/** Updates archiver config */ updateConfig(newConfig) {
|
|
450
486
|
this.config = merge(this.config, mapArchiverConfig(newConfig));
|
|
451
487
|
this.synchronizer.setConfig(this.config);
|
|
@@ -460,10 +496,16 @@ _dec = trackSpan('Archiver.sync');
|
|
|
460
496
|
await this.blobClient.testSources();
|
|
461
497
|
await this.synchronizer.testEthereumNodeSynced();
|
|
462
498
|
await validateAndLogTraceAvailability(this.debugClient, this.config.ethereumAllowNoDebugHosts ?? false, this.log.getBindings());
|
|
499
|
+
await validateAndLogHistoricalLogsAvailability(this.publicClient, {
|
|
500
|
+
rollupAddress: this.l1Addresses.rollupAddress,
|
|
501
|
+
inboxAddress: this.l1Addresses.inboxAddress,
|
|
502
|
+
registryAddress: this.l1Addresses.registryAddress,
|
|
503
|
+
governanceProposerAddress: this.l1Addresses.governanceProposerAddress
|
|
504
|
+
}, this.config.skipHistoricalLogsCheck ?? false, this.log.getBindings());
|
|
463
505
|
// Log initial state for the archiver
|
|
464
506
|
const { l1StartBlock } = this.l1Constants;
|
|
465
|
-
const { blocksSynchedTo = l1StartBlock, messagesSynchedTo = l1StartBlock } = await this.
|
|
466
|
-
const currentL2Checkpoint = await this.
|
|
507
|
+
const { blocksSynchedTo = l1StartBlock, messagesSynchedTo = l1StartBlock } = await getArchiverSynchPoint(this.stores);
|
|
508
|
+
const currentL2Checkpoint = await this.getCheckpointNumber();
|
|
467
509
|
this.log.info(`Starting archiver sync to rollup contract ${this.rollup.address} from L1 block ${blocksSynchedTo} and L2 checkpoint ${currentL2Checkpoint}`, {
|
|
468
510
|
blocksSynchedTo,
|
|
469
511
|
messagesSynchedTo,
|
|
@@ -478,6 +520,13 @@ _dec = trackSpan('Archiver.sync');
|
|
|
478
520
|
syncImmediate() {
|
|
479
521
|
return this.runningPromise.trigger();
|
|
480
522
|
}
|
|
523
|
+
trySyncImmediate() {
|
|
524
|
+
try {
|
|
525
|
+
return this.syncImmediate();
|
|
526
|
+
} catch (err) {
|
|
527
|
+
this.log.error(`Failed to trigger immediate archiver sync: ${err}`, err);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
481
530
|
/**
|
|
482
531
|
* Queues a block to be added to the archiver store and triggers processing.
|
|
483
532
|
* The block will be processed by the sync loop.
|
|
@@ -485,53 +534,84 @@ _dec = trackSpan('Archiver.sync');
|
|
|
485
534
|
* @param block - The L2 block to add.
|
|
486
535
|
* @returns A promise that resolves when the block has been added to the store, or rejects on error.
|
|
487
536
|
*/ addBlock(block) {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
537
|
+
const promise = promiseWithResolvers();
|
|
538
|
+
this.inboundQueue.push({
|
|
539
|
+
block,
|
|
540
|
+
...promise,
|
|
541
|
+
type: 'block'
|
|
542
|
+
});
|
|
543
|
+
this.log.debug(`Queued block ${block.number} for processing`);
|
|
544
|
+
void this.trySyncImmediate();
|
|
545
|
+
return promise.promise;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Queues a new proposed checkpoint into the archiver store.
|
|
549
|
+
* Checks that the checkpoint is not for an L2 slot already synced from L1.
|
|
550
|
+
* Resolves once the checkpoint has been processed.
|
|
551
|
+
*/ addProposedCheckpoint(pending) {
|
|
552
|
+
const promise = promiseWithResolvers();
|
|
553
|
+
this.inboundQueue.push({
|
|
554
|
+
checkpoint: pending,
|
|
555
|
+
...promise,
|
|
556
|
+
type: 'checkpoint'
|
|
499
557
|
});
|
|
558
|
+
this.log.debug(`Queued checkpoint ${pending.checkpointNumber} for processing`);
|
|
559
|
+
void this.trySyncImmediate();
|
|
560
|
+
return promise.promise;
|
|
500
561
|
}
|
|
501
562
|
/**
|
|
502
|
-
* Processes all queued blocks, adding them to the store.
|
|
563
|
+
* Processes all queued blocks and checkpoints, adding them to the store.
|
|
503
564
|
* Called at the beginning of each sync iteration.
|
|
504
|
-
*
|
|
505
|
-
*/ async
|
|
506
|
-
if (this.
|
|
565
|
+
* Items are processed in the order they were queued.
|
|
566
|
+
*/ async processInboundQueue() {
|
|
567
|
+
if (this.inboundQueue.length === 0) {
|
|
507
568
|
return;
|
|
508
569
|
}
|
|
509
|
-
// Take all
|
|
510
|
-
const queuedItems = this.
|
|
511
|
-
this.log.debug(`Processing ${queuedItems.length} queued
|
|
570
|
+
// Take all items from the queue
|
|
571
|
+
const queuedItems = this.inboundQueue.splice(0, this.inboundQueue.length);
|
|
572
|
+
this.log.debug(`Processing ${queuedItems.length} queued inbound items`);
|
|
512
573
|
// Calculate slot threshold for validation
|
|
513
574
|
const l1Timestamp = this.synchronizer.getL1Timestamp();
|
|
514
575
|
const slotAtNextL1Block = l1Timestamp === undefined ? undefined : getSlotAtNextL1Block(l1Timestamp, this.l1Constants);
|
|
515
|
-
//
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
576
|
+
// Helpers for manipulating blocks and checkpoints in the queue
|
|
577
|
+
const getSlot = (item)=>item.type === 'block' ? item.block.header.globalVariables.slotNumber : item.checkpoint.header.slotNumber;
|
|
578
|
+
const getNumber = (item)=>item.type === 'block' ? item.block.number : item.checkpoint.checkpointNumber;
|
|
579
|
+
// Process each item individually to properly resolve/reject each promise
|
|
580
|
+
for (const item of queuedItems){
|
|
581
|
+
const { resolve, reject, type } = item;
|
|
582
|
+
const itemSlot = getSlot(item);
|
|
583
|
+
const itemNumber = getNumber(item);
|
|
584
|
+
if (slotAtNextL1Block !== undefined && itemSlot < slotAtNextL1Block) {
|
|
585
|
+
const nextSlotTimestamp = getTimestampForSlot(slotAtNextL1Block, this.l1Constants);
|
|
586
|
+
this.log.warn(`Rejecting proposed ${type} ${itemNumber} for past slot ${itemSlot} (current ${slotAtNextL1Block})`, {
|
|
587
|
+
number: itemNumber,
|
|
588
|
+
type,
|
|
521
589
|
l1Timestamp,
|
|
522
|
-
slotAtNextL1Block
|
|
590
|
+
slotAtNextL1Block,
|
|
591
|
+
nextSlotTimestamp
|
|
523
592
|
});
|
|
524
|
-
reject(new
|
|
593
|
+
reject(new BlockOrCheckpointSlotExpiredError(itemSlot, nextSlotTimestamp, l1Timestamp));
|
|
525
594
|
continue;
|
|
526
595
|
}
|
|
527
596
|
try {
|
|
528
|
-
|
|
529
|
-
block
|
|
530
|
-
|
|
531
|
-
|
|
597
|
+
if (type === 'block') {
|
|
598
|
+
const [durationMs] = await elapsed(()=>this.updater.addProposedBlock(item.block));
|
|
599
|
+
this.instrumentation.processNewProposedBlock(durationMs, item.block);
|
|
600
|
+
} else {
|
|
601
|
+
await this.updater.addProposedCheckpoint(item.checkpoint);
|
|
602
|
+
}
|
|
603
|
+
this.log.debug(`Added ${type} ${itemNumber} to store`);
|
|
532
604
|
resolve();
|
|
533
605
|
} catch (err) {
|
|
534
|
-
|
|
606
|
+
if (err instanceof BlockAlreadyCheckpointedError) {
|
|
607
|
+
this.log.debug(`Proposed block ${itemNumber} matches already checkpointed block, ignoring late proposal`);
|
|
608
|
+
resolve();
|
|
609
|
+
continue;
|
|
610
|
+
}
|
|
611
|
+
this.log.error(`Failed to add ${type} ${itemNumber} to store: ${err.message}`, err, {
|
|
612
|
+
number: itemNumber,
|
|
613
|
+
type
|
|
614
|
+
});
|
|
535
615
|
reject(err);
|
|
536
616
|
}
|
|
537
617
|
}
|
|
@@ -543,9 +623,88 @@ _dec = trackSpan('Archiver.sync');
|
|
|
543
623
|
* Fetches logs from L1 contracts and processes them.
|
|
544
624
|
*/ async sync() {
|
|
545
625
|
// Process any queued blocks first, before doing L1 sync
|
|
546
|
-
await this.
|
|
626
|
+
await this.processInboundQueue();
|
|
547
627
|
// Now perform L1 sync
|
|
548
628
|
await this.syncFromL1();
|
|
629
|
+
// Prune proposed blocks with no corresponding proposed checkpoint by the end of their build slot.
|
|
630
|
+
await this.pruneOrphanProposedBlocks();
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Prunes a block-only local tip that was built atop a checkpoint that was never itself proposed.
|
|
634
|
+
*
|
|
635
|
+
* Under pipelining, a proposer publishes the blocks for a checkpoint (block-only proposals) before
|
|
636
|
+
* assembling and publishing the enclosing proposed checkpoint at the end of the build slot. A node
|
|
637
|
+
* that received those blocks but never the proposed checkpoint is left with an orphan tip it must
|
|
638
|
+
* not build on. We prune it once enough wall-clock time has elapsed that the proposed checkpoint
|
|
639
|
+
* should have arrived. This runs on wall-clock time (not L1 block advancement) so it fires during
|
|
640
|
+
* quiet L1 periods, and is the liveness counterpart to the sequencer's checkSync guard.
|
|
641
|
+
*
|
|
642
|
+
* The uncheckpointed suffix is scanned in order. Blocks covered by proposed checkpoints are left in
|
|
643
|
+
* place; the first block not covered by a proposed checkpoint starts the orphan suffix to prune.
|
|
644
|
+
*/ async pruneOrphanProposedBlocks() {
|
|
645
|
+
// Orphan pruning is a pipelining-only liveness mechanism: it cleans up block-only proposals
|
|
646
|
+
// whose enclosing checkpoint never arrived over gossip. The test-only automine sequencer is
|
|
647
|
+
// non-pipelined — it publishes each checkpoint synchronously in the slot it builds — so it
|
|
648
|
+
// never produces orphan proposed blocks. Running the prune there would race its two-step local
|
|
649
|
+
// push (addBlock then addProposedCheckpoint) and delete the block before its checkpoint attaches.
|
|
650
|
+
if (!this.config.enableOrphanProposedBlockPruning) {
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
const tips = await this.getL2Tips();
|
|
654
|
+
const now = BigInt(this.dateProvider.nowInSeconds());
|
|
655
|
+
const pipeliningOffset = PROPOSER_PIPELINING_SLOT_OFFSET;
|
|
656
|
+
// The proposed tip is a proposed-checkpointed block, so there are no orphan proposed blocks to prune
|
|
657
|
+
if (tips.proposedCheckpoint.block.number === tips.proposed.number) {
|
|
658
|
+
this.log.trace(`No orphan proposed blocks to prune: proposed tip ${tips.proposed.number} is checkpointed`, pick(tips, 'proposed', 'proposedCheckpoint'));
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
// Load the blocks that are candidates for pruning (ie blocks without a proposed checkpoint covering them)
|
|
662
|
+
const blocksWithoutProposedCheckpoint = await this.stores.blocks.getBlocksData({
|
|
663
|
+
from: BlockNumber(tips.proposedCheckpoint.block.number + 1),
|
|
664
|
+
limit: tips.proposed.number - tips.proposedCheckpoint.block.number
|
|
665
|
+
});
|
|
666
|
+
// Iterate through them in order, the first one with a slot that should have received a proposed checkpoint
|
|
667
|
+
// is the first orphan block, and all blocks after it are also orphaned and should be pruned.
|
|
668
|
+
let lastSlotChecked = undefined;
|
|
669
|
+
for (const blockData of blocksWithoutProposedCheckpoint){
|
|
670
|
+
// No need to recheck if this block had the same slot as the previous one.
|
|
671
|
+
const blockSlot = blockData.header.getSlot();
|
|
672
|
+
const blockNumber = blockData.header.getBlockNumber();
|
|
673
|
+
if (lastSlotChecked !== undefined && blockSlot === lastSlotChecked) {
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
lastSlotChecked = blockSlot;
|
|
677
|
+
// The proposed checkpoint should have landed by the start of the slot after the block's build slot
|
|
678
|
+
// (build slot = blockSlot - pipeliningOffset). Wait a grace period beyond that to tolerate propagation.
|
|
679
|
+
const expectedCheckpointedBySlot = SlotNumber(Number(blockSlot) - pipeliningOffset + 1);
|
|
680
|
+
const expectedCheckpointedByTime = getTimestampForSlot(expectedCheckpointedBySlot, this.l1Constants) + BigInt(this.config.orphanProposedBlockPruneGraceSeconds);
|
|
681
|
+
// If it's not checkpointed by the expected time, prune it along with all blocks after it.
|
|
682
|
+
if (now >= expectedCheckpointedByTime) {
|
|
683
|
+
const pruneAfterBlockNumber = BlockNumber(blockNumber - 1);
|
|
684
|
+
this.log.warn(`Pruning orphan blocks after block ${pruneAfterBlockNumber}: block at slot ${blockSlot} belongs to ` + `checkpoint ${blockData.checkpointNumber} which has no matching proposed checkpoint`, {
|
|
685
|
+
firstUncheckpointedBlockHeader: blockData.header.toInspect(),
|
|
686
|
+
blockCheckpointNumber: blockData.checkpointNumber,
|
|
687
|
+
blockNumber,
|
|
688
|
+
blockSlot,
|
|
689
|
+
pipeliningOffset,
|
|
690
|
+
expectedCheckpointedBySlot,
|
|
691
|
+
expectedCheckpointedByTime,
|
|
692
|
+
now
|
|
693
|
+
});
|
|
694
|
+
const prunedBlocks = await this.updater.removeBlocksWithoutProposedCheckpointAfter(pruneAfterBlockNumber);
|
|
695
|
+
if (prunedBlocks.length > 0) {
|
|
696
|
+
this.events.emit(L2BlockSourceEvents.L2PruneUncheckpointed, {
|
|
697
|
+
type: L2BlockSourceEvents.L2PruneUncheckpointed,
|
|
698
|
+
slotNumber: blockSlot,
|
|
699
|
+
blocks: prunedBlocks
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
this.log.trace('No orphan proposed blocks to prune: all uncheckpointed blocks are still within the grace period', {
|
|
706
|
+
blocksWithoutProposedCheckpoint: blocksWithoutProposedCheckpoint.map((b)=>b.header.toInspect())
|
|
707
|
+
});
|
|
549
708
|
}
|
|
550
709
|
async syncFromL1() {
|
|
551
710
|
// Delegate to the L1 synchronizer
|
|
@@ -557,7 +716,7 @@ _dec = trackSpan('Archiver.sync');
|
|
|
557
716
|
if (currentL1BlockNumber + 1n >= l1BlockNumberAtEnd) {
|
|
558
717
|
this.log.info(`Initial archiver sync to L1 block ${currentL1BlockNumber} complete`, {
|
|
559
718
|
l1BlockNumber: currentL1BlockNumber,
|
|
560
|
-
syncPoint: await this.
|
|
719
|
+
syncPoint: await getArchiverSynchPoint(this.stores),
|
|
561
720
|
...await this.getL2Tips()
|
|
562
721
|
});
|
|
563
722
|
this.runningPromise.setPollingIntervalMS(this.config.pollingIntervalMs);
|
|
@@ -583,7 +742,7 @@ _dec = trackSpan('Archiver.sync');
|
|
|
583
742
|
return Promise.resolve();
|
|
584
743
|
}
|
|
585
744
|
backupTo(destPath) {
|
|
586
|
-
return this.
|
|
745
|
+
return backupArchiverDataStores(this.dataStores, destPath);
|
|
587
746
|
}
|
|
588
747
|
getL1Constants() {
|
|
589
748
|
return Promise.resolve(this.l1Constants);
|
|
@@ -605,20 +764,53 @@ _dec = trackSpan('Archiver.sync');
|
|
|
605
764
|
getL1Timestamp() {
|
|
606
765
|
return Promise.resolve(this.synchronizer.getL1Timestamp());
|
|
607
766
|
}
|
|
608
|
-
|
|
767
|
+
async getSyncedL2SlotNumber() {
|
|
768
|
+
// The synced L2 slot is the latest slot for which we have all L1 data,
|
|
769
|
+
// either because we have seen all L1 blocks for that slot, or because
|
|
770
|
+
// we have seen the corresponding checkpoint.
|
|
771
|
+
let slotFromL1Sync;
|
|
609
772
|
const l1Timestamp = this.synchronizer.getL1Timestamp();
|
|
610
|
-
|
|
773
|
+
if (l1Timestamp !== undefined) {
|
|
774
|
+
const nextL1BlockSlot = getSlotAtNextL1Block(l1Timestamp, this.l1Constants);
|
|
775
|
+
if (Number(nextL1BlockSlot) > 0) {
|
|
776
|
+
slotFromL1Sync = SlotNumber.add(nextL1BlockSlot, -1);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
let slotFromCheckpoint;
|
|
780
|
+
const latestCheckpointNumber = await this.stores.blocks.getLatestCheckpointNumber();
|
|
781
|
+
if (latestCheckpointNumber > 0) {
|
|
782
|
+
const checkpointData = await this.stores.blocks.getCheckpointData(latestCheckpointNumber);
|
|
783
|
+
if (checkpointData) {
|
|
784
|
+
slotFromCheckpoint = checkpointData.header.slotNumber;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
if (slotFromL1Sync === undefined && slotFromCheckpoint === undefined) {
|
|
788
|
+
return undefined;
|
|
789
|
+
}
|
|
790
|
+
return SlotNumber(Math.max(slotFromL1Sync ?? 0, slotFromCheckpoint ?? 0));
|
|
611
791
|
}
|
|
612
|
-
|
|
613
|
-
const
|
|
614
|
-
|
|
792
|
+
async getSyncedL2EpochNumber() {
|
|
793
|
+
const syncedSlot = await this.getSyncedL2SlotNumber();
|
|
794
|
+
if (syncedSlot === undefined) {
|
|
795
|
+
return undefined;
|
|
796
|
+
}
|
|
797
|
+
// An epoch is fully synced when all its slots are synced.
|
|
798
|
+
// We check if syncedSlot is the last slot of its epoch; if so, that epoch is fully synced.
|
|
799
|
+
// Otherwise, only the previous epoch is fully synced.
|
|
800
|
+
const epoch = getEpochAtSlot(syncedSlot, this.l1Constants);
|
|
801
|
+
const [, endSlot] = getSlotRangeForEpoch(epoch, this.l1Constants);
|
|
802
|
+
if (syncedSlot >= endSlot) {
|
|
803
|
+
return epoch;
|
|
804
|
+
}
|
|
805
|
+
return Number(epoch) > 0 ? EpochNumber(Number(epoch) - 1) : undefined;
|
|
615
806
|
}
|
|
616
807
|
async isEpochComplete(epochNumber) {
|
|
617
808
|
// The epoch is complete if the current checkpointed L2 block is the last one in the epoch (or later).
|
|
618
809
|
// We use the checkpointed block number (synced from L1) instead of 'latest' to avoid returning true
|
|
619
810
|
// prematurely when proposed blocks have been pushed to the archiver but not yet checkpointed on L1.
|
|
620
|
-
const
|
|
621
|
-
|
|
811
|
+
const header = (await this.getBlockData({
|
|
812
|
+
tag: 'checkpointed'
|
|
813
|
+
}))?.header;
|
|
622
814
|
const slot = header ? header.globalVariables.slotNumber : undefined;
|
|
623
815
|
const [_startSlot, endSlot] = getSlotRangeForEpoch(epochNumber, this.l1Constants);
|
|
624
816
|
if (slot && slot >= endSlot) {
|
|
@@ -650,106 +842,38 @@ _dec = trackSpan('Archiver.sync');
|
|
|
650
842
|
await this.updater.addCheckpoints(checkpoints, pendingChainValidationStatus);
|
|
651
843
|
return true;
|
|
652
844
|
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
this.getBlockNumber(),
|
|
656
|
-
this.getProvenBlockNumber(),
|
|
657
|
-
this.getCheckpointedL2BlockNumber(),
|
|
658
|
-
this.getFinalizedL2BlockNumber()
|
|
659
|
-
]);
|
|
660
|
-
const beforeInitialblockNumber = BlockNumber(INITIAL_L2_BLOCK_NUM - 1);
|
|
661
|
-
// Get the latest block header and checkpointed blocks for proven, finalised and checkpointed blocks
|
|
662
|
-
const [latestBlockHeader, provenCheckpointedBlock, finalizedCheckpointedBlock, checkpointedBlock] = await Promise.all([
|
|
663
|
-
latestBlockNumber > beforeInitialblockNumber ? this.getBlockHeader(latestBlockNumber) : undefined,
|
|
664
|
-
provenBlockNumber > beforeInitialblockNumber ? this.getCheckpointedBlock(provenBlockNumber) : undefined,
|
|
665
|
-
finalizedBlockNumber > beforeInitialblockNumber ? this.getCheckpointedBlock(finalizedBlockNumber) : undefined,
|
|
666
|
-
checkpointedBlockNumber > beforeInitialblockNumber ? this.getCheckpointedBlock(checkpointedBlockNumber) : undefined
|
|
667
|
-
]);
|
|
668
|
-
if (latestBlockNumber > beforeInitialblockNumber && !latestBlockHeader) {
|
|
669
|
-
throw new Error(`Failed to retrieve latest block header for block ${latestBlockNumber}`);
|
|
670
|
-
}
|
|
671
|
-
// Checkpointed blocks must exist for proven, finalized and checkpointed tips if they are beyond the initial block number.
|
|
672
|
-
if (checkpointedBlockNumber > beforeInitialblockNumber && !checkpointedBlock?.block.header) {
|
|
673
|
-
throw new Error(`Failed to retrieve checkpointed block header for block ${checkpointedBlockNumber} (latest block is ${latestBlockNumber})`);
|
|
674
|
-
}
|
|
675
|
-
if (provenBlockNumber > beforeInitialblockNumber && !provenCheckpointedBlock?.block.header) {
|
|
676
|
-
throw new Error(`Failed to retrieve proven checkpointed for block ${provenBlockNumber} (latest block is ${latestBlockNumber})`);
|
|
677
|
-
}
|
|
678
|
-
if (finalizedBlockNumber > beforeInitialblockNumber && !finalizedCheckpointedBlock?.block.header) {
|
|
679
|
-
throw new Error(`Failed to retrieve finalized block header for block ${finalizedBlockNumber} (latest block is ${latestBlockNumber})`);
|
|
680
|
-
}
|
|
681
|
-
const latestBlockHeaderHash = await latestBlockHeader?.hash() ?? GENESIS_BLOCK_HEADER_HASH;
|
|
682
|
-
const provenBlockHeaderHash = await provenCheckpointedBlock?.block.header?.hash() ?? GENESIS_BLOCK_HEADER_HASH;
|
|
683
|
-
const finalizedBlockHeaderHash = await finalizedCheckpointedBlock?.block.header?.hash() ?? GENESIS_BLOCK_HEADER_HASH;
|
|
684
|
-
const checkpointedBlockHeaderHash = await checkpointedBlock?.block.header?.hash() ?? GENESIS_BLOCK_HEADER_HASH;
|
|
685
|
-
// Now attempt to retrieve checkpoints for proven, finalised and checkpointed blocks
|
|
686
|
-
const [[provenBlockCheckpoint], [finalizedBlockCheckpoint], [checkpointedBlockCheckpoint]] = await Promise.all([
|
|
687
|
-
provenCheckpointedBlock !== undefined ? await this.getCheckpoints(provenCheckpointedBlock?.checkpointNumber, 1) : [
|
|
688
|
-
undefined
|
|
689
|
-
],
|
|
690
|
-
finalizedCheckpointedBlock !== undefined ? await this.getCheckpoints(finalizedCheckpointedBlock?.checkpointNumber, 1) : [
|
|
691
|
-
undefined
|
|
692
|
-
],
|
|
693
|
-
checkpointedBlock !== undefined ? await this.getCheckpoints(checkpointedBlock?.checkpointNumber, 1) : [
|
|
694
|
-
undefined
|
|
695
|
-
]
|
|
696
|
-
]);
|
|
697
|
-
const initialcheckpointId = {
|
|
698
|
-
number: CheckpointNumber.ZERO,
|
|
699
|
-
hash: GENESIS_CHECKPOINT_HEADER_HASH.toString()
|
|
700
|
-
};
|
|
701
|
-
const makeCheckpointId = (checkpoint)=>{
|
|
702
|
-
if (checkpoint === undefined) {
|
|
703
|
-
return initialcheckpointId;
|
|
704
|
-
}
|
|
705
|
-
return {
|
|
706
|
-
number: checkpoint.checkpoint.number,
|
|
707
|
-
hash: checkpoint.checkpoint.hash().toString()
|
|
708
|
-
};
|
|
709
|
-
};
|
|
710
|
-
const l2Tips = {
|
|
711
|
-
proposed: {
|
|
712
|
-
number: latestBlockNumber,
|
|
713
|
-
hash: latestBlockHeaderHash.toString()
|
|
714
|
-
},
|
|
715
|
-
proven: {
|
|
716
|
-
block: {
|
|
717
|
-
number: provenBlockNumber,
|
|
718
|
-
hash: provenBlockHeaderHash.toString()
|
|
719
|
-
},
|
|
720
|
-
checkpoint: makeCheckpointId(provenBlockCheckpoint)
|
|
721
|
-
},
|
|
722
|
-
finalized: {
|
|
723
|
-
block: {
|
|
724
|
-
number: finalizedBlockNumber,
|
|
725
|
-
hash: finalizedBlockHeaderHash.toString()
|
|
726
|
-
},
|
|
727
|
-
checkpoint: makeCheckpointId(finalizedBlockCheckpoint)
|
|
728
|
-
},
|
|
729
|
-
checkpointed: {
|
|
730
|
-
block: {
|
|
731
|
-
number: checkpointedBlockNumber,
|
|
732
|
-
hash: checkpointedBlockHeaderHash.toString()
|
|
733
|
-
},
|
|
734
|
-
checkpoint: makeCheckpointId(checkpointedBlockCheckpoint)
|
|
735
|
-
}
|
|
736
|
-
};
|
|
737
|
-
return l2Tips;
|
|
845
|
+
getL2Tips() {
|
|
846
|
+
return this.l2TipsCache.getL2Tips();
|
|
738
847
|
}
|
|
739
848
|
async rollbackTo(targetL2BlockNumber) {
|
|
740
|
-
// TODO(pw/mbps): This still assumes 1 block per checkpoint
|
|
741
849
|
const currentBlocks = await this.getL2Tips();
|
|
742
850
|
const currentL2Block = currentBlocks.proposed.number;
|
|
743
851
|
const currentProvenBlock = currentBlocks.proven.block.number;
|
|
744
852
|
if (targetL2BlockNumber >= currentL2Block) {
|
|
745
853
|
throw new Error(`Target L2 block ${targetL2BlockNumber} must be less than current L2 block ${currentL2Block}`);
|
|
746
854
|
}
|
|
747
|
-
const
|
|
748
|
-
if (
|
|
855
|
+
const checkpointedTip = await this.stores.blocks.getCheckpointedL2BlockNumber();
|
|
856
|
+
if (targetL2BlockNumber > checkpointedTip) {
|
|
857
|
+
throw new Error(`Target L2 block ${targetL2BlockNumber} is not checkpointed yet`);
|
|
858
|
+
}
|
|
859
|
+
const targetBlockData = await this.stores.blocks.getBlockData({
|
|
860
|
+
number: targetL2BlockNumber
|
|
861
|
+
});
|
|
862
|
+
if (!targetBlockData) {
|
|
749
863
|
throw new Error(`Target L2 block ${targetL2BlockNumber} not found`);
|
|
750
864
|
}
|
|
751
|
-
const
|
|
752
|
-
|
|
865
|
+
const targetCheckpointNumber = targetBlockData.checkpointNumber;
|
|
866
|
+
// Rollback operates at checkpoint granularity: the target block must be the last block of its checkpoint.
|
|
867
|
+
const checkpointData = await this.stores.blocks.getCheckpointData(targetCheckpointNumber);
|
|
868
|
+
if (!checkpointData) {
|
|
869
|
+
throw new Error(`Checkpoint ${targetCheckpointNumber} not found for block ${targetL2BlockNumber}`);
|
|
870
|
+
}
|
|
871
|
+
const lastBlockInCheckpoint = BlockNumber(checkpointData.startBlock + checkpointData.blockCount - 1);
|
|
872
|
+
if (targetL2BlockNumber !== lastBlockInCheckpoint) {
|
|
873
|
+
const previousCheckpointBoundary = checkpointData.startBlock > 1 ? BlockNumber(checkpointData.startBlock - 1) : BlockNumber(0);
|
|
874
|
+
throw new Error(`Target L2 block ${targetL2BlockNumber} is not at a checkpoint boundary. ` + `Checkpoint ${targetCheckpointNumber} spans blocks ${checkpointData.startBlock} to ${lastBlockInCheckpoint}. ` + `Use block ${lastBlockInCheckpoint} to roll back to this checkpoint, ` + `or block ${previousCheckpointBoundary} to roll back to the previous one.`);
|
|
875
|
+
}
|
|
876
|
+
const targetL1BlockNumber = checkpointData.l1.blockNumber;
|
|
753
877
|
const targetL1Block = await this.publicClient.getBlock({
|
|
754
878
|
blockNumber: targetL1BlockNumber,
|
|
755
879
|
includeTransactions: false
|
|
@@ -761,21 +885,21 @@ _dec = trackSpan('Archiver.sync');
|
|
|
761
885
|
this.log.info(`Removing checkpoints after checkpoint ${targetCheckpointNumber} (target block ${targetL2BlockNumber})`);
|
|
762
886
|
await this.updater.removeCheckpointsAfter(targetCheckpointNumber);
|
|
763
887
|
this.log.info(`Rolling back L1 to L2 messages to checkpoint ${targetCheckpointNumber}`);
|
|
764
|
-
await this.
|
|
888
|
+
await this.stores.messages.rollbackL1ToL2MessagesToCheckpoint(targetCheckpointNumber);
|
|
765
889
|
this.log.info(`Setting L1 syncpoints to ${targetL1BlockNumber}`);
|
|
766
|
-
await this.
|
|
767
|
-
await this.
|
|
890
|
+
await this.stores.blocks.setSynchedL1BlockNumber(targetL1BlockNumber);
|
|
891
|
+
await this.stores.messages.setMessageSyncState({
|
|
768
892
|
l1BlockNumber: targetL1BlockNumber,
|
|
769
893
|
l1BlockHash: targetL1BlockHash
|
|
770
|
-
});
|
|
894
|
+
}, undefined);
|
|
771
895
|
if (targetL2BlockNumber < currentProvenBlock) {
|
|
772
|
-
this.log.info(`
|
|
773
|
-
await this.
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
896
|
+
this.log.info(`Rolling back proven L2 checkpoint to ${targetCheckpointNumber}`);
|
|
897
|
+
await this.updater.setProvenCheckpointNumber(targetCheckpointNumber);
|
|
898
|
+
}
|
|
899
|
+
const currentFinalizedBlock = currentBlocks.finalized.block.number;
|
|
900
|
+
if (targetL2BlockNumber < currentFinalizedBlock) {
|
|
901
|
+
this.log.info(`Rolling back finalized L2 checkpoint to ${targetCheckpointNumber}`);
|
|
902
|
+
await this.updater.setFinalizedCheckpointNumber(targetCheckpointNumber);
|
|
903
|
+
}
|
|
780
904
|
}
|
|
781
905
|
}
|
package/dest/config.d.ts
CHANGED
|
@@ -24,7 +24,10 @@ export declare function mapArchiverConfig(config: Partial<ArchiverConfig>): {
|
|
|
24
24
|
pollingIntervalMs: number | undefined;
|
|
25
25
|
batchSize: number | undefined;
|
|
26
26
|
skipValidateCheckpointAttestations: boolean | undefined;
|
|
27
|
+
skipPromoteProposedCheckpointDuringL1Sync: boolean | undefined;
|
|
27
28
|
maxAllowedEthClientDriftSeconds: number | undefined;
|
|
28
29
|
ethereumAllowNoDebugHosts: boolean | undefined;
|
|
30
|
+
skipHistoricalLogsCheck: boolean | undefined;
|
|
31
|
+
orphanProposedBlockPruneGraceSeconds: number | undefined;
|
|
29
32
|
};
|
|
30
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
33
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxLQUFLLGdCQUFnQixFQUEyQixNQUFNLGtDQUFrQyxDQUFDO0FBQ2xHLE9BQU8sRUFBRSxLQUFLLGlCQUFpQixFQUE2QixNQUFNLHdCQUF3QixDQUFDO0FBQzNGLE9BQU8sRUFBRSxLQUFLLGNBQWMsRUFBMEIsTUFBTSwyQkFBMkIsQ0FBQztBQUN4RixPQUFPLEVBQ0wsS0FBSyxrQkFBa0IsRUFLeEIsTUFBTSwwQkFBMEIsQ0FBQztBQUNsQyxPQUFPLEVBQUUsS0FBSyxXQUFXLEVBQXVCLE1BQU0sc0JBQXNCLENBQUM7QUFDN0UsT0FBTyxLQUFLLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUU5RTs7Ozs7O0dBTUc7QUFDSCxNQUFNLE1BQU0sY0FBYyxHQUFHLHNCQUFzQixHQUNqRCxjQUFjLEdBQ2QsaUJBQWlCLEdBQ2pCLGdCQUFnQixHQUNoQixXQUFXLENBQUM7QUFFZCxlQUFPLE1BQU0sc0JBQXNCLEVBQUUsa0JBQWtCLENBQUMsY0FBYyxDQTBEckUsQ0FBQztBQUVGOzs7O0dBSUc7QUFDSCx3QkFBZ0Isd0JBQXdCLElBQUksY0FBYyxDQUV6RDtBQUVELGdGQUFnRjtBQUNoRix3QkFBZ0IsaUJBQWlCLENBQUMsTUFBTSxFQUFFLE9BQU8sQ0FBQyxjQUFjLENBQUM7Ozs7Ozs7OztFQVdoRSJ9
|
package/dest/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAA2B,MAAM,kCAAkC,CAAC;AAClG,OAAO,EAAE,KAAK,iBAAiB,EAA6B,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAA2B,MAAM,kCAAkC,CAAC;AAClG,OAAO,EAAE,KAAK,iBAAiB,EAA6B,MAAM,wBAAwB,CAAC;AAC3F,OAAO,EAAE,KAAK,cAAc,EAA0B,MAAM,2BAA2B,CAAC;AACxF,OAAO,EACL,KAAK,kBAAkB,EAKxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,WAAW,EAAuB,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAE9E;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,sBAAsB,GACjD,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,WAAW,CAAC;AAEd,eAAO,MAAM,sBAAsB,EAAE,kBAAkB,CAAC,cAAc,CA0DrE,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,cAAc,CAEzD;AAED,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC;;;;;;;;;EAWhE"}
|