@aztec/sequencer-client 0.0.1-commit.86469d5 → 0.0.1-commit.8655d4a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/README.md +282 -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 +67 -33
  5. package/dest/config.d.ts +29 -7
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +77 -37
  8. package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
  9. package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
  10. package/dest/global_variable_builder/fee_predictor.js +128 -0
  11. package/dest/global_variable_builder/fee_provider.d.ts +21 -0
  12. package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
  13. package/dest/global_variable_builder/fee_provider.js +58 -0
  14. package/dest/global_variable_builder/global_builder.d.ts +14 -16
  15. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  16. package/dest/global_variable_builder/global_builder.js +16 -50
  17. package/dest/global_variable_builder/index.d.ts +4 -2
  18. package/dest/global_variable_builder/index.d.ts.map +1 -1
  19. package/dest/global_variable_builder/index.js +2 -0
  20. package/dest/index.d.ts +2 -2
  21. package/dest/index.d.ts.map +1 -1
  22. package/dest/index.js +1 -1
  23. package/dest/publisher/config.d.ts +47 -17
  24. package/dest/publisher/config.d.ts.map +1 -1
  25. package/dest/publisher/config.js +121 -42
  26. package/dest/publisher/index.d.ts +2 -1
  27. package/dest/publisher/index.d.ts.map +1 -1
  28. package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
  29. package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
  30. package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
  31. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +58 -0
  32. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
  33. package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
  34. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
  35. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
  36. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
  37. package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
  38. package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
  39. package/dest/publisher/l1_tx_failed_store/index.js +2 -0
  40. package/dest/publisher/sequencer-bundle-simulator.d.ts +96 -0
  41. package/dest/publisher/sequencer-bundle-simulator.d.ts.map +1 -0
  42. package/dest/publisher/sequencer-bundle-simulator.js +198 -0
  43. package/dest/publisher/sequencer-publisher-factory.d.ts +11 -5
  44. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  45. package/dest/publisher/sequencer-publisher-factory.js +27 -3
  46. package/dest/publisher/sequencer-publisher.d.ts +94 -67
  47. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  48. package/dest/publisher/sequencer-publisher.js +440 -378
  49. package/dest/sequencer/automine/automine_factory.d.ts +54 -0
  50. package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
  51. package/dest/sequencer/automine/automine_factory.js +84 -0
  52. package/dest/sequencer/automine/automine_sequencer.d.ts +151 -0
  53. package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
  54. package/dest/sequencer/automine/automine_sequencer.js +506 -0
  55. package/dest/sequencer/chain_state_overrides.d.ts +61 -0
  56. package/dest/sequencer/chain_state_overrides.d.ts.map +1 -0
  57. package/dest/sequencer/chain_state_overrides.js +98 -0
  58. package/dest/sequencer/checkpoint_proposal_job.d.ts +56 -11
  59. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  60. package/dest/sequencer/checkpoint_proposal_job.js +805 -225
  61. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
  62. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
  63. package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
  64. package/dest/sequencer/checkpoint_voter.d.ts +1 -2
  65. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
  66. package/dest/sequencer/checkpoint_voter.js +2 -5
  67. package/dest/sequencer/events.d.ts +47 -2
  68. package/dest/sequencer/events.d.ts.map +1 -1
  69. package/dest/sequencer/index.d.ts +3 -1
  70. package/dest/sequencer/index.d.ts.map +1 -1
  71. package/dest/sequencer/index.js +2 -0
  72. package/dest/sequencer/metrics.d.ts +23 -8
  73. package/dest/sequencer/metrics.d.ts.map +1 -1
  74. package/dest/sequencer/metrics.js +117 -21
  75. package/dest/sequencer/sequencer.d.ts +74 -21
  76. package/dest/sequencer/sequencer.d.ts.map +1 -1
  77. package/dest/sequencer/sequencer.js +353 -136
  78. package/dest/sequencer/timetable.d.ts +17 -6
  79. package/dest/sequencer/timetable.d.ts.map +1 -1
  80. package/dest/sequencer/timetable.js +51 -46
  81. package/dest/sequencer/types.d.ts +2 -2
  82. package/dest/sequencer/types.d.ts.map +1 -1
  83. package/dest/test/index.d.ts +3 -5
  84. package/dest/test/index.d.ts.map +1 -1
  85. package/dest/test/mock_checkpoint_builder.d.ts +11 -11
  86. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  87. package/dest/test/mock_checkpoint_builder.js +45 -34
  88. package/dest/test/utils.d.ts +3 -3
  89. package/dest/test/utils.d.ts.map +1 -1
  90. package/dest/test/utils.js +10 -8
  91. package/package.json +27 -28
  92. package/src/client/sequencer-client.ts +92 -35
  93. package/src/config.ts +102 -46
  94. package/src/global_variable_builder/README.md +44 -0
  95. package/src/global_variable_builder/fee_predictor.ts +172 -0
  96. package/src/global_variable_builder/fee_provider.ts +75 -0
  97. package/src/global_variable_builder/global_builder.ts +26 -63
  98. package/src/global_variable_builder/index.ts +3 -1
  99. package/src/index.ts +10 -1
  100. package/src/publisher/config.ts +157 -45
  101. package/src/publisher/index.ts +3 -0
  102. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  103. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +57 -0
  104. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
  105. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  106. package/src/publisher/sequencer-bundle-simulator.ts +254 -0
  107. package/src/publisher/sequencer-publisher-factory.ts +38 -9
  108. package/src/publisher/sequencer-publisher.ts +533 -469
  109. package/src/sequencer/README.md +152 -450
  110. package/src/sequencer/automine/README.md +46 -0
  111. package/src/sequencer/automine/automine_factory.ts +145 -0
  112. package/src/sequencer/automine/automine_sequencer.ts +592 -0
  113. package/src/sequencer/chain_state_overrides.ts +162 -0
  114. package/src/sequencer/checkpoint_proposal_job.ts +984 -245
  115. package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
  116. package/src/sequencer/checkpoint_voter.ts +1 -12
  117. package/src/sequencer/events.ts +50 -2
  118. package/src/sequencer/index.ts +2 -0
  119. package/src/sequencer/metrics.ts +132 -25
  120. package/src/sequencer/sequencer.ts +444 -154
  121. package/src/sequencer/timetable.ts +70 -57
  122. package/src/sequencer/types.ts +1 -1
  123. package/src/test/index.ts +2 -4
  124. package/src/test/mock_checkpoint_builder.ts +63 -49
  125. package/src/test/utils.ts +31 -10
