@aztec/sequencer-client 0.0.1-commit.2ed92850 → 0.0.1-commit.2f68f620

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 (129) 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-metrics.d.ts +1 -1
  47. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  48. package/dest/publisher/sequencer-publisher-metrics.js +12 -4
  49. package/dest/publisher/sequencer-publisher.d.ts +94 -68
  50. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  51. package/dest/publisher/sequencer-publisher.js +448 -363
  52. package/dest/sequencer/automine/automine_factory.d.ts +54 -0
  53. package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
  54. package/dest/sequencer/automine/automine_factory.js +84 -0
  55. package/dest/sequencer/automine/automine_sequencer.d.ts +151 -0
  56. package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
  57. package/dest/sequencer/automine/automine_sequencer.js +509 -0
  58. package/dest/sequencer/chain_state_overrides.d.ts +61 -0
  59. package/dest/sequencer/chain_state_overrides.d.ts.map +1 -0
  60. package/dest/sequencer/chain_state_overrides.js +98 -0
  61. package/dest/sequencer/checkpoint_proposal_job.d.ts +85 -14
  62. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  63. package/dest/sequencer/checkpoint_proposal_job.js +882 -254
  64. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
  65. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
  66. package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
  67. package/dest/sequencer/checkpoint_voter.d.ts +1 -2
  68. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
  69. package/dest/sequencer/checkpoint_voter.js +2 -5
  70. package/dest/sequencer/events.d.ts +48 -2
  71. package/dest/sequencer/events.d.ts.map +1 -1
  72. package/dest/sequencer/index.d.ts +3 -1
  73. package/dest/sequencer/index.d.ts.map +1 -1
  74. package/dest/sequencer/index.js +2 -0
  75. package/dest/sequencer/metrics.d.ts +23 -8
  76. package/dest/sequencer/metrics.d.ts.map +1 -1
  77. package/dest/sequencer/metrics.js +142 -36
  78. package/dest/sequencer/sequencer.d.ts +85 -22
  79. package/dest/sequencer/sequencer.d.ts.map +1 -1
  80. package/dest/sequencer/sequencer.js +380 -137
  81. package/dest/sequencer/timetable.d.ts +14 -6
  82. package/dest/sequencer/timetable.d.ts.map +1 -1
  83. package/dest/sequencer/timetable.js +47 -46
  84. package/dest/sequencer/types.d.ts +2 -2
  85. package/dest/sequencer/types.d.ts.map +1 -1
  86. package/dest/test/index.d.ts +3 -5
  87. package/dest/test/index.d.ts.map +1 -1
  88. package/dest/test/mock_checkpoint_builder.d.ts +12 -12
  89. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  90. package/dest/test/mock_checkpoint_builder.js +45 -36
  91. package/dest/test/utils.d.ts +3 -3
  92. package/dest/test/utils.d.ts.map +1 -1
  93. package/dest/test/utils.js +10 -8
  94. package/package.json +27 -28
  95. package/src/client/sequencer-client.ts +91 -35
  96. package/src/config.ts +98 -46
  97. package/src/global_variable_builder/README.md +44 -0
  98. package/src/global_variable_builder/fee_predictor.ts +172 -0
  99. package/src/global_variable_builder/fee_provider.ts +75 -0
  100. package/src/global_variable_builder/global_builder.ts +26 -63
  101. package/src/global_variable_builder/index.ts +3 -1
  102. package/src/index.ts +10 -1
  103. package/src/publisher/config.ts +157 -45
  104. package/src/publisher/index.ts +3 -0
  105. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  106. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +57 -0
  107. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
  108. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  109. package/src/publisher/sequencer-bundle-simulator.ts +254 -0
  110. package/src/publisher/sequencer-publisher-factory.ts +38 -9
  111. package/src/publisher/sequencer-publisher-metrics.ts +7 -3
  112. package/src/publisher/sequencer-publisher.ts +542 -460
  113. package/src/sequencer/README.md +162 -450
  114. package/src/sequencer/automine/README.md +46 -0
  115. package/src/sequencer/automine/automine_factory.ts +145 -0
  116. package/src/sequencer/automine/automine_sequencer.ts +595 -0
  117. package/src/sequencer/chain_state_overrides.ts +162 -0
  118. package/src/sequencer/checkpoint_proposal_job.ts +1078 -290
  119. package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
  120. package/src/sequencer/checkpoint_voter.ts +1 -12
  121. package/src/sequencer/events.ts +51 -2
  122. package/src/sequencer/index.ts +2 -0
  123. package/src/sequencer/metrics.ts +164 -39
  124. package/src/sequencer/sequencer.ts +471 -157
  125. package/src/sequencer/timetable.ts +62 -56
  126. package/src/sequencer/types.ts +1 -1
  127. package/src/test/index.ts +2 -4
  128. package/src/test/mock_checkpoint_builder.ts +65 -53
  129. 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
- import { WEI_CONST } from '@aztec/ethereum/l1-tx-utils';
378
- import { FormattedViemError, formatViemError, tryExtractEvent } from '@aztec/ethereum/utils';
379
- import { sumBigint } from '@aztec/foundation/bigint';
380
- import { toHex as toPaddedHex } from '@aztec/foundation/bigint-buffer';
377
+ import { MAX_L1_TX_LIMIT, WEI_CONST } from '@aztec/ethereum/l1-tx-utils';
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,58 +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
- // @note - with blobs, the below estimate seems too large.
442
- // Total used for full block from int_l1_pub e2e test: 1m (of which 86k is 1x blob)
443
- // Total used for emptier block from above test: 429k (of which 84k is 1x blob)
444
- static PROPOSE_GAS_GUESS = 12_000_000n;
445
- // A CALL to a cold address is 2700 gas
446
- static MULTICALL_OVERHEAD_GAS_GUESS = 5000n;
447
- // Gas report for VotingWithSigTest shows a max gas of 100k, but we've seen it cost 700k+ in testnet
448
- 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;
449
455
  l1TxUtils;
450
456
  rollupContract;
451
457
  govProposerContract;
452
458
  slashingProposerContract;
453
- slashFactoryContract;
454
459
  tracer;
455
460
  requests;
