@aztec/sequencer-client 4.0.4 → 4.1.0-rc.2

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.
@@ -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
@@ -13,7 +13,6 @@ import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
13
13
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
14
14
  import {
15
15
  type ChainConfig,
16
- DEFAULT_MAX_TXS_PER_BLOCK,
17
16
  type SequencerConfig,
18
17
  chainConfigMappings,
19
18
  sharedSequencerConfigMappings,
@@ -36,15 +35,12 @@ export type { SequencerConfig };
36
35
  * Default values for SequencerConfig.
37
36
  * Centralized location for all sequencer configuration defaults.
38
37
  */
39
- export const DefaultSequencerConfig: ResolvedSequencerConfig = {
38
+ export const DefaultSequencerConfig = {
40
39
  sequencerPollingIntervalMS: 500,
41
- maxTxsPerBlock: DEFAULT_MAX_TXS_PER_BLOCK,
42
40
  minTxsPerBlock: 1,
43
41
  buildCheckpointIfEmpty: false,
44
42
  publishTxsWithProposals: false,
45
- maxL2BlockGas: 10e9,
46
- maxDABlockGas: 10e9,
47
- maxBlockSizeInBytes: 1024 * 1024,
43
+ perBlockAllocationMultiplier: 2,
48
44
  enforceTimeTable: true,
49
45
  attestationPropagationTime: DEFAULT_P2P_PROPAGATION_TIME,
50
46
  secondsBeforeInvalidatingBlockAsCommitteeMember: 144, // 12 L1 blocks
@@ -53,11 +49,13 @@ export const DefaultSequencerConfig: ResolvedSequencerConfig = {
53
49
  skipInvalidateBlockAsProposer: false,
54
50
  broadcastInvalidBlockProposal: false,
55
51
  injectFakeAttestation: false,
52
+ injectHighSValueAttestation: false,
53
+ injectUnrecoverableSignatureAttestation: false,
56
54
  fishermanMode: false,
57
55
  shuffleAttestationOrdering: false,
58
56
  skipPushProposedBlocksToArchiver: false,
59
57
  skipPublishingCheckpointsPercent: 0,
60
- };
58
+ } satisfies ResolvedSequencerConfig;
61
59
 
62
60
  /**
63
61
  * Configuration settings for the SequencerClient.
@@ -69,7 +67,7 @@ export type SequencerClientConfig = SequencerPublisherConfig &
69
67
  SequencerConfig &
70
68
  L1ReaderConfig &
71
69
  ChainConfig &
72
- Pick<P2PConfig, 'txPublicSetupAllowList'> &
70
+ Pick<P2PConfig, 'txPublicSetupAllowListExtend'> &
73
71
  Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
74
72
 
75
73
  export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
@@ -78,6 +76,11 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
78
76
  description: 'The number of ms to wait between polling for checking to build on the next slot.',
79
77
  ...numberConfigHelper(DefaultSequencerConfig.sequencerPollingIntervalMS),
80
78
  },
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),
83
+ },
81
84
  minTxsPerBlock: {
82
85
  env: 'SEQ_MIN_TX_PER_BLOCK',
83
86
  description: 'The minimum number of txs to include in a block.',
@@ -95,12 +98,19 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
95
98
  maxL2BlockGas: {
96
99
  env: 'SEQ_MAX_L2_BLOCK_GAS',
97
100
  description: 'The maximum L2 block gas.',
98
- ...numberConfigHelper(DefaultSequencerConfig.maxL2BlockGas),
101
+ parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
99
102
  },
100
103
  maxDABlockGas: {
101
104
  env: 'SEQ_MAX_DA_BLOCK_GAS',
102
105
  description: 'The maximum DA block gas.',
103
- ...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),
104
114
  },
105
115
  coinbase: {
106
116
  env: 'COINBASE',
@@ -120,11 +130,6 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
120
130
  env: 'ACVM_BINARY_PATH',
121
131
  description: 'The path to the ACVM binary',
122
132
  },
123
- maxBlockSizeInBytes: {
124
- env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES',
125
- description: 'Max block size',
126
- ...numberConfigHelper(DefaultSequencerConfig.maxBlockSizeInBytes),
127
- },
128
133
  enforceTimeTable: {
129
134
  env: 'SEQ_ENFORCE_TIME_TABLE',
130
135
  description: 'Whether to enforce the time table when building blocks',
@@ -182,6 +187,14 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
182
187
  description: 'Inject a fake attestation (for testing only)',
183
188
  ...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation),
184
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
+ },
185
198
  fishermanMode: {
186
199
  env: 'FISHERMAN_MODE',
187
200
  description:
@@ -210,7 +223,7 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
210
223
  description: 'Percent probability (0 - 100) of sequencer skipping checkpoint publishing (testing only)',
211
224
  ...numberConfigHelper(DefaultSequencerConfig.skipPublishingCheckpointsPercent),
212
225
  },
213
- ...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowList']),
226
+ ...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowListExtend']),
214
227
  };
215
228
 
216
229
  export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientConfig> = {
@@ -1,5 +1,3 @@
1
- import { NUM_CHECKPOINT_END_MARKER_FIELDS, getNumBlockEndBlobFields } from '@aztec/blob-lib/encoding';
2
- import { BLOBS_PER_CHECKPOINT, FIELDS_PER_BLOB } from '@aztec/constants';
3
1
  import type { EpochCache } from '@aztec/epoch-cache';
4
2
  import {
5
3
  BlockNumber,
@@ -9,6 +7,11 @@ import {
9
7
  SlotNumber,
10
8
  } from '@aztec/foundation/branded-types';
11
9
  import { randomInt } from '@aztec/foundation/crypto/random';
10
+ import {
11
+ flipSignature,
12
+ generateRecoverableSignature,
13
+ generateUnrecoverableSignature,
14
+ } from '@aztec/foundation/crypto/secp256k1-signer';
12
15
  import { Fr } from '@aztec/foundation/curves/bn254';
13
16
  import { EthAddress } from '@aztec/foundation/eth-address';
14
17
  import { Signature } from '@aztec/foundation/eth-signature';
@@ -27,7 +30,7 @@ import {
27
30
  type L2BlockSource,
28
31
  MaliciousCommitteeAttestationsAndSigners,
29
32
  } from '@aztec/stdlib/block';
30
- import type { Checkpoint } from '@aztec/stdlib/checkpoint';
33
+ import { type Checkpoint, validateCheckpoint } from '@aztec/stdlib/checkpoint';
31
34
  import { getSlotStartBuildTimestamp } from '@aztec/stdlib/epoch-helpers';
32
35
  import { Gas } from '@aztec/stdlib/gas';
33
36
  import {
@@ -262,6 +265,22 @@ export class CheckpointProposalJob implements Traceable {
262
265
  this.setStateFn(SequencerState.ASSEMBLING_CHECKPOINT, this.slot);
263
266
  const checkpoint = await checkpointBuilder.completeCheckpoint();
264
267
 
268
+ // Final validation round for the checkpoint before we propose it, just for safety
269
+ try {
270
+ validateCheckpoint(checkpoint, {
271
+ rollupManaLimit: this.l1Constants.rollupManaLimit,
272
+ maxL2BlockGas: this.config.maxL2BlockGas,
273
+ maxDABlockGas: this.config.maxDABlockGas,
274
+ maxTxsPerBlock: this.config.maxTxsPerBlock,
275
+ maxTxsPerCheckpoint: this.config.maxTxsPerCheckpoint,
276
+ });
277
+ } catch (err) {
278
+ this.log.error(`Built an invalid checkpoint at slot ${this.slot} (skipping proposal)`, err, {
279
+ checkpoint: checkpoint.header.toInspect(),
280
+ });
281
+ return undefined;
282
+ }
283
+
265
284
  // Record checkpoint-level build metrics
266
285
  this.metrics.recordCheckpointBuild(
267
286
  checkpointBuildTimer.ms(),
@@ -384,9 +403,6 @@ export class CheckpointProposalJob implements Traceable {
384
403
  const txHashesAlreadyIncluded = new Set<string>();
385
404
  const initialBlockNumber = BlockNumber(this.syncedToBlockNumber + 1);
386
405
 
387
- // Remaining blob fields available for blocks (checkpoint end marker already subtracted)
388
- let remainingBlobFields = BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB - NUM_CHECKPOINT_END_MARKER_FIELDS;
389
-
390
406
  // Last block in the checkpoint will usually be flagged as pending broadcast, so we send it along with the checkpoint proposal
391
407
  let blockPendingBroadcast: { block: L2Block; txs: Tx[] } | undefined = undefined;
392
408
 
@@ -419,7 +435,6 @@ export class CheckpointProposalJob implements Traceable {
419
435
  blockNumber,
420
436
  indexWithinCheckpoint,
421
437
  txHashesAlreadyIncluded,
422
- remainingBlobFields,
423
438
  });
424
439
 
425
440
  // TODO(palla/mbps): Review these conditions. We may want to keep trying in some scenarios.
@@ -445,12 +460,9 @@ export class CheckpointProposalJob implements Traceable {
445
460
  break;
446
461
  }
447
462
 
448
- const { block, usedTxs, remainingBlobFields: newRemainingBlobFields } = buildResult;
463
+ const { block, usedTxs } = buildResult;
449
464
  blocksInCheckpoint.push(block);
450
465
 
451
- // Update remaining blob fields for the next block
452
- remainingBlobFields = newRemainingBlobFields;
453
-
454
466
  // Sync the proposed block to the archiver to make it available
455
467
  // Note that the checkpoint builder uses its own fork so it should not need to wait for this syncing
456
468
  // Eventually we should refactor the checkpoint builder to not need a separate long-lived fork
@@ -518,18 +530,10 @@ export class CheckpointProposalJob implements Traceable {
518
530
  indexWithinCheckpoint: IndexWithinCheckpoint;
519
531
  buildDeadline: Date | undefined;
520
532
  txHashesAlreadyIncluded: Set<string>;
521
- remainingBlobFields: number;
522
533
  },
523
- ): Promise<{ block: L2Block; usedTxs: Tx[]; remainingBlobFields: number } | { error: Error } | undefined> {
524
- const {
525
- blockTimestamp,
526
- forceCreate,
527
- blockNumber,
528
- indexWithinCheckpoint,
529
- buildDeadline,
530
- txHashesAlreadyIncluded,
531
- remainingBlobFields,
532
- } = opts;
534
+ ): Promise<{ block: L2Block; usedTxs: Tx[] } | { error: Error } | undefined> {
535
+ const { blockTimestamp, forceCreate, blockNumber, indexWithinCheckpoint, buildDeadline, txHashesAlreadyIncluded } =
536
+ opts;
533
537
 
534
538
  this.log.verbose(
535
539
  `Preparing block ${blockNumber} index ${indexWithinCheckpoint} at checkpoint ${this.checkpointNumber} for slot ${this.slot}`,
@@ -563,16 +567,16 @@ export class CheckpointProposalJob implements Traceable {
563
567
  );
564
568
  this.setStateFn(SequencerState.CREATING_BLOCK, this.slot);
565
569
 
566
- // Calculate blob fields limit for txs (remaining capacity - this block's end overhead)
567
- const blockEndOverhead = getNumBlockEndBlobFields(indexWithinCheckpoint === 0);
568
- const maxBlobFieldsForTxs = remainingBlobFields - blockEndOverhead;
569
-
570
+ // Per-block limits derived at startup by computeBlockLimits(), further capped
571
+ // by remaining checkpoint-level budgets inside CheckpointBuilder before each block is built.
570
572
  const blockBuilderOptions: PublicProcessorLimits = {
571
573
  maxTransactions: this.config.maxTxsPerBlock,
572
- maxBlockSize: this.config.maxBlockSizeInBytes,
573
- maxBlockGas: new Gas(this.config.maxDABlockGas, this.config.maxL2BlockGas),
574
- maxBlobFields: maxBlobFieldsForTxs,
574
+ maxBlockGas:
575
+ this.config.maxL2BlockGas !== undefined || this.config.maxDABlockGas !== undefined
576
+ ? new Gas(this.config.maxDABlockGas ?? Infinity, this.config.maxL2BlockGas ?? Infinity)
577
+ : undefined,
575
578
  deadline: buildDeadline,
579
+ isBuildingProposal: true,
576
580
  };
577
581
 
578
582
  // Actually build the block by executing txs
@@ -602,7 +606,7 @@ export class CheckpointProposalJob implements Traceable {
602
606
  }
603
607
 
604
608
  // Block creation succeeded, emit stats and metrics
605
- const { publicGas, block, publicProcessorDuration, usedTxs, usedTxBlobFields, blockBuildDuration } = buildResult;
609
+ const { block, publicProcessorDuration, usedTxs, blockBuildDuration } = buildResult;
606
610
 
607
611
  const blockStats = {
608
612
  eventName: 'l2-block-built',
@@ -613,7 +617,7 @@ export class CheckpointProposalJob implements Traceable {
613
617
 
614
618
  const blockHash = await block.hash();
615
619
  const txHashes = block.body.txEffects.map(tx => tx.txHash);
616
- const manaPerSec = publicGas.l2Gas / (blockBuildDuration / 1000);
620
+ const manaPerSec = block.header.totalManaUsed.toNumberUnsafe() / (blockBuildDuration / 1000);
617
621
 
618
622
  this.log.info(
619
623
  `Built block ${block.number} at checkpoint ${this.checkpointNumber} for slot ${this.slot} with ${numTxs} txs`,
@@ -621,9 +625,9 @@ export class CheckpointProposalJob implements Traceable {
621
625
  );
622
626
 
623
627
  this.eventEmitter.emit('block-proposed', { blockNumber: block.number, slot: this.slot });
624
- this.metrics.recordBuiltBlock(blockBuildDuration, publicGas.l2Gas);
628
+ this.metrics.recordBuiltBlock(blockBuildDuration, block.header.totalManaUsed.toNumberUnsafe());
625
629
 
626
- return { block, usedTxs, remainingBlobFields: maxBlobFieldsForTxs - usedTxBlobFields };
630
+ return { block, usedTxs };
627
631
  } catch (err: any) {
628
632
  this.eventEmitter.emit('block-build-failed', { reason: err.message, slot: this.slot });
629
633
  this.log.error(`Error building block`, err, { blockNumber, slot: this.slot });
@@ -759,7 +763,12 @@ export class CheckpointProposalJob implements Traceable {
759
763
  const sorted = orderAttestations(trimmed, committee);
760
764
 
761
765
  // Manipulate the attestations if we've been configured to do so
762
- if (this.config.injectFakeAttestation || this.config.shuffleAttestationOrdering) {
766
+ if (
767
+ this.config.injectFakeAttestation ||
768
+ this.config.injectHighSValueAttestation ||
769
+ this.config.injectUnrecoverableSignatureAttestation ||
770
+ this.config.shuffleAttestationOrdering
771
+ ) {
763
772
  return this.manipulateAttestations(proposal.slotNumber, epoch, seed, committee, sorted);
764
773
  }
765
774
 
@@ -788,7 +797,11 @@ export class CheckpointProposalJob implements Traceable {
788
797
  this.epochCache.computeProposerIndex(slotNumber, epoch, seed, BigInt(committee.length)),
789
798
  );
790
799
 
791
- if (this.config.injectFakeAttestation) {
800
+ if (
801
+ this.config.injectFakeAttestation ||
802
+ this.config.injectHighSValueAttestation ||
803
+ this.config.injectUnrecoverableSignatureAttestation
804
+ ) {
792
805
  // Find non-empty attestations that are not from the proposer
793
806
  const nonProposerIndices: number[] = [];
794
807
  for (let i = 0; i < attestations.length; i++) {
@@ -798,8 +811,20 @@ export class CheckpointProposalJob implements Traceable {
798
811
  }
799
812
  if (nonProposerIndices.length > 0) {
800
813
  const targetIndex = nonProposerIndices[randomInt(nonProposerIndices.length)];
801
- this.log.warn(`Injecting fake attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`);
802
- unfreeze(attestations[targetIndex]).signature = Signature.random();
814
+ if (this.config.injectHighSValueAttestation) {
815
+ this.log.warn(
816
+ `Injecting high-s value attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`,
817
+ );
818
+ unfreeze(attestations[targetIndex]).signature = flipSignature(attestations[targetIndex].signature);
819
+ } else if (this.config.injectUnrecoverableSignatureAttestation) {
820
+ this.log.warn(
821
+ `Injecting unrecoverable signature attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`,
822
+ );
823
+ unfreeze(attestations[targetIndex]).signature = generateUnrecoverableSignature();
824
+ } else {
825
+ this.log.warn(`Injecting fake attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`);
826
+ unfreeze(attestations[targetIndex]).signature = generateRecoverableSignature();
827
+ }
803
828
  }
804
829
  return new CommitteeAttestationsAndSigners(attestations);
805
830
  }
@@ -110,7 +110,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
110
110
  /** Updates sequencer config by the defined values and updates the timetable */
111
111
  public updateConfig(config: Partial<SequencerConfig>) {
112
112
  const filteredConfig = pickFromSchema(config, SequencerConfigSchema);
113
- this.log.info(`Updated sequencer config`, omit(filteredConfig, 'txPublicSetupAllowList'));
113
+ this.log.info(`Updated sequencer config`, omit(filteredConfig, 'txPublicSetupAllowListExtend'));
114
114
  this.config = merge(this.config, filteredConfig);
115
115
  this.timetable = new SequencerTimetable(
116
116
  {
@@ -1,4 +1,4 @@
1
- import { createLogger } from '@aztec/aztec.js/log';
1
+ import type { Logger } from '@aztec/foundation/log';
2
2
  import {
3
3
  CHECKPOINT_ASSEMBLE_TIME,
4
4
  CHECKPOINT_INITIALIZATION_TIME,
@@ -80,7 +80,7 @@ export class SequencerTimetable {
80
80
  enforce: boolean;
81
81
  },
82
82
  private readonly metrics?: SequencerMetrics,
83
- private readonly log = createLogger('sequencer:timetable'),
83
+ private readonly log?: Logger,
84
84
  ) {
85
85
  this.ethereumSlotDuration = opts.ethereumSlotDuration;
86
86
  this.aztecSlotDuration = opts.aztecSlotDuration;
@@ -132,7 +132,7 @@ export class SequencerTimetable {
132
132
  const initializeDeadline = this.aztecSlotDuration - minWorkToDo;
133
133
  this.initializeDeadline = initializeDeadline;
134
134
 
135
- this.log.verbose(
135
+ this.log?.info(
136
136
  `Sequencer timetable initialized with ${this.maxNumberOfBlocks} blocks per slot (${this.enforce ? 'enforced' : 'not enforced'})`,
137
137
  {
138
138
  ethereumSlotDuration: this.ethereumSlotDuration,
@@ -206,7 +206,7 @@ export class SequencerTimetable {
206
206
  }
207
207
 
208
208
  this.metrics?.recordStateTransitionBufferMs(Math.floor(bufferSeconds * 1000), newState);
209
- this.log.trace(`Enough time to transition to ${newState}`, { maxAllowedTime, secondsIntoSlot });
209
+ this.log?.trace(`Enough time to transition to ${newState}`, { maxAllowedTime, secondsIntoSlot });
210
210
  }
211
211
 
212
212
  /**
@@ -242,7 +242,7 @@ export class SequencerTimetable {
242
242
  const canStart = available >= this.minExecutionTime;
243
243
  const deadline = secondsIntoSlot + available;
244
244
 
245
- this.log.verbose(
245
+ this.log?.verbose(
246
246
  `${canStart ? 'Can' : 'Cannot'} start single-block checkpoint at ${secondsIntoSlot}s into slot`,
247
247
  { secondsIntoSlot, maxAllowed, available, deadline },
248
248
  );
@@ -262,7 +262,7 @@ export class SequencerTimetable {
262
262
  // Found an available sub-slot! Is this the last one?
263
263
  const isLastBlock = subSlot === this.maxNumberOfBlocks;
264
264
 
265
- this.log.verbose(
265
+ this.log?.verbose(
266
266
  `Can start ${isLastBlock ? 'last block' : 'block'} in sub-slot ${subSlot} with deadline ${deadline}s`,
267
267
  { secondsIntoSlot, deadline, timeUntilDeadline, subSlot, maxBlocks: this.maxNumberOfBlocks },
268
268
  );
@@ -272,7 +272,7 @@ export class SequencerTimetable {
272
272
  }
273
273
 
274
274
  // No sub-slots available with enough time
275
- this.log.verbose(`No time left to start any more blocks`, {
275
+ this.log?.verbose(`No time left to start any more blocks`, {
276
276
  secondsIntoSlot,
277
277
  maxBlocks: this.maxNumberOfBlocks,
278
278
  initializationOffset: this.initializationOffset,
@@ -3,4 +3,7 @@ import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
3
3
  export type SequencerRollupConstants = Pick<
4
4
  L1RollupConstants,
5
5
  'ethereumSlotDuration' | 'l1GenesisTime' | 'slotDuration'
6
- >;
6
+ > & {
7
+ /** Total L2 gas (mana) allowed per checkpoint. Fetched from L1 getManaLimit(). */
8
+ rollupManaLimit: number;
9
+ };