@aztec/sequencer-client 0.0.1-commit.3e3d0c9cd → 0.0.1-commit.3f5453c7b

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 (73) hide show
  1. package/dest/client/sequencer-client.d.ts +6 -13
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +32 -84
  4. package/dest/config.d.ts +3 -3
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +2 -9
  7. package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
  8. package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
  9. package/dest/global_variable_builder/fee_predictor.js +128 -0
  10. package/dest/global_variable_builder/fee_provider.d.ts +21 -0
  11. package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
  12. package/dest/global_variable_builder/fee_provider.js +58 -0
  13. package/dest/global_variable_builder/global_builder.d.ts +15 -14
  14. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  15. package/dest/global_variable_builder/global_builder.js +16 -51
  16. package/dest/global_variable_builder/index.d.ts +4 -2
  17. package/dest/global_variable_builder/index.d.ts.map +1 -1
  18. package/dest/global_variable_builder/index.js +2 -0
  19. package/dest/publisher/config.d.ts +13 -1
  20. package/dest/publisher/config.d.ts.map +1 -1
  21. package/dest/publisher/config.js +17 -2
  22. package/dest/publisher/sequencer-publisher-factory.d.ts +3 -5
  23. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  24. package/dest/publisher/sequencer-publisher-factory.js +2 -3
  25. package/dest/publisher/sequencer-publisher.d.ts +51 -43
  26. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  27. package/dest/publisher/sequencer-publisher.js +124 -110
  28. package/dest/sequencer/chain_state_overrides.d.ts +25 -0
  29. package/dest/sequencer/chain_state_overrides.d.ts.map +1 -0
  30. package/dest/sequencer/chain_state_overrides.js +39 -0
  31. package/dest/sequencer/checkpoint_proposal_job.d.ts +26 -7
  32. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  33. package/dest/sequencer/checkpoint_proposal_job.js +274 -159
  34. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
  35. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
  36. package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
  37. package/dest/sequencer/checkpoint_voter.d.ts +1 -2
  38. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
  39. package/dest/sequencer/checkpoint_voter.js +2 -5
  40. package/dest/sequencer/events.d.ts +2 -1
  41. package/dest/sequencer/events.d.ts.map +1 -1
  42. package/dest/sequencer/metrics.d.ts +9 -10
  43. package/dest/sequencer/metrics.d.ts.map +1 -1
  44. package/dest/sequencer/metrics.js +23 -20
  45. package/dest/sequencer/sequencer.d.ts +20 -7
  46. package/dest/sequencer/sequencer.d.ts.map +1 -1
  47. package/dest/sequencer/sequencer.js +125 -60
  48. package/dest/sequencer/timetable.d.ts +14 -1
  49. package/dest/sequencer/timetable.d.ts.map +1 -1
  50. package/dest/sequencer/timetable.js +45 -36
  51. package/dest/test/mock_checkpoint_builder.d.ts +4 -8
  52. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  53. package/package.json +27 -27
  54. package/src/client/sequencer-client.ts +44 -110
  55. package/src/config.ts +4 -8
  56. package/src/global_variable_builder/README.md +44 -0
  57. package/src/global_variable_builder/fee_predictor.ts +172 -0
  58. package/src/global_variable_builder/fee_provider.ts +75 -0
  59. package/src/global_variable_builder/global_builder.ts +26 -63
  60. package/src/global_variable_builder/index.ts +3 -1
  61. package/src/publisher/config.ts +32 -0
  62. package/src/publisher/sequencer-publisher-factory.ts +3 -6
  63. package/src/publisher/sequencer-publisher.ts +191 -157
  64. package/src/sequencer/README.md +83 -13
  65. package/src/sequencer/chain_state_overrides.ts +87 -0
  66. package/src/sequencer/checkpoint_proposal_job.ts +353 -186
  67. package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
  68. package/src/sequencer/checkpoint_voter.ts +1 -12
  69. package/src/sequencer/events.ts +1 -1
  70. package/src/sequencer/metrics.ts +29 -25
  71. package/src/sequencer/sequencer.ts +185 -66
  72. package/src/sequencer/timetable.ts +57 -45
  73. package/src/test/mock_checkpoint_builder.ts +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"sequencer-publisher.d.ts","sourceRoot":"","sources":["../../src/publisher/sequencer-publisher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EACL,KAAK,8BAA8B,EAEnC,KAAK,0BAA0B,EAI/B,cAAc,EACd,KAAK,6BAA6B,EAGnC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,mBAAmB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAC1F,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,SAAS,EAEd,KAAK,gBAAgB,EAEtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAA+C,MAAM,uBAAuB,CAAC;AAGxG,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAG/E,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAsB,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAE,YAAY,EAAS,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,KAAK,mBAAmB,EAA6B,MAAM,gBA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AC,OAAO,CAAC,CA8DlB;IAED,+DAA+D;IAClD,wBAAwB,CACnC,UAAU,EAAE,UAAU,EACtB,sBAAsB,EAAE,+BAA+B,EACvD,+BAA+B,EAAE,SAAS,EAC1C,IAAI,GAAE,4BAAiC,GACtC,OAAO,CAAC,IAAI,CAAC,CAkEf;IAEM,2BAA2B,CAChC,OAAO,EAAE,2BAA2B,GAAG,SAAS,EAChD,IAAI,GAAE;QAAE,WAAW,CAAC,EAAE,IAAI,CAAA;KAAO,QA+BlC;YAEa,yBAAyB;IA0EvC;;;;;OAKG;IACI,SAAS,SAIf;IAED,wDAAwD;IACjD,OAAO,SAGb;YAEa,gBAAgB;YAiFhB,iBAAiB;YAoFjB,YAAY;IA0F1B;mHAC+G;IAC/G,OAAO,CAAC,sBAAsB;IAK9B,oEAAoE;IACpE,OAAO,CAAC,sBAAsB;CAI/B"}
