@aztec/sequencer-client 0.0.1-commit.358457c → 0.0.1-commit.3895657bc

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 (36) hide show
  1. package/dest/client/sequencer-client.d.ts +12 -1
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +85 -13
  4. package/dest/config.d.ts +23 -4
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +23 -16
  7. package/dest/publisher/sequencer-publisher-factory.d.ts +1 -1
  8. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  9. package/dest/publisher/sequencer-publisher-factory.js +14 -0
  10. package/dest/publisher/sequencer-publisher.d.ts +5 -1
  11. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  12. package/dest/publisher/sequencer-publisher.js +45 -5
  13. package/dest/sequencer/checkpoint_proposal_job.d.ts +2 -4
  14. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  15. package/dest/sequencer/checkpoint_proposal_job.js +60 -35
  16. package/dest/sequencer/sequencer.d.ts +9 -6
  17. package/dest/sequencer/sequencer.d.ts.map +1 -1
  18. package/dest/sequencer/sequencer.js +1 -1
  19. package/dest/sequencer/timetable.d.ts +4 -3
  20. package/dest/sequencer/timetable.d.ts.map +1 -1
  21. package/dest/sequencer/timetable.js +6 -7
  22. package/dest/sequencer/types.d.ts +5 -2
  23. package/dest/sequencer/types.d.ts.map +1 -1
  24. package/dest/test/mock_checkpoint_builder.d.ts +4 -6
  25. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  26. package/dest/test/mock_checkpoint_builder.js +39 -30
  27. package/package.json +28 -28
  28. package/src/client/sequencer-client.ts +111 -12
  29. package/src/config.ts +28 -19
  30. package/src/publisher/sequencer-publisher-factory.ts +15 -0
  31. package/src/publisher/sequencer-publisher.ts +61 -9
  32. package/src/sequencer/checkpoint_proposal_job.ts +76 -42
  33. package/src/sequencer/sequencer.ts +1 -1
  34. package/src/sequencer/timetable.ts +7 -7
  35. package/src/sequencer/types.ts +4 -1
  36. package/src/test/mock_checkpoint_builder.ts +48 -45
