@aztec/archiver 0.0.1-commit.ec5f612 → 0.0.1-commit.ec7ac5448
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 +12 -6
- package/dest/archiver.d.ts +8 -7
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +77 -26
- package/dest/config.d.ts +3 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +2 -1
- package/dest/errors.d.ts +34 -10
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +45 -16
- package/dest/factory.d.ts +4 -5
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +24 -21
- package/dest/l1/calldata_retriever.d.ts +1 -1
- package/dest/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/l1/calldata_retriever.js +2 -1
- package/dest/l1/data_retrieval.d.ts +3 -3
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +14 -15
- package/dest/modules/data_source_base.d.ts +8 -6
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +11 -5
- package/dest/modules/data_store_updater.d.ts +18 -12
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +87 -77
- package/dest/modules/instrumentation.d.ts +4 -2
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +17 -6
- package/dest/modules/l1_synchronizer.d.ts +4 -2
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +166 -129
- package/dest/modules/validation.d.ts +1 -1
- package/dest/modules/validation.d.ts.map +1 -1
- package/dest/modules/validation.js +2 -2
- package/dest/store/block_store.d.ts +50 -16
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +288 -119
- package/dest/store/contract_class_store.d.ts +2 -3
- package/dest/store/contract_class_store.d.ts.map +1 -1
- package/dest/store/contract_class_store.js +7 -67
- 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 +45 -22
- package/dest/store/kv_archiver_store.d.ts.map +1 -1
- package/dest/store/kv_archiver_store.js +57 -27
- package/dest/store/l2_tips_cache.d.ts +2 -1
- package/dest/store/l2_tips_cache.d.ts.map +1 -1
- package/dest/store/l2_tips_cache.js +25 -5
- package/dest/store/log_store.d.ts +6 -3
- package/dest/store/log_store.d.ts.map +1 -1
- package/dest/store/log_store.js +93 -16
- package/dest/store/message_store.d.ts +5 -1
- package/dest/store/message_store.d.ts.map +1 -1
- package/dest/store/message_store.js +21 -9
- package/dest/test/fake_l1_state.d.ts +16 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +77 -8
- 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 +10 -4
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +35 -7
- 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 -2
- package/package.json +13 -13
- package/src/archiver.ts +98 -31
- package/src/config.ts +8 -1
- package/src/errors.ts +70 -26
- package/src/factory.ts +23 -15
- package/src/l1/calldata_retriever.ts +2 -1
- package/src/l1/data_retrieval.ts +8 -12
- package/src/modules/data_source_base.ts +26 -7
- package/src/modules/data_store_updater.ts +96 -107
- package/src/modules/instrumentation.ts +19 -7
- package/src/modules/l1_synchronizer.ts +189 -161
- package/src/modules/validation.ts +2 -2
- package/src/store/block_store.ts +370 -140
- package/src/store/contract_class_store.ts +8 -106
- package/src/store/contract_instance_store.ts +8 -5
- package/src/store/kv_archiver_store.ts +81 -39
- package/src/store/l2_tips_cache.ts +50 -11
- package/src/store/log_store.ts +126 -27
- package/src/store/message_store.ts +27 -10
- package/src/structs/inbox_message.ts +1 -1
- package/src/test/fake_l1_state.ts +103 -13
- package/src/test/mock_l1_to_l2_message_source.ts +1 -0
- package/src/test/mock_l2_block_source.ts +52 -5
- package/src/test/mock_structs.ts +20 -6
- package/src/test/noop_l1_archiver.ts +7 -2
|
@@ -371,20 +371,23 @@ 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, _dec1, _dec2, _dec3, _initProto;
|
|
374
|
+
import { asyncPool } from '@aztec/foundation/async-pool';
|
|
374
375
|
import { maxBigint } from '@aztec/foundation/bigint';
|
|
375
376
|
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
376
|
-
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
377
|
+
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
|
|
377
378
|
import { pick } from '@aztec/foundation/collection';
|
|
378
379
|
import { createLogger } from '@aztec/foundation/log';
|
|
380
|
+
import { retryTimes } from '@aztec/foundation/retry';
|
|
379
381
|
import { count } from '@aztec/foundation/string';
|
|
380
382
|
import { Timer, elapsed } from '@aztec/foundation/timer';
|
|
381
|
-
import { isDefined } from '@aztec/foundation/types';
|
|
383
|
+
import { isDefined, isErrorClass } from '@aztec/foundation/types';
|
|
382
384
|
import { L2BlockSourceEvents } from '@aztec/stdlib/block';
|
|
383
385
|
import { getEpochAtSlot, getSlotAtNextL1Block } from '@aztec/stdlib/epoch-helpers';
|
|
384
386
|
import { computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
|
|
385
387
|
import { execInSpan, trackSpan } from '@aztec/telemetry-client';
|
|
386
388
|
import { InitialCheckpointNumberNotSequentialError } from '../errors.js';
|
|
387
389
|
import { retrieveCheckpointsFromRollup, retrieveL1ToL2Message, retrieveL1ToL2Messages, retrievedToPublishedCheckpoint } from '../l1/data_retrieval.js';
|
|
390
|
+
import { MessageStoreError } from '../store/message_store.js';
|
|
388
391
|
import { ArchiverDataStoreUpdater } from './data_store_updater.js';
|
|
389
392
|
import { validateCheckpointAttestations } from './validation.js';
|
|
390
393
|
_dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpochPrune'), _dec2 = trackSpan('Archiver.handleL1ToL2Messages'), _dec3 = trackSpan('Archiver.handleCheckpoints');
|
|
@@ -449,7 +452,9 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
449
452
|
this.events = events;
|
|
450
453
|
this.log = log;
|
|
451
454
|
_initProto(this);
|
|
452
|
-
this.updater = new ArchiverDataStoreUpdater(this.store, l2TipsCache
|
|
455
|
+
this.updater = new ArchiverDataStoreUpdater(this.store, l2TipsCache, {
|
|
456
|
+
rollupManaLimit: l1Constants.rollupManaLimit
|
|
457
|
+
});
|
|
453
458
|
this.tracer = tracer;
|
|
454
459
|
}
|
|
455
460
|
/** Sets new config */ setConfig(newConfig) {
|
|
@@ -475,12 +480,20 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
475
480
|
}
|
|
476
481
|
}
|
|
477
482
|
async syncFromL1(initialSyncComplete) {
|
|
483
|
+
// In between the various calls to L1, the block number can move meaning some of the following
|
|
484
|
+
// calls will return data for blocks that were not present during earlier calls. To combat this
|
|
485
|
+
// we ensure that all data retrieval methods only retrieve data up to the currentBlockNumber
|
|
486
|
+
// captured at the top of this function.
|
|
478
487
|
const currentL1Block = await this.publicClient.getBlock({
|
|
479
488
|
includeTransactions: false
|
|
480
489
|
});
|
|
481
490
|
const currentL1BlockNumber = currentL1Block.number;
|
|
482
491
|
const currentL1BlockHash = Buffer32.fromString(currentL1Block.hash);
|
|
483
492
|
const currentL1Timestamp = currentL1Block.timestamp;
|
|
493
|
+
const currentL1BlockData = {
|
|
494
|
+
l1BlockNumber: currentL1BlockNumber,
|
|
495
|
+
l1BlockHash: currentL1BlockHash
|
|
496
|
+
};
|
|
484
497
|
if (this.l1BlockHash && currentL1BlockHash.equals(this.l1BlockHash)) {
|
|
485
498
|
this.log.trace(`No new L1 blocks since last sync at L1 block ${this.l1BlockNumber}`);
|
|
486
499
|
return;
|
|
@@ -496,36 +509,16 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
496
509
|
maxAllowedDelay
|
|
497
510
|
});
|
|
498
511
|
}
|
|
499
|
-
// Load sync point for blocks
|
|
500
|
-
const { blocksSynchedTo = this.l1Constants.l1StartBlock
|
|
501
|
-
l1BlockNumber: this.l1Constants.l1StartBlock,
|
|
502
|
-
l1BlockHash: this.l1Constants.l1StartBlockHash
|
|
503
|
-
} } = await this.store.getSynchPoint();
|
|
512
|
+
// Load sync point for blocks defaulting to start block
|
|
513
|
+
const { blocksSynchedTo = this.l1Constants.l1StartBlock } = await this.store.getSynchPoint();
|
|
504
514
|
this.log.debug(`Starting new archiver sync iteration`, {
|
|
505
515
|
blocksSynchedTo,
|
|
506
|
-
|
|
507
|
-
currentL1BlockNumber,
|
|
508
|
-
currentL1BlockHash
|
|
516
|
+
currentL1BlockData
|
|
509
517
|
});
|
|
510
|
-
//
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
* to ensure that data is read exactly once.
|
|
515
|
-
*
|
|
516
|
-
* The first is the problem of eventually consistent ETH service providers like Infura.
|
|
517
|
-
* Each L1 read operation will query data from the last L1 block that it saw emit its kind of data.
|
|
518
|
-
* (so pending L1 to L2 messages will read from the last L1 block that emitted a message and so on)
|
|
519
|
-
* This will mean the archiver will lag behind L1 and will only advance when there's L2-relevant activity on the chain.
|
|
520
|
-
*
|
|
521
|
-
* The second is that in between the various calls to L1, the block number can move meaning some
|
|
522
|
-
* of the following calls will return data for blocks that were not present during earlier calls.
|
|
523
|
-
* To combat this for the time being we simply ensure that all data retrieval methods only retrieve
|
|
524
|
-
* data up to the currentBlockNumber captured at the top of this function. We might want to improve on this
|
|
525
|
-
* in future but for the time being it should give us the guarantees that we need
|
|
526
|
-
*/ // ********** Events that are processed per L1 block **********
|
|
527
|
-
await this.handleL1ToL2Messages(messagesSynchedTo, currentL1BlockNumber);
|
|
528
|
-
// ********** Events that are processed per checkpoint **********
|
|
518
|
+
// Sync L1 to L2 messages. We retry this a few times since there are error conditions that reset the sync point, requiring a new iteration.
|
|
519
|
+
// Note that we cannot just wait for the l1 synchronizer to loop again, since the synchronizer would report as synced up to the current L1
|
|
520
|
+
// block, when that wouldn't be the case, since L1 to L2 messages would need another iteration.
|
|
521
|
+
await retryTimes(()=>this.handleL1ToL2Messages(currentL1BlockData), 'Handling L1 to L2 messages', 3, 0.1);
|
|
529
522
|
if (currentL1BlockNumber > blocksSynchedTo) {
|
|
530
523
|
// First we retrieve new checkpoints and L2 blocks and store them in the DB. This will also update the
|
|
531
524
|
// pending chain validation status, proven checkpoint number, and synched L1 block number.
|
|
@@ -553,6 +546,8 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
553
546
|
}
|
|
554
547
|
this.instrumentation.updateL1BlockHeight(currentL1BlockNumber);
|
|
555
548
|
}
|
|
549
|
+
// Update the finalized L2 checkpoint based on L1 finality.
|
|
550
|
+
await this.updateFinalizedCheckpoint();
|
|
556
551
|
// After syncing has completed, update the current l1 block number and timestamp,
|
|
557
552
|
// otherwise we risk announcing to the world that we've synced to a given point,
|
|
558
553
|
// but the corresponding blocks have not been processed (see #12631).
|
|
@@ -566,6 +561,31 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
566
561
|
l1BlockNumberAtEnd
|
|
567
562
|
});
|
|
568
563
|
}
|
|
564
|
+
/** Query L1 for its finalized block and update the finalized checkpoint accordingly. */ async updateFinalizedCheckpoint() {
|
|
565
|
+
try {
|
|
566
|
+
const finalizedL1Block = await this.publicClient.getBlock({
|
|
567
|
+
blockTag: 'finalized',
|
|
568
|
+
includeTransactions: false
|
|
569
|
+
});
|
|
570
|
+
const finalizedL1BlockNumber = finalizedL1Block.number;
|
|
571
|
+
const finalizedCheckpointNumber = await this.rollup.getProvenCheckpointNumber({
|
|
572
|
+
blockNumber: finalizedL1BlockNumber
|
|
573
|
+
});
|
|
574
|
+
const localFinalizedCheckpointNumber = await this.store.getFinalizedCheckpointNumber();
|
|
575
|
+
if (localFinalizedCheckpointNumber !== finalizedCheckpointNumber) {
|
|
576
|
+
await this.updater.setFinalizedCheckpointNumber(finalizedCheckpointNumber);
|
|
577
|
+
this.log.info(`Updated finalized chain to checkpoint ${finalizedCheckpointNumber}`, {
|
|
578
|
+
finalizedCheckpointNumber,
|
|
579
|
+
finalizedL1BlockNumber
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
} catch (err) {
|
|
583
|
+
// The rollup contract may not exist at the finalized L1 block right after deployment.
|
|
584
|
+
if (!err?.message?.includes('returned no data')) {
|
|
585
|
+
this.log.warn(`Failed to update finalized checkpoint: ${err}`);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
569
589
|
/** Prune all proposed local blocks that should have been checkpointed by now. */ async pruneUncheckpointedBlocks(currentL1Timestamp) {
|
|
570
590
|
const [lastCheckpointedBlockNumber, lastProposedBlockNumber] = await Promise.all([
|
|
571
591
|
this.store.getCheckpointedL2BlockNumber(),
|
|
@@ -576,26 +596,28 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
576
596
|
this.log.trace(`No uncheckpointed blocks to prune.`);
|
|
577
597
|
return;
|
|
578
598
|
}
|
|
579
|
-
// What's the slot
|
|
599
|
+
// What's the slot at the next L1 block? All blocks for slots strictly before this one should've been checkpointed by now.
|
|
600
|
+
const slotAtNextL1Block = getSlotAtNextL1Block(currentL1Timestamp, this.l1Constants);
|
|
580
601
|
const firstUncheckpointedBlockNumber = BlockNumber(lastCheckpointedBlockNumber + 1);
|
|
602
|
+
// What's the slot of the first uncheckpointed block?
|
|
581
603
|
const [firstUncheckpointedBlockHeader] = await this.store.getBlockHeaders(firstUncheckpointedBlockNumber, 1);
|
|
582
604
|
const firstUncheckpointedBlockSlot = firstUncheckpointedBlockHeader?.getSlot();
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
605
|
+
if (firstUncheckpointedBlockSlot === undefined || firstUncheckpointedBlockSlot >= slotAtNextL1Block) {
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
// Prune provisional blocks from slots that have ended without being checkpointed.
|
|
609
|
+
// This also clears any proposed checkpoint whose blocks are being pruned.
|
|
610
|
+
this.log.warn(`Pruning blocks after block ${lastCheckpointedBlockNumber} due to slot ${firstUncheckpointedBlockSlot} not being checkpointed`, {
|
|
611
|
+
firstUncheckpointedBlockHeader: firstUncheckpointedBlockHeader.toInspect(),
|
|
612
|
+
slotAtNextL1Block
|
|
613
|
+
});
|
|
614
|
+
const prunedBlocks = await this.updater.removeUncheckpointedBlocksAfter(lastCheckpointedBlockNumber);
|
|
615
|
+
if (prunedBlocks.length > 0) {
|
|
616
|
+
this.events.emit(L2BlockSourceEvents.L2PruneUncheckpointed, {
|
|
617
|
+
type: L2BlockSourceEvents.L2PruneUncheckpointed,
|
|
618
|
+
slotNumber: firstUncheckpointedBlockSlot,
|
|
619
|
+
blocks: prunedBlocks
|
|
590
620
|
});
|
|
591
|
-
const prunedBlocks = await this.updater.removeUncheckpointedBlocksAfter(lastCheckpointedBlockNumber);
|
|
592
|
-
if (prunedBlocks.length > 0) {
|
|
593
|
-
this.events.emit(L2BlockSourceEvents.L2PruneUncheckpointed, {
|
|
594
|
-
type: L2BlockSourceEvents.L2PruneUncheckpointed,
|
|
595
|
-
slotNumber: firstUncheckpointedBlockSlot,
|
|
596
|
-
blocks: prunedBlocks
|
|
597
|
-
});
|
|
598
|
-
}
|
|
599
621
|
}
|
|
600
622
|
}
|
|
601
623
|
/** Queries the rollup contract on whether a prune can be executed on the immediate next L1 block. */ async canPrune(currentL1BlockNumber, currentL1Timestamp) {
|
|
@@ -626,12 +648,14 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
626
648
|
const pruneFromSlotNumber = header.slotNumber;
|
|
627
649
|
const pruneFromEpochNumber = getEpochAtSlot(pruneFromSlotNumber, this.l1Constants);
|
|
628
650
|
const checkpointsToUnwind = localPendingCheckpointNumber - provenCheckpointNumber;
|
|
629
|
-
|
|
651
|
+
// Fetch checkpoints and blocks in bounded batches to avoid unbounded concurrent
|
|
652
|
+
// promises when the gap between local pending and proven checkpoint numbers is large.
|
|
653
|
+
const BATCH_SIZE = 10;
|
|
654
|
+
const indices = Array.from({
|
|
630
655
|
length: checkpointsToUnwind
|
|
631
|
-
}
|
|
632
|
-
const checkpoints = await
|
|
633
|
-
const
|
|
634
|
-
const newBlocks = blockPromises.filter(isDefined).flat();
|
|
656
|
+
}, (_, i)=>CheckpointNumber(i + pruneFrom));
|
|
657
|
+
const checkpoints = (await asyncPool(BATCH_SIZE, indices, (idx)=>this.store.getCheckpointData(idx))).filter(isDefined);
|
|
658
|
+
const newBlocks = (await asyncPool(BATCH_SIZE, checkpoints, (cp)=>this.store.getBlocksForCheckpoint(CheckpointNumber(cp.checkpointNumber)))).filter(isDefined).flat();
|
|
635
659
|
// Emit an event for listening services to react to the chain prune
|
|
636
660
|
this.events.emit(L2BlockSourceEvents.L2PruneUnproven, {
|
|
637
661
|
type: L2BlockSourceEvents.L2PruneUnproven,
|
|
@@ -665,55 +689,75 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
665
689
|
nextEnd
|
|
666
690
|
];
|
|
667
691
|
}
|
|
668
|
-
async handleL1ToL2Messages(
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
692
|
+
async handleL1ToL2Messages(currentL1Block) {
|
|
693
|
+
// Load the syncpoint, which may have been updated in a previous iteration
|
|
694
|
+
const { messagesSynchedTo = {
|
|
695
|
+
l1BlockNumber: this.l1Constants.l1StartBlock,
|
|
696
|
+
l1BlockHash: this.l1Constants.l1StartBlockHash
|
|
697
|
+
} } = await this.store.getSynchPoint();
|
|
698
|
+
// Nothing to do if L1 block number has not moved forward
|
|
699
|
+
const currentL1BlockNumber = currentL1Block.l1BlockNumber;
|
|
700
|
+
if (currentL1BlockNumber <= messagesSynchedTo.l1BlockNumber) {
|
|
701
|
+
return true;
|
|
672
702
|
}
|
|
673
|
-
//
|
|
674
|
-
const localMessagesInserted = await this.store.getTotalL1ToL2MessageCount();
|
|
675
|
-
const localLastMessage = await this.store.getLastL1ToL2Message();
|
|
703
|
+
// Compare local message store state with the remote. If they match, we just advance the match pointer.
|
|
676
704
|
const remoteMessagesState = await this.inbox.getState({
|
|
677
705
|
blockNumber: currentL1BlockNumber
|
|
678
706
|
});
|
|
679
|
-
this.
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
remoteMessagesState
|
|
683
|
-
|
|
684
|
-
// Compare message count and rolling hash. If they match, no need to retrieve anything.
|
|
685
|
-
if (remoteMessagesState.totalMessagesInserted === localMessagesInserted && remoteMessagesState.messagesRollingHash.equals(localLastMessage?.rollingHash ?? Buffer32.ZERO)) {
|
|
686
|
-
this.log.trace(`No L1 to L2 messages to query between L1 blocks ${messagesSyncPoint.l1BlockNumber} and ${currentL1BlockNumber}.`);
|
|
687
|
-
return;
|
|
707
|
+
const localLastMessage = await this.store.getLastL1ToL2Message();
|
|
708
|
+
if (await this.localStateMatches(localLastMessage, remoteMessagesState)) {
|
|
709
|
+
this.log.trace(`Local L1 to L2 messages are already in sync with remote at L1 block ${currentL1BlockNumber}`);
|
|
710
|
+
await this.store.setMessageSyncState(currentL1Block, remoteMessagesState.treeInProgress);
|
|
711
|
+
return true;
|
|
688
712
|
}
|
|
689
|
-
//
|
|
690
|
-
//
|
|
691
|
-
//
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
this.
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
this.log.warn(`Rolling back L1 to L2 messages due to hash mismatch or msg not found.`, {
|
|
700
|
-
remoteLastMessage,
|
|
701
|
-
messagesSyncPoint,
|
|
702
|
-
localLastMessage
|
|
703
|
-
});
|
|
704
|
-
messagesSyncPoint = await this.rollbackL1ToL2Messages(localLastMessage, messagesSyncPoint);
|
|
705
|
-
this.log.debug(`Rolled back L1 to L2 messages to L1 block ${messagesSyncPoint.l1BlockNumber}.`, {
|
|
706
|
-
messagesSyncPoint
|
|
713
|
+
// If not, then we are out of sync. Most likely there are new messages on the inbox, so we try retrieving them.
|
|
714
|
+
// However, it could also be the case that there was an L1 reorg and our syncpoint is no longer valid.
|
|
715
|
+
// If that's the case, we'd get an exception out of the message store since the rolling hash of the first message
|
|
716
|
+
// we try to insert would not match the one in the db, in which case we rollback to the last common message with L1.
|
|
717
|
+
try {
|
|
718
|
+
await this.retrieveAndStoreMessages(messagesSynchedTo.l1BlockNumber, currentL1BlockNumber);
|
|
719
|
+
} catch (error) {
|
|
720
|
+
if (isErrorClass(error, MessageStoreError)) {
|
|
721
|
+
this.log.warn(`Failed to store L1 to L2 messages retrieved from L1: ${error.message}. Rolling back syncpoint to retry.`, {
|
|
722
|
+
inboxMessage: error.inboxMessage
|
|
707
723
|
});
|
|
724
|
+
await this.rollbackL1ToL2Messages(remoteMessagesState.treeInProgress);
|
|
725
|
+
return false;
|
|
708
726
|
}
|
|
727
|
+
throw error;
|
|
709
728
|
}
|
|
710
|
-
//
|
|
729
|
+
// Note that, if there are no new messages to insert, but there was an L1 reorg that pruned out last messages,
|
|
730
|
+
// we'd notice by comparing our local state with the remote one again, and seeing they don't match even after
|
|
731
|
+
// our sync attempt. In this case, we also rollback our syncpoint, and trigger a retry.
|
|
732
|
+
const localLastMessageAfterSync = await this.store.getLastL1ToL2Message();
|
|
733
|
+
if (!await this.localStateMatches(localLastMessageAfterSync, remoteMessagesState)) {
|
|
734
|
+
this.log.warn(`Local L1 to L2 messages state does not match remote after sync attempt. Rolling back syncpoint to retry.`, {
|
|
735
|
+
localLastMessageAfterSync,
|
|
736
|
+
remoteMessagesState
|
|
737
|
+
});
|
|
738
|
+
await this.rollbackL1ToL2Messages(remoteMessagesState.treeInProgress);
|
|
739
|
+
return false;
|
|
740
|
+
}
|
|
741
|
+
// Advance the syncpoint after a successful sync
|
|
742
|
+
await this.store.setMessageSyncState(currentL1Block, remoteMessagesState.treeInProgress);
|
|
743
|
+
return true;
|
|
744
|
+
}
|
|
745
|
+
/** Checks if the local rolling hash and message count matches the remote state */ async localStateMatches(localLastMessage, remoteState) {
|
|
746
|
+
const localMessageCount = await this.store.getTotalL1ToL2MessageCount();
|
|
747
|
+
this.log.trace(`Comparing local and remote inbox state`, {
|
|
748
|
+
localMessageCount,
|
|
749
|
+
localLastMessage,
|
|
750
|
+
remoteState
|
|
751
|
+
});
|
|
752
|
+
return remoteState.totalMessagesInserted === localMessageCount && remoteState.messagesRollingHash.equals(localLastMessage?.rollingHash ?? Buffer16.ZERO);
|
|
753
|
+
}
|
|
754
|
+
/** Retrieves L1 to L2 messages from L1 in batches and stores them. */ async retrieveAndStoreMessages(fromL1Block, toL1Block) {
|
|
711
755
|
let searchStartBlock = 0n;
|
|
712
|
-
let searchEndBlock =
|
|
756
|
+
let searchEndBlock = fromL1Block;
|
|
713
757
|
let lastMessage;
|
|
714
758
|
let messageCount = 0;
|
|
715
759
|
do {
|
|
716
|
-
[searchStartBlock, searchEndBlock] = this.nextRange(searchEndBlock,
|
|
760
|
+
[searchStartBlock, searchEndBlock] = this.nextRange(searchEndBlock, toL1Block);
|
|
717
761
|
this.log.trace(`Retrieving L1 to L2 messages in L1 blocks ${searchStartBlock}-${searchEndBlock}`);
|
|
718
762
|
const messages = await retrieveL1ToL2Messages(this.inbox, searchStartBlock, searchEndBlock);
|
|
719
763
|
const timer = new Timer();
|
|
@@ -728,74 +772,65 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
728
772
|
lastMessage = msg;
|
|
729
773
|
messageCount++;
|
|
730
774
|
}
|
|
731
|
-
}while (searchEndBlock <
|
|
732
|
-
// Log stats for messages retrieved (if any).
|
|
775
|
+
}while (searchEndBlock < toL1Block)
|
|
733
776
|
if (messageCount > 0) {
|
|
734
777
|
this.log.info(`Retrieved ${messageCount} new L1 to L2 messages up to message with index ${lastMessage?.index} for checkpoint ${lastMessage?.checkpointNumber}`, {
|
|
735
778
|
lastMessage,
|
|
736
779
|
messageCount
|
|
737
780
|
});
|
|
738
781
|
}
|
|
739
|
-
// Warn if the resulting rolling hash does not match the remote state we had retrieved.
|
|
740
|
-
if (lastMessage && !lastMessage.rollingHash.equals(remoteMessagesState.messagesRollingHash)) {
|
|
741
|
-
this.log.warn(`Last message retrieved rolling hash does not match remote state.`, {
|
|
742
|
-
lastMessage,
|
|
743
|
-
remoteMessagesState
|
|
744
|
-
});
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
async retrieveL1ToL2Message(leaf) {
|
|
748
|
-
const currentL1BlockNumber = await this.publicClient.getBlockNumber();
|
|
749
|
-
let searchStartBlock = 0n;
|
|
750
|
-
let searchEndBlock = this.l1Constants.l1StartBlock - 1n;
|
|
751
|
-
do {
|
|
752
|
-
[searchStartBlock, searchEndBlock] = this.nextRange(searchEndBlock, currentL1BlockNumber);
|
|
753
|
-
const message = await retrieveL1ToL2Message(this.inbox, leaf, searchStartBlock, searchEndBlock);
|
|
754
|
-
if (message) {
|
|
755
|
-
return message;
|
|
756
|
-
}
|
|
757
|
-
}while (searchEndBlock < currentL1BlockNumber)
|
|
758
|
-
return undefined;
|
|
759
782
|
}
|
|
760
|
-
|
|
783
|
+
/**
|
|
784
|
+
* Rolls back local L1 to L2 messages to the last common message with L1, and updates the syncpoint to the L1 block of that message.
|
|
785
|
+
* If no common message is found, rolls back all messages and sets the syncpoint to the start block.
|
|
786
|
+
*/ async rollbackL1ToL2Messages(remoteTreeInProgress) {
|
|
761
787
|
// Slowly go back through our messages until we find the last common message.
|
|
762
788
|
// We could query the logs in batch as an optimization, but the depth of the reorg should not be deep, and this
|
|
763
789
|
// is a very rare case, so it's fine to query one log at a time.
|
|
764
790
|
let commonMsg;
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
791
|
+
let messagesToDelete = 0;
|
|
792
|
+
this.log.verbose(`Searching most recent common L1 to L2 message`);
|
|
793
|
+
for await (const localMsg of this.store.iterateL1ToL2Messages({
|
|
794
|
+
reverse: true
|
|
769
795
|
})){
|
|
770
|
-
const remoteMsg = await
|
|
796
|
+
const remoteMsg = await retrieveL1ToL2Message(this.inbox, localMsg);
|
|
771
797
|
const logCtx = {
|
|
772
798
|
remoteMsg,
|
|
773
|
-
localMsg:
|
|
799
|
+
localMsg: localMsg
|
|
774
800
|
};
|
|
775
|
-
if (remoteMsg && remoteMsg.rollingHash.equals(
|
|
776
|
-
this.log.verbose(`Found most recent common L1 to L2 message at index ${
|
|
801
|
+
if (remoteMsg && remoteMsg.rollingHash.equals(localMsg.rollingHash)) {
|
|
802
|
+
this.log.verbose(`Found most recent common L1 to L2 message at index ${localMsg.index} on L1 block ${localMsg.l1BlockNumber}`, logCtx);
|
|
777
803
|
commonMsg = remoteMsg;
|
|
778
804
|
break;
|
|
779
805
|
} else if (remoteMsg) {
|
|
780
|
-
this.log.debug(`Local L1 to L2 message with index ${
|
|
806
|
+
this.log.debug(`Local L1 to L2 message with index ${localMsg.index} has different rolling hash`, logCtx);
|
|
807
|
+
messagesToDelete++;
|
|
781
808
|
} else {
|
|
782
|
-
this.log.debug(`Local L1 to L2 message with index ${
|
|
809
|
+
this.log.debug(`Local L1 to L2 message with index ${localMsg.index} not found on L1`, logCtx);
|
|
810
|
+
messagesToDelete++;
|
|
783
811
|
}
|
|
784
812
|
}
|
|
785
|
-
// Delete everything after the common message we found.
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
813
|
+
// Delete everything after the common message we found, if anything needs to be deleted.
|
|
814
|
+
// Do not exit early if there are no messages to delete, we still want to update the syncpoint.
|
|
815
|
+
if (messagesToDelete > 0) {
|
|
816
|
+
const lastGoodIndex = commonMsg?.index;
|
|
817
|
+
this.log.warn(`Rolling back all local L1 to L2 messages after index ${lastGoodIndex ?? 'initial'}`);
|
|
818
|
+
await this.store.removeL1ToL2Messages(lastGoodIndex !== undefined ? lastGoodIndex + 1n : 0n);
|
|
819
|
+
}
|
|
789
820
|
// Update the syncpoint so the loop below reprocesses the changed messages. We go to the block before
|
|
790
821
|
// the last common one, so we force reprocessing it, in case new messages were added on that same L1 block
|
|
791
822
|
// after the last common message.
|
|
792
823
|
const syncPointL1BlockNumber = commonMsg ? commonMsg.l1BlockNumber - 1n : this.l1Constants.l1StartBlock;
|
|
793
824
|
const syncPointL1BlockHash = await this.getL1BlockHash(syncPointL1BlockNumber);
|
|
794
|
-
messagesSyncPoint = {
|
|
825
|
+
const messagesSyncPoint = {
|
|
795
826
|
l1BlockNumber: syncPointL1BlockNumber,
|
|
796
827
|
l1BlockHash: syncPointL1BlockHash
|
|
797
828
|
};
|
|
798
|
-
await this.store.
|
|
829
|
+
await this.store.setMessageSyncState(messagesSyncPoint, remoteTreeInProgress);
|
|
830
|
+
this.log.verbose(`Updated messages syncpoint to L1 block ${syncPointL1BlockNumber}`, {
|
|
831
|
+
...messagesSyncPoint,
|
|
832
|
+
remoteTreeInProgress
|
|
833
|
+
});
|
|
799
834
|
return messagesSyncPoint;
|
|
800
835
|
}
|
|
801
836
|
async getL1BlockHash(l1BlockNumber) {
|
|
@@ -1016,12 +1051,14 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
1016
1051
|
try {
|
|
1017
1052
|
const updatedValidationResult = rollupStatus.validationResult === initialValidationResult ? undefined : rollupStatus.validationResult;
|
|
1018
1053
|
const [processDuration, result] = await elapsed(()=>execInSpan(this.tracer, 'Archiver.addCheckpoints', ()=>this.updater.addCheckpoints(validCheckpoints, updatedValidationResult)));
|
|
1019
|
-
|
|
1054
|
+
if (validCheckpoints.length > 0) {
|
|
1055
|
+
this.instrumentation.processNewCheckpointedBlocks(processDuration / validCheckpoints.length, validCheckpoints.flatMap((c)=>c.checkpoint.blocks));
|
|
1056
|
+
}
|
|
1020
1057
|
// If blocks were pruned due to conflict with L1 checkpoints, emit event
|
|
1021
1058
|
if (result.prunedBlocks && result.prunedBlocks.length > 0) {
|
|
1022
1059
|
const prunedCheckpointNumber = result.prunedBlocks[0].checkpointNumber;
|
|
1023
1060
|
const prunedSlotNumber = result.prunedBlocks[0].header.globalVariables.slotNumber;
|
|
1024
|
-
this.log.
|
|
1061
|
+
this.log.info(`Pruned ${result.prunedBlocks.length} mismatching blocks for checkpoint ${prunedCheckpointNumber}`, {
|
|
1025
1062
|
prunedBlocks: result.prunedBlocks.map((b)=>b.toBlockInfo()),
|
|
1026
1063
|
prunedSlotNumber,
|
|
1027
1064
|
prunedCheckpointNumber
|
|
@@ -14,4 +14,4 @@ export declare function getAttestationInfoFromPublishedCheckpoint({ checkpoint,
|
|
|
14
14
|
* Returns true if the attestations are valid and sufficient, false otherwise.
|
|
15
15
|
*/
|
|
16
16
|
export declare function validateCheckpointAttestations(publishedCheckpoint: PublishedCheckpoint, epochCache: EpochCache, constants: Pick<L1RollupConstants, 'epochDuration'>, logger?: Logger): Promise<ValidateCheckpointResult>;
|
|
17
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGlvbi5kL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EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,wBAAwB,EAE9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/modules/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,wBAAwB,EAE9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,KAAK,iBAAiB,EAAiC,MAAM,6BAA6B,CAAC;AAGpG,YAAY,EAAE,wBAAwB,EAAE,CAAC;AAEzC;;;GAGG;AACH,wBAAgB,yCAAyC,CAAC,EACxD,UAAU,EACV,YAAY,EACb,EAAE,mBAAmB,GAAG,eAAe,EAAE,CAGzC;AAED;;;GAGG;AACH,wBAAsB,8BAA8B,CAClD,mBAAmB,EAAE,mBAAmB,EACxC,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,eAAe,CAAC,EACnD,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,wBAAwB,CAAC,CA2FnC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { compactArray } from '@aztec/foundation/collection';
|
|
2
2
|
import { getAttestationInfoFromPayload } from '@aztec/stdlib/block';
|
|
3
|
-
import { getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
|
|
3
|
+
import { computeQuorum, getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
|
|
4
4
|
import { ConsensusPayload } from '@aztec/stdlib/p2p';
|
|
5
5
|
/**
|
|
6
6
|
* Extracts attestation information from a published checkpoint.
|
|
@@ -46,7 +46,7 @@ import { ConsensusPayload } from '@aztec/stdlib/p2p';
|
|
|
46
46
|
valid: true
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
const requiredAttestationCount =
|
|
49
|
+
const requiredAttestationCount = computeQuorum(committee.length);
|
|
50
50
|
const failedValidationResult = (reason)=>({
|
|
51
51
|
valid: false,
|
|
52
52
|
reason,
|
|
@@ -3,8 +3,8 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import { type BlockData, BlockHash, CheckpointedL2Block, L2Block, type ValidateCheckpointResult } from '@aztec/stdlib/block';
|
|
6
|
-
import { type CheckpointData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
7
|
-
import type
|
|
6
|
+
import { type CheckpointData, type CommonCheckpointData, type ProposedCheckpointData, type ProposedCheckpointInput, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
7
|
+
import { type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
8
8
|
import { BlockHeader, type IndexedTxEffect, TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
9
9
|
export { TxReceipt, type TxEffect, type TxHash } from '@aztec/stdlib/tx';
|
|
10
10
|
export type RemoveCheckpointsResult = {
|
|
@@ -16,34 +16,39 @@ export type RemoveCheckpointsResult = {
|
|
|
16
16
|
export declare class BlockStore {
|
|
17
17
|
#private;
|
|
18
18
|
private db;
|
|
19
|
-
|
|
20
|
-
constructor(db: AztecAsyncKVStore, l1Constants: Pick<L1RollupConstants, 'epochDuration'>);
|
|
19
|
+
constructor(db: AztecAsyncKVStore);
|
|
21
20
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* TODO(#13569): Compute proper finalized block number based on L1 finalized block.
|
|
25
|
-
* TODO(palla/mbps): Even the provisional computation is wrong, since it should subtract checkpoints, not blocks
|
|
21
|
+
* Returns the finalized L2 block number. An L2 block is finalized when it was proven
|
|
22
|
+
* in an L1 block that has itself been finalized on Ethereum.
|
|
26
23
|
* @returns The finalized block number.
|
|
27
24
|
*/
|
|
28
25
|
getFinalizedL2BlockNumber(): Promise<BlockNumber>;
|
|
29
26
|
/**
|
|
30
|
-
* Append new proposed
|
|
31
|
-
*
|
|
27
|
+
* Append a new proposed block to the store.
|
|
28
|
+
* This is an uncheckpointed block that has been proposed by the sequencer but not yet included in a checkpoint on L1.
|
|
32
29
|
* For checkpointed blocks (already published to L1), use addCheckpoints() instead.
|
|
33
|
-
* @param
|
|
30
|
+
* @param block - The proposed L2 block to be added to the store.
|
|
34
31
|
* @returns True if the operation is successful.
|
|
35
32
|
*/
|
|
36
|
-
|
|
33
|
+
addProposedBlock(block: L2Block, opts?: {
|
|
37
34
|
force?: boolean;
|
|
38
35
|
}): Promise<boolean>;
|
|
39
36
|
/**
|
|
40
|
-
* Append new
|
|
37
|
+
* Append new checkpoints to the store's list.
|
|
41
38
|
* @param checkpoints - The L2 checkpoints to be added to the store.
|
|
42
39
|
* @returns True if the operation is successful.
|
|
43
40
|
*/
|
|
44
41
|
addCheckpoints(checkpoints: PublishedCheckpoint[], opts?: {
|
|
45
42
|
force?: boolean;
|
|
46
43
|
}): Promise<boolean>;
|
|
44
|
+
private skipOrUpdateAlreadyStoredCheckpoints;
|
|
45
|
+
private getPreviousCheckpointBlock;
|
|
46
|
+
/**
|
|
47
|
+
* Validates that blocks are sequential, have correct indexes, and chain via archive roots.
|
|
48
|
+
* This is the same validation used for both confirmed checkpoints (addCheckpoints) and
|
|
49
|
+
* proposed checkpoints (setProposedCheckpoint).
|
|
50
|
+
*/
|
|
51
|
+
private validateCheckpointBlocks;
|
|
47
52
|
private addBlockToDatabase;
|
|
48
53
|
private deleteBlock;
|
|
49
54
|
/**
|
|
@@ -73,8 +78,32 @@ export declare class BlockStore {
|
|
|
73
78
|
*/
|
|
74
79
|
removeBlocksAfter(blockNumber: BlockNumber): Promise<L2Block[]>;
|
|
75
80
|
getProvenBlockNumber(): Promise<BlockNumber>;
|
|
76
|
-
getLatestBlockNumber(): Promise<BlockNumber>;
|
|
77
81
|
getLatestCheckpointNumber(): Promise<CheckpointNumber>;
|
|
82
|
+
hasProposedCheckpoint(): Promise<boolean>;
|
|
83
|
+
/** Deletes the proposed checkpoint from storage. */
|
|
84
|
+
deleteProposedCheckpoint(): Promise<void>;
|
|
85
|
+
/** Clears the proposed checkpoint if the given confirmed checkpoint number supersedes it. */
|
|
86
|
+
clearProposedCheckpointIfSuperseded(confirmedCheckpointNumber: CheckpointNumber): Promise<void>;
|
|
87
|
+
/** Returns the proposed checkpoint data, or undefined if no proposed checkpoint exists. No fallback to confirmed. */
|
|
88
|
+
getProposedCheckpointOnly(): Promise<ProposedCheckpointData | undefined>;
|
|
89
|
+
/**
|
|
90
|
+
* Gets the checkpoint at the proposed tip
|
|
91
|
+
* - pending checkpoint if it exists
|
|
92
|
+
* - fallsback to latest confirmed checkpoint otherwise
|
|
93
|
+
* @returns CommonCheckpointData
|
|
94
|
+
*/
|
|
95
|
+
getProposedCheckpoint(): Promise<CommonCheckpointData | undefined>;
|
|
96
|
+
private convertToProposedCheckpointData;
|
|
97
|
+
/**
|
|
98
|
+
* Attempts to get the proposedCheckpoint's number, if there is not one, then fallback to the latest confirmed checkpoint number.
|
|
99
|
+
* @returns CheckpointNumber
|
|
100
|
+
*/
|
|
101
|
+
getProposedCheckpointNumber(): Promise<CheckpointNumber>;
|
|
102
|
+
/**
|
|
103
|
+
* Attempts to get the proposedCheckpoint's block number, if there is not one, then fallback to the checkpointed block number
|
|
104
|
+
* @returns BlockNumber
|
|
105
|
+
*/
|
|
106
|
+
getProposedCheckpointL2BlockNumber(): Promise<BlockNumber>;
|
|
78
107
|
getCheckpointedBlock(number: BlockNumber): Promise<CheckpointedL2Block | undefined>;
|
|
79
108
|
/**
|
|
80
109
|
* Gets up to `limit` amount of Checkpointed L2 blocks starting from `from`.
|
|
@@ -155,7 +184,7 @@ export declare class BlockStore {
|
|
|
155
184
|
* @param txHash - The hash of a tx we try to get the receipt for.
|
|
156
185
|
* @returns The requested tx receipt (or undefined if not found).
|
|
157
186
|
*/
|
|
158
|
-
getSettledTxReceipt(txHash: TxHash): Promise<TxReceipt | undefined>;
|
|
187
|
+
getSettledTxReceipt(txHash: TxHash, l1Constants?: Pick<L1RollupConstants, 'epochDuration'>): Promise<TxReceipt | undefined>;
|
|
159
188
|
/**
|
|
160
189
|
* Looks up which block included the requested tx effect.
|
|
161
190
|
* @param txHash - The txHash of the tx.
|
|
@@ -180,8 +209,13 @@ export declare class BlockStore {
|
|
|
180
209
|
*/
|
|
181
210
|
getSynchedL1BlockNumber(): Promise<bigint | undefined>;
|
|
182
211
|
setSynchedL1BlockNumber(l1BlockNumber: bigint): Promise<boolean>;
|
|
212
|
+
/** Sets the proposed checkpoint (not yet L1-confirmed). Only accepts confirmed + 1.
|
|
213
|
+
* Computes archive and checkpointOutHash from the stored blocks. */
|
|
214
|
+
setProposedCheckpoint(proposed: ProposedCheckpointInput): Promise<void>;
|
|
183
215
|
getProvenCheckpointNumber(): Promise<CheckpointNumber>;
|
|
184
216
|
setProvenCheckpointNumber(checkpointNumber: CheckpointNumber): Promise<boolean>;
|
|
217
|
+
getFinalizedCheckpointNumber(): Promise<CheckpointNumber>;
|
|
218
|
+
setFinalizedCheckpointNumber(checkpointNumber: CheckpointNumber): Promise<boolean>;
|
|
185
219
|
/**
|
|
186
220
|
* Gets the pending chain validation status.
|
|
187
221
|
* @returns The validation status or undefined if not set.
|
|
@@ -193,4 +227,4 @@ export declare class BlockStore {
|
|
|
193
227
|
*/
|
|
194
228
|
setPendingChainValidationStatus(status: ValidateCheckpointResult | undefined): Promise<void>;
|
|
195
229
|
}
|
|
196
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
230
|
+
//# sourceMapp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