@aztec-labs/archiver 6.0.0-rc.3 → 6.0.0-rc.4

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.
Files changed (62) hide show
  1. package/dest/archiver.d.ts +11 -2
  2. package/dest/archiver.d.ts.map +1 -1
  3. package/dest/archiver.js +94 -2
  4. package/dest/config.js +1 -1
  5. package/dest/errors.d.ts +12 -1
  6. package/dest/errors.d.ts.map +1 -1
  7. package/dest/errors.js +12 -0
  8. package/dest/l1/bin/retrieve-calldata.js +7 -5
  9. package/dest/l1/calldata_retriever.d.ts +5 -2
  10. package/dest/l1/calldata_retriever.d.ts.map +1 -1
  11. package/dest/l1/calldata_retriever.js +8 -3
  12. package/dest/l1/data_retrieval.d.ts +2 -1
  13. package/dest/l1/data_retrieval.d.ts.map +1 -1
  14. package/dest/l1/data_retrieval.js +14 -9
  15. package/dest/l1/validate_trace.d.ts +3 -1
  16. package/dest/l1/validate_trace.d.ts.map +1 -1
  17. package/dest/l1/validate_trace.js +8 -3
  18. package/dest/modules/checkpoint_ingestor.d.ts +71 -0
  19. package/dest/modules/checkpoint_ingestor.d.ts.map +1 -0
  20. package/dest/modules/checkpoint_ingestor.js +516 -0
  21. package/dest/modules/data_store_updater.d.ts +6 -11
  22. package/dest/modules/data_store_updater.d.ts.map +1 -1
  23. package/dest/modules/data_store_updater.js +4 -3
  24. package/dest/modules/instrumentation.d.ts +8 -4
  25. package/dest/modules/instrumentation.d.ts.map +1 -1
  26. package/dest/modules/instrumentation.js +8 -2
  27. package/dest/modules/l1_synchronizer.d.ts +3 -7
  28. package/dest/modules/l1_synchronizer.d.ts.map +1 -1
  29. package/dest/modules/l1_synchronizer.js +84 -420
  30. package/dest/modules/pending_chain_validation_tracker.d.ts +21 -0
  31. package/dest/modules/pending_chain_validation_tracker.d.ts.map +1 -0
  32. package/dest/modules/pending_chain_validation_tracker.js +32 -0
  33. package/dest/modules/validation.d.ts +2 -2
  34. package/dest/modules/validation.d.ts.map +1 -1
  35. package/dest/modules/validation.js +17 -11
  36. package/dest/store/block_store.d.ts +1 -1
  37. package/dest/store/block_store.d.ts.map +1 -1
  38. package/dest/store/block_store.js +8 -2
  39. package/dest/store/log_store_codec.d.ts +2 -1
  40. package/dest/store/log_store_codec.d.ts.map +1 -1
  41. package/dest/store/log_store_codec.js +1 -0
  42. package/dest/test/fake_l1_state.d.ts +21 -1
  43. package/dest/test/fake_l1_state.d.ts.map +1 -1
  44. package/dest/test/fake_l1_state.js +82 -30
  45. package/package.json +15 -15
  46. package/src/archiver.ts +112 -3
  47. package/src/config.ts +1 -1
  48. package/src/errors.ts +21 -0
  49. package/src/l1/README.md +5 -0
  50. package/src/l1/bin/retrieve-calldata.ts +5 -3
  51. package/src/l1/calldata_retriever.ts +8 -3
  52. package/src/l1/data_retrieval.ts +13 -11
  53. package/src/l1/validate_trace.ts +11 -2
  54. package/src/modules/checkpoint_ingestor.ts +742 -0
  55. package/src/modules/data_store_updater.ts +7 -13
  56. package/src/modules/instrumentation.ts +17 -3
  57. package/src/modules/l1_synchronizer.ts +116 -563
  58. package/src/modules/pending_chain_validation_tracker.ts +43 -0
  59. package/src/modules/validation.ts +13 -9
  60. package/src/store/block_store.ts +6 -0
  61. package/src/store/log_store_codec.ts +1 -0
  62. package/src/test/fake_l1_state.ts +94 -31
@@ -376,22 +376,16 @@ import { asyncPool } from '@aztec-labs/foundation/async-pool';
376
376
  import { maxBigint } from '@aztec-labs/foundation/bigint';
377
377
  import { BlockNumber, CheckpointNumber } from '@aztec-labs/foundation/branded-types';
378
378
  import { Buffer32 } from '@aztec-labs/foundation/buffer';
379
- import { partition, pick } from '@aztec-labs/foundation/collection';
380
- import { Fr } from '@aztec-labs/foundation/curves/bn254';
381
- import { EthAddress } from '@aztec-labs/foundation/eth-address';
382
379
  import { createLogger } from '@aztec-labs/foundation/log';
383
380
  import { count } from '@aztec-labs/foundation/string';
384
- import { Timer, elapsed } from '@aztec-labs/foundation/timer';
381
+ import { Timer } from '@aztec-labs/foundation/timer';
385
382
  import { isDefined } from '@aztec-labs/foundation/types';
386
383
  import { L2BlockSourceEvents } from '@aztec-labs/stdlib/block';
387
- import { Checkpoint, PublishedCheckpoint } from '@aztec-labs/stdlib/checkpoint';
388
384
  import { getEpochAtSlot, getSlotAtNextL1Block } from '@aztec-labs/stdlib/epoch-helpers';
389
385
  import { execInSpan, trackSpan } from '@aztec-labs/telemetry-client';
390
- import { InitialCheckpointNumberNotSequentialError } from '../errors.js';
391
- import { getCheckpointBlobDataFromBlobs, retrieveCheckpointCalldataFromRollup, retrievedToPublishedCheckpoint } from '../l1/data_retrieval.js';
386
+ import { CheckpointIngestor } from './checkpoint_ingestor.js';
392
387
  import { ArchiverDataStoreUpdater, blockLeafCount } from './data_store_updater.js';
393
388
  import { InboxMessageSynchronizer } from './inbox_message_synchronizer.js';
394
- import { resolveCheckpointAttestationsFromCalldata } from './validation.js';
395
389
  /** Bounded Inbox message sync passes (a recovery step each) taken within one archiver sync iteration. */ const MAX_MESSAGE_SYNC_PASSES_PER_ITERATION = 3;