@@ -1,14 +1,13 @@
1
+ import { MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT } from '@aztec/constants';
1
2
  import { EpochCache } from '@aztec/epoch-cache';
2
3
  import { isAnvilTestChain } from '@aztec/ethereum/chain';
3
4
  import { getPublicClient } from '@aztec/ethereum/client';
4
5
  import { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
5
6
  import { PublisherManager } from '@aztec/ethereum/publisher-manager';
6
- import { EthAddress } from '@aztec/foundation/eth-address';
7
7
  import { createLogger } from '@aztec/foundation/log';
8
- import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
9
8
  import { L1Metrics } from '@aztec/telemetry-client';
10
9
  import { NodeKeystoreAdapter } from '@aztec/validator-client';
11
- import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
10
+ import { getPublisherConfigFromSequencerConfig } from '../config.js';
12
11
  import { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
13
12
  import { Sequencer } from '../sequencer/index.js';
14
13
  /**
@@ -19,12 +18,14 @@ import { Sequencer } from '../sequencer/index.js';
19
18
  checkpointsBuilder;
20
19
  validatorClient;
21
20
  l1Metrics;
22
- constructor(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics){
21
+ delayer_;
22
+ constructor(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics, delayer_){
23
23
  this.publisherManager = publisherManager;
24
24
  this.sequencer = sequencer;
25
25
  this.checkpointsBuilder = checkpointsBuilder;
26
26
  this.validatorClient = validatorClient;
27
27
  this.l1Metrics = l1Metrics;
28
+ this.delayer_ = delayer_;
28
29
  }
29
30
  /**
30
31
  * Initializes a new instance.
@@ -44,30 +45,31 @@ import { Sequencer } from '../sequencer/index.js';
44
45
  const publicClient = getPublicClient(config);
45
46
  const l1TxUtils = deps.l1TxUtils;
46
47
  const l1Metrics = new L1Metrics(telemetryClient.getMeter('L1PublisherMetrics'), publicClient, l1TxUtils.map((x)=>x.getSenderAddress()));
47
- const publisherManager = new PublisherManager(l1TxUtils, config, log.getBindings());
48
- const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
49
- const [l1GenesisTime, slotDuration, rollupVersion, rollupManaLimit] = await Promise.all([
48
+ const publisherManager = new PublisherManager(l1TxUtils, getPublisherConfigFromSequencerConfig(config), {
49
+ bindings: log.getBindings(),
50
+ funder: deps.funderL1TxUtils
51
+ });
52
+ const rollupContract = new RollupContract(publicClient, config.rollupAddress.toString());
53
+ const [l1GenesisTime, slotDuration, rollupManaLimit] = await Promise.all([
50
54
  rollupContract.getL1GenesisTime(),
51
55
  rollupContract.getSlotDuration(),
52
- rollupContract.getVersion(),
53
56
  rollupContract.getManaLimit().then(Number)
54
57
  ]);
55
- const governanceProposerContract = new GovernanceProposerContract(publicClient, config.l1Contracts.governanceProposerAddress.toString());
56
- const epochCache = deps.epochCache ?? await EpochCache.create(config.l1Contracts.rollupAddress, {
58
+ const governanceProposerContract = new GovernanceProposerContract(publicClient, config.governanceProposerAddress.toString());
59
+ const epochCache = deps.epochCache ?? await EpochCache.create(config.rollupAddress, {
57
60
  l1RpcUrls: rpcUrls,
58
61
  l1ChainId: chainId,
59
62
  viemPollingIntervalMS: config.viemPollingIntervalMS,
60
- ethereumSlotDuration: config.ethereumSlotDuration
63
+ ethereumSlotDuration: config.ethereumSlotDuration,
64
+ enableProposerPipelining: config.enableProposerPipelining
61
65
  }, {
62
66
  dateProvider: deps.dateProvider
63
67
  });
64
- const slashFactoryContract = new SlashFactoryContract(publicClient, config.l1Contracts.slashFactoryAddress?.toString() ?? EthAddress.ZERO.toString());
65
68
  const publisherFactory = deps.publisherFactory ?? new SequencerPublisherFactory(config, {
66
69
  telemetry: telemetryClient,
67
70
  blobClient: deps.blobClient,
68
71
  epochCache,
69
72
  governanceProposerContract,
70
- slashFactoryContract,
71
73
  rollupContract,
72
74
  dateProvider: deps.dateProvider,
73
75
  publisherManager,
@@ -75,21 +77,7 @@ import { Sequencer } from '../sequencer/index.js';
75
77
  logger: log
76
78
  });
77
79
  const ethereumSlotDuration = config.ethereumSlotDuration;
78
- const l1Constants = {
79
- l1GenesisTime,
80
- slotDuration: Number(slotDuration),
81
- ethereumSlotDuration
82
- };
83
- const globalsBuilder = new GlobalVariableBuilder({
84
- ...config,
85
- ...l1Constants,
86
- rollupVersion
87
- });
88
- let sequencerManaLimit = config.maxL2BlockGas ?? rollupManaLimit;
89
- if (sequencerManaLimit > rollupManaLimit) {
90
- log.warn(`Provided maxL2BlockGas ${sequencerManaLimit} is greater than the max allowed by L1. Setting limit to ${rollupManaLimit}.`);
91
- sequencerManaLimit = rollupManaLimit;
92
- }
80
+ const globalsBuilder = deps.globalVariableBuilder;
93
81
  // When running in anvil, assume we can post a tx up until one second before the end of an L1 slot.
94
82
  // Otherwise, we need the full L1 slot duration for publishing to ensure inclusion.
95
83
  // In theory, the L1 slot has an initial 4s phase where the block is propagated, so we could
@@ -97,13 +85,25 @@ import { Sequencer } from '../sequencer/index.js';
97
85
  // See https://www.blocknative.com/blog/anatomy-of-a-slot#7 for more info.
98
86
  const l1PublishingTimeBasedOnChain = isAnvilTestChain(config.l1ChainId) ? 1 : ethereumSlotDuration;
99
87
  const l1PublishingTime = config.l1PublishingTime ?? l1PublishingTimeBasedOnChain;
88
+ const { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock } = capPerBlockLimits(config, rollupManaLimit, log);
89
+ const l1Constants = {
90
+ l1GenesisTime,
91
+ slotDuration: Number(slotDuration),
92
+ ethereumSlotDuration,
93
+ rollupManaLimit,
94
+ epochDuration: config.aztecEpochDuration
95
+ };
100
96
  const sequencer = new Sequencer(publisherFactory, validatorClient, globalsBuilder, p2pClient, worldStateSynchronizer, slasherClient, l2BlockSource, l1ToL2MessageSource, checkpointsBuilder, l1Constants, deps.dateProvider, epochCache, rollupContract, {
101
97
  ...config,
102
98
  l1PublishingTime,
103
- maxL2BlockGas: sequencerManaLimit
99
+ maxL2BlockGas,
100
+ maxDABlockGas,
101
+ maxTxsPerBlock
104
102
  }, telemetryClient, log);
105
- await sequencer.init();
106
- return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics);
103
+ sequencer.init();
104
+ // Extract the shared delayer from the first L1TxUtils instance (all instances share the same delayer)
105
+ const delayer = l1TxUtils[0]?.delayer;
106
+ return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics, delayer);
107
107
  }
108
108
  /**
109
109
  * Updates sequencer and validator client config.
@@ -117,19 +117,28 @@ import { Sequencer } from '../sequencer/index.js';
117
117
  await this.validatorClient?.start();
118
118
  this.sequencer.start();
119
119
  this.l1Metrics?.start();
120
- await this.publisherManager.loadState();
120
+ await this.publisherManager.start();
121
121
  }
122
122
  /**
123
123
  * Stops the sequencer from processing new txs.
124
124
  */ async stop() {
125
125
  await this.sequencer.stop();
126
126
  await this.validatorClient?.stop();
127
- this.publisherManager.interrupt();
127
+ await this.publisherManager.stop();
128
128
  this.l1Metrics?.stop();
129
129
  }
130
+ /** Triggers an immediate run of the sequencer, bypassing the polling interval. */ trigger() {
131
+ return this.sequencer.trigger();
132
+ }
130
133
  getSequencer() {
131
134
  return this.sequencer;
132
135
  }
136
+ /** Updates the publisher factory's node keystore adapter after a keystore reload. */ updatePublisherNodeKeyStore(adapter) {
137
+ this.sequencer.updatePublisherNodeKeyStore(adapter);
138
+ }
139
+ /** Returns the shared tx delayer for sequencer L1 txs, if enabled. Test-only. */ getDelayer() {
140
+ return this.delayer_;
141
+ }
133
142
  get validatorAddresses() {
134
143
  return this.sequencer.getValidatorAddresses();
135
144
  }
@@ -137,3 +146,28 @@ import { Sequencer } from '../sequencer/index.js';
137
146
  return this.sequencer.maxL2BlockGas;
138
147
  }
139
148
  }
