@aztec/sequencer-client 6.0.0-nightly.20260604 → 6.0.0-nightly.20260721
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 +27 -27
- package/dest/client/sequencer-client.d.ts +16 -3
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +17 -12
- package/dest/config.d.ts +6 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +23 -14
- package/dest/global_variable_builder/fee_predictor.d.ts +1 -1
- package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -1
- package/dest/global_variable_builder/fee_predictor.js +11 -1
- package/dest/global_variable_builder/fee_provider.d.ts +1 -1
- package/dest/global_variable_builder/fee_provider.d.ts.map +1 -1
- package/dest/global_variable_builder/fee_provider.js +27 -5
- package/dest/global_variable_builder/global_builder.d.ts +3 -16
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +2 -25
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/publisher/config.d.ts +5 -1
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +11 -1
- package/dest/publisher/l1_to_l2_messaging.d.ts +21 -0
- package/dest/publisher/l1_to_l2_messaging.d.ts.map +1 -0
- package/dest/publisher/l1_to_l2_messaging.js +70 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +48 -8
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -1
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +68 -1
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +2 -2
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -1
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +4 -2
- package/dest/publisher/l1_tx_failed_store/index.d.ts +2 -2
- package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -1
- package/dest/publisher/l1_tx_failed_store/index.js +1 -0
- package/dest/publisher/sequencer-publisher.d.ts +34 -6
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +364 -60
- package/dest/publisher/write_json.d.ts +11 -0
- package/dest/publisher/write_json.d.ts.map +1 -0
- package/dest/publisher/write_json.js +57 -0
- package/dest/sequencer/automine/automine_factory.d.ts +5 -3
- package/dest/sequencer/automine/automine_factory.d.ts.map +1 -1
- package/dest/sequencer/automine/automine_factory.js +2 -1
- package/dest/sequencer/automine/automine_sequencer.d.ts +43 -5
- package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -1
- package/dest/sequencer/automine/automine_sequencer.js +199 -18
- 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/checkpoint_proposal_job.d.ts +28 -15
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +140 -96
- package/dest/sequencer/events.d.ts +16 -5
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/index.d.ts +1 -3
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +0 -2
- package/dest/sequencer/requests_tracker.d.ts +22 -0
- package/dest/sequencer/requests_tracker.d.ts.map +1 -0
- package/dest/sequencer/requests_tracker.js +33 -0
- package/dest/sequencer/sequencer.d.ts +110 -36
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +330 -174
- 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 +18 -1
- package/package.json +30 -28
- package/src/client/sequencer-client.ts +20 -13
- package/src/config.ts +25 -12
- package/src/global_variable_builder/fee_predictor.ts +11 -1
- package/src/global_variable_builder/fee_provider.ts +27 -5
- package/src/global_variable_builder/global_builder.ts +2 -34
- package/src/index.ts +1 -10
- package/src/publisher/config.ts +22 -1
- package/src/publisher/l1_to_l2_messaging.ts +85 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +114 -7
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +4 -3
- package/src/publisher/l1_tx_failed_store/index.ts +1 -1
- package/src/publisher/sequencer-publisher.ts +385 -71
- package/src/publisher/write_json.ts +78 -0
- package/src/sequencer/automine/README.md +18 -4
- package/src/sequencer/automine/automine_factory.ts +8 -1
- package/src/sequencer/automine/automine_sequencer.ts +221 -20
- package/src/sequencer/automine/index.ts +6 -0
- package/src/sequencer/checkpoint_proposal_job.ts +163 -111
- package/src/sequencer/events.ts +16 -4
- package/src/sequencer/index.ts +0 -2
- package/src/sequencer/requests_tracker.ts +43 -0
- package/src/sequencer/sequencer.ts +361 -187
- package/src/test/index.ts +2 -2
- package/src/test/utils.ts +33 -0
- package/dest/sequencer/chain_state_overrides.d.ts +0 -61
- package/dest/sequencer/chain_state_overrides.d.ts.map +0 -1
- package/dest/sequencer/chain_state_overrides.js +0 -98
- package/dest/sequencer/timetable.d.ts +0 -98
- package/dest/sequencer/timetable.d.ts.map +0 -1
- package/dest/sequencer/timetable.js +0 -227
- package/src/sequencer/chain_state_overrides.ts +0 -162
- package/src/sequencer/timetable.ts +0 -288
|
@@ -435,19 +435,20 @@ function applyDecs2203RFactory() {
|
|
|
435
435
|
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
436
436
|
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
437
437
|
}
|
|
438
|
-
var _dec, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6,
|
|
439
|
-
import {
|
|
438
|
+
var _dec, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _initProto;
|
|
439
|
+
import { PROPOSER_PIPELINING_SLOT_OFFSET } from '@aztec/epoch-cache';
|
|
440
|
+
import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
|
|
440
441
|
import { randomInt } from '@aztec/foundation/crypto/random';
|
|
441
442
|
import { flipSignature, generateRecoverableSignature, generateUnrecoverableSignature } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
443
|
+
import { InterruptError, TimeoutError } from '@aztec/foundation/error';
|
|
442
444
|
import { filter } from '@aztec/foundation/iterator';
|
|
443
445
|
import { createLogger } from '@aztec/foundation/log';
|
|
444
|
-
import {
|
|
445
|
-
import { sleep, sleepUntil } from '@aztec/foundation/sleep';
|
|
446
|
+
import { InterruptibleSleep } from '@aztec/foundation/sleep';
|
|
446
447
|
import { Timer } from '@aztec/foundation/timer';
|
|
447
448
|
import { isErrorClass, unfreeze } from '@aztec/foundation/types';
|
|
448
|
-
import { CommitteeAttestationsAndSigners, MaliciousCommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
449
|
-
import { getPreviousCheckpointOutHashes, validateCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
450
|
-
import { computeQuorum,
|
|
449
|
+
import { CommitteeAttestationsAndSigners, MaliciousCommitteeAttestationsAndSigners, MaliciousYParityCommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
450
|
+
import { buildCheckpointSimulationOverridesPlan, getPreviousCheckpointOutHashes, validateCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
451
|
+
import { computeQuorum, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
451
452
|
import { Gas } from '@aztec/stdlib/gas';
|
|
452
453
|
import { InsufficientValidTxsError } from '@aztec/stdlib/interfaces/server';
|
|
453
454
|
import { computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
|
|
@@ -455,25 +456,24 @@ import { orderAttestations, trimAttestations } from '@aztec/stdlib/p2p';
|
|
|
455
456
|
import { AttestationTimeoutError } from '@aztec/stdlib/validators';
|
|
456
457
|
import { Attributes, trackSpan } from '@aztec/telemetry-client';
|
|
457
458
|
import { DutyAlreadySignedError, SlashingProtectionError } from '@aztec/validator-ha-signer/errors';
|
|
458
|
-
import { buildCheckpointSimulationOverridesPlan } from './chain_state_overrides.js';
|
|
459
459
|
import { CheckpointVoter } from './checkpoint_voter.js';
|
|
460
460
|
import { SequencerInterruptedError } from './errors.js';
|
|
461
461
|
import { SequencerState } from './utils.js';
|
|
462
462
|
/** How much time to sleep while waiting for min transactions to accumulate for a block */ const TXS_POLLING_MS = 500;
|
|
463
|
+
const ARCHIVER_SYNC_POLLING_MS = 200;
|
|
463
464
|
_dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('CheckpointProposalJob.proposeCheckpoint', function() {
|
|
464
465
|
return {
|
|
465
466
|
// nullish operator needed for tests
|
|
466
467
|
[Attributes.COINBASE]: this.validatorClient.getCoinbaseForAttestor(this.attestorAddress)?.toString(),
|
|
467
468
|
[Attributes.SLOT_NUMBER]: this.targetSlot
|
|
468
469
|
};
|
|
469
|
-
}), _dec2 = trackSpan('CheckpointProposalJob.buildBlocksForCheckpoint'), _dec3 = trackSpan('CheckpointProposalJob.waitUntilNextSubslot'), _dec4 = trackSpan('CheckpointProposalJob.buildSingleBlock'), _dec5 = trackSpan('CheckpointProposalJob.waitForMinTxs'), _dec6 = trackSpan('CheckpointProposalJob.waitForAttestations')
|
|
470
|
+
}), _dec2 = trackSpan('CheckpointProposalJob.buildBlocksForCheckpoint'), _dec3 = trackSpan('CheckpointProposalJob.waitUntilNextSubslot'), _dec4 = trackSpan('CheckpointProposalJob.buildSingleBlock'), _dec5 = trackSpan('CheckpointProposalJob.waitForMinTxs'), _dec6 = trackSpan('CheckpointProposalJob.waitForAttestations');
|
|
470
471
|
/**
|
|
471
472
|
* Handles the execution of a checkpoint proposal after the initial preparation phase.
|
|
472
473
|
* This includes building blocks, collecting attestations, and publishing the checkpoint to L1,
|
|
473
474
|
* as well as enqueueing votes for slashing and governance proposals. This class is created from
|
|
474
475
|
* the Sequencer once the check for being the proposer for the slot has succeeded.
|
|
475
476
|
*/ export class CheckpointProposalJob {
|
|
476
|
-
slotNow;
|
|
477
477
|
targetSlot;
|
|
478
478
|
targetEpoch;
|
|
479
479
|
checkpointNumber;
|
|
@@ -501,6 +501,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
501
501
|
metrics;
|
|
502
502
|
checkpointMetrics;
|
|
503
503
|
eventEmitter;
|
|
504
|
+
pendingRequests;
|
|
504
505
|
setStateFn;
|
|
505
506
|
tracer;
|
|
506
507
|
proposedCheckpointData;
|
|
@@ -540,17 +541,13 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
540
541
|
_dec6,
|
|
541
542
|
2,
|
|
542
543
|
"waitForAttestations"
|
|
543
|
-
],
|
|
544
|
-
[
|
|
545
|
-
_dec7,
|
|
546
|
-
2,
|
|
547
|
-
"waitUntilTimeInSlot"
|
|
548
544
|
]
|
|
549
545
|
], []));
|
|
550
546
|
}
|
|
551
547
|
log;
|
|
552
548
|
checkpointEventLog;
|
|
553
|
-
|
|
549
|
+
interruptibleSleep;
|
|
550
|
+
interrupted;
|
|
554
551
|
/**
|
|
555
552
|
* Chain state overrides built once per slot in proposeCheckpoint after the checkpoint is
|
|
556
553
|
* complete. Carries the pending parent override (archive + slot + fee header) for pipelining,
|
|
@@ -560,9 +557,10 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
560
557
|
getSignatureContext() {
|
|
561
558
|
return this.signatureContext;
|
|
562
559
|
}
|
|
563
|
-
constructor(
|
|
564
|
-
proposer, publisher, attestorAddress, invalidateCheckpoint, validatorClient, globalsBuilder, p2pClient, worldState, l1ToL2MessageSource, l2BlockSource, checkpointsBuilder, blockSink, l1Constants, signatureContext, config, timetable, slasherClient, epochCache, dateProvider, metrics, checkpointMetrics, eventEmitter,
|
|
565
|
-
|
|
560
|
+
constructor(targetSlot, targetEpoch, checkpointNumber, syncedToBlockNumber, checkpointedCheckpointNumber, // TODO(palla/mbps): Can we remove the proposer in favor of attestorAddress? Need to check fisherman-node flows.
|
|
561
|
+
proposer, publisher, attestorAddress, invalidateCheckpoint, validatorClient, globalsBuilder, p2pClient, worldState, l1ToL2MessageSource, l2BlockSource, checkpointsBuilder, blockSink, l1Constants, signatureContext, config, timetable, slasherClient, epochCache, dateProvider, metrics, checkpointMetrics, eventEmitter, // Shared with the owning sequencer, which drains it during shutdown; the fire-and-forget L1
|
|
562
|
+
// submission this job backgrounds is tracked here rather than in a job-local tracker.
|
|
563
|
+
pendingRequests, setStateFn, tracer, bindings, proposedCheckpointData){
|
|
566
564
|
this.targetSlot = targetSlot;
|
|
567
565
|
this.targetEpoch = targetEpoch;
|
|
568
566
|
this.checkpointNumber = checkpointNumber;
|
|
@@ -590,22 +588,54 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
590
588
|
this.metrics = metrics;
|
|
591
589
|
this.checkpointMetrics = checkpointMetrics;
|
|
592
590
|
this.eventEmitter = eventEmitter;
|
|
591
|
+
this.pendingRequests = pendingRequests;
|
|
593
592
|
this.setStateFn = setStateFn;
|
|
594
593
|
this.tracer = tracer;
|
|
595
594
|
this.proposedCheckpointData = proposedCheckpointData;
|
|
596
|
-
_initProto(this);
|
|
595
|
+
this.interruptibleSleep = (_initProto(this), new InterruptibleSleep());
|
|
596
|
+
this.interrupted = false;
|
|
597
597
|
this.log = createLogger('sequencer:checkpoint-proposal', {
|
|
598
598
|
...bindings,
|
|
599
|
-
instanceId: `slot-${this.
|
|
599
|
+
instanceId: `slot-${this.getBuildSlot()}`
|
|
600
600
|
});
|
|
601
601
|
this.checkpointEventLog = createLogger('sequencer:checkpoint-events', {
|
|
602
602
|
...bindings,
|
|
603
|
-
instanceId: `slot-${this.
|
|
603
|
+
instanceId: `slot-${this.getBuildSlot()}`
|
|
604
604
|
});
|
|
605
605
|
}
|
|
606
|
-
/**
|
|
607
|
-
|
|
608
|
-
|
|
606
|
+
/**
|
|
607
|
+
* The wall-clock slot during which this job builds, i.e. the slot one before {@link targetSlot} under
|
|
608
|
+
* proposer pipelining. Also the slot of the parent checkpoint this job builds on top of.
|
|
609
|
+
*/ getBuildSlot() {
|
|
610
|
+
return SlotNumber(this.targetSlot - PROPOSER_PIPELINING_SLOT_OFFSET);
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Sets the sequencer state for this job, reporting the target slot the checkpoint is being proposed for
|
|
614
|
+
* (not the wall-clock build slot). The slot is informational on the event payload/metrics; the job knows
|
|
615
|
+
* its own target slot, so callers only pass the state.
|
|
616
|
+
*/ setState(state) {
|
|
617
|
+
this.setStateFn(state, this.targetSlot);
|
|
618
|
+
}
|
|
619
|
+
/** Interrupts job-owned waits, including the publisher's send-at-slot sleep, so shutdown can finish. */ interrupt() {
|
|
620
|
+
this.interrupted = true;
|
|
621
|
+
this.interruptibleSleep.interrupt(true);
|
|
622
|
+
this.publisher.interrupt();
|
|
623
|
+
}
|
|
624
|
+
async awaitInterruptibleSleep(ms) {
|
|
625
|
+
if (this.interrupted) {
|
|
626
|
+
throw new SequencerInterruptedError();
|
|
627
|
+
}
|
|
628
|
+
if (ms <= 0) {
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
try {
|
|
632
|
+
await this.interruptibleSleep.sleep(ms);
|
|
633
|
+
} catch (err) {
|
|
634
|
+
if (err instanceof InterruptError) {
|
|
635
|
+
throw new SequencerInterruptedError();
|
|
636
|
+
}
|
|
637
|
+
throw err;
|
|
638
|
+
}
|
|
609
639
|
}
|
|
610
640
|
logCheckpointEvent(eventName, message, fields) {
|
|
611
641
|
this.checkpointEventLog.debug(message, {
|
|
@@ -636,7 +666,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
636
666
|
// signature verification to fail silently inside Multicall3. Delay submission to the
|
|
637
667
|
// start of `targetSlot` so the tx mines in the slot the vote was signed for.
|
|
638
668
|
if (!this.config.fishermanMode) {
|
|
639
|
-
this.
|
|
669
|
+
this.pendingRequests.trackRequest(this.publisher.sendRequestsAt(this.targetSlot), ()=>this.interrupt());
|
|
640
670
|
}
|
|
641
671
|
return undefined;
|
|
642
672
|
}
|
|
@@ -648,13 +678,13 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
648
678
|
return checkpoint;
|
|
649
679
|
}
|
|
650
680
|
// Background the attestation → signing → L1 pipeline so the work loop is unblocked
|
|
651
|
-
this.
|
|
681
|
+
this.pendingRequests.trackRequest(this.waitForAttestationsAndEnqueueSubmissionAsync(broadcast, votesPromises), ()=>this.interrupt());
|
|
652
682
|
// Return the built checkpoint immediately — the work loop is now unblocked
|
|
653
683
|
return checkpoint;
|
|
654
684
|
}
|
|
655
685
|
/**
|
|
656
686
|
* Background pipeline: collects attestations, signs them, enqueues the checkpoint, and submits to L1.
|
|
657
|
-
* Runs as a fire-and-forget task
|
|
687
|
+
* Runs as a fire-and-forget task tracked in the sequencer's shared tracker so the work loop is unblocked.
|
|
658
688
|
*/ async waitForAttestationsAndEnqueueSubmissionAsync(broadcast, votesPromises) {
|
|
659
689
|
const { checkpoint } = broadcast;
|
|
660
690
|
try {
|
|
@@ -671,7 +701,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
671
701
|
});
|
|
672
702
|
}
|
|
673
703
|
// If we failed to collect attestations, at least check if we need to issue an invalidation
|
|
674
|
-
if (!signedAttestations && await this.waitForSyncedL2SlotNumber(this.
|
|
704
|
+
if (!signedAttestations && await this.waitForSyncedL2SlotNumber(this.getBuildSlot())) {
|
|
675
705
|
const validationStatus = await this.l2BlockSource.getPendingChainValidationStatus();
|
|
676
706
|
if (!validationStatus.valid) {
|
|
677
707
|
this.log.warn(`Checkpoint ${validationStatus.checkpoint.checkpointNumber} has invalid attestations, enqueuing invalidation in spite of attestation collection failure`, {
|
|
@@ -744,11 +774,15 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
744
774
|
}
|
|
745
775
|
/** Enqueues the checkpoint for L1 submission. Called after pipeline sleep in execute(). */ async enqueueCheckpointForSubmission(result) {
|
|
746
776
|
const { checkpoint, attestations, attestationsSignature } = result;
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
777
|
+
this.setState(SequencerState.PUBLISHING_CHECKPOINT);
|
|
778
|
+
// Latest L1 block the propose can still land in for the target slot: the last Ethereum block inside
|
|
779
|
+
// the target slot (`target_slot_start + S - E`). This is one ethereum slot later than
|
|
780
|
+
// `attestation_deadline` (= last_ethereum_block_in_target_slot - E), which bounds when validators must
|
|
781
|
+
// have signed, not when the proposer must have sent. Using the attestation deadline here is too tight:
|
|
782
|
+
// attestations are collected up to (and, when not enforcing, past) it, so the propose tx would be
|
|
783
|
+
// enqueued already expired and time out before it can mine.
|
|
784
|
+
const lastL1BlockInTargetSlot = Number(getTimestampForSlot(this.targetSlot, this.l1Constants)) + this.l1Constants.slotDuration - this.l1Constants.ethereumSlotDuration;
|
|
785
|
+
const txTimeoutAt = new Date(lastL1BlockInTargetSlot * 1000);
|
|
752
786
|
// If we have been configured to potentially skip publishing checkpoint then roll the dice here
|
|
753
787
|
if (this.config.skipPublishingCheckpointsPercent !== undefined && this.config.skipPublishingCheckpointsPercent > 0) {
|
|
754
788
|
const roll = Math.max(0, randomInt(100));
|
|
@@ -771,11 +805,21 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
771
805
|
const syncDelayTolerance = this.l1Constants.ethereumSlotDuration * 2 * 1000;
|
|
772
806
|
const timeoutSeconds = Math.max(0.1, (targetSlotEndMs + syncDelayTolerance - this.dateProvider.now()) / 1000);
|
|
773
807
|
try {
|
|
774
|
-
|
|
808
|
+
const timer = new Timer();
|
|
809
|
+
while(true){
|
|
775
810
|
const syncedSlot = await this.l2BlockSource.getSyncedL2SlotNumber();
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
811
|
+
if (syncedSlot !== undefined && syncedSlot >= waitForSlot) {
|
|
812
|
+
return true;
|
|
813
|
+
}
|
|
814
|
+
if (timeoutSeconds && timer.s() > timeoutSeconds) {
|
|
815
|
+
throw new TimeoutError(`Timeout awaiting archiver sync past slot ${waitForSlot}`);
|
|
816
|
+
}
|
|
817
|
+
await this.awaitInterruptibleSleep(ARCHIVER_SYNC_POLLING_MS);
|
|
818
|
+
}
|
|
819
|
+
} catch (err) {
|
|
820
|
+
if (err instanceof SequencerInterruptedError) {
|
|
821
|
+
throw err;
|
|
822
|
+
}
|
|
779
823
|
this.log.warn(`Archiver did not sync L1 past slot ${waitForSlot} before slot ${this.targetSlot} expired, discarding pipelined work`, {
|
|
780
824
|
checkpointNumber: this.checkpointNumber
|
|
781
825
|
});
|
|
@@ -797,8 +841,8 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
797
841
|
return true;
|
|
798
842
|
}
|
|
799
843
|
const parentCheckpointNumber = CheckpointNumber(this.checkpointNumber - 1);
|
|
800
|
-
// Wait until archiver has synced L1 past the parent's slot (
|
|
801
|
-
if (!await this.waitForSyncedL2SlotNumber(this.
|
|
844
|
+
// Wait until archiver has synced L1 past the parent's slot (the build slot, one before targetSlot)
|
|
845
|
+
if (!await this.waitForSyncedL2SlotNumber(this.getBuildSlot())) {
|
|
802
846
|
return false;
|
|
803
847
|
}
|
|
804
848
|
const tips = await this.l2BlockSource.getL2Tips();
|
|
@@ -895,7 +939,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
895
939
|
// Measure against the wall-clock slot whose build window we are currently using.
|
|
896
940
|
// In pipelining mode `targetSlot` is intentionally one slot ahead, which makes the
|
|
897
941
|
// target-slot boundary a full slot away from the actual build start time.
|
|
898
|
-
const slotBoundaryMs = Number(getTimestampForSlot(this.
|
|
942
|
+
const slotBoundaryMs = Number(getTimestampForSlot(this.getBuildSlot(), this.l1Constants)) * 1000;
|
|
899
943
|
this.checkpointMetrics.recordPipelinedCheckpointBuildStartOffsetFromSlotBoundary(now - slotBoundaryMs);
|
|
900
944
|
}
|
|
901
945
|
this.checkpointMetrics.startCheckpointTiming(now);
|
|
@@ -903,9 +947,9 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
903
947
|
const coinbase = this.validatorClient.getCoinbaseForAttestor(this.attestorAddress);
|
|
904
948
|
const feeRecipient = this.validatorClient.getFeeRecipientForAttestor(this.attestorAddress);
|
|
905
949
|
// Start the checkpoint
|
|
906
|
-
this.
|
|
950
|
+
this.setState(SequencerState.INITIALIZING_CHECKPOINT);
|
|
907
951
|
this.logCheckpointEvent('slot-started', `Starting checkpoint proposal for slot ${this.targetSlot}`, {
|
|
908
|
-
buildSlot: this.
|
|
952
|
+
buildSlot: this.getBuildSlot(),
|
|
909
953
|
submissionSlot: this.targetSlot,
|
|
910
954
|
slot: this.targetSlot,
|
|
911
955
|
checkpointNumber: this.checkpointNumber,
|
|
@@ -1021,7 +1065,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1021
1065
|
}
|
|
1022
1066
|
// Assemble and broadcast the checkpoint proposal, including the last block that was not
|
|
1023
1067
|
// broadcasted yet, and wait to collect the committee attestations.
|
|
1024
|
-
this.
|
|
1068
|
+
this.setState(SequencerState.ASSEMBLING_CHECKPOINT);
|
|
1025
1069
|
const checkpoint = await checkpointBuilder.completeCheckpoint();
|
|
1026
1070
|
// Final validation: per-block limits are only checked if the operator set them explicitly.
|
|
1027
1071
|
// Otherwise, checkpoint-level budgets were already enforced by the redistribution logic.
|
|
@@ -1041,7 +1085,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1041
1085
|
reason: 'invalid_checkpoint',
|
|
1042
1086
|
checkpoint: checkpoint.header.toInspect()
|
|
1043
1087
|
});
|
|
1044
|
-
this.log.error(`Built an invalid checkpoint at slot ${this.
|
|
1088
|
+
this.log.error(`Built an invalid checkpoint at slot ${this.targetSlot} (skipping proposal)`, err, {
|
|
1045
1089
|
slot: this.targetSlot,
|
|
1046
1090
|
checkpointNumber: this.checkpointNumber,
|
|
1047
1091
|
blocksBuilt: blocksInCheckpoint.length,
|
|
@@ -1054,7 +1098,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1054
1098
|
this.checkpointMetrics.recordCheckpointBuild(checkpointBuildTimer.ms(), blocksInCheckpoint.length, checkpoint.getStats().txCount, Number(checkpoint.header.totalManaUsed.toBigInt()));
|
|
1055
1099
|
this.logCheckpointEvent('built', `Checkpoint built for slot ${this.targetSlot}`, {
|
|
1056
1100
|
slot: this.targetSlot,
|
|
1057
|
-
buildSlot: this.
|
|
1101
|
+
buildSlot: this.getBuildSlot(),
|
|
1058
1102
|
checkpointNumber: this.checkpointNumber,
|
|
1059
1103
|
proposer: this.proposer?.toString(),
|
|
1060
1104
|
attestorAddress: this.attestorAddress.toString(),
|
|
@@ -1159,13 +1203,13 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1159
1203
|
});
|
|
1160
1204
|
break;
|
|
1161
1205
|
}
|
|
1162
|
-
const
|
|
1163
|
-
const timingInfo = this.timetable.
|
|
1206
|
+
const nowSeconds = this.dateProvider.now() / 1000;
|
|
1207
|
+
const timingInfo = this.timetable.selectNextSubslot(this.targetSlot, nowSeconds);
|
|
1164
1208
|
if (!timingInfo.canStart) {
|
|
1165
1209
|
this.log.debug(`Not enough time left in slot to start another block`, {
|
|
1166
1210
|
slot: this.targetSlot,
|
|
1167
1211
|
blocksBuilt,
|
|
1168
|
-
|
|
1212
|
+
nowSeconds
|
|
1169
1213
|
});
|
|
1170
1214
|
break;
|
|
1171
1215
|
}
|
|
@@ -1174,16 +1218,15 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1174
1218
|
blockTimestamp: timestamp,
|
|
1175
1219
|
// Create an empty block if we haven't already and this is the last one
|
|
1176
1220
|
forceCreate: timingInfo.isLastBlock && blocksBuilt === 0 && this.config.buildCheckpointIfEmpty,
|
|
1177
|
-
|
|
1178
|
-
buildDeadline: timingInfo.deadline ? new Date((this.getSlotStartBuildTimestamp() + timingInfo.deadline) * 1000) : undefined,
|
|
1221
|
+
buildDeadline: new Date(timingInfo.deadline * 1000),
|
|
1179
1222
|
blockNumber,
|
|
1180
1223
|
indexWithinCheckpoint,
|
|
1181
1224
|
txHashesAlreadyIncluded
|
|
1182
1225
|
});
|
|
1183
1226
|
// If we failed to build the block due to insufficient txs, we try again if there is still time left in the slot
|
|
1184
1227
|
if ('failure' in buildResult) {
|
|
1185
|
-
// If this was the last subslot,
|
|
1186
|
-
if (timingInfo.isLastBlock
|
|
1228
|
+
// If this was the last subslot, we're done.
|
|
1229
|
+
if (timingInfo.isLastBlock) {
|
|
1187
1230
|
break;
|
|
1188
1231
|
}
|
|
1189
1232
|
// Otherwise, if there is still time for more blocks, we wait until the next subslot and try again
|
|
@@ -1252,12 +1295,15 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1252
1295
|
}
|
|
1253
1296
|
return this.validatorClient.createBlockProposal(block.header, this.checkpointNumber, block.indexWithinCheckpoint, inHash, block.archive.root, usedTxs, this.proposer, blockProposalOptions);
|
|
1254
1297
|
}
|
|
1255
|
-
/**
|
|
1256
|
-
|
|
1257
|
-
|
|
1298
|
+
/**
|
|
1299
|
+
* Sleeps until it is time to produce the next block in the slot.
|
|
1300
|
+
* @param nextSubslotStart - Absolute wall-clock timestamp in seconds of the previous sub-slot deadline.
|
|
1301
|
+
*/ async waitUntilNextSubslot(nextSubslotStart) {
|
|
1302
|
+
this.setState(SequencerState.WAITING_UNTIL_NEXT_BLOCK);
|
|
1303
|
+
this.log.verbose(`Waiting until time for the next block at ${nextSubslotStart}s`, {
|
|
1258
1304
|
slot: this.targetSlot
|
|
1259
1305
|
});
|
|
1260
|
-
await this.
|
|
1306
|
+
await this.awaitInterruptibleSleep(Math.max(0, nextSubslotStart * 1000 - this.dateProvider.now()));
|
|
1261
1307
|
}
|
|
1262
1308
|
/** Builds a single block. Called from the main block building loop. */ async buildSingleBlock(checkpointBuilder, opts) {
|
|
1263
1309
|
const { blockTimestamp, forceCreate, blockNumber, indexWithinCheckpoint, buildDeadline, txHashesAlreadyIncluded } = opts;
|
|
@@ -1267,7 +1313,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1267
1313
|
});
|
|
1268
1314
|
try {
|
|
1269
1315
|
// Wait until we have enough txs to build the block
|
|
1270
|
-
const {
|
|
1316
|
+
const { canStartBuilding, minTxs } = await this.waitForMinTxs(opts);
|
|
1271
1317
|
if (!canStartBuilding) {
|
|
1272
1318
|
this.logCheckpointEvent('block-build-failed', `Block build failed for slot ${this.targetSlot}`, {
|
|
1273
1319
|
reason: 'insufficient_txs',
|
|
@@ -1275,21 +1321,18 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1275
1321
|
slot: this.targetSlot,
|
|
1276
1322
|
checkpointNumber: this.checkpointNumber,
|
|
1277
1323
|
indexWithinCheckpoint,
|
|
1278
|
-
availableTxs,
|
|
1279
1324
|
minTxs
|
|
1280
1325
|
});
|
|
1281
|
-
this.log.
|
|
1326
|
+
this.log.verbose(`Not enough age-eligible txs to build block ${blockNumber} at index ${indexWithinCheckpoint} in slot ${this.targetSlot} (needs ${minTxs} eligible)`, {
|
|
1282
1327
|
reason: 'insufficient_txs',
|
|
1283
1328
|
blockNumber,
|
|
1284
1329
|
slot: this.targetSlot,
|
|
1285
1330
|
checkpointNumber: this.checkpointNumber,
|
|
1286
1331
|
indexWithinCheckpoint,
|
|
1287
|
-
availableTxs,
|
|
1288
1332
|
minTxs
|
|
1289
1333
|
});
|
|
1290
1334
|
this.eventEmitter.emit('block-tx-count-check-failed', {
|
|
1291
1335
|
minTxs,
|
|
1292
|
-
availableTxs,
|
|
1293
1336
|
slot: this.targetSlot
|
|
1294
1337
|
});
|
|
1295
1338
|
this.metrics.recordBlockProposalFailed('insufficient_txs');
|
|
@@ -1299,13 +1342,17 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1299
1342
|
}
|
|
1300
1343
|
// Create iterator to pending txs. We filter out txs already included in previous blocks in the checkpoint
|
|
1301
1344
|
// just in case p2p failed to sync the provisional block and didn't get to remove those txs from the mempool yet.
|
|
1302
|
-
|
|
1303
|
-
|
|
1345
|
+
// Block building only executes txs, so we skip loading their proofs unless these same tx objects get attached
|
|
1346
|
+
// to the broadcasted proposals via publishTxsWithProposals.
|
|
1347
|
+
const pendingTxs = filter(this.p2pClient.iterateEligiblePendingTxs({
|
|
1348
|
+
includeProof: !!this.config.publishTxsWithProposals
|
|
1349
|
+
}), (tx)=>!txHashesAlreadyIncluded.has(tx.txHash.toString()));
|
|
1350
|
+
this.log.debug(`Building block ${blockNumber} at index ${indexWithinCheckpoint} for slot ${this.targetSlot}`, {
|
|
1304
1351
|
slot: this.targetSlot,
|
|
1305
1352
|
blockNumber,
|
|
1306
1353
|
indexWithinCheckpoint
|
|
1307
1354
|
});
|
|
1308
|
-
this.
|
|
1355
|
+
this.setState(SequencerState.CREATING_BLOCK);
|
|
1309
1356
|
// Per-block limits are operator overrides (from SEQ_MAX_L2_BLOCK_GAS etc.) further capped
|
|
1310
1357
|
// by remaining checkpoint-level budgets inside CheckpointBuilder before each block is built.
|
|
1311
1358
|
// minValidTxs is passed into the builder so it can reject the block *before* updating state.
|
|
@@ -1316,8 +1363,9 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1316
1363
|
deadline: buildDeadline,
|
|
1317
1364
|
isBuildingProposal: true,
|
|
1318
1365
|
minValidTxs,
|
|
1319
|
-
maxBlocksPerCheckpoint: this.timetable.
|
|
1320
|
-
perBlockAllocationMultiplier: this.config.perBlockAllocationMultiplier
|
|
1366
|
+
maxBlocksPerCheckpoint: this.timetable.getMaxBlocksPerCheckpoint(),
|
|
1367
|
+
perBlockAllocationMultiplier: this.config.perBlockAllocationMultiplier,
|
|
1368
|
+
perBlockDAAllocationMultiplier: this.config.perBlockDAAllocationMultiplier
|
|
1321
1369
|
};
|
|
1322
1370
|
// Actually build the block by executing txs. The builder throws InsufficientValidTxsError
|
|
1323
1371
|
// if the number of successfully processed txs is below minValidTxs, ensuring state is not
|
|
@@ -1378,7 +1426,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1378
1426
|
checkpointNumber: this.checkpointNumber,
|
|
1379
1427
|
indexWithinCheckpoint: block.indexWithinCheckpoint,
|
|
1380
1428
|
slot: this.targetSlot,
|
|
1381
|
-
buildSlot: this.
|
|
1429
|
+
buildSlot: this.getBuildSlot()
|
|
1382
1430
|
});
|
|
1383
1431
|
this.metrics.recordBuiltBlock(blockBuildDuration, block.header.totalManaUsed.toNumberUnsafe(), this.targetSlot);
|
|
1384
1432
|
return {
|
|
@@ -1434,38 +1482,37 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1434
1482
|
const { indexWithinCheckpoint, blockNumber, buildDeadline, forceCreate } = opts;
|
|
1435
1483
|
// We only allow a block with 0 txs in the first block of the checkpoint
|
|
1436
1484
|
const minTxs = indexWithinCheckpoint > 0 && this.config.minTxsPerBlock === 0 ? 1 : this.config.minTxsPerBlock;
|
|
1437
|
-
//
|
|
1438
|
-
const startBuildingDeadline = buildDeadline ? new Date(buildDeadline.getTime() - this.timetable.
|
|
1439
|
-
|
|
1440
|
-
|
|
1485
|
+
// Latest time to keep waiting for txs: wait_for_txs_deadline = block_build_deadline(k) - min_block_duration.
|
|
1486
|
+
const startBuildingDeadline = buildDeadline ? new Date(buildDeadline.getTime() - this.timetable.minBlockDuration * 1000) : undefined;
|
|
1487
|
+
// Gate on age-eligible txs so we don't start building on txs the builder would then filter out for being
|
|
1488
|
+
// too fresh. hasEligiblePendingTxs early-exits once minTxs are eligible instead of counting the whole pool.
|
|
1489
|
+
while(!forceCreate && !await this.p2pClient.hasEligiblePendingTxs(minTxs)){
|
|
1441
1490
|
// If we're past deadline, or we have no deadline, give up
|
|
1442
1491
|
const now = this.dateProvider.nowAsDate();
|
|
1443
1492
|
if (startBuildingDeadline === undefined || now >= startBuildingDeadline) {
|
|
1444
1493
|
return {
|
|
1445
1494
|
canStartBuilding: false,
|
|
1446
|
-
availableTxs,
|
|
1447
1495
|
minTxs
|
|
1448
1496
|
};
|
|
1449
1497
|
}
|
|
1450
1498
|
// Wait a bit before checking again
|
|
1451
|
-
this.
|
|
1452
|
-
this.log.verbose(`Waiting for
|
|
1499
|
+
this.setState(SequencerState.WAITING_FOR_TXS);
|
|
1500
|
+
this.log.verbose(`Waiting for ${minTxs} age-eligible txs to build block ${blockNumber} at index ${indexWithinCheckpoint} in slot ${this.targetSlot}`, {
|
|
1453
1501
|
blockNumber,
|
|
1454
1502
|
slot: this.targetSlot,
|
|
1455
|
-
indexWithinCheckpoint
|
|
1503
|
+
indexWithinCheckpoint,
|
|
1504
|
+
minTxs
|
|
1456
1505
|
});
|
|
1457
1506
|
await this.waitForTxsPollingInterval();
|
|
1458
|
-
availableTxs = await this.p2pClient.getPendingTxCount();
|
|
1459
1507
|
}
|
|
1460
1508
|
return {
|
|
1461
1509
|
canStartBuilding: true,
|
|
1462
|
-
availableTxs,
|
|
1463
1510
|
minTxs
|
|
1464
1511
|
};
|
|
1465
1512
|
}
|
|
1466
1513
|
async getSignedCommitteeAttestations(broadcast) {
|
|
1467
1514
|
const { proposal, blockProposedAt } = broadcast;
|
|
1468
|
-
this.
|
|
1515
|
+
this.setState(SequencerState.COLLECTING_ATTESTATIONS);
|
|
1469
1516
|
const attestations = await this.waitForAttestations(proposal);
|
|
1470
1517
|
if (!attestations) {
|
|
1471
1518
|
return undefined;
|
|
@@ -1516,9 +1563,10 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1516
1563
|
});
|
|
1517
1564
|
return new CommitteeAttestationsAndSigners(orderAttestations(attestations ?? [], committee), this.getSignatureContext());
|
|
1518
1565
|
}
|
|
1519
|
-
|
|
1520
|
-
const
|
|
1521
|
-
|
|
1566
|
+
// Hard attestation-collection cutoff = the single consensus attestation_deadline (target_slot_start + S - 2E).
|
|
1567
|
+
const attestationDeadlineSeconds = this.timetable.getAttestationDeadline(this.targetSlot);
|
|
1568
|
+
const attestationDeadline = new Date(attestationDeadlineSeconds * 1000);
|
|
1569
|
+
this.metrics.recordRequiredAttestations(numberOfRequiredAttestations, Math.max(0, attestationDeadline.getTime() - this.dateProvider.now()));
|
|
1522
1570
|
const collectAttestationsTimer = new Timer();
|
|
1523
1571
|
let collectedAttestationsCount = 0;
|
|
1524
1572
|
try {
|
|
@@ -1536,7 +1584,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1536
1584
|
submittedCount: trimmed.length
|
|
1537
1585
|
});
|
|
1538
1586
|
// Manipulate the attestations if we've been configured to do so
|
|
1539
|
-
if (this.config.injectFakeAttestation || this.config.injectHighSValueAttestation || this.config.injectUnrecoverableSignatureAttestation || this.config.shuffleAttestationOrdering) {
|
|
1587
|
+
if (this.config.injectFakeAttestation || this.config.injectHighSValueAttestation || this.config.injectUnrecoverableSignatureAttestation || this.config.injectYParityAttestation || this.config.shuffleAttestationOrdering) {
|
|
1540
1588
|
return this.manipulateAttestations(proposal.slotNumber, epoch, seed, committee, sorted);
|
|
1541
1589
|
}
|
|
1542
1590
|
return new CommitteeAttestationsAndSigners(sorted, this.getSignatureContext());
|
|
@@ -1608,6 +1656,14 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1608
1656
|
}
|
|
1609
1657
|
return new CommitteeAttestationsAndSigners(attestations, this.getSignatureContext());
|
|
1610
1658
|
}
|
|
1659
|
+
if (this.config.injectYParityAttestation) {
|
|
1660
|
+
// Force every non-proposer signed slot's recovery byte to yParity (v ∈ {0, 1}) form in the packed L1
|
|
1661
|
+
// tuple, after packAttestations has canonicalized it. The proposer's own slot is left canonical so
|
|
1662
|
+
// propose() still passes verifyProposer. Models a malicious proposer landing a checkpoint L1 accepts
|
|
1663
|
+
// but that can never be proven (ECDSA.recover rejects v ∉ {27, 28}).
|
|
1664
|
+
this.log.warn(`Injecting yParity attestations in checkpoint for slot ${slotNumber} (proposer #${proposerIndex})`);
|
|
1665
|
+
return new MaliciousYParityCommitteeAttestationsAndSigners(attestations, proposerIndex, this.getSignatureContext());
|
|
1666
|
+
}
|
|
1611
1667
|
if (this.config.shuffleAttestationOrdering) {
|
|
1612
1668
|
this.log.warn(`Shuffling attestation ordering in checkpoint for slot ${slotNumber} (proposer #${proposerIndex})`);
|
|
1613
1669
|
const shuffled = [
|
|
@@ -1736,20 +1792,8 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1736
1792
|
}
|
|
1737
1793
|
return false;
|
|
1738
1794
|
}
|
|
1739
|
-
/** Waits until a specific time within the current slot */ async waitUntilTimeInSlot(targetSecondsIntoSlot) {
|
|
1740
|
-
const slotStartTimestamp = this.getSlotStartBuildTimestamp();
|
|
1741
|
-
const targetTimestamp = slotStartTimestamp + targetSecondsIntoSlot;
|
|
1742
|
-
await sleepUntil(new Date(targetTimestamp * 1000), this.dateProvider.nowAsDate());
|
|
1743
|
-
}
|
|
1744
1795
|
/** Waits the polling interval for transactions. Extracted for test overriding. */ async waitForTxsPollingInterval() {
|
|
1745
|
-
await
|
|
1746
|
-
}
|
|
1747
|
-
getSlotStartBuildTimestamp() {
|
|
1748
|
-
return getSlotStartBuildTimestamp(this.slotNow, this.l1Constants);
|
|
1749
|
-
}
|
|
1750
|
-
getSecondsIntoSlot() {
|
|
1751
|
-
const slotStartTimestamp = this.getSlotStartBuildTimestamp();
|
|
1752
|
-
return Number((this.dateProvider.now() / 1000 - slotStartTimestamp).toFixed(3));
|
|
1796
|
+
await this.awaitInterruptibleSleep(TXS_POLLING_MS);
|
|
1753
1797
|
}
|
|
1754
1798
|
getPublisher() {
|
|
1755
1799
|
return this.publisher;
|
|
@@ -3,12 +3,24 @@ import type { BlockHash } from '@aztec/stdlib/block';
|
|
|
3
3
|
import type { Action } from '../publisher/sequencer-publisher.js';
|
|
4
4
|
import type { SequencerState } from './utils.js';
|
|
5
5
|
export type SequencerEvents = {
|
|
6
|
+
/**
|
|
7
|
+
* Emitted on every sequencer state transition (including no-op transitions to the same state). The
|
|
8
|
+
* timing fields are anchored to the build frame of the slot being proposed for, not to wall-clock
|
|
9
|
+
* slot boundaries, because the proposer builds for `targetSlot` during the previous (build) slot.
|
|
10
|
+
*
|
|
11
|
+
* - `oldState` / `newState` are the previous and new {@link SequencerState}.
|
|
12
|
+
* - `secondsIntoBuildFrame` is the wall-clock seconds elapsed since the build-frame start of
|
|
13
|
+
* `targetSlot` (`now − getBuildFrameStart(targetSlot)`). Undefined for lifecycle states with no
|
|
14
|
+
* associated slot (e.g. IDLE/STOPPING). It can be negative if the transition happens before the
|
|
15
|
+
* build frame opens.
|
|
16
|
+
* - `targetSlot` is the slot the checkpoint is being proposed for (the submission slot, one ahead of
|
|
17
|
+
* the wall-clock build slot under pipelining). Undefined for lifecycle states with no slot.
|
|
18
|
+
*/
|
|
6
19
|
['state-changed']: (args: {
|
|
7
20
|
oldState: SequencerState;
|
|
8
21
|
newState: SequencerState;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
timeReferenceSlot?: SlotNumber;
|
|
22
|
+
secondsIntoBuildFrame?: number;
|
|
23
|
+
targetSlot?: SlotNumber;
|
|
12
24
|
}) => void;
|
|
13
25
|
/**
|
|
14
26
|
* Emitted by the sequencer once it has decided it is going to attempt to build a
|
|
@@ -40,7 +52,6 @@ export type SequencerEvents = {
|
|
|
40
52
|
}) => void;
|
|
41
53
|
['block-tx-count-check-failed']: (args: {
|
|
42
54
|
minTxs: number;
|
|
43
|
-
availableTxs: number;
|
|
44
55
|
slot: SlotNumber;
|
|
45
56
|
}) => void;
|
|
46
57
|
['block-build-failed']: (args: {
|
|
@@ -89,4 +100,4 @@ export type SequencerEvents = {
|
|
|
89
100
|
reason: string;
|
|
90
101
|
}) => void;
|
|
91
102
|
};
|
|
92
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
103
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXZlbnRzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2VxdWVuY2VyL2V2ZW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsZ0JBQWdCLEVBQUUscUJBQXFCLEVBQUUsVUFBVSxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDeEgsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFFckQsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0scUNBQXFDLENBQUM7QUFDbEUsT0FBTyxLQUFLLEVBQUUsY0FBYyxFQUFFLE1BQU0sWUFBWSxDQUFDO0FBRWpELE1BQU0sTUFBTSxlQUFlLEdBQUc7SUFDNUI7Ozs7Ozs7Ozs7OztPQVlHO0lBQ0gsQ0FBQyxlQUFlLENBQUMsRUFBRSxDQUFDLElBQUksRUFBRTtRQUN4QixRQUFRLEVBQUUsY0FBYyxDQUFDO1FBQ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RTtRQUFFLEtBQUssRUFBRSxLQUFLLENBQUE7S0FBRSxLQUFLLElBQUksQ0FBQztJQUN2RCxDQUFDLGdDQUFnQyxDQUFDLEVBQUUsQ0FBQyxJQUFJLEVBQUU7UUFDekMsSUFBSSxFQUFFLFVBQVUsQ0FBQztRQUNqQixnQkFBZ0IsRUFBRSxnQkFBZ0IsQ0FBQztRQUNuQyxNQUFNLEVBQUUsTUFBTSxDQUFDO0tBQ2hCLEtBQUssSUFBSSxDQUFDO0NBQ1osQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/sequencer/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AACxH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE;QACxB,QAAQ,EAAE,cAAc,CAAC;QACzB,QAAQ,EAAE,cAAc,CAAC;QACzB,
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/sequencer/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AACxH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;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EAAE;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,KAAK,IAAI,CAAC;IAC3D;;;;;OAKG;IACH,CAAC,0BAA0B,CAAC,EAAE,CAAC,IAAI,EAAE;QACnC,IAAI,EAAE,UAAU,CAAC;QACjB,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,MAAM,EAAE,MAAM,CAAC;KAChB,KAAK,IAAI,CAAC;IACX,CAAC,2BAA2B,CAAC,EAAE,CAAC,IAAI,EAAE;QACpC,IAAI,EAAE,UAAU,CAAC;QACjB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;QAC7B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;QACzB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;KAC3B,KAAK,IAAI,CAAC;IACX,CAAC,sBAAsB,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,UAAU,EAAE,gBAAgB,CAAC;QAAC,IAAI,EAAE,UAAU,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7F,CAAC,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,KAAK,IAAI,CAAC;IACvD,CAAC,gCAAgC,CAAC,EAAE,CAAC,IAAI,EAAE;QACzC,IAAI,EAAE,UAAU,CAAC;QACjB,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,MAAM,EAAE,MAAM,CAAC;KAChB,KAAK,IAAI,CAAC;CACZ,CAAC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export * from './automine/automine_factory.js';
|
|
2
|
-
export * from './automine/automine_sequencer.js';
|
|
3
1
|
export * from './checkpoint_proposal_job.js';
|
|
4
2
|
export * from './checkpoint_voter.js';
|
|
5
3
|
export * from './config.js';
|
|
6
4
|
export * from './events.js';
|
|
7
5
|
export * from './sequencer.js';
|
|
8
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zZXF1ZW5jZXIvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyw4QkFBOEIsQ0FBQztBQUM3QyxjQUFjLHVCQUF1QixDQUFDO0FBQ3RDLGNBQWMsYUFBYSxDQUFDO0FBQzVCLGNBQWMsYUFBYSxDQUFDO0FBQzVCLGNBQWMsZ0JBQWdCLENBQUMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sequencer/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sequencer/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
|