@aztec/sequencer-client 0.0.1-commit.e558bd1c → 0.0.1-commit.e57c76e

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 (125) hide show
  1. package/README.md +281 -21
  2. package/dest/client/sequencer-client.d.ts +19 -9
  3. package/dest/client/sequencer-client.d.ts.map +1 -1
  4. package/dest/client/sequencer-client.js +65 -32
  5. package/dest/config.d.ts +28 -6
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +76 -37
  8. package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
  9. package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
  10. package/dest/global_variable_builder/fee_predictor.js +128 -0
  11. package/dest/global_variable_builder/fee_provider.d.ts +21 -0
  12. package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
  13. package/dest/global_variable_builder/fee_provider.js +58 -0
  14. package/dest/global_variable_builder/global_builder.d.ts +14 -16
  15. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  16. package/dest/global_variable_builder/global_builder.js +16 -50
  17. package/dest/global_variable_builder/index.d.ts +4 -2
  18. package/dest/global_variable_builder/index.d.ts.map +1 -1
  19. package/dest/global_variable_builder/index.js +2 -0
  20. package/dest/index.d.ts +2 -2
  21. package/dest/index.d.ts.map +1 -1
  22. package/dest/index.js +1 -1
  23. package/dest/publisher/config.d.ts +47 -17
  24. package/dest/publisher/config.d.ts.map +1 -1
  25. package/dest/publisher/config.js +121 -42
  26. package/dest/publisher/index.d.ts +2 -1
  27. package/dest/publisher/index.d.ts.map +1 -1
  28. package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
  29. package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
  30. package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
  31. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +58 -0
  32. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
  33. package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
  34. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
  35. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
  36. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
  37. package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
  38. package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
  39. package/dest/publisher/l1_tx_failed_store/index.js +2 -0
  40. package/dest/publisher/sequencer-bundle-simulator.d.ts +96 -0
  41. package/dest/publisher/sequencer-bundle-simulator.d.ts.map +1 -0
  42. package/dest/publisher/sequencer-bundle-simulator.js +198 -0
  43. package/dest/publisher/sequencer-publisher-factory.d.ts +11 -5
  44. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  45. package/dest/publisher/sequencer-publisher-factory.js +27 -3
  46. package/dest/publisher/sequencer-publisher.d.ts +94 -67
  47. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  48. package/dest/publisher/sequencer-publisher.js +439 -378
  49. package/dest/sequencer/automine/automine_factory.d.ts +54 -0
  50. package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
  51. package/dest/sequencer/automine/automine_factory.js +84 -0
  52. package/dest/sequencer/automine/automine_sequencer.d.ts +151 -0
  53. package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
  54. package/dest/sequencer/automine/automine_sequencer.js +509 -0
  55. package/dest/sequencer/chain_state_overrides.d.ts +61 -0
  56. package/dest/sequencer/chain_state_overrides.d.ts.map +1 -0
  57. package/dest/sequencer/chain_state_overrides.js +98 -0
  58. package/dest/sequencer/checkpoint_proposal_job.d.ts +60 -12
  59. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  60. package/dest/sequencer/checkpoint_proposal_job.js +830 -229
  61. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
  62. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
  63. package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
  64. package/dest/sequencer/checkpoint_voter.d.ts +1 -2
  65. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
  66. package/dest/sequencer/checkpoint_voter.js +2 -5
  67. package/dest/sequencer/events.d.ts +48 -2
  68. package/dest/sequencer/events.d.ts.map +1 -1
  69. package/dest/sequencer/index.d.ts +3 -1
  70. package/dest/sequencer/index.d.ts.map +1 -1
  71. package/dest/sequencer/index.js +2 -0
  72. package/dest/sequencer/metrics.d.ts +23 -8
  73. package/dest/sequencer/metrics.d.ts.map +1 -1
  74. package/dest/sequencer/metrics.js +117 -21
  75. package/dest/sequencer/sequencer.d.ts +83 -22
  76. package/dest/sequencer/sequencer.d.ts.map +1 -1
  77. package/dest/sequencer/sequencer.js +378 -139
  78. package/dest/sequencer/timetable.d.ts +14 -6
  79. package/dest/sequencer/timetable.d.ts.map +1 -1
  80. package/dest/sequencer/timetable.js +47 -46
  81. package/dest/sequencer/types.d.ts +2 -2
  82. package/dest/sequencer/types.d.ts.map +1 -1
  83. package/dest/test/index.d.ts +3 -5
  84. package/dest/test/index.d.ts.map +1 -1
  85. package/dest/test/mock_checkpoint_builder.d.ts +11 -11
  86. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  87. package/dest/test/mock_checkpoint_builder.js +45 -34
  88. package/dest/test/utils.d.ts +3 -3
  89. package/dest/test/utils.d.ts.map +1 -1
  90. package/dest/test/utils.js +10 -8
  91. package/package.json +27 -28
  92. package/src/client/sequencer-client.ts +91 -35
  93. package/src/config.ts +98 -46
  94. package/src/global_variable_builder/README.md +44 -0
  95. package/src/global_variable_builder/fee_predictor.ts +172 -0
  96. package/src/global_variable_builder/fee_provider.ts +75 -0
  97. package/src/global_variable_builder/global_builder.ts +26 -63
  98. package/src/global_variable_builder/index.ts +3 -1
  99. package/src/index.ts +10 -1
  100. package/src/publisher/config.ts +157 -45
  101. package/src/publisher/index.ts +3 -0
  102. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  103. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +57 -0
  104. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
  105. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  106. package/src/publisher/sequencer-bundle-simulator.ts +254 -0
  107. package/src/publisher/sequencer-publisher-factory.ts +38 -9
  108. package/src/publisher/sequencer-publisher.ts +532 -469
  109. package/src/sequencer/README.md +162 -450
  110. package/src/sequencer/automine/README.md +46 -0
  111. package/src/sequencer/automine/automine_factory.ts +145 -0
  112. package/src/sequencer/automine/automine_sequencer.ts +595 -0
  113. package/src/sequencer/chain_state_overrides.ts +162 -0
  114. package/src/sequencer/checkpoint_proposal_job.ts +1003 -248
  115. package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
  116. package/src/sequencer/checkpoint_voter.ts +1 -12
  117. package/src/sequencer/events.ts +51 -2
  118. package/src/sequencer/index.ts +2 -0
  119. package/src/sequencer/metrics.ts +132 -25
  120. package/src/sequencer/sequencer.ts +466 -158
  121. package/src/sequencer/timetable.ts +62 -56
  122. package/src/sequencer/types.ts +1 -1
  123. package/src/test/index.ts +2 -4
  124. package/src/test/mock_checkpoint_builder.ts +63 -49
  125. package/src/test/utils.ts +31 -10
@@ -370,41 +370,52 @@ function applyDecs2203RFactory() {
370
370
  function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
371
371
  return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
372
372
  }
373
- var _dec, _dec1, _dec2, _initProto;
373
+ var _dec, _dec1, _initProto;
374
374
  import { Blob, getBlobsPerL1Block, getPrefixedEthBlobCommitments } from '@aztec/blob-lib';
375
- import { MULTI_CALL_3_ADDRESS, Multicall3, RollupContract } from '@aztec/ethereum/contracts';
375
+ import { FeeAssetPriceOracle, MULTI_CALL_3_ADDRESS, Multicall3, MulticallForwarderRevertedError, buildSimulationOverridesStateOverride } from '@aztec/ethereum/contracts';
376
376
  import { L1FeeAnalyzer } from '@aztec/ethereum/l1-fee-analysis';
377
377
  import { MAX_L1_TX_LIMIT, WEI_CONST } from '@aztec/ethereum/l1-tx-utils';
