@aztec/sequencer-client 0.0.1-commit.7b86788 → 0.0.1-commit.7cbc774

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 (106) hide show
  1. package/README.md +282 -21
  2. package/dest/client/sequencer-client.d.ts +8 -3
  3. package/dest/client/sequencer-client.d.ts.map +1 -1
  4. package/dest/client/sequencer-client.js +53 -30
  5. package/dest/config.d.ts +28 -5
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +62 -27
  8. package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
  9. package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
  10. package/dest/global_variable_builder/fee_predictor.js +128 -0
  11. package/dest/global_variable_builder/fee_provider.d.ts +21 -0
  12. package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
  13. package/dest/global_variable_builder/fee_provider.js +58 -0
  14. package/dest/global_variable_builder/global_builder.d.ts +14 -14
  15. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  16. package/dest/global_variable_builder/global_builder.js +16 -50
  17. package/dest/global_variable_builder/index.d.ts +4 -2
  18. package/dest/global_variable_builder/index.d.ts.map +1 -1
  19. package/dest/global_variable_builder/index.js +2 -0
  20. package/dest/index.d.ts +2 -2
  21. package/dest/index.d.ts.map +1 -1
  22. package/dest/index.js +1 -1
  23. package/dest/publisher/config.d.ts +15 -3
  24. package/dest/publisher/config.d.ts.map +1 -1
  25. package/dest/publisher/config.js +19 -4
  26. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +3 -4
  27. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -1
  28. package/dest/publisher/sequencer-bundle-simulator.d.ts +96 -0
  29. package/dest/publisher/sequencer-bundle-simulator.d.ts.map +1 -0
  30. package/dest/publisher/sequencer-bundle-simulator.js +198 -0
  31. package/dest/publisher/sequencer-publisher-factory.d.ts +3 -5
  32. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  33. package/dest/publisher/sequencer-publisher-factory.js +16 -3
  34. package/dest/publisher/sequencer-publisher.d.ts +77 -65
  35. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  36. package/dest/publisher/sequencer-publisher.js +345 -512
  37. package/dest/sequencer/automine/automine_factory.d.ts +54 -0
  38. package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
  39. package/dest/sequencer/automine/automine_factory.js +84 -0
  40. package/dest/sequencer/automine/automine_sequencer.d.ts +151 -0
  41. package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
  42. package/dest/sequencer/automine/automine_sequencer.js +506 -0
  43. package/dest/sequencer/chain_state_overrides.d.ts +61 -0
  44. package/dest/sequencer/chain_state_overrides.d.ts.map +1 -0
  45. package/dest/sequencer/chain_state_overrides.js +98 -0
  46. package/dest/sequencer/checkpoint_proposal_job.d.ts +54 -11
  47. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  48. package/dest/sequencer/checkpoint_proposal_job.js +776 -227
  49. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
  50. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
  51. package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
  52. package/dest/sequencer/checkpoint_voter.d.ts +1 -2
  53. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
  54. package/dest/sequencer/checkpoint_voter.js +2 -5
  55. package/dest/sequencer/events.d.ts +47 -2
  56. package/dest/sequencer/events.d.ts.map +1 -1
  57. package/dest/sequencer/index.d.ts +3 -1
  58. package/dest/sequencer/index.d.ts.map +1 -1
  59. package/dest/sequencer/index.js +2 -0
  60. package/dest/sequencer/metrics.d.ts +13 -10
  61. package/dest/sequencer/metrics.d.ts.map +1 -1
  62. package/dest/sequencer/metrics.js +45 -20
  63. package/dest/sequencer/sequencer.d.ts +59 -16
  64. package/dest/sequencer/sequencer.d.ts.map +1 -1
  65. package/dest/sequencer/sequencer.js +333 -119
  66. package/dest/sequencer/timetable.d.ts +17 -3
  67. package/dest/sequencer/timetable.d.ts.map +1 -1
  68. package/dest/sequencer/timetable.js +51 -43
  69. package/dest/sequencer/types.d.ts +2 -2
  70. package/dest/sequencer/types.d.ts.map +1 -1
  71. package/dest/test/mock_checkpoint_builder.d.ts +7 -9
  72. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  73. package/dest/test/mock_checkpoint_builder.js +39 -30
  74. package/dest/test/utils.d.ts +1 -1
  75. package/dest/test/utils.d.ts.map +1 -1
  76. package/dest/test/utils.js +7 -6
  77. package/package.json +27 -28
  78. package/src/client/sequencer-client.ts +72 -33
  79. package/src/config.ts +76 -27
  80. package/src/global_variable_builder/README.md +44 -0
  81. package/src/global_variable_builder/fee_predictor.ts +172 -0
  82. package/src/global_variable_builder/fee_provider.ts +75 -0
  83. package/src/global_variable_builder/global_builder.ts +25 -62
  84. package/src/global_variable_builder/index.ts +3 -1
  85. package/src/index.ts +10 -1
  86. package/src/publisher/config.ts +40 -6
  87. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +3 -1
  88. package/src/publisher/sequencer-bundle-simulator.ts +254 -0
  89. package/src/publisher/sequencer-publisher-factory.ts +18 -6
  90. package/src/publisher/sequencer-publisher.ts +426 -567
  91. package/src/sequencer/README.md +152 -450
  92. package/src/sequencer/automine/README.md +46 -0
  93. package/src/sequencer/automine/automine_factory.ts +145 -0
  94. package/src/sequencer/automine/automine_sequencer.ts +592 -0
  95. package/src/sequencer/chain_state_overrides.ts +162 -0
  96. package/src/sequencer/checkpoint_proposal_job.ts +941 -256
  97. package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
  98. package/src/sequencer/checkpoint_voter.ts +1 -12
  99. package/src/sequencer/events.ts +50 -2
  100. package/src/sequencer/index.ts +2 -0
  101. package/src/sequencer/metrics.ts +57 -24
  102. package/src/sequencer/sequencer.ts +414 -132
  103. package/src/sequencer/timetable.ts +64 -52
  104. package/src/sequencer/types.ts +1 -1
  105. package/src/test/mock_checkpoint_builder.ts +51 -48
  106. package/src/test/utils.ts +28 -10