149
+ /**
150
+ * Caps operator-provided per-block limits at checkpoint-level limits.
151
+ * Returns undefined for any limit the operator didn't set — the checkpoint builder handles redistribution.
152
+ */ function capPerBlockLimits(config, rollupManaLimit, log) {
153
+ let maxL2BlockGas = config.maxL2BlockGas;
154
+ if (maxL2BlockGas !== undefined && maxL2BlockGas > rollupManaLimit) {
155
+ log.warn(`Provided MAX_L2_BLOCK_GAS ${maxL2BlockGas} exceeds rollup mana limit ${rollupManaLimit} (capping)`);
156
+ maxL2BlockGas = rollupManaLimit;
157
+ }
158
+ let maxDABlockGas = config.maxDABlockGas;
159
+ if (maxDABlockGas !== undefined && maxDABlockGas > MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT) {
160
+ log.warn(`Provided MAX_DA_BLOCK_GAS ${maxDABlockGas} exceeds DA checkpoint limit ${MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT} (capping)`);
161
+ maxDABlockGas = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT;
162
+ }
163
+ let maxTxsPerBlock = config.maxTxsPerBlock;
164
+ if (maxTxsPerBlock !== undefined && config.maxTxsPerCheckpoint !== undefined && maxTxsPerBlock > config.maxTxsPerCheckpoint) {
165
+ log.warn(`Provided MAX_TX_PER_BLOCK ${maxTxsPerBlock} exceeds MAX_TX_PER_CHECKPOINT ${config.maxTxsPerCheckpoint} (capping)`);
166
+ maxTxsPerBlock = config.maxTxsPerCheckpoint;
167
+ }
168
+ return {
169
+ maxL2BlockGas,
170
+ maxDABlockGas,
171
+ maxTxsPerBlock
172
+ };
173
+ }
package/dest/config.d.ts CHANGED
@@ -3,26 +3,48 @@ import { type L1ReaderConfig } from '@aztec/ethereum/l1-reader';
3
3
  import { type ConfigMappingsType } from '@aztec/foundation/config';
4
4
  import { type KeyStoreConfig } from '@aztec/node-keystore/config';
5
5
  import { type P2PConfig } from '@aztec/p2p/config';
6
- import { type ChainConfig, type SequencerConfig } from '@aztec/stdlib/config';
7
- import type { ResolvedSequencerConfig } from '@aztec/stdlib/interfaces/server';
6
+ import { type ChainConfig, type PipelineConfig, type SequencerConfig } from '@aztec/stdlib/config';
8
7
  import { type ValidatorClientConfig } from '@aztec/validator-client/config';