378
- import { FormattedViemError, formatViemError, mergeAbis, tryExtractEvent } from '@aztec/ethereum/utils';
379
- import { sumBigint } from '@aztec/foundation/bigint';
380
- import { toHex as toPaddedHex } from '@aztec/foundation/bigint-buffer';
378
+ import { FormattedViemError, formatViemError, mergeAbis, tryDecodeRevertReason, tryExtractEvent } from '@aztec/ethereum/utils';
381
379
  import { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
380
+ import { trimmedBytesLength } from '@aztec/foundation/buffer';
382
381
  import { pick } from '@aztec/foundation/collection';
382
+ import { TimeoutError } from '@aztec/foundation/error';
383
383
  import { EthAddress } from '@aztec/foundation/eth-address';
384
384
  import { Signature } from '@aztec/foundation/eth-signature';
385
385
  import { createLogger } from '@aztec/foundation/log';
386
+ import { InterruptibleSleep } from '@aztec/foundation/sleep';
386
387
  import { bufferToHex } from '@aztec/foundation/string';
387
388
  import { Timer } from '@aztec/foundation/timer';
388
- import { EmpireBaseAbi, ErrorsAbi, RollupAbi } from '@aztec/l1-artifacts';
389
+ import { EmpireBaseAbi, ErrorsAbi, RollupAbi, SlashingProposerAbi } from '@aztec/l1-artifacts';
389
390
  import { encodeSlashConsensusVotes } from '@aztec/slasher';
390
391
  import { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
392
+ import { getLastL1SlotTimestampForL2Slot, getNextL1SlotTimestamp, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
391
393
  import { getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
392
- import { encodeFunctionData, toHex } from 'viem';
394
+ import { encodeFunctionData, keccak256, toHex } from 'viem';
395
+ import { createL1TxFailedStore } from './l1_tx_failed_store/index.js';
396
+ import { SequencerBundleSimulator } from './sequencer-bundle-simulator.js';
393
397
  import { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
398
+ /**
399
+ * Returns true if the receipt indicates a successful send AND the expected event was emitted
400
+ * by the target contract. Both pieces are required: an aggregate3 entry that reverted will
401
+ * have receipt.status === 'success' but no event log.
402
+ */ function extractEventSuccess(receipt, opts) {
403
+ if (!receipt || receipt.status !== 'success') {
404
+ return false;
405
+ }
406
+ return !!tryExtractEvent(receipt.logs, opts.address.toString(), opts.abi, opts.eventName);
407
+ }
394
408
  export const Actions = [
395
409
  'invalidate-by-invalid-attestation',
396
410
  'invalidate-by-insufficient-attestations',
397
411
  'propose',
398
412
  'governance-signal',
399
- 'empire-slashing-signal',
400
- 'create-empire-payload',
401
- 'execute-empire-payload',
402
413
  'vote-offenses',
403
414
  'execute-slash'
404
415
  ];
405
416
  // Sorting for actions such that invalidations go before proposals, and proposals go before votes
406
417
  export const compareActions = (a, b)=>Actions.indexOf(a) - Actions.indexOf(b);
407
- _dec = trackSpan('SequencerPublisher.sendRequests'), _dec1 = trackSpan('SequencerPublisher.validateBlockHeader'), _dec2 = trackSpan('SequencerPublisher.validateCheckpointForSubmission');
418
+ _dec = trackSpan('SequencerPublisher.sendRequests'), _dec1 = trackSpan('SequencerPublisher.validateBlockHeader');
408
419
  export class SequencerPublisher {
409
420
  config;
410
421
  static{
@@ -418,54 +429,60 @@ export class SequencerPublisher {
418
429
  _dec1,
419
430
  2,
420
431
  "validateBlockHeader"
421
- ],
422
- [
423
- _dec2,
424
- 2,
425
- "validateCheckpointForSubmission"
426
432
  ]
427
433
  ], []));
428
434
  }
429
435
  interrupted;
430
436
  metrics;
437
+ bundleSimulator;
431
438
  epochCache;
432
- governanceLog;
433
- slashingLog;
439
+ failedTxStore;
440
+ /**
441
+ * ABI used to decode raw revert payloads from dropped bundle entries when the original
442
+ * request did not carry an abi (e.g. the propose request). Merges every contract the
443
+ * publisher can route to so any of their custom errors decode against it.
444
+ */ revertDecoderAbi;
434
445
  lastActions;
435
- isPayloadEmptyCache;
436
446
  log;
437
447
  ethereumSlotDuration;
448
+ aztecSlotDuration;
449
+ /** Date provider for wall-clock time. */ dateProvider;
438
450
  blobClient;
439
- /** Address to use for simulations in fisherman mode (actual proposer's address) */ proposerAddressForSimulation;
451
+ /** Optional callback to obtain a replacement publisher when the current one fails to send. */ getNextPublisher;
440
452
  /** L1 fee analyzer for fisherman mode */ l1FeeAnalyzer;
441
- // A CALL to a cold address is 2700 gas
442
- static MULTICALL_OVERHEAD_GAS_GUESS = 5000n;
443
- // Gas report for VotingWithSigTest shows a max gas of 100k, but we've seen it cost 700k+ in testnet
444
- static VOTE_GAS_GUESS = 800_000n;
453
+ /** Fee asset price oracle for computing price modifiers from Uniswap V4 */ feeAssetPriceOracle;
454
+ /** Interruptible sleep used by sendRequestsAt to wait until a target timestamp. */ interruptibleSleep;
445
455
  l1TxUtils;
446
456
  rollupContract;
447
457
  govProposerContract;
448
458
  slashingProposerContract;
449
- slashFactoryContract;
450
459
  tracer;
451
460
  requests;
452
461
  constructor(config, deps){
453
462
  this.config = config;
454
463
  this.interrupted = (_initProto(this), false);
455
- this.governanceLog = createLogger('sequencer:publisher:governance');
456
- this.slashingLog = createLogger('sequencer:publisher:slashing');
464
+ this.revertDecoderAbi = mergeAbis([
465
+ RollupAbi,
466
+ SlashingProposerAbi,
467
+ EmpireBaseAbi,
468
+ ErrorsAbi
469
+ ]);
457
470
  this.lastActions = {};
458
- this.isPayloadEmptyCache = new Map();
471
+ this.interruptibleSleep = new InterruptibleSleep();
459
472
  this.requests = [];
460
473
  this.log = deps.log ?? createLogger('sequencer:publisher');
461
474
  this.ethereumSlotDuration = BigInt(config.ethereumSlotDuration);
475
+ this.aztecSlotDuration = BigInt(config.aztecSlotDuration);
476
+ this.dateProvider = deps.dateProvider;
462
477
  this.epochCache = deps.epochCache;
463
478
  this.lastActions = deps.lastActions;
464
479
  this.blobClient = deps.blobClient;
480
+ this.dateProvider = deps.dateProvider;
465
481
  const telemetry = deps.telemetry ?? getTelemetryClient();
466
482
  this.metrics = deps.metrics ?? new SequencerPublisherMetrics(telemetry, 'SequencerPublisher');
467
483
  this.tracer = telemetry.getTracer('SequencerPublisher');
468
484
  this.l1TxUtils = deps.l1TxUtils;
485
+ this.getNextPublisher = deps.getNextPublisher;
469
486
  this.rollupContract = deps.rollupContract;
470
487
  this.govProposerContract = deps.governanceProposerContract;
471
488
  this.slashingProposerContract = deps.slashingProposerContract;
@@ -474,15 +491,50 @@ export class SequencerPublisher {
474
491
  const newSlashingProposer = await this.rollupContract.getSlashingProposer();
475
492
  this.slashingProposerContract = newSlashingProposer;
476
493
  });
477
- this.slashFactoryContract = deps.slashFactoryContract;
478
494
  // Initialize L1 fee analyzer for fisherman mode
479
495
  if (config.fishermanMode) {
480
- this.l1FeeAnalyzer = new L1FeeAnalyzer(this.l1TxUtils.client, deps.dateProvider, createLogger('sequencer:publisher:fee-analyzer'));
496
+ this.l1FeeAnalyzer = new L1FeeAnalyzer(this.l1TxUtils.client, deps.dateProvider, this.log.createChild('fee-analyzer'));
481
497
  }
498
+ // Initialize fee asset price oracle
499
+ this.feeAssetPriceOracle = new FeeAssetPriceOracle(this.l1TxUtils.client, this.rollupContract, this.log.createChild('price-oracle'));
500
+ // Initialize failed L1 tx store (optional, for test networks)
501
+ this.failedTxStore = createL1TxFailedStore(config.l1TxFailedStore, this.log);
502
+ this.bundleSimulator = new SequencerBundleSimulator({
503
+ getL1TxUtils: ()=>this.l1TxUtils,
504
+ rollupContract: this.rollupContract,
505
+ epochCache: this.epochCache,
506
+ log: this.log.createChild('bundle-simulator')
507
+ });
508
+ }
509
+ /**
510
+ * Backs up a failed L1 transaction to the configured store for debugging.
511
+ * Does nothing if no store is configured.
512
+ */ backupFailedTx(failedTx) {
513
+ if (!this.failedTxStore) {
514
+ return;
515
+ }
516
+ const tx = {
517
+ ...failedTx,
518
+ timestamp: Date.now()
519
+ };
520
+ // Fire and forget - don't block on backup
521
+ void this.failedTxStore.then((store)=>store?.saveFailedTx(tx)).catch((err)=>{
522
+ this.log.warn(`Failed to backup failed L1 tx to store`, err);
523
+ });
482
524
  }
483
525
  getRollupContract() {
484
526
  return this.rollupContract;
485
527
  }
528
+ /**
529
+ * Gets the fee asset price modifier from the oracle.
530
+ *
531
+ * @param predictedParentEthPerFeeAssetE12 - Optional predicted parent eth-per-fee-asset (E12).
532
+ * Pipelined proposers should pass the value from the predicted parent fee header so the
533
+ * modifier matches the parent L1 will use when applying it.
534
+ * @returns The fee asset price modifier in basis points, or 0n if the oracle query fails.
535
+ */ getFeeAssetPriceModifier(predictedParentEthPerFeeAssetE12) {
536
+ return this.feeAssetPriceOracle.computePriceModifier(predictedParentEthPerFeeAssetE12);
537
+ }
486
538
  getSenderAddress() {
487
539
  return this.l1TxUtils.getSenderAddress();
488
540
  }
@@ -491,17 +543,11 @@ export class SequencerPublisher {
491
543
  */ getL1FeeAnalyzer() {
492
544
  return this.l1FeeAnalyzer;
493
545
  }
494
- /**
495
- * Sets the proposer address to use for simulations in fisherman mode.
496
- * @param proposerAddress - The actual proposer's address to use for balance lookups in simulations
497
- */ setProposerAddressForSimulation(proposerAddress) {
498
- this.proposerAddressForSimulation = proposerAddress;
499
- }
500
546
  addRequest(request) {
501
547
  this.requests.push(request);
502
548
  }
503
549
  getCurrentL2Slot() {
504
- return this.epochCache.getEpochAndSlotNow().slot;
550
+ return this.epochCache.getSlotNow();
505
551
  }
506
552
  /**
507
553
  * Clears all pending requests without sending them.
@@ -554,11 +600,15 @@ export class SequencerPublisher {
554
600
  }
555
601
  /**
556
602
  * Sends all requests that are still valid.
603
+ * @param targetSlot - The target L2 slot for this send. When provided (the production path, via
604
+ * sendRequestsAt), it is threaded into bundleSimulate so the block.timestamp override matches
605
+ * the slot the propose is built for. When omitted, falls back to getCurrentL2Slot() for the
606
+ * AutomineSequencer, which publishes synchronously within the current slot.
557
607
  * @returns one of:
558
608
  * - A receipt and stats if the tx succeeded
559
609
  * - a receipt and errorMsg if it failed on L1
560
610
  * - undefined if no valid requests are found OR the tx failed to send.
561
- */ async sendRequests() {
611
+ */ async sendRequests(targetSlot) {
562
612
  const requestsToProcess = [
563
613
  ...this.requests
564
614
  ];
@@ -566,10 +616,9 @@ export class SequencerPublisher {
566
616
  if (this.interrupted || requestsToProcess.length === 0) {
567
617
  return undefined;
568
618
  }
569
- const currentL2Slot = this.getCurrentL2Slot();
619
+ const currentL2Slot = targetSlot ?? this.getCurrentL2Slot();
570
620
  this.log.debug(`Sending requests on L2 slot ${currentL2Slot}`);
571
621
  const validRequests = requestsToProcess.filter((request)=>request.lastValidL2Slot >= currentL2Slot);
572
- const validActions = validRequests.map((x)=>x.action);
573
622
  const expiredActions = requestsToProcess.filter((request)=>request.lastValidL2Slot < currentL2Slot).map((x)=>x.action);
574
623
  if (validRequests.length !== requestsToProcess.length) {
575
624
  this.log.warn(`Some requests were expired for slot ${currentL2Slot}`, {
@@ -587,49 +636,53 @@ export class SequencerPublisher {
587
636
  this.log.debug(`No valid requests to send`);
588
637
  return undefined;
589
638
  }
590
- // @note - we can only have one blob config per bundle
591
- // find requests with gas and blob configs
592
- // See https://github.com/AztecProtocol/aztec-packages/issues/11513
593
- const gasConfigs = requestsToProcess.filter((request)=>request.gasConfig).map((request)=>request.gasConfig);
594
- const blobConfigs = requestsToProcess.filter((request)=>request.blobConfig).map((request)=>request.blobConfig);
595
- if (blobConfigs.length > 1) {
596
- throw new Error('Multiple blob configs found');
597
- }
598
- const blobConfig = blobConfigs[0];
599
- // Merge gasConfigs. Yields the sum of gasLimits, and the earliest txTimeoutAt, or undefined if no gasConfig sets them.
600
- const gasLimits = gasConfigs.map((g)=>g?.gasLimit).filter((g)=>g !== undefined);
601
- let gasLimit = gasLimits.length > 0 ? sumBigint(gasLimits) : undefined; // sum
602
- // Cap at L1 block gas limit so the node accepts the tx ("gas limit too high" otherwise).
603
- const maxGas = MAX_L1_TX_LIMIT;
604
- if (gasLimit !== undefined && gasLimit > maxGas) {
605
- this.log.debug('Capping bundled tx gas limit to L1 max', {
606
- requested: gasLimit,
607
- capped: maxGas
608
- });
609
- gasLimit = maxGas;
610
- }
639
+ // Collect earliest txTimeoutAt across all requests.
640
+ const gasConfigs = validRequests.filter((request)=>request.gasConfig).map((request)=>request.gasConfig);
611
641
  const txTimeoutAts = gasConfigs.map((g)=>g?.txTimeoutAt).filter((g)=>g !== undefined);
612
- const txTimeoutAt = txTimeoutAts.length > 0 ? new Date(Math.min(...txTimeoutAts.map((g)=>g.getTime()))) : undefined; // earliest
613
- const txConfig = {
614
- gasLimit,
615
- txTimeoutAt
616
- };
642
+ const txTimeoutAt = txTimeoutAts.length > 0 ? new Date(Math.min(...txTimeoutAts.map((g)=>g.getTime()))) : undefined;
617
643
  // Sort the requests so that proposals always go first
618
644
  // This ensures the committee gets precomputed correctly
619
645
  validRequests.sort((a, b)=>compareActions(a.action, b.action));
620
646
  try {
647
+ // Bundle-level eth_simulateV1: filters out entries that revert and derives the gasLimit.
648
+ const bundleResult = await this.bundleSimulator.simulate(validRequests, currentL2Slot);
649
+ if (bundleResult.kind === 'aborted') {
650
+ this.logDroppedInSim(bundleResult.droppedRequests);
651
+ void this.backupDroppedInSim(bundleResult.droppedRequests);
652
+ return undefined;
653
+ }
654
+ const { requests, droppedRequests, gasLimit } = bundleResult.kind === 'fallback' ? {
655
+ requests: bundleResult.requests,
656
+ droppedRequests: bundleResult.droppedRequests,
657
+ gasLimit: MAX_L1_TX_LIMIT
658
+ } : bundleResult;
659
+ this.logDroppedInSim(droppedRequests);
660
+ // Compute blobConfig from survivors (not original validRequests) so that if the propose
661
+ // entry was dropped by bundleSimulate we don't attach a blob-typed config to a non-blob tx.
662
+ const [blobConfig] = requests.filter((r)=>r.blobConfig).map((r)=>r.blobConfig);
663
+ const txConfig = {
664
+ gasLimit,
665
+ txTimeoutAt
666
+ };
621
667
  this.log.debug('Forwarding transactions', {
622
- validRequests: validRequests.map((request)=>request.action),
668
+ requests: requests.map((request)=>request.action),
623
669
  txConfig
624
670
  });
625
- const result = await Multicall3.forward(validRequests.map((request)=>request.request), this.l1TxUtils, txConfig, blobConfig, this.rollupContract.address, this.log);
626
- const { successfulActions = [], failedActions = [] } = this.callbackBundledTransactions(validRequests, result);
671
+ const result = await this.forwardWithPublisherRotation(requests, txConfig, blobConfig);
672
+ if (result === undefined) {
673
+ return undefined;
674
+ }
675
+ const { successfulActions = [], failedActions = [] } = this.callbackBundledTransactions(requests, result);
676
+ const allFailedActions = [
677
+ ...failedActions,
678
+ ...droppedRequests.map((d)=>d.request.action)
679
+ ];
627
680
  return {
628
681
  result,
629
682
  expiredActions,
630
- sentActions: validActions,
683
+ sentActions: requests.map((x)=>x.action),
631
684
  successfulActions,
632
- failedActions
685
+ failedActions: allFailedActions
633
686
  };
634
687
  } catch (err) {
635
688
  const viemError = formatViemError(err);
@@ -643,49 +696,173 @@ export class SequencerPublisher {
643
696
  }
644
697
  }
645
698
  }
646
- callbackBundledTransactions(requests, result) {
647
- const actionsListStr = requests.map((r)=>r.action).join(', ');
648
- if (result instanceof FormattedViemError) {
649
- this.log.error(`Failed to publish bundled transactions (${actionsListStr})`, result);
650
- return {
651
- failedActions: requests.map((r)=>r.action)
652
- };
653
- } else {
654
- this.log.verbose(`Published bundled transactions (${actionsListStr})`, {
655
- result,
656
- requests
699
+ /** Logs entries dropped by bundle simulation as warnings on the publisher's logger. */ logDroppedInSim(dropped) {
700
+ for (const drop of dropped){
701
+ const revertReasonDecoded = drop.revertReason ?? tryDecodeRevertReason(drop.returnData, this.revertDecoderAbi);
702
+ this.log.warn('Bundle entry dropped: action reverted in sim', {
703
+ action: drop.request.action,
704
+ revertReason: revertReasonDecoded ?? drop.returnData,
705
+ revertReasonDecoded,
706
+ returnData: drop.returnData
657
707
  });
658
- const successfulActions = [];
659
- const failedActions = [];
660
- for (const request of requests){
661
- if (request.checkSuccess(request.request, result)) {
662
- successfulActions.push(request.action);
663
- } else {
664
- failedActions.push(request.action);
708
+ }
709
+ }
710
+ /** Backs up entries dropped by bundle simulation, one record per dropped action. */ async backupDroppedInSim(dropped) {
711
+ if (dropped.length === 0) {
712
+ return;
713
+ }
714
+ const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
715
+ for (const { request: req } of dropped){
716
+ this.backupFailedTx({
717
+ id: keccak256(req.request.data),
718
+ failureType: 'simulation',
719
+ request: {
720
+ to: req.request.to,
721
+ data: req.request.data
722
+ },
723
+ l1BlockNumber: l1BlockNumber.toString(),
724
+ error: {
725
+ message: 'Bundle entry dropped: action reverted in sim'
726
+ },
727
+ context: {
728
+ actions: [
729
+ req.action
730
+ ],
731
+ sender: this.getSenderAddress().toString()
665
732
  }
733
+ });
734
+ }
735
+ }
736
+ /**
737
+ * Forwards transactions via Multicall3, rotating to the next available publisher if a send
738
+ * failure occurs (i.e. the tx never reached the chain).
739
+ * On-chain reverts and simulation errors are returned as-is without rotation.
740
+ */ async forwardWithPublisherRotation(validRequests, txConfig, blobConfig) {
741
+ if (!txConfig?.gasLimit) {
742
+ throw new Error('gasLimit is required for bundled transactions');
743
+ }
744
+ const txConfigWithGasLimit = txConfig;
745
+ const triedAddresses = [];
746
+ let currentPublisher = this.l1TxUtils;
747
+ while(true){
748
+ if (txConfig.txTimeoutAt && new Date() > txConfig.txTimeoutAt) {
749
+ this.log.warn(`Tx timeout (${txConfig.txTimeoutAt.toISOString()}) elapsed; stopping publisher rotation`, {
750
+ triedAddresses: triedAddresses.map((a)=>a.toString())
751
+ });
752
+ return undefined;
753
+ }
754
+ triedAddresses.push(currentPublisher.getSenderAddress());
755
+ try {
756
+ const result = await Multicall3.forward(validRequests.map((r)=>r.request), currentPublisher, txConfigWithGasLimit, blobConfig, {
757
+ gasLimitRequired: true
758
+ });
759
+ this.l1TxUtils = currentPublisher;
760
+ return result;
761
+ } catch (err) {
762
+ if (err instanceof TimeoutError) {
763
+ throw err;
764
+ }
765
+ if (err instanceof MulticallForwarderRevertedError) {
766
+ this.log.error('Forwarder transaction reverted on-chain; not rotating publisher', err, {
767
+ transactionHash: err.receipt.transactionHash
768
+ });
769
+ return undefined;
770
+ }
771
+ const viemError = formatViemError(err);
772
+ if (!this.getNextPublisher) {
773
+ this.log.error('Failed to publish bundled transactions', viemError);
774
+ return undefined;
775
+ }
776
+ this.log.warn(`Publisher ${currentPublisher.getSenderAddress()} failed to send, rotating to next publisher`, viemError);
777
+ const nextPublisher = await this.getNextPublisher([
778
+ ...triedAddresses
779
+ ]);
780
+ if (!nextPublisher) {
781
+ this.log.error(`All available publishers exhausted (tried ${triedAddresses.length}), failed to publish bundled transactions`, viemError, {
782
+ triedAddresses: triedAddresses.map((a)=>a.toString())
783
+ });
784
+ return undefined;
785
+ }
786
+ currentPublisher = nextPublisher;
787
+ }
788
+ }
789
+ }
790
+ /*
791
+ * Schedules sending all enqueued requests at (or after) the start of the given L2 slot.
792
+ * Sleeps until one L1 slot before the L2 slot boundary so the tx has a chance of being
793
+ * picked up by the first L1 block of the L2 slot.
794
+ * NB: there is a known correctness risk — being included in the L1 block right before the
795
+ * L2 slot starts would revert propose with HeaderLib__InvalidSlotNumber.
796
+ * Uses InterruptibleSleep so it can be cancelled via interrupt().
797
+ */ async sendRequestsAt(targetSlot) {
798
+ const l1Constants = this.epochCache.getL1Constants();
799
+ // Start of the target L2 slot, in ms (getTimestampForSlot returns seconds).
800
+ const startOfTargetSlotMs = Number(getTimestampForSlot(targetSlot, l1Constants)) * 1000;
801
+ // Aim to be in the mempool one L1 slot before the L2 slot starts, so we have a chance of
802
+ // being picked up by the first L1 block of the L2 slot.
803
+ const submitAfterMs = startOfTargetSlotMs - Number(this.ethereumSlotDuration) * 1000;
804
+ const sleepMs = submitAfterMs - this.dateProvider.now();
805
+ if (sleepMs > 0) {
806
+ this.log.debug(`Sleeping ${sleepMs}ms before sending requests`, {
807
+ targetSlot,
808
+ submitAfterMs
809
+ });
810
+ await this.interruptibleSleep.sleep(sleepMs);
811
+ }
812
+ if (this.interrupted) {
813
+ return undefined;
814
+ }
815
+ return this.sendRequests(targetSlot);
816
+ }
817
+ callbackBundledTransactions(requests, result) {
818
+ const actionsListStr = requests.map((r)=>r.action).join(', ');
819
+ this.log.verbose(`Published bundled transactions (${actionsListStr})`, {
820
+ result,
821
+ requests: requests.map((r)=>({
822
+ ...r,
823
+ // Avoid logging large blob data
824
+ blobConfig: r.blobConfig ? {
825
+ ...r.blobConfig,
826
+ blobs: r.blobConfig.blobs.map((b)=>({
827
+ size: trimmedBytesLength(b)
828
+ }))
829
+ } : undefined
830
+ }))
831
+ });
832
+ const successfulActions = [];
833
+ const failedActions = [];
834
+ for (const request of requests){
835
+ if (request.checkSuccess(request.request, result)) {
836
+ successfulActions.push(request.action);
837
+ } else {
838
+ failedActions.push(request.action);
666
839
  }
667
- return {
668
- successfulActions,
669
- failedActions
670
- };
671
840
  }
841
+ return {
842
+ successfulActions,
843
+ failedActions
844
+ };
672
845
  }
673
846
  /**
674
- * @notice Will call `canProposeAtNextEthBlock` to make sure that it is possible to propose
847
+ * @notice Will call `canProposeAt` to make sure that it is possible to propose
675
848
  * @param tipArchive - The archive to check
676
849
  * @returns The slot and block number if it is possible to propose, undefined otherwise
677
- */ canProposeAtNextEthBlock(tipArchive, msgSender, opts = {}) {
850
+ */ async canProposeAt(tipArchive, msgSender, simulationOverridesPlan) {
678
851
  // TODO: #14291 - should loop through multiple keys to check if any of them can propose
679
- const ignoredErrors = [
852
+ // These errors are expected when we cannot actually propose right now — usually because our
853
+ // local view of the chain is ahead of L1 (proposed parent hasn't landed yet, or someone
854
+ // else has just landed the slot, or the archive override doesn't match). We log a warn and
855
+ // skip the proposal; we do NOT treat these as bugs.
856
+ const expectedErrors = [
680
857
  'SlotAlreadyInChain',
681
858
  'InvalidProposer',
682
859
  'InvalidArchive'
683
860
  ];
684
- return this.rollupContract.canProposeAtNextEthBlock(tipArchive.toBuffer(), msgSender.toString(), Number(this.ethereumSlotDuration), {
685
- forcePendingCheckpointNumber: opts.forcePendingCheckpointNumber
686
- }).catch((err)=>{
687
- if (err instanceof FormattedViemError && ignoredErrors.find((e)=>err.message.includes(e))) {
688
- this.log.warn(`Failed canProposeAtTime check with ${ignoredErrors.find((e)=>err.message.includes(e))}`, {
861
+ const slotOffset = this.aztecSlotDuration;
862
+ const nextL1SlotTs = this.getNextL1SlotTimestamp() + slotOffset;
863
+ return this.rollupContract.canProposeAt(tipArchive.toBuffer(), msgSender.toString(), nextL1SlotTs, await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan)).catch((err)=>{
864
+ if (err instanceof FormattedViemError && expectedErrors.find((e)=>err.message.includes(e))) {
865
+ this.log.warn(`Failed canProposeAtTime check with ${expectedErrors.find((e)=>err.message.includes(e))}`, {
689
866
  error: err.message
690
867
  });
691
868
  } else {
@@ -699,22 +876,23 @@ export class SequencerPublisher {
699
876
  * @dev This is a convenience function that can be used by the sequencer to validate a "partial" header.
700
877
  * It will throw if the block header is invalid.
701
878
  * @param header - The block header to validate
702
- */ async validateBlockHeader(header, opts) {
879
+ */ async validateBlockHeader(header, simulationOverridesPlan) {
703
880
  const flags = {
704
881
  ignoreDA: true,
705
882
  ignoreSignatures: true
706
883
  };
707
884
  const args = [
708
885
  header.toViem(),
709
- CommitteeAttestationsAndSigners.empty().getPackedAttestations(),
886
+ CommitteeAttestationsAndSigners.packAttestations([]),
710
887
  [],
711
888
  Signature.empty().toViemSignature(),
712
889
  `0x${'0'.repeat(64)}`,
713
890
  header.blobsHash.toString(),
714
891
  flags
715
892
  ];
716
- const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);
717
- const stateOverrides = await this.rollupContract.makePendingCheckpointNumberOverride(opts?.forcePendingCheckpointNumber);
893
+ const l1Constants = this.epochCache.getL1Constants();
894
+ const ts = getLastL1SlotTimestampForL2Slot(header.slotNumber, l1Constants);
895
+ const stateOverrides = await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan);
718
896
  let balance = 0n;
719
897
  if (this.config.fishermanMode) {
720
898
  // In fisherman mode, we can't know where the proposer is publishing from
@@ -736,7 +914,7 @@ export class SequencerPublisher {
736
914
  }),
737
915
  from: MULTI_CALL_3_ADDRESS
738
916
  }, {
739
- time: ts + 1n
917
+ time: ts
740
918
  }, stateOverrides);
741
919
  this.log.debug(`Simulated validateHeader`);
742
920
  }
@@ -766,6 +944,7 @@ export class SequencerPublisher {
766
944
  ...logData,
767
945
  request
768
946
  });
947
+ const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
769
948
  try {
770
949
  const { gasUsed } = await this.l1TxUtils.simulate(request, undefined, undefined, mergeAbis([
771
950
  request.abi ?? [],
@@ -781,6 +960,7 @@ export class SequencerPublisher {
781
960
  gasUsed,
782
961
  checkpointNumber,
783
962
  forcePendingCheckpointNumber: CheckpointNumber(checkpointNumber - 1),
963
+ lastArchive: validationResult.checkpoint.lastArchive,
784
964
  reason
785
965
  };
786
966
  } catch (err) {
@@ -793,8 +973,8 @@ export class SequencerPublisher {
793
973
  request,
794
974
  error: viemError.message
795
975
  });
796
- const latestPendingCheckpointNumber = await this.rollupContract.getCheckpointNumber();
797
- if (latestPendingCheckpointNumber < checkpointNumber) {
976
+ const latestProposedCheckpointNumber = await this.rollupContract.getCheckpointNumber();
977
+ if (latestProposedCheckpointNumber < checkpointNumber) {
798
978
  this.log.verbose(`Checkpoint ${checkpointNumber} has already been invalidated`, {
799
979
  ...logData
800
980
  });
@@ -808,6 +988,27 @@ export class SequencerPublisher {
808
988
  }
809
989
  // Otherwise, throw. We cannot build the next checkpoint if we cannot invalidate the previous one.
810
990
  this.log.error(`Simulation for invalidate checkpoint ${checkpointNumber} failed`, viemError, logData);
991
+ this.backupFailedTx({
992
+ id: keccak256(request.data),
993
+ failureType: 'simulation',
994
+ request: {
995
+ to: request.to,
996
+ data: request.data,
997
+ value: request.value?.toString()
998
+ },
999
+ l1BlockNumber: l1BlockNumber.toString(),
1000
+ error: {
1001
+ message: viemError.message,
1002
+ name: viemError.name
1003
+ },
1004
+ context: {
1005
+ actions: [
1006
+ `invalidate-${reason}`
1007
+ ],
1008
+ checkpointNumber,
1009
+ sender: this.getSenderAddress().toString()
1010
+ }
1011
+ });
811
1012
  throw new Error(`Failed to simulate invalidate checkpoint ${checkpointNumber}`, {
812
1013
  cause: viemError
813
1014
  });
@@ -823,7 +1024,7 @@ export class SequencerPublisher {
823
1024
  reason
824
1025
  };
825
1026
  this.log.debug(`Building invalidate checkpoint ${checkpoint.checkpointNumber} request`, logData);
826
- const attestationsAndSigners = new CommitteeAttestationsAndSigners(validationResult.attestations).getPackedAttestations();
1027
+ const attestationsAndSigners = CommitteeAttestationsAndSigners.packAttestations(validationResult.attestations);
827
1028
  if (reason === 'invalid-attestation') {
828
1029
  return this.rollupContract.buildInvalidateBadAttestationRequest(checkpoint.checkpointNumber, attestationsAndSigners, committee, validationResult.invalidIndex);
829
1030
  } else if (reason === 'insufficient-attestations') {
@@ -833,42 +1034,7 @@ export class SequencerPublisher {
833
1034
  throw new Error(`Unknown reason for invalidation`);
834
1035
  }
835
1036
  }
836
- /** Simulates `propose` to make sure that the checkpoint is valid for submission */ async validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, options) {
837
- const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);
838
- // TODO(palla/mbps): This should not be needed, there's no flow where we propose with zero attestations. Or is there?
839
- // If we have no attestations, we still need to provide the empty attestations
840
- // so that the committee is recalculated correctly
841
- // const ignoreSignatures = attestationsAndSigners.attestations.length === 0;
842
- // if (ignoreSignatures) {
843
- // const { committee } = await this.epochCache.getCommittee(block.header.globalVariables.slotNumber);
844
- // if (!committee) {
845
- // this.log.warn(`No committee found for slot ${block.header.globalVariables.slotNumber}`);
846
- // throw new Error(`No committee found for slot ${block.header.globalVariables.slotNumber}`);
847
- // }
848
- // attestationsAndSigners.attestations = committee.map(committeeMember =>
849
- // CommitteeAttestation.fromAddress(committeeMember),
850
- // );
851
- // }
852
- const blobFields = checkpoint.toBlobFields();
853
- const blobs = getBlobsPerL1Block(blobFields);
854
- const blobInput = getPrefixedEthBlobCommitments(blobs);
855
- const args = [
856
- {
857
- header: checkpoint.header.toViem(),
858
- archive: toHex(checkpoint.archive.root.toBuffer()),
859
- oracleInput: {
860
- feeAssetPriceModifier: 0n
861
- }
862
- },
863
- attestationsAndSigners.getPackedAttestations(),
864
- attestationsAndSigners.getSigners().map((signer)=>signer.toString()),
865
- attestationsAndSignersSignature.toViemSignature(),
866
- blobInput
867
- ];
868
- await this.simulateProposeTx(args, ts, options);
869
- return ts;
870
- }
871
- async enqueueCastSignalHelper(slotNumber, timestamp, signalType, payload, base, signerAddress, signer) {
1037
+ async enqueueCastSignalHelper(slotNumber, signalType, payload, base, signerAddress, signer) {
872
1038
  if (this.lastActions[signalType] && this.lastActions[signalType] === slotNumber) {
873
1039
  this.log.debug(`Skipping duplicate vote cast signal ${signalType} for slot ${slotNumber}`);
874
1040
  return false;
@@ -888,10 +1054,28 @@ export class SequencerPublisher {
888
1054
  if (roundInfo.lastSignalSlot >= slotNumber) {
889
1055
  return false;
890
1056
  }
891
- if (await this.isPayloadEmpty(payload)) {
1057
+ if (await base.isPayloadEmpty(payload)) {
892
1058
  this.log.warn(`Skipping vote cast for payload with empty code`);
893
1059
  return false;
894
1060
  }
1061
+ // Skip signaling if there is already a live (non-terminal) Governance proposal for this
1062
+ // payload. This is intentionally not cached: a previously-live proposal may transition to
1063
+ // a terminal state (Dropped/Rejected/Expired/Executed), at which point we may want to re-signal
1064
+ // the same payload in a future round.
1065
+ let proposed = false;
1066
+ try {
1067
+ proposed = await base.hasActiveProposalWithPayload(payload.toString());
1068
+ } catch (err) {
1069
+ // We deliberately swallow the error and proceed to signal. Failing closed (skipping the
1070
+ // signal) on transient RPC errors would let a flaky L1 endpoint silence governance
1071
+ // participation entirely; failing open at worst produces a duplicate signal that the
1072
+ // contract will simply count alongside others in the round.
1073
+ this.log.error(`Failed to check if payload ${payload} was already proposed (signalling anyway)`, err);
1074
+ }
1075
+ if (proposed) {
1076
+ this.log.info(`Payload ${payload} has a live governance proposal, stopping signals`);
1077
+ return false;
1078
+ }
895
1079
  const cachedLastVote = this.lastActions[signalType];
896
1080
  this.lastActions[signalType] = slotNumber;
897
1081
  const action = signalType;
@@ -902,30 +1086,17 @@ export class SequencerPublisher {
902
1086
  signer: this.l1TxUtils.client.account?.address,
903
1087
  lastValidL2Slot: slotNumber
904
1088
  });
905
- try {
906
- await this.l1TxUtils.simulate(request, {
907
- time: timestamp
908
- }, [], mergeAbis([
909
- request.abi ?? [],
910
- ErrorsAbi
911
- ]));
912
- this.log.debug(`Simulation for ${action} at slot ${slotNumber} succeeded`, {
913
- request
914
- });
915
- } catch (err) {
916
- this.log.error(`Failed simulation for ${action} at slot ${slotNumber} (enqueuing the action anyway)`, err);
917
- // Yes, we enqueue the request anyway, in case there was a bug with the simulation itself
918
- }
919
1089
  // TODO(palla/slash): All votes (governance and slashing) should txTimeoutAt at the end of the slot.
920
1090
  this.addRequest({
921
- gasConfig: {
922
- gasLimit: SequencerPublisher.VOTE_GAS_GUESS
923
- },
924
1091
  action,
925
1092
  request,
926
1093
  lastValidL2Slot: slotNumber,
927
1094
  checkSuccess: (_request, result)=>{
928
- const success = result && result.receipt && result.receipt.status === 'success' && tryExtractEvent(result.receipt.logs, base.address.toString(), EmpireBaseAbi, 'SignalCast');
1095
+ const success = result && extractEventSuccess(result.receipt, {
1096
+ address: base.address.toString(),
1097
+ abi: EmpireBaseAbi,
1098
+ eventName: 'SignalCast'
1099
+ });
929
1100
  const logData = {
930
1101
  ...result,
931
1102
  slotNumber,
@@ -944,68 +1115,20 @@ export class SequencerPublisher {
944
1115
  });
945
1116
  return true;
946
1117
  }
947
- async isPayloadEmpty(payload) {
948
- const key = payload.toString();
949
- const cached = this.isPayloadEmptyCache.get(key);
950
- if (cached) {
951
- return cached;
952
- }
953
- const isEmpty = !await this.l1TxUtils.getCode(payload);
954
- this.isPayloadEmptyCache.set(key, isEmpty);
955
- return isEmpty;
956
- }
957
1118
  /**
958
1119
  * Enqueues a governance castSignal transaction to cast a signal for a given slot number.
959
1120
  * @param slotNumber - The slot number to cast a signal for.
960
- * @param timestamp - The timestamp of the slot to cast a signal for.
961
1121
  * @returns True if the signal was successfully enqueued, false otherwise.
962
- */ enqueueGovernanceCastSignal(governancePayload, slotNumber, timestamp, signerAddress, signer) {
963
- return this.enqueueCastSignalHelper(slotNumber, timestamp, 'governance-signal', governancePayload, this.govProposerContract, signerAddress, signer);
1122
+ */ enqueueGovernanceCastSignal(governancePayload, slotNumber, signerAddress, signer) {
1123
+ return this.enqueueCastSignalHelper(slotNumber, 'governance-signal', governancePayload, this.govProposerContract, signerAddress, signer);
964
1124
  }
965
- /** Enqueues all slashing actions as returned by the slasher client. */ async enqueueSlashingActions(actions, slotNumber, timestamp, signerAddress, signer) {
1125
+ /** Enqueues all slashing actions as returned by the slasher client. */ async enqueueSlashingActions(actions, slotNumber, signerAddress, signer) {
966
1126
  if (actions.length === 0) {
967
1127
  this.log.debug(`No slashing actions to enqueue for slot ${slotNumber}`);
968
1128
  return false;
969
1129
  }
970
1130
  for (const action of actions){
971
1131
  switch(action.type){
972
- case 'vote-empire-payload':
973
- {
974
- if (this.slashingProposerContract?.type !== 'empire') {
975
- this.log.error('Cannot vote for empire payload on non-empire slashing contract');
976
- break;
977
- }
978
- this.log.debug(`Enqueuing slashing vote for payload ${action.payload} at slot ${slotNumber}`, {
979
- signerAddress
980
- });
981
- await this.enqueueCastSignalHelper(slotNumber, timestamp, 'empire-slashing-signal', action.payload, this.slashingProposerContract, signerAddress, signer);
982
- break;
983
- }
984
- case 'create-empire-payload':
985
- {
986
- this.log.debug(`Enqueuing slashing create payload at slot ${slotNumber}`, {
987
- slotNumber,
988
- signerAddress
989
- });
990
- const request = this.slashFactoryContract.buildCreatePayloadRequest(action.data);
991
- await this.simulateAndEnqueueRequest('create-empire-payload', request, (receipt)=>!!this.slashFactoryContract.tryExtractSlashPayloadCreatedEvent(receipt.logs), slotNumber, timestamp);
992
- break;
993
- }
994
- case 'execute-empire-payload':
995
- {
996
- this.log.debug(`Enqueuing slashing execute payload at slot ${slotNumber}`, {
997
- slotNumber,
998
- signerAddress
999
- });
1000
- if (this.slashingProposerContract?.type !== 'empire') {
1001
- this.log.error('Cannot execute slashing payload on non-empire slashing contract');
1002
- return false;
1003
- }
1004
- const empireSlashingProposer = this.slashingProposerContract;
1005
- const request = empireSlashingProposer.buildExecuteRoundRequest(action.round);
1006
- await this.simulateAndEnqueueRequest('execute-empire-payload', request, (receipt)=>!!empireSlashingProposer.tryExtractPayloadSubmittedEvent(receipt.logs), slotNumber, timestamp);
1007
- break;
1008
- }
1009
1132
  case 'vote-offenses':
1010
1133
  {
1011
1134
  this.log.debug(`Enqueuing slashing vote for ${action.votes.length} votes at slot ${slotNumber}`, {
@@ -1014,14 +1137,17 @@ export class SequencerPublisher {
1014
1137
  votesCount: action.votes.length,
1015
1138
  signerAddress
1016
1139
  });
1017
- if (this.slashingProposerContract?.type !== 'tally') {
1018
- this.log.error('Cannot vote for slashing offenses on non-tally slashing contract');
1140
+ if (!this.slashingProposerContract) {
1141
+ this.log.error('No slashing proposer contract available');
1019
1142
  return false;
1020
1143
  }
1021
- const tallySlashingProposer = this.slashingProposerContract;
1022
1144
  const votes = bufferToHex(encodeSlashConsensusVotes(action.votes));
1023
- const request = await tallySlashingProposer.buildVoteRequestFromSigner(votes, slotNumber, signer);
1024
- await this.simulateAndEnqueueRequest('vote-offenses', request, (receipt)=>!!tallySlashingProposer.tryExtractVoteCastEvent(receipt.logs), slotNumber, timestamp);
1145
+ const request = await this.slashingProposerContract.buildVoteRequestFromSigner(votes, slotNumber, signer);
1146
+ this.enqueueRequest('vote-offenses', request, {
1147
+ address: this.slashingProposerContract.address.toString(),
1148
+ abi: SlashingProposerAbi,
1149
+ eventName: 'VoteCast'
1150
+ }, slotNumber);
1025
1151
  break;
1026
1152
  }
1027
1153
  case 'execute-slash':
@@ -1031,13 +1157,16 @@ export class SequencerPublisher {
1031
1157
  round: action.round,
1032
1158
  signerAddress
1033
1159
  });
1034
- if (this.slashingProposerContract?.type !== 'tally') {
1035
- this.log.error('Cannot execute slashing offenses on non-tally slashing contract');
1160
+ if (!this.slashingProposerContract) {
1161
+ this.log.error('No slashing proposer contract available');
1036
1162
  return false;
1037
1163
  }
1038
- const tallySlashingProposer = this.slashingProposerContract;
1039
- const request = tallySlashingProposer.buildExecuteRoundRequest(action.round, action.committees);
1040
- await this.simulateAndEnqueueRequest('execute-slash', request, (receipt)=>!!tallySlashingProposer.tryExtractRoundExecutedEvent(receipt.logs), slotNumber, timestamp);
1164
+ const executeRequest = this.slashingProposerContract.buildExecuteRoundRequest(action.round, action.committees);
1165
+ this.enqueueRequest('execute-slash', executeRequest, {
1166
+ address: this.slashingProposerContract.address.toString(),
1167
+ abi: SlashingProposerAbi,
1168
+ eventName: 'RoundExecuted'
1169
+ }, slotNumber);
1041
1170
  break;
1042
1171
  }
1043
1172
  default:
@@ -1049,63 +1178,50 @@ export class SequencerPublisher {
1049
1178
  }
1050
1179
  return true;
1051
1180
  }
1052
- /** Simulates and enqueues a proposal for a checkpoint on L1 */ async enqueueProposeCheckpoint(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, opts = {}) {
1181
+ /** Enqueues a proposal for a checkpoint on L1 */ async enqueueProposeCheckpoint(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, opts = {}) {
1053
1182
  const checkpointHeader = checkpoint.header;
1054
1183
  const blobFields = checkpoint.toBlobFields();
1055
- const blobs = getBlobsPerL1Block(blobFields);
1184
+ const blobs = await getBlobsPerL1Block(blobFields);
1056
1185
  const proposeTxArgs = {
1057
1186
  header: checkpointHeader,
1058
1187
  archive: checkpoint.archive.root.toBuffer(),
1059
1188
  blobs,
1060
1189
  attestationsAndSigners,
1061
- attestationsAndSignersSignature
1190
+ attestationsAndSignersSignature,
1191
+ feeAssetPriceModifier: checkpoint.feeAssetPriceModifier
1062
1192
  };
1063
- let ts;
1064
- try {
1065
- // @note This will make sure that we are passing the checks for our header ASSUMING that the data is also made available
1066
- // This means that we can avoid the simulation issues in later checks.
1067
- // By simulation issue, I mean the fact that the block.timestamp is equal to the last block, not the next, which
1068
- // make time consistency checks break.
1069
- // TODO(palla): Check whether we're validating twice, once here and once within addProposeTx, since we call simulateProposeTx in both places.
1070
- ts = await this.validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, opts);
1071
- } catch (err) {
1072
- this.log.error(`Checkpoint validation failed. ${err instanceof Error ? err.message : 'No error message'}`, err, {
1073
- ...checkpoint.getStats(),
1074
- slotNumber: checkpoint.header.slotNumber,
1075
- forcePendingCheckpointNumber: opts.forcePendingCheckpointNumber
1076
- });
1077
- throw err;
1078
- }
1079
1193
  this.log.verbose(`Enqueuing checkpoint propose transaction`, {
1080
1194
  ...checkpoint.toCheckpointInfo(),
1081
- ...opts
1195
+ txTimeoutAt: opts.txTimeoutAt
1196
+ });
1197
+ await this.addProposeTx(checkpoint, proposeTxArgs, {
1198
+ txTimeoutAt: opts.txTimeoutAt
1082
1199
  });
1083
- await this.addProposeTx(checkpoint, proposeTxArgs, opts, ts);
1084
1200
  }
1085
1201
  enqueueInvalidateCheckpoint(request, opts = {}) {
1086
1202
  if (!request) {
1087
1203
  return;
1088
1204
  }
1089
- // We issued the simulation against the rollup contract, so we need to account for the overhead of the multicall3
1090
- const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(request.gasUsed) * 64 / 63)));
1091
1205
  const { gasUsed, checkpointNumber } = request;
1092
1206
  const logData = {
1093
1207
  gasUsed,
1094
1208
  checkpointNumber,
1095
- gasLimit,
1096
1209
  opts
1097
1210
  };
1098
1211
  this.log.verbose(`Enqueuing invalidate checkpoint request`, logData);
1099
1212
  this.addRequest({
1100
1213
  action: `invalidate-by-${request.reason}`,
1101
1214
  request: request.request,
1102
- gasConfig: {
1103
- gasLimit,
1215
+ gasConfig: opts.txTimeoutAt ? {
1104
1216
  txTimeoutAt: opts.txTimeoutAt
1105
- },
1217
+ } : undefined,
1106
1218
  lastValidL2Slot: SlotNumber(this.getCurrentL2Slot() + 2),
1107
1219
  checkSuccess: (_req, result)=>{
1108
- const success = result && result.receipt && result.receipt.status === 'success' && tryExtractEvent(result.receipt.logs, this.rollupContract.address, RollupAbi, 'CheckpointInvalidated');
1220
+ const success = result && extractEventSuccess(result.receipt, {
1221
+ address: this.rollupContract.address,
1222
+ abi: RollupAbi,
1223
+ eventName: 'CheckpointInvalidated'
1224
+ });
1109
1225
  if (!success) {
1110
1226
  this.log.warn(`Invalidate checkpoint ${request.checkpointNumber} failed`, {
1111
1227
  ...result,
@@ -1121,67 +1237,36 @@ export class SequencerPublisher {
1121
1237
  }
1122
1238
  });
1123
1239
  }
1124
- async simulateAndEnqueueRequest(action, request, checkSuccess, slotNumber, timestamp) {
1125
- const logData = {
1126
- slotNumber,
1127
- timestamp,
1128
- gasLimit: undefined
1129
- };
1240
+ /**
1241
+ * Dedup-checked enqueue helper for actions that are simulated at bundle-send time rather
1242
+ * than at enqueue time. Validates the (action, slot) dedup key, sets `lastActions`, and
1243
+ * enqueues without a gasLimit so the bundle simulate sets the only gasLimit that matters.
1244
+ */ enqueueRequest(action, request, eventOpts, slotNumber) {
1130
1245
  if (this.lastActions[action] && this.lastActions[action] === slotNumber) {
1131
1246
  this.log.debug(`Skipping duplicate action ${action} for slot ${slotNumber}`);
1132
1247
  return false;
1133
1248
  }
1134
1249
  const cachedLastActionSlot = this.lastActions[action];
1135
1250
  this.lastActions[action] = slotNumber;
1136
- this.log.debug(`Simulating ${action} for slot ${slotNumber}`, logData);
1137
- let gasUsed;
1138
- const simulateAbi = mergeAbis([
1139
- request.abi ?? [],
1140
- ErrorsAbi
1141
- ]);
1142
- try {
1143
- ({ gasUsed } = await this.l1TxUtils.simulate(request, {
1144
- time: timestamp
1145
- }, [], simulateAbi)); // TODO(palla/slash): Check the timestamp logic
1146
- this.log.verbose(`Simulation for ${action} succeeded`, {
1147
- ...logData,
1148
- request,
1149
- gasUsed
1150
- });
1151
- } catch (err) {
1152
- const viemError = formatViemError(err, simulateAbi);
1153
- this.log.error(`Simulation for ${action} at ${slotNumber} failed`, viemError, logData);
1154
- return false;
1155
- }
1156
- // We issued the simulation against the rollup contract, so we need to account for the overhead of the multicall3
1157
- const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(gasUsed) * 64 / 63)));
1158
- logData.gasLimit = gasLimit;
1159
- // Store the ABI used for simulation on the request so Multicall3.forward can decode errors
1160
- // when the tx is sent and a revert is diagnosed via simulation.
1161
- const requestWithAbi = {
1162
- ...request,
1163
- abi: simulateAbi
1164
- };
1165
- this.log.debug(`Enqueuing ${action}`, logData);
1251
+ this.log.debug(`Enqueuing ${action}`, {
1252
+ slotNumber
1253
+ });
1166
1254
  this.addRequest({
1167
1255
  action,
1168
- request: requestWithAbi,
1169
- gasConfig: {
1170
- gasLimit
1171
- },
1256
+ request,
1172
1257
  lastValidL2Slot: slotNumber,
1173
- checkSuccess: (_req, result)=>{
1174
- const success = result && result.receipt && result.receipt.status === 'success' && checkSuccess(result.receipt);
1258
+ checkSuccess: (_request, result)=>{
1259
+ const success = result && extractEventSuccess(result.receipt, eventOpts);
1175
1260
  if (!success) {
1176
1261
  this.log.warn(`Action ${action} at ${slotNumber} failed`, {
1177
1262
  ...result,
1178
- ...logData
1263
+ slotNumber
1179
1264
  });
1180
1265
  this.lastActions[action] = cachedLastActionSlot;
1181
1266
  } else {
1182
1267
  this.log.info(`Action ${action} at ${slotNumber} succeeded`, {
1183
1268
  ...result,
1184
- ...logData
1269
+ slotNumber
1185
1270
  });
1186
1271
  }
1187
1272
  return !!success;
@@ -1196,13 +1281,14 @@ export class SequencerPublisher {
1196
1281
  * A call to `restart` is required before you can continue publishing.
1197
1282
  */ interrupt() {
1198
1283
  this.interrupted = true;
1284
+ this.interruptibleSleep.interrupt();
1199
1285
  this.l1TxUtils.interrupt();
1200
1286
  }
1201
1287
  /** Restarts the publisher after calling `interrupt`. */ restart() {
1202
1288
  this.interrupted = false;
1203
1289
  this.l1TxUtils.restart();
1204
1290
  }
1205
- async prepareProposeTx(encodedData, timestamp, options) {
1291
+ async prepareProposeTx(encodedData) {
1206
1292
  const kzg = Blob.getViemKzgInstance();
1207
1293
  const blobInput = getPrefixedEthBlobCommitments(encodedData.blobs);
1208
1294
  this.log.debug('Validating blob input', {
@@ -1216,7 +1302,11 @@ export class SequencerPublisher {
1216
1302
  blobEvaluationGas = BigInt(encodedData.blobs.length) * 21_000n;
1217
1303
  this.log.debug(`Using fixed blob evaluation gas estimate in fisherman mode: ${blobEvaluationGas}`);
1218
1304
  } else {
1219
- // Normal mode - use estimateGas with blob inputs
1305
+ // We call validateBlobs via estimateGas with real blob+kzg sidecars as a consistency check
1306
+ // that our locally-built blob commitments match the blob data. The bundle simulate at send
1307
+ // time uses eth_simulateV1, which cannot carry blob inputs, so the rollup's on-chain blob
1308
+ // check is forced off there — making this the only pre-flight detector of a commitment/data
1309
+ // mismatch. The returned gas estimate is stashed on the request for the bundle path to read.
1220
1310
  blobEvaluationGas = await this.l1TxUtils.estimateGas(this.getSenderAddress().toString(), {
1221
1311
  to: this.rollupContract.address,
1222
1312
  data: encodeFunctionData({
@@ -1229,10 +1319,38 @@ export class SequencerPublisher {
1229
1319
  }, {}, {
1230
1320
  blobs: encodedData.blobs.map((b)=>b.data),
1231
1321
  kzg
1232
- }).catch((err)=>{
1233
- const { message, metaMessages } = formatViemError(err);
1234
- this.log.error(`Failed to validate blobs`, message, {
1235
- metaMessages
1322
+ }).catch(async (err)=>{
1323
+ const viemError = formatViemError(err);
1324
+ this.log.error(`Failed to validate blobs`, viemError.message, {
1325
+ metaMessages: viemError.metaMessages
1326
+ });
1327
+ const validateBlobsData = encodeFunctionData({
1328
+ abi: RollupAbi,
1329
+ functionName: 'validateBlobs',
1330
+ args: [
1331
+ blobInput
1332
+ ]
1333
+ });
1334
+ const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
1335
+ this.backupFailedTx({
1336
+ id: keccak256(validateBlobsData),
1337
+ failureType: 'simulation',
1338
+ request: {
1339
+ to: this.rollupContract.address,
1340
+ data: validateBlobsData
1341
+ },
1342
+ blobData: encodedData.blobs.map((b)=>toHex(b.data)),
1343
+ l1BlockNumber: l1BlockNumber.toString(),
1344
+ error: {
1345
+ message: viemError.message,
1346
+ name: viemError.name
1347
+ },
1348
+ context: {
1349
+ actions: [
1350
+ 'validate-blobs'
1351
+ ],
1352
+ sender: this.getSenderAddress().toString()
1353
+ }
1236
1354
  });
1237
1355
  throw new Error('Failed to validate blobs');
1238
1356
  });
@@ -1243,8 +1361,7 @@ export class SequencerPublisher {
1243
1361
  header: encodedData.header.toViem(),
1244
1362
  archive: toHex(encodedData.archive),
1245
1363
  oracleInput: {
1246
- // We are currently not modifying these. See #9963
1247
- feeAssetPriceModifier: 0n
1364
+ feeAssetPriceModifier: encodedData.feeAssetPriceModifier
1248
1365
  }
1249
1366
  },
1250
1367
  encodedData.attestationsAndSigners.getPackedAttestations(),
@@ -1252,88 +1369,23 @@ export class SequencerPublisher {
1252
1369
  encodedData.attestationsAndSignersSignature.toViemSignature(),
1253
1370
  blobInput
1254
1371
  ];
1255
- const { rollupData, simulationResult } = await this.simulateProposeTx(args, timestamp, options);
1256
- return {
1257
- args,
1258
- blobEvaluationGas,
1259
- rollupData,
1260
- simulationResult
1261
- };
1262
- }
1263
- /**
1264
- * Simulates the propose tx with eth_simulateV1
1265
- * @param args - The propose tx args
1266
- * @param timestamp - The timestamp to simulate proposal at
1267
- * @returns The simulation result
1268
- */ async simulateProposeTx(args, timestamp, options) {
1269
1372
  const rollupData = encodeFunctionData({
1270
1373
  abi: RollupAbi,
1271
1374
  functionName: 'propose',
1272
1375
  args
1273
1376
  });
1274
- // override the pending checkpoint number if requested
1275
- const forcePendingCheckpointNumberStateDiff = (options.forcePendingCheckpointNumber !== undefined ? await this.rollupContract.makePendingCheckpointNumberOverride(options.forcePendingCheckpointNumber) : []).flatMap((override)=>override.stateDiff ?? []);
1276
- const stateOverrides = [
1277
- {
1278
- address: this.rollupContract.address,
1279
- // @note we override checkBlob to false since blobs are not part simulate()
1280
- stateDiff: [
1281
- {
1282
- slot: toPaddedHex(RollupContract.checkBlobStorageSlot, true),
1283
- value: toPaddedHex(0n, true)
1284
- },
1285
- ...forcePendingCheckpointNumberStateDiff
1286
- ]
1287
- }
1288
- ];
1289
- // In fisherman mode, simulate as the proposer but with sufficient balance
1290
- if (this.proposerAddressForSimulation) {
1291
- stateOverrides.push({
1292
- address: this.proposerAddressForSimulation.toString(),
1293
- balance: 10n * WEI_CONST * WEI_CONST
1294
- });
1295
- }
1296
- const simulationResult = await this.l1TxUtils.simulate({
1297
- to: this.rollupContract.address,
1298
- data: rollupData,
1299
- gas: MAX_L1_TX_LIMIT,
1300
- ...this.proposerAddressForSimulation && {
1301
- from: this.proposerAddressForSimulation.toString()
1302
- }
1303
- }, {
1304
- // @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp
1305
- time: timestamp + 1n,
1306
- // @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit so we increase here
1307
- gasLimit: MAX_L1_TX_LIMIT * 2n
1308
- }, stateOverrides, RollupAbi, {
1309
- // @note fallback gas estimate to use if the node doesn't support simulation API
1310
- fallbackGasEstimate: MAX_L1_TX_LIMIT
1311
- }).catch((err)=>{
1312
- // In fisherman mode, we expect ValidatorSelection__MissingProposerSignature since fisherman doesn't have proposer signature
1313
- const viemError = formatViemError(err);
1314
- if (this.config.fishermanMode && viemError.message?.includes('ValidatorSelection__MissingProposerSignature')) {
1315
- this.log.debug(`Ignoring expected ValidatorSelection__MissingProposerSignature error in fisherman mode`);
1316
- // Return a minimal simulation result with the fallback gas estimate
1317
- return {
1318
- gasUsed: MAX_L1_TX_LIMIT,
1319
- logs: []
1320
- };
1321
- }
1322
- this.log.error(`Failed to simulate propose tx`, viemError);
1323
- throw err;
1324
- });
1325
1377
  return {
1326
- rollupData,
1327
- simulationResult
1378
+ args,
1379
+ blobEvaluationGas,
1380
+ rollupData
1328
1381
  };
1329
1382
  }
1330
- async addProposeTx(checkpoint, encodedData, opts = {}, timestamp) {
1383
+ async addProposeTx(checkpoint, encodedData, opts = {}) {
1331
1384
  const slot = checkpoint.header.slotNumber;
1332
1385
  const timer = new Timer();
1333
1386
  const kzg = Blob.getViemKzgInstance();
1334
- const { rollupData, simulationResult, blobEvaluationGas } = await this.prepareProposeTx(encodedData, timestamp, opts);
1387
+ const { rollupData, blobEvaluationGas } = await this.prepareProposeTx(encodedData);
1335
1388
  const startBlock = await this.l1TxUtils.getBlockNumber();
1336
- const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(simulationResult.gasUsed) * 64 / 63)) + blobEvaluationGas + SequencerPublisher.MULTICALL_OVERHEAD_GAS_GUESS);
1337
1389
  // Send the blobs to the blob client preemptively. This helps in tests where the sequencer mistakingly thinks that the propose
1338
1390
  // tx fails but it does get mined. We make sure that the blobs are sent to the blob client regardless of the tx outcome.
1339
1391
  void Promise.resolve().then(()=>this.blobClient.sendBlobsToFilestore(encodedData.blobs).catch((_err)=>{
@@ -1347,9 +1399,10 @@ export class SequencerPublisher {
1347
1399
  },
1348
1400
  lastValidL2Slot: checkpoint.header.slotNumber,
1349
1401
  gasConfig: {
1350
- ...opts,
1351
- gasLimit
1402
+ txTimeoutAt: opts.txTimeoutAt,
1403
+ gasLimit: undefined
1352
1404
  },
1405
+ blobEvaluationGas,
1353
1406
  blobConfig: {
1354
1407
  blobs: encodedData.blobs.map((b)=>b.data),
1355
1408
  kzg
@@ -1359,7 +1412,11 @@ export class SequencerPublisher {
1359
1412
  return false;
1360
1413
  }
1361
1414
  const { receipt, stats, errorMsg } = result;
1362
- const success = receipt && receipt.status === 'success' && tryExtractEvent(receipt.logs, this.rollupContract.address, RollupAbi, 'CheckpointProposed');
1415
+ const success = extractEventSuccess(receipt, {
1416
+ address: this.rollupContract.address,
1417
+ abi: RollupAbi,
1418
+ eventName: 'CheckpointProposed'
1419
+ });
1363
1420
  if (success) {
1364
1421
  const endBlock = receipt.blockNumber;
1365
1422
  const inclusionBlocks = Number(endBlock - startBlock);
@@ -1396,4 +1453,8 @@ export class SequencerPublisher {
1396
1453
  }
1397
1454
  });
1398
1455
  }
1456
+ /** Returns the timestamp of the next L1 slot boundary after now. */ getNextL1SlotTimestamp() {
1457
+ const l1Constants = this.epochCache.getL1Constants();
1458
+ return getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), l1Constants);
1459
+ }
1399
1460
  }