@aztec/sequencer-client 5.0.0-private.20260319 → 5.0.0-rc.1
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/README.md +281 -21
- package/dest/client/sequencer-client.d.ts +8 -3
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +17 -32
- package/dest/config.d.ts +10 -4
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +48 -24
- package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
- package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_predictor.js +128 -0
- package/dest/global_variable_builder/fee_provider.d.ts +21 -0
- package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_provider.js +67 -0
- package/dest/global_variable_builder/global_builder.d.ts +14 -14
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +16 -51
- package/dest/global_variable_builder/index.d.ts +4 -2
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- package/dest/global_variable_builder/index.js +2 -0
- package/dest/publisher/config.d.ts +15 -3
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +19 -4
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +3 -4
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -1
- package/dest/publisher/sequencer-bundle-simulator.d.ts +96 -0
- package/dest/publisher/sequencer-bundle-simulator.d.ts.map +1 -0
- package/dest/publisher/sequencer-bundle-simulator.js +198 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +3 -5
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +2 -3
- package/dest/publisher/sequencer-publisher.d.ts +70 -64
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +312 -533
- package/dest/sequencer/automine/automine_factory.d.ts +56 -0
- package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_factory.js +85 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts +184 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_sequencer.js +677 -0
- package/dest/sequencer/automine/index.d.ts +3 -0
- package/dest/sequencer/automine/index.d.ts.map +1 -0
- package/dest/sequencer/automine/index.js +2 -0
- package/dest/sequencer/chain_state_overrides.d.ts +61 -0
- package/dest/sequencer/chain_state_overrides.d.ts.map +1 -0
- package/dest/sequencer/chain_state_overrides.js +98 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts +73 -21
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +709 -199
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
- package/dest/sequencer/checkpoint_voter.d.ts +1 -2
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_voter.js +2 -5
- package/dest/sequencer/errors.d.ts +1 -8
- package/dest/sequencer/errors.d.ts.map +1 -1
- package/dest/sequencer/errors.js +0 -9
- package/dest/sequencer/events.d.ts +61 -4
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/metrics.d.ts +9 -10
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +34 -20
- package/dest/sequencer/sequencer.d.ts +112 -27
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +467 -147
- package/dest/sequencer/types.d.ts +2 -2
- package/dest/sequencer/types.d.ts.map +1 -1
- package/dest/test/index.d.ts +3 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/utils.d.ts +15 -1
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +23 -6
- package/package.json +28 -27
- package/src/client/sequencer-client.ts +29 -41
- package/src/config.ts +57 -24
- package/src/global_variable_builder/README.md +44 -0
- package/src/global_variable_builder/fee_predictor.ts +172 -0
- package/src/global_variable_builder/fee_provider.ts +80 -0
- package/src/global_variable_builder/global_builder.ts +25 -63
- package/src/global_variable_builder/index.ts +3 -1
- package/src/publisher/config.ts +40 -6
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +3 -1
- package/src/publisher/sequencer-bundle-simulator.ts +254 -0
- package/src/publisher/sequencer-publisher-factory.ts +3 -6
- package/src/publisher/sequencer-publisher.ts +368 -577
- package/src/sequencer/automine/README.md +60 -0
- package/src/sequencer/automine/automine_factory.ts +152 -0
- package/src/sequencer/automine/automine_sequencer.ts +783 -0
- package/src/sequencer/automine/index.ts +6 -0
- package/src/sequencer/chain_state_overrides.ts +169 -0
- package/src/sequencer/checkpoint_proposal_job.ts +818 -224
- package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
- package/src/sequencer/checkpoint_voter.ts +1 -12
- package/src/sequencer/errors.ts +0 -15
- package/src/sequencer/events.ts +65 -4
- package/src/sequencer/metrics.ts +43 -24
- package/src/sequencer/sequencer.ts +542 -164
- package/src/sequencer/types.ts +1 -1
- package/src/test/index.ts +2 -2
- package/src/test/utils.ts +59 -10
- package/dest/sequencer/timetable.d.ts +0 -88
- package/dest/sequencer/timetable.d.ts.map +0 -1
- package/dest/sequencer/timetable.js +0 -222
- package/src/sequencer/README.md +0 -531
- package/src/sequencer/timetable.ts +0 -283
|
@@ -372,29 +372,30 @@ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
372
372
|
}
|
|
373
373
|
var _dec, _dec1, _dec2, _dec3, _initProto;
|
|
374
374
|
import { getKzg } from '@aztec/blob-lib';
|
|
375
|
-
import {
|
|
375
|
+
import { PROPOSER_PIPELINING_SLOT_OFFSET } from '@aztec/epoch-cache';
|
|
376
376
|
import { NoCommitteeError } from '@aztec/ethereum/contracts';
|
|
377
|
-
import {
|
|
377
|
+
import { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
378
378
|
import { merge, omit, pick } from '@aztec/foundation/collection';
|
|
379
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
380
379
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
381
380
|
import { createLogger } from '@aztec/foundation/log';
|
|
382
381
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
383
|
-
import {
|
|
382
|
+
import { getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
|
|
383
|
+
import { MIN_PER_BLOCK_ALLOCATION_MULTIPLIER, MIN_PER_BLOCK_DA_ALLOCATION_MULTIPLIER, computeNetworkTxGasLimits } from '@aztec/stdlib/gas';
|
|
384
384
|
import { SequencerConfigSchema } from '@aztec/stdlib/interfaces/server';
|
|
385
385
|
import { pickFromSchema } from '@aztec/stdlib/schemas';
|
|
386
|
-
import {
|
|
386
|
+
import { buildProposerTimetable } from '@aztec/stdlib/timetable';
|
|
387
387
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
388
388
|
import EventEmitter from 'node:events';
|
|
389
389
|
import { DefaultSequencerConfig } from '../config.js';
|
|
390
|
+
import { buildCheckpointSimulationOverridesPlan } from './chain_state_overrides.js';
|
|
390
391
|
import { CheckpointProposalJob } from './checkpoint_proposal_job.js';
|
|
392
|
+
import { CheckpointProposalJobMetrics } from './checkpoint_proposal_job_metrics.js';
|
|
391
393
|
import { CheckpointVoter } from './checkpoint_voter.js';
|
|
392
|
-
import { SequencerInterruptedError
|
|
394
|
+
import { SequencerInterruptedError } from './errors.js';
|
|
393
395
|
import { SequencerMetrics } from './metrics.js';
|
|
394
|
-
import { SequencerTimetable } from './timetable.js';
|
|
395
396
|
import { SequencerState } from './utils.js';
|
|
396
397
|
export { SequencerState };
|
|
397
|
-
_dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpointProposal'), _dec2 = trackSpan('
|
|
398
|
+
_dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpointProposal'), _dec2 = trackSpan('Sequencer.tryVoteWhenCannotBuild', ({ slot })=>({
|
|
398
399
|
[Attributes.SLOT_NUMBER]: slot
|
|
399
400
|
})), _dec3 = trackSpan('Sequencer.tryVoteWhenEscapeHatchOpen', ({ slot })=>({
|
|
400
401
|
[Attributes.SLOT_NUMBER]: slot
|
|
@@ -437,7 +438,7 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
437
438
|
[
|
|
438
439
|
_dec2,
|
|
439
440
|
2,
|
|
440
|
-
"
|
|
441
|
+
"tryVoteWhenCannotBuild"
|
|
441
442
|
],
|
|
442
443
|
[
|
|
443
444
|
_dec3,
|
|
@@ -448,35 +449,133 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
448
449
|
}
|
|
449
450
|
runningPromise;
|
|
450
451
|
state;
|
|
452
|
+
stateSlotNumber;
|
|
453
|
+
/** Wall-clock time (ms, via the date provider) at which the current state was entered. */ stateEnteredAtMs;
|
|
451
454
|
metrics;
|
|
455
|
+
checkpointProposalJobMetrics;
|
|
456
|
+
stateLog;
|
|
452
457
|
/** The last slot for which we attempted to perform our voting duties with degraded block production */ lastSlotForFallbackVote;
|
|
458
|
+
/** The (checkpoint, slot) of the last invalidation request we successfully simulated, to prevent
|
|
459
|
+
* re-simulating and re-submitting the same invalidation across the many ticks within a single slot. */ lastInvalidationAttempt;
|
|
453
460
|
/** The last slot for which we logged "no committee" warning, to avoid spam */ lastSlotForNoCommitteeWarning;
|
|
454
461
|
/** The last slot for which we triggered a checkpoint proposal job, to prevent duplicate attempts. */ lastSlotForCheckpointProposalJob;
|
|
455
462
|
/** Last successful checkpoint proposed */ lastCheckpointProposed;
|
|
456
463
|
/** The last epoch for which we logged strategy comparison in fisherman mode. */ lastEpochForStrategyComparison;
|
|
457
|
-
/** The
|
|
464
|
+
/** The last checkpoint proposal job, tracked so we can await its pending L1 submission during shutdown. */ lastCheckpointProposalJob;
|
|
465
|
+
/** Proposer schedule and block sub-slot timetable for the sequencer, rebuilt on every config update. */ timetable;
|
|
458
466
|
/** Config for the sequencer */ config;
|
|
467
|
+
signatureContext;
|
|
459
468
|
constructor(publisherFactory, validatorClient, globalsBuilder, p2pClient, worldState, slasherClient, l2BlockSource, l1ToL2MessageSource, checkpointsBuilder, l1Constants, dateProvider, epochCache, rollupContract, config, telemetry = getTelemetryClient(), log = createLogger('sequencer')){
|
|
460
469
|
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;
|
|
470
|
+
this.stateLog = log.createChild('state');
|
|
471
|
+
this.stateEnteredAtMs = this.dateProvider.now();
|
|
461
472
|
// Add [FISHERMAN] prefix to logger if in fisherman mode
|
|
462
473
|
if (config.fishermanMode) {
|
|
463
474
|
this.log = log.createChild('[FISHERMAN]');
|
|
464
475
|
}
|
|
476
|
+
this.signatureContext = {
|
|
477
|
+
chainId: config.l1ChainId,
|
|
478
|
+
rollupAddress: config.rollupAddress
|
|
479
|
+
};
|
|
465
480
|
this.metrics = new SequencerMetrics(telemetry, this.rollupContract, 'Sequencer');
|
|
481
|
+
this.checkpointProposalJobMetrics = new CheckpointProposalJobMetrics(telemetry);
|
|
466
482
|
this.updateConfig(config);
|
|
467
483
|
}
|
|
468
|
-
/**
|
|
484
|
+
/**
|
|
485
|
+
* Updates sequencer config by the defined values and rebuilds the timetable.
|
|
486
|
+
*
|
|
487
|
+
* The merged config is validated against a candidate before being committed: {@link buildTimetable} may
|
|
488
|
+
* reject the candidate (invalid timing geometry, or per-block allocation multipliers below the network
|
|
489
|
+
* minimums). On rejection we leave `this.config` and `this.timetable` untouched and rethrow, so a bad update
|
|
490
|
+
* never leaves the sequencer running with a rejected config and a stale timetable.
|
|
491
|
+
*/ updateConfig(config) {
|
|
469
492
|
const filteredConfig = pickFromSchema(config, SequencerConfigSchema);
|
|
493
|
+
const candidate = merge(this.config, filteredConfig);
|
|
494
|
+
let timetable;
|
|
495
|
+
try {
|
|
496
|
+
timetable = this.buildTimetable(candidate);
|
|
497
|
+
} catch (err) {
|
|
498
|
+
this.log.warn(`Rejecting sequencer config update: ${err.message}`, {
|
|
499
|
+
rejectedConfig: omit(filteredConfig, 'txPublicSetupAllowListExtend')
|
|
500
|
+
});
|
|
501
|
+
throw err;
|
|
502
|
+
}
|
|
503
|
+
this.config = candidate;
|
|
504
|
+
this.timetable = timetable;
|
|
470
505
|
this.log.info(`Updated sequencer config`, omit(filteredConfig, 'txPublicSetupAllowListExtend'));
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Builds the proposer timetable from the given config and L1 constants via the shared
|
|
509
|
+
* {@link buildProposerTimetable} helper, so the sequencer derives the same blocks-per-checkpoint as the p2p
|
|
510
|
+
* layer and `getNodeInfo`. The fast local/e2e profile and budget clamping happen inside
|
|
511
|
+
* {@link ProposerTimetable}.
|
|
512
|
+
*
|
|
513
|
+
* Throws if the timing geometry is invalid or the per-block allocation multipliers are below the network
|
|
514
|
+
* minimums; callers must treat a throw as a rejected config and not commit it.
|
|
515
|
+
*/ buildTimetable(config) {
|
|
516
|
+
const timetable = buildProposerTimetable(config, this.l1Constants);
|
|
517
|
+
const maxNumberOfBlocks = timetable.getMaxBlocksPerCheckpoint();
|
|
518
|
+
this.log.info(`Sequencer timetable initialized with ${maxNumberOfBlocks} blocks per slot`, {
|
|
519
|
+
aztecSlotDuration: timetable.aztecSlotDuration,
|
|
520
|
+
ethereumSlotDuration: timetable.ethereumSlotDuration,
|
|
521
|
+
blockDuration: timetable.blockDuration,
|
|
522
|
+
minBlockDuration: timetable.minBlockDuration,
|
|
523
|
+
p2pPropagationTime: timetable.p2pPropagationTime,
|
|
524
|
+
checkpointProposalPrepareTime: timetable.checkpointProposalPrepareTime,
|
|
525
|
+
maxNumberOfBlocks
|
|
526
|
+
});
|
|
527
|
+
this.assertConfigMeetsNetworkTxLimits(config, maxNumberOfBlocks);
|
|
528
|
+
return timetable;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Checks this node's configured per-block allocation against the network admission limit. A node
|
|
532
|
+
* advertises and admits txs up to the limit derived from the network-minimum multipliers (see
|
|
533
|
+
* {@link computeNetworkTxGasLimits}).
|
|
534
|
+
*
|
|
535
|
+
* Fails startup (and runtime config updates) only when the configured per-block allocation *multipliers*
|
|
536
|
+
* (`perBlockAllocationMultiplier` / `perBlockDAAllocationMultiplier`) are below the network minimums: such
|
|
537
|
+
* a node would accept txs over RPC/gossip that its builder can never pack into a block regardless of block
|
|
538
|
+
* size. Operators may configure a higher (more generous) multiplier, but not a lower one.
|
|
539
|
+
*
|
|
540
|
+
* When the multipliers meet the floor but an absolute per-block gas cap (`maxDABlockGas` / `maxL2BlockGas`)
|
|
541
|
+
* shrinks the builder's effective grant below the network limit, this is legitimate operator
|
|
542
|
+
* restrictiveness — the node simply builds smaller blocks and such txs stay in the pool for other
|
|
543
|
+
* proposers — so we only log a warning rather than failing startup. Restrictive tx-count caps
|
|
544
|
+
* (`maxTxsPerBlock` / `maxTxsPerCheckpoint`) can likewise make the builder skip admitted txs; they are
|
|
545
|
+
* intentionally not modeled here for the same reason.
|
|
546
|
+
*/ assertConfigMeetsNetworkTxLimits(config, maxBlocksPerCheckpoint) {
|
|
547
|
+
// Mirror CheckpointBuilder.capLimitsByCheckpointBudgets: DA falls back to the general multiplier.
|
|
548
|
+
const l2Multiplier = config.perBlockAllocationMultiplier;
|
|
549
|
+
const daMultiplier = config.perBlockDAAllocationMultiplier ?? l2Multiplier;
|
|
550
|
+
// The allocation is monotonic in the multiplier, so a multiplier at or above the network minimum
|
|
551
|
+
// guarantees the builder grants at least the network admission limit. Checking the multipliers directly
|
|
552
|
+
// is sufficient (and strictly more conservative than modeling the resulting gas grant).
|
|
553
|
+
if (daMultiplier < MIN_PER_BLOCK_DA_ALLOCATION_MULTIPLIER) {
|
|
554
|
+
throw new Error(`perBlockDAAllocationMultiplier (${daMultiplier}) is below the network minimum ` + `${MIN_PER_BLOCK_DA_ALLOCATION_MULTIPLIER}; the node would admit txs its own builder can never include.`);
|
|
555
|
+
}
|
|
556
|
+
if (l2Multiplier < MIN_PER_BLOCK_ALLOCATION_MULTIPLIER) {
|
|
557
|
+
throw new Error(`perBlockAllocationMultiplier (${l2Multiplier}) is below the network minimum ` + `${MIN_PER_BLOCK_ALLOCATION_MULTIPLIER}; the node would admit txs its own builder can never include.`);
|
|
558
|
+
}
|
|
559
|
+
// Absolute per-block gas caps below the network admission limit are legitimate operator restrictiveness:
|
|
560
|
+
// the node simply builds smaller blocks and such txs stay in the pool for other proposers. Warn only.
|
|
561
|
+
const networkLimit = computeNetworkTxGasLimits({
|
|
562
|
+
maxBlocksPerCheckpoint,
|
|
563
|
+
manaCheckpointBudget: this.l1Constants.rollupManaLimit
|
|
564
|
+
});
|
|
565
|
+
if (config.maxDABlockGas !== undefined && config.maxDABlockGas < networkLimit.daGas) {
|
|
566
|
+
this.log.warn(`Sequencer maxDABlockGas (${config.maxDABlockGas}) is below the network DA admission limit ` + `(${networkLimit.daGas}): txs declaring more DA gas are admitted over RPC/gossip but will be skipped ` + `by this proposer's own blocks and left in the pool for other proposers.`, {
|
|
567
|
+
maxDABlockGas: config.maxDABlockGas,
|
|
568
|
+
networkDaGas: networkLimit.daGas,
|
|
569
|
+
maxBlocksPerCheckpoint
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
if (config.maxL2BlockGas !== undefined && config.maxL2BlockGas < networkLimit.l2Gas) {
|
|
573
|
+
this.log.warn(`Sequencer maxL2BlockGas (${config.maxL2BlockGas}) is below the network L2 admission limit ` + `(${networkLimit.l2Gas}): txs declaring more L2 gas are admitted over RPC/gossip but will be skipped ` + `by this proposer's own blocks and left in the pool for other proposers.`, {
|
|
574
|
+
maxL2BlockGas: config.maxL2BlockGas,
|
|
575
|
+
networkL2Gas: networkLimit.l2Gas,
|
|
576
|
+
maxBlocksPerCheckpoint
|
|
577
|
+
});
|
|
578
|
+
}
|
|
480
579
|
}
|
|
481
580
|
/** Initializes the sequencer (precomputes tables). Takes about 3s. */ init() {
|
|
482
581
|
getKzg();
|
|
@@ -489,13 +588,18 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
489
588
|
this.runningPromise.start();
|
|
490
589
|
this.log.info('Started sequencer');
|
|
491
590
|
}
|
|
591
|
+
/** Triggers an immediate run of the sequencer, bypassing the polling interval. */ trigger() {
|
|
592
|
+
return this.runningPromise?.trigger();
|
|
593
|
+
}
|
|
492
594
|
/** Stops the sequencer from building blocks and moves to STOPPED state. */ async stop() {
|
|
493
595
|
this.log.info(`Stopping sequencer`);
|
|
494
596
|
this.setState(SequencerState.STOPPING, undefined, {
|
|
495
597
|
force: true
|
|
496
598
|
});
|
|
497
|
-
this.
|
|
599
|
+
this.lastCheckpointProposalJob?.interrupt();
|
|
600
|
+
await this.publisherFactory.stopAll();
|
|
498
601
|
await this.runningPromise?.stop();
|
|
602
|
+
await this.lastCheckpointProposalJob?.awaitPendingSubmission();
|
|
499
603
|
this.setState(SequencerState.STOPPED, undefined, {
|
|
500
604
|
force: true
|
|
501
605
|
});
|
|
@@ -508,19 +612,7 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
508
612
|
this.emit('checkpoint-error', {
|
|
509
613
|
error: err
|
|
510
614
|
});
|
|
511
|
-
|
|
512
|
-
// Log as warn only if we had to abort halfway through the block proposal
|
|
513
|
-
const logLvl = [
|
|
514
|
-
SequencerState.INITIALIZING_CHECKPOINT,
|
|
515
|
-
SequencerState.PROPOSER_CHECK
|
|
516
|
-
].includes(err.proposedState) ? 'debug' : 'warn';
|
|
517
|
-
this.log[logLvl](err.message, {
|
|
518
|
-
now: this.dateProvider.nowInSeconds()
|
|
519
|
-
});
|
|
520
|
-
} else {
|
|
521
|
-
// Re-throw other errors
|
|
522
|
-
throw err;
|
|
523
|
-
}
|
|
615
|
+
throw err;
|
|
524
616
|
} finally{
|
|
525
617
|
this.setState(SequencerState.IDLE, undefined);
|
|
526
618
|
}
|
|
@@ -539,13 +631,14 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
539
631
|
* - Submit checkpoint
|
|
540
632
|
*/ async work() {
|
|
541
633
|
this.setState(SequencerState.SYNCHRONIZING, undefined);
|
|
542
|
-
const { slot, ts, nowSeconds
|
|
543
|
-
const { slot: targetSlot, epoch: targetEpoch } = this.epochCache.getTargetEpochAndSlotInNextL1Slot();
|
|
634
|
+
const { slot, targetSlot, epoch, targetEpoch, ts, nowSeconds } = this.getSlotContextInNextL1Slot();
|
|
544
635
|
// Check if we are synced and it's our slot, grab a publisher, check previous block invalidation, etc
|
|
545
636
|
const checkpointProposalJob = await this.prepareCheckpointProposal(slot, targetSlot, epoch, targetEpoch, ts, nowSeconds);
|
|
546
637
|
if (!checkpointProposalJob) {
|
|
547
638
|
return;
|
|
548
639
|
}
|
|
640
|
+
// Track the job so we can await its pending L1 submission during shutdown
|
|
641
|
+
this.lastCheckpointProposalJob = checkpointProposalJob;
|
|
549
642
|
// Execute the checkpoint proposal job
|
|
550
643
|
const checkpoint = await checkpointProposalJob.execute();
|
|
551
644
|
// Update last checkpoint proposed (currently unused)
|
|
@@ -559,15 +652,25 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
559
652
|
}
|
|
560
653
|
return checkpoint;
|
|
561
654
|
}
|
|
655
|
+
/** Returns slot and target slot from a single clock snapshot. */ getSlotContextInNextL1Slot() {
|
|
656
|
+
const { slot, ts, nowSeconds, epoch } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
657
|
+
const targetSlot = SlotNumber(slot + PROPOSER_PIPELINING_SLOT_OFFSET);
|
|
658
|
+
return {
|
|
659
|
+
slot,
|
|
660
|
+
targetSlot,
|
|
661
|
+
epoch,
|
|
662
|
+
targetEpoch: getEpochAtSlot(targetSlot, this.l1Constants),
|
|
663
|
+
ts,
|
|
664
|
+
nowSeconds
|
|
665
|
+
};
|
|
666
|
+
}
|
|
562
667
|
/**
|
|
563
668
|
* Prepares the checkpoint proposal by performing all necessary checks and setup.
|
|
564
669
|
* This is the initial step in the main loop.
|
|
565
670
|
* @returns CheckpointProposalJob if successful, undefined if we are not yet synced or are not the proposer.
|
|
566
671
|
*/ async prepareCheckpointProposal(slot, targetSlot, epoch, targetEpoch, ts, nowSeconds) {
|
|
567
|
-
// Check we have not already processed this target slot (cheapest check)
|
|
568
|
-
|
|
569
|
-
// running against actual time (eg when we use sandbox-style automining)
|
|
570
|
-
if (this.lastSlotForCheckpointProposalJob && this.lastSlotForCheckpointProposalJob >= targetSlot && this.config.enforceTimeTable) {
|
|
672
|
+
// Check we have not already processed this target slot (cheapest check).
|
|
673
|
+
if (this.lastSlotForCheckpointProposalJob && this.lastSlotForCheckpointProposalJob >= targetSlot) {
|
|
571
674
|
this.log.trace(`Target slot ${targetSlot} has already been processed`);
|
|
572
675
|
return undefined;
|
|
573
676
|
}
|
|
@@ -576,29 +679,28 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
576
679
|
this.log.trace(`Slot ${targetSlot} has already been published as checkpoint ${this.lastCheckpointProposed.number}`);
|
|
577
680
|
return undefined;
|
|
578
681
|
}
|
|
579
|
-
//
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
slot
|
|
583
|
-
|
|
584
|
-
if (!syncedTo) {
|
|
585
|
-
await this.tryVoteWhenSyncFails({
|
|
586
|
-
slot,
|
|
587
|
-
targetSlot,
|
|
588
|
-
ts
|
|
682
|
+
// Test-only: skip proposing for explicitly paused slots. Attestation paths run in the validator
|
|
683
|
+
// client and are not gated by this hook, so paused proposers still attest to others' proposals.
|
|
684
|
+
if (this.config.pauseProposingForSlots?.some((s)=>s === targetSlot)) {
|
|
685
|
+
this.log.warn(`Skipping proposal for paused slot ${targetSlot} (test-only pauseProposingForSlots hook)`, {
|
|
686
|
+
targetSlot
|
|
589
687
|
});
|
|
590
688
|
return undefined;
|
|
591
689
|
}
|
|
690
|
+
// Cheap proposer check first: most nodes are not the proposer for most slots, so gate the
|
|
691
|
+
// expensive multi-subsystem checkSync (and the rest of the build path) behind it. Computed once
|
|
692
|
+
// here and reused for the escape-hatch voting path below. No setState/timing gate on this path:
|
|
693
|
+
// the build-start deadline gate runs only on the proposer build path after a successful checkSync.
|
|
694
|
+
const [canPropose, proposer] = await this.checkCanPropose(targetSlot);
|
|
592
695
|
// If escape hatch is open for the target epoch, do not start checkpoint proposal work and do not attempt invalidations.
|
|
593
696
|
// Still perform governance/slashing voting (as proposer) once per slot.
|
|
594
697
|
// When pipelining, we check the target epoch (slot+1's epoch) since that's the epoch we're building for.
|
|
595
698
|
const isEscapeHatchOpen = await this.epochCache.isEscapeHatchOpen(targetEpoch);
|
|
596
699
|
if (isEscapeHatchOpen) {
|
|
597
|
-
this.setState(SequencerState.PROPOSER_CHECK, slot);
|
|
598
|
-
const [canPropose, proposer] = await this.checkCanPropose(targetSlot);
|
|
599
700
|
if (canPropose) {
|
|
600
701
|
await this.tryVoteWhenEscapeHatchOpen({
|
|
601
702
|
slot,
|
|
703
|
+
targetSlot,
|
|
602
704
|
proposer
|
|
603
705
|
});
|
|
604
706
|
} else {
|
|
@@ -610,6 +712,60 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
610
712
|
}
|
|
611
713
|
return undefined;
|
|
612
714
|
}
|
|
715
|
+
// If we are not the proposer, check whether we should invalidate an invalid pending chain (a
|
|
716
|
+
// liveness backstop) and bail before any sync work or build-timing gate. This reads only the
|
|
717
|
+
// archiver's pending-chain validation status, which is authoritative on its own, instead of
|
|
718
|
+
// running the full sync check. Wrapped in try/catch because this leaner path skips the broader
|
|
719
|
+
// proposed-checkpoint/tip coherence screen that checkSync applied, so transient archiver
|
|
720
|
+
// incoherence surfaces as a quiet skip rather than a work-loop error.
|
|
721
|
+
if (!canPropose) {
|
|
722
|
+
try {
|
|
723
|
+
const pendingChainValidationStatus = await this.l2BlockSource.getPendingChainValidationStatus();
|
|
724
|
+
await this.considerInvalidatingCheckpoint(pendingChainValidationStatus, slot);
|
|
725
|
+
} catch (err) {
|
|
726
|
+
this.log.warn(`Failed to consider invalidating checkpoint`, {
|
|
727
|
+
err,
|
|
728
|
+
slot,
|
|
729
|
+
targetSlot
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
return undefined;
|
|
733
|
+
}
|
|
734
|
+
// We are the proposer and the escape hatch is closed: now run the full sync check before building.
|
|
735
|
+
const syncedTo = await this.checkSync({
|
|
736
|
+
ts,
|
|
737
|
+
slot
|
|
738
|
+
});
|
|
739
|
+
if (!syncedTo) {
|
|
740
|
+
await this.tryVoteWhenCannotBuild({
|
|
741
|
+
slot,
|
|
742
|
+
targetSlot
|
|
743
|
+
});
|
|
744
|
+
return undefined;
|
|
745
|
+
}
|
|
746
|
+
// Explicit build-loop entry gate: if we are past the latest useful block-building start for the
|
|
747
|
+
// target slot, abandon building for this slot. The proposer prioritizes the ideal L1-publish path
|
|
748
|
+
// and does not plan around the late consensus-handoff path. This is the proposer build path's
|
|
749
|
+
// timing gate; it runs only after we know we are the synced proposer, so non-proposer invalidation
|
|
750
|
+
// and escape-hatch voting (which returned above) are never gated by build timing. Vote-only paths
|
|
751
|
+
// still run when block building is abandoned.
|
|
752
|
+
const startDeadline = this.timetable.getBuildStartDeadline(targetSlot);
|
|
753
|
+
const nowForStartGate = this.dateProvider.now() / 1000;
|
|
754
|
+
if (nowForStartGate > startDeadline) {
|
|
755
|
+
this.log.debug(`Past start deadline for slot ${targetSlot}, abandoning block building`, {
|
|
756
|
+
targetSlot,
|
|
757
|
+
nowForStartGate,
|
|
758
|
+
startDeadline
|
|
759
|
+
});
|
|
760
|
+
// Mark the slot as attempted so a deadline abort is not retried within the same slot. Vote-only actions
|
|
761
|
+
// still need to run because sync can succeed even when it is too late to start building a checkpoint.
|
|
762
|
+
await this.tryVoteWhenCannotBuild({
|
|
763
|
+
slot,
|
|
764
|
+
targetSlot
|
|
765
|
+
});
|
|
766
|
+
this.lastSlotForCheckpointProposalJob = targetSlot;
|
|
767
|
+
return undefined;
|
|
768
|
+
}
|
|
613
769
|
// Next checkpoint follows from the last synced one
|
|
614
770
|
const checkpointNumber = CheckpointNumber(syncedTo.checkpointNumber + 1);
|
|
615
771
|
const logCtx = {
|
|
@@ -621,12 +777,13 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
621
777
|
checkpointNumber,
|
|
622
778
|
isPendingChainValid: pick(syncedTo.pendingChainValidationStatus, 'valid', 'reason', 'invalidIndex')
|
|
623
779
|
};
|
|
624
|
-
//
|
|
625
|
-
this.setState(SequencerState.PROPOSER_CHECK,
|
|
626
|
-
|
|
627
|
-
//
|
|
628
|
-
|
|
629
|
-
|
|
780
|
+
// We are the synced proposer within the build window; enter the proposer-check state and build.
|
|
781
|
+
this.setState(SequencerState.PROPOSER_CHECK, targetSlot);
|
|
782
|
+
// Guard: don't exceed 1-deep pipeline. Without a proposed checkpoint, we can only build
|
|
783
|
+
// confirmed + 1. With a proposed checkpoint, we can build confirmed + 2.
|
|
784
|
+
const confirmedCkpt = syncedTo.checkpointedCheckpointNumber;
|
|
785
|
+
if (checkpointNumber > confirmedCkpt + 2) {
|
|
786
|
+
this.log.verbose(`Skipping slot ${targetSlot}: checkpoint ${checkpointNumber} exceeds max pipeline depth (confirmed=${confirmedCkpt})`);
|
|
630
787
|
return undefined;
|
|
631
788
|
}
|
|
632
789
|
// Check that the target slot is not taken by a block already (should never happen, since only us can propose for this slot)
|
|
@@ -645,20 +802,84 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
645
802
|
const proposerForPublisher = this.config.fishermanMode ? undefined : proposer;
|
|
646
803
|
const { attestorAddress, publisher } = await this.publisherFactory.create(proposerForPublisher);
|
|
647
804
|
this.log.verbose(`Created publisher at address ${publisher.getSenderAddress()} for attestor ${attestorAddress}`);
|
|
648
|
-
//
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
//
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
805
|
+
// Prepare invalidation request if the pending chain is invalid (returns undefined if no need).
|
|
806
|
+
// Only simulate invalidation when there's no proposed parent, since we assume the proposed parent
|
|
807
|
+
// will invalidate the currently invalid checkpoint on L1.
|
|
808
|
+
const invalidateCheckpoint = syncedTo.hasProposedCheckpoint || syncedTo.pendingChainValidationStatus.valid ? undefined : await publisher.simulateInvalidateCheckpoint(syncedTo.pendingChainValidationStatus);
|
|
809
|
+
// Determine the correct archive and L1 state overrides for the canProposeAt check.
|
|
810
|
+
// The L1 contract reads archives[proposedCheckpointNumber] and compares it with the provided archive.
|
|
811
|
+
// When invalidating or pipelining, the local archive may differ from L1's, so we adjust accordingly.
|
|
812
|
+
let archiveForCheck = syncedTo.archive;
|
|
813
|
+
if (syncedTo.hasProposedCheckpoint) {
|
|
814
|
+
this.metrics.recordPipelineDepth(syncedTo.checkpointNumber - syncedTo.checkpointedCheckpointNumber);
|
|
815
|
+
this.log.verbose(`Building on top of proposed checkpoint (pending=${syncedTo.proposedCheckpointData?.checkpointNumber}) for target slot ${targetSlot}`, {
|
|
816
|
+
targetSlot,
|
|
817
|
+
parentCheckpointNumber: CheckpointNumber(checkpointNumber - 1)
|
|
818
|
+
});
|
|
819
|
+
// Match what L1 will see at archives[pending] once the proposed parent lands: the parent's
|
|
820
|
+
// own archive root from the gossiped proposal. `syncedTo.archive` is the world-state-local
|
|
821
|
+
// view and can transiently diverge from the proposed parent (e.g. before the proposed
|
|
822
|
+
// parent's blocks have been applied locally); diverging here would cause the canProposeAt
|
|
823
|
+
// override to set archives[pending] to one value while we present another for comparison.
|
|
824
|
+
archiveForCheck = syncedTo.proposedCheckpointData.archive.root;
|
|
825
|
+
} else if (invalidateCheckpoint) {
|
|
826
|
+
// After invalidation, L1 will roll back to checkpoint N-1. The archive at N-1 already
|
|
827
|
+
// exists on L1, so we just pass the matching archive (the lastArchive of the invalid checkpoint).
|
|
828
|
+
archiveForCheck = invalidateCheckpoint.lastArchive;
|
|
829
|
+
this.metrics.recordPipelineDepth(0);
|
|
830
|
+
} else {
|
|
831
|
+
this.metrics.recordPipelineDepth(0);
|
|
832
|
+
}
|
|
833
|
+
// Build the simulation plan: pending/proven override from pipelining or invalidation (or the
|
|
834
|
+
// current snapshot when neither applies, to short-circuit any pending prune in simulation),
|
|
835
|
+
// plus the parent checkpoint cell and fee header when pipelining.
|
|
836
|
+
const simulationOverridesPlan = await buildCheckpointSimulationOverridesPlan({
|
|
837
|
+
checkpointNumber,
|
|
838
|
+
proposedCheckpointData: syncedTo.hasProposedCheckpoint ? syncedTo.proposedCheckpointData : undefined,
|
|
839
|
+
invalidateToPendingCheckpointNumber: invalidateCheckpoint?.forcePendingCheckpointNumber,
|
|
840
|
+
checkpointedCheckpointNumber: syncedTo.checkpointedCheckpointNumber,
|
|
841
|
+
rollup: this.rollupContract,
|
|
842
|
+
signatureContext: this.signatureContext,
|
|
843
|
+
log: this.log
|
|
659
844
|
});
|
|
845
|
+
// The plan always pins both pending/proven (to short-circuit `canPruneAtTime` in simulation),
|
|
846
|
+
// so `provenOverride` always reflects the assumed proven checkpoint we are pinning the
|
|
847
|
+
// simulation to. We additionally warn when the pin is load-bearing — i.e. when a prune would
|
|
848
|
+
// actually fire at the target slot without it — so observers can spot "we are building
|
|
849
|
+
// optimistically across a pruning boundary" in the logs.
|
|
850
|
+
const provenOverride = simulationOverridesPlan?.chainTipsOverride?.proven;
|
|
851
|
+
if (provenOverride !== undefined && await this.l2BlockSource.isPruneDueAtSlot(targetSlot)) {
|
|
852
|
+
this.log.warn(`Assuming proof for epoch ending at checkpoint ${provenOverride} lands by target slot ${targetSlot}`, {
|
|
853
|
+
checkpointNumber,
|
|
854
|
+
slot,
|
|
855
|
+
targetSlot,
|
|
856
|
+
provenOverride
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
this.emit('preparing-checkpoint', {
|
|
860
|
+
targetSlot,
|
|
861
|
+
checkpointNumber,
|
|
862
|
+
hadProposedParent: syncedTo.hasProposedCheckpoint,
|
|
863
|
+
provenOverride,
|
|
864
|
+
simulatedPending: simulationOverridesPlan?.chainTipsOverride?.pending
|
|
865
|
+
});
|
|
866
|
+
const canProposeCheck = await publisher.canProposeAt(archiveForCheck, proposer ?? EthAddress.ZERO, simulationOverridesPlan);
|
|
867
|
+
const proposeContext = {
|
|
868
|
+
hasProposedCheckpoint: syncedTo.hasProposedCheckpoint,
|
|
869
|
+
proposedCheckpointNumber: syncedTo.proposedCheckpointData?.checkpointNumber,
|
|
870
|
+
checkpointedCheckpointNumber: syncedTo.checkpointedCheckpointNumber,
|
|
871
|
+
isInvalidating: !!invalidateCheckpoint,
|
|
872
|
+
invalidatingCheckpointNumber: invalidateCheckpoint?.checkpointNumber,
|
|
873
|
+
archiveForCheck: archiveForCheck.toString(),
|
|
874
|
+
overridePendingCheckpointNumber: simulationOverridesPlan?.chainTipsOverride?.pending,
|
|
875
|
+
overrideArchive: simulationOverridesPlan?.pendingCheckpointState?.archive,
|
|
876
|
+
overrideFeeHeader: simulationOverridesPlan?.pendingCheckpointState?.feeHeader
|
|
877
|
+
};
|
|
660
878
|
if (canProposeCheck === undefined) {
|
|
661
|
-
this.log.warn(`Cannot propose checkpoint ${checkpointNumber} at slot ${slot} due to failed rollup contract check`,
|
|
879
|
+
this.log.warn(`Cannot propose checkpoint ${checkpointNumber} at slot ${slot} due to failed rollup contract check`, {
|
|
880
|
+
...logCtx,
|
|
881
|
+
...proposeContext
|
|
882
|
+
});
|
|
662
883
|
this.emit('proposer-rollup-check-failed', {
|
|
663
884
|
reason: 'Rollup contract check failed',
|
|
664
885
|
slot
|
|
@@ -669,6 +890,7 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
669
890
|
if (canProposeCheck.slot !== targetSlot) {
|
|
670
891
|
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}.`, {
|
|
671
892
|
...logCtx,
|
|
893
|
+
...proposeContext,
|
|
672
894
|
rollup: canProposeCheck,
|
|
673
895
|
expectedSlot: targetSlot
|
|
674
896
|
});
|
|
@@ -682,6 +904,7 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
682
904
|
if (canProposeCheck.checkpointNumber !== checkpointNumber) {
|
|
683
905
|
this.log.warn(`Cannot propose due to block mismatch with rollup contract (this can be caused by a pending archiver sync). Expected checkpoint ${checkpointNumber} but got ${canProposeCheck.checkpointNumber}.`, {
|
|
684
906
|
...logCtx,
|
|
907
|
+
...proposeContext,
|
|
685
908
|
rollup: canProposeCheck,
|
|
686
909
|
expectedSlot: slot
|
|
687
910
|
});
|
|
@@ -696,14 +919,14 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
696
919
|
await this.p2pClient.prepareForSlot(targetSlot);
|
|
697
920
|
this.log.info(`Preparing checkpoint proposal ${checkpointNumber} for target slot ${targetSlot} during wall-clock slot ${slot}`, {
|
|
698
921
|
...logCtx,
|
|
699
|
-
|
|
700
|
-
|
|
922
|
+
...proposeContext,
|
|
923
|
+
proposer
|
|
701
924
|
});
|
|
702
925
|
// Create and return the checkpoint proposal job
|
|
703
|
-
return this.createCheckpointProposalJob(
|
|
926
|
+
return this.createCheckpointProposalJob(targetSlot, targetEpoch, checkpointNumber, syncedTo.blockNumber, syncedTo.checkpointedCheckpointNumber, proposer, publisher, attestorAddress, invalidateCheckpoint, syncedTo.proposedCheckpointData);
|
|
704
927
|
}
|
|
705
|
-
createCheckpointProposalJob(
|
|
706
|
-
return new CheckpointProposalJob(
|
|
928
|
+
createCheckpointProposalJob(targetSlot, targetEpoch, checkpointNumber, syncedToBlockNumber, checkpointedCheckpointNumber, proposer, publisher, attestorAddress, invalidateCheckpoint, proposedCheckpointData) {
|
|
929
|
+
return new CheckpointProposalJob(targetSlot, targetEpoch, checkpointNumber, syncedToBlockNumber, checkpointedCheckpointNumber, proposer, publisher, attestorAddress, invalidateCheckpoint, this.validatorClient, this.globalsBuilder, this.p2pClient, this.worldState, this.l1ToL2MessageSource, this.l2BlockSource, this.checkpointsBuilder, this.l2BlockSource, this.l1Constants, this.signatureContext, this.config, this.timetable, this.slasherClient, this.epochCache, this.dateProvider, this.metrics, this.checkpointProposalJobMetrics.createRecorder(), this, this.setState.bind(this), this.tracer, this.log.getBindings(), proposedCheckpointData);
|
|
707
930
|
}
|
|
708
931
|
/**
|
|
709
932
|
* Returns the current sequencer state.
|
|
@@ -711,9 +934,11 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
711
934
|
return this.state;
|
|
712
935
|
}
|
|
713
936
|
/**
|
|
714
|
-
* Internal helper for setting the sequencer state
|
|
937
|
+
* Internal helper for setting the sequencer state. Pure: sets the state, emits `state-changed`, and
|
|
938
|
+
* records metrics. Timing deadlines are queried explicitly at the relevant call sites, not gated here.
|
|
715
939
|
* @param proposedState - The new state to transition to.
|
|
716
|
-
* @param slotNumber - The
|
|
940
|
+
* @param slotNumber - The target slot being proposed for, emitted as `targetSlot` on the event payload
|
|
941
|
+
* and used to anchor `secondsIntoBuildFrame`. Undefined for lifecycle states with no associated slot.
|
|
717
942
|
* @param force - Whether to force the transition even if the sequencer is stopped.
|
|
718
943
|
*/ setState(proposedState, slotNumber, opts = {}) {
|
|
719
944
|
if (this.state === SequencerState.STOPPING && proposedState !== SequencerState.STOPPED && !opts.force) {
|
|
@@ -724,26 +949,40 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
724
949
|
this.log.warn(`Cannot set sequencer from ${this.state} to ${proposedState} as it is stopped.`);
|
|
725
950
|
return;
|
|
726
951
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
952
|
+
const secondsIntoBuildFrame = slotNumber !== undefined ? this.getSecondsIntoBuildFrame(slotNumber) : undefined;
|
|
953
|
+
const oldState = this.state;
|
|
954
|
+
const oldStateSlotNumber = this.stateSlotNumber;
|
|
955
|
+
const stateChanged = proposedState !== oldState;
|
|
956
|
+
// Wall-clock time spent in the previous state: the delta between consecutive state-changing setState
|
|
957
|
+
// calls, read from the date provider so it tracks simulated time under a test/manual clock.
|
|
958
|
+
const transitionAtMs = this.dateProvider.now();
|
|
959
|
+
const stateDurationMs = transitionAtMs - this.stateEnteredAtMs;
|
|
732
960
|
const boringStates = [
|
|
733
961
|
SequencerState.IDLE,
|
|
734
962
|
SequencerState.SYNCHRONIZING
|
|
735
963
|
];
|
|
736
|
-
const logLevel = boringStates.includes(proposedState) && boringStates.includes(
|
|
737
|
-
this.
|
|
964
|
+
const logLevel = boringStates.includes(proposedState) && boringStates.includes(oldState) ? 'trace' : 'debug';
|
|
965
|
+
this.stateLog[logLevel](`Transitioning from ${oldState} to ${proposedState}`, {
|
|
966
|
+
oldState,
|
|
967
|
+
newState: proposedState,
|
|
738
968
|
slotNumber,
|
|
739
|
-
|
|
969
|
+
stateSlotNumber: oldStateSlotNumber,
|
|
970
|
+
secondsIntoBuildFrame,
|
|
971
|
+
...stateChanged && {
|
|
972
|
+
stateDurationMs: Math.ceil(stateDurationMs)
|
|
973
|
+
}
|
|
740
974
|
});
|
|
741
975
|
this.emit('state-changed', {
|
|
742
|
-
oldState
|
|
976
|
+
oldState,
|
|
743
977
|
newState: proposedState,
|
|
744
|
-
|
|
745
|
-
|
|
978
|
+
secondsIntoBuildFrame,
|
|
979
|
+
targetSlot: slotNumber
|
|
746
980
|
});
|
|
981
|
+
if (stateChanged) {
|
|
982
|
+
this.metrics.recordStateDuration(stateDurationMs, oldState);
|
|
983
|
+
this.stateEnteredAtMs = transitionAtMs;
|
|
984
|
+
this.stateSlotNumber = slotNumber;
|
|
985
|
+
}
|
|
747
986
|
this.state = proposedState;
|
|
748
987
|
}
|
|
749
988
|
/**
|
|
@@ -751,8 +990,8 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
751
990
|
* We don't check against the previous block submitted since it may have been reorg'd out.
|
|
752
991
|
*/ async checkSync(args) {
|
|
753
992
|
// Check that the archiver has fully synced the L2 slot before the one we want to propose in.
|
|
754
|
-
//
|
|
755
|
-
//
|
|
993
|
+
// The archiver reports sync progress via L1 block timestamps and synced checkpoint slots.
|
|
994
|
+
// See getSyncedL2SlotNumber for how missed L1 blocks are handled.
|
|
756
995
|
const syncedL2Slot = await this.l2BlockSource.getSyncedL2SlotNumber();
|
|
757
996
|
const { slot } = args;
|
|
758
997
|
if (syncedL2Slot === undefined || syncedL2Slot + 1 < slot) {
|
|
@@ -767,48 +1006,98 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
767
1006
|
number: syncSummary.latestBlockNumber,
|
|
768
1007
|
hash: syncSummary.latestBlockHash
|
|
769
1008
|
})),
|
|
770
|
-
this.l2BlockSource.getL2Tips().then((t)=>
|
|
1009
|
+
this.l2BlockSource.getL2Tips().then((t)=>({
|
|
1010
|
+
proposed: t.proposed,
|
|
1011
|
+
checkpointed: t.checkpointed,
|
|
1012
|
+
proposedCheckpoint: t.proposedCheckpoint
|
|
1013
|
+
})),
|
|
771
1014
|
this.p2pClient.getStatus().then((p2p)=>p2p.syncedToL2Block),
|
|
772
|
-
this.l1ToL2MessageSource.getL2Tips().then((t)=>
|
|
773
|
-
|
|
1015
|
+
this.l1ToL2MessageSource.getL2Tips().then((t)=>({
|
|
1016
|
+
proposed: t.proposed,
|
|
1017
|
+
checkpointed: t.checkpointed
|
|
1018
|
+
})),
|
|
1019
|
+
this.l2BlockSource.getPendingChainValidationStatus(),
|
|
1020
|
+
this.l2BlockSource.getProposedCheckpointData()
|
|
774
1021
|
]);
|
|
775
|
-
const [worldState,
|
|
776
|
-
|
|
777
|
-
// as the world state can compute the new genesis block hash, but other components use the hardcoded constant.
|
|
778
|
-
// TODO(palla/mbps): Fix the above. All components should be able to handle dynamic genesis block hashes.
|
|
779
|
-
const result = l2BlockSource.number === 0 && worldState.number === 0 && p2p.number === 0 && l1ToL2MessageSource.number === 0 || worldState.hash === l2BlockSource.hash && p2p.hash === l2BlockSource.hash && l1ToL2MessageSource.hash === l2BlockSource.hash;
|
|
1022
|
+
const [worldState, l2Tips, p2p, l1ToL2MessageSourceTips, pendingChainValidationStatus, proposedCheckpointData] = syncedBlocks;
|
|
1023
|
+
const result = worldState.hash === l2Tips.proposed.hash && p2p.hash === l2Tips.proposed.hash && l1ToL2MessageSourceTips.proposed.hash === l2Tips.proposed.hash && l1ToL2MessageSourceTips.checkpointed.block.hash === l2Tips.checkpointed.block.hash && l1ToL2MessageSourceTips.checkpointed.checkpoint.hash === l2Tips.checkpointed.checkpoint.hash;
|
|
780
1024
|
if (!result) {
|
|
781
1025
|
this.log.debug(`Sequencer sync check failed`, {
|
|
782
1026
|
worldState,
|
|
783
|
-
l2BlockSource,
|
|
1027
|
+
l2BlockSource: l2Tips.proposed,
|
|
784
1028
|
p2p,
|
|
785
|
-
|
|
1029
|
+
l1ToL2MessageSourceTips
|
|
786
1030
|
});
|
|
787
1031
|
return undefined;
|
|
788
1032
|
}
|
|
789
|
-
// Special case for genesis state
|
|
790
1033
|
const blockNumber = worldState.number;
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
1034
|
+
const blockData = await this.l2BlockSource.getBlockData({
|
|
1035
|
+
number: blockNumber
|
|
1036
|
+
});
|
|
1037
|
+
if (!blockData) {
|
|
1038
|
+
this.log.warn(`Sequencer sync check failed: failed to get L2 block data ${blockNumber} from the archiver`, {
|
|
1039
|
+
blockNumber,
|
|
1040
|
+
l2Tips,
|
|
797
1041
|
syncedL2Slot,
|
|
798
|
-
|
|
1042
|
+
...args
|
|
1043
|
+
});
|
|
1044
|
+
return undefined;
|
|
1045
|
+
}
|
|
1046
|
+
// Refuse to build a checkpoint on top of a proposed block whose enclosing checkpoint was never
|
|
1047
|
+
// proposed. Under pipelining we may have received and reexecuted such a block locally — advancing
|
|
1048
|
+
// our world-state tip past the checkpointed tip — while the proposing node never published the
|
|
1049
|
+
// matching proposed checkpoint (e.g. it crashed before assembling it). Building on this orphan block
|
|
1050
|
+
// would fork the chain off a tip no other node can follow. The archiver prunes these orphan blocks
|
|
1051
|
+
// once their build slot ends; this guard is the correctness barrier during the grace window before.
|
|
1052
|
+
if (blockData.checkpointNumber > l2Tips.checkpointed.checkpoint.number && (l2Tips.proposedCheckpoint.checkpoint.number !== blockData.checkpointNumber || proposedCheckpointData?.checkpointNumber !== blockData.checkpointNumber)) {
|
|
1053
|
+
const logCtx = {
|
|
1054
|
+
blockCheckpointNumber: blockData.checkpointNumber,
|
|
1055
|
+
checkpointedCheckpointNumber: l2Tips.checkpointed.checkpoint.number,
|
|
1056
|
+
proposedCheckpointTipNumber: l2Tips.proposedCheckpoint.checkpoint.number,
|
|
1057
|
+
proposedCheckpointDataNumber: proposedCheckpointData?.checkpointNumber,
|
|
1058
|
+
blockNumber: blockData.header.getBlockNumber(),
|
|
1059
|
+
blockSlot: blockData.header.getSlot(),
|
|
1060
|
+
syncedL2Slot,
|
|
1061
|
+
...args
|
|
799
1062
|
};
|
|
1063
|
+
this.log.debug(`Waiting for proposed checkpoint to catch up with reexecuted block`, logCtx);
|
|
1064
|
+
return undefined;
|
|
800
1065
|
}
|
|
801
|
-
const
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
1066
|
+
const hasProposedCheckpoint = l2Tips.proposedCheckpoint.checkpoint.number > l2Tips.checkpointed.checkpoint.number;
|
|
1067
|
+
// The l2Tips and proposedCheckpointData reads above come from independent archiver snapshots
|
|
1068
|
+
// (a JS-side tips cache vs. a direct store read on `#proposedCheckpoints`). A concurrent archiver
|
|
1069
|
+
// write that mutates both can be observed split, leaving us with `hasProposedCheckpoint=true` but
|
|
1070
|
+
// no proposedCheckpointData (or one whose number doesn't match the tip). Refuse to proceed in that
|
|
1071
|
+
// window — the next checkSync tick will see a coherent snapshot.
|
|
1072
|
+
if (hasProposedCheckpoint && (!proposedCheckpointData || proposedCheckpointData.checkpointNumber !== l2Tips.proposedCheckpoint.checkpoint.number)) {
|
|
1073
|
+
this.log.warn(`Sequencer sync check failed: inconsistent proposed-checkpoint state`, {
|
|
1074
|
+
proposedCheckpointTipNumber: l2Tips.proposedCheckpoint.checkpoint.number,
|
|
1075
|
+
checkpointedTipNumber: l2Tips.checkpointed.checkpoint.number,
|
|
1076
|
+
proposedCheckpointDataNumber: proposedCheckpointData?.checkpointNumber,
|
|
1077
|
+
syncedL2Slot,
|
|
1078
|
+
...args
|
|
1079
|
+
});
|
|
1080
|
+
return undefined;
|
|
1081
|
+
}
|
|
1082
|
+
// Check that the proposed checkpoint is indeed the parent of the checkpoint we'll be building
|
|
1083
|
+
// The checkpoint number to build is derived as blockData.checkpointNumber + 1
|
|
1084
|
+
if (proposedCheckpointData && proposedCheckpointData.checkpointNumber !== blockData.checkpointNumber) {
|
|
1085
|
+
this.log.warn(`Sequencer sync check failed: proposed checkpoint number mismatch`, {
|
|
1086
|
+
proposedCheckpointNumber: proposedCheckpointData.checkpointNumber,
|
|
1087
|
+
blockCheckpointNumber: blockData.checkpointNumber,
|
|
1088
|
+
syncedL2Slot,
|
|
1089
|
+
...args
|
|
1090
|
+
});
|
|
805
1091
|
return undefined;
|
|
806
1092
|
}
|
|
807
1093
|
return {
|
|
808
1094
|
blockData,
|
|
809
1095
|
blockNumber: blockData.header.getBlockNumber(),
|
|
810
1096
|
checkpointNumber: blockData.checkpointNumber,
|
|
1097
|
+
checkpointedCheckpointNumber: l2Tips.checkpointed.checkpoint.number,
|
|
811
1098
|
archive: blockData.archive.root,
|
|
1099
|
+
hasProposedCheckpoint,
|
|
1100
|
+
proposedCheckpointData,
|
|
812
1101
|
syncedL2Slot,
|
|
813
1102
|
pendingChainValidationStatus
|
|
814
1103
|
};
|
|
@@ -864,7 +1153,7 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
864
1153
|
proposer
|
|
865
1154
|
];
|
|
866
1155
|
}
|
|
867
|
-
this.log.
|
|
1156
|
+
this.log.info(`We are the proposer for pipeline slot ${targetSlot}`, {
|
|
868
1157
|
targetSlot,
|
|
869
1158
|
proposer
|
|
870
1159
|
});
|
|
@@ -874,30 +1163,23 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
874
1163
|
];
|
|
875
1164
|
}
|
|
876
1165
|
/**
|
|
877
|
-
* Tries to vote on slashing actions and governance when
|
|
1166
|
+
* Tries to vote on slashing actions and governance when we cannot build and are past the block-building window.
|
|
878
1167
|
* This allows the sequencer to participate in governance/slashing votes even when it cannot build blocks.
|
|
879
|
-
*/ async
|
|
1168
|
+
*/ async tryVoteWhenCannotBuild(args) {
|
|
880
1169
|
const { slot, targetSlot } = args;
|
|
881
1170
|
// Prevent duplicate attempts in the same slot
|
|
882
1171
|
if (this.lastSlotForFallbackVote === slot) {
|
|
883
1172
|
this.log.trace(`Already attempted to vote in slot ${slot} (skipping)`);
|
|
884
1173
|
return;
|
|
885
1174
|
}
|
|
886
|
-
//
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
maxAllowedTime
|
|
895
|
-
});
|
|
896
|
-
return;
|
|
897
|
-
}
|
|
898
|
-
this.log.trace(`Sync for slot ${slot} failed, checking for voting opportunities`, {
|
|
899
|
-
secondsIntoSlot,
|
|
900
|
-
maxAllowedTime
|
|
1175
|
+
// Vote-only actions do not give up the slot: if sync recovers, a later work-loop iteration can still build.
|
|
1176
|
+
// Under proposer pipelining the work loop reasons about the next L1 slot, so waiting for the target slot's
|
|
1177
|
+
// build-start deadline can miss the whole fallback window when the target advances with the clock.
|
|
1178
|
+
const nowSeconds = this.dateProvider.now() / 1000;
|
|
1179
|
+
const startDeadline = this.timetable.getBuildStartDeadline(targetSlot);
|
|
1180
|
+
this.log.trace(`Cannot build for slot ${slot}, checking for voting opportunities`, {
|
|
1181
|
+
nowSeconds,
|
|
1182
|
+
startDeadline
|
|
901
1183
|
});
|
|
902
1184
|
// Check if we're a proposer or proposal is open
|
|
903
1185
|
const [canPropose, proposer] = await this.checkCanPropose(targetSlot);
|
|
@@ -927,13 +1209,21 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
927
1209
|
this.log.info(`Voting in slot ${slot} despite sync failure`, {
|
|
928
1210
|
slot
|
|
929
1211
|
});
|
|
930
|
-
|
|
1212
|
+
// Votes are EIP-712-signed for `targetSlot` (the pipelined slot in which the multicall is
|
|
1213
|
+
// expected to mine). Delay submission to the start of `targetSlot` so the tx mines in the
|
|
1214
|
+
// slot the votes were signed for. We fire-and-forget so we don't block the sequencer's
|
|
1215
|
+
// work loop while waiting for the target slot to start.
|
|
1216
|
+
void publisher.sendRequestsAt(targetSlot).catch((err)=>{
|
|
1217
|
+
this.log.error(`Failed to publish votes despite sync failure for slot ${slot}`, err, {
|
|
1218
|
+
slot
|
|
1219
|
+
});
|
|
1220
|
+
});
|
|
931
1221
|
}
|
|
932
1222
|
/**
|
|
933
1223
|
* Tries to vote on slashing actions and governance proposals when escape hatch is open.
|
|
934
1224
|
* This allows the sequencer to participate in voting without performing checkpoint proposal work.
|
|
935
1225
|
*/ async tryVoteWhenEscapeHatchOpen(args) {
|
|
936
|
-
const { slot, proposer } = args;
|
|
1226
|
+
const { slot, targetSlot, proposer } = args;
|
|
937
1227
|
// Prevent duplicate attempts in the same slot
|
|
938
1228
|
if (this.lastSlotForFallbackVote === slot) {
|
|
939
1229
|
this.log.trace(`Already attempted to vote in slot ${slot} (escape hatch open, skipping)`);
|
|
@@ -944,9 +1234,14 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
944
1234
|
const { attestorAddress, publisher } = await this.publisherFactory.create(proposer);
|
|
945
1235
|
this.log.debug(`Escape hatch open for slot ${slot}, attempting vote-only actions`, {
|
|
946
1236
|
slot,
|
|
1237
|
+
targetSlot,
|
|
947
1238
|
attestorAddress
|
|
948
1239
|
});
|
|
949
|
-
|
|
1240
|
+
// Under proposer pipelining, the multicall is expected to mine in `targetSlot` (slot + 1).
|
|
1241
|
+
// Governance and slashing votes are EIP-712-signed against the slot they will mine in, and the
|
|
1242
|
+
// L1 contract checks `msg.sender == getCurrentProposer()` using the mining slot. So we must
|
|
1243
|
+
// sign for `targetSlot` and delay submission to the start of `targetSlot`.
|
|
1244
|
+
const voter = new CheckpointVoter(targetSlot, publisher, attestorAddress, this.validatorClient, this.slasherClient, this.l1Constants, this.config, this.metrics, this.log);
|
|
950
1245
|
const votesPromises = voter.enqueueVotes();
|
|
951
1246
|
const votes = await Promise.all(votesPromises);
|
|
952
1247
|
if (votes.every((p)=>!p)) {
|
|
@@ -954,28 +1249,50 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
954
1249
|
return;
|
|
955
1250
|
}
|
|
956
1251
|
this.log.info(`Voting in slot ${slot} (escape hatch open)`, {
|
|
957
|
-
slot
|
|
1252
|
+
slot,
|
|
1253
|
+
targetSlot
|
|
1254
|
+
});
|
|
1255
|
+
// Votes are EIP-712-signed for `targetSlot`. Delay submission to the start of `targetSlot` so
|
|
1256
|
+
// the multicall mines in the slot the votes were signed for; otherwise the L1 contract reads
|
|
1257
|
+
// `signaler = getCurrentProposer()` against the wrong slot and signature verification fails
|
|
1258
|
+
// silently inside Multicall3. Fire-and-forget so we don't block the sequencer's work loop while
|
|
1259
|
+
// waiting for the target slot to start, mirroring tryVoteWhenCannotBuild.
|
|
1260
|
+
void publisher.sendRequestsAt(targetSlot).catch((err)=>{
|
|
1261
|
+
this.log.error(`Failed to publish escape-hatch votes for slot ${slot}`, err, {
|
|
1262
|
+
slot,
|
|
1263
|
+
targetSlot
|
|
1264
|
+
});
|
|
958
1265
|
});
|
|
959
|
-
await publisher.sendRequests();
|
|
960
1266
|
}
|
|
961
1267
|
/**
|
|
962
1268
|
* Considers invalidating a block if the pending chain is invalid. Depends on how long the invalid block
|
|
963
1269
|
* has been there without being invalidated and whether the sequencer is in the committee or not. We always
|
|
964
1270
|
* have the proposer try to invalidate, but if they fail, the sequencers in the committee are expected to try,
|
|
965
1271
|
* and if they fail, any sequencer will try as well.
|
|
966
|
-
|
|
967
|
-
|
|
1272
|
+
* @param pendingChainValidationStatus - The archiver's pending-chain validation status, authoritative on its own.
|
|
1273
|
+
* @param currentSlot - The wall-clock slot, used for committee lookup, the per-(checkpoint, slot) dedup guard, and logging.
|
|
1274
|
+
*/ async considerInvalidatingCheckpoint(pendingChainValidationStatus, currentSlot) {
|
|
968
1275
|
if (pendingChainValidationStatus.valid) {
|
|
969
1276
|
return;
|
|
970
1277
|
}
|
|
971
1278
|
const invalidCheckpointNumber = pendingChainValidationStatus.checkpoint.checkpointNumber;
|
|
1279
|
+
// Avoid re-running the committee lookup, simulation, and submission on every tick within a slot.
|
|
1280
|
+
// The guard is keyed by (checkpoint, slot) — so a different invalid checkpoint surfacing later in
|
|
1281
|
+
// the same slot is not suppressed — and is set only after a request is successfully simulated below,
|
|
1282
|
+
// so a transient simulation failure (or thresholds not yet met) still retries on the next tick.
|
|
1283
|
+
if (this.lastInvalidationAttempt?.slot === currentSlot && this.lastInvalidationAttempt.checkpointNumber === invalidCheckpointNumber) {
|
|
1284
|
+
this.log.trace(`Already attempted to invalidate checkpoint ${invalidCheckpointNumber} in slot ${currentSlot}`, {
|
|
1285
|
+
currentSlot,
|
|
1286
|
+
invalidCheckpointNumber
|
|
1287
|
+
});
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
972
1290
|
const invalidCheckpointTimestamp = pendingChainValidationStatus.checkpoint.timestamp;
|
|
973
1291
|
const timeSinceChainInvalid = this.dateProvider.nowInSeconds() - Number(invalidCheckpointTimestamp);
|
|
974
1292
|
const ourValidatorAddresses = this.validatorClient.getValidatorAddresses();
|
|
975
1293
|
const { secondsBeforeInvalidatingBlockAsCommitteeMember, secondsBeforeInvalidatingBlockAsNonCommitteeMember } = this.config;
|
|
976
1294
|
const logData = {
|
|
977
1295
|
invalidL1Timestamp: invalidCheckpointTimestamp,
|
|
978
|
-
syncedL2Slot,
|
|
979
1296
|
invalidCheckpoint: pendingChainValidationStatus.checkpoint,
|
|
980
1297
|
secondsBeforeInvalidatingBlockAsCommitteeMember,
|
|
981
1298
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember,
|
|
@@ -1009,6 +1326,12 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
1009
1326
|
this.log.warn(`Failed to simulate invalidate checkpoint`, logData);
|
|
1010
1327
|
return;
|
|
1011
1328
|
}
|
|
1329
|
+
// We produced a valid invalidation request; record it so further ticks within this slot skip the
|
|
1330
|
+
// committee lookup, simulation, and submission above for this same invalid checkpoint.
|
|
1331
|
+
this.lastInvalidationAttempt = {
|
|
1332
|
+
slot: currentSlot,
|
|
1333
|
+
checkpointNumber: invalidCheckpointNumber
|
|
1334
|
+
};
|
|
1012
1335
|
this.log.info(invalidateAsCommitteeMember ? `Invalidating checkpoint ${invalidCheckpointNumber} as committee member` : `Invalidating checkpoint ${invalidCheckpointNumber} as non-committee member`, logData);
|
|
1013
1336
|
publisher.enqueueInvalidateCheckpoint(invalidateCheckpoint);
|
|
1014
1337
|
if (!this.config.fishermanMode) {
|
|
@@ -1044,12 +1367,12 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
1044
1367
|
}))
|
|
1045
1368
|
});
|
|
1046
1369
|
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
const
|
|
1052
|
-
return Number((this.dateProvider.now() / 1000 -
|
|
1370
|
+
/**
|
|
1371
|
+
* Wall-clock seconds elapsed since the build-frame start of the given target slot
|
|
1372
|
+
* (`now − getBuildFrameStart(targetSlot)`). May be negative if called before the build frame opens.
|
|
1373
|
+
*/ getSecondsIntoBuildFrame(targetSlot) {
|
|
1374
|
+
const buildFrameStart = this.timetable.getBuildFrameStart(targetSlot);
|
|
1375
|
+
return Number((this.dateProvider.now() / 1000 - buildFrameStart).toFixed(3));
|
|
1053
1376
|
}
|
|
1054
1377
|
get aztecSlotDuration() {
|
|
1055
1378
|
return this.l1Constants.slotDuration;
|
|
@@ -1072,7 +1395,4 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
1072
1395
|
getConfig() {
|
|
1073
1396
|
return this.config;
|
|
1074
1397
|
}
|
|
1075
|
-
get l1PublishingTime() {
|
|
1076
|
-
return this.config.l1PublishingTime ?? this.l1Constants.ethereumSlotDuration;
|
|
1077
|
-
}
|
|
1078
1398
|
}
|