9
- import { type PublisherConfig, type TxSenderConfig } from './publisher/config.js';
8
+ import { type SequencerPublisherConfig, type SequencerTxSenderConfig } from './publisher/config.js';
10
9
  export * from './publisher/config.js';
11
10
  export type { SequencerConfig };
12
- export declare const DEFAULT_ATTESTATION_PROPAGATION_TIME = 2;
13
11
  /**
14
12
  * Default values for SequencerConfig.
15
13
  * Centralized location for all sequencer configuration defaults.
16
14
  */
17
- export declare const DefaultSequencerConfig: ResolvedSequencerConfig;
15
+ export declare const DefaultSequencerConfig: {
16
+ sequencerPollingIntervalMS: number;
17
+ minTxsPerBlock: number;
18
+ buildCheckpointIfEmpty: false;
19
+ publishTxsWithProposals: false;
20
+ perBlockAllocationMultiplier: number;
21
+ redistributeCheckpointBudget: true;
22
+ enforceTimeTable: true;
23
+ attestationPropagationTime: number;
24
+ secondsBeforeInvalidatingBlockAsCommitteeMember: number;
25
+ secondsBeforeInvalidatingBlockAsNonCommitteeMember: number;
26
+ skipCollectingAttestations: false;
27
+ skipInvalidateBlockAsProposer: false;
28
+ skipWaitForValidParentCheckpointOnL1: false;
29
+ broadcastInvalidBlockProposal: false;
30
+ broadcastInvalidCheckpointProposalOnly: false;
31
+ injectFakeAttestation: false;
32
+ injectHighSValueAttestation: false;
33
+ injectUnrecoverableSignatureAttestation: false;
34
+ fishermanMode: false;
35
+ shuffleAttestationOrdering: false;
36
+ skipPushProposedBlocksToArchiver: false;
37
+ skipPublishingCheckpointsPercent: number;
38
+ maxBlocksPerCheckpoint: number;
39
+ };
18
40
  /**
19
41
  * Configuration settings for the SequencerClient.
20
42
  */
21
- export type SequencerClientConfig = PublisherConfig & KeyStoreConfig & ValidatorClientConfig & TxSenderConfig & SequencerConfig & L1ReaderConfig & ChainConfig & Pick<P2PConfig, 'txPublicSetupAllowList'> & Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
43
+ export type SequencerClientConfig = SequencerPublisherConfig & KeyStoreConfig & ValidatorClientConfig & SequencerTxSenderConfig & SequencerConfig & L1ReaderConfig & ChainConfig & PipelineConfig & Pick<P2PConfig, 'txPublicSetupAllowListExtend'> & Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
22
44
  export declare const sequencerConfigMappings: ConfigMappingsType<SequencerConfig>;
23
45
  export declare const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientConfig>;
24
46
  /**
25
47
  * Creates an instance of SequencerClientConfig out of environment variables using sensible defaults for integration testing if not set.
26
48
  */
27
49
  export declare function getConfigEnvVars(): SequencerClientConfig;
28
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic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OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,mBAAmB,CAAC;AAEtE,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,cAAc,EACnB,KAAK,eAAe,EAIrB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,KAAK,qBAAqB,EAAiC,MAAM,gCAAgC,CAAC;AAE3G,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAG7B,MAAM,uBAAuB,CAAC;AAE/B,cAAc,uBAAuB,CAAC;AACtC,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;CAwBA,CAAC;AAEpC;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,wBAAwB,GAC1D,cAAc,GACd,qBAAqB,GACrB,uBAAuB,GACvB,eAAe,GACf,cAAc,GACd,WAAW,GACX,cAAc,GACd,IAAI,CAAC,SAAS,EAAE,8BAA8B,CAAC,GAC/C,IAAI,CAAC,iBAAiB,EAAE,sBAAsB,GAAG,mBAAmB,GAAG,oBAAoB,CAAC,CAAC;AAE/F,eAAO,MAAM,uBAAuB,EAAE,kBAAkB,CAAC,eAAe,CAwLvE,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,kBAAkB,CAAC,qBAAqB,CAUnF,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,qBAAqB,CAExD"}
package/dest/config.js CHANGED
@@ -1,38 +1,42 @@
1
1
  import { l1ContractsConfigMappings } from '@aztec/ethereum/config';
