@aztec/sequencer-client 0.0.1-commit.993d52e → 0.0.1-commit.9a89641

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 (133) hide show
  1. package/README.md +281 -21
  2. package/dest/client/sequencer-client.d.ts +23 -5
  3. package/dest/client/sequencer-client.d.ts.map +1 -1
  4. package/dest/client/sequencer-client.js +63 -36
  5. package/dest/config.d.ts +32 -4
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +76 -32
  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 +138 -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 +80 -0
  14. package/dest/global_variable_builder/global_builder.d.ts +13 -26
  15. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  16. package/dest/global_variable_builder/global_builder.js +9 -66
  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/publisher/config.d.ts +23 -3
  21. package/dest/publisher/config.d.ts.map +1 -1
  22. package/dest/publisher/config.js +36 -6
  23. package/dest/publisher/index.d.ts +2 -1
  24. package/dest/publisher/index.d.ts.map +1 -1
  25. package/dest/publisher/l1_to_l2_messaging.d.ts +21 -0
  26. package/dest/publisher/l1_to_l2_messaging.d.ts.map +1 -0
  27. package/dest/publisher/l1_to_l2_messaging.js +70 -0
  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 +98 -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 +68 -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 +36 -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 +3 -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 +3 -5
  44. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  45. package/dest/publisher/sequencer-publisher-factory.js +16 -3
  46. package/dest/publisher/sequencer-publisher.d.ts +112 -65
  47. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  48. package/dest/publisher/sequencer-publisher.js +758 -388
  49. package/dest/publisher/write_json.d.ts +11 -0
  50. package/dest/publisher/write_json.d.ts.map +1 -0
  51. package/dest/publisher/write_json.js +57 -0
  52. package/dest/sequencer/automine/automine_factory.d.ts +56 -0
  53. package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
  54. package/dest/sequencer/automine/automine_factory.js +85 -0
  55. package/dest/sequencer/automine/automine_sequencer.d.ts +189 -0
  56. package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
  57. package/dest/sequencer/automine/automine_sequencer.js +696 -0
  58. package/dest/sequencer/automine/index.d.ts +3 -0
  59. package/dest/sequencer/automine/index.d.ts.map +1 -0
  60. package/dest/sequencer/automine/index.js +2 -0
  61. package/dest/sequencer/checkpoint_proposal_job.d.ts +75 -19
  62. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  63. package/dest/sequencer/checkpoint_proposal_job.js +846 -264
  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 +62 -5
  71. package/dest/sequencer/events.d.ts.map +1 -1
  72. package/dest/sequencer/metrics.d.ts +13 -10
  73. package/dest/sequencer/metrics.d.ts.map +1 -1
  74. package/dest/sequencer/metrics.js +45 -20
  75. package/dest/sequencer/missing_committee.d.ts +72 -0
  76. package/dest/sequencer/missing_committee.d.ts.map +1 -0
  77. package/dest/sequencer/missing_committee.js +139 -0
  78. package/dest/sequencer/requests_tracker.d.ts +22 -0
  79. package/dest/sequencer/requests_tracker.d.ts.map +1 -0
  80. package/dest/sequencer/requests_tracker.js +33 -0
  81. package/dest/sequencer/sequencer.d.ts +167 -41
  82. package/dest/sequencer/sequencer.d.ts.map +1 -1
  83. package/dest/sequencer/sequencer.js +604 -200
  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 -3
  87. package/dest/test/index.d.ts.map +1 -1
  88. package/dest/test/mock_checkpoint_builder.d.ts +7 -9
  89. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  90. package/dest/test/mock_checkpoint_builder.js +39 -30
  91. package/dest/test/utils.d.ts +15 -1
  92. package/dest/test/utils.d.ts.map +1 -1
  93. package/dest/test/utils.js +25 -7
  94. package/package.json +29 -29
  95. package/src/client/sequencer-client.ts +90 -45
  96. package/src/config.ts +92 -33
  97. package/src/global_variable_builder/README.md +44 -0
  98. package/src/global_variable_builder/fee_predictor.ts +182 -0
  99. package/src/global_variable_builder/fee_provider.ts +97 -0
  100. package/src/global_variable_builder/global_builder.ts +19 -88
  101. package/src/global_variable_builder/index.ts +3 -1
  102. package/src/publisher/config.ts +71 -7
  103. package/src/publisher/index.ts +3 -0
  104. package/src/publisher/l1_to_l2_messaging.ts +85 -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 +164 -0
  107. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +47 -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 +18 -6
  111. package/src/publisher/sequencer-publisher.ts +847 -474
  112. package/src/publisher/write_json.ts +78 -0
  113. package/src/sequencer/README.md +162 -450
  114. package/src/sequencer/automine/README.md +60 -0
  115. package/src/sequencer/automine/automine_factory.ts +152 -0
  116. package/src/sequencer/automine/automine_sequencer.ts +800 -0
  117. package/src/sequencer/automine/index.ts +6 -0
  118. package/src/sequencer/checkpoint_proposal_job.ts +1002 -298
  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 +66 -5
  122. package/src/sequencer/metrics.ts +57 -24
  123. package/src/sequencer/missing_committee.ts +192 -0
  124. package/src/sequencer/requests_tracker.ts +43 -0
  125. package/src/sequencer/sequencer.ts +711 -223
  126. package/src/sequencer/types.ts +1 -1
  127. package/src/test/index.ts +2 -2
  128. package/src/test/mock_checkpoint_builder.ts +51 -48
  129. package/src/test/utils.ts +61 -10
  130. package/dest/sequencer/timetable.d.ts +0 -87
  131. package/dest/sequencer/timetable.d.ts.map +0 -1
  132. package/dest/sequencer/timetable.js +0 -223
  133. package/src/sequencer/timetable.ts +0 -283