@@ -1,6 +1,8 @@
1
+ import { IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
1
2
  import { Fr } from '@aztec/foundation/curves/bn254';
3
+ import { unfreeze } from '@aztec/foundation/types';
4
+ import { L2Block } from '@aztec/stdlib/block';
2
5
  import { Checkpoint } from '@aztec/stdlib/checkpoint';
3
- import { Gas } from '@aztec/stdlib/gas';
4
6
  import { CheckpointHeader } from '@aztec/stdlib/rollup';
5
7
  import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
6
8
  /**
@@ -63,8 +65,10 @@ import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
63
65
  let block;
64
66
  let usedTxs;
65
67
  if (this.blockProvider) {
66
- // Dynamic mode: get block from provider
67
- block = this.blockProvider();
68
+ // Dynamic mode: get block from provider, cloning to avoid shared references across multiple buildBlock calls
69
+ block = L2Block.fromBuffer(this.blockProvider().toBuffer());
70
+ block.header.globalVariables.blockNumber = blockNumber;
71
+ await block.header.recomputeHash();
68
72
  usedTxs = [];
69
73
  this.builtBlocks.push(block);
70
74
  } else {
@@ -87,61 +91,63 @@ import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
87
91
  }
88
92
  return {
89
93
  block,
90
- publicGas: Gas.empty(),
91
94
  publicProcessorDuration: 0,
92
95
  numTxs: block?.body?.txEffects?.length ?? usedTxs.length,
93
96
  usedTxs,
94
- failedTxs: [],
95
- usedTxBlobFields: block?.body?.txEffects?.reduce((sum, tx)=>sum + tx.getNumBlobFields(), 0) ?? 0
97
+ failedTxs: []
96
98
  };
97
99
  }
98
100
  completeCheckpoint() {
99
101
  this.completeCheckpointCalled = true;
100
102
  const allBlocks = this.blockProvider ? this.builtBlocks : this.blocks;
101
- const lastBlock = allBlocks[allBlocks.length - 1];
102
- // Create a CheckpointHeader from the last block's header for testing
103
- const checkpointHeader = this.createCheckpointHeader(lastBlock);
104
- return Promise.resolve(new Checkpoint(makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1), checkpointHeader, allBlocks, this.checkpointNumber));
103
+ return this.buildCheckpoint(allBlocks);
105
104
  }
106
105
  getCheckpoint() {
107
106
  this.getCheckpointCalled = true;
108
107
  const builtBlocks = this.blockProvider ? this.builtBlocks : this.blocks.slice(0, this.blockIndex);
109
- const lastBlock = builtBlocks[builtBlocks.length - 1];
110
- if (!lastBlock) {
108
+ if (builtBlocks.length === 0) {
111
109
  throw new Error('No blocks built yet');
112
110
  }
113
- // Create a CheckpointHeader from the last block's header for testing
114
- const checkpointHeader = this.createCheckpointHeader(lastBlock);
115
- return Promise.resolve(new Checkpoint(makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1), checkpointHeader, builtBlocks, this.checkpointNumber));
116
- }
117
- /**
118
- * Creates a CheckpointHeader from a block's header for testing.
119
- * This is a simplified version that creates a minimal CheckpointHeader.
120
- */ createCheckpointHeader(block) {
121
- const header = block.header;
122
- const gv = header.globalVariables;
123
- return CheckpointHeader.empty({
124
- lastArchiveRoot: header.lastArchive.root,
111
+ return this.buildCheckpoint(builtBlocks);
112
+ }
113
+ /** Builds a structurally valid Checkpoint from a list of blocks, fixing up indexes and archive chaining. */ async buildCheckpoint(blocks) {
114
+ // Fix up indexWithinCheckpoint and archive chaining so the checkpoint passes structural validation.
115
+ for(let i = 0; i < blocks.length; i++){
116
+ blocks[i].indexWithinCheckpoint = IndexWithinCheckpoint(i);
117
+ if (i > 0) {
118
+ unfreeze(blocks[i].header).lastArchive = blocks[i - 1].archive;
119
+ await blocks[i].header.recomputeHash();
120
+ }
121
+ }
122
+ const firstBlock = blocks[0];
123
+ const lastBlock = blocks[blocks.length - 1];
124
+ const gv = firstBlock.header.globalVariables;
125
+ const checkpointHeader = CheckpointHeader.empty({
126
+ lastArchiveRoot: firstBlock.header.lastArchive.root,
125
127
  blockHeadersHash: Fr.random(),
126
128
  slotNumber: gv.slotNumber,
127
129
  timestamp: gv.timestamp,
128
130
  coinbase: gv.coinbase,
129
131
  feeRecipient: gv.feeRecipient,
130
132
  gasFees: gv.gasFees,
131
- totalManaUsed: header.totalManaUsed
133
+ totalManaUsed: lastBlock.header.totalManaUsed
132
134
  });
135
+ return new Checkpoint(makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1), checkpointHeader, blocks, this.checkpointNumber);
133
136
  }
134
- /** Reset for reuse in another test */ reset() {
135
- this.blocks = [];
137
+ /** Resets per-checkpoint state (built blocks, consumed txs) while preserving config (blockProvider, seeded blocks). */ resetCheckpointState() {
136
138
  this.builtBlocks = [];
137
- this.usedTxsPerBlock = [];
138
139
  this.blockIndex = 0;
139
- this.buildBlockCalls = [];
140
140
  this.consumedTxHashes.clear();
141
141
  this.completeCheckpointCalled = false;
142
142
  this.getCheckpointCalled = false;
143
+ }
144
+ /** Reset for reuse in another test */ reset() {
145
+ this.blocks = [];
146
+ this.usedTxsPerBlock = [];
147
+ this.buildBlockCalls = [];
143
148
  this.errorOnBuild = undefined;
144
149
  this.blockProvider = undefined;
150
+ this.resetCheckpointState();
145
151
  }
146
152
  }
147
153
  /**
@@ -175,7 +181,8 @@ import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
175
181
  l1GenesisTime: 0n,
176
182
  slotDuration: 24,
177
183
  l1ChainId: 1,
178
- rollupVersion: 1
184
+ rollupVersion: 1,
185
+ rollupManaLimit: 200_000_000
179
186
  };
180
187
  }
181
188
  updateConfig(config) {
@@ -192,6 +199,8 @@ import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
192
199
  if (!this.checkpointBuilder) {
193
200
  // Auto-create a builder if none was set
194
201
  this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
202
+ } else {
203
+ this.checkpointBuilder.resetCheckpointState();
195
204
  }
196
205
  return Promise.resolve(this.checkpointBuilder);
197
206
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/sequencer-client",
3
- "version": "0.0.1-commit.358457c",
3
+ "version": "0.0.1-commit.3895657bc",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -26,38 +26,38 @@
26
26
  "test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --config jest.integration.config.json"
27
27
  },
28
28
  "dependencies": {
29
- "@aztec/aztec.js": "0.0.1-commit.358457c",
30
- "@aztec/bb-prover": "0.0.1-commit.358457c",
31
- "@aztec/blob-client": "0.0.1-commit.358457c",
32
- "@aztec/blob-lib": "0.0.1-commit.358457c",
33
- "@aztec/constants": "0.0.1-commit.358457c",
34
- "@aztec/epoch-cache": "0.0.1-commit.358457c",
35
- "@aztec/ethereum": "0.0.1-commit.358457c",
36
- "@aztec/foundation": "0.0.1-commit.358457c",
37
- "@aztec/l1-artifacts": "0.0.1-commit.358457c",
38
- "@aztec/merkle-tree": "0.0.1-commit.358457c",
39
- "@aztec/node-keystore": "0.0.1-commit.358457c",
40
- "@aztec/noir-acvm_js": "0.0.1-commit.358457c",
41
- "@aztec/noir-contracts.js": "0.0.1-commit.358457c",
42
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.358457c",
43
- "@aztec/noir-types": "0.0.1-commit.358457c",
44
- "@aztec/p2p": "0.0.1-commit.358457c",
45
- "@aztec/protocol-contracts": "0.0.1-commit.358457c",
46
- "@aztec/prover-client": "0.0.1-commit.358457c",
47
- "@aztec/simulator": "0.0.1-commit.358457c",
48
- "@aztec/slasher": "0.0.1-commit.358457c",
49
- "@aztec/stdlib": "0.0.1-commit.358457c",
50
- "@aztec/telemetry-client": "0.0.1-commit.358457c",
51
- "@aztec/validator-client": "0.0.1-commit.358457c",
52
- "@aztec/validator-ha-signer": "0.0.1-commit.358457c",
53
- "@aztec/world-state": "0.0.1-commit.358457c",
29
+ "@aztec/aztec.js": "0.0.1-commit.3895657bc",
30
+ "@aztec/bb-prover": "0.0.1-commit.3895657bc",
31
+ "@aztec/blob-client": "0.0.1-commit.3895657bc",
32
+ "@aztec/blob-lib": "0.0.1-commit.3895657bc",
33
+ "@aztec/constants": "0.0.1-commit.3895657bc",
34
+ "@aztec/epoch-cache": "0.0.1-commit.3895657bc",
35
+ "@aztec/ethereum": "0.0.1-commit.3895657bc",
36
+ "@aztec/foundation": "0.0.1-commit.3895657bc",
37
+ "@aztec/l1-artifacts": "0.0.1-commit.3895657bc",
38
+ "@aztec/merkle-tree": "0.0.1-commit.3895657bc",
39
+ "@aztec/node-keystore": "0.0.1-commit.3895657bc",
40
+ "@aztec/noir-acvm_js": "0.0.1-commit.3895657bc",
41
+ "@aztec/noir-contracts.js": "0.0.1-commit.3895657bc",
42
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.3895657bc",
43
+ "@aztec/noir-types": "0.0.1-commit.3895657bc",
44
+ "@aztec/p2p": "0.0.1-commit.3895657bc",
45
+ "@aztec/protocol-contracts": "0.0.1-commit.3895657bc",
46
+ "@aztec/prover-client": "0.0.1-commit.3895657bc",
47
+ "@aztec/simulator": "0.0.1-commit.3895657bc",
48
+ "@aztec/slasher": "0.0.1-commit.3895657bc",
49
+ "@aztec/stdlib": "0.0.1-commit.3895657bc",
50
+ "@aztec/telemetry-client": "0.0.1-commit.3895657bc",
51
+ "@aztec/validator-client": "0.0.1-commit.3895657bc",
52
+ "@aztec/validator-ha-signer": "0.0.1-commit.3895657bc",
53
+ "@aztec/world-state": "0.0.1-commit.3895657bc",
54
54
  "lodash.chunk": "^4.2.0",
55
55
  "tslib": "^2.4.0",
56
56
  "viem": "npm:@aztec/viem@2.38.2"
57
57
  },
58
58
  "devDependencies": {
59
- "@aztec/archiver": "0.0.1-commit.358457c",
60
- "@aztec/kv-store": "0.0.1-commit.358457c",
59
+ "@aztec/archiver": "0.0.1-commit.3895657bc",
60
+ "@aztec/kv-store": "0.0.1-commit.3895657bc",
61
61
  "@electric-sql/pglite": "^0.3.14",
62
62
  "@jest/globals": "^30.0.0",
63
63
  "@types/jest": "^30.0.0",
@@ -1,4 +1,5 @@
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
4
  import { isAnvilTestChain } from '@aztec/ethereum/chain';
4
5
  import { getPublicClient } from '@aztec/ethereum/client';
@@ -18,10 +19,15 @@ import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
18
19
  import { L1Metrics, type TelemetryClient } from '@aztec/telemetry-client';
19
20
  import { FullNodeCheckpointsBuilder, NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
20
21
 
21
- import { type SequencerClientConfig, getPublisherConfigFromSequencerConfig } from '../config.js';
22
+ import {
23
+ DefaultSequencerConfig,
24
+ type SequencerClientConfig,
25
+ getPublisherConfigFromSequencerConfig,
26
+ } from '../config.js';
22
27
  import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
23
28
  import { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
24
29
  import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
30
+ import { SequencerTimetable } from '../sequencer/timetable.js';
25
31
 
26
32
  /**
27
33
  * Encapsulates the full sequencer and publisher.
@@ -137,17 +143,14 @@ export class SequencerClient {
137
143
  });
138
144
 
139
145
  const ethereumSlotDuration = config.ethereumSlotDuration;
140
- const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration };
141
146
 
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
- }
147
+ const globalsBuilder = new GlobalVariableBuilder({
148
+ ...config,
149
+ l1GenesisTime,
150
+ slotDuration: Number(slotDuration),
151
+ ethereumSlotDuration,
152
+ rollupVersion,
153
+ });
151
154
 
152
155
  // When running in anvil, assume we can post a tx up until one second before the end of an L1 slot.
153
156
  // Otherwise, we need the full L1 slot duration for publishing to ensure inclusion.
@@ -157,6 +160,15 @@ export class SequencerClient {
157
160
  const l1PublishingTimeBasedOnChain = isAnvilTestChain(config.l1ChainId) ? 1 : ethereumSlotDuration;
158
161
  const l1PublishingTime = config.l1PublishingTime ?? l1PublishingTimeBasedOnChain;
159
162
 
163
+ const { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock } = computeBlockLimits(
164
+ config,
165
+ rollupManaLimit,
166
+ l1PublishingTime,
167
+ log,
168
+ );
169
+
170
+ const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration, rollupManaLimit };
171
+
160
172
  const sequencer = new Sequencer(
161
173
  publisherFactory,
162
174
  validatorClient,
@@ -171,7 +183,7 @@ export class SequencerClient {
171
183
  deps.dateProvider,
172
184
  epochCache,
173
185
  rollupContract,
174
- { ...config, l1PublishingTime, maxL2BlockGas: sequencerManaLimit },
186
+ { ...config, l1PublishingTime, maxL2BlockGas, maxDABlockGas, maxTxsPerBlock },
175
187
  telemetryClient,
176
188
  log,
177
189
  );
@@ -234,3 +246,90 @@ export class SequencerClient {
234
246
  return this.sequencer.maxL2BlockGas;
235
247
  }
236
248
  }
249
+
250
+ /**
251
+ * Computes per-block L2 gas, DA gas, and TX count budgets based on the L1 rollup limits and the timetable.
252
+ * If the user explicitly set a limit, it is capped at the corresponding checkpoint limit.
253
+ * Otherwise, derives it as (checkpointLimit / maxBlocks) * multiplier, capped at the checkpoint limit.
254
+ */
255
+ export function computeBlockLimits(
256
+ config: SequencerClientConfig,
257
+ rollupManaLimit: number,
258
+ l1PublishingTime: number,
259
+ log: ReturnType<typeof createLogger>,
260
+ ): { maxL2BlockGas: number; maxDABlockGas: number; maxTxsPerBlock: number } {
261
+ const maxNumberOfBlocks = new SequencerTimetable({
262
+ ethereumSlotDuration: config.ethereumSlotDuration,
263
+ aztecSlotDuration: config.aztecSlotDuration,
264
+ l1PublishingTime,
265
+ p2pPropagationTime: config.attestationPropagationTime,
266
+ blockDurationMs: config.blockDurationMs,
267
+ enforce: config.enforceTimeTable ?? DefaultSequencerConfig.enforceTimeTable,
268
+ }).maxNumberOfBlocks;
269
+
270
+ const multiplier = config.perBlockAllocationMultiplier ?? DefaultSequencerConfig.perBlockAllocationMultiplier;
271
+
272
+ // Compute maxL2BlockGas
273
+ let maxL2BlockGas: number;
274
+ if (config.maxL2BlockGas !== undefined) {
275
+ if (config.maxL2BlockGas > rollupManaLimit) {
276
+ log.warn(
277
+ `Provided MAX_L2_BLOCK_GAS ${config.maxL2BlockGas} exceeds L1 rollup mana limit ${rollupManaLimit} (capping)`,
278
+ );
279
+ maxL2BlockGas = rollupManaLimit;
280
+ } else {
281
+ maxL2BlockGas = config.maxL2BlockGas;
282
+ }
283
+ } else {
284
+ maxL2BlockGas = Math.min(rollupManaLimit, Math.ceil((rollupManaLimit / maxNumberOfBlocks) * multiplier));
285
+ }
286
+
287
+ // Compute maxDABlockGas
288
+ const daCheckpointLimit = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT;
289
+ let maxDABlockGas: number;
290
+ if (config.maxDABlockGas !== undefined) {
291
+ if (config.maxDABlockGas > daCheckpointLimit) {
292
+ log.warn(
293
+ `Provided MAX_DA_BLOCK_GAS ${config.maxDABlockGas} exceeds DA checkpoint limit ${daCheckpointLimit} (capping)`,
294
+ );
295
+ maxDABlockGas = daCheckpointLimit;
296
+ } else {
297
+ maxDABlockGas = config.maxDABlockGas;
298
+ }
299
+ } else {
300
+ maxDABlockGas = Math.min(daCheckpointLimit, Math.ceil((daCheckpointLimit / maxNumberOfBlocks) * multiplier));
301
+ }
302
+
303
+ // Compute maxTxsPerBlock
304
+ const defaultMaxTxsPerBlock = 32;
305
+ let maxTxsPerBlock: number;
306
+ if (config.maxTxsPerBlock !== undefined) {
307
+ if (config.maxTxsPerCheckpoint !== undefined && config.maxTxsPerBlock > config.maxTxsPerCheckpoint) {
308
+ log.warn(
309
+ `Provided MAX_TX_PER_BLOCK ${config.maxTxsPerBlock} exceeds MAX_TX_PER_CHECKPOINT ${config.maxTxsPerCheckpoint} (capping)`,
310
+ );
311
+ maxTxsPerBlock = config.maxTxsPerCheckpoint;
312
+ } else {
313
+ maxTxsPerBlock = config.maxTxsPerBlock;
314
+ }
315
+ } else if (config.maxTxsPerCheckpoint !== undefined) {
316
+ maxTxsPerBlock = Math.min(
317
+ config.maxTxsPerCheckpoint,
318
+ Math.ceil((config.maxTxsPerCheckpoint / maxNumberOfBlocks) * multiplier),
319
+ );
320
+ } else {
321
+ maxTxsPerBlock = defaultMaxTxsPerBlock;
322
+ }
323
+
324
+ log.info(`Computed block limits L2=${maxL2BlockGas} DA=${maxDABlockGas} maxTxs=${maxTxsPerBlock}`, {
325
+ maxL2BlockGas,
326
+ maxDABlockGas,
327
+ maxTxsPerBlock,
328
+ rollupManaLimit,
329
+ daCheckpointLimit,
330
+ maxNumberOfBlocks,
331
+ multiplier,
332
+ });
333
+
334
+ return { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock };
335
+ }
package/src/config.ts CHANGED
@@ -35,15 +35,12 @@ export type { SequencerConfig };
35
35
  * Default values for SequencerConfig.
36
36
  * Centralized location for all sequencer configuration defaults.
37
37
  */
38
- export const DefaultSequencerConfig: ResolvedSequencerConfig = {
38
+ export const DefaultSequencerConfig = {
39
39
  sequencerPollingIntervalMS: 500,
40
- maxTxsPerBlock: 32,
41
40
  minTxsPerBlock: 1,
42
41
  buildCheckpointIfEmpty: false,
43
42
  publishTxsWithProposals: false,
44
- maxL2BlockGas: 10e9,
45
- maxDABlockGas: 10e9,
46
- maxBlockSizeInBytes: 1024 * 1024,
43
+ perBlockAllocationMultiplier: 2,
47
44
  enforceTimeTable: true,
48
45
  attestationPropagationTime: DEFAULT_P2P_PROPAGATION_TIME,
49
46
  secondsBeforeInvalidatingBlockAsCommitteeMember: 144, // 12 L1 blocks
@@ -52,11 +49,13 @@ export const DefaultSequencerConfig: ResolvedSequencerConfig = {
52
49
  skipInvalidateBlockAsProposer: false,
53
50
  broadcastInvalidBlockProposal: false,
54
51
  injectFakeAttestation: false,
52
+ injectHighSValueAttestation: false,
53
+ injectUnrecoverableSignatureAttestation: false,
55
54
  fishermanMode: false,
56
55
  shuffleAttestationOrdering: false,
57
56
  skipPushProposedBlocksToArchiver: false,
58
57
  skipPublishingCheckpointsPercent: 0,
59
- };
58
+ } satisfies ResolvedSequencerConfig;
60
59
 
61
60
  /**
62
61
  * Configuration settings for the SequencerClient.
@@ -68,7 +67,7 @@ export type SequencerClientConfig = SequencerPublisherConfig &
68
67
  SequencerConfig &
69
68
  L1ReaderConfig &
70
69
  ChainConfig &
71
- Pick<P2PConfig, 'txPublicSetupAllowList'> &
70
+ Pick<P2PConfig, 'txPublicSetupAllowListExtend'> &
72
71
  Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
73
72
 
74
73
  export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
@@ -77,10 +76,10 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
77
76
  description: 'The number of ms to wait between polling for checking to build on the next slot.',
78
77
  ...numberConfigHelper(DefaultSequencerConfig.sequencerPollingIntervalMS),
79
78
  },
80
- maxTxsPerBlock: {
81
- env: 'SEQ_MAX_TX_PER_BLOCK',
82
- description: 'The maximum number of txs to include in a block.',
83
- ...numberConfigHelper(DefaultSequencerConfig.maxTxsPerBlock),
79
+ maxTxsPerCheckpoint: {
80
+ env: 'SEQ_MAX_TX_PER_CHECKPOINT',
81
+ description: 'The maximum number of txs across all blocks in a checkpoint.',
82
+ parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
84
83
  },
85
84
  minTxsPerBlock: {
86
85
  env: 'SEQ_MIN_TX_PER_BLOCK',
@@ -99,12 +98,19 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
99
98
  maxL2BlockGas: {
100
99
  env: 'SEQ_MAX_L2_BLOCK_GAS',
101
100
  description: 'The maximum L2 block gas.',
102
- ...numberConfigHelper(DefaultSequencerConfig.maxL2BlockGas),
101
+ parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
103
102
  },
104
103
  maxDABlockGas: {
105
104
  env: 'SEQ_MAX_DA_BLOCK_GAS',
106
105
  description: 'The maximum DA block gas.',
107
- ...numberConfigHelper(DefaultSequencerConfig.maxDABlockGas),
106
+ parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
107
+ },
108
+ perBlockAllocationMultiplier: {
109
+ env: 'SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER',
110
+ description:
111
+ 'Per-block gas budget multiplier for both L2 and DA gas. Budget per block is (checkpointLimit / maxBlocks) * multiplier.' +
112
+ ' Values greater than one allow early blocks to use more than their even share, relying on checkpoint-level capping for later blocks.',
113
+ ...numberConfigHelper(DefaultSequencerConfig.perBlockAllocationMultiplier),
108
114
  },
109
115
  coinbase: {
110
116
  env: 'COINBASE',
@@ -124,11 +130,6 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
124
130
  env: 'ACVM_BINARY_PATH',
125
131
  description: 'The path to the ACVM binary',
126
132
  },
127
- maxBlockSizeInBytes: {
128
- env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES',
129
- description: 'Max block size',
130
- ...numberConfigHelper(DefaultSequencerConfig.maxBlockSizeInBytes),
131
- },
132
133
  enforceTimeTable: {
133
134
  env: 'SEQ_ENFORCE_TIME_TABLE',
134
135
  description: 'Whether to enforce the time table when building blocks',
@@ -186,6 +187,14 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
186
187
  description: 'Inject a fake attestation (for testing only)',
187
188
  ...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation),
188
189
  },
190
+ injectHighSValueAttestation: {
191
+ description: 'Inject a malleable attestation with a high-s value (for testing only)',
192
+ ...booleanConfigHelper(DefaultSequencerConfig.injectHighSValueAttestation),
193
+ },
194
+ injectUnrecoverableSignatureAttestation: {
195
+ description: 'Inject an attestation with an unrecoverable signature (for testing only)',
196
+ ...booleanConfigHelper(DefaultSequencerConfig.injectUnrecoverableSignatureAttestation),
197
+ },
189
198
  fishermanMode: {
190
199
  env: 'FISHERMAN_MODE',
191
200
  description:
@@ -214,7 +223,7 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
214
223
  description: 'Percent probability (0 - 100) of sequencer skipping checkpoint publishing (testing only)',
215
224
  ...numberConfigHelper(DefaultSequencerConfig.skipPublishingCheckpointsPercent),
216
225
  },
217
- ...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowList']),
226
+ ...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowListExtend']),
218
227
  };
219
228
 
220
229
  export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientConfig> = {
@@ -81,8 +81,23 @@ export class SequencerPublisherFactory {
81
81
  const rollup = this.deps.rollupContract;
82
82
  const slashingProposerContract = await rollup.getSlashingProposer();
83
83
 
84
+ const getNextPublisher = async (excludeAddresses: EthAddress[]): Promise<L1TxUtils | undefined> => {
85
+ const exclusionFilter: PublisherFilter<L1TxUtils> = (utils: L1TxUtils) => {
86
+ if (excludeAddresses.some(addr => addr.equals(utils.getSenderAddress()))) {
87
+ return false;
88
+ }
89
+ return filter(utils);
90
+ };
91
+ try {
92
+ return await this.deps.publisherManager.getAvailablePublisher(exclusionFilter);
93
+ } catch {
94
+ return undefined;
95
+ }
96
+ };
97
+
84
98
  const publisher = new SequencerPublisher(this.sequencerConfig, {
85
99
  l1TxUtils: l1Publisher,
100
+ getNextPublisher,
86
101
  telemetry: this.deps.telemetry,
87
102
  blobClient: this.deps.blobClient,
88
103
  rollupContract: this.deps.rollupContract,
@@ -30,6 +30,7 @@ import { toHex as toPaddedHex } from '@aztec/foundation/bigint-buffer';
30
30
  import { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
31
31
  import { pick } from '@aztec/foundation/collection';
32
32
  import type { Fr } from '@aztec/foundation/curves/bn254';
33
+ import { TimeoutError } from '@aztec/foundation/error';
33
34
  import { EthAddress } from '@aztec/foundation/eth-address';
34
35
  import { Signature, type ViemSignature } from '@aztec/foundation/eth-signature';
35
36
  import { type Logger, createLogger } from '@aztec/foundation/log';
@@ -137,6 +138,9 @@ export class SequencerPublisher {
137
138
  /** Address to use for simulations in fisherman mode (actual proposer's address) */
138
139
  private proposerAddressForSimulation?: EthAddress;
139
140
 
141
+ /** Optional callback to obtain a replacement publisher when the current one fails to send. */
142
+ private getNextPublisher?: (excludeAddresses: EthAddress[]) => Promise<L1TxUtils | undefined>;
143
+
140
144
  /** L1 fee analyzer for fisherman mode */
141
145
  private l1FeeAnalyzer?: L1FeeAnalyzer;
142
146
 
@@ -175,6 +179,7 @@ export class SequencerPublisher {
175
179
  metrics: SequencerPublisherMetrics;
176
180
  lastActions: Partial<Record<Action, SlotNumber>>;
177
181
  log?: Logger;
182
+ getNextPublisher?: (excludeAddresses: EthAddress[]) => Promise<L1TxUtils | undefined>;
178
183
  },
179
184
  ) {
180
185
  this.log = deps.log ?? createLogger('sequencer:publisher');
@@ -188,6 +193,7 @@ export class SequencerPublisher {
188
193
  this.metrics = deps.metrics ?? new SequencerPublisherMetrics(telemetry, 'SequencerPublisher');
189
194
  this.tracer = telemetry.getTracer('SequencerPublisher');
190
195
  this.l1TxUtils = deps.l1TxUtils;
196
+ this.getNextPublisher = deps.getNextPublisher;
191
197
 
192
198
  this.rollupContract = deps.rollupContract;
193
199
 
@@ -437,19 +443,16 @@ export class SequencerPublisher {
437
443
  });
438
444
  const blobDataHex = blobConfig?.blobs?.map(b => toHex(b)) as Hex[] | undefined;
439
445
 
446
+ const txContext = { multicallData, blobData: blobDataHex, l1BlockNumber };
447
+
440
448
  this.log.debug('Forwarding transactions', {
441
449
  validRequests: validRequests.map(request => request.action),
442
450
  txConfig,
443
451
  });
444
- const result = await Multicall3.forward(
445
- validRequests.map(request => request.request),
446
- this.l1TxUtils,
447
- txConfig,
448
- blobConfig,
449
- this.rollupContract.address,
450
- this.log,
451
- );
452
- const txContext = { multicallData, blobData: blobDataHex, l1BlockNumber };
452
+ const result = await this.forwardWithPublisherRotation(validRequests, txConfig, blobConfig);
453
+ if (result === undefined) {
454
+ return undefined;
455
+ }
453
456
  const { successfulActions = [], failedActions = [] } = this.callbackBundledTransactions(
454
457
  validRequests,
455
458
  result,
@@ -472,6 +475,55 @@ export class SequencerPublisher {
472
475
  }
473
476
  }
474
477
 
478
+ /**
479
+ * Forwards transactions via Multicall3, rotating to the next available publisher if a send
480
+ * failure occurs (i.e. the tx never reached the chain).
481
+ * On-chain reverts and simulation errors are returned as-is without rotation.
482
+ */
483
+ private async forwardWithPublisherRotation(
484
+ validRequests: RequestWithExpiry[],
485
+ txConfig: RequestWithExpiry['gasConfig'],
486
+ blobConfig: L1BlobInputs | undefined,
487
+ ) {
488
+ const triedAddresses: EthAddress[] = [];
489
+ let currentPublisher = this.l1TxUtils;
490
+
491
+ while (true) {
492
+ triedAddresses.push(currentPublisher.getSenderAddress());
493
+ try {
494
+ const result = await Multicall3.forward(
495
+ validRequests.map(r => r.request),
496
+ currentPublisher,
497
+ txConfig,
498
+ blobConfig,
499
+ this.rollupContract.address,
500
+ this.log,
501
+ );
502
+ this.l1TxUtils = currentPublisher;
503
+ return result;
504
+ } catch (err) {
505
+ if (err instanceof TimeoutError) {
506
+ throw err;
507
+ }
508
+ const viemError = formatViemError(err);
509
+ if (!this.getNextPublisher) {
510
+ this.log.error('Failed to publish bundled transactions', viemError);
511
+ return undefined;
512
+ }
513
+ this.log.warn(
514
+ `Publisher ${currentPublisher.getSenderAddress()} failed to send, rotating to next publisher`,
515
+ viemError,
516
+ );
517
+ const nextPublisher = await this.getNextPublisher([...triedAddresses]);
518
+ if (!nextPublisher) {
519
+ this.log.error('All available publishers exhausted, failed to publish bundled transactions');
520
+ return undefined;
521
+ }
522
+ currentPublisher = nextPublisher;
523
+ }
524
+ }
525
+ }
526
+
475
527
  private callbackBundledTransactions(
476
528
  requests: RequestWithExpiry[],
477
529
  result: { receipt: TransactionReceipt; errorMsg?: string } | FormattedViemError | undefined,