396
390
  _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpochPrune'), _dec2 = trackSpan('Archiver.syncL1ToL2Messages'), _dec3 = trackSpan('Archiver.handleCheckpoints');
397
391
  /**
@@ -399,13 +393,10 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
399
393
  * Responsible for fetching checkpoints, L1 to L2 messages, and handling L1 reorgs.
400
394
  */ export class ArchiverL1Synchronizer {
401
395
  publicClient;
402
- debugClient;
403
396
  rollup;
404
397
  inbox;
405
398
  stores;
406
399
  config;
407
- blobClient;
408
- epochCache;
409
400
  dateProvider;
410
401
  instrumentation;
411
402
  l1Constants;
@@ -441,6 +432,7 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
441
432
  l1Timestamp;
442
433
  updater;
443
434
  messageSynchronizer;
435
+ checkpointIngestor;
444
436
  /**
445
437
  * Set when an Inbox message replacement reached below the checkpointed tip's consumed count. The published chain
446
438
  * is then L1's to reconcile through checkpoint sync; until the checkpointed tip agrees with the message log again,
@@ -449,13 +441,10 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
449
441
  tracer;
450
442
  constructor(publicClient, debugClient, rollup, inbox, stores, config, blobClient, epochCache, dateProvider, instrumentation, l1Constants, events, tracer, l2FrontierCache, log = createLogger('archiver:l1-sync')){
451
443
  this.publicClient = publicClient;
452
- this.debugClient = debugClient;
453
444
  this.rollup = rollup;
454
445
  this.inbox = inbox;
455
446
  this.stores = stores;
456
447
  this.config = config;
457
- this.blobClient = blobClient;
458
- this.epochCache = epochCache;
459
448
  this.dateProvider = dateProvider;
460
449
  this.instrumentation = instrumentation;
461
450
  this.l1Constants = l1Constants;
@@ -470,6 +459,24 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
470
459
  l1BlockNumber: l1Constants.l1StartBlock,
471
460
  l1BlockHash: l1Constants.l1StartBlockHash
472
461
  }, ()=>this.getBatchSizeInL1Blocks(), undefined, (count, msPerMessage)=>this.instrumentation.processNewMessages(count, msPerMessage), this.log.createChild('inbox'));
462
+ this.checkpointIngestor = new CheckpointIngestor({
463
+ rollup,
464
+ publicClient,
465
+ debugClient,
466
+ blobClient,
467
+ epochCache,
468
+ stores,
469
+ updater: this.updater,
470
+ events,
471
+ instrumentation,
472
+ l1Constants,
473
+ tracer,
474
+ log: this.log
475
+ }, ()=>({
476
+ batchSizeInL1Blocks: this.getBatchSizeInL1Blocks(),
477
+ skipValidateCheckpointAttestations: this.config.skipValidateCheckpointAttestations ?? false,
478
+ skipPromoteProposedCheckpointDuringL1Sync: this.config.skipPromoteProposedCheckpointDuringL1Sync ?? false
479
+ }));
473
480
  this.tracer = tracer;
474
481
  }
475
482
  /**
@@ -491,12 +498,6 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
491
498
  /** Returns the last L1 timestamp that was synced. */ getL1Timestamp() {
492
499
  return this.l1Timestamp;
493
500
  }
494
- getSignatureContext() {
495
- return {
496
- chainId: this.publicClient.chain.id,
497
- rollupAddress: EthAddress.fromString(this.rollup.address)
498
- };
499
- }
500
501
  /** Checks that the ethereum node we are connected to has a latest timestamp no more than the allowed drift. Throw if not. */ async testEthereumNodeSynced() {
501
502
  const maxAllowedDelay = this.config.maxAllowedEthClientDriftSeconds;
502
503
  if (maxAllowedDelay === 0) {
@@ -569,11 +570,16 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
569
570
  // may leave the messages pending; checkpoints are still processed below so a disagreement below the checkpointed
570
571
  // tip can be reconciled from L1, but the iteration then does not advertise the head as synced.
571
572
  const messageSync = await this.syncL1ToL2Messages(currentL1BlockData, finalizedL1Block);
573
+ // A behind-syncpoint rollback rewinds the persisted scan point but not this iteration's head. Advertising the
574
+ // head as synced now would let the next same-head sync return early before the rewound scan point is re-read,
575
+ // leaving the detected checkpoint absent until another L1 block arrives.
576
+ let rolledBackScanPoint = false;
572
577
  if (currentL1BlockNumber > blocksSynchedTo) {
573
578
  // First we retrieve new checkpoints and L2 blocks and store them in the DB. This will also update the
574
579
  // pending chain validation status, proven checkpoint number, and synched L1 block number.
575
- const rollupStatus = await this.handleCheckpoints(blocksSynchedTo, currentL1BlockNumber, initialSyncComplete);
576
- blocksAdded.push(...rollupStatus.blocksAdded);
580
+ const checkpointSync = await this.handleCheckpoints(blocksSynchedTo, currentL1BlockNumber, initialSyncComplete);
581
+ const { rollupStatus } = checkpointSync;
582
+ blocksAdded.push(...checkpointSync.blocksAdded);
577
583
  // Then we try pruning uncheckpointed blocks if a new slot was mined without checkpoints
578
584
  await this.pruneUncheckpointedBlocks(currentL1Timestamp);
579
585
  // Then we prune the current epoch if it'd reorg on next submission.
@@ -586,11 +592,11 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
586
592
  // We only do this if rollup cant prune on the next submission. Otherwise we will end up
587
593
  // re-syncing the checkpoints we have just unwound above.
588
594
  if (!rollupCanPrune) {
589
- await this.checkForNewCheckpointsBeforeL1SyncPoint(rollupStatus, blocksSynchedTo, currentL1BlockNumber);
595
+ rolledBackScanPoint = await this.checkForNewCheckpointsBeforeL1SyncPoint(rollupStatus, checkpointSync.lastSeenCheckpoint, blocksSynchedTo, currentL1BlockNumber);
590
596
  }
591
597
  this.instrumentation.updateL1BlockHeight(currentL1BlockNumber);
592
598
  } else if (await this.checkpointedChainNeedsReconciliation(currentL1BlockData)) {
593
- await this.reconcileCheckpointedChainAtNonAdvancingHead(blocksSynchedTo, currentL1BlockNumber);
599
+ rolledBackScanPoint = await this.reconcileCheckpointedChainAtNonAdvancingHead(blocksSynchedTo, currentL1BlockNumber);
594
600
  }
595
601
  // Update the finalized L2 checkpoint based on L1 finality.
596
602
  await this.updateFinalizedCheckpoint(finalizedL1Block);
@@ -598,10 +604,11 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
598
604
  // Readiness (the synced L1 block, which drives the synced L2 slot proposers build on) is only advanced once the
599
605
  // messages agree with L1 at this head and the checkpointed tip agrees with them: while either is pending, nothing
600
606
  // may build on the local tip.
601
- if (messageSync !== 'synced' || this.speculationGate !== undefined) {
607
+ if (messageSync !== 'synced' || this.speculationGate !== undefined || rolledBackScanPoint) {
602
608
  this.log.verbose(`Not advertising L1 block ${currentL1BlockNumber} as synced`, {
603
609
  currentL1BlockNumber,
604
610
  messageSync,
611
+ rolledBackScanPoint,
605
612
  speculationGate: this.speculationGate,
606
613
  recovery: this.messageSynchronizer.getRecoveryProgress()
607
614
  });
@@ -737,20 +744,6 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
737
744
  rollupCanPrune
738
745
  };
739
746
  }
740
- nextRange(end, limit) {
741
- const nextStart = end + 1n;
742
- const nextEnd = nextStart + this.getBatchSizeInL1Blocks();
743
- if (nextEnd > limit) {
744
- return [
745
- nextStart,
746
- limit
747
- ];
748
- }
749
- return [
750
- nextStart,
751
- nextEnd
752
- ];
753
- }
754
747
  /**
755
748
  * Runs Inbox message sync passes against the captured head until the messages are synced to it or the per-iteration
756
749
  * pass budget is spent. Each pass is bounded; a recovery that needs more work continues on the next iteration, which
@@ -877,7 +870,7 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
877
870
  if (currentL1BlockNumber < await this.stores.blocks.getSynchedL1BlockNumber()) {
878
871
  await this.stores.blocks.setSynchedL1BlockNumber(currentL1BlockNumber);
879
872
  }
880
- await this.checkForNewCheckpointsBeforeL1SyncPoint(rollupStatus, blocksSynchedTo, currentL1BlockNumber);
873
+ return this.checkForNewCheckpointsBeforeL1SyncPoint(rollupStatus, undefined, blocksSynchedTo, currentL1BlockNumber);
881
874
  }
882
875
  /**
883
876
  * Compares the local checkpointed chain with the rollup's status at the given L1 head: updates the proven tip and
@@ -885,17 +878,14 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
885
878
  * is not the case when neither side has checkpoints or L1's pending tip is exactly the local one.
886
879
  */ async reconcileCheckpointedChain(blocksSynchedTo, currentL1BlockNumber) {
887
880
  const localPendingCheckpointNumber = await this.stores.blocks.getLatestCheckpointNumber();
888
- const initialValidationResult = await this.stores.blocks.getPendingChainValidationStatus();
889
881
  const { provenCheckpointNumber, provenArchive, pendingCheckpointNumber, pendingArchive, archiveOfMyCheckpoint: archiveForLocalPendingCheckpointNumber } = await execInSpan(this.tracer, 'Archiver.getRollupStatus', ()=>this.rollup.status(localPendingCheckpointNumber, {
890
882
  blockNumber: currentL1BlockNumber
891
883
  }));
892
884
  const rollupStatus = {
893
885
  provenCheckpointNumber,
894
- provenArchive: provenArchive.toString(),
886
+ provenArchive,
895
887
  pendingCheckpointNumber,
896
- pendingArchive: pendingArchive.toString(),
897
- validationResult: initialValidationResult,
898
- blocksAdded: []
888
+ pendingArchive
899
889
  };
900
890
  this.log.trace(`Retrieved rollup status at current L1 block ${currentL1BlockNumber}.`, {
901
891
  localPendingCheckpointNumber,
@@ -912,8 +902,7 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
912
902
  this.log.debug(`No checkpoints to retrieve from ${blocksSynchedTo + 1n} to ${currentL1BlockNumber}, no checkpoints on chain`);
913
903
  return {
914
904
  rollupStatus,
915
- fetchCheckpoints: false,
916
- provenArchive
905
+ fetchCheckpoints: false
917
906
  };
918
907
  }
919
908
  await this.updateProvenCheckpoint(provenCheckpointNumber, provenArchive);
@@ -925,7 +914,7 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
925
914
  throw new Error(`Missing checkpoint ${localPendingCheckpointNumber}`);
926
915
  }
927
916
  const localPendingArchiveRoot = localPendingCheckpoint.archive.root.toString();
928
- const noCheckpointSinceLast = localPendingCheckpoint && pendingArchive.toString() === localPendingArchiveRoot;
917
+ const noCheckpointSinceLast = pendingArchive.toString() === localPendingArchiveRoot;
929
918
  if (noCheckpointSinceLast) {
930
919
  // We believe the following line causes a problem when we encounter L1 re-orgs.
931
920
  // Basically, by setting the synched L1 block number here, we are saying that we have
@@ -943,8 +932,7 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
943
932
  this.log.debug(`No checkpoints to retrieve from ${blocksSynchedTo + 1n} to ${currentL1BlockNumber}`);
944
933
  return {
945
934
  rollupStatus,
946
- fetchCheckpoints: false,
947
- provenArchive
935
+ fetchCheckpoints: false
948
936
  };
949
937
  }
950
938
  const localPendingCheckpointInChain = archiveForLocalPendingCheckpointNumber.equals(localPendingCheckpoint.archive.root);
@@ -958,22 +946,7 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
958
946
  localPendingArchiveRoot,
959
947
  archiveForLocalPendingCheckpointNumber
960
948
  });
961
- let tipAfterUnwind = localPendingCheckpointNumber;
962
- while(true){
963
- const candidateCheckpoint = await this.stores.blocks.getCheckpointData(tipAfterUnwind);
964
- if (candidateCheckpoint === undefined) {
965
- break;
966
- }
967
- const archiveAtContract = await this.rollup.archiveAt(candidateCheckpoint.checkpointNumber);
968
- this.log.trace(`Checking local checkpoint ${candidateCheckpoint.checkpointNumber} with archive ${candidateCheckpoint.archive.root}`, {
969
- archiveAtContract,
970
- archiveLocal: candidateCheckpoint.archive.root.toString()
971
- });
972
- if (archiveAtContract.equals(candidateCheckpoint.archive.root)) {
973
- break;
974
- }
975
- tipAfterUnwind--;
976
- }
949
+ const tipAfterUnwind = await this.findLastCheckpointAlsoOnL1(localPendingCheckpointNumber);
977
950
  const checkpointsToRemove = localPendingCheckpointNumber - tipAfterUnwind;
978
951
  await this.updater.removeCheckpointsAfter(CheckpointNumber(tipAfterUnwind));
979
952
  if (checkpointsToRemove > 0) {
@@ -984,10 +957,31 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
984
957
  }
985
958
  return {
986
959
  rollupStatus,
987
- fetchCheckpoints: true,
988
- provenArchive
960
+ fetchCheckpoints: true
989
961
  };
990
962
  }
963
+ /**
964
+ * Walks down from the given local checkpoint to the latest one whose archive matches the rollup's, stopping early at
965
+ * a checkpoint missing locally.
966
+ */ async findLastCheckpointAlsoOnL1(from) {
967
+ let tipAfterUnwind = from;
968
+ while(true){
969
+ const candidateCheckpoint = await this.stores.blocks.getCheckpointData(tipAfterUnwind);
970
+ if (candidateCheckpoint === undefined) {
971
+ break;
972
+ }
973
+ const archiveAtContract = await this.rollup.archiveAt(candidateCheckpoint.checkpointNumber);
974
+ this.log.trace(`Checking local checkpoint ${candidateCheckpoint.checkpointNumber} with archive ${candidateCheckpoint.archive.root}`, {
975
+ archiveAtContract,
976
+ archiveLocal: candidateCheckpoint.archive.root.toString()
977
+ });
978
+ if (archiveAtContract.equals(candidateCheckpoint.archive.root)) {
979
+ break;
980
+ }
981
+ tipAfterUnwind--;
982
+ }
983
+ return tipAfterUnwind;
984
+ }
991
985
  async updateProvenCheckpoint(provenCheckpointNumber, provenArchive) {
992
986
  // Annoying edge case: if proven checkpoint is moved back to 0 due to a reorg at the beginning of the chain,
993
987
  // we need to set it to zero. This is an edge case because we dont have a checkpoint zero (initial checkpoint is one),
@@ -1032,363 +1026,30 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
1032
1026
  }
1033
1027
  }
