@aztec/sequencer-client 0.0.1-commit.c2595eba → 0.0.1-commit.c2eed6949
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.
- package/dest/client/sequencer-client.d.ts +15 -7
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +60 -26
- package/dest/config.d.ts +26 -7
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +47 -28
- package/dest/global_variable_builder/global_builder.d.ts +14 -10
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +22 -21
- package/dest/global_variable_builder/index.d.ts +2 -2
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- package/dest/publisher/config.d.ts +47 -17
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +121 -42
- package/dest/publisher/index.d.ts +2 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +59 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/index.js +2 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +11 -3
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +27 -2
- package/dest/publisher/sequencer-publisher.d.ts +33 -10
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +371 -57
- package/dest/sequencer/checkpoint_proposal_job.d.ts +39 -10
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +287 -167
- package/dest/sequencer/events.d.ts +2 -1
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/metrics.d.ts +21 -5
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +97 -15
- package/dest/sequencer/sequencer.d.ts +30 -15
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +95 -82
- package/dest/sequencer/timetable.d.ts +4 -6
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +7 -11
- package/dest/sequencer/types.d.ts +2 -2
- package/dest/sequencer/types.d.ts.map +1 -1
- package/dest/test/index.d.ts +3 -5
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +12 -12
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +45 -36
- package/dest/test/utils.d.ts +3 -3
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +5 -4
- package/package.json +27 -28
- package/src/client/sequencer-client.ts +76 -23
- package/src/config.ts +65 -38
- package/src/global_variable_builder/global_builder.ts +23 -24
- package/src/global_variable_builder/index.ts +1 -1
- package/src/publisher/config.ts +153 -43
- package/src/publisher/index.ts +3 -0
- package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
- package/src/publisher/l1_tx_failed_store/index.ts +3 -0
- package/src/publisher/sequencer-publisher-factory.ts +38 -6
- package/src/publisher/sequencer-publisher.ts +371 -70
- package/src/sequencer/checkpoint_proposal_job.ts +392 -193
- package/src/sequencer/events.ts +1 -1
- package/src/sequencer/metrics.ts +106 -18
- package/src/sequencer/sequencer.ts +131 -94
- package/src/sequencer/timetable.ts +13 -12
- package/src/sequencer/types.ts +1 -1
- package/src/test/index.ts +2 -4
- package/src/test/mock_checkpoint_builder.ts +65 -53
- package/src/test/utils.ts +5 -2
|
@@ -380,7 +380,7 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
380
380
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
381
381
|
import { createLogger } from '@aztec/foundation/log';
|
|
382
382
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
383
|
-
import {
|
|
383
|
+
import { getSlotStartBuildTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
384
384
|
import { SequencerConfigSchema } from '@aztec/stdlib/interfaces/server';
|
|
385
385
|
import { pickFromSchema } from '@aztec/stdlib/schemas';
|
|
386
386
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
@@ -450,17 +450,11 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
450
450
|
state;
|
|
451
451
|
metrics;
|
|
452
452
|
/** The last slot for which we attempted to perform our voting duties with degraded block production */ lastSlotForFallbackVote;
|
|
453
|
+
/** The last slot for which we logged "no committee" warning, to avoid spam */ lastSlotForNoCommitteeWarning;
|
|
453
454
|
/** The last slot for which we triggered a checkpoint proposal job, to prevent duplicate attempts. */ lastSlotForCheckpointProposalJob;
|
|
454
455
|
/** Last successful checkpoint proposed */ lastCheckpointProposed;
|
|
455
456
|
/** The last epoch for which we logged strategy comparison in fisherman mode. */ lastEpochForStrategyComparison;
|
|
456
457
|
/** The maximum number of seconds that the sequencer can be into a slot to transition to a particular state. */ timetable;
|
|
457
|
-
// This shouldn't be here as this gets re-created each time we build/propose a block.
|
|
458
|
-
// But we have a number of tests that abuse/rely on this class having a permanent publisher.
|
|
459
|
-
// As long as those tests only configure a single publisher they will continue to work.
|
|
460
|
-
// This will get re-assigned every time the sequencer goes to build a new block to a publisher that is valid
|
|
461
|
-
// for the block proposer.
|
|
462
|
-
// TODO(palla/mbps): Remove this field and fix tests
|
|
463
|
-
publisher;
|
|
464
458
|
/** Config for the sequencer */ config;
|
|
465
459
|
constructor(publisherFactory, validatorClient, globalsBuilder, p2pClient, worldState, slasherClient, l2BlockSource, l1ToL2MessageSource, checkpointsBuilder, l1Constants, dateProvider, epochCache, rollupContract, config, telemetry = getTelemetryClient(), log = createLogger('sequencer')){
|
|
466
460
|
super(), this.publisherFactory = publisherFactory, this.validatorClient = validatorClient, this.globalsBuilder = globalsBuilder, this.p2pClient = p2pClient, this.worldState = worldState, this.slasherClient = slasherClient, this.l2BlockSource = l2BlockSource, this.l1ToL2MessageSource = l1ToL2MessageSource, this.checkpointsBuilder = checkpointsBuilder, this.l1Constants = l1Constants, this.dateProvider = dateProvider, this.epochCache = epochCache, this.rollupContract = rollupContract, this.telemetry = telemetry, this.log = log, this.state = (_initProto(this), SequencerState.STOPPED), this.config = DefaultSequencerConfig;
|
|
@@ -473,7 +467,7 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
473
467
|
}
|
|
474
468
|
/** Updates sequencer config by the defined values and updates the timetable */ updateConfig(config) {
|
|
475
469
|
const filteredConfig = pickFromSchema(config, SequencerConfigSchema);
|
|
476
|
-
this.log.info(`Updated sequencer config`, omit(filteredConfig, '
|
|
470
|
+
this.log.info(`Updated sequencer config`, omit(filteredConfig, 'txPublicSetupAllowListExtend'));
|
|
477
471
|
this.config = merge(this.config, filteredConfig);
|
|
478
472
|
this.timetable = new SequencerTimetable({
|
|
479
473
|
ethereumSlotDuration: this.l1Constants.ethereumSlotDuration,
|
|
@@ -484,9 +478,8 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
484
478
|
enforce: this.config.enforceTimeTable
|
|
485
479
|
}, this.metrics, this.log);
|
|
486
480
|
}
|
|
487
|
-
/** Initializes the sequencer (precomputes tables
|
|
481
|
+
/** Initializes the sequencer (precomputes tables). Takes about 3s. */ init() {
|
|
488
482
|
getKzg();
|
|
489
|
-
this.publisher = (await this.publisherFactory.create(undefined)).publisher;
|
|
490
483
|
}
|
|
491
484
|
/** Starts the sequencer and moves to IDLE state. */ start() {
|
|
492
485
|
this.runningPromise = new RunningPromise(this.safeWork.bind(this), this.log, this.config.sequencerPollingIntervalMS);
|
|
@@ -501,7 +494,7 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
501
494
|
this.setState(SequencerState.STOPPING, undefined, {
|
|
502
495
|
force: true
|
|
503
496
|
});
|
|
504
|
-
this.
|
|
497
|
+
await this.publisherFactory.stopAll();
|
|
505
498
|
await this.runningPromise?.stop();
|
|
506
499
|
this.setState(SequencerState.STOPPED, undefined, {
|
|
507
500
|
force: true
|
|
@@ -516,7 +509,6 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
516
509
|
error: err
|
|
517
510
|
});
|
|
518
511
|
if (err instanceof SequencerTooSlowError) {
|
|
519
|
-
// TODO(palla/mbps): Add missing states
|
|
520
512
|
// Log as warn only if we had to abort halfway through the block proposal
|
|
521
513
|
const logLvl = [
|
|
522
514
|
SequencerState.INITIALIZING_CHECKPOINT,
|
|
@@ -547,9 +539,10 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
547
539
|
* - Submit checkpoint
|
|
548
540
|
*/ async work() {
|
|
549
541
|
this.setState(SequencerState.SYNCHRONIZING, undefined);
|
|
550
|
-
const { slot, ts,
|
|
542
|
+
const { slot, ts, nowSeconds, epoch } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
543
|
+
const { slot: targetSlot, epoch: targetEpoch } = this.epochCache.getTargetEpochAndSlotInNextL1Slot();
|
|
551
544
|
// Check if we are synced and it's our slot, grab a publisher, check previous block invalidation, etc
|
|
552
|
-
const checkpointProposalJob = await this.prepareCheckpointProposal(epoch,
|
|
545
|
+
const checkpointProposalJob = await this.prepareCheckpointProposal(slot, targetSlot, epoch, targetEpoch, ts, nowSeconds);
|
|
553
546
|
if (!checkpointProposalJob) {
|
|
554
547
|
return;
|
|
555
548
|
}
|
|
@@ -559,10 +552,10 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
559
552
|
if (checkpoint) {
|
|
560
553
|
this.lastCheckpointProposed = checkpoint;
|
|
561
554
|
}
|
|
562
|
-
// Log fee strategy comparison if on fisherman
|
|
563
|
-
if (this.config.fishermanMode && (this.lastEpochForStrategyComparison === undefined ||
|
|
564
|
-
this.logStrategyComparison(
|
|
565
|
-
this.lastEpochForStrategyComparison =
|
|
555
|
+
// Log fee strategy comparison if on fisherman (uses target epoch since we mirror the proposer's perspective)
|
|
556
|
+
if (this.config.fishermanMode && (this.lastEpochForStrategyComparison === undefined || targetEpoch > this.lastEpochForStrategyComparison)) {
|
|
557
|
+
this.logStrategyComparison(targetEpoch, checkpointProposalJob.getPublisher());
|
|
558
|
+
this.lastEpochForStrategyComparison = targetEpoch;
|
|
566
559
|
}
|
|
567
560
|
return checkpoint;
|
|
568
561
|
}
|
|
@@ -570,17 +563,17 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
570
563
|
* Prepares the checkpoint proposal by performing all necessary checks and setup.
|
|
571
564
|
* This is the initial step in the main loop.
|
|
572
565
|
* @returns CheckpointProposalJob if successful, undefined if we are not yet synced or are not the proposer.
|
|
573
|
-
*/ async prepareCheckpointProposal(epoch,
|
|
574
|
-
// Check we have not already processed this slot (cheapest check)
|
|
566
|
+
*/ async prepareCheckpointProposal(slot, targetSlot, epoch, targetEpoch, ts, nowSeconds) {
|
|
567
|
+
// Check we have not already processed this target slot (cheapest check)
|
|
575
568
|
// We only check this if enforce timetable is set, since we want to keep processing the same slot if we are not
|
|
576
569
|
// running against actual time (eg when we use sandbox-style automining)
|
|
577
|
-
if (this.lastSlotForCheckpointProposalJob && this.lastSlotForCheckpointProposalJob >=
|
|
578
|
-
this.log.trace(`
|
|
570
|
+
if (this.lastSlotForCheckpointProposalJob && this.lastSlotForCheckpointProposalJob >= targetSlot && this.config.enforceTimeTable) {
|
|
571
|
+
this.log.trace(`Target slot ${targetSlot} has already been processed`);
|
|
579
572
|
return undefined;
|
|
580
573
|
}
|
|
581
|
-
// But if we have already proposed for this slot,
|
|
582
|
-
if (this.lastCheckpointProposed && this.lastCheckpointProposed.header.slotNumber >=
|
|
583
|
-
this.log.trace(`Slot ${
|
|
574
|
+
// But if we have already proposed for this slot, then we definitely have to skip it, automining or not
|
|
575
|
+
if (this.lastCheckpointProposed && this.lastCheckpointProposed.header.slotNumber >= targetSlot) {
|
|
576
|
+
this.log.trace(`Slot ${targetSlot} has already been published as checkpoint ${this.lastCheckpointProposed.number}`);
|
|
584
577
|
return undefined;
|
|
585
578
|
}
|
|
586
579
|
// Check all components are synced to latest as seen by the archiver (queries all subsystems)
|
|
@@ -591,16 +584,18 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
591
584
|
if (!syncedTo) {
|
|
592
585
|
await this.tryVoteWhenSyncFails({
|
|
593
586
|
slot,
|
|
587
|
+
targetSlot,
|
|
594
588
|
ts
|
|
595
589
|
});
|
|
596
590
|
return undefined;
|
|
597
591
|
}
|
|
598
|
-
// If escape hatch is open for
|
|
592
|
+
// If escape hatch is open for the target epoch, do not start checkpoint proposal work and do not attempt invalidations.
|
|
599
593
|
// Still perform governance/slashing voting (as proposer) once per slot.
|
|
600
|
-
|
|
594
|
+
// When pipelining, we check the target epoch (slot+1's epoch) since that's the epoch we're building for.
|
|
595
|
+
const isEscapeHatchOpen = await this.epochCache.isEscapeHatchOpen(targetEpoch);
|
|
601
596
|
if (isEscapeHatchOpen) {
|
|
602
597
|
this.setState(SequencerState.PROPOSER_CHECK, slot);
|
|
603
|
-
const [canPropose, proposer] = await this.checkCanPropose(
|
|
598
|
+
const [canPropose, proposer] = await this.checkCanPropose(targetSlot);
|
|
604
599
|
if (canPropose) {
|
|
605
600
|
await this.tryVoteWhenEscapeHatchOpen({
|
|
606
601
|
slot,
|
|
@@ -618,29 +613,29 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
618
613
|
// Next checkpoint follows from the last synced one
|
|
619
614
|
const checkpointNumber = CheckpointNumber(syncedTo.checkpointNumber + 1);
|
|
620
615
|
const logCtx = {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
syncedToL2Slot: getSlotAtTimestamp(syncedTo.l1Timestamp, this.l1Constants),
|
|
616
|
+
nowSeconds,
|
|
617
|
+
syncedToL2Slot: syncedTo.syncedL2Slot,
|
|
624
618
|
slot,
|
|
619
|
+
targetSlot,
|
|
625
620
|
slotTs: ts,
|
|
626
621
|
checkpointNumber,
|
|
627
622
|
isPendingChainValid: pick(syncedTo.pendingChainValidationStatus, 'valid', 'reason', 'invalidIndex')
|
|
628
623
|
};
|
|
629
|
-
// Check that we are a proposer for the
|
|
624
|
+
// Check that we are a proposer for the target slot.
|
|
630
625
|
this.setState(SequencerState.PROPOSER_CHECK, slot);
|
|
631
|
-
const [canPropose, proposer] = await this.checkCanPropose(
|
|
626
|
+
const [canPropose, proposer] = await this.checkCanPropose(targetSlot);
|
|
632
627
|
// If we are not a proposer check if we should invalidate an invalid checkpoint, and bail
|
|
633
628
|
if (!canPropose) {
|
|
634
629
|
await this.considerInvalidatingCheckpoint(syncedTo, slot);
|
|
635
630
|
return undefined;
|
|
636
631
|
}
|
|
637
|
-
// Check that the slot is not taken by a block already (should never happen, since only us can propose for this slot)
|
|
638
|
-
if (syncedTo.
|
|
639
|
-
this.log.warn(`Cannot propose block at
|
|
632
|
+
// Check that the target slot is not taken by a block already (should never happen, since only us can propose for this slot)
|
|
633
|
+
if (syncedTo.blockData && syncedTo.blockData.header.getSlot() >= targetSlot) {
|
|
634
|
+
this.log.warn(`Cannot propose block at target slot ${targetSlot} since that slot was taken by block ${syncedTo.blockNumber}`, {
|
|
640
635
|
...logCtx,
|
|
641
|
-
block: syncedTo.
|
|
636
|
+
block: syncedTo.blockData.header.toInspect()
|
|
642
637
|
});
|
|
643
|
-
this.metrics.
|
|
638
|
+
this.metrics.recordCheckpointPrecheckFailed('slot_already_taken');
|
|
644
639
|
return undefined;
|
|
645
640
|
}
|
|
646
641
|
// We now need to get ourselves a publisher.
|
|
@@ -650,7 +645,6 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
650
645
|
const proposerForPublisher = this.config.fishermanMode ? undefined : proposer;
|
|
651
646
|
const { attestorAddress, publisher } = await this.publisherFactory.create(proposerForPublisher);
|
|
652
647
|
this.log.verbose(`Created publisher at address ${publisher.getSenderAddress()} for attestor ${attestorAddress}`);
|
|
653
|
-
this.publisher = publisher;
|
|
654
648
|
// In fisherman mode, set the actual proposer's address for simulations
|
|
655
649
|
if (this.config.fishermanMode && proposer) {
|
|
656
650
|
publisher.setProposerAddressForSimulation(proposer);
|
|
@@ -658,29 +652,31 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
658
652
|
}
|
|
659
653
|
// Prepare invalidation request if the pending chain is invalid (returns undefined if no need)
|
|
660
654
|
const invalidateCheckpoint = await publisher.simulateInvalidateCheckpoint(syncedTo.pendingChainValidationStatus);
|
|
661
|
-
// Check with the rollup contract if we can indeed propose at the
|
|
655
|
+
// Check with the rollup contract if we can indeed propose at the target slot. This check should not fail
|
|
662
656
|
// if all the previous checks are good, but we do it just in case.
|
|
663
|
-
const canProposeCheck = await publisher.
|
|
657
|
+
const canProposeCheck = await publisher.canProposeAt(syncedTo.archive, proposer ?? EthAddress.ZERO, {
|
|
658
|
+
...invalidateCheckpoint
|
|
659
|
+
});
|
|
664
660
|
if (canProposeCheck === undefined) {
|
|
665
661
|
this.log.warn(`Cannot propose checkpoint ${checkpointNumber} at slot ${slot} due to failed rollup contract check`, logCtx);
|
|
666
662
|
this.emit('proposer-rollup-check-failed', {
|
|
667
663
|
reason: 'Rollup contract check failed',
|
|
668
664
|
slot
|
|
669
665
|
});
|
|
670
|
-
this.metrics.
|
|
666
|
+
this.metrics.recordCheckpointPrecheckFailed('rollup_contract_check_failed');
|
|
671
667
|
return undefined;
|
|
672
668
|
}
|
|
673
|
-
if (canProposeCheck.slot !==
|
|
674
|
-
this.log.warn(`Cannot propose block due to slot mismatch with rollup contract (this can be caused by a clock out of sync). Expected slot ${
|
|
669
|
+
if (canProposeCheck.slot !== targetSlot) {
|
|
670
|
+
this.log.warn(`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}.`, {
|
|
675
671
|
...logCtx,
|
|
676
672
|
rollup: canProposeCheck,
|
|
677
|
-
expectedSlot:
|
|
673
|
+
expectedSlot: targetSlot
|
|
678
674
|
});
|
|
679
675
|
this.emit('proposer-rollup-check-failed', {
|
|
680
676
|
reason: 'Slot mismatch',
|
|
681
677
|
slot
|
|
682
678
|
});
|
|
683
|
-
this.metrics.
|
|
679
|
+
this.metrics.recordCheckpointPrecheckFailed('slot_mismatch');
|
|
684
680
|
return undefined;
|
|
685
681
|
}
|
|
686
682
|
if (canProposeCheck.checkpointNumber !== checkpointNumber) {
|
|
@@ -693,19 +689,26 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
693
689
|
reason: 'Block mismatch',
|
|
694
690
|
slot
|
|
695
691
|
});
|
|
696
|
-
this.metrics.
|
|
692
|
+
this.metrics.recordCheckpointPrecheckFailed('block_number_mismatch');
|
|
697
693
|
return undefined;
|
|
698
694
|
}
|
|
699
|
-
this.lastSlotForCheckpointProposalJob =
|
|
700
|
-
this.
|
|
695
|
+
this.lastSlotForCheckpointProposalJob = targetSlot;
|
|
696
|
+
await this.p2pClient.prepareForSlot(targetSlot);
|
|
697
|
+
this.log.info(`Preparing checkpoint proposal ${checkpointNumber} for target slot ${targetSlot} during wall-clock slot ${slot}`, {
|
|
701
698
|
...logCtx,
|
|
702
|
-
proposer
|
|
699
|
+
proposer,
|
|
700
|
+
pipeliningEnabled: this.epochCache.isProposerPipeliningEnabled()
|
|
703
701
|
});
|
|
704
702
|
// Create and return the checkpoint proposal job
|
|
705
|
-
return this.createCheckpointProposalJob(epoch,
|
|
703
|
+
return this.createCheckpointProposalJob(slot, targetSlot, epoch, targetEpoch, checkpointNumber, syncedTo.blockNumber, proposer, publisher, attestorAddress, invalidateCheckpoint);
|
|
706
704
|
}
|
|
707
|
-
createCheckpointProposalJob(epoch,
|
|
708
|
-
return new CheckpointProposalJob(epoch,
|
|
705
|
+
createCheckpointProposalJob(slot, targetSlot, epoch, targetEpoch, checkpointNumber, syncedToBlockNumber, proposer, publisher, attestorAddress, invalidateCheckpoint) {
|
|
706
|
+
return new CheckpointProposalJob(slot, targetSlot, epoch, targetEpoch, checkpointNumber, syncedToBlockNumber, proposer, publisher, attestorAddress, invalidateCheckpoint, this.validatorClient, this.globalsBuilder, this.p2pClient, this.worldState, this.l1ToL2MessageSource, this.l2BlockSource, this.checkpointsBuilder, this.l2BlockSource, this.l1Constants, this.config, this.timetable, this.slasherClient, this.epochCache, this.dateProvider, this.metrics, this, this.setState.bind(this), this.tracer, this.log.getBindings());
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* Returns the current sequencer state.
|
|
710
|
+
*/ getState() {
|
|
711
|
+
return this.state;
|
|
709
712
|
}
|
|
710
713
|
/**
|
|
711
714
|
* Internal helper for setting the sequencer state and checks if we have enough time left in the slot to transition to the new state.
|
|
@@ -747,16 +750,15 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
747
750
|
* Returns whether all dependencies have caught up.
|
|
748
751
|
* We don't check against the previous block submitted since it may have been reorg'd out.
|
|
749
752
|
*/ async checkSync(args) {
|
|
750
|
-
// Check that the archiver
|
|
751
|
-
//
|
|
752
|
-
//
|
|
753
|
-
const
|
|
754
|
-
const { slot
|
|
755
|
-
if (
|
|
753
|
+
// Check that the archiver has fully synced the L2 slot before the one we want to propose in.
|
|
754
|
+
// The archiver reports sync progress via L1 block timestamps and synced checkpoint slots.
|
|
755
|
+
// See getSyncedL2SlotNumber for how missed L1 blocks are handled.
|
|
756
|
+
const syncedL2Slot = await this.l2BlockSource.getSyncedL2SlotNumber();
|
|
757
|
+
const { slot } = args;
|
|
758
|
+
if (syncedL2Slot === undefined || syncedL2Slot + 1 < slot) {
|
|
756
759
|
this.log.debug(`Cannot propose block at next L2 slot ${slot} due to pending sync from L1`, {
|
|
757
760
|
slot,
|
|
758
|
-
|
|
759
|
-
l1Timestamp
|
|
761
|
+
syncedL2Slot
|
|
760
762
|
});
|
|
761
763
|
return undefined;
|
|
762
764
|
}
|
|
@@ -792,41 +794,44 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
792
794
|
checkpointNumber: CheckpointNumber.ZERO,
|
|
793
795
|
blockNumber: BlockNumber.ZERO,
|
|
794
796
|
archive,
|
|
795
|
-
|
|
797
|
+
syncedL2Slot,
|
|
796
798
|
pendingChainValidationStatus
|
|
797
799
|
};
|
|
798
800
|
}
|
|
799
|
-
const
|
|
800
|
-
if (!
|
|
801
|
+
const blockData = await this.l2BlockSource.getBlockData(blockNumber);
|
|
802
|
+
if (!blockData) {
|
|
801
803
|
// this shouldn't really happen because a moment ago we checked that all components were in sync
|
|
802
|
-
this.log.error(`Failed to get L2 block ${blockNumber} from the archiver with all components in sync`);
|
|
804
|
+
this.log.error(`Failed to get L2 block data ${blockNumber} from the archiver with all components in sync`);
|
|
803
805
|
return undefined;
|
|
804
806
|
}
|
|
805
807
|
return {
|
|
806
|
-
|
|
807
|
-
blockNumber:
|
|
808
|
-
checkpointNumber:
|
|
809
|
-
archive:
|
|
810
|
-
|
|
808
|
+
blockData,
|
|
809
|
+
blockNumber: blockData.header.getBlockNumber(),
|
|
810
|
+
checkpointNumber: blockData.checkpointNumber,
|
|
811
|
+
archive: blockData.archive.root,
|
|
812
|
+
syncedL2Slot,
|
|
811
813
|
pendingChainValidationStatus
|
|
812
814
|
};
|
|
813
815
|
}
|
|
814
816
|
/**
|
|
815
817
|
* Checks if we are the proposer for the next slot.
|
|
816
818
|
* @returns True if we can propose, and the proposer address (undefined if anyone can propose)
|
|
817
|
-
*/ async checkCanPropose(
|
|
819
|
+
*/ async checkCanPropose(targetSlot) {
|
|
818
820
|
let proposer;
|
|
819
821
|
try {
|
|
820
|
-
proposer = await this.epochCache.getProposerAttesterAddressInSlot(
|
|
822
|
+
proposer = await this.epochCache.getProposerAttesterAddressInSlot(targetSlot);
|
|
821
823
|
} catch (e) {
|
|
822
824
|
if (e instanceof NoCommitteeError) {
|
|
823
|
-
this.
|
|
825
|
+
if (this.lastSlotForNoCommitteeWarning !== targetSlot) {
|
|
826
|
+
this.lastSlotForNoCommitteeWarning = targetSlot;
|
|
827
|
+
this.log.warn(`Cannot propose at target slot ${targetSlot} since the committee does not exist on L1`);
|
|
828
|
+
}
|
|
824
829
|
return [
|
|
825
830
|
false,
|
|
826
831
|
undefined
|
|
827
832
|
];
|
|
828
833
|
}
|
|
829
|
-
this.log.error(`Error getting proposer for slot ${
|
|
834
|
+
this.log.error(`Error getting proposer for target slot ${targetSlot}`, e);
|
|
830
835
|
return [
|
|
831
836
|
false,
|
|
832
837
|
undefined
|
|
@@ -849,7 +854,8 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
849
854
|
const validatorAddresses = this.validatorClient.getValidatorAddresses();
|
|
850
855
|
const weAreProposer = validatorAddresses.some((addr)=>addr.equals(proposer));
|
|
851
856
|
if (!weAreProposer) {
|
|
852
|
-
this.log.debug(`Cannot propose at slot ${
|
|
857
|
+
this.log.debug(`Cannot propose at target slot ${targetSlot} since we are not a proposer`, {
|
|
858
|
+
targetSlot,
|
|
853
859
|
validatorAddresses,
|
|
854
860
|
proposer
|
|
855
861
|
});
|
|
@@ -858,6 +864,10 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
858
864
|
proposer
|
|
859
865
|
];
|
|
860
866
|
}
|
|
867
|
+
this.log.debug(`We are the proposer for target slot ${targetSlot}`, {
|
|
868
|
+
targetSlot,
|
|
869
|
+
proposer
|
|
870
|
+
});
|
|
861
871
|
return [
|
|
862
872
|
true,
|
|
863
873
|
proposer
|
|
@@ -867,7 +877,7 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
867
877
|
* Tries to vote on slashing actions and governance when the sync check fails but we're past the max time for initializing a proposal.
|
|
868
878
|
* This allows the sequencer to participate in governance/slashing votes even when it cannot build blocks.
|
|
869
879
|
*/ async tryVoteWhenSyncFails(args) {
|
|
870
|
-
const { slot } = args;
|
|
880
|
+
const { slot, targetSlot } = args;
|
|
871
881
|
// Prevent duplicate attempts in the same slot
|
|
872
882
|
if (this.lastSlotForFallbackVote === slot) {
|
|
873
883
|
this.log.trace(`Already attempted to vote in slot ${slot} (skipping)`);
|
|
@@ -890,7 +900,7 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
890
900
|
maxAllowedTime
|
|
891
901
|
});
|
|
892
902
|
// Check if we're a proposer or proposal is open
|
|
893
|
-
const [canPropose, proposer] = await this.checkCanPropose(
|
|
903
|
+
const [canPropose, proposer] = await this.checkCanPropose(targetSlot);
|
|
894
904
|
if (!canPropose) {
|
|
895
905
|
this.log.trace(`Cannot vote in slot ${slot} since we are not a proposer`, {
|
|
896
906
|
slot,
|
|
@@ -906,8 +916,8 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
906
916
|
attestorAddress,
|
|
907
917
|
slot
|
|
908
918
|
});
|
|
909
|
-
// Enqueue governance and slashing votes
|
|
910
|
-
const voter = new CheckpointVoter(
|
|
919
|
+
// Enqueue governance and slashing votes (voter uses the target slot for L1 submission)
|
|
920
|
+
const voter = new CheckpointVoter(targetSlot, publisher, attestorAddress, this.validatorClient, this.slasherClient, this.l1Constants, this.config, this.metrics, this.log);
|
|
911
921
|
const votesPromises = voter.enqueueVotes();
|
|
912
922
|
const votes = await Promise.all(votesPromises);
|
|
913
923
|
if (votes.every((p)=>!p)) {
|
|
@@ -954,7 +964,7 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
954
964
|
* have the proposer try to invalidate, but if they fail, the sequencers in the committee are expected to try,
|
|
955
965
|
* and if they fail, any sequencer will try as well.
|
|
956
966
|
*/ async considerInvalidatingCheckpoint(syncedTo, currentSlot) {
|
|
957
|
-
const { pendingChainValidationStatus,
|
|
967
|
+
const { pendingChainValidationStatus, syncedL2Slot } = syncedTo;
|
|
958
968
|
if (pendingChainValidationStatus.valid) {
|
|
959
969
|
return;
|
|
960
970
|
}
|
|
@@ -965,7 +975,7 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
965
975
|
const { secondsBeforeInvalidatingBlockAsCommitteeMember, secondsBeforeInvalidatingBlockAsNonCommitteeMember } = this.config;
|
|
966
976
|
const logData = {
|
|
967
977
|
invalidL1Timestamp: invalidCheckpointTimestamp,
|
|
968
|
-
|
|
978
|
+
syncedL2Slot,
|
|
969
979
|
invalidCheckpoint: pendingChainValidationStatus.checkpoint,
|
|
970
980
|
secondsBeforeInvalidatingBlockAsCommitteeMember,
|
|
971
981
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember,
|
|
@@ -1056,6 +1066,9 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
1056
1066
|
getValidatorAddresses() {
|
|
1057
1067
|
return this.validatorClient?.getValidatorAddresses();
|
|
1058
1068
|
}
|
|
1069
|
+
/** Updates the publisher factory's node keystore adapter after a keystore reload. */ updatePublisherNodeKeyStore(adapter) {
|
|
1070
|
+
this.publisherFactory.updateNodeKeyStore(adapter);
|
|
1071
|
+
}
|
|
1059
1072
|
getConfig() {
|
|
1060
1073
|
return this.config;
|
|
1061
1074
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
1
2
|
import type { SequencerMetrics } from './metrics.js';
|
|
2
3
|
import { SequencerState } from './utils.js';
|
|
3
|
-
export declare const MIN_EXECUTION_TIME = 2;
|
|
4
|
-
export declare const CHECKPOINT_INITIALIZATION_TIME = 1;
|
|
5
|
-
export declare const CHECKPOINT_ASSEMBLE_TIME = 1;
|
|
6
4
|
export declare class SequencerTimetable {
|
|
7
5
|
private readonly metrics?;
|
|
8
|
-
private readonly log
|
|
6
|
+
private readonly log?;
|
|
9
7
|
/**
|
|
10
8
|
* How late into the slot can we be to start working. Computed as the total time needed for assembling and publishing a block,
|
|
11
9
|
* assuming an execution time equal to `minExecutionTime`, subtracted from the slot duration. This means that, if the proposer
|
|
@@ -59,7 +57,7 @@ export declare class SequencerTimetable {
|
|
|
59
57
|
p2pPropagationTime?: number;
|
|
60
58
|
blockDurationMs?: number;
|
|
61
59
|
enforce: boolean;
|
|
62
|
-
}, metrics?: SequencerMetrics | undefined, log?:
|
|
60
|
+
}, metrics?: SequencerMetrics | undefined, log?: Logger | undefined);
|
|
63
61
|
getMaxAllowedTime(state: Extract<SequencerState, SequencerState.STOPPED | SequencerState.IDLE | SequencerState.SYNCHRONIZING>): undefined;
|
|
64
62
|
getMaxAllowedTime(state: Exclude<SequencerState, SequencerState.STOPPED | SequencerState.IDLE | SequencerState.SYNCHRONIZING>): number;
|
|
65
63
|
getMaxAllowedTime(state: SequencerState): number | undefined;
|
|
@@ -87,4 +85,4 @@ export declare class SequencerTimetable {
|
|
|
87
85
|
isLastBlock: boolean;
|
|
88
86
|
};
|
|
89
87
|
}
|
|
90
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
88
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGltZXRhYmxlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2VxdWVuY2VyL3RpbWV0YWJsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQVNwRCxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLGNBQWMsQ0FBQztBQUNyRCxPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0sWUFBWSxDQUFDO0FBRTVDLHFCQUFhLGtCQUFrQjtJQXFFM0IsT0FBTyxDQUFDLFFBQVEsQ0FBQyxPQUFPLENBQUM7SUFDekIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxHQUFHLENBQUM7SUFyRXZCOzs7O09BSUc7SUFDSCxTQUFnQixrQkFBa0IsRUFBRSxNQUFNLENBQUM7SUFFM0M7Ozs7T0FJRztJQUNILFNBQWdCLG9CQUFvQixFQUFFLE1BQU0sQ0FBQztJQUU3Qzs7Ozs7T0FLRztJQUNILFNBQWdCLDBCQUEwQixFQUFFLE1BQU0sQ0FBQztJQUVuRDs7OztPQUlHO0lBQ0gsU0FBZ0IsZ0JBQWdCLEVBQUUsTUFBTSxDQUFDO0lBRXpDOzs7T0FHRztJQUNILFNBQWdCLGdCQUFnQixFQUFFLE1BQU0sQ0FBc0I7SUFFOUQsdURBQXVEO0lBQ3ZELFNBQWdCLDRCQUE0QixFQUFFLE1BQU0sQ0FBa0M7SUFFdEYsbUdBQW1HO0lBQ25HLFNBQWdCLGtCQUFrQixFQUFFLE1BQU0sQ0FBQztJQUUzQyxtRkFBbUY7SUFDbkYsU0FBZ0Isc0JBQXNCLEVBQUUsTUFBTSxDQUE0QjtJQUUxRSx3Q0FBd0M7SUFDeEMsU0FBZ0Isb0JBQW9CLEVBQUUsTUFBTSxDQUFDO0lBRTdDLGtGQUFrRjtJQUNsRixTQUFnQixpQkFBaUIsRUFBRSxNQUFNLENBQUM7SUFFMUMsNERBQTREO0lBQzVELFNBQWdCLE9BQU8sRUFBRSxPQUFPLENBQUM7SUFFakMsb0dBQW9HO0lBQ3BHLFNBQWdCLGFBQWEsRUFBRSxNQUFNLEdBQUcsU0FBUyxDQUFDO0lBRWxELDRFQUE0RTtJQUM1RSxTQUFnQixpQkFBaUIsRUFBRSxNQUFNLENBQUM7SUFFMUMsWUFDRSxJQUFJLEVBQUU7UUFDSixvQkFBb0IsRUFBRSxNQUFNLENBQUM7UUFDN0IsaUJBQWlCLEVBQUUsTUFBTSxDQUFDO1FBQzFCLGdCQUFnQixFQUFFLE1BQU0sQ0FBQztRQUN6QixrQkFBa0IsQ0FBQyxFQUFFLE1BQU0sQ0FBQztRQUM1QixlQUFlLENBQUMsRUFBRSxNQUFNLENBQUM7UUFDekIsT0FBTyxFQUFFLE9BQU8sQ0FBQztLQUNsQixFQUNnQixPQUFPLENBQUMsOEJBQWtCLEVBQzFCLEdBQUcsQ0FBQyxvQkFBUSxFQTJFOUI7SUFFTSxpQkFBaUIsQ0FDdEIsS0FBSyxFQUFFLE9BQU8sQ0FBQyxjQUFjLEVBQUUsY0FBYyxDQUFDLE9BQU8sR0FBRyxjQUFjLENBQUMsSUFBSSxHQUFHLGNBQWMsQ0FBQyxhQUFhLENBQUMsR0FDMUcsU0FBUyxDQUFDO0lBQ04saUJBQWlCLENBQ3RCLEtBQUssRUFBRSxPQUFPLENBQUMsY0FBYyxFQUFFLGNBQWMsQ0FBQyxPQUFPLEdBQUcsY0FBYyxDQUFDLElBQUksR0FBRyxjQUFjLENBQUMsYUFBYSxDQUFDLEdBQzFHLE1BQU0sQ0FBQztJQUNILGlCQUFpQixDQUFDLEtBQUssRUFBRSxjQUFjLEdBQUcsTUFBTSxHQUFHLFNBQVMsQ0FBQztJQTJCN0QsY0FBYyxDQUFDLFFBQVEsRUFBRSxjQUFjLEVBQUUsZUFBZSxFQUFFLE1BQU0sUUFpQnRFO0lBRUQ7Ozs7Ozs7O09BUUc7SUFDSSxpQkFBaUIsQ0FDdEIsZUFBZSxFQUFFLE1BQU0sR0FFckI7UUFBRSxRQUFRLEVBQUUsSUFBSSxDQUFDO1FBQUMsUUFBUSxFQUFFLFNBQVMsQ0FBQztRQUFDLFdBQVcsRUFBRSxJQUFJLENBQUE7S0FBRSxHQUMxRDtRQUFFLFFBQVEsRUFBRSxLQUFLLENBQUM7UUFBQyxRQUFRLEVBQUUsU0FBUyxDQUFDO1FBQUMsV0FBVyxFQUFFLEtBQUssQ0FBQTtLQUFFLEdBQzVEO1FBQUUsUUFBUSxFQUFFLE9BQU8sQ0FBQztRQUFDLFFBQVEsRUFBRSxNQUFNLENBQUM7UUFBQyxXQUFXLEVBQUUsT0FBTyxDQUFBO0tBQUUsQ0F3RGhFO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timetable.d.ts","sourceRoot":"","sources":["../../src/sequencer/timetable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"timetable.d.ts","sourceRoot":"","sources":["../../src/sequencer/timetable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AASpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,qBAAa,kBAAkB;IAqE3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;IArEvB;;;;OAIG;IACH,SAAgB,kBAAkB,EAAE,MAAM,CAAC;IAE3C;;;;OAIG;IACH,SAAgB,oBAAoB,EAAE,MAAM,CAAC;IAE7C;;;;;OAKG;IACH,SAAgB,0BAA0B,EAAE,MAAM,CAAC;IAEnD;;;;OAIG;IACH,SAAgB,gBAAgB,EAAE,MAAM,CAAC;IAEzC;;;OAGG;IACH,SAAgB,gBAAgB,EAAE,MAAM,CAAsB;IAE9D,uDAAuD;IACvD,SAAgB,4BAA4B,EAAE,MAAM,CAAkC;IAEtF,mGAAmG;IACnG,SAAgB,kBAAkB,EAAE,MAAM,CAAC;IAE3C,mFAAmF;IACnF,SAAgB,sBAAsB,EAAE,MAAM,CAA4B;IAE1E,wCAAwC;IACxC,SAAgB,oBAAoB,EAAE,MAAM,CAAC;IAE7C,kFAAkF;IAClF,SAAgB,iBAAiB,EAAE,MAAM,CAAC;IAE1C,4DAA4D;IAC5D,SAAgB,OAAO,EAAE,OAAO,CAAC;IAEjC,oGAAoG;IACpG,SAAgB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAElD,4EAA4E;IAC5E,SAAgB,iBAAiB,EAAE,MAAM,CAAC;IAE1C,YACE,IAAI,EAAE;QACJ,oBAAoB,EAAE,MAAM,CAAC;QAC7B,iBAAiB,EAAE,MAAM,CAAC;QAC1B,gBAAgB,EAAE,MAAM,CAAC;QACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,OAAO,EAAE,OAAO,CAAC;KAClB,EACgB,OAAO,CAAC,8BAAkB,EAC1B,GAAG,CAAC,oBAAQ,EA2E9B;IAEM,iBAAiB,CACtB,KAAK,EAAE,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,OAAO,GAAG,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,aAAa,CAAC,GAC1G,SAAS,CAAC;IACN,iBAAiB,CACtB,KAAK,EAAE,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,OAAO,GAAG,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,aAAa,CAAC,GAC1G,MAAM,CAAC;IACH,iBAAiB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,CAAC;IA2B7D,cAAc,CAAC,QAAQ,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,QAiBtE;IAED;;;;;;;;OAQG;IACI,iBAAiB,CACtB,eAAe,EAAE,MAAM,GAErB;QAAE,QAAQ,EAAE,IAAI,CAAC;QAAC,QAAQ,EAAE,SAAS,CAAC;QAAC,WAAW,EAAE,IAAI,CAAA;KAAE,GAC1D;QAAE,QAAQ,EAAE,KAAK,CAAC;QAAC,QAAQ,EAAE,SAAS,CAAC;QAAC,WAAW,EAAE,KAAK,CAAA;KAAE,GAC5D;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,OAAO,CAAA;KAAE,CAwDhE;CACF"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DEFAULT_ATTESTATION_PROPAGATION_TIME as DEFAULT_P2P_PROPAGATION_TIME } from '../config.js';
|
|
1
|
+
import { CHECKPOINT_ASSEMBLE_TIME, CHECKPOINT_INITIALIZATION_TIME, DEFAULT_P2P_PROPAGATION_TIME, MIN_EXECUTION_TIME } from '@aztec/stdlib/timetable';
|
|
3
2
|
import { SequencerTooSlowError } from './errors.js';
|
|
4
3
|
import { SequencerState } from './utils.js';
|
|
5
|
-
export const MIN_EXECUTION_TIME = 2;
|
|
6
|
-
export const CHECKPOINT_INITIALIZATION_TIME = 1;
|
|
7
|
-
export const CHECKPOINT_ASSEMBLE_TIME = 1;
|
|
8
4
|
export class SequencerTimetable {
|
|
9
5
|
metrics;
|
|
10
6
|
log;
|
|
@@ -41,7 +37,7 @@ export class SequencerTimetable {
|
|
|
41
37
|
/** Whether assertTimeLeft will throw if not enough time. */ enforce;
|
|
42
38
|
/** Duration per block when building multiple blocks per slot (undefined = single block per slot) */ blockDuration;
|
|
43
39
|
/** Maximum number of blocks that can be built in this slot configuration */ maxNumberOfBlocks;
|
|
44
|
-
constructor(opts, metrics, log
|
|
40
|
+
constructor(opts, metrics, log){
|
|
45
41
|
this.metrics = metrics;
|
|
46
42
|
this.log = log;
|
|
47
43
|
this.minExecutionTime = MIN_EXECUTION_TIME;
|
|
@@ -84,7 +80,7 @@ export class SequencerTimetable {
|
|
|
84
80
|
this.checkpointFinalizationTime;
|
|
85
81
|
const initializeDeadline = this.aztecSlotDuration - minWorkToDo;
|
|
86
82
|
this.initializeDeadline = initializeDeadline;
|
|
87
|
-
this.log
|
|
83
|
+
this.log?.info(`Sequencer timetable initialized with ${this.maxNumberOfBlocks} blocks per slot (${this.enforce ? 'enforced' : 'not enforced'})`, {
|
|
88
84
|
ethereumSlotDuration: this.ethereumSlotDuration,
|
|
89
85
|
aztecSlotDuration: this.aztecSlotDuration,
|
|
90
86
|
l1PublishingTime: this.l1PublishingTime,
|
|
@@ -141,7 +137,7 @@ export class SequencerTimetable {
|
|
|
141
137
|
throw new SequencerTooSlowError(newState, maxAllowedTime, secondsIntoSlot);
|
|
142
138
|
}
|
|
143
139
|
this.metrics?.recordStateTransitionBufferMs(Math.floor(bufferSeconds * 1000), newState);
|
|
144
|
-
this.log
|
|
140
|
+
this.log?.trace(`Enough time to transition to ${newState}`, {
|
|
145
141
|
maxAllowedTime,
|
|
146
142
|
secondsIntoSlot
|
|
147
143
|
});
|
|
@@ -175,7 +171,7 @@ export class SequencerTimetable {
|
|
|
175
171
|
const available = (maxAllowed - secondsIntoSlot) / 2; // Split remaining time: half for execution, half for re-execution
|
|
176
172
|
const canStart = available >= this.minExecutionTime;
|
|
177
173
|
const deadline = secondsIntoSlot + available;
|
|
178
|
-
this.log
|
|
174
|
+
this.log?.verbose(`${canStart ? 'Can' : 'Cannot'} start single-block checkpoint at ${secondsIntoSlot}s into slot`, {
|
|
179
175
|
secondsIntoSlot,
|
|
180
176
|
maxAllowed,
|
|
181
177
|
available,
|
|
@@ -197,7 +193,7 @@ export class SequencerTimetable {
|
|
|
197
193
|
if (timeUntilDeadline >= this.minExecutionTime) {
|
|
198
194
|
// Found an available sub-slot! Is this the last one?
|
|
199
195
|
const isLastBlock = subSlot === this.maxNumberOfBlocks;
|
|
200
|
-
this.log
|
|
196
|
+
this.log?.verbose(`Can start ${isLastBlock ? 'last block' : 'block'} in sub-slot ${subSlot} with deadline ${deadline}s`, {
|
|
201
197
|
secondsIntoSlot,
|
|
202
198
|
deadline,
|
|
203
199
|
timeUntilDeadline,
|
|
@@ -212,7 +208,7 @@ export class SequencerTimetable {
|
|
|
212
208
|
}
|
|
213
209
|
}
|
|
214
210
|
// No sub-slots available with enough time
|
|
215
|
-
this.log
|
|
211
|
+
this.log?.verbose(`No time left to start any more blocks`, {
|
|
216
212
|
secondsIntoSlot,
|
|
217
213
|
maxBlocks: this.maxNumberOfBlocks,
|
|
218
214
|
initializationOffset: this.initializationOffset
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
2
|
-
export type SequencerRollupConstants = Pick<L1RollupConstants, 'ethereumSlotDuration' | 'l1GenesisTime' | 'slotDuration'>;
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
2
|
+
export type SequencerRollupConstants = Pick<L1RollupConstants, 'ethereumSlotDuration' | 'l1GenesisTime' | 'slotDuration' | 'rollupManaLimit'>;
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zZXF1ZW5jZXIvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUVyRSxNQUFNLE1BQU0sd0JBQXdCLEdBQUcsSUFBSSxDQUN6QyxpQkFBaUIsRUFDakIsc0JBQXNCLEdBQUcsZUFBZSxHQUFHLGNBQWMsR0FBRyxpQkFBaUIsQ0FDOUUsQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sequencer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE,MAAM,MAAM,wBAAwB,GAAG,IAAI,CACzC,iBAAiB,EACjB,sBAAsB,GAAG,eAAe,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sequencer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE,MAAM,MAAM,wBAAwB,GAAG,IAAI,CACzC,iBAAiB,EACjB,sBAAsB,GAAG,eAAe,GAAG,cAAc,GAAG,iBAAiB,CAC9E,CAAC"}
|
package/dest/test/index.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
2
2
|
import type { PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
3
3
|
import type { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
4
4
|
import type { FullNodeCheckpointsBuilder, ValidatorClient } from '@aztec/validator-client';
|
|
5
5
|
import { SequencerClient } from '../client/sequencer-client.js';
|
|
6
6
|
import type { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
|
|
7
|
-
import type { SequencerPublisher } from '../publisher/sequencer-publisher.js';
|
|
8
7
|
import { Sequencer } from '../sequencer/sequencer.js';
|
|
9
8
|
import type { SequencerTimetable } from '../sequencer/timetable.js';
|
|
10
9
|
declare class TestSequencer_ extends Sequencer {
|
|
11
10
|
publicProcessorFactory: PublicProcessorFactory;
|
|
12
11
|
timetable: SequencerTimetable;
|
|
13
|
-
publisher: SequencerPublisher;
|
|
14
12
|
publisherFactory: SequencerPublisherFactory;
|
|
15
13
|
validatorClient: ValidatorClient;
|
|
16
14
|
checkpointsBuilder: FullNodeCheckpointsBuilder;
|
|
@@ -18,8 +16,8 @@ declare class TestSequencer_ extends Sequencer {
|
|
|
18
16
|
export type TestSequencer = TestSequencer_;
|
|
19
17
|
declare class TestSequencerClient_ extends SequencerClient {
|
|
20
18
|
sequencer: TestSequencer;
|
|
21
|
-
publisherManager: PublisherManager<
|
|
19
|
+
publisherManager: PublisherManager<L1TxUtils>;
|
|
22
20
|
}
|
|
23
21
|
export type TestSequencerClient = TestSequencerClient_;
|
|
24
22
|
export {};
|
|
25
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0L2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQzdELE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sbUNBQW1DLENBQUM7QUFDMUUsT0FBTyxLQUFLLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUN0RSxPQUFPLEtBQUssRUFBRSwwQkFBMEIsRUFBRSxlQUFlLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUUzRixPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUseUJBQXlCLEVBQUUsTUFBTSw2Q0FBNkMsQ0FBQztBQUM3RixPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDdEQsT0FBTyxLQUFLLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUVwRSxjQUFNLGNBQWUsU0FBUSxTQUFTO0lBQ3JCLHNCQUFzQixFQUFFLHNCQUFzQixDQUFDO0lBQy9DLFNBQVMsRUFBRSxrQkFBa0IsQ0FBQztJQUM5QixnQkFBZ0IsRUFBRSx5QkFBeUIsQ0FBQztJQUM1QyxlQUFlLEVBQUUsZUFBZSxDQUFDO0lBQ2pDLGtCQUFrQixFQUFFLDBCQUEwQixDQUFDO0NBQy9EO0FBRUQsTUFBTSxNQUFNLGFBQWEsR0FBRyxjQUFjLENBQUM7QUFFM0MsY0FBTSxvQkFBcUIsU0FBUSxlQUFlO0lBQ2pDLFNBQVMsRUFBRSxhQUFhLENBQUM7SUFDekIsZ0JBQWdCLEVBQUUsZ0JBQWdCLENBQUMsU0FBUyxDQUFDLENBQUM7Q0FDOUQ7QUFFRCxNQUFNLE1BQU0sbUJBQW1CLEdBQUcsb0JBQW9CLENBQUMifQ==
|
package/dest/test/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE3F,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,cAAM,cAAe,SAAQ,SAAS;IACrB,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,SAAS,EAAE,kBAAkB,CAAC;IAC9B,gBAAgB,EAAE,yBAAyB,CAAC;IAC5C,eAAe,EAAE,eAAe,CAAC;IACjC,kBAAkB,EAAE,0BAA0B,CAAC;CAC/D;AAED,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC;AAE3C,cAAM,oBAAqB,SAAQ,eAAe;IACjC,SAAS,EAAE,aAAa,CAAC;IACzB,gBAAgB,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;CAC9D;AAED,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,CAAC"}
|