@aztec/archiver 0.0.1-commit.b2a5d0dd1 → 0.0.1-commit.b3d3157a

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 (106) hide show
  1. package/README.md +7 -5
  2. package/dest/archiver.d.ts +49 -14
  3. package/dest/archiver.d.ts.map +1 -1
  4. package/dest/archiver.js +216 -68
  5. package/dest/config.d.ts +4 -3
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +11 -16
  8. package/dest/errors.d.ts +19 -13
  9. package/dest/errors.d.ts.map +1 -1
  10. package/dest/errors.js +32 -16
  11. package/dest/factory.d.ts +12 -6
  12. package/dest/factory.d.ts.map +1 -1
  13. package/dest/factory.js +31 -21
  14. package/dest/index.d.ts +9 -2
  15. package/dest/index.d.ts.map +1 -1
  16. package/dest/index.js +8 -1
  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 +13 -4
  20. package/dest/l1/trace_tx.d.ts +12 -66
  21. package/dest/l1/trace_tx.d.ts.map +1 -1
  22. package/dest/modules/contract_data_source_adapter.d.ts +25 -0
  23. package/dest/modules/contract_data_source_adapter.d.ts.map +1 -0
  24. package/dest/modules/contract_data_source_adapter.js +40 -0
  25. package/dest/modules/data_source_base.d.ts +71 -49
  26. package/dest/modules/data_source_base.d.ts.map +1 -1
  27. package/dest/modules/data_source_base.js +269 -143
  28. package/dest/modules/data_store_updater.d.ts +18 -6
  29. package/dest/modules/data_store_updater.d.ts.map +1 -1
  30. package/dest/modules/data_store_updater.js +108 -59
  31. package/dest/modules/instrumentation.js +3 -1
  32. package/dest/modules/l1_synchronizer.d.ts +6 -5
  33. package/dest/modules/l1_synchronizer.d.ts.map +1 -1
  34. package/dest/modules/l1_synchronizer.js +203 -100
  35. package/dest/modules/outbox_trees_resolver.d.ts +62 -0
  36. package/dest/modules/outbox_trees_resolver.d.ts.map +1 -0
  37. package/dest/modules/outbox_trees_resolver.js +162 -0
  38. package/dest/modules/validation.d.ts +4 -3
  39. package/dest/modules/validation.d.ts.map +1 -1
  40. package/dest/modules/validation.js +4 -4
  41. package/dest/store/block_store.d.ts +155 -98
  42. package/dest/store/block_store.d.ts.map +1 -1
  43. package/dest/store/block_store.js +473 -265
  44. package/dest/store/contract_class_store.d.ts +17 -3
  45. package/dest/store/contract_class_store.d.ts.map +1 -1
  46. package/dest/store/contract_class_store.js +17 -1
  47. package/dest/store/contract_instance_store.d.ts +28 -1
  48. package/dest/store/contract_instance_store.d.ts.map +1 -1
  49. package/dest/store/contract_instance_store.js +31 -0
  50. package/dest/store/data_stores.d.ts +68 -0
  51. package/dest/store/data_stores.d.ts.map +1 -0
  52. package/dest/store/data_stores.js +54 -0
  53. package/dest/store/function_names_cache.d.ts +17 -0
  54. package/dest/store/function_names_cache.d.ts.map +1 -0
  55. package/dest/store/function_names_cache.js +30 -0
  56. package/dest/store/l2_tips_cache.d.ts +13 -8
  57. package/dest/store/l2_tips_cache.d.ts.map +1 -1
  58. package/dest/store/l2_tips_cache.js +13 -96
  59. package/dest/store/log_store.d.ts +42 -40
  60. package/dest/store/log_store.d.ts.map +1 -1
  61. package/dest/store/log_store.js +257 -478
  62. package/dest/store/log_store_codec.d.ts +70 -0
  63. package/dest/store/log_store_codec.d.ts.map +1 -0
  64. package/dest/store/log_store_codec.js +101 -0
  65. package/dest/store/message_store.d.ts +9 -3
  66. package/dest/store/message_store.d.ts.map +1 -1
  67. package/dest/store/message_store.js +31 -1
  68. package/dest/test/fake_l1_state.d.ts +2 -1
  69. package/dest/test/fake_l1_state.d.ts.map +1 -1
  70. package/dest/test/fake_l1_state.js +25 -8
  71. package/dest/test/mock_l2_block_source.d.ts +47 -51
  72. package/dest/test/mock_l2_block_source.d.ts.map +1 -1
  73. package/dest/test/mock_l2_block_source.js +223 -185
  74. package/dest/test/noop_l1_archiver.d.ts +10 -6
  75. package/dest/test/noop_l1_archiver.d.ts.map +1 -1
  76. package/dest/test/noop_l1_archiver.js +19 -8
  77. package/package.json +14 -14
  78. package/src/archiver.ts +265 -72
  79. package/src/config.ts +12 -19
  80. package/src/errors.ts +46 -23
  81. package/src/factory.ts +38 -20
  82. package/src/index.ts +16 -1
  83. package/src/l1/calldata_retriever.ts +14 -4
  84. package/src/modules/contract_data_source_adapter.ts +55 -0
  85. package/src/modules/data_source_base.ts +335 -187
  86. package/src/modules/data_store_updater.ts +118 -61
  87. package/src/modules/instrumentation.ts +1 -1
  88. package/src/modules/l1_synchronizer.ts +278 -120
  89. package/src/modules/outbox_trees_resolver.ts +199 -0
  90. package/src/modules/validation.ts +8 -7
  91. package/src/store/block_store.ts +566 -323
  92. package/src/store/contract_class_store.ts +28 -2
  93. package/src/store/contract_instance_store.ts +43 -0
  94. package/src/store/data_stores.ts +104 -0
  95. package/src/store/function_names_cache.ts +37 -0
  96. package/src/store/l2_tips_cache.ts +16 -115
  97. package/src/store/log_store.ts +296 -650
  98. package/src/store/log_store_codec.ts +132 -0
  99. package/src/store/message_store.ts +35 -2
  100. package/src/test/fake_l1_state.ts +24 -14
  101. package/src/test/mock_l2_block_source.ts +271 -239
  102. package/src/test/noop_l1_archiver.ts +39 -8
  103. package/dest/store/kv_archiver_store.d.ts +0 -383
  104. package/dest/store/kv_archiver_store.d.ts.map +0 -1
  105. package/dest/store/kv_archiver_store.js +0 -501
  106. package/src/store/kv_archiver_store.ts +0 -728