1034
1028
  async handleCheckpoints(blocksSynchedTo, currentL1BlockNumber, initialSyncComplete) {
1035
- const { rollupStatus, fetchCheckpoints, provenArchive } = await this.reconcileCheckpointedChain(blocksSynchedTo, currentL1BlockNumber);
1029
+ const { rollupStatus, fetchCheckpoints } = await this.reconcileCheckpointedChain(blocksSynchedTo, currentL1BlockNumber);
1036
1030
  if (!fetchCheckpoints) {
1037
- return rollupStatus;
1031
+ return {
1032
+ rollupStatus,
1033
+ blocksAdded: [],
1034
+ lastSeenCheckpoint: undefined
1035
+ };
1038
1036
  }
1039
- const { blocksAdded, validationResult: initialValidationResult } = rollupStatus;
1040
- // Retrieve checkpoints in batches. Each batch is estimated to accommodate up to 'blockBatchSize' L1 blocks,
1041
- // computed using the L2 block time vs the L1 block time.
1042
- let searchStartBlock = blocksSynchedTo;
1043
- let searchEndBlock = blocksSynchedTo;
1044
- let lastRetrievedCheckpoint;
1045
- let lastSeenCheckpoint;
1046
- do {
1047
- [searchStartBlock, searchEndBlock] = this.nextRange(searchEndBlock, currentL1BlockNumber);
1048
- this.log.trace(`Retrieving checkpoints from L1 block ${searchStartBlock} to ${searchEndBlock}`);
1049
- // First fetch calldata only, no blobs yet, since we may be able to just get that data out of the proposed chain
1050
- const calldataCheckpoints = await execInSpan(this.tracer, 'Archiver.retrieveCheckpointCalldataFromRollup', ()=>retrieveCheckpointCalldataFromRollup(this.rollup, this.publicClient, this.debugClient, searchStartBlock, searchEndBlock, this.instrumentation, this.log));
1051
- if (calldataCheckpoints.length === 0) {
1052
- // We are not calling `setBlockSynchedL1BlockNumber` because it may cause sync issues if based off infura.
1053
- // See further details in earlier comments.
1054
- this.log.trace(`Retrieved no new checkpoints from L1 block ${searchStartBlock} to ${searchEndBlock}`);
1055
- continue;
1056
- }
1057
- this.log.debug(`Retrieved ${calldataCheckpoints.length} new checkpoint calldata between L1 blocks ${searchStartBlock} and ${searchEndBlock}`, {
1058
- lastProcessedCheckpoint: calldataCheckpoints[calldataCheckpoints.length - 1].l1,
1059
- searchStartBlock,
1060
- searchEndBlock
1061
- });
1062
- // Screening below records rejected checkpoints as it goes, and each such write advances the L1 sync point past
1063
- // the rejected checkpoint's L1 block before the batch's valid checkpoints are persisted. If anything in the batch
1064
- // throws before the batch is persisted, the sync point is restored to where it stood before the batch, so the
1065
- // next iteration processes the whole batch again instead of skipping its valid checkpoints. Once the batch is
1066
- // persisted the sync point is left alone: replaying it would refetch blobs for checkpoints already stored,
1067
- // including promoted ones this node never fetched blobs for, and stall if those blobs are unavailable.
1068
- const syncPointBeforeBatch = await this.stores.blocks.getSynchedL1BlockNumber();
1069
- let batchPersisted = false;
1070
- try {
1071
- // Decode and validate attestations from CALLDATA before fetching any blobs, so a checkpoint with invalid
1072
- // attestations is rejected without decoding a possibly malformed blob. Runs even when validation is
1073
- // disabled, since promotion and persistence need the decoded attestations.
1074
- const resolvedCheckpoints = await asyncPool(10, calldataCheckpoints, async (calldataCheckpoint)=>{
1075
- const { attestations, validationResult } = await resolveCheckpointAttestationsFromCalldata(calldataCheckpoint, this.epochCache, this.l1Constants, this.getSignatureContext(), this.log);
1076
- return {
1077
- checkpoint: {
1078
- ...calldataCheckpoint,
1079
- attestations
1080
- },
1081
- validationResult
1082
- };
1083
- });
1084
- // Check if the last checkpoint matches a local pending entry (so we can skip blob fetch).
1085
- // We only check the last one; if it matches, the blob fetch is skipped for that entry.
1086
- // TODO(palla/pipelining): We may have more than a single checkpoint to promote
1087
- const lastCalldataCheckpoint = resolvedCheckpoints[resolvedCheckpoints.length - 1].checkpoint;
1088
- const promoteResult = await this.tryBuildPublishedCheckpointFromProposed(lastCalldataCheckpoint);
1089
- const checkpointToPromote = promoteResult && !('diverged' in promoteResult) ? promoteResult : undefined;
1090
- const evictProposedFrom = promoteResult && 'diverged' in promoteResult ? promoteResult.fromCheckpointNumber : undefined;
1091
- const checkpointsToIngest = [];
1092
- for (const { checkpoint: calldataCheckpoint, validationResult: resolvedValidationResult } of resolvedCheckpoints){
1093
- // Check the attestations uploaded by the publisher to L1 are correct.
1094
- // Rollup contract does not validate attestations to save on gas, so this
1095
- // falls on the nodes to verify offchain and skip those checkpoints.
1096
- const validationResult = this.config.skipValidateCheckpointAttestations ? {
1097
- valid: true
1098
- } : resolvedValidationResult;
1099
- // Also skip the checkpoint if it builds on a previously-rejected ancestor. Without
1100
- // this, addCheckpoints would throw InitialCheckpointNumberNotSequentialError when the
1101
- // ancestor was skipped earlier (e.g. due to invalid attestations), the catch handler
1102
- // would roll back the L1 sync point, and the next iteration would re-fetch and re-throw.
1103
- const rejectedAncestor = await this.stores.blocks.getRejectedCheckpointByArchiveRoot(calldataCheckpoint.header.lastArchiveRoot);
1104
- // Update the validation result if it has changed, so we can keep track of the first invalid checkpoint
1105
- // in case there is a sequence of more than one invalid checkpoint, as we need to invalidate the first one.
1106
- // There is an exception though: if a checkpoint is invalidated and replaced with another invalid checkpoint,
1107
- // we need to update the validation result, since we need to be able to invalidate the new one.
1108
- // See test 'chain progresses if an invalid checkpoint is invalidated with an invalid one' for more info.
1109
- // Do not update the validation result if there is a rejected ancestor, since in that case we want to keep the
1110
- // original invalidation, as the new checkpoint is extending from a previous invalid one.
1111
- const validStatusChanged = rollupStatus.validationResult?.valid !== validationResult.valid;
1112
- const invalidStatusWithSameCheckpointNumber = !validationResult.valid && rollupStatus.validationResult && !rollupStatus.validationResult.valid && rollupStatus.validationResult.checkpoint.checkpointNumber === validationResult.checkpoint.checkpointNumber;
1113
- if (!rejectedAncestor && (validStatusChanged || invalidStatusWithSameCheckpointNumber)) {
1114
- rollupStatus.validationResult = validationResult;
1115
- }
1116
- if (!validationResult.valid) {
1117
- this.log.warn(`Skipping checkpoint ${calldataCheckpoint.checkpointNumber} due to invalid attestations`, {
1118
- checkpointNumber: calldataCheckpoint.checkpointNumber,
1119
- l1BlockNumber: calldataCheckpoint.l1.blockNumber,
1120
- ...pick(validationResult, 'reason')
1121
- });
1122
- // Emit event for invalid checkpoint detection
1123
- this.events.emit(L2BlockSourceEvents.InvalidAttestationsCheckpointDetected, {
1124
- type: L2BlockSourceEvents.InvalidAttestationsCheckpointDetected,
1125
- validationResult
1126
- });
1127
- // Persist a rejected-ancestor entry so any later checkpoint that builds on this one
1128
- // is detected and skipped (rather than tripping the addCheckpoints consecutive-number
1129
- // check and causing the sync point to roll back in a loop).
1130
- await this.stores.blocks.addRejectedCheckpoint({
1131
- checkpointNumber: calldataCheckpoint.checkpointNumber,
1132
- archiveRoot: calldataCheckpoint.archiveRoot,
1133
- parentArchiveRoot: calldataCheckpoint.header.lastArchiveRoot,
1134
- slotNumber: calldataCheckpoint.header.slotNumber,
1135
- l1: calldataCheckpoint.l1,
1136
- reason: 'invalid-attestations'
1137
- });
1138
- continue;
1139
- }
1140
- if (rejectedAncestor) {
1141
- const descendantInfo = {
1142
- archive: calldataCheckpoint.archiveRoot,
1143
- lastArchive: calldataCheckpoint.header.lastArchiveRoot,
1144
- slotNumber: calldataCheckpoint.header.slotNumber,
1145
- checkpointNumber: calldataCheckpoint.checkpointNumber,
1146
- timestamp: calldataCheckpoint.header.timestamp
1147
- };
1148
- this.log.warn(`Skipping checkpoint ${calldataCheckpoint.checkpointNumber} as it is a descendant of ` + `rejected checkpoint ${rejectedAncestor.checkpointNumber} (${rejectedAncestor.reason})`, {
1149
- checkpointNumber: calldataCheckpoint.checkpointNumber,
1150
- l1BlockNumber: calldataCheckpoint.l1.blockNumber,
1151
- l1BlockHash: calldataCheckpoint.l1.blockHash,
1152
- ancestorCheckpointNumber: rejectedAncestor.checkpointNumber,
1153
- ancestorArchiveRoot: rejectedAncestor.archiveRoot.toString(),
1154
- ancestorReason: rejectedAncestor.reason
1155
- });
1156
- this.events.emit(L2BlockSourceEvents.DescendentOfInvalidAttestationsCheckpointDetected, {
1157
- type: L2BlockSourceEvents.DescendentOfInvalidAttestationsCheckpointDetected,
1158
- checkpoint: descendantInfo,
1159
- ancestorArchiveRoot: rejectedAncestor.archiveRoot,
1160
- ancestorCheckpointNumber: rejectedAncestor.checkpointNumber
1161
- });
1162
- // Persist this chainpoint as rejected as well, so we can construct a chain of
1163
- // skipped checkpoints starting from the first one with invalid attestations.
1164
- await this.stores.blocks.addRejectedCheckpoint({
1165
- checkpointNumber: calldataCheckpoint.checkpointNumber,
1166
- archiveRoot: calldataCheckpoint.archiveRoot,
1167
- parentArchiveRoot: calldataCheckpoint.header.lastArchiveRoot,
1168
- slotNumber: calldataCheckpoint.header.slotNumber,
1169
- l1: calldataCheckpoint.l1,
1170
- reason: 'descends-from-invalid-attestations'
1171
- });
1172
- continue;
1173
- }
1174
- checkpointsToIngest.push(calldataCheckpoint);
1175
- }
1176
- // Fetch blobs in parallel only for the surviving (attestation-valid, non-descendant) checkpoints,
1177
- // then build the full published checkpoints. The last calldata checkpoint may be promotable from a
1178
- // local proposed block (checkpointToPromote), in which case it carries no blob to fetch. A missing or
1179
- // undecodable blob throws and propagates, and the batch guard restores the L1 sync point so the fetch is retried.
1180
- const toFetchBlobs = checkpointToPromote ? checkpointsToIngest.filter((c)=>c.checkpointNumber !== checkpointToPromote.checkpoint.number) : checkpointsToIngest;
1181
- const blobFetched = await asyncPool(10, toFetchBlobs, async (checkpoint)=>retrievedToPublishedCheckpoint({
1182
- ...checkpoint,
1183
- checkpointBlobData: await getCheckpointBlobDataFromBlobs(this.blobClient, checkpoint.l1.blockHash, checkpoint.blobHashes, checkpoint.checkpointNumber, this.log, !initialSyncComplete, checkpoint.parentBeaconBlockRoot, checkpoint.l1.timestamp)
1184
- }));
1185
- // Index the built checkpoints by number so we can ingest them in calldata order, slotting in the
1186
- // promoted checkpoint (built from a local proposed block rather than blobs).
1187
- const publishedByNumber = new Map(blobFetched.map((publishedCheckpoint)=>[
1188
- publishedCheckpoint.checkpoint.number,
1189
- publishedCheckpoint
1190
- ]));
1191
- if (checkpointToPromote) {
1192
- publishedByNumber.set(checkpointToPromote.checkpoint.number, checkpointToPromote);
1193
- }
1194
- const validCheckpoints = [];
1195
- for (const calldataCheckpoint of checkpointsToIngest){
1196
- const published = publishedByNumber.get(calldataCheckpoint.checkpointNumber);
1197
- validCheckpoints.push(published);
1198
- this.log.debug(`Ingesting new checkpoint ${published.checkpoint.number} with ${published.checkpoint.blocks.length} blocks`, {
1199
- checkpointHash: published.checkpoint.hash(),
1200
- l1BlockNumber: published.l1.blockNumber,
1201
- ...published.checkpoint.header.toInspect(),
1202
- blocks: published.checkpoint.blocks.map((b)=>b.getStats())
1203
- });
1204
- }
1205
- for (const published of validCheckpoints){
1206
- this.instrumentation.processCheckpointL1Timing({
1207
- slotNumber: published.checkpoint.header.slotNumber,
1208
- l1Timestamp: published.l1.timestamp,
1209
- l1Constants: this.l1Constants
1210
- });
1211
- }
1212
- try {
1213
- const updatedValidationResult = rollupStatus.validationResult === initialValidationResult ? undefined : rollupStatus.validationResult;
1214
- // Split valid checkpoints: the promoted one (if any) is persisted via the proposed-promotion path,
1215
- // the rest via addCheckpoints. Both paths run within the same store transaction for atomicity.
1216
- const [[maybeValidCheckpointToPromote], checkpointsToAdd] = partition(validCheckpoints, (c)=>c.checkpoint.number === checkpointToPromote?.checkpoint.number);
1217
- const [processDuration, result] = await elapsed(()=>execInSpan(this.tracer, 'Archiver.addCheckpoints', async ()=>{
1218
- const addResult = await this.updater.addCheckpoints(checkpointsToAdd, updatedValidationResult, maybeValidCheckpointToPromote && {
1219
- l1: lastCalldataCheckpoint.l1,
1220
- attestations: lastCalldataCheckpoint.attestations,
1221
- verbatimAttestations: lastCalldataCheckpoint.verbatimAttestations,
1222
- checkpoint: maybeValidCheckpointToPromote
1223
- }, evictProposedFrom);
1224
- // Set before the span wrappers finish, so a throw while closing the span doesn't count as unpersisted.
1225
- batchPersisted = true;
1226
- return addResult;
1227
- }));
1228
- if (validCheckpoints.length > 0) {
1229
- this.instrumentation.processNewCheckpointedBlocks(processDuration / validCheckpoints.length, validCheckpoints.flatMap((c)=>c.checkpoint.blocks));
1230
- }
1231
- // Record blocks newly fetched from L1 checkpoint payloads as added. The promoted checkpoint (if any) is
1232
- // excluded: its blocks were already in local archiver storage (added via the proposed-block path) so the
1233
- // block stream does not need them re-downloaded.
1234
- blocksAdded.push(...checkpointsToAdd.flatMap((c)=>c.checkpoint.blocks));
1235
- // If blocks were pruned due to conflict with L1 checkpoints, emit event
1236
- if (result.prunedBlocks && result.prunedBlocks.length > 0) {
1237
- const prunedCheckpointNumber = result.prunedBlocks[0].checkpointNumber;
1238
- const prunedSlotNumber = result.prunedBlocks[0].header.globalVariables.slotNumber;
1239
- this.log.info(`Pruned ${result.prunedBlocks.length} mismatching blocks for checkpoint ${prunedCheckpointNumber}`, {
1240
- prunedBlocks: result.prunedBlocks.map((b)=>b.toBlockInfo()),
1241
- prunedSlotNumber,
1242
- prunedCheckpointNumber
1243
- });
1244
- this.instrumentation.recordPrune('l1_conflict');
1245
- // Emit event for listening services to react to the prune.
1246
- // Note: slotNumber comes from the first pruned block. If pruned blocks theoretically spanned multiple slots,
1247
- // only one slot number would be reported (though in practice all blocks in a checkpoint span a single slot).
1248
- this.events.emit(L2BlockSourceEvents.L2PruneUncheckpointed, {
1249
- type: L2BlockSourceEvents.L2PruneUncheckpointed,
1250
- slotNumber: prunedSlotNumber,
1251
- blocks: result.prunedBlocks
1252
- });
1253
- }
1254
- } catch (err) {
1255
- if (err instanceof InitialCheckpointNumberNotSequentialError) {
1256
- const { previousCheckpointNumber, newCheckpointNumber } = err;
1257
- const previousCheckpoint = previousCheckpointNumber ? await this.stores.blocks.getCheckpointData(CheckpointNumber(previousCheckpointNumber)) : undefined;
1258
- const lastFinalizedCheckpoint = await this.stores.blocks.getCheckpointData(await this.stores.blocks.getFinalizedCheckpointNumber());
1259
- const updatedL1SyncPoint = previousCheckpoint?.l1.blockNumber ?? lastFinalizedCheckpoint?.l1.blockNumber ?? this.l1Constants.l1StartBlock;
1260
- await this.stores.blocks.setSynchedL1BlockNumber(updatedL1SyncPoint);
1261
- this.log.warn(`Attempting to insert checkpoint ${newCheckpointNumber} with previous block ${previousCheckpointNumber}. Rolling back L1 sync point to ${updatedL1SyncPoint} to try and fetch the missing blocks.`, {
1262
- previousCheckpointNumber,
1263
- previousCheckpoint: previousCheckpoint?.header.toInspect(),
1264
- lastFinalizedCheckpoint: lastFinalizedCheckpoint?.header.toInspect(),
1265
- l1StartBlock: this.l1Constants.l1StartBlock,
1266
- newCheckpointNumber,
1267
- updatedL1SyncPoint
1268
- });
1269
- }
1270
- throw err;
1271
- }
1272
- for (const checkpoint of validCheckpoints){
1273
- this.log.info(`Downloaded checkpoint ${checkpoint.checkpoint.number}`, {
1274
- checkpointHash: checkpoint.checkpoint.hash(),
1275
- checkpointNumber: checkpoint.checkpoint.number,
1276
- blockCount: checkpoint.checkpoint.blocks.length,
1277
- txCount: checkpoint.checkpoint.blocks.reduce((acc, b)=>acc + b.body.txEffects.length, 0),
1278
- header: checkpoint.checkpoint.header.toInspect(),
1279
- archiveRoot: checkpoint.checkpoint.archive.root.toString(),
1280
- archiveNextLeafIndex: checkpoint.checkpoint.archive.nextAvailableLeafIndex
1281
- });
1282
- }
1283
- lastRetrievedCheckpoint = validCheckpoints.at(-1) ?? lastRetrievedCheckpoint;
1284
- // The last checkpoint seen on L1 this batch (valid or rejected), tracked from calldata since
1285
- // rejected checkpoints are no longer built into PublishedCheckpoints.
1286
- lastSeenCheckpoint = lastCalldataCheckpoint;
1287
- } catch (err) {
1288
- const restoreTo = syncPointBeforeBatch ?? this.l1Constants.l1StartBlock;
1289
- const currentSyncPoint = await this.stores.blocks.getSynchedL1BlockNumber();
1290
- // Only ever lower it, so a deeper rewind made while handling the error (e.g. on a checkpoint gap) is kept.
1291
- if (!batchPersisted && currentSyncPoint !== undefined && currentSyncPoint > restoreTo) {
1292
- this.log.warn(`Restoring L1 sync point to ${restoreTo} after failing to process checkpoints`, {
1293
- currentSyncPoint,
1294
- restoreTo,
1295
- searchStartBlock,
1296
- searchEndBlock
1297
- });
1298
- await this.stores.blocks.setSynchedL1BlockNumber(restoreTo);
1299
- }
1300
- throw err;
1301
- }
1302
- }while (searchEndBlock < currentL1BlockNumber)
1037
+ // Read after reconciliation, since an unwind resets the stored status to valid.
1038
+ const initialValidationStatus = await this.stores.blocks.getPendingChainValidationStatus();
1039
+ const { blocksAdded, lastSeenCheckpoint } = await this.checkpointIngestor.ingest(blocksSynchedTo, currentL1BlockNumber, {
1040
+ initialSyncComplete,
1041
+ initialValidationStatus
1042
+ });
1303
1043
  // Important that we update AFTER inserting the blocks.
1304
- await this.updateProvenCheckpoint(rollupStatus.provenCheckpointNumber, provenArchive);
1044
+ await this.updateProvenCheckpoint(rollupStatus.provenCheckpointNumber, rollupStatus.provenArchive);
1305
1045
  return {
1306
- ...rollupStatus,
1307
- lastRetrievedCheckpoint,
1046
+ rollupStatus,
1047
+ blocksAdded,
1308
1048
  lastSeenCheckpoint
1309
1049
  };
1310
1050
  }
