@aztec/sequencer-client 0.0.1-commit.cd76b27 → 0.0.1-commit.ce4f8c4f2

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 (73) hide show
  1. package/dest/client/sequencer-client.d.ts +4 -1
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +46 -23
  4. package/dest/config.d.ts +25 -5
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +31 -17
  7. package/dest/global_variable_builder/global_builder.d.ts +13 -7
  8. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  9. package/dest/global_variable_builder/global_builder.js +22 -21
  10. package/dest/global_variable_builder/index.d.ts +2 -2
  11. package/dest/global_variable_builder/index.d.ts.map +1 -1
  12. package/dest/publisher/config.d.ts +17 -1
  13. package/dest/publisher/config.d.ts.map +1 -1
  14. package/dest/publisher/config.js +23 -3
  15. package/dest/publisher/index.d.ts +2 -1
  16. package/dest/publisher/index.d.ts.map +1 -1
  17. package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
  18. package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
  19. package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
  20. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +59 -0
  21. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
  22. package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
  23. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
  24. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
  25. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
  26. package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
  27. package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
  28. package/dest/publisher/l1_tx_failed_store/index.js +2 -0
  29. package/dest/publisher/sequencer-publisher-factory.d.ts +3 -3
  30. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  31. package/dest/publisher/sequencer-publisher-factory.js +16 -2
  32. package/dest/publisher/sequencer-publisher.d.ts +19 -4
  33. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  34. package/dest/publisher/sequencer-publisher.js +294 -18
  35. package/dest/sequencer/checkpoint_proposal_job.d.ts +13 -7
  36. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  37. package/dest/sequencer/checkpoint_proposal_job.js +206 -130
  38. package/dest/sequencer/events.d.ts +2 -1
  39. package/dest/sequencer/events.d.ts.map +1 -1
  40. package/dest/sequencer/metrics.d.ts +5 -1
  41. package/dest/sequencer/metrics.d.ts.map +1 -1
  42. package/dest/sequencer/metrics.js +11 -0
  43. package/dest/sequencer/sequencer.d.ts +18 -9
  44. package/dest/sequencer/sequencer.d.ts.map +1 -1
  45. package/dest/sequencer/sequencer.js +77 -62
  46. package/dest/sequencer/timetable.d.ts +4 -3
  47. package/dest/sequencer/timetable.d.ts.map +1 -1
  48. package/dest/sequencer/timetable.js +6 -7
  49. package/dest/sequencer/types.d.ts +2 -2
  50. package/dest/sequencer/types.d.ts.map +1 -1
  51. package/dest/test/mock_checkpoint_builder.d.ts +7 -9
  52. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  53. package/dest/test/mock_checkpoint_builder.js +39 -30
  54. package/package.json +27 -28
  55. package/src/client/sequencer-client.ts +56 -21
  56. package/src/config.ts +39 -19
  57. package/src/global_variable_builder/global_builder.ts +22 -23
  58. package/src/global_variable_builder/index.ts +1 -1
  59. package/src/publisher/config.ts +41 -0
  60. package/src/publisher/index.ts +3 -0
  61. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  62. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
  63. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
  64. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  65. package/src/publisher/sequencer-publisher-factory.ts +18 -3
  66. package/src/publisher/sequencer-publisher.ts +281 -26
  67. package/src/sequencer/checkpoint_proposal_job.ts +277 -142
  68. package/src/sequencer/events.ts +1 -1
  69. package/src/sequencer/metrics.ts +14 -0
  70. package/src/sequencer/sequencer.ts +105 -69
  71. package/src/sequencer/timetable.ts +7 -7
  72. package/src/sequencer/types.ts +1 -1
  73. package/src/test/mock_checkpoint_builder.ts +51 -48