@@ -372,12 +372,11 @@ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
372
372
  }
373
373
  var _dec, _dec1, _dec2, _initProto;
374
374
  import { Blob, getBlobsPerL1Block, getPrefixedEthBlobCommitments } from '@aztec/blob-lib';
375
- import { FeeAssetPriceOracle, MULTI_CALL_3_ADDRESS, Multicall3, RollupContract } from '@aztec/ethereum/contracts';
375
+ import { FeeAssetPriceOracle, MULTI_CALL_3_ADDRESS, Multicall3, SimulationOverridesBuilder, 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
378
  import { FormattedViemError, formatViemError, mergeAbis, tryExtractEvent } from '@aztec/ethereum/utils';
379
379
  import { sumBigint } from '@aztec/foundation/bigint';
380
- import { toHex as toPaddedHex } from '@aztec/foundation/bigint-buffer';
381
380
  import { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
382
381
  import { trimmedBytesLength } from '@aztec/foundation/buffer';
383
382
  import { pick } from '@aztec/foundation/collection';
@@ -386,11 +385,13 @@ import { EthAddress } from '@aztec/foundation/eth-address';
386
385
  import { Signature } from '@aztec/foundation/eth-signature';
387
386
  import { createLogger } from '@aztec/foundation/log';
388
387
  import { makeBackoff, retry } from '@aztec/foundation/retry';
388
+ import { InterruptibleSleep } from '@aztec/foundation/sleep';
389
389
  import { bufferToHex } from '@aztec/foundation/string';
390
390
  import { Timer } from '@aztec/foundation/timer';
391
391
  import { EmpireBaseAbi, ErrorsAbi, RollupAbi } from '@aztec/l1-artifacts';
392
392
  import { encodeSlashConsensusVotes } from '@aztec/slasher';
393
393
  import { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
394
+ import { getLastL1SlotTimestampForL2Slot, getNextL1SlotTimestamp } from '@aztec/stdlib/epoch-helpers';
394
395
  import { getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
395
396
  import { encodeFunctionData, keccak256, multicall3Abi, toHex } from 'viem';
396
397
  import { createL1TxFailedStore } from './l1_tx_failed_store/index.js';
@@ -400,9 +401,6 @@ export const Actions = [
400
401
  'invalidate-by-insufficient-attestations',
401
402
  'propose',
402
403
  'governance-signal',
403
- 'empire-slashing-signal',
404
- 'create-empire-payload',
405
- 'execute-empire-payload',
406
404
  'vote-offenses',
407
405
  'execute-slash'
408
406
  ];
@@ -441,11 +439,14 @@ export class SequencerPublisher {
441
439
  payloadProposedCache;
442
440
  log;
443
441
  ethereumSlotDuration;
442
+ aztecSlotDuration;
443
+ /** Date provider for wall-clock time. */ dateProvider;
444
444
  blobClient;
445
445
  /** Address to use for simulations in fisherman mode (actual proposer's address) */ proposerAddressForSimulation;
446
446
  /** Optional callback to obtain a replacement publisher when the current one fails to send. */ getNextPublisher;
447
447
  /** L1 fee analyzer for fisherman mode */ l1FeeAnalyzer;
448
448
  /** Fee asset price oracle for computing price modifiers from Uniswap V4 */ feeAssetPriceOracle;
449
+ /** Interruptible sleep used by sendRequestsAt to wait until a target timestamp. */ interruptibleSleep;
449
450
  // A CALL to a cold address is 2700 gas
450
451
  static MULTICALL_OVERHEAD_GAS_GUESS = 5000n;
451
452
  // Gas report for VotingWithSigTest shows a max gas of 100k, but we've seen it cost 700k+ in testnet
@@ -454,7 +455,6 @@ export class SequencerPublisher {
454
455
  rollupContract;
455
456
  govProposerContract;
456
457
  slashingProposerContract;
457
- slashFactoryContract;
458
458
  tracer;
459
459
  requests;
460
460
  constructor(config, deps){
@@ -465,12 +465,16 @@ export class SequencerPublisher {
465
465
  this.lastActions = {};
466
466
  this.isPayloadEmptyCache = new Map();
467
467
  this.payloadProposedCache = new Set();
468
+ this.interruptibleSleep = new InterruptibleSleep();
468
469
  this.requests = [];
469
470
  this.log = deps.log ?? createLogger('sequencer:publisher');
470
471
  this.ethereumSlotDuration = BigInt(config.ethereumSlotDuration);
472
+ this.aztecSlotDuration = BigInt(config.aztecSlotDuration);
473
+ this.dateProvider = deps.dateProvider;
471
474
  this.epochCache = deps.epochCache;
472
475
  this.lastActions = deps.lastActions;
473
476
  this.blobClient = deps.blobClient;
477
+ this.dateProvider = deps.dateProvider;
474
478
  const telemetry = deps.telemetry ?? getTelemetryClient();
475
479
  this.metrics = deps.metrics ?? new SequencerPublisherMetrics(telemetry, 'SequencerPublisher');
476
480
  this.tracer = telemetry.getTracer('SequencerPublisher');
@@ -484,7 +488,6 @@ export class SequencerPublisher {
484
488
  const newSlashingProposer = await this.rollupContract.getSlashingProposer();
485
489
  this.slashingProposerContract = newSlashingProposer;
486
490
  });
487
- this.slashFactoryContract = deps.slashFactoryContract;
488
491
  // Initialize L1 fee analyzer for fisherman mode
489
492
  if (config.fishermanMode) {
490
493
  this.l1FeeAnalyzer = new L1FeeAnalyzer(this.l1TxUtils.client, deps.dateProvider, createLogger('sequencer:publisher:fee-analyzer'));
@@ -537,7 +540,7 @@ export class SequencerPublisher {
537
540
  this.requests.push(request);
538
541
  }
539
542
  getCurrentL2Slot() {
540
- return this.epochCache.getEpochAndSlotNow().slot;
543
+ return this.epochCache.getSlotNow();
541
544
  }
542
545
  /**
543
546
  * Clears all pending requests without sending them.
@@ -626,8 +629,8 @@ export class SequencerPublisher {
626
629
  // @note - we can only have one blob config per bundle
627
630
  // find requests with gas and blob configs
628
631
  // See https://github.com/AztecProtocol/aztec-packages/issues/11513
629
- const gasConfigs = requestsToProcess.filter((request)=>request.gasConfig).map((request)=>request.gasConfig);
630
- const blobConfigs = requestsToProcess.filter((request)=>request.blobConfig).map((request)=>request.blobConfig);
632
+ const gasConfigs = validRequests.filter((request)=>request.gasConfig).map((request)=>request.gasConfig);
633
+ const blobConfigs = validRequests.filter((request)=>request.blobConfig).map((request)=>request.blobConfig);
631
634
  if (blobConfigs.length > 1) {
632
635
  throw new Error('Multiple blob configs found');
633
636
  }
@@ -735,6 +738,41 @@ export class SequencerPublisher {
735
738
  }
736
739
  }
737
740
  }
741
+ /*
742
+ * Schedules sending all enqueued requests at (or after) the given timestamp.
743
+ * Uses InterruptibleSleep so it can be cancelled via interrupt().
744
+ * Returns the promise for the L1 response (caller should NOT await this in the work loop).
745
+ */ async sendRequestsAt(submitAfter) {
746
+ const ms = submitAfter.getTime() - this.dateProvider.now();
747
+ if (ms > 0) {
748
+ this.log.debug(`Sleeping ${ms}ms before sending requests`, {
749
+ submitAfter
750
+ });
751
+ await this.interruptibleSleep.sleep(ms);
752
+ }
753
+ if (this.interrupted) {
754
+ return undefined;
755
+ }
756
+ // Re-validate enqueued requests after the sleep (state may have changed, e.g. prune or L1 reorg)
757
+ const validRequests = [];
758
+ for (const request of this.requests){
759
+ if (!request.preCheck) {
760
+ validRequests.push(request);
761
+ continue;
762
+ }
763
+ try {
764
+ await request.preCheck();
765
+ validRequests.push(request);
766
+ } catch (err) {
767
+ this.log.warn(`Pre-send validation failed for ${request.action}, discarding request`, err);
768
+ }
769
+ }
770
+ this.requests = validRequests;
771
+ if (this.requests.length === 0) {
772
+ return undefined;
773
+ }
774
+ return this.sendRequests();
775
+ }
738
776
  callbackBundledTransactions(requests, result, txContext) {
739
777
  const actionsListStr = requests.map((r)=>r.action).join(', ');
740
778
  if (result instanceof FormattedViemError) {
@@ -826,19 +864,20 @@ export class SequencerPublisher {
826
864
  }
827
865
  }
828
866
  /**
829
- * @notice Will call `canProposeAtNextEthBlock` to make sure that it is possible to propose
867
+ * @notice Will call `canProposeAt` to make sure that it is possible to propose
830
868
  * @param tipArchive - The archive to check
831
869
  * @returns The slot and block number if it is possible to propose, undefined otherwise
832
- */ canProposeAtNextEthBlock(tipArchive, msgSender, opts = {}) {
870
+ */ async canProposeAt(tipArchive, msgSender, simulationOverridesPlan) {
833
871
  // TODO: #14291 - should loop through multiple keys to check if any of them can propose
834
872
  const ignoredErrors = [
835
873
  'SlotAlreadyInChain',
836
874
  'InvalidProposer',
837
875
  'InvalidArchive'
838
876
  ];
839
- return this.rollupContract.canProposeAtNextEthBlock(tipArchive.toBuffer(), msgSender.toString(), Number(this.ethereumSlotDuration), {
840
- forcePendingCheckpointNumber: opts.forcePendingCheckpointNumber
841
- }).catch((err)=>{
877
+ const pipelined = this.epochCache.isProposerPipeliningEnabled();
878
+ const slotOffset = pipelined ? this.aztecSlotDuration : 0n;
879
+ const nextL1SlotTs = this.getNextL1SlotTimestamp() + slotOffset;
880
+ return this.rollupContract.canProposeAt(tipArchive.toBuffer(), msgSender.toString(), nextL1SlotTs, await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan)).catch((err)=>{
842
881
  if (err instanceof FormattedViemError && ignoredErrors.find((e)=>err.message.includes(e))) {
843
882
  this.log.warn(`Failed canProposeAtTime check with ${ignoredErrors.find((e)=>err.message.includes(e))}`, {
844
883
  error: err.message
@@ -854,7 +893,7 @@ export class SequencerPublisher {
854
893
  * @dev This is a convenience function that can be used by the sequencer to validate a "partial" header.
855
894
  * It will throw if the block header is invalid.
856
895
  * @param header - The block header to validate
857
- */ async validateBlockHeader(header, opts) {
896
+ */ async validateBlockHeader(header, simulationOverridesPlan) {
858
897
  const flags = {
859
898
  ignoreDA: true,
860
899
  ignoreSignatures: true
@@ -868,8 +907,8 @@ export class SequencerPublisher {
868
907
  header.blobsHash.toString(),
869
908
  flags
870
909
  ];
871
- const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);
872
- const stateOverrides = await this.rollupContract.makePendingCheckpointNumberOverride(opts?.forcePendingCheckpointNumber);
910
+ const ts = this.getSimulationTimestamp(header.slotNumber);
911
+ const stateOverrides = await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan);
873
912
  let balance = 0n;
874
913
  if (this.config.fishermanMode) {
875
914
  // In fisherman mode, we can't know where the proposer is publishing from
@@ -891,7 +930,7 @@ export class SequencerPublisher {
891
930
  }),
892
931
  from: MULTI_CALL_3_ADDRESS
893
932
  }, {
894
- time: ts + 1n
933
+ time: ts
895
934
  }, stateOverrides);
896
935
  this.log.debug(`Simulated validateHeader`);
897
936
  }
@@ -937,6 +976,7 @@ export class SequencerPublisher {
937
976
  gasUsed,
938
977
  checkpointNumber,
939
978
  forcePendingCheckpointNumber: CheckpointNumber(checkpointNumber - 1),
979
+ lastArchive: validationResult.checkpoint.lastArchive,
940
980
  reason
941
981
  };
942
982
  } catch (err) {
@@ -949,8 +989,8 @@ export class SequencerPublisher {
949
989
  request,
950
990
  error: viemError.message
951
991
  });
952
- const latestPendingCheckpointNumber = await this.rollupContract.getCheckpointNumber();
953
- if (latestPendingCheckpointNumber < checkpointNumber) {
992
+ const latestProposedCheckpointNumber = await this.rollupContract.getCheckpointNumber();
993
+ if (latestProposedCheckpointNumber < checkpointNumber) {
954
994
  this.log.verbose(`Checkpoint ${checkpointNumber} has already been invalidated`, {
955
995
  ...logData
956
996
  });
@@ -1010,8 +1050,7 @@ export class SequencerPublisher {
1010
1050
  throw new Error(`Unknown reason for invalidation`);
1011
1051
  }
1012
1052
  }
1013
- /** Simulates `propose` to make sure that the checkpoint is valid for submission */ async validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, options) {
1014
- const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);
1053
+ /** Simulates `propose` to make sure that the checkpoint is valid for submission */ async validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, simulationOverridesPlan) {
1015
1054
  const blobFields = checkpoint.toBlobFields();
1016
1055
  const blobs = await getBlobsPerL1Block(blobFields);
1017
1056
  const blobInput = getPrefixedEthBlobCommitments(blobs);
@@ -1028,10 +1067,9 @@ export class SequencerPublisher {
1028
1067
  attestationsAndSignersSignature.toViemSignature(),
1029
1068
  blobInput
1030
1069
  ];
1031
- await this.simulateProposeTx(args, ts, options);
1032
- return ts;
1070
+ await this.simulateProposeTx(args, simulationOverridesPlan);
1033
1071
  }
1034
- async enqueueCastSignalHelper(slotNumber, timestamp, signalType, payload, base, signerAddress, signer) {
1072
+ async enqueueCastSignalHelper(slotNumber, signalType, payload, base, signerAddress, signer) {
1035
1073
  if (this.lastActions[signalType] && this.lastActions[signalType] === slotNumber) {
1036
1074
  this.log.debug(`Skipping duplicate vote cast signal ${signalType} for slot ${slotNumber}`);
1037
1075
  return false;
@@ -1088,6 +1126,7 @@ export class SequencerPublisher {
1088
1126
  lastValidL2Slot: slotNumber
1089
1127
  });
1090
1128
  const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
1129
+ const timestamp = this.getSimulationTimestamp(slotNumber);
1091
1130
  try {
1092
1131
  await this.l1TxUtils.simulate(request, {
1093
1132
  time: timestamp
@@ -1100,7 +1139,10 @@ export class SequencerPublisher {
1100
1139
  });
1101
1140
  } catch (err) {
1102
1141
  const viemError = formatViemError(err);
1103
- this.log.error(`Failed simulation for ${action} at slot ${slotNumber} (enqueuing the action anyway)`, viemError);
1142
+ this.log.error(`Failed simulation for ${action} at slot ${slotNumber} (enqueuing the action anyway)`, viemError, {
1143
+ simulationTimestamp: timestamp,
1144
+ l1BlockNumber
1145
+ });
1104
1146
  this.backupFailedTx({
1105
1147
  id: keccak256(request.data),
1106
1148
  failureType: 'simulation',
@@ -1165,55 +1207,17 @@ export class SequencerPublisher {
1165
1207
  /**
1166
1208
  * Enqueues a governance castSignal transaction to cast a signal for a given slot number.
1167
1209
  * @param slotNumber - The slot number to cast a signal for.
1168
- * @param timestamp - The timestamp of the slot to cast a signal for.
1169
1210
  * @returns True if the signal was successfully enqueued, false otherwise.
1170
- */ enqueueGovernanceCastSignal(governancePayload, slotNumber, timestamp, signerAddress, signer) {
1171
- return this.enqueueCastSignalHelper(slotNumber, timestamp, 'governance-signal', governancePayload, this.govProposerContract, signerAddress, signer);
1211
+ */ enqueueGovernanceCastSignal(governancePayload, slotNumber, signerAddress, signer) {
1212
+ return this.enqueueCastSignalHelper(slotNumber, 'governance-signal', governancePayload, this.govProposerContract, signerAddress, signer);
1172
1213
  }
1173
- /** Enqueues all slashing actions as returned by the slasher client. */ async enqueueSlashingActions(actions, slotNumber, timestamp, signerAddress, signer) {
1214
+ /** Enqueues all slashing actions as returned by the slasher client. */ async enqueueSlashingActions(actions, slotNumber, signerAddress, signer) {
1174
1215
  if (actions.length === 0) {
1175
1216
  this.log.debug(`No slashing actions to enqueue for slot ${slotNumber}`);
1176
1217
  return false;
1177
1218
  }
1178
1219
  for (const action of actions){
1179
1220
  switch(action.type){
1180
- case 'vote-empire-payload':
1181
- {
1182
- if (this.slashingProposerContract?.type !== 'empire') {
1183
- this.log.error('Cannot vote for empire payload on non-empire slashing contract');
1184
- break;
1185
- }
1186
- this.log.debug(`Enqueuing slashing vote for payload ${action.payload} at slot ${slotNumber}`, {
1187
- signerAddress
1188
- });
1189
- await this.enqueueCastSignalHelper(slotNumber, timestamp, 'empire-slashing-signal', action.payload, this.slashingProposerContract, signerAddress, signer);
1190
- break;
1191
- }
1192
- case 'create-empire-payload':
1193
- {
1194
- this.log.debug(`Enqueuing slashing create payload at slot ${slotNumber}`, {
1195
- slotNumber,
1196
- signerAddress
1197
- });
1198
- const request = this.slashFactoryContract.buildCreatePayloadRequest(action.data);
1199
- await this.simulateAndEnqueueRequest('create-empire-payload', request, (receipt)=>!!this.slashFactoryContract.tryExtractSlashPayloadCreatedEvent(receipt.logs), slotNumber, timestamp);
1200
- break;
1201
- }
1202
- case 'execute-empire-payload':
1203
- {
1204
- this.log.debug(`Enqueuing slashing execute payload at slot ${slotNumber}`, {
1205
- slotNumber,
1206
- signerAddress
1207
- });
1208
- if (this.slashingProposerContract?.type !== 'empire') {
1209
- this.log.error('Cannot execute slashing payload on non-empire slashing contract');
1210
- return false;
1211
- }
1212
- const empireSlashingProposer = this.slashingProposerContract;
1213
- const request = empireSlashingProposer.buildExecuteRoundRequest(action.round);
1214
- await this.simulateAndEnqueueRequest('execute-empire-payload', request, (receipt)=>!!empireSlashingProposer.tryExtractPayloadSubmittedEvent(receipt.logs), slotNumber, timestamp);
1215
- break;
1216
- }
1217
1221
  case 'vote-offenses':
1218
1222
  {
1219
1223
  this.log.debug(`Enqueuing slashing vote for ${action.votes.length} votes at slot ${slotNumber}`, {
@@ -1222,14 +1226,13 @@ export class SequencerPublisher {
1222
1226
  votesCount: action.votes.length,
1223
1227
  signerAddress
1224
1228
  });
1225
- if (this.slashingProposerContract?.type !== 'tally') {
1226
- this.log.error('Cannot vote for slashing offenses on non-tally slashing contract');
1229
+ if (!this.slashingProposerContract) {
1230
+ this.log.error('No slashing proposer contract available');
1227
1231
  return false;
1228
1232
  }
1229
- const tallySlashingProposer = this.slashingProposerContract;
1230
1233
  const votes = bufferToHex(encodeSlashConsensusVotes(action.votes));
1231
- const request = await tallySlashingProposer.buildVoteRequestFromSigner(votes, slotNumber, signer);
1232
- await this.simulateAndEnqueueRequest('vote-offenses', request, (receipt)=>!!tallySlashingProposer.tryExtractVoteCastEvent(receipt.logs), slotNumber, timestamp);
1234
+ const request = await this.slashingProposerContract.buildVoteRequestFromSigner(votes, slotNumber, signer);
1235
+ await this.simulateAndEnqueueRequest('vote-offenses', request, (receipt)=>!!this.slashingProposerContract.tryExtractVoteCastEvent(receipt.logs), slotNumber);
1233
1236
  break;
1234
1237
  }
1235
1238
  case 'execute-slash':
@@ -1239,13 +1242,12 @@ export class SequencerPublisher {
1239
1242
  round: action.round,
1240
1243
  signerAddress
1241
1244
  });
1242
- if (this.slashingProposerContract?.type !== 'tally') {
1243
- this.log.error('Cannot execute slashing offenses on non-tally slashing contract');
1245
+ if (!this.slashingProposerContract) {
1246
+ this.log.error('No slashing proposer contract available');
1244
1247
  return false;
1245
1248
  }
1246
- const tallySlashingProposer = this.slashingProposerContract;
1247
- const request = tallySlashingProposer.buildExecuteRoundRequest(action.round, action.committees);
1248
- await this.simulateAndEnqueueRequest('execute-slash', request, (receipt)=>!!tallySlashingProposer.tryExtractRoundExecutedEvent(receipt.logs), slotNumber, timestamp);
1249
+ const executeRequest = this.slashingProposerContract.buildExecuteRoundRequest(action.round, action.committees);
1250
+ await this.simulateAndEnqueueRequest('execute-slash', executeRequest, (receipt)=>!!this.slashingProposerContract.tryExtractRoundExecutedEvent(receipt.logs), slotNumber);
1249
1251
  break;
1250
1252
  }
1251
1253
  default:
@@ -1269,27 +1271,40 @@ export class SequencerPublisher {
1269
1271
  attestationsAndSignersSignature,
1270
1272
  feeAssetPriceModifier: checkpoint.feeAssetPriceModifier
1271
1273
  };
1272
- let ts;
1274
+ const simulationOverridesPlan = SimulationOverridesBuilder.from(opts.simulationOverridesPlan).withoutBlobCheck().build();
1273
1275
  try {
1274
1276
  // @note This will make sure that we are passing the checks for our header ASSUMING that the data is also made available
1275
1277
  // This means that we can avoid the simulation issues in later checks.
1276
1278
  // By simulation issue, I mean the fact that the block.timestamp is equal to the last block, not the next, which
1277
1279
  // make time consistency checks break.
1278
1280
  // TODO(palla): Check whether we're validating twice, once here and once within addProposeTx, since we call simulateProposeTx in both places.
1279
- ts = await this.validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, opts);
1281
+ await this.validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, simulationOverridesPlan);
1280
1282
  } catch (err) {
1281
1283
  this.log.error(`Checkpoint validation failed. ${err instanceof Error ? err.message : 'No error message'}`, err, {
1282
1284
  ...checkpoint.getStats(),
1283
1285
  slotNumber: checkpoint.header.slotNumber,
1284
- forcePendingCheckpointNumber: opts.forcePendingCheckpointNumber
1286
+ simulationOverridesPlan
1285
1287
  });
1286
1288
  throw err;
1287
1289
  }
1290
+ // Build a pre-check callback that re-validates the checkpoint before L1 submission.
1291
+ // During pipelining this catches stale proposals due to prunes or L1 reorgs that occur during the pipeline sleep.
1292
+ let preCheck = undefined;
1293
+ if (this.epochCache.isProposerPipeliningEnabled()) {
1294
+ preCheck = async ()=>{
1295
+ this.log.debug(`Re-validating checkpoint ${checkpoint.number} before L1 submission`);
1296
+ await this.validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, simulationOverridesPlan);
1297
+ };
1298
+ }
1288
1299
  this.log.verbose(`Enqueuing checkpoint propose transaction`, {
1289
1300
  ...checkpoint.toCheckpointInfo(),
1290
- ...opts
1301
+ txTimeoutAt: opts.txTimeoutAt,
1302
+ simulationOverridesPlan
1291
1303
  });
1292
- await this.addProposeTx(checkpoint, proposeTxArgs, opts, ts);
1304
+ await this.addProposeTx(checkpoint, proposeTxArgs, {
1305
+ txTimeoutAt: opts.txTimeoutAt,
1306
+ simulationOverridesPlan
1307
+ }, preCheck);
1293
1308
  }
1294
1309
  enqueueInvalidateCheckpoint(request, opts = {}) {
1295
1310
  if (!request) {
@@ -1330,7 +1345,8 @@ export class SequencerPublisher {
1330
1345
  }
1331
1346
  });
1332
1347
  }
1333
- async simulateAndEnqueueRequest(action, request, checkSuccess, slotNumber, timestamp) {
1348
+ async simulateAndEnqueueRequest(action, request, checkSuccess, slotNumber) {
1349
+ const timestamp = this.getSimulationTimestamp(slotNumber);
1334
1350
  const logData = {
1335
1351
  slotNumber,
1336
1352
  timestamp,
@@ -1352,7 +1368,7 @@ export class SequencerPublisher {
1352
1368
  try {
1353
1369
  ({ gasUsed } = await this.l1TxUtils.simulate(request, {
1354
1370
  time: timestamp
1355
- }, [], simulateAbi)); // TODO(palla/slash): Check the timestamp logic
1371
+ }, [], simulateAbi));
1356
1372
  this.log.verbose(`Simulation for ${action} succeeded`, {
1357
1373
  ...logData,
1358
1374
  request,
@@ -1427,13 +1443,14 @@ export class SequencerPublisher {
1427
1443
  * A call to `restart` is required before you can continue publishing.
1428
1444
  */ interrupt() {
1429
1445
  this.interrupted = true;
1446
+ this.interruptibleSleep.interrupt();
1430
1447
  this.l1TxUtils.interrupt();
1431
1448
  }
1432
1449
  /** Restarts the publisher after calling `interrupt`. */ restart() {
1433
1450
  this.interrupted = false;
1434
1451
  this.l1TxUtils.restart();
1435
1452
  }
1436
- async prepareProposeTx(encodedData, timestamp, options) {
1453
+ async prepareProposeTx(encodedData, simulationOverridesPlan) {
1437
1454
  const kzg = Blob.getViemKzgInstance();
1438
1455
  const blobInput = getPrefixedEthBlobCommitments(encodedData.blobs);
1439
1456
  this.log.debug('Validating blob input', {
@@ -1510,7 +1527,7 @@ export class SequencerPublisher {
1510
1527
  encodedData.attestationsAndSignersSignature.toViemSignature(),
1511
1528
  blobInput
1512
1529
  ];
1513
- const { rollupData, simulationResult } = await this.simulateProposeTx(args, timestamp, options);
1530
+ const { rollupData, simulationResult } = await this.simulateProposeTx(args, simulationOverridesPlan);
1514
1531
  return {
1515
1532
  args,
1516
1533
  blobEvaluationGas,
@@ -1521,29 +1538,14 @@ export class SequencerPublisher {
1521
1538
  /**
1522
1539
  * Simulates the propose tx with eth_simulateV1
1523
1540
  * @param args - The propose tx args
1524
- * @param timestamp - The timestamp to simulate proposal at
1525
1541
  * @returns The simulation result
1526
- */ async simulateProposeTx(args, timestamp, options) {
1542
+ */ async simulateProposeTx(args, simulationOverridesPlan) {
1527
1543
  const rollupData = encodeFunctionData({
1528
1544
  abi: RollupAbi,
1529
1545
  functionName: 'propose',
1530
1546
  args
1531
1547
  });
1532
- // override the pending checkpoint number if requested
1533
- const forcePendingCheckpointNumberStateDiff = (options.forcePendingCheckpointNumber !== undefined ? await this.rollupContract.makePendingCheckpointNumberOverride(options.forcePendingCheckpointNumber) : []).flatMap((override)=>override.stateDiff ?? []);
1534
- const stateOverrides = [
1535
- {
1536
- address: this.rollupContract.address,
1537
- // @note we override checkBlob to false since blobs are not part simulate()
1538
- stateDiff: [
1539
- {
1540
- slot: toPaddedHex(RollupContract.checkBlobStorageSlot, true),
1541
- value: toPaddedHex(0n, true)
1542
- },
1543
- ...forcePendingCheckpointNumberStateDiff
1544
- ]
1545
- }
1546
- ];
1548
+ const stateOverrides = await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan);
1547
1549
  // In fisherman mode, simulate as the proposer but with sufficient balance
1548
1550
  if (this.proposerAddressForSimulation) {
1549
1551
  stateOverrides.push({
@@ -1552,6 +1554,7 @@ export class SequencerPublisher {
1552
1554
  });
1553
1555
  }
1554
1556
  const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
1557
+ const simTs = this.getSimulationTimestamp(SlotNumber.fromBigInt(args[0].header.slotNumber));
1555
1558
  const simulationResult = await this.l1TxUtils.simulate({
1556
1559
  to: this.rollupContract.address,
1557
1560
  data: rollupData,
@@ -1560,8 +1563,7 @@ export class SequencerPublisher {
1560
1563
  from: this.proposerAddressForSimulation.toString()
1561
1564
  }
1562
1565
  }, {
1563
- // @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp
1564
- time: timestamp + 1n,
1566
+ time: simTs,
1565
1567
  // @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit so we increase here
1566
1568
  gasLimit: MAX_L1_TX_LIMIT * 2n
1567
1569
  }, stateOverrides, RollupAbi, {
@@ -1578,7 +1580,9 @@ export class SequencerPublisher {
1578
1580
  logs: []
1579
1581
  };
1580
1582
  }
1581
- this.log.error(`Failed to simulate propose tx`, viemError);
1583
+ this.log.error(`Failed to simulate propose tx`, viemError, {
1584
+ simulationTimestamp: simTs
1585
+ });
1582
1586
  this.backupFailedTx({
1583
1587
  id: keccak256(rollupData),
1584
1588
  failureType: 'simulation',
@@ -1606,11 +1610,11 @@ export class SequencerPublisher {
1606
1610
  simulationResult
1607
1611
  };
1608
1612
  }
1609
- async addProposeTx(checkpoint, encodedData, opts = {}, timestamp) {
1613
+ async addProposeTx(checkpoint, encodedData, opts = {}, preCheck) {
1610
1614
  const slot = checkpoint.header.slotNumber;
1611
1615
  const timer = new Timer();
1612
1616
  const kzg = Blob.getViemKzgInstance();
1613
- const { rollupData, simulationResult, blobEvaluationGas } = await this.prepareProposeTx(encodedData, timestamp, opts);
1617
+ const { rollupData, simulationResult, blobEvaluationGas } = await this.prepareProposeTx(encodedData, opts.simulationOverridesPlan);
1614
1618
  const startBlock = await this.l1TxUtils.getBlockNumber();
1615
1619
  const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(simulationResult.gasUsed) * 64 / 63)) + blobEvaluationGas + SequencerPublisher.MULTICALL_OVERHEAD_GAS_GUESS);
1616
1620
  // Send the blobs to the blob client preemptively. This helps in tests where the sequencer mistakingly thinks that the propose
@@ -1626,9 +1630,10 @@ export class SequencerPublisher {
1626
1630
  },
1627
1631
  lastValidL2Slot: checkpoint.header.slotNumber,
1628
1632
  gasConfig: {
1629
- ...opts,
1633
+ txTimeoutAt: opts.txTimeoutAt,
1630
1634
  gasLimit
1631
1635
  },
1636
+ preCheck,
1632
1637
  blobConfig: {
1633
1638
  blobs: encodedData.blobs.map((b)=>b.data),
1634
1639
  kzg
@@ -1675,4 +1680,13 @@ export class SequencerPublisher {
1675
1680
  }
1676
1681
  });
1677
1682
  }
1683
+ /** Returns the timestamp of the last L1 slot within a given L2 slot. Used as the simulation timestamp
1684
+ * for eth_simulateV1 calls, since it's guaranteed to be greater than any L1 block produced during the slot. */ getSimulationTimestamp(slot) {
1685
+ const l1Constants = this.epochCache.getL1Constants();
1686
+ return getLastL1SlotTimestampForL2Slot(slot, l1Constants);
1687
+ }
1688
+ /** Returns the timestamp of the next L1 slot boundary after now. */ getNextL1SlotTimestamp() {
1689
+ const l1Constants = this.epochCache.getL1Constants();
1690
+ return getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), l1Constants);
1691
+ }
1678
1692
  }
@@ -0,0 +1,25 @@
1
+ import { RollupContract, type SimulationOverridesPlan } from '@aztec/ethereum/contracts';
2
+ import { CheckpointNumber } from '@aztec/foundation/branded-types';
3
+ import type { Fr } from '@aztec/foundation/curves/bn254';
4
+ import type { Logger } from '@aztec/foundation/log';
5
+ import type { ProposedCheckpointData } from '@aztec/stdlib/checkpoint';
6
+ type PipelinedParentSimulationOverridesPlanInput = {
7
+ checkpointNumber: CheckpointNumber;
8
+ proposedCheckpointData?: ProposedCheckpointData;
9
+ rollup: RollupContract;
10
+ log: Logger;
11
+ };
12
+ type SubmissionSimulationOverridesPlanInput = {
13
+ pipelinedParentPlan?: SimulationOverridesPlan;
14
+ invalidateToPendingCheckpointNumber?: CheckpointNumber;
15
+ lastArchiveRoot: Fr;
16
+ pipeliningEnabled: boolean;
17
+ };
18
+ /** Builds the simulated parent checkpoint view used while constructing a pipelined proposal. */
19
+ export declare function buildPipelinedParentSimulationOverridesPlan(input: PipelinedParentSimulationOverridesPlanInput): Promise<SimulationOverridesPlan | undefined>;
20
+ /** Builds the simulated chain view used when validating and enqueueing checkpoint submission. */
21
+ export declare function buildSubmissionSimulationOverridesPlan(input: SubmissionSimulationOverridesPlanInput): SimulationOverridesPlan | undefined;
22
+ /** Derives the pending parent fee header used during pipelined proposal simulation. */
23
+ export declare function computePipelinedParentFeeHeader(input: PipelinedParentSimulationOverridesPlanInput): Promise<import("@aztec/ethereum/contracts").FeeHeader | undefined>;
24
+ export {};
25
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hhaW5fc3RhdGVfb3ZlcnJpZGVzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2VxdWVuY2VyL2NoYWluX3N0YXRlX292ZX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RkFBdUY7QUFDdkYsd0JBQXNCLCtCQUErQixDQUFDLEtBQUssRUFBRSwyQ0FBMkMsc0VBZ0N2RyJ9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain_state_overrides.d.ts","sourceRoot":"","sources":["../../src/sequencer/chain_state_overrides.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA8B,KAAK,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACrH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEvE,KAAK,2CAA2C,GAAG;IACjD,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;IAChD,MAAM,EAAE,cAAc,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,KAAK,sCAAsC,GAAG;IAC5C,mBAAmB,CAAC,EAAE,uBAAuB,CAAC;IAC9C,mCAAmC,CAAC,EAAE,gBAAgB,CAAC;IACvD,eAAe,EAAE,EAAE,CAAC;IACpB,iBAAiB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,gGAAgG;AAChG,wBAAsB,2CAA2C,CAC/D,KAAK,EAAE,2CAA2C,GACjD,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAU9C;AAED,iGAAiG;AACjG,wBAAgB,sCAAsC,CACpD,KAAK,EAAE,sCAAsC,GAC5C,uBAAuB,GAAG,SAAS,CAarC;AAED,uFAAuF;AACvF,wBAAsB,+BAA+B,CAAC,KAAK,EAAE,2CAA2C,sEAgCvG"}
@@ -0,0 +1,39 @@
1
+ import { RollupContract, SimulationOverridesBuilder } from '@aztec/ethereum/contracts';
2
+ import { CheckpointNumber } from '@aztec/foundation/branded-types';
3
+ /** Builds the simulated parent checkpoint view used while constructing a pipelined proposal. */ export async function buildPipelinedParentSimulationOverridesPlan(input) {
4
+ const parentCheckpointNumber = CheckpointNumber(input.checkpointNumber - 1);
5
+ const builder = new SimulationOverridesBuilder().forPendingCheckpoint(parentCheckpointNumber);
6
+ const pendingFeeHeader = await computePipelinedParentFeeHeader(input);
7
+ if (pendingFeeHeader) {
8
+ builder.withPendingFeeHeader(pendingFeeHeader);
9
+ }
10
+ return builder.build();
11
+ }
12
+ /** Builds the simulated chain view used when validating and enqueueing checkpoint submission. */ export function buildSubmissionSimulationOverridesPlan(input) {
13
+ const pendingCheckpointNumber = input.invalidateToPendingCheckpointNumber ?? input.pipelinedParentPlan?.pendingCheckpointNumber;
14
+ const builder = SimulationOverridesBuilder.from(input.pipelinedParentPlan).forPendingCheckpoint(pendingCheckpointNumber);
15
+ if (input.pipeliningEnabled && pendingCheckpointNumber !== undefined) {
16
+ builder.withPendingArchive(input.lastArchiveRoot);
17
+ }
18
+ return builder.build();
19
+ }
20
+ /** Derives the pending parent fee header used during pipelined proposal simulation. */ export async function computePipelinedParentFeeHeader(input) {
21
+ if (!input.proposedCheckpointData || input.checkpointNumber < 2) {
22
+ return undefined;
23
+ }
24
+ const grandparentCheckpointNumber = CheckpointNumber(input.checkpointNumber - 2);
25
+ try {
26
+ const [grandparentCheckpoint, manaTarget] = await Promise.all([
27
+ input.rollup.getCheckpoint(grandparentCheckpointNumber),
28
+ input.rollup.getManaTarget()
29
+ ]);
30
+ if (!grandparentCheckpoint?.feeHeader) {
31
+ input.log.error(`Grandparent checkpoint or feeHeader missing for checkpoint ${grandparentCheckpointNumber.toString()}`);
32
+ return undefined;
33
+ }
34
+ return RollupContract.computeChildFeeHeader(grandparentCheckpoint.feeHeader, input.proposedCheckpointData.totalManaUsed, input.proposedCheckpointData.feeAssetPriceModifier, manaTarget);
35
+ } catch (err) {
36
+ input.log.error(`Failed to derive pipelined parent fee header for checkpoint ${grandparentCheckpointNumber.toString()}: ${err}`);
37
+ return undefined;
38
+ }
39
+ }