1311
- /**
1312
- * Checks if a specific checkpoint matches a local pending entry, and if so, loads local data to build
1313
- * a synthetic published checkpoint (skipping blob fetch).
1314
- *
1315
- * Returns { diverged: true, fromCheckpointNumber } when the L1 checkpoint does NOT match local pending
1316
- * data for that number, so the caller can evict the entire pending suffix >= fromCheckpointNumber
1317
- * (those entries chain off the now-invalid local state) within the same addCheckpoints transaction.
1318
- */ async tryBuildPublishedCheckpointFromProposed(calldataCheckpoint) {
1319
- if (this.config.skipPromoteProposedCheckpointDuringL1Sync || !calldataCheckpoint) {
1320
- return undefined;
1321
- }
1322
- // Look up the specific pending entry for the checkpoint being mined, not just the tip
1323
- const proposed = await this.stores.blocks.getProposedCheckpointByNumber(calldataCheckpoint.checkpointNumber);
1324
- if (!proposed) {
1325
- return undefined;
1326
- }
1327
- if (!proposed.header.equals(calldataCheckpoint.header) || !proposed.archive.root.equals(calldataCheckpoint.archiveRoot) || proposed.feeAssetPriceModifier !== calldataCheckpoint.feeAssetPriceModifier) {
1328
- this.log.warn(`Local proposed checkpoint ${proposed.checkpointNumber} does not match checkpoint retrieved from L1, overriding with L1 data`, {
1329
- proposedCheckpointNumber: proposed.checkpointNumber,
1330
- proposedHeader: proposed.header.toInspect(),
1331
- proposedArchiveRoot: proposed.archive.root.toString(),
1332
- proposedFeeAssetPriceModifier: proposed.feeAssetPriceModifier.toString(),
1333
- calldataCheckpointNumber: calldataCheckpoint.checkpointNumber,
1334
- calldataHeader: calldataCheckpoint.header.toInspect(),
1335
- calldataArchiveRoot: calldataCheckpoint.archiveRoot.toString(),
1336
- calldataFeeAssetPriceModifier: calldataCheckpoint.feeAssetPriceModifier.toString()
1337
- });
1338
- // Both the locally-proposed checkpoint and the L1-confirmed one are signed by the
1339
- // slot proposer; emit a divergence event so the slasher can attribute equivocation.
1340
- // Only emit when the slots match — uncheckpointed entries are pruned above so this
1341
- // should always hold, but guard defensively to avoid mis-attributing a slash.
1342
- if (proposed.header.slotNumber === calldataCheckpoint.header.slotNumber) {
1343
- this.events.emit(L2BlockSourceEvents.CheckpointEquivocationDetected, {
1344
- type: L2BlockSourceEvents.CheckpointEquivocationDetected,
1345
- slotNumber: calldataCheckpoint.header.slotNumber,
1346
- checkpointNumber: calldataCheckpoint.checkpointNumber,
1347
- l1ArchiveRoot: calldataCheckpoint.archiveRoot,
1348
- proposedArchiveRoot: proposed.archive.root
1349
- });
1350
- }
1351
- // Return a divergence signal so the caller can evict pending >= this number
1352
- return {
1353
- diverged: true,
1354
- fromCheckpointNumber: proposed.checkpointNumber
1355
- };
1356
- }
1357
- this.log.debug(`Building published checkpoint from proposed ${calldataCheckpoint.checkpointNumber} (skipping blob fetch)`, {
1358
- proposedHeader: proposed.header.toInspect(),
1359
- proposedArchiveRoot: proposed.archive.root.toString()
1360
- });
1361
- const blocks = await this.stores.blocks.getBlocks({
1362
- from: BlockNumber(proposed.startBlock),
1363
- limit: proposed.blockCount
1364
- });
1365
- if (blocks.length !== proposed.blockCount) {
1366
- this.log.warn(`Local proposed checkpoint ${proposed.checkpointNumber} has wrong block count (expected ${proposed.blockCount} blocks starting at ${proposed.startBlock} but got ${blocks.length})`, {
1367
- proposedCheckpointNumber: proposed.checkpointNumber,
1368
- proposedStartBlock: proposed.startBlock,
1369
- proposedBlockCount: proposed.blockCount,
1370
- retrievedBlocks: blocks.map((b)=>b.number)
1371
- });
1372
- return undefined;
1373
- }
1374
- const checkpoint = Checkpoint.from({
1375
- archive: proposed.archive,
1376
- header: proposed.header,
1377
- blocks,
1378
- number: proposed.checkpointNumber,
1379
- feeAssetPriceModifier: proposed.feeAssetPriceModifier
1380
- });
1381
- const promotedCheckpoint = PublishedCheckpoint.from({
1382
- checkpoint,
1383
- l1: calldataCheckpoint.l1,
1384
- attestations: calldataCheckpoint.attestations,
1385
- verbatimAttestations: calldataCheckpoint.verbatimAttestations
1386
- });
1387
- this.instrumentation.processCheckpointPromoted();
1388
- return promotedCheckpoint;
1389
- }
1390
- async checkForNewCheckpointsBeforeL1SyncPoint(status, blocksSynchedTo, currentL1BlockNumber) {
1391
- const { lastSeenCheckpoint, pendingCheckpointNumber } = status;
1051
+ async checkForNewCheckpointsBeforeL1SyncPoint(status, lastSeenCheckpoint, blocksSynchedTo, currentL1BlockNumber) {
1052
+ const { pendingCheckpointNumber } = status;
1392
1053
  // Compare the last checkpoint (valid or not) we have (either retrieved in this round or loaded from store)
1393
1054
  // with what the rollup contract told us was the latest one (pinned at the currentL1BlockNumber).
1394
1055
  const latestLocalCheckpoint = lastSeenCheckpoint ?? await this.getLocalProgressCheckpoint(status);
@@ -1405,15 +1066,18 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
1405
1066
  latestLocalCheckpointL1: latestLocalCheckpoint?.l1,
1406
1067
  blocksSynchedTo,
1407
1068
  currentL1BlockNumber,
1408
- ...status
1069
+ ...status,
1070
+ lastSeenCheckpoint
1409
1071
  });