2
2
  import { l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
3
- import { booleanConfigHelper, getConfigFromMappings, numberConfigHelper, pickConfigMappings } from '@aztec/foundation/config';
3
+ import { booleanConfigHelper, getConfigFromMappings, numberConfigHelper, optionalNumberConfigHelper, pickConfigMappings } from '@aztec/foundation/config';
4
4
  import { EthAddress } from '@aztec/foundation/eth-address';
5
5
  import { keyStoreConfigMappings } from '@aztec/node-keystore/config';
6
6
  import { p2pConfigMappings } from '@aztec/p2p/config';
7
7
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
8
- import { chainConfigMappings } from '@aztec/stdlib/config';
8
+ import { DEFAULT_MAX_BLOCKS_PER_CHECKPOINT, chainConfigMappings, pipelineConfigMappings, sharedSequencerConfigMappings } from '@aztec/stdlib/config';
9
+ import { DEFAULT_P2P_PROPAGATION_TIME } from '@aztec/stdlib/timetable';
9
10
  import { validatorClientConfigMappings } from '@aztec/validator-client/config';
10
- import { getPublisherConfigMappings, getTxSenderConfigMappings } from './publisher/config.js';
11
+ import { sequencerPublisherConfigMappings, sequencerTxSenderConfigMappings } from './publisher/config.js';
11
12
  export * from './publisher/config.js';
12
- export const DEFAULT_ATTESTATION_PROPAGATION_TIME = 2;
13
13
  /**
14
14
  * Default values for SequencerConfig.
15
15
  * Centralized location for all sequencer configuration defaults.
16
16
  */ export const DefaultSequencerConfig = {
17
17
  sequencerPollingIntervalMS: 500,
18
- maxTxsPerBlock: 32,
19
18
  minTxsPerBlock: 1,
20
19
  buildCheckpointIfEmpty: false,
21
20
  publishTxsWithProposals: false,
22
- maxL2BlockGas: 10e9,
23
- maxDABlockGas: 10e9,
24
- maxBlockSizeInBytes: 1024 * 1024,
21
+ perBlockAllocationMultiplier: 1.2,
22
+ redistributeCheckpointBudget: true,
25
23
  enforceTimeTable: true,
26
- attestationPropagationTime: DEFAULT_ATTESTATION_PROPAGATION_TIME,
24
+ attestationPropagationTime: DEFAULT_P2P_PROPAGATION_TIME,
27
25
  secondsBeforeInvalidatingBlockAsCommitteeMember: 144,
28
26
  secondsBeforeInvalidatingBlockAsNonCommitteeMember: 432,
29
27
  skipCollectingAttestations: false,
30
28
  skipInvalidateBlockAsProposer: false,
29
+ skipWaitForValidParentCheckpointOnL1: false,
31
30
  broadcastInvalidBlockProposal: false,
31
+ broadcastInvalidCheckpointProposalOnly: false,
32
32
  injectFakeAttestation: false,
33
+ injectHighSValueAttestation: false,
34
+ injectUnrecoverableSignatureAttestation: false,
33
35
  fishermanMode: false,
34
36
  shuffleAttestationOrdering: false,
35
- skipPushProposedBlocksToArchiver: false
37
+ skipPushProposedBlocksToArchiver: false,
38
+ skipPublishingCheckpointsPercent: 0,
39
+ maxBlocksPerCheckpoint: DEFAULT_MAX_BLOCKS_PER_CHECKPOINT
36
40
  };
37
41
  export const sequencerConfigMappings = {
38
42
  sequencerPollingIntervalMS: {
@@ -40,10 +44,10 @@ export const sequencerConfigMappings = {
40
44
  description: 'The number of ms to wait between polling for checking to build on the next slot.',
41
45
  ...numberConfigHelper(DefaultSequencerConfig.sequencerPollingIntervalMS)
42
46
  },
43
- maxTxsPerBlock: {
44
- env: 'SEQ_MAX_TX_PER_BLOCK',
45
- description: 'The maximum number of txs to include in a block.',
46
- ...numberConfigHelper(DefaultSequencerConfig.maxTxsPerBlock)
47
+ maxTxsPerCheckpoint: {
48
+ env: 'SEQ_MAX_TX_PER_CHECKPOINT',
49
+ description: 'The maximum number of txs across all blocks in a checkpoint.',
50
+ ...optionalNumberConfigHelper()
47
51
  },
48
52
  minTxsPerBlock: {
49
53
  env: 'SEQ_MIN_TX_PER_BLOCK',
@@ -61,16 +65,26 @@ export const sequencerConfigMappings = {
61
65
  maxL2BlockGas: {
62
66
  env: 'SEQ_MAX_L2_BLOCK_GAS',
63
67
  description: 'The maximum L2 block gas.',
64
- ...numberConfigHelper(DefaultSequencerConfig.maxL2BlockGas)
68
+ ...optionalNumberConfigHelper()
65
69
  },
66
70
  maxDABlockGas: {
67
71
  env: 'SEQ_MAX_DA_BLOCK_GAS',
68
72
  description: 'The maximum DA block gas.',
69
- ...numberConfigHelper(DefaultSequencerConfig.maxDABlockGas)
73
+ ...optionalNumberConfigHelper()
74
+ },
75
+ perBlockAllocationMultiplier: {
76
+ env: 'SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER',
77
+ description: 'Per-block gas budget multiplier for both L2 and DA gas. Budget per block is (checkpointLimit / maxBlocks) * multiplier.' + ' Values greater than one allow early blocks to use more than their even share, relying on checkpoint-level capping for later blocks.',
78
+ ...numberConfigHelper(DefaultSequencerConfig.perBlockAllocationMultiplier)
79
+ },
80
+ redistributeCheckpointBudget: {
81
+ env: 'SEQ_REDISTRIBUTE_CHECKPOINT_BUDGET',
82
+ description: 'Redistribute remaining checkpoint budget evenly across remaining blocks instead of allowing a single block to consume the entire remaining budget.',
83
+ ...booleanConfigHelper(DefaultSequencerConfig.redistributeCheckpointBudget)
70
84
  },
71
85
  coinbase: {
72
86
  env: 'COINBASE',
73
- parseEnv: (val)=>val ? EthAddress.fromString(val) : undefined,
87
+ parseEnv: (val)=>EthAddress.fromString(val),
74
88
  description: 'Recipient of block reward.'
75
89
  },
76
90
  feeRecipient: {
@@ -86,11 +100,6 @@ export const sequencerConfigMappings = {
86
100
  env: 'ACVM_BINARY_PATH',
87
101
  description: 'The path to the ACVM binary'
88
102
  },
89
- maxBlockSizeInBytes: {
90
- env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES',
91
- description: 'Max block size',
92
- ...numberConfigHelper(DefaultSequencerConfig.maxBlockSizeInBytes)
93
- },
94
103
  enforceTimeTable: {
95
104
  env: 'SEQ_ENFORCE_TIME_TABLE',
96
105
  description: 'Whether to enforce the time table when building blocks',
@@ -104,12 +113,7 @@ export const sequencerConfigMappings = {
104
113
  l1PublishingTime: {
105
114
  env: 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT',
106
115
  description: 'How much time (in seconds) we allow in the slot for publishing the L1 tx (defaults to 1 L1 slot).',
107
- parseEnv: (val)=>val ? parseInt(val, 10) : undefined
108
- },
109
- attestationPropagationTime: {
110
- env: 'SEQ_ATTESTATION_PROPAGATION_TIME',
111
- description: 'How many seconds it takes for proposals and attestations to travel across the p2p layer (one-way)',
112
- ...numberConfigHelper(DefaultSequencerConfig.attestationPropagationTime)
116
+ ...optionalNumberConfigHelper()
113
117
  },
114
118
  fakeProcessingDelayPerTxMs: {
115
119
  description: 'Used for testing to introduce a fake delay after processing each tx'
@@ -135,14 +139,34 @@ export const sequencerConfigMappings = {
135
139
  description: 'Do not invalidate the previous block if invalid when we are the proposer (for testing only)',
136
140
  ...booleanConfigHelper(DefaultSequencerConfig.skipInvalidateBlockAsProposer)
137
141
  },
142
+ skipWaitForValidParentCheckpointOnL1: {
143
+ description: 'Bypass the parent checkpoint validity check before submitting a pipelined checkpoint, ' + 'allowing the proposer to publish even when the parent landed on L1 with invalid attestations (for testing only)',
144
+ ...booleanConfigHelper(DefaultSequencerConfig.skipWaitForValidParentCheckpointOnL1)
145
+ },
138
146
  broadcastInvalidBlockProposal: {
139
147
  description: 'Broadcast invalid block proposals with corrupted state (for testing only)',
140
148
  ...booleanConfigHelper(DefaultSequencerConfig.broadcastInvalidBlockProposal)
141
149
  },
150
+ invalidBlockProposalIndexWithinCheckpoint: {
151
+ description: 'Broadcast an invalid block proposal only at this indexWithinCheckpoint (for testing only)',
152
+ ...optionalNumberConfigHelper()
153
+ },
154
+ broadcastInvalidCheckpointProposalOnly: {
155
+ description: 'Broadcast invalid checkpoint proposals while keeping the underlying block proposals valid (for testing only). When unset, the checkpoint follows broadcastInvalidBlockProposal.',
156
+ ...booleanConfigHelper(DefaultSequencerConfig.broadcastInvalidCheckpointProposalOnly)
157
+ },
142
158
  injectFakeAttestation: {
143
159
  description: 'Inject a fake attestation (for testing only)',
144
160
  ...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation)
145
161
  },
162
+ injectHighSValueAttestation: {
163
+ description: 'Inject a malleable attestation with a high-s value (for testing only)',
164
+ ...booleanConfigHelper(DefaultSequencerConfig.injectHighSValueAttestation)
165
+ },
166
+ injectUnrecoverableSignatureAttestation: {
167
+ description: 'Inject an attestation with an unrecoverable signature (for testing only)',
168
+ ...booleanConfigHelper(DefaultSequencerConfig.injectUnrecoverableSignatureAttestation)
169
+ },
146
170
  fishermanMode: {
147
171
  env: 'FISHERMAN_MODE',
148
172
  description: 'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
@@ -152,11 +176,7 @@ export const sequencerConfigMappings = {
152
176
  description: 'Shuffle attestation ordering to create invalid ordering (for testing only)',
153
177
  ...booleanConfigHelper(DefaultSequencerConfig.shuffleAttestationOrdering)
154
178
  },
155
- blockDurationMs: {
156
- env: 'SEQ_BLOCK_DURATION_MS',
157
- description: 'Duration per block in milliseconds when building multiple blocks per slot. ' + 'If undefined (default), builds a single block per slot using the full slot duration.',
158
- parseEnv: (val)=>val ? parseInt(val, 10) : undefined
159
- },
179
+ ...sharedSequencerConfigMappings,
160
180
  buildCheckpointIfEmpty: {
161
181
  env: 'SEQ_BUILD_CHECKPOINT_IF_EMPTY',
162
182
  description: 'Have sequencer build and publish an empty checkpoint if there are no txs',
@@ -166,18 +186,38 @@ export const sequencerConfigMappings = {
166
186
  description: 'Skip pushing proposed blocks to archiver (default: true)',
167
187
  ...booleanConfigHelper(DefaultSequencerConfig.skipPushProposedBlocksToArchiver)
168
188
  },
189
+ minBlocksForCheckpoint: {
190
+ description: 'Minimum number of blocks required for a checkpoint proposal (test only)'
191
+ },
192
+ skipPublishingCheckpointsPercent: {
193
+ env: 'SEQ_SKIP_CHECKPOINT_PUBLISH_PERCENT',
194
+ description: 'Percent probability (0 - 100) of sequencer skipping checkpoint publishing (testing only)',
195
+ ...numberConfigHelper(DefaultSequencerConfig.skipPublishingCheckpointsPercent)
196
+ },
197
+ skipBroadcastProposals: {
198
+ description: 'Skip broadcasting checkpoint and block proposals via gossipsub when proposer (for testing only)',
199
+ ...booleanConfigHelper(false)
200
+ },
201
+ skipBroadcastCheckpointProposal: {
202
+ description: 'Skip broadcasting only the CheckpointProposal via gossipsub when proposer; the held last block is broadcast ' + 'standalone instead so peers still receive it as a proposed-but-uncheckpointed tip (for testing only)',
203
+ ...booleanConfigHelper(false)
204
+ },
205
+ pauseProposingForSlots: {
206
+ description: 'List of slots for which the sequencer will not produce a proposal (for testing only). Attestation paths are unaffected.'
207
+ },
169
208
  ...pickConfigMappings(p2pConfigMappings, [
170
- 'txPublicSetupAllowList'
209
+ 'txPublicSetupAllowListExtend'
171
210
  ])
172
211
  };
173
212
  export const sequencerClientConfigMappings = {
213
+ ...chainConfigMappings,
174
214
  ...validatorClientConfigMappings,
175
215
  ...sequencerConfigMappings,
176
216
  ...keyStoreConfigMappings,
177
217
  ...l1ReaderConfigMappings,
178
- ...getTxSenderConfigMappings('SEQ'),
179
- ...getPublisherConfigMappings('SEQ'),
180
- ...chainConfigMappings,
218
+ ...sequencerTxSenderConfigMappings,
219
+ ...sequencerPublisherConfigMappings,
220
+ ...pipelineConfigMappings,
181
221
  ...pickConfigMappings(l1ContractsConfigMappings, [
182
222
  'ethereumSlotDuration',
183
223
  'aztecSlotDuration',
@@ -0,0 +1,37 @@
1
+ import { type RollupContract } from '@aztec/ethereum/contracts';
2
+ import type { DateProvider } from '@aztec/foundation/timer';
3
+ import { GasFees, ManaUsageEstimate } from '@aztec/stdlib/gas';
4
+ /**
5
+ * Predicts min fees for LAG upcoming slots based on the L1 oracle state.
6
+ * A new oracle update can activate at startSlot + LAG, so only the first LAG entries
7
+ * are guaranteed stable. Caches L1 queries per L1 block and recomputes predictions
8
+ * for each mana usage estimate.
9
+ */
10
+ export declare class FeePredictor {
11
+ private readonly rollupContract;
12
+ private readonly publicClient;
13
+ private readonly dateProvider;
14
+ private cachedState;
15
+ private cachedL1BlockNumber;
16
+ private readonly slotDuration;
17
+ private readonly l1GenesisTime;
18
+ private readonly ethereumSlotDuration;
19
+ constructor(rollupContract: RollupContract, publicClient: {
20
+ getBlockNumber: (opts?: {
21
+ cacheTime?: number;
22
+ }) => Promise<bigint>;
23
+ }, dateProvider: DateProvider, config: {
24
+ slotDuration: number;
25
+ l1GenesisTime: bigint;
26
+ ethereumSlotDuration: number;
27
+ });
28
+ /** Returns predicted min fees for each slot in the prediction window. */
29
+ getPredictedMinFees(manaUsage: ManaUsageEstimate): Promise<GasFees[]>;
30
+ private getState;
31
+ private fetchState;
32
+ /** Computes per-slot fee predictions given cached state and a mana usage assumption. */
33
+ private computePredictions;
34
+ private getAssumedManaUsed;
35
+ private computeGasFees;
36
+ }
37
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlX3ByZWRpY3Rvci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2dsb2JhbF92YXJpYWJsZV9idWlsZGVyL2ZlZV9wcmVkaWN0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFvRCxLQUFLLGNBQWMsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBR2xILE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBRTVELE9BQU8sRUFFTCxPQUFPLEVBRVAsaUJBQWlCLEVBR2xCLE1BQU0sbUJBQW1CLENBQUM7QUFlM0I7Ozs7O0dBS0c7QUFDSCxxQkFBYSxZQUFZO0lBU3JCLE9BQU8sQ0FBQyxRQUFRLENBQUMsY0FBYztJQUMvQixPQUFPLENBQUMsUUFBUSxDQUFDLFlBQVk7SUFDN0IsT0FBTyxDQUFDLFFBQVEsQ0FBQyxZQUFZO0lBVi9CLE9BQU8sQ0FBQyxXQUFXLENBQXNDO0lBQ3pELE9BQU8sQ0FBQyxtQkFBbUIsQ0FBcUI7SUFFaEQsT0FBTyxDQUFDLFFBQVEsQ0FBQyxZQUFZLENBQVM7SUFDdEMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxhQUFhLENBQVM7SUFDdkMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxvQkFBb0IsQ0FBUztJQUU5QyxZQUNtQixjQUFjLEVBQUUsY0FBYyxFQUM5QixZQUFZLEVBQUU7UUFBRSxjQUFjLEVBQUUsQ0FBQyxJQUFJLENBQUMsRUFBRTtZQUFFLFNBQVMsQ0FBQyxFQUFFLE1BQU0sQ0FBQTtTQUFFLEtBQUssT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AY,EAAE;QAAE,cAAc,EAAE,CAAC,IAAI,CAAC,EAAE;YAAE,SAAS,CAAC,EAAE,MAAM,CAAA;SAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;KAAE,EACpF,YAAY,EAAE,YAAY,EAC3C,MAAM,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,oBAAoB,EAAE,MAAM,CAAA;KAAE,EAKtF;IAED,yEAAyE;IACnE,mBAAmB,CAAC,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAG1E;YAGa,QAAQ;YASR,UAAU;IAiDxB,wFAAwF;IACxF,OAAO,CAAC,kBAAkB;IAuB1B,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,cAAc;CAmBvB"}
@@ -0,0 +1,128 @@
1
+ import { MAX_FEE_ASSET_PRICE_MODIFIER_BPS } from '@aztec/ethereum/contracts';
2
+ import { SlotNumber } from '@aztec/foundation/branded-types';
3
+ import { times } from '@aztec/foundation/collection';
4
+ import { getSlotAtNextL1Block, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
5
+ import { FEE_ORACLE_LAG, GasFees, MIN_ETH_PER_FEE_ASSET, ManaUsageEstimate, computeExcessMana, computeManaMinFee } from '@aztec/stdlib/gas';
6
+ /**
7
+ * Predicts min fees for LAG upcoming slots based on the L1 oracle state.
8
+ * A new oracle update can activate at startSlot + LAG, so only the first LAG entries
9
+ * are guaranteed stable. Caches L1 queries per L1 block and recomputes predictions
10
+ * for each mana usage estimate.
11
+ */ export class FeePredictor {
12
+ rollupContract;
13
+ publicClient;
14
+ dateProvider;
15
+ cachedState;
16
+ cachedL1BlockNumber;
17
+ slotDuration;
18
+ l1GenesisTime;
19
+ ethereumSlotDuration;
20
+ constructor(rollupContract, publicClient, dateProvider, config){
21
+ this.rollupContract = rollupContract;
22
+ this.publicClient = publicClient;
23
+ this.dateProvider = dateProvider;
24
+ this.slotDuration = config.slotDuration;
25
+ this.l1GenesisTime = config.l1GenesisTime;
26
+ this.ethereumSlotDuration = config.ethereumSlotDuration;
27
+ }
28
+ /** Returns predicted min fees for each slot in the prediction window. */ async getPredictedMinFees(manaUsage) {
29
+ const state = await this.getState();
30
+ return this.computePredictions(state, manaUsage);
31
+ }
32
+ /** Fetches and caches rollup state. Refreshes when L1 block number advances. */ async getState() {
33
+ const blockNumber = await this.publicClient.getBlockNumber({
34
+ cacheTime: 0
35
+ });
36
+ if (this.cachedL1BlockNumber === undefined || blockNumber > this.cachedL1BlockNumber) {
37
+ this.cachedL1BlockNumber = blockNumber;
38
+ this.cachedState = this.fetchState(blockNumber);
39
+ }
40
+ return this.cachedState;
41
+ }
42
+ async fetchState(blockNumber) {
43
+ // Pin all non-constant queries to this L1 block number for a consistent snapshot.
44
+ const opts = {
45
+ blockNumber
46
+ };
47
+ // Cached constants don't need pinning
48
+ const [manaTarget, manaLimit, provingCostPerManaEth, epochDuration] = await Promise.all([
49
+ this.rollupContract.getManaTarget(),
50
+ this.rollupContract.getManaLimit(),
51
+ this.rollupContract.getProvingCostPerMana(),
52
+ this.rollupContract.getEpochDuration()
53
+ ]);
54
+ // First, compute the earliest possible nextSlot independently of the checkpoint, so we can
55
+ // evaluate pruneability at the prediction start timestamp instead of the current L1 block time.
56
+ // This avoids an epoch-boundary edge case where the effective parent differs between now and nextSlot.
57
+ const slotConfig = {
58
+ slotDuration: this.slotDuration,
59
+ l1GenesisTime: this.l1GenesisTime
60
+ };
61
+ const currentSlot = await this.rollupContract.getSlotNumber(opts);
62
+ const slotAtNextL1Block = getSlotAtNextL1Block(BigInt(this.dateProvider.nowInSeconds()), {
63
+ l1GenesisTime: this.l1GenesisTime,
64
+ slotDuration: this.slotDuration,
65
+ ethereumSlotDuration: this.ethereumSlotDuration
66
+ });
67
+ const preliminaryNextSlot = SlotNumber(Math.max(currentSlot, slotAtNextL1Block));
68
+ const nextSlotTimestamp = getTimestampForSlot(preliminaryNextSlot, slotConfig);
69
+ // Resolve the effective checkpoint at the prediction start timestamp
70
+ const lastCheckpoint = await this.rollupContract.getEffectivePendingCheckpoint(nextSlotTimestamp, opts);
71
+ const lastSlot = lastCheckpoint.slotNumber;
72
+ // Refine nextSlot: also account for the slot after the last checkpoint
73
+ const nextSlot = SlotNumber(Math.max(SlotNumber.add(lastSlot, 1), preliminaryNextSlot));
74
+ const feeHeader = lastCheckpoint.feeHeader;
75
+ const slotCount = FEE_ORACLE_LAG;
76
+ const timestamps = times(slotCount, (i)=>getTimestampForSlot(SlotNumber.add(nextSlot, i), slotConfig));
77
+ const l1FeesBySlot = await Promise.all(timestamps.map((ts)=>this.rollupContract.getL1FeesAt(ts, opts)));
78
+ return {
79
+ lastSlot,
80
+ excessMana: computeExcessMana(feeHeader.excessMana, feeHeader.manaUsed, manaTarget),
81
+ ethPerFeeAsset: feeHeader.ethPerFeeAsset,
82
+ manaTarget,
83
+ manaLimit,
84
+ provingCostPerManaEth,
85
+ epochDuration: BigInt(epochDuration),
86
+ l1FeesBySlot
87
+ };
88
+ }
89
+ /** Computes per-slot fee predictions given cached state and a mana usage assumption. */ computePredictions(state, manaUsage) {
90
+ const assumedManaUsed = this.getAssumedManaUsed(state, manaUsage);
91
+ const result = [];
92
+ let { excessMana } = state;
93
+ let { ethPerFeeAsset } = state;
94
+ // Slot 0: current state (next available slot after last checkpoint)
95
+ result.push(this.computeGasFees(state, excessMana, ethPerFeeAsset, state.l1FeesBySlot[0]));
96
+ // Slots 1..LAG-1: advance excessMana with the assumed mana usage per checkpoint,
97
+ // and decay ethPerFeeAsset by MAX_FEE_ASSET_PRICE_MODIFIER_BPS per slot for conservative estimates.
98
+ // Lower ethPerFeeAsset means higher fees in fee asset terms.
99
+ for(let i = 1; i < state.l1FeesBySlot.length; i++){
100
+ excessMana = computeExcessMana(excessMana, assumedManaUsed, state.manaTarget);
101
+ const decayed = ethPerFeeAsset * (10000n - MAX_FEE_ASSET_PRICE_MODIFIER_BPS) / 10000n;
102
+ ethPerFeeAsset = decayed < MIN_ETH_PER_FEE_ASSET ? MIN_ETH_PER_FEE_ASSET : decayed;
103
+ result.push(this.computeGasFees(state, excessMana, ethPerFeeAsset, state.l1FeesBySlot[i]));
104
+ }
105
+ return result;
106
+ }
107
+ getAssumedManaUsed(state, manaUsage) {
108
+ switch(manaUsage){
109
+ case ManaUsageEstimate.None:
110
+ return 0n;
111
+ case ManaUsageEstimate.Target:
112
+ return state.manaTarget;
113
+ case ManaUsageEstimate.Limit:
114
+ return state.manaLimit;
115
+ }
116
+ }
117
+ computeGasFees(state, excessMana, ethPerFeeAsset, l1Fees) {
118
+ return new GasFees(0, computeManaMinFee({
119
+ l1BaseFee: l1Fees.baseFee,
120
+ l1BlobFee: l1Fees.blobFee,
121
+ manaTarget: state.manaTarget,
122
+ epochDuration: state.epochDuration,
123
+ provingCostPerManaEth: state.provingCostPerManaEth,
124
+ excessMana,
125
+ ethPerFeeAsset
126
+ }));
127
+ }
128
+ }