@aztec/archiver 0.0.1-commit.e6bd8901 → 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 +14 -9
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +97 -115
- 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 +5 -4
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +32 -28
- 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 +191 -259
- package/dest/l1/data_retrieval.d.ts +11 -11
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +36 -35
- 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/validate_trace.d.ts +6 -3
- package/dest/l1/validate_trace.d.ts.map +1 -1
- package/dest/l1/validate_trace.js +13 -9
- package/dest/modules/data_source_base.d.ts +17 -10
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +39 -77
- package/dest/modules/data_store_updater.d.ts +25 -12
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +125 -94
- package/dest/modules/instrumentation.d.ts +18 -3
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +53 -18
- package/dest/modules/l1_synchronizer.d.ts +7 -9
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +180 -139
- 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 +69 -31
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +358 -137
- 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 +16 -72
- 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 +64 -27
- package/dest/store/kv_archiver_store.d.ts.map +1 -1
- package/dest/store/kv_archiver_store.js +77 -30
- package/dest/store/l2_tips_cache.d.ts +20 -0
- package/dest/store/l2_tips_cache.d.ts.map +1 -0
- package/dest/store/l2_tips_cache.js +109 -0
- 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 +150 -53
- 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 +21 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +133 -26
- package/dest/test/index.js +3 -1
- 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 +30 -9
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +161 -90
- package/dest/test/mock_structs.d.ts +6 -2
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +20 -6
- package/dest/test/noop_l1_archiver.d.ts +26 -0
- package/dest/test/noop_l1_archiver.d.ts.map +1 -0
- package/dest/test/noop_l1_archiver.js +71 -0
- package/package.json +14 -13
- package/src/archiver.ts +128 -141
- package/src/config.ts +8 -1
- package/src/errors.ts +70 -26
- package/src/factory.ts +48 -26
- 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 +250 -379
- package/src/l1/data_retrieval.ts +32 -38
- package/src/l1/spire_proposer.ts +7 -15
- package/src/l1/validate_trace.ts +24 -6
- package/src/modules/data_source_base.ts +81 -101
- package/src/modules/data_store_updater.ts +138 -124
- package/src/modules/instrumentation.ts +63 -19
- package/src/modules/l1_synchronizer.ts +204 -174
- package/src/modules/validation.ts +2 -2
- package/src/store/block_store.ts +456 -177
- package/src/store/contract_class_store.ts +16 -110
- package/src/store/contract_instance_store.ts +8 -5
- package/src/store/kv_archiver_store.ts +120 -46
- package/src/store/l2_tips_cache.ts +128 -0
- package/src/store/log_store.ts +224 -63
- package/src/store/message_store.ts +27 -10
- package/src/structs/inbox_message.ts +1 -1
- package/src/test/fake_l1_state.ts +178 -30
- package/src/test/index.ts +3 -0
- 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 +215 -88
- package/src/test/mock_structs.ts +42 -12
- package/src/test/noop_l1_archiver.ts +114 -0
|
@@ -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
|
-
import { getEpochAtSlot,
|
|
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');
|
|
@@ -396,7 +399,6 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
396
399
|
debugClient;
|
|
397
400
|
rollup;
|
|
398
401
|
inbox;
|
|
399
|
-
l1Addresses;
|
|
400
402
|
store;
|
|
401
403
|
config;
|
|
402
404
|
blobClient;
|
|
@@ -435,12 +437,11 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
435
437
|
l1Timestamp;
|
|
436
438
|
updater;
|
|
437
439
|
tracer;
|
|
438
|
-
constructor(publicClient, debugClient, rollup, inbox,
|
|
440
|
+
constructor(publicClient, debugClient, rollup, inbox, store, config, blobClient, epochCache, dateProvider, instrumentation, l1Constants, events, tracer, l2TipsCache, log = createLogger('archiver:l1-sync')){
|
|
439
441
|
this.publicClient = publicClient;
|
|
440
442
|
this.debugClient = debugClient;
|
|
441
443
|
this.rollup = rollup;
|
|
442
444
|
this.inbox = inbox;
|
|
443
|
-
this.l1Addresses = l1Addresses;
|
|
444
445
|
this.store = store;
|
|
445
446
|
this.config = config;
|
|
446
447
|
this.blobClient = blobClient;
|
|
@@ -451,7 +452,9 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
451
452
|
this.events = events;
|
|
452
453
|
this.log = log;
|
|
453
454
|
_initProto(this);
|
|
454
|
-
this.updater = new ArchiverDataStoreUpdater(this.store
|
|
455
|
+
this.updater = new ArchiverDataStoreUpdater(this.store, l2TipsCache, {
|
|
456
|
+
rollupManaLimit: l1Constants.rollupManaLimit
|
|
457
|
+
});
|
|
455
458
|
this.tracer = tracer;
|
|
456
459
|
}
|
|
457
460
|
/** Sets new config */ setConfig(newConfig) {
|
|
@@ -477,12 +480,20 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
477
480
|
}
|
|
478
481
|
}
|
|
479
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.
|
|
480
487
|
const currentL1Block = await this.publicClient.getBlock({
|
|
481
488
|
includeTransactions: false
|
|
482
489
|
});
|
|
483
490
|
const currentL1BlockNumber = currentL1Block.number;
|
|
484
491
|
const currentL1BlockHash = Buffer32.fromString(currentL1Block.hash);
|
|
485
492
|
const currentL1Timestamp = currentL1Block.timestamp;
|
|
493
|
+
const currentL1BlockData = {
|
|
494
|
+
l1BlockNumber: currentL1BlockNumber,
|
|
495
|
+
l1BlockHash: currentL1BlockHash
|
|
496
|
+
};
|
|
486
497
|
if (this.l1BlockHash && currentL1BlockHash.equals(this.l1BlockHash)) {
|
|
487
498
|
this.log.trace(`No new L1 blocks since last sync at L1 block ${this.l1BlockNumber}`);
|
|
488
499
|
return;
|
|
@@ -498,36 +509,16 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
498
509
|
maxAllowedDelay
|
|
499
510
|
});
|
|
500
511
|
}
|
|
501
|
-
// Load sync point for blocks
|
|
502
|
-
const { blocksSynchedTo = this.l1Constants.l1StartBlock
|
|
503
|
-
l1BlockNumber: this.l1Constants.l1StartBlock,
|
|
504
|
-
l1BlockHash: this.l1Constants.l1StartBlockHash
|
|
505
|
-
} } = await this.store.getSynchPoint();
|
|
512
|
+
// Load sync point for blocks defaulting to start block
|
|
513
|
+
const { blocksSynchedTo = this.l1Constants.l1StartBlock } = await this.store.getSynchPoint();
|
|
506
514
|
this.log.debug(`Starting new archiver sync iteration`, {
|
|
507
515
|
blocksSynchedTo,
|
|
508
|
-
|
|
509
|
-
currentL1BlockNumber,
|
|
510
|
-
currentL1BlockHash
|
|
516
|
+
currentL1BlockData
|
|
511
517
|
});
|
|
512
|
-
//
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
* to ensure that data is read exactly once.
|
|
517
|
-
*
|
|
518
|
-
* The first is the problem of eventually consistent ETH service providers like Infura.
|
|
519
|
-
* Each L1 read operation will query data from the last L1 block that it saw emit its kind of data.
|
|
520
|
-
* (so pending L1 to L2 messages will read from the last L1 block that emitted a message and so on)
|
|
521
|
-
* This will mean the archiver will lag behind L1 and will only advance when there's L2-relevant activity on the chain.
|
|
522
|
-
*
|
|
523
|
-
* The second is that in between the various calls to L1, the block number can move meaning some
|
|
524
|
-
* of the following calls will return data for blocks that were not present during earlier calls.
|
|
525
|
-
* To combat this for the time being we simply ensure that all data retrieval methods only retrieve
|
|
526
|
-
* data up to the currentBlockNumber captured at the top of this function. We might want to improve on this
|
|
527
|
-
* in future but for the time being it should give us the guarantees that we need
|
|
528
|
-
*/ // ********** Events that are processed per L1 block **********
|
|
529
|
-
await this.handleL1ToL2Messages(messagesSynchedTo, currentL1BlockNumber);
|
|
530
|
-
// ********** 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);
|
|
531
522
|
if (currentL1BlockNumber > blocksSynchedTo) {
|
|
532
523
|
// First we retrieve new checkpoints and L2 blocks and store them in the DB. This will also update the
|
|
533
524
|
// pending chain validation status, proven checkpoint number, and synched L1 block number.
|
|
@@ -555,6 +546,8 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
555
546
|
}
|
|
556
547
|
this.instrumentation.updateL1BlockHeight(currentL1BlockNumber);
|
|
557
548
|
}
|
|
549
|
+
// Update the finalized L2 checkpoint based on L1 finality.
|
|
550
|
+
await this.updateFinalizedCheckpoint();
|
|
558
551
|
// After syncing has completed, update the current l1 block number and timestamp,
|
|
559
552
|
// otherwise we risk announcing to the world that we've synced to a given point,
|
|
560
553
|
// but the corresponding blocks have not been processed (see #12631).
|
|
@@ -568,6 +561,31 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
568
561
|
l1BlockNumberAtEnd
|
|
569
562
|
});
|
|
570
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
|
+
}
|
|
571
589
|
/** Prune all proposed local blocks that should have been checkpointed by now. */ async pruneUncheckpointedBlocks(currentL1Timestamp) {
|
|
572
590
|
const [lastCheckpointedBlockNumber, lastProposedBlockNumber] = await Promise.all([
|
|
573
591
|
this.store.getCheckpointedL2BlockNumber(),
|
|
@@ -578,27 +596,28 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
578
596
|
this.log.trace(`No uncheckpointed blocks to prune.`);
|
|
579
597
|
return;
|
|
580
598
|
}
|
|
581
|
-
// 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);
|
|
582
601
|
const firstUncheckpointedBlockNumber = BlockNumber(lastCheckpointedBlockNumber + 1);
|
|
602
|
+
// What's the slot of the first uncheckpointed block?
|
|
583
603
|
const [firstUncheckpointedBlockHeader] = await this.store.getBlockHeaders(firstUncheckpointedBlockNumber, 1);
|
|
584
604
|
const firstUncheckpointedBlockSlot = firstUncheckpointedBlockHeader?.getSlot();
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
// Prune provisional blocks from slots that have ended without being checkpointed
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
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
|
|
593
620
|
});
|
|
594
|
-
const prunedBlocks = await this.updater.removeUncheckpointedBlocksAfter(lastCheckpointedBlockNumber);
|
|
595
|
-
if (prunedBlocks.length > 0) {
|
|
596
|
-
this.events.emit(L2BlockSourceEvents.L2PruneUncheckpointed, {
|
|
597
|
-
type: L2BlockSourceEvents.L2PruneUncheckpointed,
|
|
598
|
-
slotNumber: firstUncheckpointedBlockSlot,
|
|
599
|
-
blocks: prunedBlocks
|
|
600
|
-
});
|
|
601
|
-
}
|
|
602
621
|
}
|
|
603
622
|
}
|
|
604
623
|
/** Queries the rollup contract on whether a prune can be executed on the immediate next L1 block. */ async canPrune(currentL1BlockNumber, currentL1Timestamp) {
|
|
@@ -629,12 +648,14 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
629
648
|
const pruneFromSlotNumber = header.slotNumber;
|
|
630
649
|
const pruneFromEpochNumber = getEpochAtSlot(pruneFromSlotNumber, this.l1Constants);
|
|
631
650
|
const checkpointsToUnwind = localPendingCheckpointNumber - provenCheckpointNumber;
|
|
632
|
-
|
|
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({
|
|
633
655
|
length: checkpointsToUnwind
|
|
634
|
-
}
|
|
635
|
-
const checkpoints = await
|
|
636
|
-
const
|
|
637
|
-
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();
|
|
638
659
|
// Emit an event for listening services to react to the chain prune
|
|
639
660
|
this.events.emit(L2BlockSourceEvents.L2PruneUnproven, {
|
|
640
661
|
type: L2BlockSourceEvents.L2PruneUnproven,
|
|
@@ -668,55 +689,75 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
668
689
|
nextEnd
|
|
669
690
|
];
|
|
670
691
|
}
|
|
671
|
-
async handleL1ToL2Messages(
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
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;
|
|
675
702
|
}
|
|
676
|
-
//
|
|
677
|
-
const localMessagesInserted = await this.store.getTotalL1ToL2MessageCount();
|
|
678
|
-
const localLastMessage = await this.store.getLastL1ToL2Message();
|
|
703
|
+
// Compare local message store state with the remote. If they match, we just advance the match pointer.
|
|
679
704
|
const remoteMessagesState = await this.inbox.getState({
|
|
680
705
|
blockNumber: currentL1BlockNumber
|
|
681
706
|
});
|
|
682
|
-
this.
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
remoteMessagesState
|
|
686
|
-
|
|
687
|
-
// Compare message count and rolling hash. If they match, no need to retrieve anything.
|
|
688
|
-
if (remoteMessagesState.totalMessagesInserted === localMessagesInserted && remoteMessagesState.messagesRollingHash.equals(localLastMessage?.rollingHash ?? Buffer32.ZERO)) {
|
|
689
|
-
this.log.trace(`No L1 to L2 messages to query between L1 blocks ${messagesSyncPoint.l1BlockNumber} and ${currentL1BlockNumber}.`);
|
|
690
|
-
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;
|
|
691
712
|
}
|
|
692
|
-
//
|
|
693
|
-
//
|
|
694
|
-
//
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
this.
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
this.log.warn(`Rolling back L1 to L2 messages due to hash mismatch or msg not found.`, {
|
|
703
|
-
remoteLastMessage,
|
|
704
|
-
messagesSyncPoint,
|
|
705
|
-
localLastMessage
|
|
706
|
-
});
|
|
707
|
-
messagesSyncPoint = await this.rollbackL1ToL2Messages(localLastMessage, messagesSyncPoint);
|
|
708
|
-
this.log.debug(`Rolled back L1 to L2 messages to L1 block ${messagesSyncPoint.l1BlockNumber}.`, {
|
|
709
|
-
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
|
|
710
723
|
});
|
|
724
|
+
await this.rollbackL1ToL2Messages(remoteMessagesState.treeInProgress);
|
|
725
|
+
return false;
|
|
711
726
|
}
|
|
727
|
+
throw error;
|
|
728
|
+
}
|
|
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;
|
|
712
740
|
}
|
|
713
|
-
//
|
|
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) {
|
|
714
755
|
let searchStartBlock = 0n;
|
|
715
|
-
let searchEndBlock =
|
|
756
|
+
let searchEndBlock = fromL1Block;
|
|
716
757
|
let lastMessage;
|
|
717
758
|
let messageCount = 0;
|
|
718
759
|
do {
|
|
719
|
-
[searchStartBlock, searchEndBlock] = this.nextRange(searchEndBlock,
|
|
760
|
+
[searchStartBlock, searchEndBlock] = this.nextRange(searchEndBlock, toL1Block);
|
|
720
761
|
this.log.trace(`Retrieving L1 to L2 messages in L1 blocks ${searchStartBlock}-${searchEndBlock}`);
|
|
721
762
|
const messages = await retrieveL1ToL2Messages(this.inbox, searchStartBlock, searchEndBlock);
|
|
722
763
|
const timer = new Timer();
|
|
@@ -731,74 +772,65 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
731
772
|
lastMessage = msg;
|
|
732
773
|
messageCount++;
|
|
733
774
|
}
|
|
734
|
-
}while (searchEndBlock <
|
|
735
|
-
// Log stats for messages retrieved (if any).
|
|
775
|
+
}while (searchEndBlock < toL1Block)
|
|
736
776
|
if (messageCount > 0) {
|
|
737
777
|
this.log.info(`Retrieved ${messageCount} new L1 to L2 messages up to message with index ${lastMessage?.index} for checkpoint ${lastMessage?.checkpointNumber}`, {
|
|
738
778
|
lastMessage,
|
|
739
779
|
messageCount
|
|
740
780
|
});
|
|
741
781
|
}
|
|
742
|
-
// Warn if the resulting rolling hash does not match the remote state we had retrieved.
|
|
743
|
-
if (lastMessage && !lastMessage.rollingHash.equals(remoteMessagesState.messagesRollingHash)) {
|
|
744
|
-
this.log.warn(`Last message retrieved rolling hash does not match remote state.`, {
|
|
745
|
-
lastMessage,
|
|
746
|
-
remoteMessagesState
|
|
747
|
-
});
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
async retrieveL1ToL2Message(leaf) {
|
|
751
|
-
const currentL1BlockNumber = await this.publicClient.getBlockNumber();
|
|
752
|
-
let searchStartBlock = 0n;
|
|
753
|
-
let searchEndBlock = this.l1Constants.l1StartBlock - 1n;
|
|
754
|
-
do {
|
|
755
|
-
[searchStartBlock, searchEndBlock] = this.nextRange(searchEndBlock, currentL1BlockNumber);
|
|
756
|
-
const message = await retrieveL1ToL2Message(this.inbox, leaf, searchStartBlock, searchEndBlock);
|
|
757
|
-
if (message) {
|
|
758
|
-
return message;
|
|
759
|
-
}
|
|
760
|
-
}while (searchEndBlock < currentL1BlockNumber)
|
|
761
|
-
return undefined;
|
|
762
782
|
}
|
|
763
|
-
|
|
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) {
|
|
764
787
|
// Slowly go back through our messages until we find the last common message.
|
|
765
788
|
// We could query the logs in batch as an optimization, but the depth of the reorg should not be deep, and this
|
|
766
789
|
// is a very rare case, so it's fine to query one log at a time.
|
|
767
790
|
let commonMsg;
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
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
|
|
772
795
|
})){
|
|
773
|
-
const remoteMsg = await
|
|
796
|
+
const remoteMsg = await retrieveL1ToL2Message(this.inbox, localMsg);
|
|
774
797
|
const logCtx = {
|
|
775
798
|
remoteMsg,
|
|
776
|
-
localMsg:
|
|
799
|
+
localMsg: localMsg
|
|
777
800
|
};
|
|
778
|
-
if (remoteMsg && remoteMsg.rollingHash.equals(
|
|
779
|
-
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);
|
|
780
803
|
commonMsg = remoteMsg;
|
|
781
804
|
break;
|
|
782
805
|
} else if (remoteMsg) {
|
|
783
|
-
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++;
|
|
784
808
|
} else {
|
|
785
|
-
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++;
|
|
786
811
|
}
|
|
787
812
|
}
|
|
788
|
-
// Delete everything after the common message we found.
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
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
|
+
}
|
|
792
820
|
// Update the syncpoint so the loop below reprocesses the changed messages. We go to the block before
|
|
793
821
|
// the last common one, so we force reprocessing it, in case new messages were added on that same L1 block
|
|
794
822
|
// after the last common message.
|
|
795
823
|
const syncPointL1BlockNumber = commonMsg ? commonMsg.l1BlockNumber - 1n : this.l1Constants.l1StartBlock;
|
|
796
824
|
const syncPointL1BlockHash = await this.getL1BlockHash(syncPointL1BlockNumber);
|
|
797
|
-
messagesSyncPoint = {
|
|
825
|
+
const messagesSyncPoint = {
|
|
798
826
|
l1BlockNumber: syncPointL1BlockNumber,
|
|
799
827
|
l1BlockHash: syncPointL1BlockHash
|
|
800
828
|
};
|
|
801
|
-
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
|
+
});
|
|
802
834
|
return messagesSyncPoint;
|
|
803
835
|
}
|
|
804
836
|
async getL1BlockHash(l1BlockNumber) {
|
|
@@ -838,7 +870,7 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
838
870
|
if (provenCheckpointNumber === 0) {
|
|
839
871
|
const localProvenCheckpointNumber = await this.store.getProvenCheckpointNumber();
|
|
840
872
|
if (localProvenCheckpointNumber !== provenCheckpointNumber) {
|
|
841
|
-
await this.
|
|
873
|
+
await this.updater.setProvenCheckpointNumber(provenCheckpointNumber);
|
|
842
874
|
this.log.info(`Rolled back proven chain to checkpoint ${provenCheckpointNumber}`, {
|
|
843
875
|
provenCheckpointNumber
|
|
844
876
|
});
|
|
@@ -855,20 +887,20 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
855
887
|
if (localCheckpointForDestinationProvenCheckpointNumber && provenArchive.equals(localCheckpointForDestinationProvenCheckpointNumber.archive.root)) {
|
|
856
888
|
const localProvenCheckpointNumber = await this.store.getProvenCheckpointNumber();
|
|
857
889
|
if (localProvenCheckpointNumber !== provenCheckpointNumber) {
|
|
858
|
-
await this.
|
|
890
|
+
await this.updater.setProvenCheckpointNumber(provenCheckpointNumber);
|
|
859
891
|
this.log.info(`Updated proven chain to checkpoint ${provenCheckpointNumber}`, {
|
|
860
892
|
provenCheckpointNumber
|
|
861
893
|
});
|
|
862
894
|
const provenSlotNumber = localCheckpointForDestinationProvenCheckpointNumber.header.slotNumber;
|
|
863
895
|
const provenEpochNumber = getEpochAtSlot(provenSlotNumber, this.l1Constants);
|
|
864
|
-
const lastBlockNumberInCheckpoint = localCheckpointForDestinationProvenCheckpointNumber.startBlock + localCheckpointForDestinationProvenCheckpointNumber.
|
|
896
|
+
const lastBlockNumberInCheckpoint = localCheckpointForDestinationProvenCheckpointNumber.startBlock + localCheckpointForDestinationProvenCheckpointNumber.blockCount - 1;
|
|
865
897
|
this.events.emit(L2BlockSourceEvents.L2BlockProven, {
|
|
866
898
|
type: L2BlockSourceEvents.L2BlockProven,
|
|
867
899
|
blockNumber: BlockNumber(lastBlockNumberInCheckpoint),
|
|
868
900
|
slotNumber: provenSlotNumber,
|
|
869
901
|
epochNumber: provenEpochNumber
|
|
870
902
|
});
|
|
871
|
-
this.instrumentation.
|
|
903
|
+
this.instrumentation.updateLastProvenCheckpoint(localCheckpointForDestinationProvenCheckpointNumber);
|
|
872
904
|
} else {
|
|
873
905
|
this.log.trace(`Proven checkpoint ${provenCheckpointNumber} already stored.`);
|
|
874
906
|
}
|
|
@@ -946,7 +978,7 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
946
978
|
[searchStartBlock, searchEndBlock] = this.nextRange(searchEndBlock, currentL1BlockNumber);
|
|
947
979
|
this.log.trace(`Retrieving checkpoints from L1 block ${searchStartBlock} to ${searchEndBlock}`);
|
|
948
980
|
// TODO(md): Retrieve from blob client then from consensus client, then from peers
|
|
949
|
-
const retrievedCheckpoints = await execInSpan(this.tracer, 'Archiver.retrieveCheckpointsFromRollup', ()=>retrieveCheckpointsFromRollup(this.rollup, this.publicClient, this.debugClient, this.blobClient, searchStartBlock, searchEndBlock, this.
|
|
981
|
+
const retrievedCheckpoints = await execInSpan(this.tracer, 'Archiver.retrieveCheckpointsFromRollup', ()=>retrieveCheckpointsFromRollup(this.rollup, this.publicClient, this.debugClient, this.blobClient, searchStartBlock, searchEndBlock, this.instrumentation, this.log, !initialSyncComplete));
|
|
950
982
|
if (retrievedCheckpoints.length === 0) {
|
|
951
983
|
// We are not calling `setBlockSynchedL1BlockNumber` because it may cause sync issues if based off infura.
|
|
952
984
|
// See further details in earlier comments.
|
|
@@ -1009,15 +1041,24 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
1009
1041
|
blocks: published.checkpoint.blocks.map((b)=>b.getStats())
|
|
1010
1042
|
});
|
|
1011
1043
|
}
|
|
1044
|
+
for (const published of validCheckpoints){
|
|
1045
|
+
this.instrumentation.processCheckpointL1Timing({
|
|
1046
|
+
slotNumber: published.checkpoint.header.slotNumber,
|
|
1047
|
+
l1Timestamp: published.l1.timestamp,
|
|
1048
|
+
l1Constants: this.l1Constants
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1012
1051
|
try {
|
|
1013
1052
|
const updatedValidationResult = rollupStatus.validationResult === initialValidationResult ? undefined : rollupStatus.validationResult;
|
|
1014
1053
|
const [processDuration, result] = await elapsed(()=>execInSpan(this.tracer, 'Archiver.addCheckpoints', ()=>this.updater.addCheckpoints(validCheckpoints, updatedValidationResult)));
|
|
1015
|
-
|
|
1054
|
+
if (validCheckpoints.length > 0) {
|
|
1055
|
+
this.instrumentation.processNewCheckpointedBlocks(processDuration / validCheckpoints.length, validCheckpoints.flatMap((c)=>c.checkpoint.blocks));
|
|
1056
|
+
}
|
|
1016
1057
|
// If blocks were pruned due to conflict with L1 checkpoints, emit event
|
|
1017
1058
|
if (result.prunedBlocks && result.prunedBlocks.length > 0) {
|
|
1018
1059
|
const prunedCheckpointNumber = result.prunedBlocks[0].checkpointNumber;
|
|
1019
1060
|
const prunedSlotNumber = result.prunedBlocks[0].header.globalVariables.slotNumber;
|
|
1020
|
-
this.log.
|
|
1061
|
+
this.log.info(`Pruned ${result.prunedBlocks.length} mismatching blocks for checkpoint ${prunedCheckpointNumber}`, {
|
|
1021
1062
|
prunedBlocks: result.prunedBlocks.map((b)=>b.toBlockInfo()),
|
|
1022
1063
|
prunedSlotNumber,
|
|
1023
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGlvbi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL21vZHVsZXMvdmFsaWRhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUdyRCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUNwRCxPQUFPLEVBQ0wsS0FBSyxlQUFlLEVBRXBCLEtBQUssd0JBQXdCLEVBRTlCLE1BQU0scUJBQXFCLENBQUM7QUFDN0IsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUNwRSxPQUFPLEVBQUUsS0FBSyxpQkFBaUIsRUFBaUMsTUFBTSw2QkFBNkIsQ0FBQztBQUdwRyxZQUFZLEVBQUUsd0JBQXdCLEVBQUUsQ0FBQztBQUV6Qzs7O0dBR0c7QUFDSCx3QkFBZ0IseUNBQXlDLENBQUMsRUFDeEQsVUFBVSxFQUNWLFlBQVksRUFDYixFQUFFLG1CQUFtQixHQUFHLGVBQWUsRUFBRSxDQUd6QztBQUVEOzs7R0FHRztBQUNILHdCQUFzQiw4QkFBOEIsQ0FDbEQsbUJBQW1CLEVBQUUsbUJBQW1CLEVBQ3hDLFVBQVUsRUFBRSxVQUFVLEVBQ3RCLFNBQVMsRUFBRSxJQUFJLENBQUMsaUJBQWlCLEVBQUUsZUFBZSxDQUFDLEVBQ25ELE1BQU0sQ0FBQyxFQUFFLE1BQU0sR0FDZCxPQUFPLENBQUMsd0JBQXdCLENBQUMsQ0EyRm5DIn0=
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,
|