1410
1072
  await this.stores.blocks.setSynchedL1BlockNumber(targetL1BlockNumber);
1073
+ return true;
1411
1074
  } else {
1412
1075
  this.log.trace(`No new checkpoints behind L1 sync point to retrieve.`, {
1413
1076
  latestLocalCheckpointNumber,
1414
1077
  pendingCheckpointNumber
1415
1078
  });
1416
1079
  }
1080
+ return false;
1417
1081
  }
1418
1082
  /**
1419
1083
  * Returns the stored checkpoint to measure local progress from when deciding whether checkpoints were added behind
@@ -1424,7 +1088,7 @@ _dec = trackSpan('Archiver.syncFromL1'), _dec1 = trackSpan('Archiver.handleEpoch
1424
1088
  * a reorg may leave a stale higher-numbered marker (e.g. a dropped descendant) while the pending tip is still one
1425
1089
  * we rejected.
1426
1090
  */ async getLocalProgressCheckpoint(status) {
1427
- const rejectedPendingTip = await this.stores.blocks.getRejectedCheckpointByArchiveRoot(Fr.fromString(status.pendingArchive));
1091
+ const rejectedPendingTip = await this.stores.blocks.getRejectedCheckpointByArchiveRoot(status.pendingArchive);
1428
1092
  return rejectedPendingTip ?? await this.stores.blocks.getCheckpointData(await this.stores.blocks.getLatestCheckpointNumber());
1429
1093
  }
1430
1094
  async getCheckpointHeader(number) {