package/dest/archiver.js CHANGED
@@ -371,24 +371,27 @@ 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, _initProto;
374
+ import { PROPOSER_PIPELINING_SLOT_OFFSET } from '@aztec/epoch-cache';
374
375
  import { BlockTagTooOldError } from '@aztec/ethereum/contracts';
375
376
  import { BlockNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
376
377
  import { Buffer32 } from '@aztec/foundation/buffer';
377
- import { merge } from '@aztec/foundation/collection';
378
+ import { merge, pick } from '@aztec/foundation/collection';
378
379
  import { EthAddress } from '@aztec/foundation/eth-address';
379
380
  import { createLogger } from '@aztec/foundation/log';
380
381
  import { promiseWithResolvers } from '@aztec/foundation/promise';
381
382
  import { RunningPromise, makeLoggingErrorHandler } from '@aztec/foundation/running-promise';
382
383
  import { elapsed } from '@aztec/foundation/timer';
383
- import { getEpochAtSlot, getSlotAtNextL1Block, getSlotRangeForEpoch, getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
384
+ import { L2BlockSourceEvents } from '@aztec/stdlib/block';
385
+ import { getEpochAtSlot, getSlotAtNextL1Block, getSlotRangeForEpoch, getTimestampForSlot, getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
384
386
  import { trackSpan } from '@aztec/telemetry-client';
385
387
  import { mapArchiverConfig } from './config.js';
386
- import { BlockAlreadyCheckpointedError, NoBlobBodiesFoundError } from './errors.js';
388
+ import { BlockAlreadyCheckpointedError, BlockOrCheckpointSlotExpiredError, NoBlobBodiesFoundError } from './errors.js';
387
389
  import { validateAndLogHistoricalLogsAvailability } from './l1/validate_historical_logs.js';
388
390
  import { validateAndLogTraceAvailability } from './l1/validate_trace.js';
389
391
  import { ArchiverDataSourceBase } from './modules/data_source_base.js';
390
392
  import { ArchiverDataStoreUpdater } from './modules/data_store_updater.js';
391
- import { L2TipsCache } from './store/l2_tips_cache.js';
393
+ import { OutboxTreesResolver } from './modules/outbox_trees_resolver.js';
394
+ import { backupArchiverDataStores, getArchiverSynchPoint } from './store/data_stores.js';
392
395
  _dec = trackSpan('Archiver.sync');
393
396
  /**
394
397
  * Pulls checkpoints in a non-blocking manner and provides interface for their retrieval.
@@ -398,11 +401,13 @@ _dec = trackSpan('Archiver.sync');
398
401
  publicClient;
399
402
  debugClient;
400
403
  rollup;
404
+ outbox;
401
405
  l1Addresses;
402
- dataStore;
406
+ dataStores;
403
407
  config;
404
408
  blobClient;
405
409
  l1Constants;
410
+ dateProvider;
406
411
  log;
407
412
  static{
408
413
  ({ e: [_initProto] } = _apply_decs_2203_r(this, [
@@ -416,9 +421,10 @@ _dec = trackSpan('Archiver.sync');
416
421
  /** Event emitter for archiver events (L2BlockProven, L2PruneUnproven, L2PruneUncheckpointed, etc). */ events;
417
422
  /** A loop in which we will be continually fetching new checkpoints. */ runningPromise;
418
423
  /** L1 synchronizer that handles fetching checkpoints and messages from L1. */ synchronizer;
424
+ /** Resolver for L2-to-L1 message membership witnesses, built over this archiver's read view. */ outboxTreesResolver;
419
425
  initialSyncComplete;
420
426
  initialSyncPromise;
421
- /** Queue of blocks to be added to the store, processed by the sync loop. */ blockQueue;
427
+ /** Queue of blocks and checkpoints to be added to the store, processed by the sync loop. */ inboundQueue;
422
428
  /** Helper to handle updates to the store */ updater;
423
429
  /** In-memory cache for L2 chain tips. */ l2TipsCache;
424
430
  tracer;
@@ -428,30 +434,54 @@ _dec = trackSpan('Archiver.sync');
428
434
  * @param publicClient - A client for interacting with the Ethereum node.
429
435
  * @param debugClient - A client for interacting with the Ethereum node for debug/trace methods.
430
436
  * @param rollup - Rollup contract instance.
437
+ * @param outbox - Outbox contract instance, used to read per-epoch L2-to-L1 message roots.
431
438
  * @param inbox - Inbox contract instance.
432
439
  * @param l1Addresses - L1 contract addresses (registry, governance proposer, slashing proposer).
433
- * @param dataStore - An archiver data store for storage & retrieval of blocks, encrypted logs & contract data.
440
+ * @param dataStores - Archiver substores for storage & retrieval of blocks, encrypted logs & contract data.
434
441
  * @param config - Archiver configuration options.
435
442
  * @param blobClient - Client for retrieving blob data.
436
- * @param dateProvider - Provider for current date/time.
437
443
  * @param instrumentation - Instrumentation for metrics and tracing.
438
444
  * @param l1Constants - L1 rollup constants.
445
+ * @param synchronizer - L1 synchronizer that handles fetching checkpoints and messages from L1.
446
+ * @param events - Event emitter shared with the synchronizer.
447
+ * @param initialHeader - Genesis block header.
448
+ * @param initialBlockHash - Precomputed hash of the genesis block header.
449
+ * @param l2TipsCache - In-memory cache for L2 chain tips.
450
+ * @param dateProvider - Provider for current date/time, used for wall-clock orphan-block pruning.
439
451
  * @param log - A logger.
440
- */ constructor(publicClient, debugClient, rollup, l1Addresses, dataStore, config, blobClient, instrumentation, l1Constants, synchronizer, events, l2TipsCache, log = createLogger('archiver')){
441
- 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 = [];
452
+ */ constructor(publicClient, debugClient, rollup, outbox, l1Addresses, dataStores, config, blobClient, instrumentation, l1Constants, synchronizer, events, initialHeader, initialBlockHash, l2TipsCache, dateProvider, log = createLogger('archiver')){
453
+ super(dataStores, l1Constants, initialHeader, initialBlockHash, l1Constants.genesisArchiveRoot), this.publicClient = publicClient, this.debugClient = debugClient, this.rollup = rollup, this.outbox = outbox, this.l1Addresses = l1Addresses, this.dataStores = dataStores, this.config = config, this.blobClient = blobClient, this.l1Constants = l1Constants, this.dateProvider = dateProvider, this.log = log, this.initialSyncComplete = (_initProto(this), false), this.inboundQueue = [];
442
454
  this.tracer = instrumentation.tracer;
443
455
  this.instrumentation = instrumentation;
444
456
  this.initialSyncPromise = promiseWithResolvers();
445
457
  this.synchronizer = synchronizer;
446
458
  this.events = events;
447
- this.l2TipsCache = l2TipsCache ?? new L2TipsCache(this.dataStore.blockStore);
448
- this.updater = new ArchiverDataStoreUpdater(this.dataStore, this.l2TipsCache, {
459
+ this.l2TipsCache = l2TipsCache;
460
+ this.updater = new ArchiverDataStoreUpdater(this.dataStores, this.l2TipsCache, {
449
461
  rollupManaLimit: l1Constants.rollupManaLimit
450
462
  });
463
+ // The resolver reads its witness data from this archiver and pins its lazy Outbox-root fetches
464
+ // to the archiver's synced L1 block. No method on `this` is invoked during construction.
465
+ this.outboxTreesResolver = new OutboxTreesResolver(this.outbox, this, ()=>Promise.resolve(this.getL1BlockNumber()), l1Constants.epochDuration);
451
466
  // Running promise starts with a small interval inbetween runs, so all iterations needed for the initial sync
452
467
  // are done as fast as possible. This then gets updated once the initial sync completes.
453
468
  this.runningPromise = new RunningPromise(()=>this.sync(), this.log, this.config.pollingIntervalMs / 10, makeLoggingErrorHandler(this.log, NoBlobBodiesFoundError, BlockTagTooOldError));
454
469
  }
470
+ /**
471
+ * Returns the L2-to-L1 membership witness for `message` emitted by tx `txHash`. The node selects
472
+ * the smallest partial-proof root on the Outbox that covers the tx's checkpoint and builds the
473
+ * witness against it.
474
+ *
475
+ * The node reads the Outbox roots lazily, pinned to its synced L1 block, so the witness reflects
476
+ * the node's synced view. Returns `undefined` if the tx isn't yet in a block/epoch or no covering
477
+ * root has landed on L1 as of the synced block.
478
+ *
479
+ * Caveat: roots are cached only for the current synced L1 block and re-fetched once the node
480
+ * advances, so a reorg is picked up on the next synced-block advance rather than re-validated per
481
+ * request.
482
+ */ getL2ToL1MembershipWitness(txHash, message, messageIndexInTx) {
483
+ return this.outboxTreesResolver.getL2ToL1MembershipWitness(txHash, message, messageIndexInTx);
484
+ }
455
485
  /** Updates archiver config */ updateConfig(newConfig) {
456
486
  this.config = merge(this.config, mapArchiverConfig(newConfig));
457
487
  this.synchronizer.setConfig(this.config);
@@ -474,8 +504,8 @@ _dec = trackSpan('Archiver.sync');
474
504
  }, this.config.skipHistoricalLogsCheck ?? false, this.log.getBindings());
475
505
  // Log initial state for the archiver
476
506
  const { l1StartBlock } = this.l1Constants;
477
- const { blocksSynchedTo = l1StartBlock, messagesSynchedTo = l1StartBlock } = await this.store.getSynchPoint();
478
- const currentL2Checkpoint = await this.getSynchedCheckpointNumber();
507
+ const { blocksSynchedTo = l1StartBlock, messagesSynchedTo = l1StartBlock } = await getArchiverSynchPoint(this.stores);
508
+ const currentL2Checkpoint = await this.getCheckpointNumber();
479
509
  this.log.info(`Starting archiver sync to rollup contract ${this.rollup.address} from L1 block ${blocksSynchedTo} and L2 checkpoint ${currentL2Checkpoint}`, {
480
510
  blocksSynchedTo,
481
511
  messagesSynchedTo,
@@ -490,6 +520,13 @@ _dec = trackSpan('Archiver.sync');
490
520
  syncImmediate() {
491
521
  return this.runningPromise.trigger();
492
522
  }
523
+ trySyncImmediate() {
524
+ try {
525
+ return this.syncImmediate();
526
+ } catch (err) {
527
+ this.log.error(`Failed to trigger immediate archiver sync: ${err}`, err);
528
+ }
529
+ }
493
530
  /**
494
531
  * Queues a block to be added to the archiver store and triggers processing.
495
532
  * The block will be processed by the sync loop.
@@ -497,60 +534,84 @@ _dec = trackSpan('Archiver.sync');
497
534
  * @param block - The L2 block to add.
498
535
  * @returns A promise that resolves when the block has been added to the store, or rejects on error.
499
536
  */ addBlock(block) {
500
- return new Promise((resolve, reject)=>{
501
- this.blockQueue.push({
502
- block,
503
- resolve,
504
- reject
505
- });
506
- this.log.debug(`Queued block ${block.number} for processing`);
507
- // Trigger an immediate sync, but don't wait for it - the promise resolves when the block is processed
508
- this.syncImmediate().catch((err)=>{
509
- this.log.error(`Sync immediate call failed: ${err}`);
510
- });
537
+ const promise = promiseWithResolvers();
538
+ this.inboundQueue.push({
539
+ block,
540
+ ...promise,
541
+ type: 'block'
511
542
  });
543
+ this.log.debug(`Queued block ${block.number} for processing`);
544
+ void this.trySyncImmediate();
545
+ return promise.promise;
512
546
  }
513
- async setProposedCheckpoint(pending) {
514
- await this.updater.setProposedCheckpoint(pending);
547
+ /**
548
+ * Queues a new proposed checkpoint into the archiver store.
549
+ * Checks that the checkpoint is not for an L2 slot already synced from L1.
550
+ * Resolves once the checkpoint has been processed.
551
+ */ addProposedCheckpoint(pending) {
552
+ const promise = promiseWithResolvers();
553
+ this.inboundQueue.push({
554
+ checkpoint: pending,
555
+ ...promise,
556
+ type: 'checkpoint'
557
+ });
558
+ this.log.debug(`Queued checkpoint ${pending.checkpointNumber} for processing`);
559
+ void this.trySyncImmediate();
560
+ return promise.promise;
515
561
  }
516
562
  /**
517
- * Processes all queued blocks, adding them to the store.
563
+ * Processes all queued blocks and checkpoints, adding them to the store.
518
564
  * Called at the beginning of each sync iteration.
519
- * Blocks are processed in the order they were queued.
520
- */ async processQueuedBlocks() {
521
- if (this.blockQueue.length === 0) {
565
+ * Items are processed in the order they were queued.
566
+ */ async processInboundQueue() {
567
+ if (this.inboundQueue.length === 0) {
522
568
  return;
523
569
  }
524
- // Take all blocks from the queue
525
- const queuedItems = this.blockQueue.splice(0, this.blockQueue.length);
526
- this.log.debug(`Processing ${queuedItems.length} queued block(s)`);
570
+ // Take all items from the queue
571
+ const queuedItems = this.inboundQueue.splice(0, this.inboundQueue.length);
572
+ this.log.debug(`Processing ${queuedItems.length} queued inbound items`);
527
573
  // Calculate slot threshold for validation
528
574
  const l1Timestamp = this.synchronizer.getL1Timestamp();
529
575
  const slotAtNextL1Block = l1Timestamp === undefined ? undefined : getSlotAtNextL1Block(l1Timestamp, this.l1Constants);
530
- // Process each block individually to properly resolve/reject each promise
531
- for (const { block, resolve, reject } of queuedItems){
532
- const blockSlot = block.header.globalVariables.slotNumber;
533
- if (slotAtNextL1Block !== undefined && blockSlot < slotAtNextL1Block) {
534
- this.log.warn(`Rejecting proposed block ${block.number} for past slot ${blockSlot} (current is ${slotAtNextL1Block})`, {
535
- block: block.toBlockInfo(),
576
+ // Helpers for manipulating blocks and checkpoints in the queue
577
+ const getSlot = (item)=>item.type === 'block' ? item.block.header.globalVariables.slotNumber : item.checkpoint.header.slotNumber;
578
+ const getNumber = (item)=>item.type === 'block' ? item.block.number : item.checkpoint.checkpointNumber;
579
+ // Process each item individually to properly resolve/reject each promise
580
+ for (const item of queuedItems){
581
+ const { resolve, reject, type } = item;
582
+ const itemSlot = getSlot(item);
583
+ const itemNumber = getNumber(item);
584
+ if (slotAtNextL1Block !== undefined && itemSlot < slotAtNextL1Block) {
585
+ const nextSlotTimestamp = getTimestampForSlot(slotAtNextL1Block, this.l1Constants);
586
+ this.log.warn(`Rejecting proposed ${type} ${itemNumber} for past slot ${itemSlot} (current ${slotAtNextL1Block})`, {
587
+ number: itemNumber,
588
+ type,
536
589
  l1Timestamp,
537
- slotAtNextL1Block
590
+ slotAtNextL1Block,
591
+ nextSlotTimestamp
538
592
  });
539
- reject(new Error(`Block ${block.number} is for past slot ${blockSlot} (current is ${slotAtNextL1Block})`));
593
+ reject(new BlockOrCheckpointSlotExpiredError(itemSlot, nextSlotTimestamp, l1Timestamp));
540
594
  continue;
541
595
  }
542
596
  try {
543
- const [durationMs] = await elapsed(()=>this.updater.addProposedBlock(block));
544
- this.instrumentation.processNewProposedBlock(durationMs, block);
545
- this.log.debug(`Added block ${block.number} to store`);
597
+ if (type === 'block') {
598
+ const [durationMs] = await elapsed(()=>this.updater.addProposedBlock(item.block));
599
+ this.instrumentation.processNewProposedBlock(durationMs, item.block);
600
+ } else {
601
+ await this.updater.addProposedCheckpoint(item.checkpoint);
602
+ }
603
+ this.log.debug(`Added ${type} ${itemNumber} to store`);
546
604
  resolve();
547
605
  } catch (err) {
548
606
  if (err instanceof BlockAlreadyCheckpointedError) {
549
- this.log.debug(`Proposed block ${block.number} matches already checkpointed block, ignoring late proposal`);
607
+ this.log.debug(`Proposed block ${itemNumber} matches already checkpointed block, ignoring late proposal`);
550
608
  resolve();
551
609
  continue;
552
610
  }
553
- this.log.error(`Failed to add block ${block.number} to store: ${err.message}`);
611
+ this.log.error(`Failed to add ${type} ${itemNumber} to store: ${err.message}`, err, {
612
+ number: itemNumber,
613
+ type
614
+ });
554
615
  reject(err);
555
616
  }
556
617
  }
@@ -562,9 +623,88 @@ _dec = trackSpan('Archiver.sync');
562
623
  * Fetches logs from L1 contracts and processes them.
563
624
  */ async sync() {
564
625
  // Process any queued blocks first, before doing L1 sync
565
- await this.processQueuedBlocks();
626
+ await this.processInboundQueue();
566
627
  // Now perform L1 sync
567
628
  await this.syncFromL1();
629
+ // Prune proposed blocks with no corresponding proposed checkpoint by the end of their build slot.
630
+ await this.pruneOrphanProposedBlocks();
631
+ }
632
+ /**
633
+ * Prunes a block-only local tip that was built atop a checkpoint that was never itself proposed.
634
+ *
635
+ * Under pipelining, a proposer publishes the blocks for a checkpoint (block-only proposals) before
636
+ * assembling and publishing the enclosing proposed checkpoint at the end of the build slot. A node
637
+ * that received those blocks but never the proposed checkpoint is left with an orphan tip it must
638
+ * not build on. We prune it once enough wall-clock time has elapsed that the proposed checkpoint
639
+ * should have arrived. This runs on wall-clock time (not L1 block advancement) so it fires during
640
+ * quiet L1 periods, and is the liveness counterpart to the sequencer's checkSync guard.
641
+ *
642
+ * The uncheckpointed suffix is scanned in order. Blocks covered by proposed checkpoints are left in
643
+ * place; the first block not covered by a proposed checkpoint starts the orphan suffix to prune.
644
+ */ async pruneOrphanProposedBlocks() {
645
+ // Orphan pruning is a pipelining-only liveness mechanism: it cleans up block-only proposals
646
+ // whose enclosing checkpoint never arrived over gossip. The test-only automine sequencer is
647
+ // non-pipelined — it publishes each checkpoint synchronously in the slot it builds — so it
648
+ // never produces orphan proposed blocks. Running the prune there would race its two-step local
649
+ // push (addBlock then addProposedCheckpoint) and delete the block before its checkpoint attaches.
650
+ if (!this.config.enableOrphanProposedBlockPruning) {
651
+ return;
652
+ }
653
+ const tips = await this.getL2Tips();
654
+ const now = BigInt(this.dateProvider.nowInSeconds());
655
+ const pipeliningOffset = PROPOSER_PIPELINING_SLOT_OFFSET;
656
+ // The proposed tip is a proposed-checkpointed block, so there are no orphan proposed blocks to prune
657
+ if (tips.proposedCheckpoint.block.number === tips.proposed.number) {
658
+ this.log.trace(`No orphan proposed blocks to prune: proposed tip ${tips.proposed.number} is checkpointed`, pick(tips, 'proposed', 'proposedCheckpoint'));
659
+ return;
660
+ }
661
+ // Load the blocks that are candidates for pruning (ie blocks without a proposed checkpoint covering them)
662
+ const blocksWithoutProposedCheckpoint = await this.stores.blocks.getBlocksData({
663
+ from: BlockNumber(tips.proposedCheckpoint.block.number + 1),
664
+ limit: tips.proposed.number - tips.proposedCheckpoint.block.number
665
+ });
666
+ // Iterate through them in order, the first one with a slot that should have received a proposed checkpoint
667
+ // is the first orphan block, and all blocks after it are also orphaned and should be pruned.
668
+ let lastSlotChecked = undefined;
669
+ for (const blockData of blocksWithoutProposedCheckpoint){
670
+ // No need to recheck if this block had the same slot as the previous one.
671
+ const blockSlot = blockData.header.getSlot();
672
+ const blockNumber = blockData.header.getBlockNumber();
673
+ if (lastSlotChecked !== undefined && blockSlot === lastSlotChecked) {
674
+ continue;
675
+ }
676
+ lastSlotChecked = blockSlot;
677
+ // The proposed checkpoint should have landed by the start of the slot after the block's build slot
678
+ // (build slot = blockSlot - pipeliningOffset). Wait a grace period beyond that to tolerate propagation.
679
+ const expectedCheckpointedBySlot = SlotNumber(Number(blockSlot) - pipeliningOffset + 1);
680
+ const expectedCheckpointedByTime = getTimestampForSlot(expectedCheckpointedBySlot, this.l1Constants) + BigInt(this.config.orphanProposedBlockPruneGraceSeconds);
681
+ // If it's not checkpointed by the expected time, prune it along with all blocks after it.
682
+ if (now >= expectedCheckpointedByTime) {
683
+ const pruneAfterBlockNumber = BlockNumber(blockNumber - 1);
684
+ this.log.warn(`Pruning orphan blocks after block ${pruneAfterBlockNumber}: block at slot ${blockSlot} belongs to ` + `checkpoint ${blockData.checkpointNumber} which has no matching proposed checkpoint`, {
685
+ firstUncheckpointedBlockHeader: blockData.header.toInspect(),
686
+ blockCheckpointNumber: blockData.checkpointNumber,
687
+ blockNumber,
688
+ blockSlot,
689
+ pipeliningOffset,
690
+ expectedCheckpointedBySlot,
691
+ expectedCheckpointedByTime,
692
+ now
693
+ });
694
+ const prunedBlocks = await this.updater.removeBlocksWithoutProposedCheckpointAfter(pruneAfterBlockNumber);
695
+ if (prunedBlocks.length > 0) {
696
+ this.events.emit(L2BlockSourceEvents.L2PruneUncheckpointed, {
697
+ type: L2BlockSourceEvents.L2PruneUncheckpointed,
698
+ slotNumber: blockSlot,
699
+ blocks: prunedBlocks
700
+ });
701
+ }
702
+ return;
703
+ }
704
+ }
705
+ this.log.trace('No orphan proposed blocks to prune: all uncheckpointed blocks are still within the grace period', {
706
+ blocksWithoutProposedCheckpoint: blocksWithoutProposedCheckpoint.map((b)=>b.header.toInspect())
707
+ });
568
708
  }
569
709
  async syncFromL1() {
570
710
  // Delegate to the L1 synchronizer
@@ -576,7 +716,7 @@ _dec = trackSpan('Archiver.sync');
576
716
  if (currentL1BlockNumber + 1n >= l1BlockNumberAtEnd) {
577
717
  this.log.info(`Initial archiver sync to L1 block ${currentL1BlockNumber} complete`, {
578
718
  l1BlockNumber: currentL1BlockNumber,
579
- syncPoint: await this.store.getSynchPoint(),
719
+ syncPoint: await getArchiverSynchPoint(this.stores),
580
720
  ...await this.getL2Tips()
581
721
  });
582
722
  this.runningPromise.setPollingIntervalMS(this.config.pollingIntervalMs);
@@ -602,7 +742,7 @@ _dec = trackSpan('Archiver.sync');
602
742
  return Promise.resolve();
603
743
  }
604
744
  backupTo(destPath) {
605
- return this.dataStore.backupTo(destPath);
745
+ return backupArchiverDataStores(this.dataStores, destPath);
606
746
  }
607
747
  getL1Constants() {
608
748
  return Promise.resolve(this.l1Constants);
@@ -637,9 +777,9 @@ _dec = trackSpan('Archiver.sync');
637
777
  }
638
778
  }
639
779
  let slotFromCheckpoint;
640
- const latestCheckpointNumber = await this.store.getSynchedCheckpointNumber();
780
+ const latestCheckpointNumber = await this.stores.blocks.getLatestCheckpointNumber();
641
781
  if (latestCheckpointNumber > 0) {
642
- const checkpointData = await this.store.getCheckpointData(latestCheckpointNumber);
782
+ const checkpointData = await this.stores.blocks.getCheckpointData(latestCheckpointNumber);
643
783
  if (checkpointData) {
644
784
  slotFromCheckpoint = checkpointData.header.slotNumber;
645
785
  }
@@ -668,8 +808,9 @@ _dec = trackSpan('Archiver.sync');
668
808
  // The epoch is complete if the current checkpointed L2 block is the last one in the epoch (or later).
669
809
  // We use the checkpointed block number (synced from L1) instead of 'latest' to avoid returning true
670
810
  // prematurely when proposed blocks have been pushed to the archiver but not yet checkpointed on L1.
671
- const checkpointedBlockNumber = await this.getCheckpointedL2BlockNumber();
672
- const header = checkpointedBlockNumber > 0 ? await this.getBlockHeader(checkpointedBlockNumber) : undefined;
811
+ const header = (await this.getBlockData({
812
+ tag: 'checkpointed'
813
+ }))?.header;
673
814
  const slot = header ? header.globalVariables.slotNumber : undefined;
674
815
  const [_startSlot, endSlot] = getSlotRangeForEpoch(epochNumber, this.l1Constants);
675
816
  if (slot && slot >= endSlot) {
@@ -711,21 +852,28 @@ _dec = trackSpan('Archiver.sync');
711
852
  if (targetL2BlockNumber >= currentL2Block) {
712
853
  throw new Error(`Target L2 block ${targetL2BlockNumber} must be less than current L2 block ${currentL2Block}`);
713
854
  }
714
- const targetL2Block = await this.store.getCheckpointedBlock(targetL2BlockNumber);
715
- if (!targetL2Block) {
855
+ const checkpointedTip = await this.stores.blocks.getCheckpointedL2BlockNumber();
856
+ if (targetL2BlockNumber > checkpointedTip) {
857
+ throw new Error(`Target L2 block ${targetL2BlockNumber} is not checkpointed yet`);
858
+ }
859
+ const targetBlockData = await this.stores.blocks.getBlockData({
860
+ number: targetL2BlockNumber
861
+ });
862
+ if (!targetBlockData) {
716
863
  throw new Error(`Target L2 block ${targetL2BlockNumber} not found`);
717
864
  }
718
- const targetCheckpointNumber = targetL2Block.checkpointNumber;
865
+ const targetCheckpointNumber = targetBlockData.checkpointNumber;
719
866
  // Rollback operates at checkpoint granularity: the target block must be the last block of its checkpoint.
720
- const checkpointData = await this.store.getCheckpointData(targetCheckpointNumber);
721
- if (checkpointData) {
722
- const lastBlockInCheckpoint = BlockNumber(checkpointData.startBlock + checkpointData.blockCount - 1);
723
- if (targetL2BlockNumber !== lastBlockInCheckpoint) {
724
- const previousCheckpointBoundary = checkpointData.startBlock > 1 ? BlockNumber(checkpointData.startBlock - 1) : BlockNumber(0);
725
- 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.`);
726
- }
867
+ const checkpointData = await this.stores.blocks.getCheckpointData(targetCheckpointNumber);
868
+ if (!checkpointData) {
869
+ throw new Error(`Checkpoint ${targetCheckpointNumber} not found for block ${targetL2BlockNumber}`);
870
+ }
871
+ const lastBlockInCheckpoint = BlockNumber(checkpointData.startBlock + checkpointData.blockCount - 1);
872
+ if (targetL2BlockNumber !== lastBlockInCheckpoint) {
873
+ const previousCheckpointBoundary = checkpointData.startBlock > 1 ? BlockNumber(checkpointData.startBlock - 1) : BlockNumber(0);
874
+ 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.`);
727
875
  }
728
- const targetL1BlockNumber = targetL2Block.l1.blockNumber;
876
+ const targetL1BlockNumber = checkpointData.l1.blockNumber;
729
877
  const targetL1Block = await this.publicClient.getBlock({
730
878
  blockNumber: targetL1BlockNumber,
731
879
  includeTransactions: false
@@ -737,10 +885,10 @@ _dec = trackSpan('Archiver.sync');
737
885
  this.log.info(`Removing checkpoints after checkpoint ${targetCheckpointNumber} (target block ${targetL2BlockNumber})`);
738
886
  await this.updater.removeCheckpointsAfter(targetCheckpointNumber);
739
887
  this.log.info(`Rolling back L1 to L2 messages to checkpoint ${targetCheckpointNumber}`);
740
- await this.store.rollbackL1ToL2MessagesToCheckpoint(targetCheckpointNumber);
888
+ await this.stores.messages.rollbackL1ToL2MessagesToCheckpoint(targetCheckpointNumber);
741
889
  this.log.info(`Setting L1 syncpoints to ${targetL1BlockNumber}`);
742
- await this.store.setCheckpointSynchedL1BlockNumber(targetL1BlockNumber);
743
- await this.store.setMessageSyncState({
890
+ await this.stores.blocks.setSynchedL1BlockNumber(targetL1BlockNumber);
891
+ await this.stores.messages.setMessageSyncState({
744
892
  l1BlockNumber: targetL1BlockNumber,
745
893
  l1BlockHash: targetL1BlockHash
746
894
  }, undefined);
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, type PipelineConfig } from '@aztec/stdlib/config';
5
+ import { type ChainConfig } 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 & PipelineConfig & BlobClientConfig & ChainConfig;
14
+ export type ArchiverConfig = ArchiverSpecificConfig & L1ReaderConfig & L1ContractsConfig & BlobClientConfig & ChainConfig;
15
15
  export declare const archiverConfigMappings: ConfigMappingsType<ArchiverConfig>;
16
16
  /**
17
17
  * Returns the archiver configuration from the environment variables.
@@ -28,5 +28,6 @@ export declare function mapArchiverConfig(config: Partial<ArchiverConfig>): {
28
28
  maxAllowedEthClientDriftSeconds: number | undefined;
29
29
  ethereumAllowNoDebugHosts: boolean | undefined;
30
30
  skipHistoricalLogsCheck: boolean | undefined;
31
+ orphanProposedBlockPruneGraceSeconds: number | undefined;
31
32
  };
32
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cm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c,CAAC;;;;;;;;;EAWhE"}
package/dest/config.js CHANGED
@@ -1,12 +1,10 @@
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, pipelineConfigMappings } from '@aztec/stdlib/config';
4
+ import { booleanConfigHelper, getConfigFromMappings, numberConfigHelper, optionalNumberConfigHelper } from '@aztec/foundation/config';
5
+ import { chainConfigMappings } from '@aztec/stdlib/config';
7
6
  export const archiverConfigMappings = {
8
7
  ...blobClientConfigMapping,
9
- ...pipelineConfigMappings,
10
8
  archiverPollingIntervalMS: {
11
9
  env: 'ARCHIVER_POLLING_INTERVAL_MS',
12
10
  description: 'The polling interval in ms for retrieving new L2 blocks and encrypted logs.',
@@ -17,14 +15,9 @@ export const archiverConfigMappings = {
17
15
  description: 'The number of L2 blocks the archiver will attempt to download at a time.',
18
16
  ...numberConfigHelper(100)
19
17
  },
20
- maxLogs: {
21
- env: 'ARCHIVER_MAX_LOGS',
22
- description: 'The max number of logs that can be obtained in 1 "getPublicLogs" call.',
23
- ...numberConfigHelper(1_000)
24
- },
25
18
  archiverStoreMapSizeKb: {
26
19
  env: 'ARCHIVER_STORE_MAP_SIZE_KB',
27
- parseEnv: (val)=>+val,
20
+ ...optionalNumberConfigHelper(),
28
21
  description: 'The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKb.'
29
22
  },
30
23
  skipValidateCheckpointAttestations: {
@@ -50,6 +43,11 @@ export const archiverConfigMappings = {
50
43
  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.',
51
44
  ...booleanConfigHelper(false)
52
45
  },
46
+ orphanProposedBlockPruneGraceSeconds: {
47
+ env: 'ARCHIVER_ORPHAN_PROPOSED_BLOCK_PRUNE_GRACE_SECONDS',
48
+ 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.',
49
+ ...optionalNumberConfigHelper()
50
+ },
53
51
  ...chainConfigMappings,
54
52
  ...l1ReaderConfigMappings,
55
53
  viemPollingIntervalMS: {
@@ -57,11 +55,7 @@ export const archiverConfigMappings = {
57
55
  description: 'The polling interval viem uses in ms',
58
56
  ...numberConfigHelper(1000)
59
57
  },
60
- ...l1ContractsConfigMappings,
61
- l1Contracts: {
62
- description: 'The deployed L1 contract addresses',
63
- nested: l1ContractAddressesMapping
64
- }
58
+ ...l1ContractsConfigMappings
65
59
  };
66
60
  /**
67
61
  * Returns the archiver configuration from the environment variables.
@@ -78,6 +72,7 @@ export const archiverConfigMappings = {
78
72
  skipPromoteProposedCheckpointDuringL1Sync: config.skipPromoteProposedCheckpointDuringL1Sync,
79
73
  maxAllowedEthClientDriftSeconds: config.maxAllowedEthClientDriftSeconds,
80
74
  ethereumAllowNoDebugHosts: config.ethereumAllowNoDebugHosts,
81
- skipHistoricalLogsCheck: config.archiverSkipHistoricalLogsCheck
75
+ skipHistoricalLogsCheck: config.archiverSkipHistoricalLogsCheck,
76
+ orphanProposedBlockPruneGraceSeconds: config.orphanProposedBlockPruneGraceSeconds
82
77
  };
83
78
  }
package/dest/errors.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
1
2
  import type { Fr } from '@aztec/foundation/schemas';
2
3
  export declare class NoBlobBodiesFoundError extends Error {
3
4
  constructor(l2BlockNum: number);
@@ -11,7 +12,13 @@ export declare class InitialCheckpointNumberNotSequentialError extends Error {
11
12
  constructor(newCheckpointNumber: number, previousCheckpointNumber: number | undefined);
12
13
  }
13
14
  export declare class CheckpointNumberNotSequentialError extends Error {
14
- constructor(newCheckpointNumber: number, previous: number | undefined, source?: 'confirmed' | 'proposed');
15
+ readonly newCheckpointNumber: CheckpointNumber;
16
+ readonly previousCheckpointNumber: CheckpointNumber | undefined;
17
+ constructor(newCheckpointNumber: CheckpointNumber, previousCheckpointNumber: CheckpointNumber | undefined, source?: 'proposed' | 'confirmed');
18
+ }
19
+ /** Thrown when a proposed block carries a checkpoint number that does not follow the latest one. */
20
+ export declare class BlockCheckpointNumberNotSequentialError extends Error {
21
+ constructor(blockNumber: BlockNumber, blockCheckpointNumber: CheckpointNumber, previous: CheckpointNumber | undefined);
15
22
  }
16
23
  export declare class BlockIndexNotSequentialError extends Error {
17
24
  constructor(newBlockIndex: number, previousBlockIndex: number | undefined);
@@ -30,14 +37,6 @@ export declare class BlockAlreadyCheckpointedError extends Error {
30
37
  readonly blockNumber: number;
31
38
  constructor(blockNumber: number);
32
39
  }
33
- /** Thrown when logs are added for a tag whose last stored log has a higher block number than the new log. */
34
- export declare class OutOfOrderLogInsertionError extends Error {
35
- readonly logType: 'private' | 'public';
36
- readonly tag: string;
37
- readonly lastBlockNumber: number;
38
- readonly newBlockNumber: number;
39
- constructor(logType: 'private' | 'public', tag: string, lastBlockNumber: number, newBlockNumber: number);
40
- }
41
40
  /** Thrown when L1 to L2 messages are requested for a checkpoint whose message tree hasn't been sealed yet. */
42
41
  export declare class L1ToL2MessagesNotReadyError extends Error {
43
42
  readonly checkpointNumber: number;
@@ -50,11 +49,18 @@ export declare class ProposedCheckpointStaleError extends Error {
50
49
  readonly currentProposedNumber: number;
51
50
  constructor(proposedCheckpointNumber: number, currentProposedNumber: number);
52
51
  }
53
- /** Thrown when a proposed checkpoint number is not the expected confirmed + 1. */
52
+ /** Thrown when a proposed checkpoint number is not the expected latestTip + 1. */
54
53
  export declare class ProposedCheckpointNotSequentialError extends Error {
55
54
  readonly proposedCheckpointNumber: number;
56
- readonly confirmedCheckpointNumber: number;
57
- constructor(proposedCheckpointNumber: number, confirmedCheckpointNumber: number);
55
+ readonly latestTipNumber: number;
56
+ constructor(proposedCheckpointNumber: number, latestTipNumber: number);
57
+ }
58
+ /** Thrown when a proposed checkpoint or block L2 slot has already expired on L1. */
59
+ export declare class BlockOrCheckpointSlotExpiredError extends Error {
60
+ readonly slot: number;
61
+ readonly nextSlotStart: bigint;
62
+ readonly l1TimestampSynced: bigint | undefined;
63
+ constructor(slot: number, nextSlotStart: bigint, l1TimestampSynced: bigint | undefined);
58
64
  }
59
65
  /** Thrown when attempting to promote a proposed checkpoint but no proposed checkpoint exists in the store. */
60
66
  export declare class NoProposedCheckpointToPromoteError extends Error {
@@ -78,4 +84,4 @@ export declare class CannotOverwriteCheckpointedBlockError extends Error {
78
84
  readonly lastCheckpointedBlock: number;
79
85
  constructor(blockNumber: number, lastCheckpointedBlock: number);
80
86
  }
81
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3JzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvZXJyb3JzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRXBELHFCQUFhLHNCQUF1QixTQUFRLEtBQUs7SUFDL0MsWUFBWSxVQUFVLEVBQUUsTUFBTSxFQUU3QjtDQUNGO0FBRUQscUJBQWEsNkJBQThCLFNBQVEsS0FBSztJQUN0RCxZQUFZLGNBQWMsRUFBRSxNQUFNLEVBQUUsUUFBUSxFQUFFLE1BQU0sR0FBRyxTQUFTLEVBRS9EO0NBQ0Y7QUFFRCxxQkFBYSx5Q0FBMEMsU0FBUSxLQUFLO2FBRWhELG1CQUFtQixFQUFFLE1BQU07YUFDM0Isd0JBQXdCLEVBQUUsTUFBTSxHQUFHLFNBQVM7SUFGOUQsWUFDa0IsbUJBQW1CLEVBQUUsTUFBTSxFQUMzQix3Q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