@@ -1,6 +1,5 @@
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';
2
+ import type { SimulationOverridesPlan } from '@aztec/ethereum/contracts';
4
3
  import {
5
4
  BlockNumber,
6
5
  CheckpointNumber,
@@ -9,11 +8,17 @@ import {
9
8
  SlotNumber,
10
9
  } from '@aztec/foundation/branded-types';
11
10
  import { randomInt } from '@aztec/foundation/crypto/random';
11
+ import {
12
+ flipSignature,
13
+ generateRecoverableSignature,
14
+ generateUnrecoverableSignature,
15
+ } from '@aztec/foundation/crypto/secp256k1-signer';
12
16
  import { Fr } from '@aztec/foundation/curves/bn254';
13
17
  import { EthAddress } from '@aztec/foundation/eth-address';
14
18
  import { Signature } from '@aztec/foundation/eth-signature';
15
19
  import { filter } from '@aztec/foundation/iterator';
16
20
  import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
21
+ import { retryUntil } from '@aztec/foundation/retry';
17
22
  import { sleep, sleepUntil } from '@aztec/foundation/sleep';
18
23
  import { type DateProvider, Timer } from '@aztec/foundation/timer';
19
24
  import { type TypedEventEmitter, isErrorClass, unfreeze } from '@aztec/foundation/types';
@@ -26,18 +31,32 @@ import {
26
31
  type L2BlockSink,
27
32
  type L2BlockSource,
28
33
  MaliciousCommitteeAttestationsAndSigners,
34
+ type ProposedCheckpointSink,
35
+ type ValidateCheckpointResult,
29
36
  } from '@aztec/stdlib/block';
30
- import type { Checkpoint } from '@aztec/stdlib/checkpoint';
31
- import { getSlotStartBuildTimestamp } from '@aztec/stdlib/epoch-helpers';
37
+ import {
38
+ type Checkpoint,
39
+ type ProposedCheckpointData,
40
+ getPreviousCheckpointOutHashes,
41
+ validateCheckpoint,
42
+ } from '@aztec/stdlib/checkpoint';
43
+ import { computeQuorum, getSlotStartBuildTimestamp, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
32
44
  import { Gas } from '@aztec/stdlib/gas';
33
45
  import {
34
- NoValidTxsError,
35
- type PublicProcessorLimits,
46
+ type BlockBuilderOptions,
47
+ InsufficientValidTxsError,
36
48
  type ResolvedSequencerConfig,
37
49
  type WorldStateSynchronizer,
38
50
  } from '@aztec/stdlib/interfaces/server';
39
51
  import { type L1ToL2MessageSource, computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
40
- import type { BlockProposalOptions, CheckpointProposal, CheckpointProposalOptions } from '@aztec/stdlib/p2p';
52
+ import type {
53
+ BlockProposal,
54
+ BlockProposalOptions,
55
+ CheckpointAttestation,
56
+ CheckpointProposal,
57
+ CheckpointProposalOptions,
58
+ CoordinationSignatureContext,
59
+ } from '@aztec/stdlib/p2p';
41
60
  import { orderAttestations, trimAttestations } from '@aztec/stdlib/p2p';
42
61
  import type { L2BlockBuiltStats } from '@aztec/stdlib/stats';
43
62
  import { type FailedTx, Tx } from '@aztec/stdlib/tx';
@@ -48,6 +67,8 @@ import { DutyAlreadySignedError, SlashingProtectionError } from '@aztec/validato
48
67
 
49
68
  import type { GlobalVariableBuilder } from '../global_variable_builder/global_builder.js';
50
69
  import type { InvalidateCheckpointRequest, SequencerPublisher } from '../publisher/sequencer-publisher.js';
70
+ import { buildCheckpointSimulationOverridesPlan } from './chain_state_overrides.js';
71
+ import type { CheckpointProposalJobMetricsRecorder } from './checkpoint_proposal_job_metrics.js';
51
72
  import { CheckpointVoter } from './checkpoint_voter.js';
52
73
  import { SequencerInterruptedError } from './errors.js';
53
74
  import type { SequencerEvents } from './events.js';
@@ -59,6 +80,20 @@ import { SequencerState } from './utils.js';
59
80
  /** How much time to sleep while waiting for min transactions to accumulate for a block */
60
81
  const TXS_POLLING_MS = 500;
61
82
 
83
+ /** Result from proposeCheckpoint when a checkpoint was successfully built and broadcast. */
84
+ type CheckpointProposalBroadcast = {
85
+ checkpoint: Checkpoint;
86
+ proposal: CheckpointProposal;
87
+ blockProposedAt: number;
88
+ };
89
+
90
+ /** Result after attestation collection and signing, ready for L1 submission. */
91
+ type CheckpointProposalResult = {
92
+ checkpoint: Checkpoint;
93
+ attestations: CommitteeAttestationsAndSigners;
94
+ attestationsSignature: Signature;
95
+ };
96
+
62
97
  /**
63
98
  * Handles the execution of a checkpoint proposal after the initial preparation phase.
64
99
  * This includes building blocks, collecting attestations, and publishing the checkpoint to L1,
@@ -67,12 +102,30 @@ const TXS_POLLING_MS = 500;
67
102
  */
68
103
  export class CheckpointProposalJob implements Traceable {
69
104
  protected readonly log: Logger;
105
+ private readonly checkpointEventLog: Logger;
106
+
107
+ /** Tracks the fire-and-forget L1 submission promise so it can be awaited during shutdown. */
108
+ private pendingL1Submission: Promise<void> | undefined;
109
+
110
+ /**
111
+ * Chain state overrides built once per slot in proposeCheckpoint after the checkpoint is
112
+ * complete. Carries the pending parent override (archive + slot + fee header) for pipelining,
113
+ * or the invalidation pending override when rolling back. Consumed by
114
+ * publisher.validateBlockHeader before broadcast.
115
+ */
116
+ private checkpointSimulationOverridesPlan?: SimulationOverridesPlan;
117
+
118
+ private getSignatureContext(): CoordinationSignatureContext {
119
+ return this.signatureContext;
120
+ }
70
121
 
71
122
  constructor(
72
- private readonly epoch: EpochNumber,
73
- private readonly slot: SlotNumber,
123
+ private readonly slotNow: SlotNumber,
124
+ private readonly targetSlot: SlotNumber,
125
+ private readonly targetEpoch: EpochNumber,
74
126
  private readonly checkpointNumber: CheckpointNumber,
75
127
  private readonly syncedToBlockNumber: BlockNumber,
128
+ private readonly checkpointedCheckpointNumber: CheckpointNumber,
76
129
  // TODO(palla/mbps): Can we remove the proposer in favor of attestorAddress? Need to check fisherman-node flows.
77
130
  private readonly proposer: EthAddress | undefined,
78
131
  private readonly publisher: SequencerPublisher,
@@ -85,25 +138,51 @@ export class CheckpointProposalJob implements Traceable {
85
138
  private readonly l1ToL2MessageSource: L1ToL2MessageSource,
86
139
  private readonly l2BlockSource: L2BlockSource,
87
140
  private readonly checkpointsBuilder: FullNodeCheckpointsBuilder,
88
- private readonly blockSink: L2BlockSink,
141
+ private readonly blockSink: L2BlockSink & ProposedCheckpointSink,
89
142
  private readonly l1Constants: SequencerRollupConstants,
143
+ private readonly signatureContext: CoordinationSignatureContext,
90
144
  protected config: ResolvedSequencerConfig,
91
145
  protected timetable: SequencerTimetable,
92
146
  private readonly slasherClient: SlasherClientInterface | undefined,
93
147
  private readonly epochCache: EpochCache,
94
148
  private readonly dateProvider: DateProvider,
95
149
  private readonly metrics: SequencerMetrics,
96
- private readonly eventEmitter: TypedEventEmitter<SequencerEvents>,
150
+ private readonly checkpointMetrics: CheckpointProposalJobMetricsRecorder,
151
+ protected readonly eventEmitter: TypedEventEmitter<SequencerEvents>,
97
152
  private readonly setStateFn: (state: SequencerState, slot?: SlotNumber) => void,
98
153
  public readonly tracer: Tracer,
99
154
  bindings?: LoggerBindings,
155
+ private readonly proposedCheckpointData?: ProposedCheckpointData,
100
156
  ) {
101
- this.log = createLogger('sequencer:checkpoint-proposal', { ...bindings, instanceId: `slot-${slot}` });
157
+ this.log = createLogger('sequencer:checkpoint-proposal', {
158
+ ...bindings,
159
+ instanceId: `slot-${this.slotNow}`,
160
+ });
161
+ this.checkpointEventLog = createLogger('sequencer:checkpoint-events', {
162
+ ...bindings,
163
+ instanceId: `slot-${this.slotNow}`,
164
+ });
165
+ }
166
+
167
+ /** Awaits the pending L1 submission if one is in progress. Call during shutdown. */
168
+ public async awaitPendingSubmission(): Promise<void> {
169
+ this.log.info('Awaiting pending L1 payload submission');
170
+ await this.pendingL1Submission;
171
+ }
172
+
173
+ private logCheckpointEvent(eventName: string, message: string, fields: Record<string, unknown>): void {
174
+ this.checkpointEventLog.debug(message, {
175
+ eventName: `sequencer-checkpoint-${eventName}`,
176
+ ...fields,
177
+ });
102
178
  }
103
179
 
104
180
  /**
105
181
  * Executes the checkpoint proposal job.
106
- * Returns the published checkpoint if successful, undefined otherwise.
182
+ * Builds blocks, assembles checkpoint, and broadcasts the proposal (blocking).
183
+ * Attestation collection, signing, and L1 submission are backgrounded so the
184
+ * work loop can return to IDLE immediately for consecutive slot proposals.
185
+ * Returns the built checkpoint if successful, undefined otherwise.
107
186
  */
108
187
  @trackSpan('CheckpointProposalJob.execute')
109
188
  public async execute(): Promise<Checkpoint | undefined> {
@@ -111,7 +190,7 @@ export class CheckpointProposalJob implements Traceable {
111
190
  // In fisherman mode, we simulate slashing but don't actually publish to L1
112
191
  // These are constant for the whole slot, so we only enqueue them once
113
192
  const votesPromises = new CheckpointVoter(
114
- this.slot,
193
+ this.targetSlot,
115
194
  this.publisher,
116
195
  this.attestorAddress,
117
196
  this.validatorClient,
@@ -122,33 +201,302 @@ export class CheckpointProposalJob implements Traceable {
122
201
  this.log,
123
202
  ).enqueueVotes();
124
203
 
125
- // Build and propose the checkpoint. This will enqueue the request on the publisher if a checkpoint is built.
126
- const checkpoint = await this.proposeCheckpoint();
127
-
128
- // Wait until the voting promises have resolved, so all requests are enqueued (not sent)
129
- await Promise.all(votesPromises);
130
-
131
- if (checkpoint) {
132
- this.metrics.recordCheckpointProposalSuccess();
204
+ // Build blocks, assemble checkpoint, and broadcast proposal (BLOCKING).
205
+ // Returns after broadcast — attestation collection is deferred.
206
+ const broadcast = await this.proposeCheckpoint();
207
+
208
+ if (!broadcast) {
209
+ await Promise.all(votesPromises);
210
+ // Still submit votes even without a checkpoint.
211
+ // Under proposer pipelining, vote-offenses signatures are EIP-712-bound to `targetSlot`
212
+ // (the pipelined slot in which the multicall is expected to mine). Submitting at the
213
+ // wall-clock time would let the multicall mine in a different L2 slot, causing
214
+ // signature verification to fail silently inside Multicall3. Delay submission to the
215
+ // start of `targetSlot` so the tx mines in the slot the vote was signed for.
216
+ if (!this.config.fishermanMode) {
217
+ this.pendingL1Submission = this.publisher.sendRequestsAt(this.targetSlot).then(() => {});
218
+ }
219
+ return undefined;
133
220
  }
134
221
 
222
+ const { checkpoint } = broadcast;
223
+ this.metrics.recordCheckpointProposalSuccess();
224
+
135
225
  // Do not post anything to L1 if we are fishermen, but do perform L1 fee analysis
136
226
  if (this.config.fishermanMode) {
137
227
  await this.handleCheckpointEndAsFisherman(checkpoint);
138
- return;
228
+ return checkpoint;
139
229
  }
140
230
 
141
- // Then send everything to L1
142
- const l1Response = await this.publisher.sendRequests();
143
- const proposedAction = l1Response?.successfulActions.find(a => a === 'propose');
144
- if (proposedAction) {
145
- this.eventEmitter.emit('checkpoint-published', { checkpoint: this.checkpointNumber, slot: this.slot });
146
- const coinbase = checkpoint?.header.coinbase;
147
- await this.metrics.incFilledSlot(this.publisher.getSenderAddress().toString(), coinbase);
148
- return checkpoint;
149
- } else if (checkpoint) {
150
- this.eventEmitter.emit('checkpoint-publish-failed', { ...l1Response, slot: this.slot });
151
- return undefined;
231
+ // Background the attestation signing → L1 pipeline so the work loop is unblocked
232
+ this.pendingL1Submission = this.waitForAttestationsAndEnqueueSubmissionAsync(broadcast, votesPromises);
233
+
234
+ // Return the built checkpoint immediately — the work loop is now unblocked
235
+ return checkpoint;
236
+ }
237
+
238
+ /**
239
+ * Background pipeline: collects attestations, signs them, enqueues the checkpoint, and submits to L1.
240
+ * Runs as a fire-and-forget task stored in `pendingL1Submission` so the work loop is unblocked.
241
+ */
242
+ private async waitForAttestationsAndEnqueueSubmissionAsync(
243
+ broadcast: CheckpointProposalBroadcast,
244
+ votesPromises: Promise<unknown>[],
245
+ ): Promise<void> {
246
+ const { checkpoint } = broadcast;
247
+ const isPipelining = this.epochCache.isProposerPipeliningEnabled();
248
+
249
+ try {
250
+ // Wait for all votes actions, enqueued at the beginning, to resolve
251
+ await Promise.all(votesPromises);
252
+
253
+ // Try to collect attestations from the committee
254
+ const signedAttestations = await this.getSignedCommitteeAttestations(broadcast);
255
+
256
+ // If pipelining, wait for the previous checkpoint to land on L1 before submitting,
257
+ // so we can check it matches the proposed checkpoint we used as parent, and has valid attestations.
258
+ if (signedAttestations && (!isPipelining || (await this.waitForValidParentCheckpointOnL1()))) {
259
+ await this.enqueueCheckpointForSubmission({ checkpoint, ...signedAttestations });
260
+ }
261
+
262
+ // If we failed to collect attestations, at least check if we need to issue an invalidation
263
+ // Note that if we are not pipelining, we enqueued the invalidation at the beginning
264
+ if (!signedAttestations && isPipelining && (await this.waitForSyncedL2SlotNumber(this.slotNow))) {
265
+ const validationStatus = await this.l2BlockSource.getPendingChainValidationStatus();
266
+ if (!validationStatus.valid) {
267
+ this.log.warn(
268
+ `Checkpoint ${validationStatus.checkpoint.checkpointNumber} has invalid attestations, enqueuing invalidation in spite of attestation collection failure`,
269
+ { checkpoint: validationStatus.checkpoint, reason: validationStatus.reason },
270
+ );
271
+ await this.enqueueInvalidation(validationStatus);
272
+ }
273
+ }
274
+
275
+ // Send whatever was enqueued: votes + (propose | invalidation | nothing).
276
+ const l1Response = await this.publisher.sendRequestsAt(this.targetSlot);
277
+ const proposedAction = l1Response?.successfulActions.find(a => a === 'propose');
278
+ if (proposedAction) {
279
+ this.logCheckpointEvent('published', `Checkpoint published for slot ${this.targetSlot}`, {
280
+ slot: this.targetSlot,
281
+ checkpointNumber: this.checkpointNumber,
282
+ successfulActions: l1Response?.successfulActions,
283
+ sentActions: l1Response?.sentActions,
284
+ });
285
+ this.eventEmitter.emit('checkpoint-published', { checkpoint: this.checkpointNumber, slot: this.targetSlot });
286
+ const coinbase = checkpoint.header.coinbase;
287
+ await this.metrics.incFilledSlot(this.publisher.getSenderAddress().toString(), coinbase);
288
+ } else {
289
+ this.logCheckpointEvent('publish-failed', `Checkpoint publish failed for slot ${this.targetSlot}`, {
290
+ slot: this.targetSlot,
291
+ checkpointNumber: this.checkpointNumber,
292
+ successfulActions: l1Response?.successfulActions,
293
+ failedActions: l1Response?.failedActions,
294
+ sentActions: l1Response?.sentActions,
295
+ expiredActions: l1Response?.expiredActions,
296
+ reason: 'propose_action_not_successful',
297
+ });
298
+ this.log.warn(`Checkpoint publish failed for slot ${this.targetSlot}`, {
299
+ slot: this.targetSlot,
300
+ checkpointNumber: this.checkpointNumber,
301
+ successfulActions: l1Response?.successfulActions,
302
+ failedActions: l1Response?.failedActions,
303
+ sentActions: l1Response?.sentActions,
304
+ expiredActions: l1Response?.expiredActions,
305
+ reason: 'propose_action_not_successful',
306
+ });
307
+ this.eventEmitter.emit('checkpoint-publish-failed', { ...l1Response, slot: this.targetSlot });
308
+ if (isPipelining) {
309
+ this.metrics.recordPipelineDiscard();
310
+ }
311
+ }
312
+ } catch (err) {
313
+ if (err instanceof SequencerInterruptedError) {
314
+ return;
315
+ }
316
+ this.logCheckpointEvent('publish-failed', `Checkpoint publish failed for slot ${this.targetSlot}`, {
317
+ slot: this.targetSlot,
318
+ checkpointNumber: this.checkpointNumber,
319
+ reason: err instanceof Error ? err.message : String(err),
320
+ });
321
+ this.log.error(`Background attestation/L1 pipeline failed for slot ${this.targetSlot}`, err, {
322
+ slot: this.targetSlot,
323
+ checkpointNumber: this.checkpointNumber,
324
+ reason: err instanceof Error ? err.message : String(err),
325
+ });
326
+ this.eventEmitter.emit('checkpoint-publish-failed', { slot: this.targetSlot });
327
+ if (isPipelining) {
328
+ this.metrics.recordPipelineDiscard();
329
+ }
330
+ }
331
+ }
332
+
333
+ /** Enqueues the checkpoint for L1 submission. Called after pipeline sleep in execute(). */
334
+ private async enqueueCheckpointForSubmission(result: CheckpointProposalResult): Promise<void> {
335
+ const { checkpoint, attestations, attestationsSignature } = result;
336
+
337
+ this.setStateFn(SequencerState.PUBLISHING_CHECKPOINT, this.targetSlot);
338
+ const aztecSlotDuration = this.l1Constants.slotDuration;
339
+ const submissionSlotStart = Number(getTimestampForSlot(this.targetSlot, this.l1Constants));
340
+ const txTimeoutAt = new Date((submissionSlotStart + aztecSlotDuration) * 1000);
341
+
342
+ // If we have been configured to potentially skip publishing checkpoint then roll the dice here
343
+ if (
344
+ this.config.skipPublishingCheckpointsPercent !== undefined &&
345
+ this.config.skipPublishingCheckpointsPercent > 0
346
+ ) {
347
+ const roll = Math.max(0, randomInt(100));
348
+ if (roll < this.config.skipPublishingCheckpointsPercent) {
349
+ this.log.warn(
350
+ `Skipping publishing proposal for checkpoint ${checkpoint.number}. Configured percentage: ${this.config.skipPublishingCheckpointsPercent}, generated value: ${roll}`,
351
+ );
352
+ return;
353
+ }
354
+ }
355
+
356
+ await this.publisher.enqueueProposeCheckpoint(checkpoint, attestations, attestationsSignature, {
357
+ txTimeoutAt,
358
+ });
359
+ }
360
+
361
+ /**
362
+ * Wait until the archiver syncs past the given L2 slot number.
363
+ * The deadline is the end of `this.targetSlot`, beyond which any pipelined work would miss its
364
+ * L1 submission window and is no longer useful.
365
+ */
366
+ private async waitForSyncedL2SlotNumber(waitForSlot: SlotNumber): Promise<boolean> {
367
+ const targetSlotStart = Number(getTimestampForSlot(this.targetSlot, this.l1Constants));
368
+ const targetSlotEndMs = (targetSlotStart + this.l1Constants.slotDuration) * 1000;
369
+ const syncDelayTolerance = this.l1Constants.ethereumSlotDuration * 2 * 1000;
370
+ const timeoutSeconds = Math.max(0.1, (targetSlotEndMs + syncDelayTolerance - this.dateProvider.now()) / 1000);
371
+
372
+ try {
373
+ return await retryUntil(
374
+ async () => {
375
+ const syncedSlot = await this.l2BlockSource.getSyncedL2SlotNumber();
376
+ return syncedSlot !== undefined && syncedSlot >= waitForSlot;
377
+ },
378
+ `archiver sync past slot ${waitForSlot}`,
379
+ timeoutSeconds,
380
+ 0.2,
381
+ );
382
+ } catch {
383
+ this.log.warn(
384
+ `Archiver did not sync L1 past slot ${waitForSlot} before slot ${this.targetSlot} expired, discarding pipelined work`,
385
+ { checkpointNumber: this.checkpointNumber },
386
+ );
387
+ this.emitPipelinedCheckpointDiscarded('archiver-sync-timeout');
388
+ return false;
389
+ }
390
+ }
391
+
392
+ /**
393
+ * Waits for the parent checkpoint to land on L1 before submitting a pipelined checkpoint.
394
+ * Polls until the archiver has synced L1 past the parent's slot, then verifies:
395
+ * - If we built on a proposed parent: it must have landed on L1 with matching hash and valid attestations.
396
+ * - If we built without a proposed parent: no new checkpoint must have appeared for that slot.
397
+ * If the parent has invalid attestations, enqueues an invalidation. Returns whether to proceed with the proposal.
398
+ */
399
+ protected async waitForValidParentCheckpointOnL1(): Promise<boolean> {
400
+ if (this.config.skipWaitForValidParentCheckpointOnL1) {
401
+ this.log.warn(`Skipping waitForValidParentCheckpointOnL1 due to test configuration`, {
402
+ checkpointNumber: this.checkpointNumber,
403
+ });
404
+ return true;
405
+ }
406
+
407
+ const parentCheckpointNumber = CheckpointNumber(this.checkpointNumber - 1);
408
+
409
+ // Wait until archiver has synced L1 past the parent's slot (slotNow)
410
+ if (!(await this.waitForSyncedL2SlotNumber(this.slotNow))) {
411
+ return false;
412
+ }
413
+
414
+ const tips = await this.l2BlockSource.getL2Tips();
415
+ const checkpointedNumber = tips.checkpointed.checkpoint.number;
416
+
417
+ // We built on top of a proposed checkpoint. Verify it landed on L1 as expected.
418
+ if (this.proposedCheckpointData) {
419
+ // After syncing from L1 we see the chain tip has invalid attestations. This means the parent checkpoint was posted
420
+ // with invalid attestations, or it built on top of something with invalid attestations and didnt invalidate them.
421
+ // Either way, we thought our parent would be valid, so we have to throw away our work. But at least we'll try and
422
+ // invalidate on L1 so we clean up the chain for the next proposer. And we'll slash them, but that's handled elsewhere.
423
+ const validationStatus = await this.l2BlockSource.getPendingChainValidationStatus();
424
+ if (!validationStatus.valid) {
425
+ this.log.warn(
426
+ `Parent checkpoint ${parentCheckpointNumber} has invalid attestations, discarding pipelined work`,
427
+ { checkpointNumber: this.checkpointNumber, reason: validationStatus.reason },
428
+ );
429
+ this.emitPipelinedCheckpointDiscarded('parent-invalid-attestations');
430
+ await this.enqueueInvalidation(validationStatus);
431
+ return false;
432
+ }
433
+
434
+ // The pending chain is valid. But did the parent checkpoint land on L1 at all?
435
+ if (checkpointedNumber < parentCheckpointNumber) {
436
+ this.log.warn(`Parent checkpoint ${parentCheckpointNumber} did not land on L1, discarding pipelined work`, {
437
+ checkpointNumber: this.checkpointNumber,
438
+ checkpointedNumber,
439
+ });
440
+ this.emitPipelinedCheckpointDiscarded('parent-not-on-l1');
441
+ return false;
442
+ }
443
+
444
+ // It landed. But is it the one we were expecting?
445
+ const expectedHash = this.proposedCheckpointData.header.hash().toString();
446
+ if (tips.checkpointed.checkpoint.hash !== expectedHash) {
447
+ this.log.warn(`Parent checkpoint ${parentCheckpointNumber} hash mismatch on L1, discarding pipelined work`, {
448
+ checkpointNumber: this.checkpointNumber,
449
+ expectedHash,
450
+ actualHash: tips.checkpointed.checkpoint.hash,
451
+ });
452
+ this.emitPipelinedCheckpointDiscarded('parent-hash-mismatch');
453
+ return false;
454
+ }
455
+
456
+ return true;
457
+ } else {
458
+ // We didn't see a proposed checkpoint at build time, so we built on checkpointed parent from two slots ago.
459
+ // But if a new checkpoint for the previous slot appeared on L1 in the meantime, our checkpoint assumed the wrong parent,
460
+ // so we have to discard our work. This can happen if we're somehow cut off from p2p and fail to see the checkpoint
461
+ // proposal for the previous slot.
462
+ if (checkpointedNumber > parentCheckpointNumber) {
463
+ this.log.warn(
464
+ `Unexpected checkpoint ${checkpointedNumber} landed on L1 after we built on top of parent ${parentCheckpointNumber}, discarding pipelined work`,
465
+ { checkpointNumber: this.checkpointNumber, checkpointedNumber },
466
+ );
467
+ this.emitPipelinedCheckpointDiscarded('unexpected-parent-appeared');
468
+ return false;
469
+ }
470
+
471
+ return true;
472
+ }
473
+ }
474
+
475
+ /** Emits the pipelined-checkpoint-discarded event and records the metric. */
476
+ private emitPipelinedCheckpointDiscarded(reason: string): void {
477
+ this.metrics.recordPipelineParentCheckpointMismatch(reason);
478
+ this.eventEmitter.emit('pipelined-checkpoint-discarded', {
479
+ slot: this.targetSlot,
480
+ checkpointNumber: this.checkpointNumber,
481
+ reason,
482
+ });
483
+ }
484
+
485
+ /** Simulates and enqueues an invalidation request for the invalid parent checkpoint. */
486
+ private async enqueueInvalidation(validationStatus: ValidateCheckpointResult): Promise<void> {
487
+ if (this.config.skipInvalidateBlockAsProposer) {
488
+ this.log.warn(`Skipping checkpoint invalidation as proposer due to test configuration`);
489
+ return;
490
+ }
491
+ const invalidateRequest = await this.publisher.simulateInvalidateCheckpoint(validationStatus);
492
+ if (invalidateRequest) {
493
+ const submissionSlotStart = Number(getTimestampForSlot(this.targetSlot, this.l1Constants));
494
+ const txTimeoutAt = new Date((submissionSlotStart + this.l1Constants.slotDuration) * 1000);
495
+ this.publisher.enqueueInvalidateCheckpoint(invalidateRequest, { txTimeoutAt });
496
+ } else {
497
+ this.log.info(`Invalidation simulation returned undefined, checkpoint may have been removed already`, {
498
+ checkpointNumber: this.checkpointNumber,
499
+ });
152
500
  }
153
501
  }
154
502
 
@@ -156,42 +504,91 @@ export class CheckpointProposalJob implements Traceable {
156
504
  return {
157
505
  // nullish operator needed for tests
158
506
  [Attributes.COINBASE]: this.validatorClient.getCoinbaseForAttestor(this.attestorAddress)?.toString(),
159
- [Attributes.SLOT_NUMBER]: this.slot,
507
+ [Attributes.SLOT_NUMBER]: this.targetSlot,
160
508
  };
161
509
  })
162
- private async proposeCheckpoint(): Promise<Checkpoint | undefined> {
510
+ private async proposeCheckpoint(): Promise<CheckpointProposalBroadcast | undefined> {
163
511
  try {
512
+ const now = this.dateProvider.now();
513
+ if (this.epochCache.isProposerPipeliningEnabled() && this.proposedCheckpointData) {
514
+ // Measure against the wall-clock slot whose build window we are currently using.
515
+ // In pipelining mode `targetSlot` is intentionally one slot ahead, which makes the
516
+ // target-slot boundary a full slot away from the actual build start time.
517
+ const slotBoundaryMs = Number(getTimestampForSlot(this.slotNow, this.l1Constants)) * 1000;
518
+ this.checkpointMetrics.recordPipelinedCheckpointBuildStartOffsetFromSlotBoundary(now - slotBoundaryMs);
519
+ }
520
+ this.checkpointMetrics.startCheckpointTiming(now);
521
+
164
522
  // Get operator configured coinbase and fee recipient for this attestor
165
523
  const coinbase = this.validatorClient.getCoinbaseForAttestor(this.attestorAddress);
166
524
  const feeRecipient = this.validatorClient.getFeeRecipientForAttestor(this.attestorAddress);
167
525
 
168
526
  // Start the checkpoint
169
- this.setStateFn(SequencerState.INITIALIZING_CHECKPOINT, this.slot);
170
- this.metrics.incOpenSlot(this.slot, this.proposer?.toString() ?? 'unknown');
527
+ this.setStateFn(SequencerState.INITIALIZING_CHECKPOINT, this.targetSlot);
528
+ this.logCheckpointEvent('slot-started', `Starting checkpoint proposal for slot ${this.targetSlot}`, {
529
+ buildSlot: this.slotNow,
530
+ submissionSlot: this.targetSlot,
531
+ slot: this.targetSlot,
532
+ checkpointNumber: this.checkpointNumber,
533
+ pipelining: this.epochCache.isProposerPipeliningEnabled(),
534
+ proposer: this.proposer?.toString(),
535
+ attestorAddress: this.attestorAddress.toString(),
536
+ publisherAddress: this.publisher.getSenderAddress().toString(),
537
+ coinbase: coinbase.toString(),
538
+ });
539
+ this.metrics.incOpenSlot(this.targetSlot, this.proposer?.toString() ?? 'unknown');
171
540
 
172
541
  // Enqueues checkpoint invalidation (constant for the whole slot)
173
542
  if (this.invalidateCheckpoint && !this.config.skipInvalidateBlockAsProposer) {
174
543
  this.publisher.enqueueInvalidateCheckpoint(this.invalidateCheckpoint);
175
544
  }
176
545
 
177
- // Create checkpoint builder for the slot
546
+ // Build the simulation plan for this slot. When pipelining, this overrides L1's view of
547
+ // pending/archive/fee-header to "as if the proposed parent had landed", so both the
548
+ // mana-min-fee simulation (in the globals builder) and the pre-broadcast
549
+ // validateBlockHeader see the chain tip the eventual L1 send will see.
550
+ const isPipelining = this.epochCache.isProposerPipeliningEnabled();
551
+ this.checkpointSimulationOverridesPlan = await buildCheckpointSimulationOverridesPlan({
552
+ checkpointNumber: this.checkpointNumber,
553
+ proposedCheckpointData: isPipelining ? this.proposedCheckpointData : undefined,
554
+ invalidateToPendingCheckpointNumber: this.invalidateCheckpoint?.forcePendingCheckpointNumber,
555
+ checkpointedCheckpointNumber: this.checkpointedCheckpointNumber,
556
+ rollup: this.publisher.rollupContract,
557
+ signatureContext: this.signatureContext,
558
+ log: this.log,
559
+ });
560
+
178
561
  const checkpointGlobalVariables = await this.globalsBuilder.buildCheckpointGlobalVariables(
179
562
  coinbase,
180
563
  feeRecipient,
181
- this.slot,
564
+ this.targetSlot,
565
+ this.checkpointSimulationOverridesPlan,
182
566
  );
183
567
 
184
568
  // Collect L1 to L2 messages for the checkpoint and compute their hash
185
569
  const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(this.checkpointNumber);
186
570
  const inHash = computeInHashFromL1ToL2Messages(l1ToL2Messages);
187
571
 
188
- // Collect the out hashes of all the checkpoints before this one in the same epoch
189
- const previousCheckpointOutHashes = (await this.l2BlockSource.getCheckpointsDataForEpoch(this.epoch))
190
- .filter(c => c.checkpointNumber < this.checkpointNumber)
191
- .map(c => c.checkpointOutHash);
572
+ // Collect the out hashes of all the checkpoints before this one in the same epoch.
573
+ // Under pipelining the parent checkpoint may not be on L1 yet at build time, so the helper
574
+ // splices in the parent's checkpointOutHash from the locally-known proposed checkpoint so
575
+ // the resulting `epochOutHash` matches what validators (and L1) compute once the parent
576
+ // lands on L1.
577
+ const previousCheckpointOutHashes = await getPreviousCheckpointOutHashes({
578
+ blockSource: this.l2BlockSource,
579
+ epoch: this.targetEpoch,
580
+ checkpointNumber: this.checkpointNumber,
581
+ l1Constants: this.epochCache.getL1Constants(),
582
+ pipeliningEnabled: this.epochCache.isProposerPipeliningEnabled(),
583
+ proposedCheckpointData: this.proposedCheckpointData,
584
+ log: this.log,
585
+ });
192
586
 
193
- // Get the fee asset price modifier from the oracle
194
- const feeAssetPriceModifier = await this.publisher.getFeeAssetPriceModifier();
587
+ // Anchor the modifier to the predicted parent fee header: L1 will apply it against
588
+ // that, not against the latest published checkpoint (which lags by one under pipelining).
589
+ const predictedParentEthPerFeeAssetE12 =
590
+ this.checkpointSimulationOverridesPlan?.pendingCheckpointState?.feeHeader?.ethPerFeeAsset;
591
+ const feeAssetPriceModifier = await this.publisher.getFeeAssetPriceModifier(predictedParentEthPerFeeAssetE12);
195
592
 
196
593
  // Create a long-lived forked world state for the checkpoint builder
197
594
  await using fork = await this.worldState.fork(this.syncedToBlockNumber, { closeDelayMs: 12_000 });
@@ -215,11 +612,12 @@ export class CheckpointProposalJob implements Traceable {
215
612
 
216
613
  const checkpointProposalOptions: CheckpointProposalOptions = {
217
614
  publishFullTxs: !!this.config.publishTxsWithProposals,
218
- broadcastInvalidCheckpointProposal: this.config.broadcastInvalidBlockProposal,
615
+ broadcastInvalidCheckpointProposal:
616
+ this.config.broadcastInvalidCheckpointProposalOnly || this.config.broadcastInvalidBlockProposal,
219
617
  };
220
618
 
221
619
  let blocksInCheckpoint: L2Block[] = [];
222
- let blockPendingBroadcast: { block: L2Block; txs: Tx[] } | undefined = undefined;
620
+ let blockPendingBroadcast: BlockProposal | undefined = undefined;
223
621
  const checkpointBuildTimer = new Timer();
224
622
 
225
623
  try {
@@ -243,126 +641,170 @@ export class CheckpointProposalJob implements Traceable {
243
641
  }
244
642
 
245
643
  if (blocksInCheckpoint.length === 0) {
246
- this.log.warn(`No blocks were built for slot ${this.slot}`, { slot: this.slot });
247
- this.eventEmitter.emit('checkpoint-empty', { slot: this.slot });
644
+ this.logCheckpointEvent('build-failed', `Checkpoint build failed for slot ${this.targetSlot}`, {
645
+ slot: this.targetSlot,
646
+ checkpointNumber: this.checkpointNumber,
647
+ reason: 'no_blocks_built',
648
+ });
649
+ this.log.warn(`No blocks were built for slot ${this.targetSlot}`, {
650
+ slot: this.targetSlot,
651
+ checkpointNumber: this.checkpointNumber,
652
+ reason: 'no_blocks_built',
653
+ });
654
+ this.eventEmitter.emit('checkpoint-empty', { slot: this.targetSlot });
248
655
  return undefined;
249
656
  }
250
657
 
251
658
  const minBlocksForCheckpoint = this.config.minBlocksForCheckpoint;
252
659
  if (minBlocksForCheckpoint !== undefined && blocksInCheckpoint.length < minBlocksForCheckpoint) {
660
+ this.logCheckpointEvent('build-failed', `Checkpoint build failed for slot ${this.targetSlot}`, {
661
+ slot: this.targetSlot,
662
+ checkpointNumber: this.checkpointNumber,
663
+ blocksBuilt: blocksInCheckpoint.length,
664
+ minBlocksForCheckpoint,
665
+ reason: 'min_blocks_not_met',
666
+ });
253
667
  this.log.warn(
254
668
  `Checkpoint has fewer blocks than minimum (${blocksInCheckpoint.length} < ${minBlocksForCheckpoint}), skipping proposal`,
255
- { slot: this.slot, blocksBuilt: blocksInCheckpoint.length, minBlocksForCheckpoint },
669
+ {
670
+ slot: this.targetSlot,
671
+ checkpointNumber: this.checkpointNumber,
672
+ blocksBuilt: blocksInCheckpoint.length,
673
+ minBlocksForCheckpoint,
674
+ reason: 'min_blocks_not_met',
675
+ },
256
676
  );
257
677
  return undefined;
258
678
  }
259
679
 
260
680
  // Assemble and broadcast the checkpoint proposal, including the last block that was not
261
681
  // broadcasted yet, and wait to collect the committee attestations.
262
- this.setStateFn(SequencerState.ASSEMBLING_CHECKPOINT, this.slot);
682
+ this.setStateFn(SequencerState.ASSEMBLING_CHECKPOINT, this.targetSlot);
263
683
  const checkpoint = await checkpointBuilder.completeCheckpoint();
264
684
 
685
+ // Final validation: per-block limits are only checked if the operator set them explicitly.
686
+ // Otherwise, checkpoint-level budgets were already enforced by the redistribution logic.
687
+ try {
688
+ validateCheckpoint(checkpoint, {
689
+ rollupManaLimit: this.l1Constants.rollupManaLimit,
690
+ maxL2BlockGas: this.config.maxL2BlockGas,
691
+ maxDABlockGas: this.config.maxDABlockGas,
692
+ maxTxsPerBlock: this.config.maxTxsPerBlock,
693
+ maxTxsPerCheckpoint: this.config.maxTxsPerCheckpoint,
694
+ });
695
+ } catch (err) {
696
+ this.logCheckpointEvent('build-failed', `Checkpoint build failed for slot ${this.targetSlot}`, {
697
+ slot: this.targetSlot,
698
+ checkpointNumber: this.checkpointNumber,
699
+ blocksBuilt: blocksInCheckpoint.length,
700
+ reason: 'invalid_checkpoint',
701
+ checkpoint: checkpoint.header.toInspect(),
702
+ });
703
+ this.log.error(`Built an invalid checkpoint at slot ${this.slotNow} (skipping proposal)`, err, {
704
+ slot: this.targetSlot,
705
+ checkpointNumber: this.checkpointNumber,
706
+ blocksBuilt: blocksInCheckpoint.length,
707
+ reason: 'invalid_checkpoint',
708
+ checkpoint: checkpoint.header.toInspect(),
709
+ });
710
+ return undefined;
711
+ }
712
+
265
713
  // Record checkpoint-level build metrics
266
- this.metrics.recordCheckpointBuild(
714
+ this.checkpointMetrics.recordCheckpointBuild(
267
715
  checkpointBuildTimer.ms(),
268
716
  blocksInCheckpoint.length,
269
717
  checkpoint.getStats().txCount,
270
718
  Number(checkpoint.header.totalManaUsed.toBigInt()),
271
719
  );
720
+ this.logCheckpointEvent('built', `Checkpoint built for slot ${this.targetSlot}`, {
721
+ slot: this.targetSlot,
722
+ buildSlot: this.slotNow,
723
+ checkpointNumber: this.checkpointNumber,
724
+ proposer: this.proposer?.toString(),
725
+ attestorAddress: this.attestorAddress.toString(),
726
+ publisherAddress: this.publisher.getSenderAddress().toString(),
727
+ blocksBuilt: blocksInCheckpoint.length,
728
+ txCount: checkpoint.getStats().txCount,
729
+ totalMana: Number(checkpoint.header.totalManaUsed.toBigInt()),
730
+ });
272
731
 
273
- // Do not collect attestations nor publish to L1 in fisherman mode
732
+ // In fisherman mode, return the checkpoint without broadcasting or collecting attestations
274
733
  if (this.config.fishermanMode) {
275
734
  this.log.info(
276
- `Built checkpoint for slot ${this.slot} with ${blocksInCheckpoint.length} blocks. ` +
735
+ `Built checkpoint for slot ${this.targetSlot} with ${blocksInCheckpoint.length} blocks. ` +
277
736
  `Skipping proposal in fisherman mode.`,
278
737
  {
279
- slot: this.slot,
738
+ slot: this.targetSlot,
280
739
  checkpoint: checkpoint.header.toInspect(),
281
740
  blocksBuilt: blocksInCheckpoint.length,
282
741
  },
283
742
  );
284
743
  this.metrics.recordCheckpointSuccess();
285
- return checkpoint;
744
+ // Return a broadcast result with a dummy proposal — fisherman mode skips attestation collection
745
+ return { checkpoint, proposal: undefined!, blockProposedAt: this.dateProvider.now() };
286
746
  }
287
747
 
288
- // Include the block pending broadcast in the checkpoint proposal if any
289
- const lastBlock = blockPendingBroadcast && {
290
- blockHeader: blockPendingBroadcast.block.header,
291
- indexWithinCheckpoint: blockPendingBroadcast.block.indexWithinCheckpoint,
292
- txs: blockPendingBroadcast.txs,
293
- };
748
+ // Validate the header against L1 state before broadcasting.
749
+ // If this fails the slot is aborted before any gossip work; state drift between here
750
+ // and the eventual L1 send is caught by the bundle simulate at send time.
751
+ try {
752
+ await this.publisher.validateBlockHeader(checkpoint.header, this.checkpointSimulationOverridesPlan);
753
+ } catch (err) {
754
+ this.log.error(`Pre-broadcast header validation failed for slot ${this.targetSlot}; aborting`, err, {
755
+ slot: this.targetSlot,
756
+ checkpointNumber: this.checkpointNumber,
757
+ });
758
+ this.metrics.recordCheckpointProposalFailed('header_validation_failed');
759
+ this.eventEmitter.emit('header-validation-failed', {
760
+ slot: this.targetSlot,
761
+ checkpointNumber: this.checkpointNumber,
762
+ reason: err instanceof Error ? err.message : String(err),
763
+ });
764
+ return undefined;
765
+ }
294
766
 
295
767
  // Create the checkpoint proposal and broadcast it
296
768
  const proposal = await this.validatorClient.createCheckpointProposal(
297
769
  checkpoint.header,
298
770
  checkpoint.archive.root,
771
+ this.checkpointNumber,
299
772
  feeAssetPriceModifier,
300
- lastBlock,
773
+ blockPendingBroadcast,
301
774
  this.proposer,
302
775
  checkpointProposalOptions,
303
776
  );
304
777
 
305
- const blockProposedAt = this.dateProvider.now();
306
- await this.p2pClient.broadcastCheckpointProposal(proposal);
307
-
308
- this.setStateFn(SequencerState.COLLECTING_ATTESTATIONS, this.slot);
309
- const attestations = await this.waitForAttestations(proposal);
310
- const blockAttestedAt = this.dateProvider.now();
311
-
312
- this.metrics.recordCheckpointAttestationDelay(blockAttestedAt - blockProposedAt);
313
-
314
- // Proposer must sign over the attestations before pushing them to L1
315
- const signer = this.proposer ?? this.publisher.getSenderAddress();
316
- let attestationsSignature: Signature;
317
- try {
318
- attestationsSignature = await this.validatorClient.signAttestationsAndSigners(
319
- attestations,
320
- signer,
321
- this.slot,
322
- this.checkpointNumber,
323
- );
324
- } catch (err) {
325
- // We shouldn't really get here since we yield to another HA node
326
- // as soon as we see these errors when creating block or checkpoint proposals.
327
- if (this.handleHASigningError(err, 'Attestations signature')) {
328
- return undefined;
329
- }
330
- throw err;
331
- }
332
-
333
- // Enqueue publishing the checkpoint to L1
334
- this.setStateFn(SequencerState.PUBLISHING_CHECKPOINT, this.slot);
335
- const aztecSlotDuration = this.l1Constants.slotDuration;
336
- const slotStartBuildTimestamp = this.getSlotStartBuildTimestamp();
337
- const txTimeoutAt = new Date((slotStartBuildTimestamp + aztecSlotDuration) * 1000);
778
+ // Advance our own optimistic proposed-checkpoint tip locally before gossiping. Gossipsub
779
+ // doesn't echo our own messages back, so this is how the proposer makes its own proposed
780
+ // checkpoint visible for pipelining the next slot. Built from local checkpoint data — never
781
+ // from the broadcast proposal archive, which may be deliberately corrupted under test flags.
782
+ // Fail closed: if this throws, the outer catch aborts the slot before gossiping.
783
+ await this.syncProposedCheckpointToArchiver(checkpoint, blocksInCheckpoint.length, feeAssetPriceModifier);
338
784
 
339
- // If we have been configured to potentially skip publishing checkpoint then roll the dice here
340
- if (
341
- this.config.skipPublishingCheckpointsPercent !== undefined &&
342
- this.config.skipPublishingCheckpointsPercent > 0
343
- ) {
344
- const result = Math.max(0, randomInt(100));
345
- if (result < this.config.skipPublishingCheckpointsPercent) {
346
- this.log.warn(
347
- `Skipping publishing proposal for checkpoint ${checkpoint.number}. Configured percentage: ${this.config.skipPublishingCheckpointsPercent}, generated value: ${result}`,
348
- );
349
- return checkpoint;
785
+ const blockProposedAt = this.dateProvider.now();
786
+ if (this.config.skipBroadcastCheckpointProposal) {
787
+ // Test-only: suppress the CheckpointProposal so peers never see a proposed checkpoint for
788
+ // this slot, but still broadcast the held last block standalone so peers' archivers ingest
789
+ // it as a proposed-but-uncheckpointed tip — the exact orphan-block state that
790
+ // pruneOrphanProposedBlocks / checkSync must handle.
791
+ if (blockPendingBroadcast && !this.config.skipBroadcastProposals) {
792
+ await this.p2pClient.broadcastProposal(blockPendingBroadcast);
350
793
  }
794
+ } else if (!this.config.skipBroadcastProposals) {
795
+ await this.p2pClient.broadcastCheckpointProposal(proposal);
796
+ this.checkpointMetrics.noteCheckpointBroadcast(this.dateProvider.now());
351
797
  }
352
798
 
353
- await this.publisher.enqueueProposeCheckpoint(checkpoint, attestations, attestationsSignature, {
354
- txTimeoutAt,
355
- forcePendingCheckpointNumber: this.invalidateCheckpoint?.forcePendingCheckpointNumber,
356
- });
357
-
358
- return checkpoint;
799
+ // Return immediately after broadcast — attestation collection happens in the background
800
+ return { checkpoint, proposal, blockProposedAt };
359
801
  } catch (err) {
360
802
  if (err && (err instanceof DutyAlreadySignedError || err instanceof SlashingProtectionError)) {
361
803
  // swallow this error. It's already been logged by a function deeper in the stack
362
804
  return undefined;
363
805
  }
364
806
 
365
- this.log.error(`Error building checkpoint at slot ${this.slot}`, err);
807
+ this.log.error(`Error building checkpoint at slot ${this.targetSlot}`, err);
366
808
  return undefined;
367
809
  }
368
810
  }
@@ -378,29 +820,35 @@ export class CheckpointProposalJob implements Traceable {
378
820
  blockProposalOptions: BlockProposalOptions,
379
821
  ): Promise<{
380
822
  blocksInCheckpoint: L2Block[];
381
- blockPendingBroadcast: { block: L2Block; txs: Tx[] } | undefined;
823
+ blockPendingBroadcast: BlockProposal | undefined;
382
824
  }> {
383
825
  const blocksInCheckpoint: L2Block[] = [];
384
826
  const txHashesAlreadyIncluded = new Set<string>();
385
827
  const initialBlockNumber = BlockNumber(this.syncedToBlockNumber + 1);
386
828
 
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
829
  // Last block in the checkpoint will usually be flagged as pending broadcast, so we send it along with the checkpoint proposal
391
- let blockPendingBroadcast: { block: L2Block; txs: Tx[] } | undefined = undefined;
830
+ let blockPendingBroadcast: BlockProposal | undefined = undefined;
392
831
 
393
832
  while (true) {
394
833
  const blocksBuilt = blocksInCheckpoint.length;
395
834
  const indexWithinCheckpoint = IndexWithinCheckpoint(blocksBuilt);
396
835
  const blockNumber = BlockNumber(initialBlockNumber + blocksBuilt);
397
836
 
837
+ if (blocksBuilt >= this.config.maxBlocksPerCheckpoint) {
838
+ this.log.debug(`Reached max blocks per checkpoint`, {
839
+ slot: this.targetSlot,
840
+ blocksBuilt,
841
+ maxBlocksPerCheckpoint: this.config.maxBlocksPerCheckpoint,
842
+ });
843
+ break;
844
+ }
845
+
398
846
  const secondsIntoSlot = this.getSecondsIntoSlot();
399
847
  const timingInfo = this.timetable.canStartNextBlock(secondsIntoSlot);
400
848
 
401
849
  if (!timingInfo.canStart) {
402
850
  this.log.debug(`Not enough time left in slot to start another block`, {
403
- slot: this.slot,
851
+ slot: this.targetSlot,
404
852
  blocksBuilt,
405
853
  secondsIntoSlot,
406
854
  });
@@ -419,25 +867,25 @@ export class CheckpointProposalJob implements Traceable {
419
867
  blockNumber,
420
868
  indexWithinCheckpoint,
421
869
  txHashesAlreadyIncluded,
422
- remainingBlobFields,
423
870
  });
424
871
 
425
- // TODO(palla/mbps): Review these conditions. We may want to keep trying in some scenarios.
426
- if (!buildResult && timingInfo.isLastBlock) {
427
- // If no block was produced due to not enough txs and this was the last subslot, exit
428
- break;
429
- } else if (!buildResult && timingInfo.deadline !== undefined) {
430
- // But if there is still time for more blocks, wait until the next subslot and try again
872
+ // If we failed to build the block due to insufficient txs, we try again if there is still time left in the slot
873
+ if ('failure' in buildResult) {
874
+ // If this was the last subslot, or we're running with a single block per slot, we're done
875
+ if (timingInfo.isLastBlock || timingInfo.deadline === undefined) {
876
+ break;
877
+ }
878
+ // Otherwise, if there is still time for more blocks, we wait until the next subslot and try again
431
879
  await this.waitUntilNextSubslot(timingInfo.deadline);
432
880
  continue;
433
- } else if (!buildResult) {
434
- // Exit if there is no possibility of building more blocks
435
- break;
436
- } else if ('error' in buildResult) {
437
- // If there was an error building the block, just exit the loop and give up the rest of the slot
881
+ }
882
+
883
+ // If there was an error building the block, we just exit the loop and give up the rest of the slot.
884
+ // We don't want to risk building more blocks if something went wrong.
885
+ if ('error' in buildResult) {
438
886
  if (!(buildResult.error instanceof SequencerInterruptedError)) {
439
- this.log.warn(`Halting block building for slot ${this.slot}`, {
440
- slot: this.slot,
887
+ this.log.warn(`Halting block building for slot ${this.targetSlot}`, {
888
+ slot: this.targetSlot,
441
889
  blocksBuilt,
442
890
  error: buildResult.error,
443
891
  });
@@ -445,45 +893,43 @@ export class CheckpointProposalJob implements Traceable {
445
893
  break;
446
894
  }
447
895
 
448
- const { block, usedTxs, remainingBlobFields: newRemainingBlobFields } = buildResult;
449
- blocksInCheckpoint.push(block);
896
+ const { block, usedTxs } = buildResult;
897
+ this.checkpointMetrics.noteCheckpointBlockBuilt(this.dateProvider.now(), {
898
+ isFirstBlock: blocksBuilt === 0,
899
+ isLastBlock: timingInfo.isLastBlock,
900
+ });
450
901
 
451
- // Update remaining blob fields for the next block
452
- remainingBlobFields = newRemainingBlobFields;
902
+ blocksInCheckpoint.push(block);
903
+ usedTxs.forEach(tx => txHashesAlreadyIncluded.add(tx.txHash.toString()));
453
904
 
454
- // Sync the proposed block to the archiver to make it available
455
- // Note that the checkpoint builder uses its own fork so it should not need to wait for this syncing
456
- // Eventually we should refactor the checkpoint builder to not need a separate long-lived fork
457
- // Fire and forget - don't block the critical path, but log errors
458
- this.syncProposedBlockToArchiver(block).catch(err => {
459
- this.log.error(`Failed to sync proposed block ${block.number} to archiver`, { blockNumber: block.number, err });
905
+ // Sign the block proposal. This will throw if HA signing fails.
906
+ const proposal = await this.createBlockProposal(block, inHash, usedTxs, {
907
+ ...blockProposalOptions,
908
+ broadcastInvalidBlockProposal:
909
+ blockProposalOptions.broadcastInvalidBlockProposal ||
910
+ block.indexWithinCheckpoint === this.config.invalidBlockProposalIndexWithinCheckpoint,
460
911
  });
461
912
 
462
- usedTxs.forEach(tx => txHashesAlreadyIncluded.add(tx.txHash.toString()));
913
+ // Sync the proposed block to the archiver to make it available, only after we've managed to sign the proposal,
914
+ // so we avoid polluting our archive with a block that would fail.
915
+ // We wait for the sync to succeed, as this helps catch consistency errors, even if it means we lose some time for block-building.
916
+ // If this throws, we abort the entire checkpoint.
917
+ await this.syncProposedBlockToArchiver(block);
463
918
 
464
- // If this is the last block, exit the loop now so we start collecting attestations
919
+ // If this is the last block, do not broadcast it, since it will be included in the checkpoint proposal.
465
920
  if (timingInfo.isLastBlock) {
466
- this.log.verbose(`Completed final block ${blockNumber} for slot ${this.slot}`, {
467
- slot: this.slot,
921
+ this.log.verbose(`Completed final block ${blockNumber} for slot ${this.targetSlot}`, {
922
+ slot: this.targetSlot,
468
923
  blockNumber,
469
924
  blocksBuilt,
470
925
  });
471
- blockPendingBroadcast = { block, txs: usedTxs };
926
+
927
+ blockPendingBroadcast = proposal;
472
928
  break;
473
929
  }
474
930
 
475
- // For non-last blocks, broadcast the block proposal (unless we're in fisherman mode)
476
- // If the block is the last one, we'll broadcast it along with the checkpoint at the end of the loop
477
- if (!this.config.fishermanMode) {
478
- const proposal = await this.validatorClient.createBlockProposal(
479
- block.header,
480
- block.indexWithinCheckpoint,
481
- inHash,
482
- block.archive.root,
483
- usedTxs,
484
- this.proposer,
485
- blockProposalOptions,
486
- );
931
+ // Once we have a signed proposal and the archiver agreed with our proposed block, then we broadcast it.
932
+ if (proposal && !this.config.skipBroadcastProposals) {
487
933
  await this.p2pClient.broadcastProposal(proposal);
488
934
  }
489
935
 
@@ -491,19 +937,44 @@ export class CheckpointProposalJob implements Traceable {
491
937
  await this.waitUntilNextSubslot(timingInfo.deadline);
492
938
  }
493
939
 
494
- this.log.verbose(`Block building loop completed for slot ${this.slot}`, {
495
- slot: this.slot,
940
+ this.log.verbose(`Block building loop completed for slot ${this.targetSlot}`, {
941
+ slot: this.targetSlot,
496
942
  blocksBuilt: blocksInCheckpoint.length,
497
943
  });
498
944
 
499
945
  return { blocksInCheckpoint, blockPendingBroadcast };
500
946
  }
501
947
 
948
+ /** Creates a block proposal for a given block via the validator client (unless in fisherman mode) */
949
+ private createBlockProposal(
950
+ block: L2Block,
951
+ inHash: Fr,
952
+ usedTxs: Tx[],
953
+ blockProposalOptions: BlockProposalOptions,
954
+ ): Promise<BlockProposal | undefined> {
955
+ if (this.config.fishermanMode) {
956
+ this.log.info(`Skipping block proposal for block ${block.number} in fisherman mode`);
957
+ return Promise.resolve(undefined);
958
+ }
959
+ return this.validatorClient.createBlockProposal(
960
+ block.header,
961
+ this.checkpointNumber,
962
+ block.indexWithinCheckpoint,
963
+ inHash,
964
+ block.archive.root,
965
+ usedTxs,
966
+ this.proposer,
967
+ blockProposalOptions,
968
+ );
969
+ }
970
+
502
971
  /** Sleeps until it is time to produce the next block in the slot */
503
972
  @trackSpan('CheckpointProposalJob.waitUntilNextSubslot')
504
973
  private async waitUntilNextSubslot(nextSubslotStart: number) {
505
- this.setStateFn(SequencerState.WAITING_UNTIL_NEXT_BLOCK, this.slot);
506
- this.log.verbose(`Waiting until time for the next block at ${nextSubslotStart}s into slot`, { slot: this.slot });
974
+ this.setStateFn(SequencerState.WAITING_UNTIL_NEXT_BLOCK, this.targetSlot);
975
+ this.log.verbose(`Waiting until time for the next block at ${nextSubslotStart}s into slot`, {
976
+ slot: this.targetSlot,
977
+ });
507
978
  await this.waitUntilTimeInSlot(nextSubslotStart);
508
979
  }
509
980
 
@@ -518,36 +989,46 @@ export class CheckpointProposalJob implements Traceable {
518
989
  indexWithinCheckpoint: IndexWithinCheckpoint;
519
990
  buildDeadline: Date | undefined;
520
991
  txHashesAlreadyIncluded: Set<string>;
521
- remainingBlobFields: number;
522
992
  },
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;
993
+ ): Promise<
994
+ { block: L2Block; usedTxs: Tx[] } | { failure: 'insufficient-txs' | 'insufficient-valid-txs' } | { error: Error }
995
+ > {
996
+ const { blockTimestamp, forceCreate, blockNumber, indexWithinCheckpoint, buildDeadline, txHashesAlreadyIncluded } =
997
+ opts;
533
998
 
534
999
  this.log.verbose(
535
- `Preparing block ${blockNumber} index ${indexWithinCheckpoint} at checkpoint ${this.checkpointNumber} for slot ${this.slot}`,
1000
+ `Preparing block ${blockNumber} index ${indexWithinCheckpoint} at checkpoint ${this.checkpointNumber} for slot ${this.targetSlot}`,
536
1001
  { ...checkpointBuilder.getConstantData(), ...opts },
537
1002
  );
538
1003
 
539
1004
  try {
540
1005
  // Wait until we have enough txs to build the block
541
- const minTxs = this.config.minTxsPerBlock;
542
- const { availableTxs, canStartBuilding } = await this.waitForMinTxs(opts);
1006
+ const { availableTxs, canStartBuilding, minTxs } = await this.waitForMinTxs(opts);
543
1007
  if (!canStartBuilding) {
1008
+ this.logCheckpointEvent('block-build-failed', `Block build failed for slot ${this.targetSlot}`, {
1009
+ reason: 'insufficient_txs',
1010
+ blockNumber,
1011
+ slot: this.targetSlot,
1012
+ checkpointNumber: this.checkpointNumber,
1013
+ indexWithinCheckpoint,
1014
+ availableTxs,
1015
+ minTxs,
1016
+ });
544
1017
  this.log.warn(
545
- `Not enough txs to build block ${blockNumber} at index ${indexWithinCheckpoint} in slot ${this.slot} (got ${availableTxs} txs but needs ${minTxs})`,
546
- { blockNumber, slot: this.slot, indexWithinCheckpoint },
1018
+ `Not enough txs to build block ${blockNumber} at index ${indexWithinCheckpoint} in slot ${this.targetSlot} (got ${availableTxs} txs but needs ${minTxs})`,
1019
+ {
1020
+ reason: 'insufficient_txs',
1021
+ blockNumber,
1022
+ slot: this.targetSlot,
1023
+ checkpointNumber: this.checkpointNumber,
1024
+ indexWithinCheckpoint,
1025
+ availableTxs,
1026
+ minTxs,
1027
+ },
547
1028
  );
548
- this.eventEmitter.emit('block-tx-count-check-failed', { minTxs, availableTxs, slot: this.slot });
1029
+ this.eventEmitter.emit('block-tx-count-check-failed', { minTxs, availableTxs, slot: this.targetSlot });
549
1030
  this.metrics.recordBlockProposalFailed('insufficient_txs');
550
- return undefined;
1031
+ return { failure: 'insufficient-txs' };
551
1032
  }
552
1033
 
553
1034
  // Create iterator to pending txs. We filter out txs already included in previous blocks in the checkpoint
@@ -558,24 +1039,31 @@ export class CheckpointProposalJob implements Traceable {
558
1039
  );
559
1040
 
560
1041
  this.log.debug(
561
- `Building block ${blockNumber} at index ${indexWithinCheckpoint} for slot ${this.slot} with ${availableTxs} available txs`,
562
- { slot: this.slot, blockNumber, indexWithinCheckpoint },
1042
+ `Building block ${blockNumber} at index ${indexWithinCheckpoint} for slot ${this.targetSlot} with ${availableTxs} available txs`,
1043
+ { slot: this.targetSlot, blockNumber, indexWithinCheckpoint },
563
1044
  );
564
- this.setStateFn(SequencerState.CREATING_BLOCK, this.slot);
565
-
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;
1045
+ this.setStateFn(SequencerState.CREATING_BLOCK, this.targetSlot);
569
1046
 
570
- const blockBuilderOptions: PublicProcessorLimits = {
1047
+ // Per-block limits are operator overrides (from SEQ_MAX_L2_BLOCK_GAS etc.) further capped
1048
+ // by remaining checkpoint-level budgets inside CheckpointBuilder before each block is built.
1049
+ // minValidTxs is passed into the builder so it can reject the block *before* updating state.
1050
+ const minValidTxs = forceCreate ? 0 : (this.config.minValidTxsPerBlock ?? minTxs);
1051
+ const blockBuilderOptions: BlockBuilderOptions = {
571
1052
  maxTransactions: this.config.maxTxsPerBlock,
572
- maxBlockSize: this.config.maxBlockSizeInBytes,
573
- maxBlockGas: new Gas(this.config.maxDABlockGas, this.config.maxL2BlockGas),
574
- maxBlobFields: maxBlobFieldsForTxs,
1053
+ maxBlockGas:
1054
+ this.config.maxL2BlockGas !== undefined || this.config.maxDABlockGas !== undefined
1055
+ ? new Gas(this.config.maxDABlockGas ?? Infinity, this.config.maxL2BlockGas ?? Infinity)
1056
+ : undefined,
575
1057
  deadline: buildDeadline,
1058
+ isBuildingProposal: true,
1059
+ minValidTxs,
1060
+ maxBlocksPerCheckpoint: this.timetable.maxNumberOfBlocks,
1061
+ perBlockAllocationMultiplier: this.config.perBlockAllocationMultiplier,
576
1062
  };
577
1063
 
578
- // Actually build the block by executing txs
1064
+ // Actually build the block by executing txs. The builder throws InsufficientValidTxsError
1065
+ // if the number of successfully processed txs is below minValidTxs, ensuring state is not
1066
+ // updated for blocks that will be discarded.
579
1067
  const buildResult = await this.buildSingleBlockWithCheckpointBuilder(
580
1068
  checkpointBuilder,
581
1069
  pendingTxs,
@@ -587,22 +1075,38 @@ export class CheckpointProposalJob implements Traceable {
587
1075
  // If any txs failed during execution, drop them from the mempool so we don't pick them up again
588
1076
  await this.dropFailedTxsFromP2P(buildResult.failedTxs);
589
1077
 
590
- // Check if we have created a block with enough txs. If there were invalid txs in the pool, or if execution took
591
- // too long, then we may not get to minTxsPerBlock after executing public functions.
592
- const minValidTxs = this.config.minValidTxsPerBlock ?? minTxs;
593
- const numTxs = buildResult.status === 'no-valid-txs' ? 0 : buildResult.numTxs;
594
- if (buildResult.status === 'no-valid-txs' || (!forceCreate && numTxs < minValidTxs)) {
1078
+ if (buildResult.status === 'insufficient-valid-txs') {
1079
+ this.logCheckpointEvent('block-build-failed', `Block build failed for slot ${this.targetSlot}`, {
1080
+ reason: 'insufficient_valid_txs',
1081
+ slot: this.targetSlot,
1082
+ checkpointNumber: this.checkpointNumber,
1083
+ blockNumber,
1084
+ numTxs: buildResult.processedCount,
1085
+ indexWithinCheckpoint,
1086
+ minValidTxs,
1087
+ });
595
1088
  this.log.warn(
596
- `Block ${blockNumber} at index ${indexWithinCheckpoint} on slot ${this.slot} has too few valid txs to be proposed`,
597
- { slot: this.slot, blockNumber, numTxs, indexWithinCheckpoint, minValidTxs, buildResult: buildResult.status },
1089
+ `Block ${blockNumber} at index ${indexWithinCheckpoint} on slot ${this.targetSlot} has too few valid txs to be proposed`,
1090
+ {
1091
+ reason: 'insufficient_valid_txs',
1092
+ slot: this.targetSlot,
1093
+ checkpointNumber: this.checkpointNumber,
1094
+ blockNumber,
1095
+ numTxs: buildResult.processedCount,
1096
+ indexWithinCheckpoint,
1097
+ minValidTxs,
1098
+ },
598
1099
  );
599
- this.eventEmitter.emit('block-build-failed', { reason: `Insufficient valid txs`, slot: this.slot });
1100
+ this.eventEmitter.emit('block-build-failed', {
1101
+ reason: `Insufficient valid txs`,
1102
+ slot: this.targetSlot,
1103
+ });
600
1104
  this.metrics.recordBlockProposalFailed('insufficient_valid_txs');
601
- return undefined;
1105
+ return { failure: 'insufficient-valid-txs' };
602
1106
  }
603
1107
 
604
1108
  // Block creation succeeded, emit stats and metrics
605
- const { publicGas, block, publicProcessorDuration, usedTxs, usedTxBlobFields, blockBuildDuration } = buildResult;
1109
+ const { block, publicProcessorDuration, usedTxs, blockBuildDuration, numTxs } = buildResult;
606
1110
 
607
1111
  const blockStats = {
608
1112
  eventName: 'l2-block-built',
@@ -613,33 +1117,56 @@ export class CheckpointProposalJob implements Traceable {
613
1117
 
614
1118
  const blockHash = await block.hash();
615
1119
  const txHashes = block.body.txEffects.map(tx => tx.txHash);
616
- const manaPerSec = publicGas.l2Gas / (blockBuildDuration / 1000);
1120
+ const manaPerSec = block.header.totalManaUsed.toNumberUnsafe() / (blockBuildDuration / 1000);
617
1121
 
618
1122
  this.log.info(
619
- `Built block ${block.number} at checkpoint ${this.checkpointNumber} for slot ${this.slot} with ${numTxs} txs`,
1123
+ `Built block ${block.number} at checkpoint ${this.checkpointNumber} for slot ${this.targetSlot} with ${numTxs} txs`,
620
1124
  { blockHash, txHashes, manaPerSec, ...blockStats },
621
1125
  );
622
1126
 
623
- this.eventEmitter.emit('block-proposed', { blockNumber: block.number, slot: this.slot });
624
- this.metrics.recordBuiltBlock(blockBuildDuration, publicGas.l2Gas);
1127
+ // `slot` is the target/submission slot (may be one ahead when pipelining),
1128
+ // `buildSlot` is the wall-clock slot during which the block was actually built.
1129
+ this.eventEmitter.emit('block-proposed', {
1130
+ blockNumber: block.number,
1131
+ blockHash,
1132
+ checkpointNumber: this.checkpointNumber,
1133
+ indexWithinCheckpoint: block.indexWithinCheckpoint,
1134
+ slot: this.targetSlot,
1135
+ buildSlot: this.slotNow,
1136
+ });
1137
+ this.metrics.recordBuiltBlock(blockBuildDuration, block.header.totalManaUsed.toNumberUnsafe(), this.targetSlot);
625
1138
 
626
- return { block, usedTxs, remainingBlobFields: maxBlobFieldsForTxs - usedTxBlobFields };
1139
+ return { block, usedTxs };
627
1140
  } catch (err: any) {
628
- this.eventEmitter.emit('block-build-failed', { reason: err.message, slot: this.slot });
629
- this.log.error(`Error building block`, err, { blockNumber, slot: this.slot });
1141
+ this.eventEmitter.emit('block-build-failed', {
1142
+ reason: err.message,
1143
+ slot: this.targetSlot,
1144
+ });
1145
+ this.logCheckpointEvent('block-build-failed', `Block build failed for slot ${this.targetSlot}`, {
1146
+ reason: err instanceof Error ? err.message : String(err),
1147
+ slot: this.targetSlot,
1148
+ checkpointNumber: this.checkpointNumber,
1149
+ blockNumber,
1150
+ });
1151
+ this.log.error(`Error building block`, err, {
1152
+ reason: err instanceof Error ? err.message : String(err),
1153
+ slot: this.targetSlot,
1154
+ checkpointNumber: this.checkpointNumber,
1155
+ blockNumber,
1156
+ });
630
1157
  this.metrics.recordBlockProposalFailed(err.name || 'unknown_error');
631
1158
  this.metrics.recordFailedBlock();
632
1159
  return { error: err };
633
1160
  }
634
1161
  }
635
1162
 
636
- /** Uses the checkpoint builder to build a block, catching specific txs */
1163
+ /** Uses the checkpoint builder to build a block, catching InsufficientValidTxsError. */
637
1164
  private async buildSingleBlockWithCheckpointBuilder(
638
1165
  checkpointBuilder: CheckpointBuilder,
639
1166
  pendingTxs: AsyncIterable<Tx>,
640
1167
  blockNumber: BlockNumber,
641
1168
  blockTimestamp: bigint,
642
- blockBuilderOptions: PublicProcessorLimits,
1169
+ blockBuilderOptions: BlockBuilderOptions,
643
1170
  ) {
644
1171
  try {
645
1172
  const workTimer = new Timer();
@@ -647,8 +1174,12 @@ export class CheckpointProposalJob implements Traceable {
647
1174
  const blockBuildDuration = workTimer.ms();
648
1175
  return { ...result, blockBuildDuration, status: 'success' as const };
649
1176
  } catch (err: unknown) {
650
- if (isErrorClass(err, NoValidTxsError)) {
651
- return { failedTxs: err.failedTxs, status: 'no-valid-txs' as const };
1177
+ if (isErrorClass(err, InsufficientValidTxsError)) {
1178
+ return {
1179
+ failedTxs: err.failedTxs,
1180
+ processedCount: err.processedCount,
1181
+ status: 'insufficient-valid-txs' as const,
1182
+ };
652
1183
  }
653
1184
  throw err;
654
1185
  }
@@ -661,7 +1192,7 @@ export class CheckpointProposalJob implements Traceable {
661
1192
  blockNumber: BlockNumber;
662
1193
  indexWithinCheckpoint: IndexWithinCheckpoint;
663
1194
  buildDeadline: Date | undefined;
664
- }): Promise<{ canStartBuilding: boolean; availableTxs: number }> {
1195
+ }): Promise<{ canStartBuilding: boolean; availableTxs: number; minTxs: number }> {
665
1196
  const { indexWithinCheckpoint, blockNumber, buildDeadline, forceCreate } = opts;
666
1197
 
667
1198
  // We only allow a block with 0 txs in the first block of the checkpoint
@@ -678,20 +1209,50 @@ export class CheckpointProposalJob implements Traceable {
678
1209
  // If we're past deadline, or we have no deadline, give up
679
1210
  const now = this.dateProvider.nowAsDate();
680
1211
  if (startBuildingDeadline === undefined || now >= startBuildingDeadline) {
681
- return { canStartBuilding: false, availableTxs: availableTxs };
1212
+ return { canStartBuilding: false, availableTxs, minTxs };
682
1213
  }
683
1214
 
684
1215
  // Wait a bit before checking again
685
- this.setStateFn(SequencerState.WAITING_FOR_TXS, this.slot);
1216
+ this.setStateFn(SequencerState.WAITING_FOR_TXS, this.targetSlot);
686
1217
  this.log.verbose(
687
- `Waiting for enough txs to build block ${blockNumber} at index ${indexWithinCheckpoint} in slot ${this.slot} (have ${availableTxs} but need ${minTxs})`,
688
- { blockNumber, slot: this.slot, indexWithinCheckpoint },
1218
+ `Waiting for enough txs to build block ${blockNumber} at index ${indexWithinCheckpoint} in slot ${this.targetSlot} (have ${availableTxs} but need ${minTxs})`,
1219
+ { blockNumber, slot: this.targetSlot, indexWithinCheckpoint },
689
1220
  );
690
1221
  await this.waitForTxsPollingInterval();
691
1222
  availableTxs = await this.p2pClient.getPendingTxCount();
692
1223
  }
693
1224
 
694
- return { canStartBuilding: true, availableTxs };
1225
+ return { canStartBuilding: true, availableTxs, minTxs };
1226
+ }
1227
+
1228
+ private async getSignedCommitteeAttestations(
1229
+ broadcast: CheckpointProposalBroadcast,
1230
+ ): Promise<{ attestations: CommitteeAttestationsAndSigners; attestationsSignature: Signature } | undefined> {
1231
+ const { proposal, blockProposedAt } = broadcast;
1232
+ this.setStateFn(SequencerState.COLLECTING_ATTESTATIONS, this.targetSlot);
1233
+ const attestations = await this.waitForAttestations(proposal);
1234
+ if (!attestations) {
1235
+ return undefined;
1236
+ }
1237
+ this.checkpointMetrics.recordCheckpointAttestationDelay(this.dateProvider.now() - blockProposedAt);
1238
+
1239
+ // Proposer must sign over the attestations before pushing them to L1
1240
+ const signer = this.proposer ?? this.publisher.getSenderAddress();
1241
+ try {
1242
+ const attestationsSignature = await this.validatorClient.signAttestationsAndSigners(
1243
+ attestations,
1244
+ signer,
1245
+ this.targetSlot,
1246
+ this.checkpointNumber,
1247
+ );
1248
+ return { attestations, attestationsSignature };
1249
+ } catch (err) {
1250
+ if (this.handleHASigningError(err, 'Attestations signature')) {
1251
+ return;
1252
+ }
1253
+ this.log.error(`Error signing attestations for checkpoint proposal at slot ${proposal.slotNumber}`, err);
1254
+ return undefined;
1255
+ }
695
1256
  }
696
1257
 
697
1258
  /**
@@ -699,10 +1260,12 @@ export class CheckpointProposalJob implements Traceable {
699
1260
  * This is run after all blocks for the checkpoint have been built.
700
1261
  */
701
1262
  @trackSpan('CheckpointProposalJob.waitForAttestations')
702
- private async waitForAttestations(proposal: CheckpointProposal): Promise<CommitteeAttestationsAndSigners> {
1263
+ private async waitForAttestations(
1264
+ proposal: CheckpointProposal,
1265
+ ): Promise<CommitteeAttestationsAndSigners | undefined> {
703
1266
  if (this.config.fishermanMode) {
704
1267
  this.log.debug('Skipping attestation collection in fisherman mode');
705
- return CommitteeAttestationsAndSigners.empty();
1268
+ return CommitteeAttestationsAndSigners.empty(this.getSignatureContext());
706
1269
  }
707
1270
 
708
1271
  const slotNumber = proposal.slotNumber;
@@ -712,21 +1275,27 @@ export class CheckpointProposalJob implements Traceable {
712
1275
  throw new Error('No committee when collecting attestations');
713
1276
  } else if (committee.length === 0) {
714
1277
  this.log.verbose(`Attesting committee is empty`);
715
- return CommitteeAttestationsAndSigners.empty();
1278
+ return CommitteeAttestationsAndSigners.empty(this.getSignatureContext());
716
1279
  } else {
717
1280
  this.log.debug(`Attesting committee length is ${committee.length}`, { committee });
718
1281
  }
719
1282
 
720
- const numberOfRequiredAttestations = Math.floor((committee.length * 2) / 3) + 1;
1283
+ const numberOfRequiredAttestations = computeQuorum(committee.length);
721
1284
 
722
1285
  if (this.config.skipCollectingAttestations) {
723
1286
  this.log.warn('Skipping attestation collection as per config (attesting with own keys only)');
724
- const attestations = await this.validatorClient?.collectOwnAttestations(proposal);
725
- return new CommitteeAttestationsAndSigners(orderAttestations(attestations ?? [], committee));
1287
+ const attestations = await this.validatorClient?.collectOwnAttestations(proposal, this.checkpointNumber);
1288
+ this.logCheckpointAttestations('collected', committee, attestations ?? [], numberOfRequiredAttestations, {
1289
+ reason: 'collect_own_only',
1290
+ });
1291
+ return new CommitteeAttestationsAndSigners(
1292
+ orderAttestations(attestations ?? [], committee),
1293
+ this.getSignatureContext(),
1294
+ );
726
1295
  }
727
1296
 
728
1297
  const attestationTimeAllowed = this.config.enforceTimeTable
729
- ? this.timetable.getMaxAllowedTime(SequencerState.PUBLISHING_CHECKPOINT)!
1298
+ ? this.timetable.getCheckpointAttestationDeadline()
730
1299
  : this.l1Constants.slotDuration;
731
1300
  const attestationDeadline = new Date((this.getSlotStartBuildTimestamp() + attestationTimeAllowed) * 1000);
732
1301
 
@@ -739,6 +1308,7 @@ export class CheckpointProposalJob implements Traceable {
739
1308
  proposal,
740
1309
  numberOfRequiredAttestations,
741
1310
  attestationDeadline,
1311
+ this.checkpointNumber,
742
1312
  );
743
1313
 
744
1314
  collectedAttestationsCount = attestations.length;
@@ -757,23 +1327,70 @@ export class CheckpointProposalJob implements Traceable {
757
1327
 
758
1328
  // Rollup contract requires that the signatures are provided in the order of the committee
759
1329
  const sorted = orderAttestations(trimmed, committee);
1330
+ this.logCheckpointAttestations('collected', committee, attestations, numberOfRequiredAttestations, {
1331
+ submittedCount: trimmed.length,
1332
+ });
760
1333
 
761
1334
  // Manipulate the attestations if we've been configured to do so
762
- if (this.config.injectFakeAttestation || this.config.shuffleAttestationOrdering) {
1335
+ if (
1336
+ this.config.injectFakeAttestation ||
1337
+ this.config.injectHighSValueAttestation ||
1338
+ this.config.injectUnrecoverableSignatureAttestation ||
1339
+ this.config.shuffleAttestationOrdering
1340
+ ) {
763
1341
  return this.manipulateAttestations(proposal.slotNumber, epoch, seed, committee, sorted);
764
1342
  }
765
1343
 
766
- return new CommitteeAttestationsAndSigners(sorted);
1344
+ return new CommitteeAttestationsAndSigners(sorted, this.getSignatureContext());
767
1345
  } catch (err) {
768
1346
  if (err && err instanceof AttestationTimeoutError) {
769
1347
  collectedAttestationsCount = err.collectedCount;
1348
+ this.logCheckpointAttestations('failed', committee, undefined, numberOfRequiredAttestations, {
1349
+ collectedCount: collectedAttestationsCount,
1350
+ reason: 'timeout',
1351
+ });
1352
+ this.log.error(
1353
+ `Timeout while waiting for attestations for checkpoint proposal at slot ${proposal.slotNumber} (collected ${collectedAttestationsCount}/${numberOfRequiredAttestations})`,
1354
+ err,
1355
+ );
1356
+ } else {
1357
+ this.logCheckpointAttestations('failed', committee, undefined, numberOfRequiredAttestations, {
1358
+ collectedCount: collectedAttestationsCount,
1359
+ reason: err instanceof Error ? err.message : String(err),
1360
+ });
1361
+ this.log.error(`Error collecting attestations for checkpoint proposal at slot ${proposal.slotNumber}`, err);
770
1362
  }
771
- throw err;
1363
+ return undefined;
772
1364
  } finally {
773
1365
  this.metrics.recordCollectedAttestations(collectedAttestationsCount, collectAttestationsTimer.ms());
774
1366
  }
775
1367
  }
776
1368
 
1369
+ private logCheckpointAttestations(
1370
+ status: 'collected' | 'failed',
1371
+ committee: EthAddress[],
1372
+ attestations: CheckpointAttestation[] | undefined,
1373
+ requiredAttestations: number,
1374
+ opts: { collectedCount?: number; submittedCount?: number; reason?: string } = {},
1375
+ ) {
1376
+ const signedValidators =
1377
+ attestations
1378
+ ?.map(attestation => attestation.getSender()?.toString())
1379
+ .filter((address): address is `0x${string}` => address !== undefined) ?? [];
1380
+ const collectedCount = opts.collectedCount ?? new Set(signedValidators).size;
1381
+ const missingValidatorCount = status === 'failed' ? Math.max(0, requiredAttestations - collectedCount) : undefined;
1382
+ this.logCheckpointEvent(`attestations-${status}`, `Checkpoint attestations ${status} for slot ${this.targetSlot}`, {
1383
+ slot: this.targetSlot,
1384
+ checkpointNumber: this.checkpointNumber,
1385
+ committeeSize: committee.length,
1386
+ requiredAttestations,
1387
+ collectedAttestations: collectedCount,
1388
+ ...(opts.submittedCount !== undefined && { submittedAttestations: opts.submittedCount }),
1389
+ ...(missingValidatorCount !== undefined && { missingValidatorCount }),
1390
+ ...(opts.reason !== undefined && { reason: opts.reason }),
1391
+ });
1392
+ }
1393
+
777
1394
  /** Breaks the attestations before publishing based on attack configs */
778
1395
  private manipulateAttestations(
779
1396
  slotNumber: SlotNumber,
@@ -788,7 +1405,11 @@ export class CheckpointProposalJob implements Traceable {
788
1405
  this.epochCache.computeProposerIndex(slotNumber, epoch, seed, BigInt(committee.length)),
789
1406
  );
790
1407
 
791
- if (this.config.injectFakeAttestation) {
1408
+ if (
1409
+ this.config.injectFakeAttestation ||
1410
+ this.config.injectHighSValueAttestation ||
1411
+ this.config.injectUnrecoverableSignatureAttestation
1412
+ ) {
792
1413
  // Find non-empty attestations that are not from the proposer
793
1414
  const nonProposerIndices: number[] = [];
794
1415
  for (let i = 0; i < attestations.length; i++) {
@@ -798,27 +1419,48 @@ export class CheckpointProposalJob implements Traceable {
798
1419
  }
799
1420
  if (nonProposerIndices.length > 0) {
800
1421
  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();
1422
+ if (this.config.injectHighSValueAttestation) {
1423
+ this.log.warn(
1424
+ `Injecting high-s value attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`,
1425
+ );
1426
+ unfreeze(attestations[targetIndex]).signature = flipSignature(attestations[targetIndex].signature);
1427
+ } else if (this.config.injectUnrecoverableSignatureAttestation) {
1428
+ this.log.warn(
1429
+ `Injecting unrecoverable signature attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`,
1430
+ );
1431
+ unfreeze(attestations[targetIndex]).signature = generateUnrecoverableSignature();
1432
+ } else {
1433
+ this.log.warn(`Injecting fake attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`);
1434
+ unfreeze(attestations[targetIndex]).signature = generateRecoverableSignature();
1435
+ }
803
1436
  }
804
- return new CommitteeAttestationsAndSigners(attestations);
1437
+ return new CommitteeAttestationsAndSigners(attestations, this.getSignatureContext());
805
1438
  }
806
1439
 
807
1440
  if (this.config.shuffleAttestationOrdering) {
808
1441
  this.log.warn(`Shuffling attestation ordering in checkpoint for slot ${slotNumber} (proposer #${proposerIndex})`);
809
1442
 
810
1443
  const shuffled = [...attestations];
811
- const [i, j] = [(proposerIndex + 1) % shuffled.length, (proposerIndex + 2) % shuffled.length];
812
- const valueI = shuffled[i];
813
- const valueJ = shuffled[j];
814
- shuffled[i] = valueJ;
815
- shuffled[j] = valueI;
816
-
817
- const signers = new CommitteeAttestationsAndSigners(attestations).getSigners();
818
- return new MaliciousCommitteeAttestationsAndSigners(shuffled, signers);
1444
+
1445
+ // Find two non-proposer positions that both have non-empty signatures to swap.
1446
+ // This ensures the bitmap doesn't change, so the MaliciousCommitteeAttestationsAndSigners
1447
+ // signers array stays correctly aligned with L1's committee reconstruction.
1448
+ const swappable: number[] = [];
1449
+ for (let k = 0; k < shuffled.length; k++) {
1450
+ if (!shuffled[k].signature.isEmpty() && k !== proposerIndex) {
1451
+ swappable.push(k);
1452
+ }
1453
+ }
1454
+ if (swappable.length >= 2) {
1455
+ const [i, j] = [swappable[0], swappable[1]];
1456
+ [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
1457
+ }
1458
+
1459
+ const signers = new CommitteeAttestationsAndSigners(attestations, this.getSignatureContext()).getSigners();
1460
+ return new MaliciousCommitteeAttestationsAndSigners(shuffled, signers, this.getSignatureContext());
819
1461
  }
820
1462
 
821
- return new CommitteeAttestationsAndSigners(attestations);
1463
+ return new CommitteeAttestationsAndSigners(attestations, this.getSignatureContext());
822
1464
  }
823
1465
 
824
1466
  private async dropFailedTxsFromP2P(failedTxs: FailedTx[]) {
@@ -835,9 +1477,13 @@ export class CheckpointProposalJob implements Traceable {
835
1477
  * Adds the proposed block to the archiver so it's available via P2P.
836
1478
  * Gossip doesn't echo messages back to the sender, so the proposer's archiver/world-state
837
1479
  * would never receive its own block without this explicit sync.
1480
+ *
1481
+ * In fisherman mode we skip this push: the fisherman builds blocks locally for validation
1482
+ * and fee analysis only, and pushing them to the archiver causes spurious reorg cascades
1483
+ * whenever the real proposer's block arrives from L1.
838
1484
  */
839
1485
  private async syncProposedBlockToArchiver(block: L2Block): Promise<void> {
840
- if (this.config.skipPushProposedBlocksToArchiver !== false) {
1486
+ if (this.config.skipPushProposedBlocksToArchiver || this.config.fishermanMode) {
841
1487
  this.log.warn(`Skipping push of proposed block ${block.number} to archiver`, {
842
1488
  blockNumber: block.number,
843
1489
  slot: block.header.globalVariables.slotNumber,
@@ -851,23 +1497,62 @@ export class CheckpointProposalJob implements Traceable {
851
1497
  await this.blockSink.addBlock(block);
852
1498
  }
853
1499
 
1500
+ /**
1501
+ * Adds the proposed checkpoint to the archiver so the proposer's optimistic proposed-checkpoint
1502
+ * tip advances locally. Gossip doesn't echo our own messages back, so without this the proposer
1503
+ * would never see its own proposed checkpoint and couldn't pipeline the next slot.
1504
+ *
1505
+ * Only runs under proposer pipelining (the proposed tip is a pipelining-only concept) and is
1506
+ * skipped whenever proposed blocks aren't pushed (`skipPushProposedBlocksToArchiver`, fisherman
1507
+ * mode): the archiver derives the checkpoint archive from its stored blocks, so without them the
1508
+ * push would fail. All blocks were already added (and awaited) during block building, so this
1509
+ * needs no retry — they are guaranteed present by the time we get here.
1510
+ */
1511
+ private async syncProposedCheckpointToArchiver(
1512
+ checkpoint: Checkpoint,
1513
+ blockCount: number,
1514
+ feeAssetPriceModifier: bigint,
1515
+ ): Promise<void> {
1516
+ if (this.config.skipPushProposedBlocksToArchiver || this.config.fishermanMode) {
1517
+ return;
1518
+ }
1519
+ if (!this.epochCache.isProposerPipeliningEnabled()) {
1520
+ return;
1521
+ }
1522
+ const startBlock = BlockNumber(this.syncedToBlockNumber + 1);
1523
+ this.log.debug(`Syncing proposed checkpoint ${this.checkpointNumber} to archiver`, {
1524
+ checkpointNumber: this.checkpointNumber,
1525
+ slot: this.targetSlot,
1526
+ startBlock,
1527
+ blockCount,
1528
+ });
1529
+ await this.blockSink.addProposedCheckpoint({
1530
+ header: checkpoint.header,
1531
+ checkpointNumber: this.checkpointNumber,
1532
+ startBlock,
1533
+ blockCount,
1534
+ totalManaUsed: checkpoint.header.totalManaUsed.toBigInt(),
1535
+ feeAssetPriceModifier,
1536
+ });
1537
+ }
1538
+
854
1539
  /** Runs fee analysis and logs checkpoint outcome as fisherman */
855
1540
  private async handleCheckpointEndAsFisherman(checkpoint: Checkpoint | undefined) {
856
1541
  // Perform L1 fee analysis before clearing requests
857
1542
  // The callback is invoked asynchronously after the next block is mined
858
- const feeAnalysis = await this.publisher.analyzeL1Fees(this.slot, analysis =>
1543
+ const feeAnalysis = await this.publisher.analyzeL1Fees(this.targetSlot, analysis =>
859
1544
  this.metrics.recordFishermanFeeAnalysis(analysis),
860
1545
  );
861
1546
 
862
1547
  if (checkpoint) {
863
- this.log.info(`Validation checkpoint building SUCCEEDED for slot ${this.slot}`, {
1548
+ this.log.info(`Validation checkpoint building SUCCEEDED for slot ${this.targetSlot}`, {
864
1549
  ...checkpoint.toCheckpointInfo(),
865
1550
  ...checkpoint.getStats(),
866
1551
  feeAnalysisId: feeAnalysis?.id,
867
1552
  });
868
1553
  } else {
869
- this.log.warn(`Validation block building FAILED for slot ${this.slot}`, {
870
- slot: this.slot,
1554
+ this.log.warn(`Validation block building FAILED for slot ${this.targetSlot}`, {
1555
+ slot: this.targetSlot,
871
1556
  feeAnalysisId: feeAnalysis?.id,
872
1557
  });
873
1558
  this.metrics.recordCheckpointProposalFailed('block_build_failed');
@@ -881,15 +1566,15 @@ export class CheckpointProposalJob implements Traceable {
881
1566
  */
882
1567
  private handleHASigningError(err: any, errorContext: string): boolean {
883
1568
  if (err instanceof DutyAlreadySignedError) {
884
- this.log.info(`${errorContext} for slot ${this.slot} already signed by another HA node, yielding`, {
885
- slot: this.slot,
1569
+ this.log.info(`${errorContext} for slot ${this.targetSlot} already signed by another HA node, yielding`, {
1570
+ slot: this.targetSlot,
886
1571
  signedByNode: err.signedByNode,
887
1572
  });
888
1573
  return true;
889
1574
  }
890
1575
  if (err instanceof SlashingProtectionError) {
891
- this.log.info(`${errorContext} for slot ${this.slot} blocked by slashing protection, yielding`, {
892
- slot: this.slot,
1576
+ this.log.info(`${errorContext} for slot ${this.targetSlot} blocked by slashing protection, yielding`, {
1577
+ slot: this.targetSlot,
893
1578
  existingMessageHash: err.existingMessageHash,
894
1579
  attemptedMessageHash: err.attemptedMessageHash,
895
1580
  });
@@ -912,7 +1597,7 @@ export class CheckpointProposalJob implements Traceable {
912
1597
  }
913
1598
 
914
1599
  private getSlotStartBuildTimestamp(): number {
915
- return getSlotStartBuildTimestamp(this.slot, this.l1Constants);
1600
+ return getSlotStartBuildTimestamp(this.slotNow, this.l1Constants);
916
1601
  }
917
1602
 
918
1603
  private getSecondsIntoSlot(): number {