@aztec/archiver 0.0.1-commit.5de5ca79e → 0.0.1-commit.6201a7b05
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 +16 -7
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +104 -48
- package/dest/config.d.ts +3 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +14 -3
- package/dest/errors.d.ts +41 -2
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +62 -1
- package/dest/factory.d.ts +2 -2
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +9 -7
- package/dest/index.d.ts +3 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -1
- package/dest/l1/calldata_retriever.d.ts +2 -1
- package/dest/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/l1/calldata_retriever.js +11 -5
- package/dest/l1/data_retrieval.d.ts +19 -10
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +25 -32
- 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/data_source_base.d.ts +8 -2
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +19 -1
- package/dest/modules/data_store_updater.d.ts +15 -10
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +71 -68
- package/dest/modules/instrumentation.d.ts +7 -2
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +22 -6
- package/dest/modules/l1_synchronizer.d.ts +7 -2
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +261 -143
- 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 +72 -5
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +341 -66
- 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 +51 -17
- package/dest/store/kv_archiver_store.d.ts.map +1 -1
- package/dest/store/kv_archiver_store.js +60 -16
- 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 +27 -7
- package/dest/store/log_store.d.ts +1 -1
- package/dest/store/log_store.d.ts.map +1 -1
- package/dest/store/log_store.js +2 -4
- package/dest/store/message_store.d.ts +3 -3
- package/dest/store/message_store.d.ts.map +1 -1
- package/dest/store/message_store.js +9 -10
- package/dest/test/fake_l1_state.d.ts +15 -3
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +80 -18
- 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 +16 -2
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +50 -3
- package/dest/test/noop_l1_archiver.d.ts +1 -1
- package/dest/test/noop_l1_archiver.d.ts.map +1 -1
- package/dest/test/noop_l1_archiver.js +4 -2
- package/package.json +13 -13
- package/src/archiver.ts +126 -46
- package/src/config.ts +15 -1
- package/src/errors.ts +97 -2
- package/src/factory.ts +13 -7
- package/src/index.ts +2 -1
- package/src/l1/calldata_retriever.ts +17 -5
- package/src/l1/data_retrieval.ts +36 -45
- package/src/l1/validate_historical_logs.ts +140 -0
- package/src/modules/data_source_base.ts +32 -1
- package/src/modules/data_store_updater.ts +98 -97
- package/src/modules/instrumentation.ts +27 -7
- package/src/modules/l1_synchronizer.ts +328 -169
- package/src/modules/validation.ts +10 -9
- package/src/store/block_store.ts +419 -76
- 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 +100 -32
- package/src/store/l2_tips_cache.ts +58 -13
- package/src/store/log_store.ts +2 -5
- package/src/store/message_store.ts +10 -12
- package/src/structs/inbox_message.ts +1 -1
- package/src/test/fake_l1_state.ts +99 -27
- package/src/test/mock_l1_to_l2_message_source.ts +1 -0
- package/src/test/mock_l2_block_source.ts +58 -2
- package/src/test/noop_l1_archiver.ts +3 -1
|
@@ -371,21 +371,26 @@ 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 { getFinalizedL1Block } from '@aztec/ethereum/queries';
|
|
374
375
|
import { asyncPool } from '@aztec/foundation/async-pool';
|
|
375
376
|
import { maxBigint } from '@aztec/foundation/bigint';
|
|
376
377
|
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
377
|
-
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
378
|
-
import { pick } from '@aztec/foundation/collection';
|
|
378
|
+
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
|
|
379
|
+
import { partition, pick } from '@aztec/foundation/collection';
|
|
380
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
379
381
|
import { createLogger } from '@aztec/foundation/log';
|
|
382
|
+
import { retryTimes } from '@aztec/foundation/retry';
|
|
380
383
|
import { count } from '@aztec/foundation/string';
|
|
381
384
|
import { Timer, elapsed } from '@aztec/foundation/timer';
|
|
382
|
-
import { isDefined } from '@aztec/foundation/types';
|
|
385
|
+
import { isDefined, isErrorClass } from '@aztec/foundation/types';
|
|
383
386
|
import { L2BlockSourceEvents } from '@aztec/stdlib/block';
|
|
387
|
+
import { Checkpoint, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
384
388
|
import { getEpochAtSlot, getSlotAtNextL1Block } from '@aztec/stdlib/epoch-helpers';
|
|
385
389
|
import { computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
|
|
386
390
|
import { execInSpan, trackSpan } from '@aztec/telemetry-client';
|
|
387
391
|
import { InitialCheckpointNumberNotSequentialError } from '../errors.js';
|
|
388
|
-
import {
|
|
392
|
+
import { getCheckpointBlobDataFromBlobs, retrieveCheckpointCalldataFromRollup, retrieveL1ToL2Message, retrieveL1ToL2Messages, retrievedToPublishedCheckpoint } from '../l1/data_retrieval.js';
|
|
393
|
+
import { MessageStoreError } from '../store/message_store.js';
|
|
389
394
|
import { ArchiverDataStoreUpdater } from './data_store_updater.js';
|
|
390
395
|
import { validateCheckpointAttestations } from './validation.js';
|
|
391
396
|
_dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpochPrune'), _dec2 = trackSpan('Archiver.handleL1ToL2Messages'), _dec3 = trackSpan('Archiver.handleCheckpoints');
|
|
@@ -464,6 +469,12 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
464
469
|
/** Returns the last L1 timestamp that was synced. */ getL1Timestamp() {
|
|
465
470
|
return this.l1Timestamp;
|
|
466
471
|
}
|
|
472
|
+
getSignatureContext() {
|
|
473
|
+
return {
|
|
474
|
+
chainId: this.publicClient.chain.id,
|
|
475
|
+
rollupAddress: EthAddress.fromString(this.rollup.address)
|
|
476
|
+
};
|
|
477
|
+
}
|
|
467
478
|
/** Checks that the ethereum node we are connected to has a latest timestamp no more than the allowed drift. Throw if not. */ async testEthereumNodeSynced() {
|
|
468
479
|
const maxAllowedDelay = this.config.maxAllowedEthClientDriftSeconds;
|
|
469
480
|
if (maxAllowedDelay === 0) {
|
|
@@ -478,12 +489,20 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
478
489
|
}
|
|
479
490
|
}
|
|
480
491
|
async syncFromL1(initialSyncComplete) {
|
|
492
|
+
// In between the various calls to L1, the block number can move meaning some of the following
|
|
493
|
+
// calls will return data for blocks that were not present during earlier calls. To combat this
|
|
494
|
+
// we ensure that all data retrieval methods only retrieve data up to the currentBlockNumber
|
|
495
|
+
// captured at the top of this function.
|
|
481
496
|
const currentL1Block = await this.publicClient.getBlock({
|
|
482
497
|
includeTransactions: false
|
|
483
498
|
});
|
|
484
499
|
const currentL1BlockNumber = currentL1Block.number;
|
|
485
500
|
const currentL1BlockHash = Buffer32.fromString(currentL1Block.hash);
|
|
486
501
|
const currentL1Timestamp = currentL1Block.timestamp;
|
|
502
|
+
const currentL1BlockData = {
|
|
503
|
+
l1BlockNumber: currentL1BlockNumber,
|
|
504
|
+
l1BlockHash: currentL1BlockHash
|
|
505
|
+
};
|
|
487
506
|
if (this.l1BlockHash && currentL1BlockHash.equals(this.l1BlockHash)) {
|
|
488
507
|
this.log.trace(`No new L1 blocks since last sync at L1 block ${this.l1BlockNumber}`);
|
|
489
508
|
return;
|
|
@@ -499,36 +518,16 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
499
518
|
maxAllowedDelay
|
|
500
519
|
});
|
|
501
520
|
}
|
|
502
|
-
// Load sync point for blocks
|
|
503
|
-
const { blocksSynchedTo = this.l1Constants.l1StartBlock
|
|
504
|
-
l1BlockNumber: this.l1Constants.l1StartBlock,
|
|
505
|
-
l1BlockHash: this.l1Constants.l1StartBlockHash
|
|
506
|
-
} } = await this.store.getSynchPoint();
|
|
521
|
+
// Load sync point for blocks defaulting to start block
|
|
522
|
+
const { blocksSynchedTo = this.l1Constants.l1StartBlock } = await this.store.getSynchPoint();
|
|
507
523
|
this.log.debug(`Starting new archiver sync iteration`, {
|
|
508
524
|
blocksSynchedTo,
|
|
509
|
-
|
|
510
|
-
currentL1BlockNumber,
|
|
511
|
-
currentL1BlockHash
|
|
525
|
+
currentL1BlockData
|
|
512
526
|
});
|
|
513
|
-
//
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
* to ensure that data is read exactly once.
|
|
518
|
-
*
|
|
519
|
-
* The first is the problem of eventually consistent ETH service providers like Infura.
|
|
520
|
-
* Each L1 read operation will query data from the last L1 block that it saw emit its kind of data.
|
|
521
|
-
* (so pending L1 to L2 messages will read from the last L1 block that emitted a message and so on)
|
|
522
|
-
* This will mean the archiver will lag behind L1 and will only advance when there's L2-relevant activity on the chain.
|
|
523
|
-
*
|
|
524
|
-
* The second is that in between the various calls to L1, the block number can move meaning some
|
|
525
|
-
* of the following calls will return data for blocks that were not present during earlier calls.
|
|
526
|
-
* To combat this for the time being we simply ensure that all data retrieval methods only retrieve
|
|
527
|
-
* data up to the currentBlockNumber captured at the top of this function. We might want to improve on this
|
|
528
|
-
* in future but for the time being it should give us the guarantees that we need
|
|
529
|
-
*/ // ********** Events that are processed per L1 block **********
|
|
530
|
-
await this.handleL1ToL2Messages(messagesSynchedTo, currentL1BlockNumber);
|
|
531
|
-
// ********** Events that are processed per checkpoint **********
|
|
527
|
+
// 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.
|
|
528
|
+
// 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
|
|
529
|
+
// block, when that wouldn't be the case, since L1 to L2 messages would need another iteration.
|
|
530
|
+
await retryTimes(()=>this.handleL1ToL2Messages(currentL1BlockData), 'Handling L1 to L2 messages', 3, 0.1);
|
|
532
531
|
if (currentL1BlockNumber > blocksSynchedTo) {
|
|
533
532
|
// First we retrieve new checkpoints and L2 blocks and store them in the DB. This will also update the
|
|
534
533
|
// pending chain validation status, proven checkpoint number, and synched L1 block number.
|
|
@@ -573,10 +572,11 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
573
572
|
}
|
|
574
573
|
/** Query L1 for its finalized block and update the finalized checkpoint accordingly. */ async updateFinalizedCheckpoint() {
|
|
575
574
|
try {
|
|
576
|
-
const finalizedL1Block = await this.publicClient
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
575
|
+
const finalizedL1Block = await getFinalizedL1Block(this.publicClient);
|
|
576
|
+
if (!finalizedL1Block) {
|
|
577
|
+
this.log.trace(`Skipping finalized checkpoint update: L1 has no finalized block yet.`);
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
580
|
const finalizedL1BlockNumber = finalizedL1Block.number;
|
|
581
581
|
const finalizedCheckpointNumber = await this.rollup.getProvenCheckpointNumber({
|
|
582
582
|
blockNumber: finalizedL1BlockNumber
|
|
@@ -590,7 +590,10 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
590
590
|
});
|
|
591
591
|
}
|
|
592
592
|
} catch (err) {
|
|
593
|
-
|
|
593
|
+
// The rollup contract may not exist at the finalized L1 block right after deployment.
|
|
594
|
+
if (!err?.message?.includes('returned no data')) {
|
|
595
|
+
this.log.warn(`Failed to update finalized checkpoint: ${err}`);
|
|
596
|
+
}
|
|
594
597
|
}
|
|
595
598
|
}
|
|
596
599
|
/** Prune all proposed local blocks that should have been checkpointed by now. */ async pruneUncheckpointedBlocks(currentL1Timestamp) {
|
|
@@ -603,26 +606,28 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
603
606
|
this.log.trace(`No uncheckpointed blocks to prune.`);
|
|
604
607
|
return;
|
|
605
608
|
}
|
|
606
|
-
// What's the slot
|
|
609
|
+
// What's the slot at the next L1 block? All blocks for slots strictly before this one should've been checkpointed by now.
|
|
610
|
+
const slotAtNextL1Block = getSlotAtNextL1Block(currentL1Timestamp, this.l1Constants);
|
|
607
611
|
const firstUncheckpointedBlockNumber = BlockNumber(lastCheckpointedBlockNumber + 1);
|
|
612
|
+
// What's the slot of the first uncheckpointed block?
|
|
608
613
|
const [firstUncheckpointedBlockHeader] = await this.store.getBlockHeaders(firstUncheckpointedBlockNumber, 1);
|
|
609
614
|
const firstUncheckpointedBlockSlot = firstUncheckpointedBlockHeader?.getSlot();
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
615
|
+
if (firstUncheckpointedBlockSlot === undefined || firstUncheckpointedBlockSlot >= slotAtNextL1Block) {
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
// Prune provisional blocks from slots that have ended without being checkpointed.
|
|
619
|
+
// This also clears any proposed checkpoint whose blocks are being pruned.
|
|
620
|
+
this.log.warn(`Pruning blocks after block ${lastCheckpointedBlockNumber} due to slot ${firstUncheckpointedBlockSlot} not being checkpointed`, {
|
|
621
|
+
firstUncheckpointedBlockHeader: firstUncheckpointedBlockHeader.toInspect(),
|
|
622
|
+
slotAtNextL1Block
|
|
623
|
+
});
|
|
624
|
+
const prunedBlocks = await this.updater.removeUncheckpointedBlocksAfter(lastCheckpointedBlockNumber);
|
|
625
|
+
if (prunedBlocks.length > 0) {
|
|
626
|
+
this.events.emit(L2BlockSourceEvents.L2PruneUncheckpointed, {
|
|
627
|
+
type: L2BlockSourceEvents.L2PruneUncheckpointed,
|
|
628
|
+
slotNumber: firstUncheckpointedBlockSlot,
|
|
629
|
+
blocks: prunedBlocks
|
|
617
630
|
});
|
|
618
|
-
const prunedBlocks = await this.updater.removeUncheckpointedBlocksAfter(lastCheckpointedBlockNumber);
|
|
619
|
-
if (prunedBlocks.length > 0) {
|
|
620
|
-
this.events.emit(L2BlockSourceEvents.L2PruneUncheckpointed, {
|
|
621
|
-
type: L2BlockSourceEvents.L2PruneUncheckpointed,
|
|
622
|
-
slotNumber: firstUncheckpointedBlockSlot,
|
|
623
|
-
blocks: prunedBlocks
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
631
|
}
|
|
627
632
|
}
|
|
628
633
|
/** Queries the rollup contract on whether a prune can be executed on the immediate next L1 block. */ async canPrune(currentL1BlockNumber, currentL1Timestamp) {
|
|
@@ -694,56 +699,75 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
694
699
|
nextEnd
|
|
695
700
|
];
|
|
696
701
|
}
|
|
697
|
-
async handleL1ToL2Messages(
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
702
|
+
async handleL1ToL2Messages(currentL1Block) {
|
|
703
|
+
// Load the syncpoint, which may have been updated in a previous iteration
|
|
704
|
+
const { messagesSynchedTo = {
|
|
705
|
+
l1BlockNumber: this.l1Constants.l1StartBlock,
|
|
706
|
+
l1BlockHash: this.l1Constants.l1StartBlockHash
|
|
707
|
+
} } = await this.store.getSynchPoint();
|
|
708
|
+
// Nothing to do if L1 block number has not moved forward
|
|
709
|
+
const currentL1BlockNumber = currentL1Block.l1BlockNumber;
|
|
710
|
+
if (currentL1BlockNumber <= messagesSynchedTo.l1BlockNumber) {
|
|
711
|
+
return true;
|
|
701
712
|
}
|
|
702
|
-
//
|
|
703
|
-
const localMessagesInserted = await this.store.getTotalL1ToL2MessageCount();
|
|
704
|
-
const localLastMessage = await this.store.getLastL1ToL2Message();
|
|
713
|
+
// Compare local message store state with the remote. If they match, we just advance the match pointer.
|
|
705
714
|
const remoteMessagesState = await this.inbox.getState({
|
|
706
715
|
blockNumber: currentL1BlockNumber
|
|
707
716
|
});
|
|
708
|
-
await this.store.
|
|
709
|
-
this.
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
});
|
|
714
|
-
// Compare message count and rolling hash. If they match, no need to retrieve anything.
|
|
715
|
-
if (remoteMessagesState.totalMessagesInserted === localMessagesInserted && remoteMessagesState.messagesRollingHash.equals(localLastMessage?.rollingHash ?? Buffer32.ZERO)) {
|
|
716
|
-
this.log.trace(`No L1 to L2 messages to query between L1 blocks ${messagesSyncPoint.l1BlockNumber} and ${currentL1BlockNumber}.`);
|
|
717
|
-
return;
|
|
717
|
+
const localLastMessage = await this.store.getLastL1ToL2Message();
|
|
718
|
+
if (await this.localStateMatches(localLastMessage, remoteMessagesState)) {
|
|
719
|
+
this.log.trace(`Local L1 to L2 messages are already in sync with remote at L1 block ${currentL1BlockNumber}`);
|
|
720
|
+
await this.store.setMessageSyncState(currentL1Block, remoteMessagesState.treeInProgress);
|
|
721
|
+
return true;
|
|
718
722
|
}
|
|
719
|
-
//
|
|
720
|
-
//
|
|
721
|
-
//
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
this.
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
this.log.warn(`Rolling back L1 to L2 messages due to hash mismatch or msg not found.`, {
|
|
730
|
-
remoteLastMessage,
|
|
731
|
-
messagesSyncPoint,
|
|
732
|
-
localLastMessage
|
|
733
|
-
});
|
|
734
|
-
messagesSyncPoint = await this.rollbackL1ToL2Messages(localLastMessage, messagesSyncPoint);
|
|
735
|
-
this.log.debug(`Rolled back L1 to L2 messages to L1 block ${messagesSyncPoint.l1BlockNumber}.`, {
|
|
736
|
-
messagesSyncPoint
|
|
723
|
+
// If not, then we are out of sync. Most likely there are new messages on the inbox, so we try retrieving them.
|
|
724
|
+
// However, it could also be the case that there was an L1 reorg and our syncpoint is no longer valid.
|
|
725
|
+
// If that's the case, we'd get an exception out of the message store since the rolling hash of the first message
|
|
726
|
+
// we try to insert would not match the one in the db, in which case we rollback to the last common message with L1.
|
|
727
|
+
try {
|
|
728
|
+
await this.retrieveAndStoreMessages(messagesSynchedTo.l1BlockNumber, currentL1BlockNumber);
|
|
729
|
+
} catch (error) {
|
|
730
|
+
if (isErrorClass(error, MessageStoreError)) {
|
|
731
|
+
this.log.warn(`Failed to store L1 to L2 messages retrieved from L1: ${error.message}. Rolling back syncpoint to retry.`, {
|
|
732
|
+
inboxMessage: error.inboxMessage
|
|
737
733
|
});
|
|
734
|
+
await this.rollbackL1ToL2Messages(remoteMessagesState);
|
|
735
|
+
return false;
|
|
738
736
|
}
|
|
737
|
+
throw error;
|
|
738
|
+
}
|
|
739
|
+
// Note that, if there are no new messages to insert, but there was an L1 reorg that pruned out last messages,
|
|
740
|
+
// we'd notice by comparing our local state with the remote one again, and seeing they don't match even after
|
|
741
|
+
// our sync attempt. In this case, we also rollback our syncpoint, and trigger a retry.
|
|
742
|
+
const localLastMessageAfterSync = await this.store.getLastL1ToL2Message();
|
|
743
|
+
if (!await this.localStateMatches(localLastMessageAfterSync, remoteMessagesState)) {
|
|
744
|
+
this.log.warn(`Local L1 to L2 messages state does not match remote after sync attempt. Rolling back syncpoint to retry.`, {
|
|
745
|
+
localLastMessageAfterSync,
|
|
746
|
+
remoteMessagesState
|
|
747
|
+
});
|
|
748
|
+
await this.rollbackL1ToL2Messages(remoteMessagesState);
|
|
749
|
+
return false;
|
|
739
750
|
}
|
|
740
|
-
//
|
|
751
|
+
// Advance the syncpoint after a successful sync
|
|
752
|
+
await this.store.setMessageSyncState(currentL1Block, remoteMessagesState.treeInProgress);
|
|
753
|
+
return true;
|
|
754
|
+
}
|
|
755
|
+
/** Checks if the local rolling hash and message count matches the remote state */ async localStateMatches(localLastMessage, remoteState) {
|
|
756
|
+
const localMessageCount = await this.store.getTotalL1ToL2MessageCount();
|
|
757
|
+
this.log.trace(`Comparing local and remote inbox state`, {
|
|
758
|
+
localMessageCount,
|
|
759
|
+
localLastMessage,
|
|
760
|
+
remoteState
|
|
761
|
+
});
|
|
762
|
+
return remoteState.totalMessagesInserted === localMessageCount && remoteState.messagesRollingHash.equals(localLastMessage?.rollingHash ?? Buffer16.ZERO);
|
|
763
|
+
}
|
|
764
|
+
/** Retrieves L1 to L2 messages from L1 in batches and stores them. */ async retrieveAndStoreMessages(fromL1Block, toL1Block) {
|
|
741
765
|
let searchStartBlock = 0n;
|
|
742
|
-
let searchEndBlock =
|
|
766
|
+
let searchEndBlock = fromL1Block;
|
|
743
767
|
let lastMessage;
|
|
744
768
|
let messageCount = 0;
|
|
745
769
|
do {
|
|
746
|
-
[searchStartBlock, searchEndBlock] = this.nextRange(searchEndBlock,
|
|
770
|
+
[searchStartBlock, searchEndBlock] = this.nextRange(searchEndBlock, toL1Block);
|
|
747
771
|
this.log.trace(`Retrieving L1 to L2 messages in L1 blocks ${searchStartBlock}-${searchEndBlock}`);
|
|
748
772
|
const messages = await retrieveL1ToL2Messages(this.inbox, searchStartBlock, searchEndBlock);
|
|
749
773
|
const timer = new Timer();
|
|
@@ -758,74 +782,81 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
758
782
|
lastMessage = msg;
|
|
759
783
|
messageCount++;
|
|
760
784
|
}
|
|
761
|
-
}while (searchEndBlock <
|
|
762
|
-
// Log stats for messages retrieved (if any).
|
|
785
|
+
}while (searchEndBlock < toL1Block)
|
|
763
786
|
if (messageCount > 0) {
|
|
764
787
|
this.log.info(`Retrieved ${messageCount} new L1 to L2 messages up to message with index ${lastMessage?.index} for checkpoint ${lastMessage?.checkpointNumber}`, {
|
|
765
788
|
lastMessage,
|
|
766
789
|
messageCount
|
|
767
790
|
});
|
|
768
791
|
}
|
|
769
|
-
// Warn if the resulting rolling hash does not match the remote state we had retrieved.
|
|
770
|
-
if (lastMessage && !lastMessage.rollingHash.equals(remoteMessagesState.messagesRollingHash)) {
|
|
771
|
-
this.log.warn(`Last message retrieved rolling hash does not match remote state.`, {
|
|
772
|
-
lastMessage,
|
|
773
|
-
remoteMessagesState
|
|
774
|
-
});
|
|
775
|
-
}
|
|
776
792
|
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
return message;
|
|
786
|
-
}
|
|
787
|
-
}while (searchEndBlock < currentL1BlockNumber)
|
|
788
|
-
return undefined;
|
|
789
|
-
}
|
|
790
|
-
async rollbackL1ToL2Messages(localLastMessage, messagesSyncPoint) {
|
|
791
|
-
// Slowly go back through our messages until we find the last common message.
|
|
792
|
-
// We could query the logs in batch as an optimization, but the depth of the reorg should not be deep, and this
|
|
793
|
-
// is a very rare case, so it's fine to query one log at a time.
|
|
793
|
+
/**
|
|
794
|
+
* 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.
|
|
795
|
+
* If no common message is found, rolls back all messages and sets the syncpoint to the start block.
|
|
796
|
+
*/ async rollbackL1ToL2Messages(remoteMessagesState) {
|
|
797
|
+
const { treeInProgress: remoteTreeInProgress, messagesRollingHash: remoteRollingHash } = remoteMessagesState;
|
|
798
|
+
// Slowly go back through our messages until we find the last common message. We could query the logs in
|
|
799
|
+
// batch as an optimization, but the depth of the reorg should not be deep, and this is a very rare case,
|
|
800
|
+
// so it's fine to query one log at a time.
|
|
794
801
|
let commonMsg;
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
802
|
+
let messagesToDelete = 0;
|
|
803
|
+
this.log.verbose(`Searching most recent common L1 to L2 message`);
|
|
804
|
+
for await (const localMsg of this.store.iterateL1ToL2Messages({
|
|
805
|
+
reverse: true
|
|
799
806
|
})){
|
|
800
|
-
const remoteMsg = await this.retrieveL1ToL2Message(msg.leaf);
|
|
801
807
|
const logCtx = {
|
|
802
|
-
remoteMsg,
|
|
803
|
-
localMsg
|
|
808
|
+
remoteMsg: undefined,
|
|
809
|
+
localMsg,
|
|
810
|
+
remoteMessagesState
|
|
804
811
|
};
|
|
805
|
-
if
|
|
806
|
-
|
|
812
|
+
// First check if the local message rolling hash matches the current rolling hash of the inbox contract,
|
|
813
|
+
// which means we just need to rollback some local messages and we should be back in sync. This means there
|
|
814
|
+
// was an L1 reorg that removed some of the messages we had, but no new messages were added compared.
|
|
815
|
+
if (localMsg.rollingHash.equals(remoteRollingHash)) {
|
|
816
|
+
this.log.info(`Found common L1 to L2 message at index ${localMsg.index} on L1 block ${localMsg.l1BlockNumber} matching current remote state`, logCtx);
|
|
817
|
+
commonMsg = localMsg;
|
|
818
|
+
break;
|
|
819
|
+
}
|
|
820
|
+
// If there's no match with the current remote state, check if the message exists on the inbox contract at all
|
|
821
|
+
// by looking at the inbox events. If the L1 reorg *added* new messages in addition to deleting existing ones,
|
|
822
|
+
// then the current remote state's rolling hash will not match anything we have locally, so we need to check existence
|
|
823
|
+
// of individual messages via logs. Note we use logs and not historical queries so we don't have to depend on
|
|
824
|
+
// an archival rpc node, since the message could be from a long time ago if we're catching up with syncing.
|
|
825
|
+
const remoteMsg = await retrieveL1ToL2Message(this.inbox, localMsg);
|
|
826
|
+
logCtx.remoteMsg = remoteMsg;
|
|
827
|
+
if (remoteMsg && remoteMsg.rollingHash.equals(localMsg.rollingHash)) {
|
|
828
|
+
this.log.info(`Found most recent common L1 to L2 message at index ${localMsg.index} on L1 block ${localMsg.l1BlockNumber}`, logCtx);
|
|
807
829
|
commonMsg = remoteMsg;
|
|
808
830
|
break;
|
|
809
831
|
} else if (remoteMsg) {
|
|
810
|
-
this.log.debug(`Local L1 to L2 message with index ${
|
|
832
|
+
this.log.debug(`Local L1 to L2 message with index ${localMsg.index} has different rolling hash`, logCtx);
|
|
833
|
+
messagesToDelete++;
|
|
811
834
|
} else {
|
|
812
|
-
this.log.debug(`Local L1 to L2 message with index ${
|
|
835
|
+
this.log.debug(`Local L1 to L2 message with index ${localMsg.index} not found on L1`, logCtx);
|
|
836
|
+
messagesToDelete++;
|
|
813
837
|
}
|
|
814
838
|
}
|
|
815
|
-
// Delete everything after the common message we found.
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
839
|
+
// Delete everything after the common message we found, if anything needs to be deleted.
|
|
840
|
+
// Do not exit early if there are no messages to delete, we still want to update the syncpoint.
|
|
841
|
+
if (messagesToDelete > 0) {
|
|
842
|
+
const lastGoodIndex = commonMsg?.index;
|
|
843
|
+
this.log.warn(`Rolling back all local L1 to L2 messages after index ${lastGoodIndex ?? 'initial'}`);
|
|
844
|
+
await this.store.removeL1ToL2Messages(lastGoodIndex !== undefined ? lastGoodIndex + 1n : 0n);
|
|
845
|
+
}
|
|
819
846
|
// Update the syncpoint so the loop below reprocesses the changed messages. We go to the block before
|
|
820
847
|
// the last common one, so we force reprocessing it, in case new messages were added on that same L1 block
|
|
821
848
|
// after the last common message.
|
|
822
849
|
const syncPointL1BlockNumber = commonMsg ? commonMsg.l1BlockNumber - 1n : this.l1Constants.l1StartBlock;
|
|
823
850
|
const syncPointL1BlockHash = await this.getL1BlockHash(syncPointL1BlockNumber);
|
|
824
|
-
messagesSyncPoint = {
|
|
851
|
+
const messagesSyncPoint = {
|
|
825
852
|
l1BlockNumber: syncPointL1BlockNumber,
|
|
826
853
|
l1BlockHash: syncPointL1BlockHash
|
|
827
854
|
};
|
|
828
|
-
await this.store.
|
|
855
|
+
await this.store.setMessageSyncState(messagesSyncPoint, remoteTreeInProgress);
|
|
856
|
+
this.log.verbose(`Updated messages syncpoint to L1 block ${syncPointL1BlockNumber}`, {
|
|
857
|
+
...messagesSyncPoint,
|
|
858
|
+
remoteTreeInProgress
|
|
859
|
+
});
|
|
829
860
|
return messagesSyncPoint;
|
|
830
861
|
}
|
|
831
862
|
async getL1BlockHash(l1BlockNumber) {
|
|
@@ -972,25 +1003,43 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
972
1003
|
do {
|
|
973
1004
|
[searchStartBlock, searchEndBlock] = this.nextRange(searchEndBlock, currentL1BlockNumber);
|
|
974
1005
|
this.log.trace(`Retrieving checkpoints from L1 block ${searchStartBlock} to ${searchEndBlock}`);
|
|
975
|
-
//
|
|
976
|
-
const
|
|
977
|
-
if (
|
|
1006
|
+
// First fetch calldata only, no blobs yet, since we may be able to just get that data out of the proposed chain
|
|
1007
|
+
const calldataCheckpoints = await execInSpan(this.tracer, 'Archiver.retrieveCheckpointCalldataFromRollup', ()=>retrieveCheckpointCalldataFromRollup(this.rollup, this.publicClient, this.debugClient, searchStartBlock, searchEndBlock, this.instrumentation, this.log));
|
|
1008
|
+
if (calldataCheckpoints.length === 0) {
|
|
978
1009
|
// We are not calling `setBlockSynchedL1BlockNumber` because it may cause sync issues if based off infura.
|
|
979
1010
|
// See further details in earlier comments.
|
|
980
1011
|
this.log.trace(`Retrieved no new checkpoints from L1 block ${searchStartBlock} to ${searchEndBlock}`);
|
|
981
1012
|
continue;
|
|
982
1013
|
}
|
|
983
|
-
this.log.debug(`Retrieved ${
|
|
984
|
-
lastProcessedCheckpoint:
|
|
1014
|
+
this.log.debug(`Retrieved ${calldataCheckpoints.length} new checkpoint calldata between L1 blocks ${searchStartBlock} and ${searchEndBlock}`, {
|
|
1015
|
+
lastProcessedCheckpoint: calldataCheckpoints[calldataCheckpoints.length - 1].l1,
|
|
985
1016
|
searchStartBlock,
|
|
986
1017
|
searchEndBlock
|
|
987
1018
|
});
|
|
988
|
-
|
|
1019
|
+
// Check if the last checkpoint matches a local pending entry (so we can skip blob fetch).
|
|
1020
|
+
// We only check the last one; if it matches, the blob fetch is skipped for that entry.
|
|
1021
|
+
// TODO(palla/pipelining): We may have more than a single checkpoint to promote
|
|
1022
|
+
const lastCalldataCheckpoint = calldataCheckpoints[calldataCheckpoints.length - 1];
|
|
1023
|
+
const promoteResult = await this.tryBuildPublishedCheckpointFromProposed(lastCalldataCheckpoint);
|
|
1024
|
+
const checkpointToPromote = promoteResult && !('diverged' in promoteResult) ? promoteResult : undefined;
|
|
1025
|
+
const evictProposedFrom = promoteResult && 'diverged' in promoteResult ? promoteResult.fromCheckpointNumber : undefined;
|
|
1026
|
+
// Then fetch blobs in parallel and build the full published checkpoints
|
|
1027
|
+
const toFetchBlobs = checkpointToPromote ? calldataCheckpoints.slice(0, -1) : calldataCheckpoints;
|
|
1028
|
+
const blobFetched = await asyncPool(10, toFetchBlobs, async (checkpoint)=>retrievedToPublishedCheckpoint({
|
|
1029
|
+
...checkpoint,
|
|
1030
|
+
checkpointBlobData: await getCheckpointBlobDataFromBlobs(this.blobClient, checkpoint.l1.blockHash, checkpoint.blobHashes, checkpoint.checkpointNumber, this.log, !initialSyncComplete, checkpoint.parentBeaconBlockRoot, checkpoint.l1.timestamp)
|
|
1031
|
+
}));
|
|
1032
|
+
// And add the promoted checkpoint to the list of all checkpoints
|
|
1033
|
+
const publishedCheckpoints = checkpointToPromote ? [
|
|
1034
|
+
...blobFetched,
|
|
1035
|
+
checkpointToPromote
|
|
1036
|
+
] : blobFetched;
|
|
989
1037
|
const validCheckpoints = [];
|
|
1038
|
+
// Now loop through all checkpoints and validate their attestations
|
|
990
1039
|
for (const published of publishedCheckpoints){
|
|
991
1040
|
const validationResult = this.config.skipValidateCheckpointAttestations ? {
|
|
992
1041
|
valid: true
|
|
993
|
-
} : await validateCheckpointAttestations(published, this.epochCache, this.l1Constants, this.log);
|
|
1042
|
+
} : await validateCheckpointAttestations(published, this.epochCache, this.l1Constants, this.getSignatureContext(), this.log);
|
|
994
1043
|
// Only update the validation result if it has changed, so we can keep track of the first invalid checkpoint
|
|
995
1044
|
// in case there is a sequence of more than one invalid checkpoint, as we need to invalidate the first one.
|
|
996
1045
|
// There is an exception though: if a checkpoint is invalidated and replaced with another invalid checkpoint,
|
|
@@ -1045,8 +1094,17 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
1045
1094
|
}
|
|
1046
1095
|
try {
|
|
1047
1096
|
const updatedValidationResult = rollupStatus.validationResult === initialValidationResult ? undefined : rollupStatus.validationResult;
|
|
1048
|
-
|
|
1049
|
-
|
|
1097
|
+
// Split valid checkpoints: the promoted one (if any) is persisted via the proposed-promotion path,
|
|
1098
|
+
// the rest via addCheckpoints. Both paths run within the same store transaction for atomicity.
|
|
1099
|
+
const [[maybeValidCheckpointToPromote], checkpointsToAdd] = partition(validCheckpoints, (c)=>c.checkpoint.number === checkpointToPromote?.checkpoint.number);
|
|
1100
|
+
const [processDuration, result] = await elapsed(()=>execInSpan(this.tracer, 'Archiver.addCheckpoints', ()=>this.updater.addCheckpoints(checkpointsToAdd, updatedValidationResult, maybeValidCheckpointToPromote && {
|
|
1101
|
+
l1: lastCalldataCheckpoint.l1,
|
|
1102
|
+
attestations: lastCalldataCheckpoint.attestations,
|
|
1103
|
+
checkpoint: maybeValidCheckpointToPromote
|
|
1104
|
+
}, evictProposedFrom)));
|
|
1105
|
+
if (checkpointsToAdd.length > 0) {
|
|
1106
|
+
this.instrumentation.processNewCheckpointedBlocks(processDuration / checkpointsToAdd.length, checkpointsToAdd.flatMap((c)=>c.checkpoint.blocks));
|
|
1107
|
+
}
|
|
1050
1108
|
// If blocks were pruned due to conflict with L1 checkpoints, emit event
|
|
1051
1109
|
if (result.prunedBlocks && result.prunedBlocks.length > 0) {
|
|
1052
1110
|
const prunedCheckpointNumber = result.prunedBlocks[0].checkpointNumber;
|
|
@@ -1091,7 +1149,7 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
1091
1149
|
});
|
|
1092
1150
|
}
|
|
1093
1151
|
lastRetrievedCheckpoint = validCheckpoints.at(-1) ?? lastRetrievedCheckpoint;
|
|
1094
|
-
lastL1BlockWithCheckpoint =
|
|
1152
|
+
lastL1BlockWithCheckpoint = calldataCheckpoints.at(-1)?.l1.blockNumber ?? lastL1BlockWithCheckpoint;
|
|
1095
1153
|
}while (searchEndBlock < currentL1BlockNumber)
|
|
1096
1154
|
// Important that we update AFTER inserting the blocks.
|
|
1097
1155
|
await updateProvenCheckpoint();
|
|
@@ -1101,6 +1159,66 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
|
|
|
1101
1159
|
lastL1BlockWithCheckpoint
|
|
1102
1160
|
};
|
|
1103
1161
|
}
|
|
1162
|
+
/**
|
|
1163
|
+
* Checks if a specific checkpoint matches a local pending entry, and if so, loads local data to build
|
|
1164
|
+
* a synthetic published checkpoint (skipping blob fetch).
|
|
1165
|
+
*
|
|
1166
|
+
* Returns { diverged: true, fromCheckpointNumber } when the L1 checkpoint does NOT match local pending
|
|
1167
|
+
* data for that number, so the caller can evict the entire pending suffix >= fromCheckpointNumber
|
|
1168
|
+
* (those entries chain off the now-invalid local state) within the same addCheckpoints transaction.
|
|
1169
|
+
*/ async tryBuildPublishedCheckpointFromProposed(calldataCheckpoint) {
|
|
1170
|
+
if (this.config.skipPromoteProposedCheckpointDuringL1Sync || !calldataCheckpoint) {
|
|
1171
|
+
return undefined;
|
|
1172
|
+
}
|
|
1173
|
+
// Look up the specific pending entry for the checkpoint being mined, not just the tip
|
|
1174
|
+
const proposed = await this.store.getProposedCheckpointByNumber(calldataCheckpoint.checkpointNumber);
|
|
1175
|
+
if (!proposed) {
|
|
1176
|
+
return undefined;
|
|
1177
|
+
}
|
|
1178
|
+
if (!proposed.header.equals(calldataCheckpoint.header) || !proposed.archive.root.equals(calldataCheckpoint.archiveRoot)) {
|
|
1179
|
+
this.log.warn(`Local proposed checkpoint ${proposed.checkpointNumber} does not match checkpoint retrieved from L1, overriding with L1 data`, {
|
|
1180
|
+
proposedCheckpointNumber: proposed.checkpointNumber,
|
|
1181
|
+
proposedHeader: proposed.header.toInspect(),
|
|
1182
|
+
proposedArchiveRoot: proposed.archive.root.toString(),
|
|
1183
|
+
calldataCheckpointNumber: calldataCheckpoint.checkpointNumber,
|
|
1184
|
+
calldataHeader: calldataCheckpoint.header.toInspect(),
|
|
1185
|
+
calldataArchiveRoot: calldataCheckpoint.archiveRoot.toString()
|
|
1186
|
+
});
|
|
1187
|
+
// Return a divergence signal so the caller can evict pending >= this number
|
|
1188
|
+
return {
|
|
1189
|
+
diverged: true,
|
|
1190
|
+
fromCheckpointNumber: proposed.checkpointNumber
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
this.log.debug(`Building published checkpoint from proposed ${calldataCheckpoint.checkpointNumber} (skipping blob fetch)`, {
|
|
1194
|
+
proposedHeader: proposed.header.toInspect(),
|
|
1195
|
+
proposedArchiveRoot: proposed.archive.root.toString()
|
|
1196
|
+
});
|
|
1197
|
+
const blocks = await this.store.getBlocks(BlockNumber(proposed.startBlock), proposed.blockCount);
|
|
1198
|
+
if (blocks.length !== proposed.blockCount) {
|
|
1199
|
+
this.log.warn(`Local proposed checkpoint ${proposed.checkpointNumber} has wrong block count (expected ${proposed.blockCount} blocks starting at ${proposed.startBlock} but got ${blocks.length})`, {
|
|
1200
|
+
proposedCheckpointNumber: proposed.checkpointNumber,
|
|
1201
|
+
proposedStartBlock: proposed.startBlock,
|
|
1202
|
+
proposedBlockCount: proposed.blockCount,
|
|
1203
|
+
retrievedBlocks: blocks.map((b)=>b.number)
|
|
1204
|
+
});
|
|
1205
|
+
return undefined;
|
|
1206
|
+
}
|
|
1207
|
+
const checkpoint = Checkpoint.from({
|
|
1208
|
+
archive: proposed.archive,
|
|
1209
|
+
header: proposed.header,
|
|
1210
|
+
blocks,
|
|
1211
|
+
number: proposed.checkpointNumber,
|
|
1212
|
+
feeAssetPriceModifier: proposed.feeAssetPriceModifier
|
|
1213
|
+
});
|
|
1214
|
+
const promotedCheckpoint = PublishedCheckpoint.from({
|
|
1215
|
+
checkpoint,
|
|
1216
|
+
l1: calldataCheckpoint.l1,
|
|
1217
|
+
attestations: calldataCheckpoint.attestations
|
|
1218
|
+
});
|
|
1219
|
+
this.instrumentation.processCheckpointPromoted();
|
|
1220
|
+
return promotedCheckpoint;
|
|
1221
|
+
}
|
|
1104
1222
|
async checkForNewCheckpointsBeforeL1SyncPoint(status, blocksSynchedTo, currentL1BlockNumber) {
|
|
1105
1223
|
const { lastRetrievedCheckpoint, pendingCheckpointNumber } = status;
|
|
1106
1224
|
// Compare the last checkpoint we have (either retrieved in this round or loaded from store) with what the
|
|
@@ -3,15 +3,16 @@ import type { Logger } from '@aztec/foundation/log';
|
|
|
3
3
|
import { type AttestationInfo, type ValidateCheckpointResult } from '@aztec/stdlib/block';
|
|
4
4
|
import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
5
5
|
import { type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
6
|
+
import { type CoordinationSignatureContext } from '@aztec/stdlib/p2p';
|
|
6
7
|
export type { ValidateCheckpointResult };
|
|
7
8
|
/**
|
|
8
9
|
* Extracts attestation information from a published checkpoint.
|
|
9
10
|
* Returns info for each attestation, preserving array indices.
|
|
10
11
|
*/
|
|
11
|
-
export declare function getAttestationInfoFromPublishedCheckpoint({ checkpoint, attestations }: PublishedCheckpoint): AttestationInfo[];
|
|
12
|
+
export declare function getAttestationInfoFromPublishedCheckpoint({ checkpoint, attestations }: PublishedCheckpoint, signatureContext: CoordinationSignatureContext): AttestationInfo[];
|
|
12
13
|
/**
|
|
13
14
|
* Validates the attestations submitted for the given checkpoint.
|
|
14
15
|
* Returns true if the attestations are valid and sufficient, false otherwise.
|
|
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
|
+
export declare function validateCheckpointAttestations(publishedCheckpoint: PublishedCheckpoint, epochCache: EpochCache, constants: Pick<L1RollupConstants, 'epochDuration'>, signatureContext: CoordinationSignatureContext, logger?: Logger): Promise<ValidateCheckpointResult>;
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGlvbi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL21vZHVsZXMvdmFsaWRhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUdyRCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUNwRCxPQUFPLEVBQ0wsS0FBSyxlQUFlLEVBRXBCLEtBQUssd0JBQXdCLEVBRTlCLE1BQU0scUJBQXFCLENBQUM7QUFDN0IsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUNwRSxPQUFPLEVBQUUsS0FBSyxpQkFBaUIsRUFBaUMsTUFBTSw2QkFBNkIsQ0FBQztBQUNwRyxPQUFPLEVBQW9CLEtBQUssNEJBQTRCLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUV4RixZQUFZLEVBQUUsd0JBQXdCLEVBQUUsQ0FBQztBQUV6Qzs7O0dBR0c7QUFDSCx3QkFBZ0IseUNBQXlDLENBQ3ZELEVBQUUsVUFBVSxFQUFFLFlBQVksRUFBRSxFQUFFLG1CQUFtQixFQUNqRCxnQkFBZ0IsRUFBRSw0QkFBNEIsR0FDN0MsZUFBZSxFQUFFLENBR25CO0FBRUQ7OztHQUdHO0FBQ0gsd0JBQXNCLDhCQUE4QixDQUNsRCxtQkFBbUIsRUFBRSxtQkFBbUIsRUFDeEMsVUFBVSxFQUFFLFVBQVUsRUFDdEIsU0FBUyxFQUFFLElBQUksQ0FBQyxpQkFBaUIsRUFBRSxlQUFlLENBQUMsRUFDbkQsZ0JBQWdCLEVBQUUsNEJBQTRCLEVBQzlDLE1BQU0sQ0FBQyxFQUFFLE1BQU0sR0FDZCxPQUFPLENBQUMsd0JBQXdCLENBQUMsQ0EyRm5DIn0=
|
|
@@ -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;AACpG,OAAO,EAAoB,KAAK,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AAExF,YAAY,EAAE,wBAAwB,EAAE,CAAC;AAEzC;;;GAGG;AACH,wBAAgB,yCAAyC,CACvD,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,mBAAmB,EACjD,gBAAgB,EAAE,4BAA4B,GAC7C,eAAe,EAAE,CAGnB;AAED;;;GAGG;AACH,wBAAsB,8BAA8B,CAClD,mBAAmB,EAAE,mBAAmB,EACxC,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,eAAe,CAAC,EACnD,gBAAgB,EAAE,4BAA4B,EAC9C,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,wBAAwB,CAAC,CA2FnC"}
|