@aztec/archiver 0.0.1-commit.04852196a → 0.0.1-commit.04d373f

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 (117) hide show
  1. package/README.md +19 -11
  2. package/dest/archiver.d.ts +36 -19
  3. package/dest/archiver.d.ts.map +1 -1
  4. package/dest/archiver.js +250 -79
  5. package/dest/config.d.ts +6 -3
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +23 -15
  8. package/dest/errors.d.ts +55 -9
  9. package/dest/errors.d.ts.map +1 -1
  10. package/dest/errors.js +81 -14
  11. package/dest/factory.d.ts +12 -8
  12. package/dest/factory.d.ts.map +1 -1
  13. package/dest/factory.js +42 -32
  14. package/dest/index.d.ts +11 -3
  15. package/dest/index.d.ts.map +1 -1
  16. package/dest/index.js +10 -2
  17. package/dest/l1/calldata_retriever.d.ts +2 -1
  18. package/dest/l1/calldata_retriever.d.ts.map +1 -1
  19. package/dest/l1/calldata_retriever.js +15 -5
  20. package/dest/l1/data_retrieval.d.ts +19 -10
  21. package/dest/l1/data_retrieval.d.ts.map +1 -1
  22. package/dest/l1/data_retrieval.js +25 -32
  23. package/dest/l1/trace_tx.d.ts +12 -66
  24. package/dest/l1/trace_tx.d.ts.map +1 -1
  25. package/dest/l1/validate_historical_logs.d.ts +23 -0
  26. package/dest/l1/validate_historical_logs.d.ts.map +1 -0
  27. package/dest/l1/validate_historical_logs.js +108 -0
  28. package/dest/modules/contract_data_source_adapter.d.ts +25 -0
  29. package/dest/modules/contract_data_source_adapter.d.ts.map +1 -0
  30. package/dest/modules/contract_data_source_adapter.js +40 -0
  31. package/dest/modules/data_source_base.d.ts +70 -46
  32. package/dest/modules/data_source_base.d.ts.map +1 -1
  33. package/dest/modules/data_source_base.js +270 -135
  34. package/dest/modules/data_store_updater.d.ts +39 -17
  35. package/dest/modules/data_store_updater.d.ts.map +1 -1
  36. package/dest/modules/data_store_updater.js +183 -122
  37. package/dest/modules/instrumentation.d.ts +7 -2
  38. package/dest/modules/instrumentation.d.ts.map +1 -1
  39. package/dest/modules/instrumentation.js +25 -7
  40. package/dest/modules/l1_synchronizer.d.ts +12 -7
  41. package/dest/modules/l1_synchronizer.d.ts.map +1 -1
  42. package/dest/modules/l1_synchronizer.js +430 -205
  43. package/dest/modules/validation.d.ts +4 -3
  44. package/dest/modules/validation.d.ts.map +1 -1
  45. package/dest/modules/validation.js +6 -6
  46. package/dest/store/block_store.d.ts +174 -70
  47. package/dest/store/block_store.d.ts.map +1 -1
  48. package/dest/store/block_store.js +696 -250
  49. package/dest/store/contract_class_store.d.ts +17 -4
  50. package/dest/store/contract_class_store.d.ts.map +1 -1
  51. package/dest/store/contract_class_store.js +24 -68
  52. package/dest/store/contract_instance_store.d.ts +28 -1
  53. package/dest/store/contract_instance_store.d.ts.map +1 -1
  54. package/dest/store/contract_instance_store.js +37 -2
  55. package/dest/store/data_stores.d.ts +68 -0
  56. package/dest/store/data_stores.d.ts.map +1 -0
  57. package/dest/store/data_stores.js +54 -0
  58. package/dest/store/function_names_cache.d.ts +17 -0
  59. package/dest/store/function_names_cache.d.ts.map +1 -0
  60. package/dest/store/function_names_cache.js +30 -0
  61. package/dest/store/l2_tips_cache.d.ts +13 -7
  62. package/dest/store/l2_tips_cache.d.ts.map +1 -1
  63. package/dest/store/l2_tips_cache.js +13 -76
  64. package/dest/store/log_store.d.ts +42 -37
  65. package/dest/store/log_store.d.ts.map +1 -1
  66. package/dest/store/log_store.js +262 -408
  67. package/dest/store/log_store_codec.d.ts +70 -0
  68. package/dest/store/log_store_codec.d.ts.map +1 -0
  69. package/dest/store/log_store_codec.js +101 -0
  70. package/dest/store/message_store.d.ts +11 -1
  71. package/dest/store/message_store.d.ts.map +1 -1
  72. package/dest/store/message_store.js +50 -8
  73. package/dest/test/fake_l1_state.d.ts +20 -1
  74. package/dest/test/fake_l1_state.d.ts.map +1 -1
  75. package/dest/test/fake_l1_state.js +114 -18
  76. package/dest/test/mock_l1_to_l2_message_source.d.ts +1 -1
  77. package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
  78. package/dest/test/mock_l1_to_l2_message_source.js +2 -1
  79. package/dest/test/mock_l2_block_source.d.ts +51 -46
  80. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  81. package/dest/test/mock_l2_block_source.js +243 -170
  82. package/dest/test/noop_l1_archiver.d.ts +12 -6
  83. package/dest/test/noop_l1_archiver.d.ts.map +1 -1
  84. package/dest/test/noop_l1_archiver.js +26 -9
  85. package/package.json +14 -14
  86. package/src/archiver.ts +301 -86
  87. package/src/config.ts +32 -12
  88. package/src/errors.ts +122 -21
  89. package/src/factory.ts +50 -28
  90. package/src/index.ts +18 -2
  91. package/src/l1/calldata_retriever.ts +16 -5
  92. package/src/l1/data_retrieval.ts +36 -45
  93. package/src/l1/validate_historical_logs.ts +140 -0
  94. package/src/modules/contract_data_source_adapter.ts +55 -0
  95. package/src/modules/data_source_base.ts +336 -171
  96. package/src/modules/data_store_updater.ts +219 -154
  97. package/src/modules/instrumentation.ts +28 -8
  98. package/src/modules/l1_synchronizer.ts +566 -248
  99. package/src/modules/validation.ts +10 -9
  100. package/src/store/block_store.ts +865 -290
  101. package/src/store/contract_class_store.ts +31 -103
  102. package/src/store/contract_instance_store.ts +51 -5
  103. package/src/store/data_stores.ts +104 -0
  104. package/src/store/function_names_cache.ts +37 -0
  105. package/src/store/l2_tips_cache.ts +16 -70
  106. package/src/store/log_store.ts +301 -559
  107. package/src/store/log_store_codec.ts +132 -0
  108. package/src/store/message_store.ts +59 -9
  109. package/src/structs/inbox_message.ts +1 -1
  110. package/src/test/fake_l1_state.ts +142 -29
  111. package/src/test/mock_l1_to_l2_message_source.ts +1 -0
  112. package/src/test/mock_l2_block_source.ts +303 -205
  113. package/src/test/noop_l1_archiver.ts +39 -9
  114. package/dest/store/kv_archiver_store.d.ts +0 -354
  115. package/dest/store/kv_archiver_store.d.ts.map +0 -1
  116. package/dest/store/kv_archiver_store.js +0 -464
  117. package/src/store/kv_archiver_store.ts +0 -671