456
461
  constructor(config, deps){
457
462
  this.config = config;
458
463
  this.interrupted = (_initProto(this), false);
459
- this.governanceLog = createLogger('sequencer:publisher:governance');
460
- this.slashingLog = createLogger('sequencer:publisher:slashing');
464
+ this.revertDecoderAbi = mergeAbis([
465
+ RollupAbi,
466
+ SlashingProposerAbi,
467
+ EmpireBaseAbi,
468
+ ErrorsAbi
469
+ ]);
461
470
  this.lastActions = {};
462
- this.isPayloadEmptyCache = new Map();
471
+ this.interruptibleSleep = new InterruptibleSleep();
463
472
  this.requests = [];
464
473
  this.log = deps.log ?? createLogger('sequencer:publisher');
465
474
  this.ethereumSlotDuration = BigInt(config.ethereumSlotDuration);
475
+ this.aztecSlotDuration = BigInt(config.aztecSlotDuration);
476
+ this.dateProvider = deps.dateProvider;
466
477
  this.epochCache = deps.epochCache;
467
478
  this.lastActions = deps.lastActions;
468
479
  this.blobClient = deps.blobClient;
480
+ this.dateProvider = deps.dateProvider;
469
481
  const telemetry = deps.telemetry ?? getTelemetryClient();
470
482
  this.metrics = deps.metrics ?? new SequencerPublisherMetrics(telemetry, 'SequencerPublisher');
471
483
  this.tracer = telemetry.getTracer('SequencerPublisher');
472
484
  this.l1TxUtils = deps.l1TxUtils;
485
+ this.getNextPublisher = deps.getNextPublisher;
473
486
  this.rollupContract = deps.rollupContract;
474
487
  this.govProposerContract = deps.governanceProposerContract;
475
488
  this.slashingProposerContract = deps.slashingProposerContract;
@@ -478,15 +491,50 @@ export class SequencerPublisher {
478
491
  const newSlashingProposer = await this.rollupContract.getSlashingProposer();
479
492
  this.slashingProposerContract = newSlashingProposer;
480
493
  });
481
- this.slashFactoryContract = deps.slashFactoryContract;
482
494
  // Initialize L1 fee analyzer for fisherman mode
483
495
  if (config.fishermanMode) {
484
- 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'));
485
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
+ });
486
524
  }
487
525
  getRollupContract() {
488
526
  return this.rollupContract;
489
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
+ }
490
538
  getSenderAddress() {
491
539
  return this.l1TxUtils.getSenderAddress();
492
540
  }