@@ -1,6 +1,6 @@
1
1
  import type { BlobClientInterface } from '@aztec/blob-client/client';
2
+ import { MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT } from '@aztec/constants';
2
3
  import { EpochCache } from '@aztec/epoch-cache';
3
- import { isAnvilTestChain } from '@aztec/ethereum/chain';
4
4
  import { getPublicClient } from '@aztec/ethereum/client';
5
5
  import { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
6
6
  import { type Delayer, L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
@@ -11,15 +11,14 @@ import type { DateProvider } from '@aztec/foundation/timer';
11
11
  import type { KeystoreManager } from '@aztec/node-keystore';
12
12
  import type { P2P } from '@aztec/p2p';
13
13
  import type { SlasherClientInterface } from '@aztec/slasher';
14
- import type { L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
14
+ import type { L2BlockSink, L2BlockSource, ProposedCheckpointSink } from '@aztec/stdlib/block';
15
15
  import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
16
- import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
17
16
  import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
18
17
  import { L1Metrics, type TelemetryClient } from '@aztec/telemetry-client';
19
18
  import { FullNodeCheckpointsBuilder, NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
20
19
 
21
20
  import { type SequencerClientConfig, getPublisherConfigFromSequencerConfig } from '../config.js';
22
- import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
21
+ import type { GlobalVariableBuilder } from '../global_variable_builder/index.js';
23
22
  import { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
24
23
  import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
25
24
 
@@ -56,7 +55,7 @@ export class SequencerClient {
56
55
  worldStateSynchronizer: WorldStateSynchronizer;
57
56
  slasherClient: SlasherClientInterface | undefined;
58
57
  checkpointsBuilder: FullNodeCheckpointsBuilder;
59
- l2BlockSource: L2BlockSource & L2BlockSink;
58
+ l2BlockSource: L2BlockSource & L2BlockSink & ProposedCheckpointSink;
60
59
  l1ToL2MessageSource: L1ToL2MessageSource;
61
60
  telemetry: TelemetryClient;
62
61
  publisherFactory?: SequencerPublisherFactory;
@@ -64,7 +63,9 @@ export class SequencerClient {
64
63
  dateProvider: DateProvider;
65
64
  epochCache?: EpochCache;
66
65
  l1TxUtils: L1TxUtils[];
66
+ funderL1TxUtils?: L1TxUtils;
67
67
  nodeKeyStore: KeystoreManager;
68
+ globalVariableBuilder: GlobalVariableBuilder;
68
69
  },
69
70
  ) {
70
71
  const {
@@ -86,27 +87,25 @@ export class SequencerClient {
86
87
  publicClient,
87
88
  l1TxUtils.map(x => x.getSenderAddress()),
88
89
  );
89
- const publisherManager = new PublisherManager(
90
- l1TxUtils,
91
- getPublisherConfigFromSequencerConfig(config),
92
- log.getBindings(),
93
- );
94
- const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
95
- const [l1GenesisTime, slotDuration, rollupVersion, rollupManaLimit] = await Promise.all([
90
+ const publisherManager = new PublisherManager(l1TxUtils, getPublisherConfigFromSequencerConfig(config), {
91
+ bindings: log.getBindings(),
92
+ funder: deps.funderL1TxUtils,
93
+ });
94
+ const rollupContract = new RollupContract(publicClient, config.rollupAddress.toString());
95
+ const [l1GenesisTime, slotDuration, rollupManaLimit] = await Promise.all([
96
96
  rollupContract.getL1GenesisTime(),
97
97
  rollupContract.getSlotDuration(),
98
- rollupContract.getVersion(),
99
98
  rollupContract.getManaLimit().then(Number),
100
99
  ] as const);
101
100
 
102
101
  const governanceProposerContract = new GovernanceProposerContract(
103
102
  publicClient,
104
- config.l1Contracts.governanceProposerAddress.toString(),
103
+ config.governanceProposerAddress.toString(),
105
104
  );
106
105
  const epochCache =
107
106
  deps.epochCache ??
108
107
  (await EpochCache.create(
109
- config.l1Contracts.rollupAddress,
108
+ config.rollupAddress,
110
109
  {
111
110
  l1RpcUrls: rpcUrls,
112
111
  l1ChainId: chainId,
@@ -116,11 +115,6 @@ export class SequencerClient {
116
115
  { dateProvider: deps.dateProvider },
117
116
  ));
118
117
 
119
- const slashFactoryContract = new SlashFactoryContract(
120
- publicClient,
121
- config.l1Contracts.slashFactoryAddress?.toString() ?? EthAddress.ZERO.toString(),
122
- );
123
-
124
118
  const publisherFactory =
125
119
  deps.publisherFactory ??
126
120
  new SequencerPublisherFactory(config, {
@@ -128,7 +122,6 @@ export class SequencerClient {
128
122
  blobClient: deps.blobClient,
129
123
  epochCache,
130
124
  governanceProposerContract,
131
- slashFactoryContract,
132
125
  rollupContract,
133
126
  dateProvider: deps.dateProvider,
134
127
  publisherManager,
@@ -137,25 +130,18 @@ export class SequencerClient {
137
130
  });
138
131
 
139
132
  const ethereumSlotDuration = config.ethereumSlotDuration;
140
- const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration };
141
-
142
- const globalsBuilder = new GlobalVariableBuilder({ ...config, ...l1Constants, rollupVersion });
143
-
144
- let sequencerManaLimit = config.maxL2BlockGas ?? rollupManaLimit;
145
- if (sequencerManaLimit > rollupManaLimit) {
146
- log.warn(
147
- `Provided maxL2BlockGas ${sequencerManaLimit} is greater than the max allowed by L1. Setting limit to ${rollupManaLimit}.`,
148
- );
149
- sequencerManaLimit = rollupManaLimit;
150
- }
151
-
152
- // When running in anvil, assume we can post a tx up until one second before the end of an L1 slot.
153
- // Otherwise, we need the full L1 slot duration for publishing to ensure inclusion.
154
- // In theory, the L1 slot has an initial 4s phase where the block is propagated, so we could
155
- // reduce the publishing time allowance. However, we prefer being conservative.
156
- // See https://www.blocknative.com/blog/anatomy-of-a-slot#7 for more info.
157
- const l1PublishingTimeBasedOnChain = isAnvilTestChain(config.l1ChainId) ? 1 : ethereumSlotDuration;
158
- const l1PublishingTime = config.l1PublishingTime ?? l1PublishingTimeBasedOnChain;
133
+
134
+ const globalsBuilder = deps.globalVariableBuilder;
135
+
136
+ const { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock } = capPerBlockLimits(config, rollupManaLimit, log);
137
+
138
+ const l1Constants = {
139
+ l1GenesisTime,
140
+ slotDuration: Number(slotDuration),
141
+ ethereumSlotDuration,
142
+ rollupManaLimit,
143
+ epochDuration: config.aztecEpochDuration,
144
+ };
159
145
 
160
146
  const sequencer = new Sequencer(
161
147
  publisherFactory,
@@ -171,7 +157,7 @@ export class SequencerClient {
171
157
  deps.dateProvider,
172
158
  epochCache,
173
159
  rollupContract,
174
- { ...config, l1PublishingTime, maxL2BlockGas: sequencerManaLimit },
160
+ { ...config, maxL2BlockGas, maxDABlockGas, maxTxsPerBlock },
175
161
  telemetryClient,
176
162
  log,
177
163
  );
@@ -194,24 +180,45 @@ export class SequencerClient {
194
180
  this.validatorClient?.updateConfig(config);
195
181
  }
196
182
 
197
- /** Starts the sequencer. */
183
+ /**
184
+ * Starts (or resumes) the sequencer, validator, publishers, and metrics. Each underlying start is
185
+ * idempotent, so this is safe to call after a previous {@link pause} to resume building and publishing.
186
+ * The publisher manager is started before the sequencer's poll loop so publishing is ready before the
187
+ * sequencer first tries to publish to L1.
188
+ */
198
189
  public async start() {
199
190
  await this.validatorClient?.start();
191
+ await this.publisherManager.start();
200
192
  this.sequencer.start();
201
193
  this.l1Metrics?.start();
202
- await this.publisherManager.loadState();
203
194
  }
204
195
 
205
196
  /**
206
- * Stops the sequencer from processing new txs.
197
+ * Stops the sequencer, validator, publishers, and metrics for good, draining in-flight work. This is the
198
+ * final teardown path: stopping the validator client closes its slashing-protection database. For a
199
+ * restartable pause (e.g. around a test clock warp) use {@link pause} instead.
207
200
  */
208
201
  public async stop() {
209
202
  await this.sequencer.stop();
210
203
  await this.validatorClient?.stop();
211
- this.publisherManager.interrupt();
204
+ await this.publisherManager.stop();
212
205
  this.l1Metrics?.stop();
213
206
  }
214
207
 
208
+ /**
209
+ * Gracefully pauses block production, waiting for in-flight work to finish rather than interrupting it,
210
+ * while leaving the validator, publishers, and metrics running so the sequencer can be resumed with
211
+ * {@link start}. Used by tests that pause sequencers around an L1 clock warp.
212
+ */
213
+ public async pause() {
214
+ await this.sequencer.pause();
215
+ }
216
+
217
+ /** Triggers an immediate run of the sequencer, bypassing the polling interval. */
218
+ public trigger() {
219
+ return this.sequencer.trigger();
220
+ }
221
+
215
222
  public getSequencer(): Sequencer {
216
223
  return this.sequencer;
217
224
  }
@@ -234,3 +241,41 @@ export class SequencerClient {
234
241
  return this.sequencer.maxL2BlockGas;
235
242
  }
236
243
  }
244
+
245
+ /**
246
+ * Caps operator-provided per-block limits at checkpoint-level limits.
247
+ * Returns undefined for any limit the operator didn't set — the checkpoint builder handles redistribution.
248
+ */
249
+ function capPerBlockLimits(
250
+ config: SequencerClientConfig,
251
+ rollupManaLimit: number,
252
+ log: ReturnType<typeof createLogger>,
253
+ ): { maxL2BlockGas: number | undefined; maxDABlockGas: number | undefined; maxTxsPerBlock: number | undefined } {
254
+ let maxL2BlockGas = config.maxL2BlockGas;
255
+ if (maxL2BlockGas !== undefined && maxL2BlockGas > rollupManaLimit) {
256
+ log.warn(`Provided MAX_L2_BLOCK_GAS ${maxL2BlockGas} exceeds rollup mana limit ${rollupManaLimit} (capping)`);
257
+ maxL2BlockGas = rollupManaLimit;
258
+ }
259
+
260
+ let maxDABlockGas = config.maxDABlockGas;
261
+ if (maxDABlockGas !== undefined && maxDABlockGas > MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT) {
262
+ log.warn(
263
+ `Provided MAX_DA_BLOCK_GAS ${maxDABlockGas} exceeds DA checkpoint limit ${MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT} (capping)`,
264
+ );
265
+ maxDABlockGas = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT;
266
+ }
267
+
268
+ let maxTxsPerBlock = config.maxTxsPerBlock;
269
+ if (
270
+ maxTxsPerBlock !== undefined &&
271
+ config.maxTxsPerCheckpoint !== undefined &&
272
+ maxTxsPerBlock > config.maxTxsPerCheckpoint
273
+ ) {
274
+ log.warn(
275
+ `Provided MAX_TX_PER_BLOCK ${maxTxsPerBlock} exceeds MAX_TX_PER_CHECKPOINT ${config.maxTxsPerCheckpoint} (capping)`,
276
+ );
277
+ maxTxsPerBlock = config.maxTxsPerCheckpoint;
278
+ }
279
+
280
+ return { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock };
281
+ }
package/src/config.ts CHANGED
@@ -3,8 +3,10 @@ import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-
3
3
  import {
4
4
  type ConfigMappingsType,
5
5
  booleanConfigHelper,
6
+ floatConfigHelper,
6
7
  getConfigFromMappings,
7
8
  numberConfigHelper,
9
+ optionalNumberConfigHelper,
8
10
  pickConfigMappings,
9
11
  } from '@aztec/foundation/config';
10
12
  import { EthAddress } from '@aztec/foundation/eth-address';
@@ -13,11 +15,13 @@ import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
13
15
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
14
16
  import {
15
17
  type ChainConfig,
16
- DEFAULT_MAX_TXS_PER_BLOCK,
18
+ DEFAULT_BLOCK_DURATION_MS,
19
+ DEFAULT_MAX_BLOCKS_PER_CHECKPOINT,
17
20
  type SequencerConfig,
18
21
  chainConfigMappings,
19
22
  sharedSequencerConfigMappings,
20
23
  } from '@aztec/stdlib/config';
24
+ import { MIN_PER_BLOCK_ALLOCATION_MULTIPLIER, MIN_PER_BLOCK_DA_ALLOCATION_MULTIPLIER } from '@aztec/stdlib/gas';
21
25
  import type { ResolvedSequencerConfig } from '@aztec/stdlib/interfaces/server';
22
26
  import { DEFAULT_P2P_PROPAGATION_TIME } from '@aztec/stdlib/timetable';
23
27
  import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
@@ -36,30 +40,36 @@ export type { SequencerConfig };
36
40
  * Default values for SequencerConfig.
37
41
  * Centralized location for all sequencer configuration defaults.
38
42
  */
39
- export const DefaultSequencerConfig: ResolvedSequencerConfig = {
43
+ export const DefaultSequencerConfig = {
40
44
  sequencerPollingIntervalMS: 500,
41
- maxTxsPerBlock: DEFAULT_MAX_TXS_PER_BLOCK,
42
45
  minTxsPerBlock: 1,
43
46
  buildCheckpointIfEmpty: false,
44
47
  publishTxsWithProposals: false,
45
- maxL2BlockGas: 10e9,
46
- maxDABlockGas: 10e9,
47
- maxBlockSizeInBytes: 1024 * 1024,
48
- enforceTimeTable: true,
48
+ perBlockAllocationMultiplier: MIN_PER_BLOCK_ALLOCATION_MULTIPLIER,
49
+ perBlockDAAllocationMultiplier: MIN_PER_BLOCK_DA_ALLOCATION_MULTIPLIER,
50
+ redistributeCheckpointBudget: true,
51
+ blockDurationMs: DEFAULT_BLOCK_DURATION_MS,
52
+ l1PublishingTime: 12,
53
+ checkpointProposalSyncGraceSeconds: 2 * (DEFAULT_BLOCK_DURATION_MS / 1000),
49
54
  attestationPropagationTime: DEFAULT_P2P_PROPAGATION_TIME,
50
55
  secondsBeforeInvalidatingBlockAsCommitteeMember: 144, // 12 L1 blocks
51
56
  secondsBeforeInvalidatingBlockAsNonCommitteeMember: 432, // 36 L1 blocks
52
57
  skipCollectingAttestations: false,
53
58
  skipInvalidateBlockAsProposer: false,
59
+ skipWaitForValidParentCheckpointOnL1: false,
54
60
  broadcastInvalidBlockProposal: false,
61
+ broadcastInvalidCheckpointProposalOnly: false,
55
62
  injectFakeAttestation: false,
56
63
  injectHighSValueAttestation: false,
57
64
  injectUnrecoverableSignatureAttestation: false,
65
+ injectYParityAttestation: false,
58
66
  fishermanMode: false,
67
+ governanceProposerForcePayloadVote: false,
59
68
  shuffleAttestationOrdering: false,
60
69
  skipPushProposedBlocksToArchiver: false,
61
70
  skipPublishingCheckpointsPercent: 0,
62
- };
71
+ maxBlocksPerCheckpoint: DEFAULT_MAX_BLOCKS_PER_CHECKPOINT,
72
+ } satisfies ResolvedSequencerConfig;
63
73
 
64
74
  /**
65
75
  * Configuration settings for the SequencerClient.
@@ -71,7 +81,7 @@ export type SequencerClientConfig = SequencerPublisherConfig &
71
81
  SequencerConfig &
72
82
  L1ReaderConfig &
73
83
  ChainConfig &
74
- Pick<P2PConfig, 'txPublicSetupAllowList'> &
84
+ Pick<P2PConfig, 'txPublicSetupAllowListExtend'> &
75
85
  Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
76
86
 
77
87
  export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
@@ -80,6 +90,11 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
80
90
  description: 'The number of ms to wait between polling for checking to build on the next slot.',
81
91
  ...numberConfigHelper(DefaultSequencerConfig.sequencerPollingIntervalMS),
82
92
  },
93
+ maxTxsPerCheckpoint: {
94
+ env: 'SEQ_MAX_TX_PER_CHECKPOINT',
95
+ description: 'The maximum number of txs across all blocks in a checkpoint.',
96
+ ...optionalNumberConfigHelper(),
97
+ },
83
98
  minTxsPerBlock: {
84
99
  env: 'SEQ_MIN_TX_PER_BLOCK',
85
100
  description: 'The minimum number of txs to include in a block.',
@@ -97,21 +112,41 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
97
112
  maxL2BlockGas: {
98
113
  env: 'SEQ_MAX_L2_BLOCK_GAS',
99
114
  description: 'The maximum L2 block gas.',
100
- ...numberConfigHelper(DefaultSequencerConfig.maxL2BlockGas),
115
+ ...optionalNumberConfigHelper(),
101
116
  },
102
117
  maxDABlockGas: {
103
118
  env: 'SEQ_MAX_DA_BLOCK_GAS',
104
119
  description: 'The maximum DA block gas.',
105
- ...numberConfigHelper(DefaultSequencerConfig.maxDABlockGas),
120
+ ...optionalNumberConfigHelper(),
121
+ },
122
+ perBlockAllocationMultiplier: {
123
+ env: 'SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER',
124
+ description:
125
+ 'Per-block gas budget multiplier for both L2 and DA gas. Budget per block is (checkpointLimit / maxBlocks) * multiplier.' +
126
+ ' Values greater than one allow early blocks to use more than their even share, relying on checkpoint-level capping for later blocks.',
127
+ ...floatConfigHelper(DefaultSequencerConfig.perBlockAllocationMultiplier),
128
+ },
129
+ perBlockDAAllocationMultiplier: {
130
+ env: 'SEQ_PER_BLOCK_DA_ALLOCATION_MULTIPLIER',
131
+ description:
132
+ 'Per-block budget multiplier applied to DA gas and blob fields in place of perBlockAllocationMultiplier.' +
133
+ ' Defaults higher than the general multiplier so the largest contract class deploy fits a single block.',
134
+ ...floatConfigHelper(DefaultSequencerConfig.perBlockDAAllocationMultiplier),
135
+ },
136
+ redistributeCheckpointBudget: {
137
+ env: 'SEQ_REDISTRIBUTE_CHECKPOINT_BUDGET',
138
+ description:
139
+ 'Redistribute remaining checkpoint budget evenly across remaining blocks instead of allowing a single block to consume the entire remaining budget.',
140
+ ...booleanConfigHelper(DefaultSequencerConfig.redistributeCheckpointBudget),
106
141
  },
107
142
  coinbase: {
108
143
  env: 'COINBASE',
109
- parseEnv: (val: string) => (val ? EthAddress.fromString(val) : undefined),
144
+ parseEnv: (val: string) => EthAddress.fromString(val),
110
145
  description: 'Recipient of block reward.',
111
146
  },
112
147
  feeRecipient: {
113
148
  env: 'FEE_RECIPIENT',
114
- parseEnv: (val: string) => AztecAddress.fromString(val),
149
+ parseEnv: (val: string) => AztecAddress.fromStringUnsafe(val),
115
150
  description: 'Address to receive fees.',
116
151
  },
117
152
  acvmWorkingDirectory: {
@@ -122,30 +157,21 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
122
157
  env: 'ACVM_BINARY_PATH',
123
158
  description: 'The path to the ACVM binary',
124
159
  },
125
- maxBlockSizeInBytes: {
126
- env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES',
127
- description: 'Max block size',
128
- ...numberConfigHelper(DefaultSequencerConfig.maxBlockSizeInBytes),
129
- },
130
- enforceTimeTable: {
131
- env: 'SEQ_ENFORCE_TIME_TABLE',
132
- description: 'Whether to enforce the time table when building blocks',
133
- ...booleanConfigHelper(DefaultSequencerConfig.enforceTimeTable),
134
- },
135
160
  governanceProposerPayload: {
136
161
  env: 'GOVERNANCE_PROPOSER_PAYLOAD_ADDRESS',
137
162
  description: 'The address of the payload for the governanceProposer',
138
163
  parseEnv: (val: string) => EthAddress.fromString(val),
139
164
  },
165
+ governanceProposerForcePayloadVote: {
166
+ env: 'GOVERNANCE_PROPOSER_FORCE_PAYLOAD_VOTE',
167
+ description:
168
+ 'Keep signalling the configured governance payload even if a proposal referencing it was already executed.',
169
+ ...booleanConfigHelper(DefaultSequencerConfig.governanceProposerForcePayloadVote),
170
+ },
140
171
  l1PublishingTime: {
141
172
  env: 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT',
142
- description: 'How much time (in seconds) we allow in the slot for publishing the L1 tx (defaults to 1 L1 slot).',
143
- parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
144
- },
145
- attestationPropagationTime: {
146
- env: 'SEQ_ATTESTATION_PROPAGATION_TIME',
147
- description: 'How many seconds it takes for proposals and attestations to travel across the p2p layer (one-way)',
148
- ...numberConfigHelper(DefaultSequencerConfig.attestationPropagationTime),
173
+ description: 'How much time in seconds to allow in the slot for publishing the L1 transaction.',
174
+ ...numberConfigHelper(DefaultSequencerConfig.l1PublishingTime),
149
175
  },
150
176
  fakeProcessingDelayPerTxMs: {
151
177
  description: 'Used for testing to introduce a fake delay after processing each tx',
@@ -176,10 +202,25 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
176
202
  description: 'Do not invalidate the previous block if invalid when we are the proposer (for testing only)',
177
203
  ...booleanConfigHelper(DefaultSequencerConfig.skipInvalidateBlockAsProposer),
178
204
  },
205
+ skipWaitForValidParentCheckpointOnL1: {
206
+ description:
207
+ 'Bypass the parent checkpoint validity check before submitting a pipelined checkpoint, ' +
208
+ 'allowing the proposer to publish even when the parent landed on L1 with invalid attestations (for testing only)',
209
+ ...booleanConfigHelper(DefaultSequencerConfig.skipWaitForValidParentCheckpointOnL1),
210
+ },
179
211
  broadcastInvalidBlockProposal: {
180
212
  description: 'Broadcast invalid block proposals with corrupted state (for testing only)',
181
213
  ...booleanConfigHelper(DefaultSequencerConfig.broadcastInvalidBlockProposal),
182
214
  },
215
+ invalidBlockProposalIndexWithinCheckpoint: {
216
+ description: 'Broadcast an invalid block proposal only at this indexWithinCheckpoint (for testing only)',
217
+ ...optionalNumberConfigHelper(),
218
+ },
219
+ broadcastInvalidCheckpointProposalOnly: {
220
+ description:
221
+ 'Broadcast invalid checkpoint proposals while keeping the underlying block proposals valid (for testing only). When unset, the checkpoint follows broadcastInvalidBlockProposal.',
222
+ ...booleanConfigHelper(DefaultSequencerConfig.broadcastInvalidCheckpointProposalOnly),
223
+ },
183
224
  injectFakeAttestation: {
184
225
  description: 'Inject a fake attestation (for testing only)',
185
226
  ...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation),
@@ -192,6 +233,10 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
192
233
  description: 'Inject an attestation with an unrecoverable signature (for testing only)',
193
234
  ...booleanConfigHelper(DefaultSequencerConfig.injectUnrecoverableSignatureAttestation),
194
235
  },
236
+ injectYParityAttestation: {
237
+ description: 'Inject a non-proposer attestation slot in yParity form in the packed L1 tuple (for testing only)',
238
+ ...booleanConfigHelper(DefaultSequencerConfig.injectYParityAttestation),
239
+ },
195
240
  fishermanMode: {
196
241
  env: 'FISHERMAN_MODE',
197
242
  description:
@@ -209,7 +254,7 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
209
254
  ...booleanConfigHelper(DefaultSequencerConfig.buildCheckpointIfEmpty),
210
255
  },
211
256
  skipPushProposedBlocksToArchiver: {
212
- description: 'Skip pushing proposed blocks to archiver (default: true)',
257
+ description: 'Skip pushing proposed blocks to archiver (test only)',
213
258
  ...booleanConfigHelper(DefaultSequencerConfig.skipPushProposedBlocksToArchiver),
214
259
  },
215
260
  minBlocksForCheckpoint: {
@@ -220,17 +265,31 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
220
265
  description: 'Percent probability (0 - 100) of sequencer skipping checkpoint publishing (testing only)',
221
266
  ...numberConfigHelper(DefaultSequencerConfig.skipPublishingCheckpointsPercent),
222
267
  },
223
- ...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowList']),
268
+ skipBroadcastProposals: {
269
+ description: 'Skip broadcasting checkpoint and block proposals via gossipsub when proposer (for testing only)',
270
+ ...booleanConfigHelper(false),
271
+ },
272
+ skipBroadcastCheckpointProposal: {
273
+ description:
274
+ 'Skip broadcasting only the CheckpointProposal via gossipsub when proposer; the held last block is broadcast ' +
275
+ 'standalone instead so peers still receive it as a proposed-but-uncheckpointed tip (for testing only)',
276
+ ...booleanConfigHelper(false),
277
+ },
278
+ pauseProposingForSlots: {
279
+ description:
280
+ 'List of slots for which the sequencer will not produce a proposal (for testing only). Attestation paths are unaffected.',
281
+ },
282
+ ...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowListExtend']),
224
283
  };
225
284
 
226
285
  export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientConfig> = {
286
+ ...chainConfigMappings,
227
287
  ...validatorClientConfigMappings,
228
288
  ...sequencerConfigMappings,
229
289
  ...keyStoreConfigMappings,
230
290
  ...l1ReaderConfigMappings,
231
291
  ...sequencerTxSenderConfigMappings,
232
292
  ...sequencerPublisherConfigMappings,
233
- ...chainConfigMappings,
234
293
  ...pickConfigMappings(l1ContractsConfigMappings, ['ethereumSlotDuration', 'aztecSlotDuration', 'aztecEpochDuration']),
235
294
  };
236
295
 
@@ -0,0 +1,44 @@
1
+ # Fee Prediction
2
+
3
+ The `FeePredictor` predicts min fees for upcoming L2 slots based on the current L1
4
+ oracle state and an assumed mana usage pattern.
5
+
6
+ ## Prediction Window
7
+
8
+ The prediction covers `LAG = 2` entries (the next available slot plus 1 more).
9
+ A new oracle update can activate at `startSlot + LAG`, so only the first LAG entries
10
+ are guaranteed stable. Beyond that, L1 fees could change unpredictably.
11
+
12
+ Each entry uses:
13
+
14
+ - The **actual L1 fees** the oracle would return for that slot's timestamp (pre or post,
15
+ depending on whether the slot is before or after `slotOfChange`).
16
+ - A **configurable congestion assumption** (`ManaUsageEstimate`): none (0 mana), target
17
+ (steady state), or limit (worst case, 2x target).
18
+
19
+ The client picks `max(predicted[0..LAG-1])` as their `maxFeesPerGas`.
20
+
21
+ ```
22
+ predicted[0] → fee at next slot (current oracle + current congestion)
23
+ predicted[1] → fee at next slot + 1 (congestion may change based on usage estimate)
24
+ ```
25
+
26
+ ## Why LAG and not LIFETIME?
27
+
28
+ The L1 gas oracle has two timing constants:
29
+
30
+ - **LAG = 2 slots**: when new fees are queued, they activate LAG slots later
31
+ - **LIFETIME = 5 slots**: after an oracle update, the next update is rejected until
32
+ `slotOfChange + (LIFETIME - LAG)` slots have passed
33
+
34
+ If the oracle cooldown has already elapsed (i.e., no recent update), a new update can
35
+ be enqueued at any moment. Its new values would activate LAG slots later. This means
36
+ predictions beyond LAG slots could be invalidated by an oracle update that happens
37
+ right after we query.
38
+
39
+ With a LIFETIME-sized window, we'd give a false sense of coverage: the prediction
40
+ would look like it covers 6 slots, but slots beyond LAG could be wrong if an update
41
+ is enqueued after the prediction is computed.
42
+
43
+ By limiting to LAG entries, we guarantee that all predicted L1 fees are the ones that
44
+ will actually be used — no oracle update can change them within this window.