package/dest/archiver.js CHANGED
@@ -372,21 +372,24 @@ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
372
372
  }
373
373
  var _dec, _initProto;
374
374
  import { BlockTagTooOldError } from '@aztec/ethereum/contracts';
375
- import { BlockNumber } from '@aztec/foundation/branded-types';
375
+ import { BlockNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
376
376
  import { Buffer32 } from '@aztec/foundation/buffer';
377
- import { merge } from '@aztec/foundation/collection';
377
+ import { merge, pick } from '@aztec/foundation/collection';
378
378
  import { EthAddress } from '@aztec/foundation/eth-address';
379
379
  import { createLogger } from '@aztec/foundation/log';
380
380
  import { promiseWithResolvers } from '@aztec/foundation/promise';
381
381
  import { RunningPromise, makeLoggingErrorHandler } from '@aztec/foundation/running-promise';
382
- import { getEpochNumberAtTimestamp, getSlotAtNextL1Block, getSlotAtTimestamp, getSlotRangeForEpoch, getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
382
+ import { elapsed } from '@aztec/foundation/timer';
383
+ import { L2BlockSourceEvents } from '@aztec/stdlib/block';
384
+ import { getEpochAtSlot, getSlotAtNextL1Block, getSlotRangeForEpoch, getTimestampForSlot, getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
383
385
  import { trackSpan } from '@aztec/telemetry-client';
384
386
  import { mapArchiverConfig } from './config.js';
385
- import { NoBlobBodiesFoundError } from './errors.js';
387
+ import { BlockAlreadyCheckpointedError, BlockOrCheckpointSlotExpiredError, NoBlobBodiesFoundError } from './errors.js';
388
+ import { validateAndLogHistoricalLogsAvailability } from './l1/validate_historical_logs.js';
386
389
  import { validateAndLogTraceAvailability } from './l1/validate_trace.js';
387
390
  import { ArchiverDataSourceBase } from './modules/data_source_base.js';
388
391
  import { ArchiverDataStoreUpdater } from './modules/data_store_updater.js';
389
- import { L2TipsCache } from './store/l2_tips_cache.js';
392
+ import { backupArchiverDataStores, getArchiverSynchPoint } from './store/data_stores.js';
390
393
  _dec = trackSpan('Archiver.sync');
391
394
  /**
392
395
  * Pulls checkpoints in a non-blocking manner and provides interface for their retrieval.
@@ -397,10 +400,12 @@ _dec = trackSpan('Archiver.sync');
397
400
  debugClient;
398
401
  rollup;
399
402
  l1Addresses;
400
- dataStore;
403
+ dataStores;
401
404
  config;
402
405
  blobClient;
403
406
  l1Constants;
407
+ epochCache;
408
+ dateProvider;
404
409
  log;
405
410
  static{
406
411
  ({ e: [_initProto] } = _apply_decs_2203_r(this, [
@@ -416,33 +421,40 @@ _dec = trackSpan('Archiver.sync');
416
421
  /** L1 synchronizer that handles fetching checkpoints and messages from L1. */ synchronizer;
417
422
  initialSyncComplete;
418
423
  initialSyncPromise;
419
- /** Queue of blocks to be added to the store, processed by the sync loop. */ blockQueue;
424
+ /** Queue of blocks and checkpoints to be added to the store, processed by the sync loop. */ inboundQueue;
420
425
  /** Helper to handle updates to the store */ updater;
421
426
  /** In-memory cache for L2 chain tips. */ l2TipsCache;
422
427
  tracer;
428
+ instrumentation;
423
429
  /**
424
430
  * Creates a new instance of the Archiver.
425
431
  * @param publicClient - A client for interacting with the Ethereum node.
426
432
  * @param debugClient - A client for interacting with the Ethereum node for debug/trace methods.
427
433
  * @param rollup - Rollup contract instance.
428
434
  * @param inbox - Inbox contract instance.
429
- * @param l1Addresses - L1 contract addresses (registry, governance proposer, slash factory, slashing proposer).
430
- * @param dataStore - An archiver data store for storage & retrieval of blocks, encrypted logs & contract data.
435
+ * @param l1Addresses - L1 contract addresses (registry, governance proposer, slashing proposer).
436
+ * @param dataStores - Archiver substores for storage & retrieval of blocks, encrypted logs & contract data.
431
437
  * @param config - Archiver configuration options.
432
438
  * @param blobClient - Client for retrieving blob data.
433
- * @param epochCache - Cache for epoch-related data.
434
- * @param dateProvider - Provider for current date/time.
435
439
  * @param instrumentation - Instrumentation for metrics and tracing.
436
440
  * @param l1Constants - L1 rollup constants.
441
+ * @param synchronizer - L1 synchronizer that handles fetching checkpoints and messages from L1.
442
+ * @param events - Event emitter shared with the synchronizer.
443
+ * @param initialHeader - Genesis block header.
444
+ * @param initialBlockHash - Precomputed hash of the genesis block header.
445
+ * @param l2TipsCache - In-memory cache for L2 chain tips.
446
+ * @param epochCache - Cache used to compute the proposer pipelining offset.
447
+ * @param dateProvider - Provider for current date/time, used for wall-clock orphan-block pruning.
437
448
  * @param log - A logger.
438
- */ constructor(publicClient, debugClient, rollup, l1Addresses, dataStore, config, blobClient, instrumentation, l1Constants, synchronizer, events, l2TipsCache, log = createLogger('archiver')){
439
- super(dataStore, l1Constants), this.publicClient = publicClient, this.debugClient = debugClient, this.rollup = rollup, this.l1Addresses = l1Addresses, this.dataStore = dataStore, this.config = config, this.blobClient = blobClient, this.l1Constants = l1Constants, this.log = log, this.initialSyncComplete = (_initProto(this), false), this.blockQueue = [];
449
+ */ constructor(publicClient, debugClient, rollup, l1Addresses, dataStores, config, blobClient, instrumentation, l1Constants, synchronizer, events, initialHeader, initialBlockHash, l2TipsCache, epochCache, dateProvider, log = createLogger('archiver')){
450
+ super(dataStores, l1Constants, initialHeader, initialBlockHash, l1Constants.genesisArchiveRoot), this.publicClient = publicClient, this.debugClient = debugClient, this.rollup = rollup, this.l1Addresses = l1Addresses, this.dataStores = dataStores, this.config = config, this.blobClient = blobClient, this.l1Constants = l1Constants, this.epochCache = epochCache, this.dateProvider = dateProvider, this.log = log, this.initialSyncComplete = (_initProto(this), false), this.inboundQueue = [];
440
451
  this.tracer = instrumentation.tracer;
452
+ this.instrumentation = instrumentation;
441
453
  this.initialSyncPromise = promiseWithResolvers();
442
454
  this.synchronizer = synchronizer;
443
455
  this.events = events;
444
- this.l2TipsCache = l2TipsCache ?? new L2TipsCache(this.dataStore.blockStore);
445
- this.updater = new ArchiverDataStoreUpdater(this.dataStore, this.l2TipsCache, {
456
+ this.l2TipsCache = l2TipsCache;
457
+ this.updater = new ArchiverDataStoreUpdater(this.dataStores, this.l2TipsCache, {
446
458
  rollupManaLimit: l1Constants.rollupManaLimit
447
459
  });
448
460
  // Running promise starts with a small interval inbetween runs, so all iterations needed for the initial sync
@@ -463,10 +475,16 @@ _dec = trackSpan('Archiver.sync');
463
475
  await this.blobClient.testSources();
464
476
  await this.synchronizer.testEthereumNodeSynced();
465
477
  await validateAndLogTraceAvailability(this.debugClient, this.config.ethereumAllowNoDebugHosts ?? false, this.log.getBindings());
478
+ await validateAndLogHistoricalLogsAvailability(this.publicClient, {
479
+ rollupAddress: this.l1Addresses.rollupAddress,
480
+ inboxAddress: this.l1Addresses.inboxAddress,
481
+ registryAddress: this.l1Addresses.registryAddress,
482
+ governanceProposerAddress: this.l1Addresses.governanceProposerAddress
483
+ }, this.config.skipHistoricalLogsCheck ?? false, this.log.getBindings());
466
484
  // Log initial state for the archiver
467
485
  const { l1StartBlock } = this.l1Constants;
468
- const { blocksSynchedTo = l1StartBlock, messagesSynchedTo = l1StartBlock } = await this.store.getSynchPoint();
469
- const currentL2Checkpoint = await this.getSynchedCheckpointNumber();
486
+ const { blocksSynchedTo = l1StartBlock, messagesSynchedTo = l1StartBlock } = await getArchiverSynchPoint(this.stores);
487
+ const currentL2Checkpoint = await this.getCheckpointNumber();
470
488
  this.log.info(`Starting archiver sync to rollup contract ${this.rollup.address} from L1 block ${blocksSynchedTo} and L2 checkpoint ${currentL2Checkpoint}`, {
471
489
  blocksSynchedTo,
472
490
  messagesSynchedTo,
@@ -481,6 +499,13 @@ _dec = trackSpan('Archiver.sync');
481
499
  syncImmediate() {
482
500
  return this.runningPromise.trigger();
483
501
  }
502
+ trySyncImmediate() {
503
+ try {
504
+ return this.syncImmediate();
505
+ } catch (err) {
506
+ this.log.error(`Failed to trigger immediate archiver sync: ${err}`, err);
507
+ }
508
+ }
484
509
  /**
485
510
  * Queues a block to be added to the archiver store and triggers processing.
486
511
  * The block will be processed by the sync loop.
@@ -488,53 +513,84 @@ _dec = trackSpan('Archiver.sync');
488
513
  * @param block - The L2 block to add.
489
514
  * @returns A promise that resolves when the block has been added to the store, or rejects on error.
490
515
  */ addBlock(block) {
491
- return new Promise((resolve, reject)=>{
492
- this.blockQueue.push({
493
- block,
494
- resolve,
495
- reject
496
- });
497
- this.log.debug(`Queued block ${block.number} for processing`);
498
- // Trigger an immediate sync, but don't wait for it - the promise resolves when the block is processed
499
- this.syncImmediate().catch((err)=>{
500
- this.log.error(`Sync immediate call failed: ${err}`);
501
- });
516
+ const promise = promiseWithResolvers();
517
+ this.inboundQueue.push({
518
+ block,
519
+ ...promise,
520
+ type: 'block'
502
521
  });
522
+ this.log.debug(`Queued block ${block.number} for processing`);
523
+ void this.trySyncImmediate();
524
+ return promise.promise;
503
525
  }
504
526
  /**
505
- * Processes all queued blocks, adding them to the store.
527
+ * Queues a new proposed checkpoint into the archiver store.
528
+ * Checks that the checkpoint is not for an L2 slot already synced from L1.
529
+ * Resolves once the checkpoint has been processed.
530
+ */ addProposedCheckpoint(pending) {
531
+ const promise = promiseWithResolvers();
532
+ this.inboundQueue.push({
533
+ checkpoint: pending,
534
+ ...promise,
535
+ type: 'checkpoint'
536
+ });
537
+ this.log.debug(`Queued checkpoint ${pending.checkpointNumber} for processing`);
538
+ void this.trySyncImmediate();
539
+ return promise.promise;
540
+ }
541
+ /**
542
+ * Processes all queued blocks and checkpoints, adding them to the store.
506
543
  * Called at the beginning of each sync iteration.
507
- * Blocks are processed in the order they were queued.
508
- */ async processQueuedBlocks() {
509
- if (this.blockQueue.length === 0) {
544
+ * Items are processed in the order they were queued.
545
+ */ async processInboundQueue() {
546
+ if (this.inboundQueue.length === 0) {
510
547
  return;
511
548
  }
512
- // Take all blocks from the queue
513
- const queuedItems = this.blockQueue.splice(0, this.blockQueue.length);
514
- this.log.debug(`Processing ${queuedItems.length} queued block(s)`);
549
+ // Take all items from the queue
550
+ const queuedItems = this.inboundQueue.splice(0, this.inboundQueue.length);
551
+ this.log.debug(`Processing ${queuedItems.length} queued inbound items`);
515
552
  // Calculate slot threshold for validation
516
553
  const l1Timestamp = this.synchronizer.getL1Timestamp();
517
554
  const slotAtNextL1Block = l1Timestamp === undefined ? undefined : getSlotAtNextL1Block(l1Timestamp, this.l1Constants);
518
- // Process each block individually to properly resolve/reject each promise
519
- for (const { block, resolve, reject } of queuedItems){
520
- const blockSlot = block.header.globalVariables.slotNumber;
521
- if (slotAtNextL1Block !== undefined && blockSlot < slotAtNextL1Block) {
522
- this.log.warn(`Rejecting proposed block ${block.number} for past slot ${blockSlot} (current is ${slotAtNextL1Block})`, {
523
- block: block.toBlockInfo(),
555
+ // Helpers for manipulating blocks and checkpoints in the queue
556
+ const getSlot = (item)=>item.type === 'block' ? item.block.header.globalVariables.slotNumber : item.checkpoint.header.slotNumber;
557
+ const getNumber = (item)=>item.type === 'block' ? item.block.number : item.checkpoint.checkpointNumber;
558
+ // Process each item individually to properly resolve/reject each promise
559
+ for (const item of queuedItems){
560
+ const { resolve, reject, type } = item;
561
+ const itemSlot = getSlot(item);
562
+ const itemNumber = getNumber(item);
563
+ if (slotAtNextL1Block !== undefined && itemSlot < slotAtNextL1Block) {
564
+ const nextSlotTimestamp = getTimestampForSlot(slotAtNextL1Block, this.l1Constants);
565
+ this.log.warn(`Rejecting proposed ${type} ${itemNumber} for past slot ${itemSlot} (current ${slotAtNextL1Block})`, {
566
+ number: itemNumber,
567
+ type,
524
568
  l1Timestamp,
525
- slotAtNextL1Block
569
+ slotAtNextL1Block,
570
+ nextSlotTimestamp
526
571
  });
527
- reject(new Error(`Block ${block.number} is for past slot ${blockSlot} (current is ${slotAtNextL1Block})`));
572
+ reject(new BlockOrCheckpointSlotExpiredError(itemSlot, nextSlotTimestamp, l1Timestamp));
528
573
  continue;
529
574
  }
530
575
  try {
531
- await this.updater.addProposedBlocks([
532
- block
533
- ]);
534
- this.log.debug(`Added block ${block.number} to store`);
576
+ if (type === 'block') {
577
+ const [durationMs] = await elapsed(()=>this.updater.addProposedBlock(item.block));
578
+ this.instrumentation.processNewProposedBlock(durationMs, item.block);
579
+ } else {
580
+ await this.updater.addProposedCheckpoint(item.checkpoint);
581
+ }
582
+ this.log.debug(`Added ${type} ${itemNumber} to store`);
535
583
  resolve();
536
584
  } catch (err) {
537
- this.log.error(`Failed to add block ${block.number} to store: ${err.message}`);
585
+ if (err instanceof BlockAlreadyCheckpointedError) {
586
+ this.log.debug(`Proposed block ${itemNumber} matches already checkpointed block, ignoring late proposal`);
587
+ resolve();
588
+ continue;
589
+ }
590
+ this.log.error(`Failed to add ${type} ${itemNumber} to store: ${err.message}`, err, {
591
+ number: itemNumber,
592
+ type
593
+ });
538
594
  reject(err);
539
595
  }
540
596
  }
@@ -546,9 +602,85 @@ _dec = trackSpan('Archiver.sync');
546
602
  * Fetches logs from L1 contracts and processes them.
547
603
  */ async sync() {
548
604
  // Process any queued blocks first, before doing L1 sync
549
- await this.processQueuedBlocks();
605
+ await this.processInboundQueue();
550
606
  // Now perform L1 sync
551
607
  await this.syncFromL1();
608
+ // Prune proposed blocks with no corresponding proposed checkpoint by the end of their build slot.
609
+ await this.pruneOrphanProposedBlocks();
610
+ }
611
+ /**
612
+ * Prunes a block-only local tip that was built atop a checkpoint that was never itself proposed.
613
+ *
614
+ * Under pipelining, a proposer publishes the blocks for a checkpoint (block-only proposals) before
615
+ * assembling and publishing the enclosing proposed checkpoint at the end of the build slot. A node
616
+ * that received those blocks but never the proposed checkpoint is left with an orphan tip it must
617
+ * not build on. We prune it once enough wall-clock time has elapsed that the proposed checkpoint
618
+ * should have arrived. This runs on wall-clock time (not L1 block advancement) so it fires during
619
+ * quiet L1 periods, and is the liveness counterpart to the sequencer's checkSync guard.
620
+ *
621
+ * The uncheckpointed suffix is scanned in order. Blocks covered by proposed checkpoints are left in
622
+ * place; the first block not covered by a proposed checkpoint starts the orphan suffix to prune.
623
+ */ async pruneOrphanProposedBlocks() {
624
+ const tips = await this.getL2Tips();
625
+ const now = BigInt(this.dateProvider.nowInSeconds());
626
+ const pipeliningOffset = this.epochCache.pipeliningOffset();
627
+ // This only applies under pipelining
628
+ if (pipeliningOffset === 0) {
629
+ this.log.trace(`Pipelining offset is 0, skipping orphan proposed block pruning`);
630
+ return;
631
+ }
632
+ // The proposed tip is a proposed-checkpointed block, so there are no orphan proposed blocks to prune
633
+ if (tips.proposedCheckpoint.block.number === tips.proposed.number) {
634
+ this.log.trace(`No orphan proposed blocks to prune: proposed tip ${tips.proposed.number} is checkpointed`, pick(tips, 'proposed', 'proposedCheckpoint'));
635
+ return;
636
+ }
637
+ // Load the blocks that are candidates for pruning (ie blocks without a proposed checkpoint covering them)
638
+ const blocksWithoutProposedCheckpoint = await this.stores.blocks.getBlocksData({
639
+ from: BlockNumber(tips.proposedCheckpoint.block.number + 1),
640
+ limit: tips.proposed.number - tips.proposedCheckpoint.block.number
641
+ });
642
+ // Iterate through them in order, the first one with a slot that should have received a proposed checkpoint
643
+ // is the first orphan block, and all blocks after it are also orphaned and should be pruned.
644
+ let lastSlotChecked = undefined;
645
+ for (const blockData of blocksWithoutProposedCheckpoint){
646
+ // No need to recheck if this block had the same slot as the previous one.
647
+ const blockSlot = blockData.header.getSlot();
648
+ const blockNumber = blockData.header.getBlockNumber();
649
+ if (lastSlotChecked !== undefined && blockSlot === lastSlotChecked) {
650
+ continue;
651
+ }
652
+ lastSlotChecked = blockSlot;
653
+ // The proposed checkpoint should have landed by the start of the slot after the block's build slot
654
+ // (build slot = blockSlot - pipeliningOffset). Wait a grace period beyond that to tolerate propagation.
655
+ const expectedCheckpointedBySlot = SlotNumber(Number(blockSlot) - pipeliningOffset + 1);
656
+ const expectedCheckpointedByTime = getTimestampForSlot(expectedCheckpointedBySlot, this.l1Constants) + BigInt(this.config.orphanProposedBlockPruneGraceSeconds);
657
+ // If it's not checkpointed by the expected time, prune it along with all blocks after it.
658
+ if (now >= expectedCheckpointedByTime) {
659
+ const pruneAfterBlockNumber = BlockNumber(blockNumber - 1);
660
+ this.log.warn(`Pruning orphan blocks after block ${pruneAfterBlockNumber}: block at slot ${blockSlot} belongs to ` + `checkpoint ${blockData.checkpointNumber} which has no matching proposed checkpoint`, {
661
+ firstUncheckpointedBlockHeader: blockData.header.toInspect(),
662
+ blockCheckpointNumber: blockData.checkpointNumber,
663
+ blockNumber,
664
+ blockSlot,
665
+ pipeliningOffset,
666
+ expectedCheckpointedBySlot,
667
+ expectedCheckpointedByTime,
668
+ now
669
+ });
670
+ const prunedBlocks = await this.updater.removeBlocksWithoutProposedCheckpointAfter(pruneAfterBlockNumber);
671
+ if (prunedBlocks.length > 0) {
672
+ this.events.emit(L2BlockSourceEvents.L2PruneUncheckpointed, {
673
+ type: L2BlockSourceEvents.L2PruneUncheckpointed,
674
+ slotNumber: blockSlot,
675
+ blocks: prunedBlocks
676
+ });
677
+ }
678
+ return;
679
+ }
680
+ }
681
+ this.log.trace('No orphan proposed blocks to prune: all uncheckpointed blocks are still within the grace period', {
682
+ blocksWithoutProposedCheckpoint: blocksWithoutProposedCheckpoint.map((b)=>b.header.toInspect())
683
+ });
552
684
  }
553
685
  async syncFromL1() {
554
686
  // Delegate to the L1 synchronizer
@@ -560,7 +692,7 @@ _dec = trackSpan('Archiver.sync');
560
692
  if (currentL1BlockNumber + 1n >= l1BlockNumberAtEnd) {
561
693
  this.log.info(`Initial archiver sync to L1 block ${currentL1BlockNumber} complete`, {
562
694
  l1BlockNumber: currentL1BlockNumber,
563
- syncPoint: await this.store.getSynchPoint(),
695
+ syncPoint: await getArchiverSynchPoint(this.stores),
564
696
  ...await this.getL2Tips()
565
697
  });
566
698
  this.runningPromise.setPollingIntervalMS(this.config.pollingIntervalMs);
@@ -586,7 +718,7 @@ _dec = trackSpan('Archiver.sync');
586
718
  return Promise.resolve();
587
719
  }
588
720
  backupTo(destPath) {
589
- return this.dataStore.backupTo(destPath);
721
+ return backupArchiverDataStores(this.dataStores, destPath);
590
722
  }
591
723
  getL1Constants() {
592
724
  return Promise.resolve(this.l1Constants);
@@ -608,20 +740,53 @@ _dec = trackSpan('Archiver.sync');
608
740
  getL1Timestamp() {
609
741
  return Promise.resolve(this.synchronizer.getL1Timestamp());
610
742
  }
611
- getL2SlotNumber() {
743
+ async getSyncedL2SlotNumber() {
744
+ // The synced L2 slot is the latest slot for which we have all L1 data,
745
+ // either because we have seen all L1 blocks for that slot, or because
746
+ // we have seen the corresponding checkpoint.
747
+ let slotFromL1Sync;
612
748
  const l1Timestamp = this.synchronizer.getL1Timestamp();
613
- return Promise.resolve(l1Timestamp === undefined ? undefined : getSlotAtTimestamp(l1Timestamp, this.l1Constants));
749
+ if (l1Timestamp !== undefined) {
750
+ const nextL1BlockSlot = getSlotAtNextL1Block(l1Timestamp, this.l1Constants);
751
+ if (Number(nextL1BlockSlot) > 0) {
752
+ slotFromL1Sync = SlotNumber.add(nextL1BlockSlot, -1);
753
+ }
754
+ }
755
+ let slotFromCheckpoint;
756
+ const latestCheckpointNumber = await this.stores.blocks.getLatestCheckpointNumber();
757
+ if (latestCheckpointNumber > 0) {
758
+ const checkpointData = await this.stores.blocks.getCheckpointData(latestCheckpointNumber);
759
+ if (checkpointData) {
760
+ slotFromCheckpoint = checkpointData.header.slotNumber;
761
+ }
762
+ }
763
+ if (slotFromL1Sync === undefined && slotFromCheckpoint === undefined) {
764
+ return undefined;
765
+ }
766
+ return SlotNumber(Math.max(slotFromL1Sync ?? 0, slotFromCheckpoint ?? 0));
614
767
  }
615
- getL2EpochNumber() {
616
- const l1Timestamp = this.synchronizer.getL1Timestamp();
617
- return Promise.resolve(l1Timestamp === undefined ? undefined : getEpochNumberAtTimestamp(l1Timestamp, this.l1Constants));
768
+ async getSyncedL2EpochNumber() {
769
+ const syncedSlot = await this.getSyncedL2SlotNumber();
770
+ if (syncedSlot === undefined) {
771
+ return undefined;
772
+ }
773
+ // An epoch is fully synced when all its slots are synced.
774
+ // We check if syncedSlot is the last slot of its epoch; if so, that epoch is fully synced.
775
+ // Otherwise, only the previous epoch is fully synced.
776
+ const epoch = getEpochAtSlot(syncedSlot, this.l1Constants);
777
+ const [, endSlot] = getSlotRangeForEpoch(epoch, this.l1Constants);
778
+ if (syncedSlot >= endSlot) {
779
+ return epoch;
780
+ }
781
+ return Number(epoch) > 0 ? EpochNumber(Number(epoch) - 1) : undefined;
618
782
  }
619
783
  async isEpochComplete(epochNumber) {
620
784
  // The epoch is complete if the current checkpointed L2 block is the last one in the epoch (or later).
621
785
  // We use the checkpointed block number (synced from L1) instead of 'latest' to avoid returning true
622
786
  // prematurely when proposed blocks have been pushed to the archiver but not yet checkpointed on L1.
623
- const checkpointedBlockNumber = await this.getCheckpointedL2BlockNumber();
624
- const header = checkpointedBlockNumber > 0 ? await this.getBlockHeader(checkpointedBlockNumber) : undefined;
787
+ const header = (await this.getBlockData({
788
+ tag: 'checkpointed'
789
+ }))?.header;
625
790
  const slot = header ? header.globalVariables.slotNumber : undefined;
626
791
  const [_startSlot, endSlot] = getSlotRangeForEpoch(epochNumber, this.l1Constants);
627
792
  if (slot && slot >= endSlot) {
@@ -663,21 +828,28 @@ _dec = trackSpan('Archiver.sync');
663
828
  if (targetL2BlockNumber >= currentL2Block) {
664
829
  throw new Error(`Target L2 block ${targetL2BlockNumber} must be less than current L2 block ${currentL2Block}`);
665
830
  }
666
- const targetL2Block = await this.store.getCheckpointedBlock(targetL2BlockNumber);
667
- if (!targetL2Block) {
831
+ const checkpointedTip = await this.stores.blocks.getCheckpointedL2BlockNumber();
832
+ if (targetL2BlockNumber > checkpointedTip) {
833
+ throw new Error(`Target L2 block ${targetL2BlockNumber} is not checkpointed yet`);
834
+ }
835
+ const targetBlockData = await this.stores.blocks.getBlockData({
836
+ number: targetL2BlockNumber
837
+ });
838
+ if (!targetBlockData) {
668
839
  throw new Error(`Target L2 block ${targetL2BlockNumber} not found`);
669
840
  }
670
- const targetCheckpointNumber = targetL2Block.checkpointNumber;
841
+ const targetCheckpointNumber = targetBlockData.checkpointNumber;
671
842
  // Rollback operates at checkpoint granularity: the target block must be the last block of its checkpoint.
672
- const checkpointData = await this.store.getCheckpointData(targetCheckpointNumber);
673
- if (checkpointData) {
674
- const lastBlockInCheckpoint = BlockNumber(checkpointData.startBlock + checkpointData.blockCount - 1);
675
- if (targetL2BlockNumber !== lastBlockInCheckpoint) {
676
- const previousCheckpointBoundary = checkpointData.startBlock > 1 ? BlockNumber(checkpointData.startBlock - 1) : BlockNumber(0);
677
- throw new Error(`Target L2 block ${targetL2BlockNumber} is not at a checkpoint boundary. ` + `Checkpoint ${targetCheckpointNumber} spans blocks ${checkpointData.startBlock} to ${lastBlockInCheckpoint}. ` + `Use block ${lastBlockInCheckpoint} to roll back to this checkpoint, ` + `or block ${previousCheckpointBoundary} to roll back to the previous one.`);
678
- }
843
+ const checkpointData = await this.stores.blocks.getCheckpointData(targetCheckpointNumber);
844
+ if (!checkpointData) {
845
+ throw new Error(`Checkpoint ${targetCheckpointNumber} not found for block ${targetL2BlockNumber}`);
846
+ }
847
+ const lastBlockInCheckpoint = BlockNumber(checkpointData.startBlock + checkpointData.blockCount - 1);
848
+ if (targetL2BlockNumber !== lastBlockInCheckpoint) {
849
+ const previousCheckpointBoundary = checkpointData.startBlock > 1 ? BlockNumber(checkpointData.startBlock - 1) : BlockNumber(0);
850
+ throw new Error(`Target L2 block ${targetL2BlockNumber} is not at a checkpoint boundary. ` + `Checkpoint ${targetCheckpointNumber} spans blocks ${checkpointData.startBlock} to ${lastBlockInCheckpoint}. ` + `Use block ${lastBlockInCheckpoint} to roll back to this checkpoint, ` + `or block ${previousCheckpointBoundary} to roll back to the previous one.`);
679
851
  }
680
- const targetL1BlockNumber = targetL2Block.l1.blockNumber;
852
+ const targetL1BlockNumber = checkpointData.l1.blockNumber;
681
853
  const targetL1Block = await this.publicClient.getBlock({
682
854
  blockNumber: targetL1BlockNumber,
683
855
  includeTransactions: false
@@ -689,22 +861,21 @@ _dec = trackSpan('Archiver.sync');
689
861
  this.log.info(`Removing checkpoints after checkpoint ${targetCheckpointNumber} (target block ${targetL2BlockNumber})`);
690
862
  await this.updater.removeCheckpointsAfter(targetCheckpointNumber);
691
863
  this.log.info(`Rolling back L1 to L2 messages to checkpoint ${targetCheckpointNumber}`);
692
- await this.store.rollbackL1ToL2MessagesToCheckpoint(targetCheckpointNumber);
864
+ await this.stores.messages.rollbackL1ToL2MessagesToCheckpoint(targetCheckpointNumber);
693
865
  this.log.info(`Setting L1 syncpoints to ${targetL1BlockNumber}`);
694
- await this.store.setCheckpointSynchedL1BlockNumber(targetL1BlockNumber);
695
- await this.store.setMessageSynchedL1Block({
866
+ await this.stores.blocks.setSynchedL1BlockNumber(targetL1BlockNumber);
867
+ await this.stores.messages.setMessageSyncState({
696
868
  l1BlockNumber: targetL1BlockNumber,
697
869
  l1BlockHash: targetL1BlockHash
698
- });
870
+ }, undefined);
699
871
  if (targetL2BlockNumber < currentProvenBlock) {
700
872
  this.log.info(`Rolling back proven L2 checkpoint to ${targetCheckpointNumber}`);
701
873
  await this.updater.setProvenCheckpointNumber(targetCheckpointNumber);
702
874
  }
703
- // TODO(palla/reorg): Set the finalized block when we add support for it.
704
- // const currentFinalizedBlock = currentBlocks.finalized.block.number;
705
- // if (targetL2BlockNumber < currentFinalizedBlock) {
706
- // this.log.info(`Rolling back finalized L2 checkpoint to ${targetCheckpointNumber}`);
707
- // await this.updater.setFinalizedCheckpointNumber(targetCheckpointNumber);
708
- // }
875
+ const currentFinalizedBlock = currentBlocks.finalized.block.number;
876
+ if (targetL2BlockNumber < currentFinalizedBlock) {
877
+ this.log.info(`Rolling back finalized L2 checkpoint to ${targetCheckpointNumber}`);
878
+ await this.updater.setFinalizedCheckpointNumber(targetCheckpointNumber);
879
+ }
709
880
  }
710
881
  }
package/dest/config.d.ts CHANGED
@@ -2,7 +2,7 @@ import { type BlobClientConfig } from '@aztec/blob-client/client/config';
2
2
  import { type L1ContractsConfig } from '@aztec/ethereum/config';
3
3
  import { type L1ReaderConfig } from '@aztec/ethereum/l1-reader';
4
4
  import { type ConfigMappingsType } from '@aztec/foundation/config';
5
- import { type ChainConfig } from '@aztec/stdlib/config';
5
+ import { type ChainConfig, type PipelineConfig } from '@aztec/stdlib/config';
6
6
  import type { ArchiverSpecificConfig } from '@aztec/stdlib/interfaces/server';
7
7
  /**
8
8
  * The archiver configuration.
@@ -11,7 +11,7 @@ import type { ArchiverSpecificConfig } from '@aztec/stdlib/interfaces/server';
11
11
  * Results of calls to eth_blockNumber are cached by viem with this cache being updated periodically at the interval specified by viemPollingIntervalMS.
12
12
  * As a result the maximum observed polling time for new blocks will be viemPollingIntervalMS + archiverPollingIntervalMS.
13
13
  */
14
- export type ArchiverConfig = ArchiverSpecificConfig & L1ReaderConfig & L1ContractsConfig & BlobClientConfig & ChainConfig;
14
+ export type ArchiverConfig = ArchiverSpecificConfig & L1ReaderConfig & L1ContractsConfig & PipelineConfig & BlobClientConfig & ChainConfig;
15
15
  export declare const archiverConfigMappings: ConfigMappingsType<ArchiverConfig>;
16
16
  /**
17
17
  * Returns the archiver configuration from the environment variables.
@@ -24,7 +24,10 @@ export declare function mapArchiverConfig(config: Partial<ArchiverConfig>): {
24
24
  pollingIntervalMs: number | undefined;
25
25
  batchSize: number | undefined;
26
26
  skipValidateCheckpointAttestations: boolean | undefined;
27
+ skipPromoteProposedCheckpointDuringL1Sync: boolean | undefined;
27
28
  maxAllowedEthClientDriftSeconds: number | undefined;
28
29
  ethereumAllowNoDebugHosts: boolean | undefined;
30
+ skipHistoricalLogsCheck: boolean | undefined;
31
+ orphanProposedBlockPruneGraceSeconds: number | undefined;
29
32
  };
30
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxLQUFLLGdCQUFnQixFQUEyQixNQUFNLGtDQUFrQyxDQUFDO0FBQ2xHLE9BQU8sRUFBRSxLQUFLLGlCQUFpQixFQUE2QixNQUFNLHdCQUF3QixDQUFDO0FBRTNGLE9BQU8sRUFBRSxLQUFLLGNBQWMsRUFBMEIsTUFBTSwyQkFBMkIsQ0FBQztBQUN4RixPQUFPLEVBQ0wsS0FBSyxrQkFBa0IsRUFJeEIsTUFBTSwwQkFBMEIsQ0FBQztBQUNsQyxPQUFPLEVBQUUsS0FBSyxXQUFXLEVBQXVCLE1BQU0sc0JBQXNCLENBQUM7QUFDN0UsT0FBTyxLQUFLLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUU5RTs7Ozs7O0dBTUc7QUFDSCxNQUFNLE1BQU0sY0FBYyxHQUFHLHNCQUFzQixHQUNqRCxjQUFjLEdBQ2QsaUJBQWlCLEdBQ2pCLGdCQUFnQixHQUNoQixXQUFXLENBQUM7QUFFZCxlQUFPLE1BQU0sc0JBQXNCLEVBQUUsa0JBQWtCLENBQUMsY0FBYyxDQWdEckUsQ0FBQztBQUVGOzs7O0dBSUc7QUFDSCx3QkFBZ0Isd0JBQXdCLElBQUksY0FBYyxDQUV6RDtBQUVELGdGQUFnRjtBQUNoRix3QkFBZ0IsaUJBQWlCLENBQUMsTUFBTSxFQUFFLE9BQU8sQ0FBQyxjQUFjLENBQUM7Ozs7OztFQVFoRSJ9
33
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxLQUFLLGdCQUFnQixFQUEyQixNQUFNLGtDQUFrQyxDQUFDO0FBQ2xHLE9BQU8sRUFBRSxLQUFLLGlCQUFpQixFQUE2QixNQUFNLHdCQUF3QixDQUFDO0FBQzNGLE9BQU8sRUFBRSxLQUFLLGNBQWMsRUFBMEIsTUFBTSwyQkFBMkIsQ0FBQztBQUN4RixPQUFPLEVBQ0wsS0FBSyxrQkFBa0IsRUFLeEIsTUFBTSwwQkFBMEIsQ0FBQztBQUNsQyxPQUFPLEVBQ0wsS0FBSyxXQUFXLEVBQ2hCLEtBQUssY0FBYyxFQUdwQixNQUFNLHNCQUFzQixDQUFDO0FBQzlCLE9BQU8sS0FBSyxFQUFFLHNCQUFzQixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFOUU7Ozs7OztHQU1HO0FBQ0gsTUFBTSxNQUFNLGNBQWMsR0FBRyxzQkFBc0IsR0FDakQsY0FBYyxHQUNkLGlCQUFpQixHQUNqQixjQUFjLEdBQ2QsZ0JBQWdCLEdBQ2hCLFdBQVcsQ0FBQztBQUVkLGVBQU8sTUFBTSxzQkFBc0IsRUFBRSxrQkFBa0IsQ0FBQyxjQUFjLENBMkRyRSxDQUFDO0FBRUY7Ozs7R0FJRztBQUNILHdCQUFnQix3QkFBd0IsSUFBSSxjQUFjLENBRXpEO0FBRUQsZ0ZBQWdGO0FBQ2hGLHdCQUFnQixpQkFBaUIsQ0FBQyxNQUFNLEVBQUUsT0FBTyxDQUFDLGNBQWMsQ0FBQzs7Ozs7Ozs7O0VBV2hFIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAA2B,MAAM,kCAAkC,CAAC;AAClG,OAAO,EAAE,KAAK,iBAAiB,EAA6B,MAAM,wBAAwB,CAAC;AAE3F,OAAO,EAAE,KAAK,cAAc,EAA0B,MAAM,2BAA2B,CAAC;AACxF,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,WAAW,EAAuB,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAE9E;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,sBAAsB,GACjD,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,WAAW,CAAC;AAEd,eAAO,MAAM,sBAAsB,EAAE,kBAAkB,CAAC,cAAc,CAgDrE,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,cAAc,CAEzD;AAED,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC;;;;;;EAQhE"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAA2B,MAAM,kCAAkC,CAAC;AAClG,OAAO,EAAE,KAAK,iBAAiB,EAA6B,MAAM,wBAAwB,CAAC;AAC3F,OAAO,EAAE,KAAK,cAAc,EAA0B,MAAM,2BAA2B,CAAC;AACxF,OAAO,EACL,KAAK,kBAAkB,EAKxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,cAAc,EAGpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAE9E;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,sBAAsB,GACjD,cAAc,GACd,iBAAiB,GACjB,cAAc,GACd,gBAAgB,GAChB,WAAW,CAAC;AAEd,eAAO,MAAM,sBAAsB,EAAE,kBAAkB,CAAC,cAAc,CA2DrE,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,cAAc,CAEzD;AAED,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC;;;;;;;;;EAWhE"}
package/dest/config.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { blobClientConfigMapping } from '@aztec/blob-client/client/config';
2
2
  import { l1ContractsConfigMappings } from '@aztec/ethereum/config';
3
- import { l1ContractAddressesMapping } from '@aztec/ethereum/l1-contract-addresses';
4
3
  import { l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
5
- import { booleanConfigHelper, getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
6
- import { chainConfigMappings } from '@aztec/stdlib/config';
4
+ import { booleanConfigHelper, getConfigFromMappings, numberConfigHelper, optionalNumberConfigHelper } from '@aztec/foundation/config';
5
+ import { chainConfigMappings, pipelineConfigMappings } from '@aztec/stdlib/config';
7
6
  export const archiverConfigMappings = {
8
7
  ...blobClientConfigMapping,
8
+ ...pipelineConfigMappings,
9
9
  archiverPollingIntervalMS: {
10
10
  env: 'ARCHIVER_POLLING_INTERVAL_MS',
11
11
  description: 'The polling interval in ms for retrieving new L2 blocks and encrypted logs.',
@@ -16,20 +16,19 @@ export const archiverConfigMappings = {
16
16
  description: 'The number of L2 blocks the archiver will attempt to download at a time.',
17
17
  ...numberConfigHelper(100)
18
18
  },
19
- maxLogs: {
20
- env: 'ARCHIVER_MAX_LOGS',
21
- description: 'The max number of logs that can be obtained in 1 "getPublicLogs" call.',
22
- ...numberConfigHelper(1_000)
23
- },
24
19
  archiverStoreMapSizeKb: {
25
20
  env: 'ARCHIVER_STORE_MAP_SIZE_KB',
26
- parseEnv: (val)=>val ? +val : undefined,
21
+ ...optionalNumberConfigHelper(),
27
22
  description: 'The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKb.'
28
23
  },
29
24
  skipValidateCheckpointAttestations: {
30
25
  description: 'Skip validating checkpoint attestations (for testing purposes only)',
31
26
  ...booleanConfigHelper(false)
32
27
  },
28
+ skipPromoteProposedCheckpointDuringL1Sync: {
29
+ description: 'Skip promoting proposed checkpoints during L1 sync (for testing purposes only)',
30
+ ...booleanConfigHelper(false)
31
+ },
33
32
  maxAllowedEthClientDriftSeconds: {
34
33
  env: 'MAX_ALLOWED_ETH_CLIENT_DRIFT_SECONDS',
35
34
  description: 'Maximum allowed drift in seconds between the Ethereum client and current time.',
@@ -40,6 +39,16 @@ export const archiverConfigMappings = {
40
39
  description: 'Whether to allow starting the archiver without debug/trace method support on Ethereum hosts',
41
40
  ...booleanConfigHelper(true)
42
41
  },
42
+ archiverSkipHistoricalLogsCheck: {
43
+ env: 'ARCHIVER_SKIP_HISTORICAL_LOGS_CHECK',
44
+ description: 'Skip the startup check that probes the L1 RPC for historical Rollup contract logs. ' + 'Set to true to bypass the check when the connected RPC node is known to prune old logs.',
45
+ ...booleanConfigHelper(false)
46
+ },
47
+ orphanProposedBlockPruneGraceSeconds: {
48
+ env: 'ARCHIVER_ORPHAN_PROPOSED_BLOCK_PRUNE_GRACE_SECONDS',
49
+ description: 'Grace period in seconds, measured from the end of a proposed block build slot, after which a ' + 'proposed block with no matching proposed checkpoint is pruned as an orphan. Defaults from the ' + 'sequencer block duration at the node wiring layer when unset.',
50
+ ...optionalNumberConfigHelper()
51
+ },
43
52
  ...chainConfigMappings,
44
53
  ...l1ReaderConfigMappings,
45
54
  viemPollingIntervalMS: {
@@ -47,11 +56,7 @@ export const archiverConfigMappings = {
47
56
  description: 'The polling interval viem uses in ms',
48
57
  ...numberConfigHelper(1000)
49
58
  },
50
- ...l1ContractsConfigMappings,
51
- l1Contracts: {
52
- description: 'The deployed L1 contract addresses',
53
- nested: l1ContractAddressesMapping
54
- }
59
+ ...l1ContractsConfigMappings
55
60
  };
56
61
  /**
57
62
  * Returns the archiver configuration from the environment variables.
@@ -65,7 +70,10 @@ export const archiverConfigMappings = {
65
70
  pollingIntervalMs: config.archiverPollingIntervalMS,
66
71
  batchSize: config.archiverBatchSize,
67
72
  skipValidateCheckpointAttestations: config.skipValidateCheckpointAttestations,
73
+ skipPromoteProposedCheckpointDuringL1Sync: config.skipPromoteProposedCheckpointDuringL1Sync,
68
74
  maxAllowedEthClientDriftSeconds: config.maxAllowedEthClientDriftSeconds,
69
- ethereumAllowNoDebugHosts: config.ethereumAllowNoDebugHosts
75
+ ethereumAllowNoDebugHosts: config.ethereumAllowNoDebugHosts,
76
+ skipHistoricalLogsCheck: config.archiverSkipHistoricalLogsCheck,
77
+ orphanProposedBlockPruneGraceSeconds: config.orphanProposedBlockPruneGraceSeconds
70
78
  };
71
79
  }