@@ -13,7 +13,7 @@ export type SequencerEvents = {
13
13
  ['proposer-rollup-check-failed']: (args: { reason: string; slot: SlotNumber }) => void;
14
14
  ['block-tx-count-check-failed']: (args: { minTxs: number; availableTxs: number; slot: SlotNumber }) => void;
15
15
  ['block-build-failed']: (args: { reason: string; slot: SlotNumber }) => void;
16
- ['block-proposed']: (args: { blockNumber: BlockNumber; slot: SlotNumber }) => void;
16
+ ['block-proposed']: (args: { blockNumber: BlockNumber; slot: SlotNumber; buildSlot: SlotNumber }) => void;
17
17
  ['checkpoint-empty']: (args: { slot: SlotNumber }) => void;
18
18
  ['checkpoint-publish-failed']: (args: {
19
19
  slot: SlotNumber;
@@ -49,6 +49,8 @@ export class SequencerMetrics {
49
49
  private checkpointBlockCount: Gauge;
50
50
  private checkpointTxCount: Gauge;
51
51
  private checkpointTotalMana: Gauge;
52
+ private pipelineDepth: Gauge;
53
+ private pipelineDiscards: UpDownCounter;
52
54
 
53
55
  // Fisherman fee analysis metrics
54
56
  private fishermanWouldBeIncluded: UpDownCounter;
@@ -143,6 +145,10 @@ export class SequencerMetrics {
143
145
 
144
146
  this.slashingAttempts = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLASHING_ATTEMPTS_COUNT);
145
147
 
148
+ this.pipelineDepth = this.meter.createGauge(Metrics.SEQUENCER_PIPELINE_DEPTH);
149
+ this.pipelineDiscards = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_PIPELINE_DISCARDS_COUNT);
150
+ this.pipelineDepth.record(0);
151
+
146
152
  // Fisherman fee analysis metrics
147
153
  this.fishermanWouldBeIncluded = createUpDownCounterWithDefault(
148
154
  this.meter,
@@ -234,6 +240,14 @@ export class SequencerMetrics {
234
240
  });
235
241
  }
236
242
 
243
+ recordPipelineDepth(depth: number) {
244
+ this.pipelineDepth.record(depth);
245
+ }
246
+
247
+ recordPipelineDiscard(count = 1) {
248
+ this.pipelineDiscards.add(count);
249
+ }
250
+
237
251
  incOpenSlot(slot: SlotNumber, proposer: string) {
238
252
  // sequencer went through the loop a second time. Noop
239
253
  if (slot === this.lastSeenSlot) {
@@ -14,7 +14,7 @@ import type { P2P } from '@aztec/p2p';
14
14
  import type { SlasherClientInterface } from '@aztec/slasher';
15
15
  import type { BlockData, L2BlockSink, L2BlockSource, ValidateCheckpointResult } from '@aztec/stdlib/block';
16
16
  import type { Checkpoint } from '@aztec/stdlib/checkpoint';
17
- import { getSlotAtTimestamp, getSlotStartBuildTimestamp } from '@aztec/stdlib/epoch-helpers';
17
+ import { getSlotStartBuildTimestamp } from '@aztec/stdlib/epoch-helpers';
18
18
  import {
19
19
  type ResolvedSequencerConfig,
20
20
  type SequencerConfig,
@@ -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
  {
@@ -147,7 +147,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
147
147
  public async stop(): Promise<void> {
148
148
  this.log.info(`Stopping sequencer`);
149
149
  this.setState(SequencerState.STOPPING, undefined, { force: true });
150
- this.publisherFactory.interruptAll();
150
+ await this.publisherFactory.stopAll();
151
151
  await this.runningPromise?.stop();
152
152
  this.setState(SequencerState.STOPPED, undefined, { force: true });
153
153
  this.log.info('Stopped sequencer');
@@ -192,10 +192,18 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
192
192
  @trackSpan('Sequencer.work')
193
193
  protected async work() {
194
194
  this.setState(SequencerState.SYNCHRONIZING, undefined);
195
- const { slot, ts, now, epoch } = this.epochCache.getEpochAndSlotInNextL1Slot();
195
+ const { slot, ts, nowSeconds, epoch } = this.epochCache.getEpochAndSlotInNextL1Slot();
196
+ const { slot: targetSlot, epoch: targetEpoch } = this.epochCache.getTargetEpochAndSlotInNextL1Slot();
196
197
 
197
198
  // Check if we are synced and it's our slot, grab a publisher, check previous block invalidation, etc
198
- const checkpointProposalJob = await this.prepareCheckpointProposal(epoch, slot, ts, now);
199
+ const checkpointProposalJob = await this.prepareCheckpointProposal(
200
+ slot,
201
+ targetSlot,
202
+ epoch,
203
+ targetEpoch,
204
+ ts,
205
+ nowSeconds,
206
+ );
199
207
  if (!checkpointProposalJob) {
200
208
  return;
201
209
  }
@@ -208,13 +216,13 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
208
216
  this.lastCheckpointProposed = checkpoint;
209
217
  }
210
218
 
211
- // Log fee strategy comparison if on fisherman
219
+ // Log fee strategy comparison if on fisherman (uses target epoch since we mirror the proposer's perspective)
212
220
  if (
213
221
  this.config.fishermanMode &&
214
- (this.lastEpochForStrategyComparison === undefined || epoch > this.lastEpochForStrategyComparison)
222
+ (this.lastEpochForStrategyComparison === undefined || targetEpoch > this.lastEpochForStrategyComparison)
215
223
  ) {
216
- this.logStrategyComparison(epoch, checkpointProposalJob.getPublisher());
217
- this.lastEpochForStrategyComparison = epoch;
224
+ this.logStrategyComparison(targetEpoch, checkpointProposalJob.getPublisher());
225
+ this.lastEpochForStrategyComparison = targetEpoch;
218
226
  }
219
227
 
220
228
  return checkpoint;
@@ -227,43 +235,48 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
227
235
  */
228
236
  @trackSpan('Sequencer.prepareCheckpointProposal')
229
237
  private async prepareCheckpointProposal(
230
- epoch: EpochNumber,
231
238
  slot: SlotNumber,
239
+ targetSlot: SlotNumber,
240
+ epoch: EpochNumber,
241
+ targetEpoch: EpochNumber,
232
242
  ts: bigint,
233
- now: bigint,
243
+ nowSeconds: bigint,
234
244
  ): Promise<CheckpointProposalJob | undefined> {
235
- // Check we have not already processed this slot (cheapest check)
245
+ // Check we have not already processed this target slot (cheapest check)
236
246
  // We only check this if enforce timetable is set, since we want to keep processing the same slot if we are not
237
247
  // running against actual time (eg when we use sandbox-style automining)
238
248
  if (
239
249
  this.lastSlotForCheckpointProposalJob &&
240
- this.lastSlotForCheckpointProposalJob >= slot &&
250
+ this.lastSlotForCheckpointProposalJob >= targetSlot &&
241
251
  this.config.enforceTimeTable
242
252
  ) {
243
- this.log.trace(`Slot ${slot} has already been processed`);
253
+ this.log.trace(`Target slot ${targetSlot} has already been processed`);
244
254
  return undefined;
245
255
  }
246
256
 
247
- // But if we have already proposed for this slot, the we definitely have to skip it, automining or not
248
- if (this.lastCheckpointProposed && this.lastCheckpointProposed.header.slotNumber >= slot) {
249
- this.log.trace(`Slot ${slot} has already been published as checkpoint ${this.lastCheckpointProposed.number}`);
257
+ // But if we have already proposed for this slot, then we definitely have to skip it, automining or not
258
+ if (this.lastCheckpointProposed && this.lastCheckpointProposed.header.slotNumber >= targetSlot) {
259
+ this.log.trace(
260
+ `Slot ${targetSlot} has already been published as checkpoint ${this.lastCheckpointProposed.number}`,
261
+ );
250
262
  return undefined;
251
263
  }
252
264
 
253
265
  // Check all components are synced to latest as seen by the archiver (queries all subsystems)
254
266
  const syncedTo = await this.checkSync({ ts, slot });
255
267
  if (!syncedTo) {
256
- await this.tryVoteWhenSyncFails({ slot, ts });
268
+ await this.tryVoteWhenSyncFails({ slot, targetSlot, ts });
257
269
  return undefined;
258
270
  }
259
271
 
260
- // If escape hatch is open for this epoch, do not start checkpoint proposal work and do not attempt invalidations.
272
+ // If escape hatch is open for the target epoch, do not start checkpoint proposal work and do not attempt invalidations.
261
273
  // Still perform governance/slashing voting (as proposer) once per slot.
262
- const isEscapeHatchOpen = await this.epochCache.isEscapeHatchOpen(epoch);
274
+ // When pipelining, we check the target epoch (slot+1's epoch) since that's the epoch we're building for.
275
+ const isEscapeHatchOpen = await this.epochCache.isEscapeHatchOpen(targetEpoch);
263
276
 
264
277
  if (isEscapeHatchOpen) {
265
278
  this.setState(SequencerState.PROPOSER_CHECK, slot);
266
- const [canPropose, proposer] = await this.checkCanPropose(slot);
279
+ const [canPropose, proposer] = await this.checkCanPropose(targetSlot);
267
280
  if (canPropose) {
268
281
  await this.tryVoteWhenEscapeHatchOpen({ slot, proposer });
269
282
  } else {
@@ -280,18 +293,18 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
280
293
  const checkpointNumber = CheckpointNumber(syncedTo.checkpointNumber + 1);
281
294
 
282
295
  const logCtx = {
283
- now,
284
- syncedToL1Ts: syncedTo.l1Timestamp,
285
- syncedToL2Slot: getSlotAtTimestamp(syncedTo.l1Timestamp, this.l1Constants),
296
+ nowSeconds,
297
+ syncedToL2Slot: syncedTo.syncedL2Slot,
286
298
  slot,
299
+ targetSlot,
287
300
  slotTs: ts,
288
301
  checkpointNumber,
289
302
  isPendingChainValid: pick(syncedTo.pendingChainValidationStatus, 'valid', 'reason', 'invalidIndex'),
290
303
  };
291
304
 
292
- // Check that we are a proposer for the next slot
305
+ // Check that we are a proposer for the target slot.
293
306
  this.setState(SequencerState.PROPOSER_CHECK, slot);
294
- const [canPropose, proposer] = await this.checkCanPropose(slot);
307
+ const [canPropose, proposer] = await this.checkCanPropose(targetSlot);
295
308
 
296
309
  // If we are not a proposer check if we should invalidate an invalid checkpoint, and bail
297
310
  if (!canPropose) {
@@ -299,10 +312,10 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
299
312
  return undefined;
300
313
  }
301
314
 
302
- // Check that the slot is not taken by a block already (should never happen, since only us can propose for this slot)
303
- if (syncedTo.blockData && syncedTo.blockData.header.getSlot() >= slot) {
315
+ // Check that the target slot is not taken by a block already (should never happen, since only us can propose for this slot)
316
+ if (syncedTo.blockData && syncedTo.blockData.header.getSlot() >= targetSlot) {
304
317
  this.log.warn(
305
- `Cannot propose block at next L2 slot ${slot} since that slot was taken by block ${syncedTo.blockNumber}`,
318
+ `Cannot propose block at target slot ${targetSlot} since that slot was taken by block ${syncedTo.blockNumber}`,
306
319
  { ...logCtx, block: syncedTo.blockData.header.toInspect() },
307
320
  );
308
321
  this.metrics.recordCheckpointPrecheckFailed('slot_already_taken');
@@ -326,13 +339,11 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
326
339
  // Prepare invalidation request if the pending chain is invalid (returns undefined if no need)
327
340
  const invalidateCheckpoint = await publisher.simulateInvalidateCheckpoint(syncedTo.pendingChainValidationStatus);
328
341
 
329
- // Check with the rollup contract if we can indeed propose at the next L2 slot. This check should not fail
342
+ // Check with the rollup contract if we can indeed propose at the target slot. This check should not fail
330
343
  // if all the previous checks are good, but we do it just in case.
331
- const canProposeCheck = await publisher.canProposeAtNextEthBlock(
332
- syncedTo.archive,
333
- proposer ?? EthAddress.ZERO,
334
- invalidateCheckpoint,
335
- );
344
+ const canProposeCheck = await publisher.canProposeAt(syncedTo.archive, proposer ?? EthAddress.ZERO, {
345
+ ...invalidateCheckpoint,
346
+ });
336
347
 
337
348
  if (canProposeCheck === undefined) {
338
349
  this.log.warn(
@@ -344,10 +355,10 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
344
355
  return undefined;
345
356
  }
346
357
 
347
- if (canProposeCheck.slot !== slot) {
358
+ if (canProposeCheck.slot !== targetSlot) {
348
359
  this.log.warn(
349
- `Cannot propose block due to slot mismatch with rollup contract (this can be caused by a clock out of sync). Expected slot ${slot} but got ${canProposeCheck.slot}.`,
350
- { ...logCtx, rollup: canProposeCheck, expectedSlot: slot },
360
+ `Cannot propose block due to slot mismatch with rollup contract (this can be caused by a clock out of sync). Expected slot ${targetSlot} but got ${canProposeCheck.slot}.`,
361
+ { ...logCtx, rollup: canProposeCheck, expectedSlot: targetSlot },
351
362
  );
352
363
  this.emit('proposer-rollup-check-failed', { reason: 'Slot mismatch', slot });
353
364
  this.metrics.recordCheckpointPrecheckFailed('slot_mismatch');
@@ -364,14 +375,24 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
364
375
  return undefined;
365
376
  }
366
377
 
367
- this.lastSlotForCheckpointProposalJob = slot;
368
- await this.p2pClient.prepareForSlot(slot);
369
- this.log.info(`Preparing checkpoint proposal ${checkpointNumber} at slot ${slot}`, { ...logCtx, proposer });
378
+ this.lastSlotForCheckpointProposalJob = targetSlot;
379
+
380
+ await this.p2pClient.prepareForSlot(targetSlot);
381
+ this.log.info(
382
+ `Preparing checkpoint proposal ${checkpointNumber} for target slot ${targetSlot} during wall-clock slot ${slot}`,
383
+ {
384
+ ...logCtx,
385
+ proposer,
386
+ pipeliningEnabled: this.epochCache.isProposerPipeliningEnabled(),
387
+ },
388
+ );
370
389
 
371
390
  // Create and return the checkpoint proposal job
372
391
  return this.createCheckpointProposalJob(
373
- epoch,
374
392
  slot,
393
+ targetSlot,
394
+ epoch,
395
+ targetEpoch,
375
396
  checkpointNumber,
376
397
  syncedTo.blockNumber,
377
398
  proposer,
@@ -382,8 +403,10 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
382
403
  }
383
404
 
384
405
  protected createCheckpointProposalJob(
385
- epoch: EpochNumber,
386
406
  slot: SlotNumber,
407
+ targetSlot: SlotNumber,
408
+ epoch: EpochNumber,
409
+ targetEpoch: EpochNumber,
387
410
  checkpointNumber: CheckpointNumber,
388
411
  syncedToBlockNumber: BlockNumber,
389
412
  proposer: EthAddress | undefined,
@@ -392,8 +415,10 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
392
415
  invalidateCheckpoint: InvalidateCheckpointRequest | undefined,
393
416
  ): CheckpointProposalJob {
394
417
  return new CheckpointProposalJob(
395
- epoch,
396
418
  slot,
419
+ targetSlot,
420
+ epoch,
421
+ targetEpoch,
397
422
  checkpointNumber,
398
423
  syncedToBlockNumber,
399
424
  proposer,
@@ -422,6 +447,13 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
422
447
  );
423
448
  }
424
449
 
450
+ /**
451
+ * Returns the current sequencer state.
452
+ */
453
+ public getState(): SequencerState {
454
+ return this.state;
455
+ }
456
+
425
457
  /**
426
458
  * Internal helper for setting the sequencer state and checks if we have enough time left in the slot to transition to the new state.
427
459
  * @param proposedState - The new state to transition to.
@@ -468,16 +500,15 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
468
500
  * We don't check against the previous block submitted since it may have been reorg'd out.
469
501
  */
470
502
  protected async checkSync(args: { ts: bigint; slot: SlotNumber }): Promise<SequencerSyncCheckResult | undefined> {
471
- // Check that the archiver and dependencies have synced to the previous L1 slot at least
472
- // TODO(#14766): Archiver reports L1 timestamp based on L1 blocks seen, which means that a missed L1 block will
473
- // cause the archiver L1 timestamp to fall behind, and cause this sequencer to start processing one L1 slot later.
474
- const l1Timestamp = await this.l2BlockSource.getL1Timestamp();
475
- const { slot, ts } = args;
476
- if (l1Timestamp === undefined || l1Timestamp + BigInt(this.l1Constants.ethereumSlotDuration) < ts) {
503
+ // Check that the archiver has fully synced the L2 slot before the one we want to propose in.
504
+ // The archiver reports sync progress via L1 block timestamps and synced checkpoint slots.
505
+ // See getSyncedL2SlotNumber for how missed L1 blocks are handled.
506
+ const syncedL2Slot = await this.l2BlockSource.getSyncedL2SlotNumber();
507
+ const { slot } = args;
508
+ if (syncedL2Slot === undefined || syncedL2Slot + 1 < slot) {
477
509
  this.log.debug(`Cannot propose block at next L2 slot ${slot} due to pending sync from L1`, {
478
510
  slot,
479
- ts,
480
- l1Timestamp,
511
+ syncedL2Slot,
481
512
  });
482
513
  return undefined;
483
514
  }
@@ -517,7 +548,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
517
548
  checkpointNumber: CheckpointNumber.ZERO,
518
549
  blockNumber: BlockNumber.ZERO,
519
550
  archive,
520
- l1Timestamp,
551
+ syncedL2Slot,
521
552
  pendingChainValidationStatus,
522
553
  };
523
554
  }
@@ -534,7 +565,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
534
565
  blockNumber: blockData.header.getBlockNumber(),
535
566
  checkpointNumber: blockData.checkpointNumber,
536
567
  archive: blockData.archive.root,
537
- l1Timestamp,
568
+ syncedL2Slot,
538
569
  pendingChainValidationStatus,
539
570
  };
540
571
  }
@@ -543,20 +574,20 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
543
574
  * Checks if we are the proposer for the next slot.
544
575
  * @returns True if we can propose, and the proposer address (undefined if anyone can propose)
545
576
  */
546
- protected async checkCanPropose(slot: SlotNumber): Promise<[boolean, EthAddress | undefined]> {
577
+ protected async checkCanPropose(targetSlot: SlotNumber): Promise<[boolean, EthAddress | undefined]> {
547
578
  let proposer: EthAddress | undefined;
548
579
 
549
580
  try {
550
- proposer = await this.epochCache.getProposerAttesterAddressInSlot(slot);
581
+ proposer = await this.epochCache.getProposerAttesterAddressInSlot(targetSlot);
551
582
  } catch (e) {
552
583
  if (e instanceof NoCommitteeError) {
553
- if (this.lastSlotForNoCommitteeWarning !== slot) {
554
- this.lastSlotForNoCommitteeWarning = slot;
555
- this.log.warn(`Cannot propose at next L2 slot ${slot} since the committee does not exist on L1`);
584
+ if (this.lastSlotForNoCommitteeWarning !== targetSlot) {
585
+ this.lastSlotForNoCommitteeWarning = targetSlot;
586
+ this.log.warn(`Cannot propose at target slot ${targetSlot} since the committee does not exist on L1`);
556
587
  }
557
588
  return [false, undefined];
558
589
  }
559
- this.log.error(`Error getting proposer for slot ${slot}`, e);
590
+ this.log.error(`Error getting proposer for target slot ${targetSlot}`, e);
560
591
  return [false, undefined];
561
592
  }
562
593
 
@@ -573,10 +604,15 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
573
604
  const weAreProposer = validatorAddresses.some(addr => addr.equals(proposer));
574
605
 
575
606
  if (!weAreProposer) {
576
- this.log.debug(`Cannot propose at slot ${slot} since we are not a proposer`, { validatorAddresses, proposer });
607
+ this.log.debug(`Cannot propose at target slot ${targetSlot} since we are not a proposer`, {
608
+ targetSlot,
609
+ validatorAddresses,
610
+ proposer,
611
+ });
577
612
  return [false, proposer];
578
613
  }
579
614
 
615
+ this.log.debug(`We are the proposer for target slot ${targetSlot}`, { targetSlot, proposer });
580
616
  return [true, proposer];
581
617
  }
582
618
 
@@ -585,8 +621,8 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
585
621
  * This allows the sequencer to participate in governance/slashing votes even when it cannot build blocks.
586
622
  */
587
623
  @trackSpan('Seqeuencer.tryVoteWhenSyncFails', ({ slot }) => ({ [Attributes.SLOT_NUMBER]: slot }))
588
- protected async tryVoteWhenSyncFails(args: { slot: SlotNumber; ts: bigint }): Promise<void> {
589
- const { slot } = args;
624
+ protected async tryVoteWhenSyncFails(args: { slot: SlotNumber; targetSlot: SlotNumber; ts: bigint }): Promise<void> {
625
+ const { slot, targetSlot } = args;
590
626
 
591
627
  // Prevent duplicate attempts in the same slot
592
628
  if (this.lastSlotForFallbackVote === slot) {
@@ -614,7 +650,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
614
650
  });
615
651
 
616
652
  // Check if we're a proposer or proposal is open
617
- const [canPropose, proposer] = await this.checkCanPropose(slot);
653
+ const [canPropose, proposer] = await this.checkCanPropose(targetSlot);
618
654
  if (!canPropose) {
619
655
  this.log.trace(`Cannot vote in slot ${slot} since we are not a proposer`, { slot, proposer });
620
656
  return;
@@ -631,9 +667,9 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
631
667
  slot,
632
668
  });
633
669
 
634
- // Enqueue governance and slashing votes
670
+ // Enqueue governance and slashing votes (voter uses the target slot for L1 submission)
635
671
  const voter = new CheckpointVoter(
636
- slot,
672
+ targetSlot,
637
673
  publisher,
638
674
  attestorAddress,
639
675
  this.validatorClient,
@@ -713,7 +749,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
713
749
  syncedTo: SequencerSyncCheckResult,
714
750
  currentSlot: SlotNumber,
715
751
  ): Promise<void> {
716
- const { pendingChainValidationStatus, l1Timestamp } = syncedTo;
752
+ const { pendingChainValidationStatus, syncedL2Slot } = syncedTo;
717
753
  if (pendingChainValidationStatus.valid) {
718
754
  return;
719
755
  }
@@ -728,7 +764,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
728
764
 
729
765
  const logData = {
730
766
  invalidL1Timestamp: invalidCheckpointTimestamp,
731
- l1Timestamp,
767
+ syncedL2Slot,
732
768
  invalidCheckpoint: pendingChainValidationStatus.checkpoint,
733
769
  secondsBeforeInvalidatingBlockAsCommitteeMember,
734
770
  secondsBeforeInvalidatingBlockAsNonCommitteeMember,
@@ -875,6 +911,6 @@ type SequencerSyncCheckResult = {
875
911
  checkpointNumber: CheckpointNumber;
876
912
  blockNumber: BlockNumber;
877
913
  archive: Fr;
878
- l1Timestamp: bigint;
914
+ syncedL2Slot: SlotNumber;
879
915
  pendingChainValidationStatus: ValidateCheckpointResult;
880
916
  };
@@ -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,
@@ -2,5 +2,5 @@ import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
2
2
 
3
3
  export type SequencerRollupConstants = Pick<
4
4
  L1RollupConstants,
5
- 'ethereumSlotDuration' | 'l1GenesisTime' | 'slotDuration'
5
+ 'ethereumSlotDuration' | 'l1GenesisTime' | 'slotDuration' | 'rollupManaLimit'
6
6
  >;