@@ -495,17 +543,11 @@ export class SequencerPublisher {
495
543
  */ getL1FeeAnalyzer() {
496
544
  return this.l1FeeAnalyzer;
497
545
  }
498
- /**
499
- * Sets the proposer address to use for simulations in fisherman mode.
500
- * @param proposerAddress - The actual proposer's address to use for balance lookups in simulations
501
- */ setProposerAddressForSimulation(proposerAddress) {
502
- this.proposerAddressForSimulation = proposerAddress;
503
- }
504
546
  addRequest(request) {
505
547
  this.requests.push(request);
506
548
  }
507
549
  getCurrentL2Slot() {
508
- return this.epochCache.getEpochAndSlotNow().slot;
550
+ return this.epochCache.getSlotNow();
509
551
  }
510
552
  /**
511
553
  * Clears all pending requests without sending them.
@@ -544,7 +586,7 @@ export class SequencerPublisher {
544
586
  // Get the transaction requests
545
587
  const l1Requests = requestsToAnalyze.map((r)=>r.request);
546
588
  // Start the analysis
547
- const analysisId = await this.l1FeeAnalyzer.startAnalysis(l2SlotNumber, gasLimit > 0n ? gasLimit : SequencerPublisher.PROPOSE_GAS_GUESS, l1Requests, blobConfig, onComplete);
589
+ const analysisId = await this.l1FeeAnalyzer.startAnalysis(l2SlotNumber, gasLimit > 0n ? gasLimit : MAX_L1_TX_LIMIT, l1Requests, blobConfig, onComplete);
548
590
  this.log.info('Started L1 fee analysis', {
549
591
  analysisId,
550
592
  l2SlotNumber: l2SlotNumber.toString(),
@@ -558,11 +600,15 @@ export class SequencerPublisher {
558
600
  }
559
601
  /**
560
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.
561
607
  * @returns one of:
562
608
  * - A receipt and stats if the tx succeeded
563
609
  * - a receipt and errorMsg if it failed on L1
564
610
  * - undefined if no valid requests are found OR the tx failed to send.
565
- */ async sendRequests() {
611
+ */ async sendRequests(targetSlot) {
566
612
  const requestsToProcess = [
567
613
  ...this.requests
568
614
  ];
@@ -570,10 +616,9 @@ export class SequencerPublisher {
570
616
  if (this.interrupted || requestsToProcess.length === 0) {
571
617
  return undefined;
572
618
  }
573
- const currentL2Slot = this.getCurrentL2Slot();
619
+ const currentL2Slot = targetSlot ?? this.getCurrentL2Slot();
574
620
  this.log.debug(`Sending requests on L2 slot ${currentL2Slot}`);
575
621
  const validRequests = requestsToProcess.filter((request)=>request.lastValidL2Slot >= currentL2Slot);
576
- const validActions = validRequests.map((x)=>x.action);
577
622
  const expiredActions = requestsToProcess.filter((request)=>request.lastValidL2Slot < currentL2Slot).map((x)=>x.action);
578
623
  if (validRequests.length !== requestsToProcess.length) {
579
624
  this.log.warn(`Some requests were expired for slot ${currentL2Slot}`, {
@@ -591,40 +636,53 @@ export class SequencerPublisher {
591
636
  this.log.debug(`No valid requests to send`);
592
637
  return undefined;
593
638
  }
594
- // @note - we can only have one blob config per bundle
595
- // find requests with gas and blob configs
596
- // See https://github.com/AztecProtocol/aztec-packages/issues/11513
597
- const gasConfigs = requestsToProcess.filter((request)=>request.gasConfig).map((request)=>request.gasConfig);
598
- const blobConfigs = requestsToProcess.filter((request)=>request.blobConfig).map((request)=>request.blobConfig);
599
- if (blobConfigs.length > 1) {
600
- throw new Error('Multiple blob configs found');
601
- }
602
- const blobConfig = blobConfigs[0];
603
- // Merge gasConfigs. Yields the sum of gasLimits, and the earliest txTimeoutAt, or undefined if no gasConfig sets them.
604
- const gasLimits = gasConfigs.map((g)=>g?.gasLimit).filter((g)=>g !== undefined);
605
- const gasLimit = gasLimits.length > 0 ? sumBigint(gasLimits) : undefined; // sum
639
+ // Collect earliest txTimeoutAt across all requests.
640
+ const gasConfigs = validRequests.filter((request)=>request.gasConfig).map((request)=>request.gasConfig);
606
641
  const txTimeoutAts = gasConfigs.map((g)=>g?.txTimeoutAt).filter((g)=>g !== undefined);
607
- const txTimeoutAt = txTimeoutAts.length > 0 ? new Date(Math.min(...txTimeoutAts.map((g)=>g.getTime()))) : undefined; // earliest
608
- const txConfig = {
609
- gasLimit,
610
- txTimeoutAt
611
- };
642
+ const txTimeoutAt = txTimeoutAts.length > 0 ? new Date(Math.min(...txTimeoutAts.map((g)=>g.getTime()))) : undefined;
612
643
  // Sort the requests so that proposals always go first
613
644
  // This ensures the committee gets precomputed correctly
614
645
  validRequests.sort((a, b)=>compareActions(a.action, b.action));
615
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
+ };
616
667
  this.log.debug('Forwarding transactions', {
617
- validRequests: validRequests.map((request)=>request.action),
668
+ requests: requests.map((request)=>request.action),
618
669
  txConfig
619
670
  });
620
- const result = await Multicall3.forward(validRequests.map((request)=>request.request), this.l1TxUtils, txConfig, blobConfig, this.rollupContract.address, this.log);
621
- 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
+ ];
622
680
  return {
623
681
  result,
624
682
  expiredActions,
625
- sentActions: validActions,
683
+ sentActions: requests.map((x)=>x.action),
626
684
  successfulActions,
627
- failedActions
685
+ failedActions: allFailedActions
628
686
  };
629
687
  } catch (err) {
630
688
  const viemError = formatViemError(err);
@@ -638,49 +696,176 @@ export class SequencerPublisher {
638
696
  }
639
697
  }
640
698
  }
641
- callbackBundledTransactions(requests, result) {
642
- const actionsListStr = requests.map((r)=>r.action).join(', ');
643
- if (result instanceof FormattedViemError) {
644
- this.log.error(`Failed to publish bundled transactions (${actionsListStr})`, result);
645
- return {
646
- failedActions: requests.map((r)=>r.action)
647
- };
648
- } else {
649
- this.log.verbose(`Published bundled transactions (${actionsListStr})`, {
650
- result,
651
- 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
652
707
  });
653
- const successfulActions = [];
654
- const failedActions = [];
655
- for (const request of requests){
656
- if (request.checkSuccess(request.request, result)) {
657
- successfulActions.push(request.action);
658
- } else {
659
- 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()
660
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
+ if (this.interrupted) {
805
+ return undefined;
806
+ }
807
+ const sleepMs = submitAfterMs - this.dateProvider.now();
808
+ if (sleepMs > 0) {
809
+ this.log.debug(`Sleeping ${sleepMs}ms before sending requests`, {
810
+ targetSlot,
811
+ submitAfterMs
812
+ });
813
+ await this.interruptibleSleep.sleep(sleepMs);
814
+ }
815
+ if (this.interrupted) {
816
+ return undefined;
817
+ }
818
+ return this.sendRequests(targetSlot);
819
+ }
820
+ callbackBundledTransactions(requests, result) {
821
+ const actionsListStr = requests.map((r)=>r.action).join(', ');
822
+ this.log.verbose(`Published bundled transactions (${actionsListStr})`, {
823
+ result,
824
+ requests: requests.map((r)=>({
825
+ ...r,
826
+ // Avoid logging large blob data
827
+ blobConfig: r.blobConfig ? {
828
+ ...r.blobConfig,
829
+ blobs: r.blobConfig.blobs.map((b)=>({
830
+ size: trimmedBytesLength(b)
831
+ }))
832
+ } : undefined
833
+ }))
834
+ });
835
+ const successfulActions = [];
836
+ const failedActions = [];
837
+ for (const request of requests){
838
+ if (request.checkSuccess(request.request, result)) {
839
+ successfulActions.push(request.action);
840
+ } else {
841
+ failedActions.push(request.action);
661
842
  }
662
- return {
663
- successfulActions,
664
- failedActions
665
- };
666
843
  }
844
+ return {
845
+ successfulActions,
846
+ failedActions
847
+ };
667
848
  }
668
849
  /**
669
- * @notice Will call `canProposeAtNextEthBlock` to make sure that it is possible to propose
850
+ * @notice Will call `canProposeAt` to make sure that it is possible to propose
670
851
  * @param tipArchive - The archive to check
671
852
  * @returns The slot and block number if it is possible to propose, undefined otherwise
672
- */ canProposeAtNextEthBlock(tipArchive, msgSender, opts = {}) {
853
+ */ async canProposeAt(tipArchive, msgSender, simulationOverridesPlan) {
673
854
  // TODO: #14291 - should loop through multiple keys to check if any of them can propose
674
- const ignoredErrors = [
855
+ // These errors are expected when we cannot actually propose right now — usually because our
856
+ // local view of the chain is ahead of L1 (proposed parent hasn't landed yet, or someone
857
+ // else has just landed the slot, or the archive override doesn't match). We log a warn and
858
+ // skip the proposal; we do NOT treat these as bugs.
859
+ const expectedErrors = [
675
860
  'SlotAlreadyInChain',
676
861
  'InvalidProposer',
677
862
  'InvalidArchive'
678
863
  ];
679
- return this.rollupContract.canProposeAtNextEthBlock(tipArchive.toBuffer(), msgSender.toString(), Number(this.ethereumSlotDuration), {
680
- forcePendingCheckpointNumber: opts.forcePendingCheckpointNumber
681
- }).catch((err)=>{
682
- if (err instanceof FormattedViemError && ignoredErrors.find((e)=>err.message.includes(e))) {
683
- this.log.warn(`Failed canProposeAtTime check with ${ignoredErrors.find((e)=>err.message.includes(e))}`, {
864
+ const slotOffset = this.aztecSlotDuration;
865
+ const nextL1SlotTs = this.getNextL1SlotTimestamp() + slotOffset;
866
+ return this.rollupContract.canProposeAt(tipArchive.toBuffer(), msgSender.toString(), nextL1SlotTs, await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan)).catch((err)=>{
867
+ if (err instanceof FormattedViemError && expectedErrors.find((e)=>err.message.includes(e))) {
868
+ this.log.warn(`Failed canProposeAtTime check with ${expectedErrors.find((e)=>err.message.includes(e))}`, {
684
869
  error: err.message
685
870
  });
686
871
  } else {
@@ -694,22 +879,23 @@ export class SequencerPublisher {
694
879
  * @dev This is a convenience function that can be used by the sequencer to validate a "partial" header.
695
880
  * It will throw if the block header is invalid.
696
881
  * @param header - The block header to validate
697
- */ async validateBlockHeader(header, opts) {
882
+ */ async validateBlockHeader(header, simulationOverridesPlan) {
698
883
  const flags = {
699
884
  ignoreDA: true,
700
885
  ignoreSignatures: true
701
886
  };
702
887
  const args = [
703
888
  header.toViem(),
704
- CommitteeAttestationsAndSigners.empty().getPackedAttestations(),
889
+ CommitteeAttestationsAndSigners.packAttestations([]),
705
890
  [],
706
891
  Signature.empty().toViemSignature(),
707
892
  `0x${'0'.repeat(64)}`,
708
893
  header.blobsHash.toString(),
709
894
  flags
710
895
  ];
711
- const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);
712
- const stateOverrides = await this.rollupContract.makePendingCheckpointNumberOverride(opts?.forcePendingCheckpointNumber);
896
+ const l1Constants = this.epochCache.getL1Constants();
897
+ const ts = getLastL1SlotTimestampForL2Slot(header.slotNumber, l1Constants);
898
+ const stateOverrides = await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan);
713
899
  let balance = 0n;
714
900
  if (this.config.fishermanMode) {
715
901
  // In fisherman mode, we can't know where the proposer is publishing from
@@ -731,7 +917,7 @@ export class SequencerPublisher {
731
917
  }),
732
918
  from: MULTI_CALL_3_ADDRESS
733
919
  }, {
734
- time: ts + 1n
920
+ time: ts
735
921
  }, stateOverrides);
736
922
  this.log.debug(`Simulated validateHeader`);
737
923
  }
@@ -761,8 +947,12 @@ export class SequencerPublisher {
761
947
  ...logData,
762
948
  request
763
949
  });
950
+ const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
764
951
  try {
765
- const { gasUsed } = await this.l1TxUtils.simulate(request, undefined, undefined, ErrorsAbi);
952
+ const { gasUsed } = await this.l1TxUtils.simulate(request, undefined, undefined, mergeAbis([
953
+ request.abi ?? [],
954
+ ErrorsAbi
955
+ ]));
766
956
  this.log.verbose(`Simulation for invalidate checkpoint ${checkpointNumber} succeeded`, {
767
957
  ...logData,
768
958
  request,
@@ -773,20 +963,21 @@ export class SequencerPublisher {
773
963
  gasUsed,
774
964
  checkpointNumber,
775
965
  forcePendingCheckpointNumber: CheckpointNumber(checkpointNumber - 1),
966
+ lastArchive: validationResult.checkpoint.lastArchive,
776
967
  reason
777
968
  };
778
969
  } catch (err) {
779
970
  const viemError = formatViemError(err);
780
971
  // If the error is due to the checkpoint not being in the pending chain, and it was indeed removed by someone else,
781
972
  // we can safely ignore it and return undefined so we go ahead with checkpoint building.
782
- if (viemError.message?.includes('Rollup__BlockNotInPendingChain')) {
973
+ if (viemError.message?.includes('Rollup__CheckpointNotInPendingChain')) {
783
974
  this.log.verbose(`Simulation for invalidate checkpoint ${checkpointNumber} failed due to checkpoint not being in pending chain`, {
784
975
  ...logData,
785
976
  request,
786
977
  error: viemError.message
787
978
  });
788
- const latestPendingCheckpointNumber = await this.rollupContract.getCheckpointNumber();
789
- if (latestPendingCheckpointNumber < checkpointNumber) {
979
+ const latestProposedCheckpointNumber = await this.rollupContract.getCheckpointNumber();
980
+ if (latestProposedCheckpointNumber < checkpointNumber) {
790
981
  this.log.verbose(`Checkpoint ${checkpointNumber} has already been invalidated`, {
791
982
  ...logData
792
983
  });
@@ -800,6 +991,27 @@ export class SequencerPublisher {
800
991
  }
801
992
  // Otherwise, throw. We cannot build the next checkpoint if we cannot invalidate the previous one.
802
993
  this.log.error(`Simulation for invalidate checkpoint ${checkpointNumber} failed`, viemError, logData);
994
+ this.backupFailedTx({
995
+ id: keccak256(request.data),
996
+ failureType: 'simulation',
997
+ request: {
998
+ to: request.to,
999
+ data: request.data,
1000
+ value: request.value?.toString()
1001
+ },
1002
+ l1BlockNumber: l1BlockNumber.toString(),
1003
+ error: {
1004
+ message: viemError.message,
1005
+ name: viemError.name
1006
+ },
1007
+ context: {
1008
+ actions: [
1009
+ `invalidate-${reason}`
1010
+ ],
1011
+ checkpointNumber,
1012
+ sender: this.getSenderAddress().toString()
1013
+ }
1014
+ });
803
1015
  throw new Error(`Failed to simulate invalidate checkpoint ${checkpointNumber}`, {
804
1016
  cause: viemError
805
1017
  });
@@ -815,7 +1027,7 @@ export class SequencerPublisher {
815
1027
  reason
816
1028
  };
817
1029
  this.log.debug(`Building invalidate checkpoint ${checkpoint.checkpointNumber} request`, logData);
818
- const attestationsAndSigners = new CommitteeAttestationsAndSigners(validationResult.attestations).getPackedAttestations();
1030
+ const attestationsAndSigners = CommitteeAttestationsAndSigners.packAttestations(validationResult.attestations);
819
1031
  if (reason === 'invalid-attestation') {
820
1032
  return this.rollupContract.buildInvalidateBadAttestationRequest(checkpoint.checkpointNumber, attestationsAndSigners, committee, validationResult.invalidIndex);
821
1033
  } else if (reason === 'insufficient-attestations') {
@@ -825,42 +1037,7 @@ export class SequencerPublisher {
825
1037
  throw new Error(`Unknown reason for invalidation`);
826
1038
  }
827
1039
  }
828
- /** Simulates `propose` to make sure that the checkpoint is valid for submission */ async validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, options) {
829
- const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);
830
- // TODO(palla/mbps): This should not be needed, there's no flow where we propose with zero attestations. Or is there?
831
- // If we have no attestations, we still need to provide the empty attestations
832
- // so that the committee is recalculated correctly
833
- // const ignoreSignatures = attestationsAndSigners.attestations.length === 0;
834
- // if (ignoreSignatures) {
835
- // const { committee } = await this.epochCache.getCommittee(block.header.globalVariables.slotNumber);
836
- // if (!committee) {
837
- // this.log.warn(`No committee found for slot ${block.header.globalVariables.slotNumber}`);
838
- // throw new Error(`No committee found for slot ${block.header.globalVariables.slotNumber}`);
839
- // }
840
- // attestationsAndSigners.attestations = committee.map(committeeMember =>
841
- // CommitteeAttestation.fromAddress(committeeMember),
842
- // );
843
- // }
844
- const blobFields = checkpoint.toBlobFields();
845
- const blobs = getBlobsPerL1Block(blobFields);
846
- const blobInput = getPrefixedEthBlobCommitments(blobs);
847
- const args = [
848
- {
849
- header: checkpoint.header.toViem(),
850
- archive: toHex(checkpoint.archive.root.toBuffer()),
851
- oracleInput: {
852
- feeAssetPriceModifier: 0n
853
- }
854
- },
855
- attestationsAndSigners.getPackedAttestations(),
856
- attestationsAndSigners.getSigners().map((signer)=>signer.toString()),
857
- attestationsAndSignersSignature.toViemSignature(),
858
- blobInput
859
- ];
860
- await this.simulateProposeTx(args, ts, options);
861
- return ts;
862
- }
863
- async enqueueCastSignalHelper(slotNumber, timestamp, signalType, payload, base, signerAddress, signer) {
1040
+ async enqueueCastSignalHelper(slotNumber, signalType, payload, base, signerAddress, signer) {
864
1041
  if (this.lastActions[signalType] && this.lastActions[signalType] === slotNumber) {
865
1042
  this.log.debug(`Skipping duplicate vote cast signal ${signalType} for slot ${slotNumber}`);
866
1043
  return false;
@@ -880,10 +1057,28 @@ export class SequencerPublisher {
880
1057
  if (roundInfo.lastSignalSlot >= slotNumber) {
881
1058
  return false;
882
1059
  }
883
- if (await this.isPayloadEmpty(payload)) {
1060
+ if (await base.isPayloadEmpty(payload)) {
884
1061
  this.log.warn(`Skipping vote cast for payload with empty code`);
885
1062
  return false;
886
1063
  }
1064
+ // Skip signaling if there is already a live (non-terminal) Governance proposal for this
1065
+ // payload. This is intentionally not cached: a previously-live proposal may transition to
1066
+ // a terminal state (Dropped/Rejected/Expired/Executed), at which point we may want to re-signal
1067
+ // the same payload in a future round.
1068
+ let proposed = false;
1069
+ try {
1070
+ proposed = await base.hasActiveProposalWithPayload(payload.toString());
1071
+ } catch (err) {
1072
+ // We deliberately swallow the error and proceed to signal. Failing closed (skipping the
1073
+ // signal) on transient RPC errors would let a flaky L1 endpoint silence governance
1074
+ // participation entirely; failing open at worst produces a duplicate signal that the
1075
+ // contract will simply count alongside others in the round.
1076
+ this.log.error(`Failed to check if payload ${payload} was already proposed (signalling anyway)`, err);
1077
+ }
1078
+ if (proposed) {
1079
+ this.log.info(`Payload ${payload} has a live governance proposal, stopping signals`);
1080
+ return false;
1081
+ }
887
1082
  const cachedLastVote = this.lastActions[signalType];
888
1083
  this.lastActions[signalType] = slotNumber;
889
1084
  const action = signalType;
@@ -894,27 +1089,17 @@ export class SequencerPublisher {
894
1089
  signer: this.l1TxUtils.client.account?.address,
895
1090
  lastValidL2Slot: slotNumber
896
1091
  });
897
- try {
898
- await this.l1TxUtils.simulate(request, {
899
- time: timestamp
900
- }, [], ErrorsAbi);
901
- this.log.debug(`Simulation for ${action} at slot ${slotNumber} succeeded`, {
902
- request
903
- });
904
- } catch (err) {
905
- this.log.error(`Failed simulation for ${action} at slot ${slotNumber} (enqueuing the action anyway)`, err);
906
- // Yes, we enqueue the request anyway, in case there was a bug with the simulation itself
907
- }
908
1092
  // TODO(palla/slash): All votes (governance and slashing) should txTimeoutAt at the end of the slot.
909
1093
  this.addRequest({
910
- gasConfig: {
911
- gasLimit: SequencerPublisher.VOTE_GAS_GUESS
912
- },
913
1094
  action,
914
1095
  request,
915
1096
  lastValidL2Slot: slotNumber,
916
1097
  checkSuccess: (_request, result)=>{
917
- const success = result && result.receipt && result.receipt.status === 'success' && tryExtractEvent(result.receipt.logs, base.address.toString(), EmpireBaseAbi, 'SignalCast');
1098
+ const success = result && extractEventSuccess(result.receipt, {
1099
+ address: base.address.toString(),
1100
+ abi: EmpireBaseAbi,
1101
+ eventName: 'SignalCast'
1102
+ });
918
1103
  const logData = {
919
1104
  ...result,
920
1105
  slotNumber,
@@ -933,68 +1118,20 @@ export class SequencerPublisher {
933
1118
  });
934
1119
  return true;
935
1120
  }
936
- async isPayloadEmpty(payload) {
937
- const key = payload.toString();
938
- const cached = this.isPayloadEmptyCache.get(key);
939
- if (cached) {
940
- return cached;
941
- }
942
- const isEmpty = !await this.l1TxUtils.getCode(payload);
943
- this.isPayloadEmptyCache.set(key, isEmpty);
944
- return isEmpty;
945
- }
946
1121
  /**
947
1122
  * Enqueues a governance castSignal transaction to cast a signal for a given slot number.
948
1123
  * @param slotNumber - The slot number to cast a signal for.
949
- * @param timestamp - The timestamp of the slot to cast a signal for.
950
1124
  * @returns True if the signal was successfully enqueued, false otherwise.
951
- */ enqueueGovernanceCastSignal(governancePayload, slotNumber, timestamp, signerAddress, signer) {
952
- return this.enqueueCastSignalHelper(slotNumber, timestamp, 'governance-signal', governancePayload, this.govProposerContract, signerAddress, signer);
1125
+ */ enqueueGovernanceCastSignal(governancePayload, slotNumber, signerAddress, signer) {
1126
+ return this.enqueueCastSignalHelper(slotNumber, 'governance-signal', governancePayload, this.govProposerContract, signerAddress, signer);
953
1127
  }
954
- /** Enqueues all slashing actions as returned by the slasher client. */ async enqueueSlashingActions(actions, slotNumber, timestamp, signerAddress, signer) {
1128
+ /** Enqueues all slashing actions as returned by the slasher client. */ async enqueueSlashingActions(actions, slotNumber, signerAddress, signer) {
955
1129
  if (actions.length === 0) {
956
1130
  this.log.debug(`No slashing actions to enqueue for slot ${slotNumber}`);
957
1131
  return false;
958
1132
  }
959
1133
  for (const action of actions){
960
1134
  switch(action.type){
961
- case 'vote-empire-payload':
962
- {
963
- if (this.slashingProposerContract?.type !== 'empire') {
964
- this.log.error('Cannot vote for empire payload on non-empire slashing contract');
965
- break;
966
- }
967
- this.log.debug(`Enqueuing slashing vote for payload ${action.payload} at slot ${slotNumber}`, {
968
- signerAddress
969
- });
970
- await this.enqueueCastSignalHelper(slotNumber, timestamp, 'empire-slashing-signal', action.payload, this.slashingProposerContract, signerAddress, signer);
971
- break;
972
- }
973
- case 'create-empire-payload':
974
- {
975
- this.log.debug(`Enqueuing slashing create payload at slot ${slotNumber}`, {
976
- slotNumber,
977
- signerAddress
978
- });
979
- const request = this.slashFactoryContract.buildCreatePayloadRequest(action.data);
980
- await this.simulateAndEnqueueRequest('create-empire-payload', request, (receipt)=>!!this.slashFactoryContract.tryExtractSlashPayloadCreatedEvent(receipt.logs), slotNumber, timestamp);
981
- break;
982
- }
983
- case 'execute-empire-payload':
984
- {
985
- this.log.debug(`Enqueuing slashing execute payload at slot ${slotNumber}`, {
986
- slotNumber,
987
- signerAddress
988
- });
989
- if (this.slashingProposerContract?.type !== 'empire') {
990
- this.log.error('Cannot execute slashing payload on non-empire slashing contract');
991
- return false;
992
- }
993
- const empireSlashingProposer = this.slashingProposerContract;
994
- const request = empireSlashingProposer.buildExecuteRoundRequest(action.round);
995
- await this.simulateAndEnqueueRequest('execute-empire-payload', request, (receipt)=>!!empireSlashingProposer.tryExtractPayloadSubmittedEvent(receipt.logs), slotNumber, timestamp);
996
- break;
997
- }
998
1135
  case 'vote-offenses':
999
1136
  {
1000
1137
  this.log.debug(`Enqueuing slashing vote for ${action.votes.length} votes at slot ${slotNumber}`, {
@@ -1003,14 +1140,17 @@ export class SequencerPublisher {
1003
1140
  votesCount: action.votes.length,
1004
1141
  signerAddress
1005
1142
  });
1006
- if (this.slashingProposerContract?.type !== 'tally') {
1007
- this.log.error('Cannot vote for slashing offenses on non-tally slashing contract');
1143
+ if (!this.slashingProposerContract) {
1144
+ this.log.error('No slashing proposer contract available');
1008
1145
  return false;
1009
1146
  }
1010
- const tallySlashingProposer = this.slashingProposerContract;
1011
1147
  const votes = bufferToHex(encodeSlashConsensusVotes(action.votes));
1012
- const request = await tallySlashingProposer.buildVoteRequestFromSigner(votes, slotNumber, signer);
1013
- await this.simulateAndEnqueueRequest('vote-offenses', request, (receipt)=>!!tallySlashingProposer.tryExtractVoteCastEvent(receipt.logs), slotNumber, timestamp);
1148
+ const request = await this.slashingProposerContract.buildVoteRequestFromSigner(votes, slotNumber, signer);
1149
+ this.enqueueRequest('vote-offenses', request, {
1150
+ address: this.slashingProposerContract.address.toString(),
1151
+ abi: SlashingProposerAbi,
1152
+ eventName: 'VoteCast'
1153
+ }, slotNumber);
1014
1154
  break;
1015
1155
  }
1016
1156
  case 'execute-slash':
@@ -1020,13 +1160,16 @@ export class SequencerPublisher {
1020
1160
  round: action.round,
1021
1161
  signerAddress
1022
1162
  });
1023
- if (this.slashingProposerContract?.type !== 'tally') {
1024
- this.log.error('Cannot execute slashing offenses on non-tally slashing contract');
1163
+ if (!this.slashingProposerContract) {
1164
+ this.log.error('No slashing proposer contract available');
1025
1165
  return false;
1026
1166
  }
1027
- const tallySlashingProposer = this.slashingProposerContract;
1028
- const request = tallySlashingProposer.buildExecuteRoundRequest(action.round, action.committees);
1029
- await this.simulateAndEnqueueRequest('execute-slash', request, (receipt)=>!!tallySlashingProposer.tryExtractRoundExecutedEvent(receipt.logs), slotNumber, timestamp);
1167
+ const executeRequest = this.slashingProposerContract.buildExecuteRoundRequest(action.round, action.committees);
1168
+ this.enqueueRequest('execute-slash', executeRequest, {
1169
+ address: this.slashingProposerContract.address.toString(),
1170
+ abi: SlashingProposerAbi,
1171
+ eventName: 'RoundExecuted'
1172
+ }, slotNumber);
1030
1173
  break;
1031
1174
  }
1032
1175
  default:
@@ -1038,63 +1181,50 @@ export class SequencerPublisher {
1038
1181
  }
1039
1182
  return true;
1040
1183
  }
1041
- /** Simulates and enqueues a proposal for a checkpoint on L1 */ async enqueueProposeCheckpoint(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, opts = {}) {
1184
+ /** Enqueues a proposal for a checkpoint on L1 */ async enqueueProposeCheckpoint(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, opts = {}) {
1042
1185
  const checkpointHeader = checkpoint.header;
1043
1186
  const blobFields = checkpoint.toBlobFields();
1044
- const blobs = getBlobsPerL1Block(blobFields);
1187
+ const blobs = await getBlobsPerL1Block(blobFields);
1045
1188
  const proposeTxArgs = {
1046
1189
  header: checkpointHeader,
1047
1190
  archive: checkpoint.archive.root.toBuffer(),
1048
1191
  blobs,
1049
1192
  attestationsAndSigners,
1050
- attestationsAndSignersSignature
1193
+ attestationsAndSignersSignature,
1194
+ feeAssetPriceModifier: checkpoint.feeAssetPriceModifier
1051
1195
  };
1052
- let ts;
1053
- try {
1054
- // @note This will make sure that we are passing the checks for our header ASSUMING that the data is also made available
1055
- // This means that we can avoid the simulation issues in later checks.
1056
- // By simulation issue, I mean the fact that the block.timestamp is equal to the last block, not the next, which
1057
- // make time consistency checks break.
1058
- // TODO(palla): Check whether we're validating twice, once here and once within addProposeTx, since we call simulateProposeTx in both places.
1059
- ts = await this.validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, opts);
1060
- } catch (err) {
1061
- this.log.error(`Checkpoint validation failed. ${err instanceof Error ? err.message : 'No error message'}`, err, {
1062
- ...checkpoint.getStats(),
1063
- slotNumber: checkpoint.header.slotNumber,
1064
- forcePendingCheckpointNumber: opts.forcePendingCheckpointNumber
1065
- });
1066
- throw err;
1067
- }
1068
1196
  this.log.verbose(`Enqueuing checkpoint propose transaction`, {
1069
1197
  ...checkpoint.toCheckpointInfo(),
1070
- ...opts
1198
+ txTimeoutAt: opts.txTimeoutAt
1199
+ });
1200
+ await this.addProposeTx(checkpoint, proposeTxArgs, {
1201
+ txTimeoutAt: opts.txTimeoutAt
1071
1202
  });
1072
- await this.addProposeTx(checkpoint, proposeTxArgs, opts, ts);
1073
1203
  }
1074
1204
  enqueueInvalidateCheckpoint(request, opts = {}) {
1075
1205
  if (!request) {
1076
1206
  return;
1077
1207
  }
1078
- // We issued the simulation against the rollup contract, so we need to account for the overhead of the multicall3
1079
- const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(request.gasUsed) * 64 / 63)));
1080
1208
  const { gasUsed, checkpointNumber } = request;
1081
1209
  const logData = {
1082
1210
  gasUsed,
1083
1211
  checkpointNumber,
1084
- gasLimit,
1085
1212
  opts
1086
1213
  };
1087
1214
  this.log.verbose(`Enqueuing invalidate checkpoint request`, logData);
1088
1215
  this.addRequest({
1089
1216
  action: `invalidate-by-${request.reason}`,
1090
1217
  request: request.request,
1091
- gasConfig: {
1092
- gasLimit,
1218
+ gasConfig: opts.txTimeoutAt ? {
1093
1219
  txTimeoutAt: opts.txTimeoutAt
1094
- },
1220
+ } : undefined,
1095
1221
  lastValidL2Slot: SlotNumber(this.getCurrentL2Slot() + 2),
1096
1222
  checkSuccess: (_req, result)=>{
1097
- const success = result && result.receipt && result.receipt.status === 'success' && tryExtractEvent(result.receipt.logs, this.rollupContract.address, RollupAbi, 'CheckpointInvalidated');
1223
+ const success = result && extractEventSuccess(result.receipt, {
1224
+ address: this.rollupContract.address,
1225
+ abi: RollupAbi,
1226
+ eventName: 'CheckpointInvalidated'
1227
+ });
1098
1228
  if (!success) {
1099
1229
  this.log.warn(`Invalidate checkpoint ${request.checkpointNumber} failed`, {
1100
1230
  ...result,
@@ -1110,57 +1240,36 @@ export class SequencerPublisher {
1110
1240
  }
1111
1241
  });
1112
1242
  }
1113
- async simulateAndEnqueueRequest(action, request, checkSuccess, slotNumber, timestamp) {
1114
- const logData = {
1115
- slotNumber,
1116
- timestamp,
1117
- gasLimit: undefined
1118
- };
1243
+ /**
1244
+ * Dedup-checked enqueue helper for actions that are simulated at bundle-send time rather
1245
+ * than at enqueue time. Validates the (action, slot) dedup key, sets `lastActions`, and
1246
+ * enqueues without a gasLimit so the bundle simulate sets the only gasLimit that matters.
1247
+ */ enqueueRequest(action, request, eventOpts, slotNumber) {
1119
1248
  if (this.lastActions[action] && this.lastActions[action] === slotNumber) {
1120
1249
  this.log.debug(`Skipping duplicate action ${action} for slot ${slotNumber}`);
1121
1250
  return false;
1122
1251
  }
1123
1252
  const cachedLastActionSlot = this.lastActions[action];
1124
1253
  this.lastActions[action] = slotNumber;
1125
- this.log.debug(`Simulating ${action} for slot ${slotNumber}`, logData);
1126
- let gasUsed;
1127
- try {
1128
- ({ gasUsed } = await this.l1TxUtils.simulate(request, {
1129
- time: timestamp
1130
- }, [], ErrorsAbi)); // TODO(palla/slash): Check the timestamp logic
1131
- this.log.verbose(`Simulation for ${action} succeeded`, {
1132
- ...logData,
1133
- request,
1134
- gasUsed
1135
- });
1136
- } catch (err) {
1137
- const viemError = formatViemError(err);
1138
- this.log.error(`Simulation for ${action} at ${slotNumber} failed`, viemError, logData);
1139
- return false;
1140
- }
1141
- // We issued the simulation against the rollup contract, so we need to account for the overhead of the multicall3
1142
- const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(gasUsed) * 64 / 63)));
1143
- logData.gasLimit = gasLimit;
1144
- this.log.debug(`Enqueuing ${action}`, logData);
1254
+ this.log.debug(`Enqueuing ${action}`, {
1255
+ slotNumber
1256
+ });
1145
1257
  this.addRequest({
1146
1258
  action,
1147
1259
  request,
1148
- gasConfig: {
1149
- gasLimit
1150
- },
1151
1260
  lastValidL2Slot: slotNumber,
1152
- checkSuccess: (_req, result)=>{
1153
- const success = result && result.receipt && result.receipt.status === 'success' && checkSuccess(result.receipt);
1261
+ checkSuccess: (_request, result)=>{
1262
+ const success = result && extractEventSuccess(result.receipt, eventOpts);
1154
1263
  if (!success) {
1155
1264
  this.log.warn(`Action ${action} at ${slotNumber} failed`, {
1156
1265
  ...result,
1157
- ...logData
1266
+ slotNumber
1158
1267
  });
1159
1268
  this.lastActions[action] = cachedLastActionSlot;
1160
1269
  } else {
1161
1270
  this.log.info(`Action ${action} at ${slotNumber} succeeded`, {
1162
1271
  ...result,
1163
- ...logData
1272
+ slotNumber
1164
1273
  });
1165
1274
  }
1166
1275
  return !!success;
@@ -1175,13 +1284,14 @@ export class SequencerPublisher {
1175
1284
  * A call to `restart` is required before you can continue publishing.
1176
1285
  */ interrupt() {
1177
1286
  this.interrupted = true;
1287
+ this.interruptibleSleep.interrupt();
1178
1288
  this.l1TxUtils.interrupt();
1179
1289
  }
1180
1290
  /** Restarts the publisher after calling `interrupt`. */ restart() {
1181
1291
  this.interrupted = false;
1182
1292
  this.l1TxUtils.restart();
1183
1293
  }
1184
- async prepareProposeTx(encodedData, timestamp, options) {
1294
+ async prepareProposeTx(encodedData) {
1185
1295
  const kzg = Blob.getViemKzgInstance();
1186
1296
  const blobInput = getPrefixedEthBlobCommitments(encodedData.blobs);
1187
1297
  this.log.debug('Validating blob input', {
@@ -1195,7 +1305,11 @@ export class SequencerPublisher {
1195
1305
  blobEvaluationGas = BigInt(encodedData.blobs.length) * 21_000n;
1196
1306
  this.log.debug(`Using fixed blob evaluation gas estimate in fisherman mode: ${blobEvaluationGas}`);
1197
1307
  } else {
1198
- // Normal mode - use estimateGas with blob inputs
1308
+ // We call validateBlobs via estimateGas with real blob+kzg sidecars as a consistency check
1309
+ // that our locally-built blob commitments match the blob data. The bundle simulate at send
1310
+ // time uses eth_simulateV1, which cannot carry blob inputs, so the rollup's on-chain blob
1311
+ // check is forced off there — making this the only pre-flight detector of a commitment/data
1312
+ // mismatch. The returned gas estimate is stashed on the request for the bundle path to read.
1199
1313
  blobEvaluationGas = await this.l1TxUtils.estimateGas(this.getSenderAddress().toString(), {
1200
1314
  to: this.rollupContract.address,
1201
1315
  data: encodeFunctionData({
@@ -1208,10 +1322,38 @@ export class SequencerPublisher {
1208
1322
  }, {}, {
1209
1323
  blobs: encodedData.blobs.map((b)=>b.data),
1210
1324
  kzg
1211
- }).catch((err)=>{
1212
- const { message, metaMessages } = formatViemError(err);
1213
- this.log.error(`Failed to validate blobs`, message, {
1214
- metaMessages
1325
+ }).catch(async (err)=>{
1326
+ const viemError = formatViemError(err);
1327
+ this.log.error(`Failed to validate blobs`, viemError.message, {
1328
+ metaMessages: viemError.metaMessages
1329
+ });
1330
+ const validateBlobsData = encodeFunctionData({
1331
+ abi: RollupAbi,
1332
+ functionName: 'validateBlobs',
1333
+ args: [
1334
+ blobInput
1335
+ ]
1336
+ });
1337
+ const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
1338
+ this.backupFailedTx({
1339
+ id: keccak256(validateBlobsData),
1340
+ failureType: 'simulation',
1341
+ request: {
1342
+ to: this.rollupContract.address,
1343
+ data: validateBlobsData
1344
+ },
1345
+ blobData: encodedData.blobs.map((b)=>toHex(b.data)),
1346
+ l1BlockNumber: l1BlockNumber.toString(),
1347
+ error: {
1348
+ message: viemError.message,
1349
+ name: viemError.name
1350
+ },
1351
+ context: {
1352
+ actions: [
1353
+ 'validate-blobs'
1354
+ ],
1355
+ sender: this.getSenderAddress().toString()
1356
+ }
1215
1357
  });
1216
1358
  throw new Error('Failed to validate blobs');
1217
1359
  });
@@ -1222,8 +1364,7 @@ export class SequencerPublisher {
1222
1364
  header: encodedData.header.toViem(),
1223
1365
  archive: toHex(encodedData.archive),
1224
1366
  oracleInput: {
1225
- // We are currently not modifying these. See #9963
1226
- feeAssetPriceModifier: 0n
1367
+ feeAssetPriceModifier: encodedData.feeAssetPriceModifier
1227
1368
  }
1228
1369
  },
1229
1370
  encodedData.attestationsAndSigners.getPackedAttestations(),
@@ -1231,88 +1372,23 @@ export class SequencerPublisher {
1231
1372
  encodedData.attestationsAndSignersSignature.toViemSignature(),
1232
1373
  blobInput
1233
1374
  ];
1234
- const { rollupData, simulationResult } = await this.simulateProposeTx(args, timestamp, options);
1235
- return {
1236
- args,
1237
- blobEvaluationGas,
1238
- rollupData,
1239
- simulationResult
1240
- };
1241
- }
1242
- /**
1243
- * Simulates the propose tx with eth_simulateV1
1244
- * @param args - The propose tx args
1245
- * @param timestamp - The timestamp to simulate proposal at
1246
- * @returns The simulation result
1247
- */ async simulateProposeTx(args, timestamp, options) {
1248
1375
  const rollupData = encodeFunctionData({
1249
1376
  abi: RollupAbi,
1250
1377
  functionName: 'propose',
1251
1378
  args
1252
1379
  });
1253
- // override the pending checkpoint number if requested
1254
- const forcePendingCheckpointNumberStateDiff = (options.forcePendingCheckpointNumber !== undefined ? await this.rollupContract.makePendingCheckpointNumberOverride(options.forcePendingCheckpointNumber) : []).flatMap((override)=>override.stateDiff ?? []);
1255
- const stateOverrides = [
1256
- {
1257
- address: this.rollupContract.address,
1258
- // @note we override checkBlob to false since blobs are not part simulate()
1259
- stateDiff: [
1260
- {
1261
- slot: toPaddedHex(RollupContract.checkBlobStorageSlot, true),
1262
- value: toPaddedHex(0n, true)
1263
- },
1264
- ...forcePendingCheckpointNumberStateDiff
1265
- ]
1266
- }
1267
- ];
1268
- // In fisherman mode, simulate as the proposer but with sufficient balance
1269
- if (this.proposerAddressForSimulation) {
1270
- stateOverrides.push({
1271
- address: this.proposerAddressForSimulation.toString(),
1272
- balance: 10n * WEI_CONST * WEI_CONST
1273
- });
1274
- }
1275
- const simulationResult = await this.l1TxUtils.simulate({
1276
- to: this.rollupContract.address,
1277
- data: rollupData,
1278
- gas: SequencerPublisher.PROPOSE_GAS_GUESS,
1279
- ...this.proposerAddressForSimulation && {
1280
- from: this.proposerAddressForSimulation.toString()
1281
- }
1282
- }, {
1283
- // @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp
1284
- time: timestamp + 1n,
1285
- // @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit so we increase here
1286
- gasLimit: SequencerPublisher.PROPOSE_GAS_GUESS * 2n
1287
- }, stateOverrides, RollupAbi, {
1288
- // @note fallback gas estimate to use if the node doesn't support simulation API
1289
- fallbackGasEstimate: SequencerPublisher.PROPOSE_GAS_GUESS
1290
- }).catch((err)=>{
1291
- // In fisherman mode, we expect ValidatorSelection__MissingProposerSignature since fisherman doesn't have proposer signature
1292
- const viemError = formatViemError(err);
1293
- if (this.config.fishermanMode && viemError.message?.includes('ValidatorSelection__MissingProposerSignature')) {
1294
- this.log.debug(`Ignoring expected ValidatorSelection__MissingProposerSignature error in fisherman mode`);
1295
- // Return a minimal simulation result with the fallback gas estimate
1296
- return {
1297
- gasUsed: SequencerPublisher.PROPOSE_GAS_GUESS,
1298
- logs: []
1299
- };
1300
- }
1301
- this.log.error(`Failed to simulate propose tx`, viemError);
1302
- throw err;
1303
- });
1304
1380
  return {
1305
- rollupData,
1306
- simulationResult
1381
+ args,
1382
+ blobEvaluationGas,
1383
+ rollupData
1307
1384
  };
1308
1385
  }
1309
- async addProposeTx(checkpoint, encodedData, opts = {}, timestamp) {
1386
+ async addProposeTx(checkpoint, encodedData, opts = {}) {
1310
1387
  const slot = checkpoint.header.slotNumber;
1311
1388
  const timer = new Timer();
1312
1389
  const kzg = Blob.getViemKzgInstance();
1313
- const { rollupData, simulationResult, blobEvaluationGas } = await this.prepareProposeTx(encodedData, timestamp, opts);
1390
+ const { rollupData, blobEvaluationGas } = await this.prepareProposeTx(encodedData);
1314
1391
  const startBlock = await this.l1TxUtils.getBlockNumber();
1315
- const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(simulationResult.gasUsed) * 64 / 63)) + blobEvaluationGas + SequencerPublisher.MULTICALL_OVERHEAD_GAS_GUESS);
1316
1392
  // Send the blobs to the blob client preemptively. This helps in tests where the sequencer mistakingly thinks that the propose
1317
1393
  // tx fails but it does get mined. We make sure that the blobs are sent to the blob client regardless of the tx outcome.
1318
1394
  void Promise.resolve().then(()=>this.blobClient.sendBlobsToFilestore(encodedData.blobs).catch((_err)=>{
@@ -1326,9 +1402,10 @@ export class SequencerPublisher {
1326
1402
  },
1327
1403
  lastValidL2Slot: checkpoint.header.slotNumber,
1328
1404
  gasConfig: {
1329
- ...opts,
1330
- gasLimit
1405
+ txTimeoutAt: opts.txTimeoutAt,
1406
+ gasLimit: undefined
1331
1407
  },
1408
+ blobEvaluationGas,
1332
1409
  blobConfig: {
1333
1410
  blobs: encodedData.blobs.map((b)=>b.data),
1334
1411
  kzg
@@ -1338,7 +1415,11 @@ export class SequencerPublisher {
1338
1415
  return false;
1339
1416
  }
1340
1417
  const { receipt, stats, errorMsg } = result;
1341
- const success = receipt && receipt.status === 'success' && tryExtractEvent(receipt.logs, this.rollupContract.address, RollupAbi, 'CheckpointProposed');
1418
+ const success = extractEventSuccess(receipt, {
1419
+ address: this.rollupContract.address,
1420
+ abi: RollupAbi,
1421
+ eventName: 'CheckpointProposed'
1422
+ });
1342
1423
  if (success) {
1343
1424
  const endBlock = receipt.blockNumber;
1344
1425
  const inclusionBlocks = Number(endBlock - startBlock);
@@ -1375,4 +1456,8 @@ export class SequencerPublisher {
1375
1456
  }
1376
1457
  });
1377
1458
  }
1459
+ /** Returns the timestamp of the next L1 slot boundary after now. */ getNextL1SlotTimestamp() {
1460
+ const l1Constants = this.epochCache.getL1Constants();
1461
+ return getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), l1Constants);
1462
+ }
1378
1463
  }