@aztec/sequencer-client 0.0.1-commit.0c875d939 → 0.0.1-commit.0ec55a70b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/client/sequencer-client.d.ts +17 -7
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +63 -30
- package/dest/config.d.ts +27 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +55 -30
- 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 +58 -0
- package/dest/global_variable_builder/global_builder.d.ts +15 -16
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +16 -50
- 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 +47 -17
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +121 -42
- package/dest/publisher/index.d.ts +2 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +58 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/index.js +2 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +11 -5
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +27 -3
- package/dest/publisher/sequencer-publisher.d.ts +68 -48
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +421 -137
- package/dest/sequencer/chain_state_overrides.d.ts +25 -0
- package/dest/sequencer/chain_state_overrides.d.ts.map +1 -0
- package/dest/sequencer/chain_state_overrides.js +39 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts +46 -10
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +700 -220
- 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/events.d.ts +7 -1
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/metrics.d.ts +20 -8
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +92 -21
- package/dest/sequencer/sequencer.d.ts +53 -19
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +188 -102
- package/dest/sequencer/timetable.d.ts +17 -3
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +51 -43
- package/dest/sequencer/types.d.ts +2 -2
- package/dest/sequencer/types.d.ts.map +1 -1
- package/dest/test/index.d.ts +3 -5
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +7 -9
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +39 -30
- package/dest/test/utils.d.ts +1 -1
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +7 -6
- package/package.json +27 -28
- package/src/client/sequencer-client.ts +81 -30
- package/src/config.ts +68 -35
- 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 +75 -0
- package/src/global_variable_builder/global_builder.ts +27 -63
- package/src/global_variable_builder/index.ts +3 -1
- package/src/publisher/config.ts +157 -45
- package/src/publisher/index.ts +3 -0
- package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +57 -0
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
- package/src/publisher/l1_tx_failed_store/index.ts +3 -0
- package/src/publisher/sequencer-publisher-factory.ts +38 -9
- package/src/publisher/sequencer-publisher.ts +474 -197
- package/src/sequencer/README.md +82 -13
- package/src/sequencer/chain_state_overrides.ts +87 -0
- package/src/sequencer/checkpoint_proposal_job.ts +866 -241
- package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
- package/src/sequencer/checkpoint_voter.ts +1 -12
- package/src/sequencer/events.ts +6 -1
- package/src/sequencer/metrics.ts +108 -25
- package/src/sequencer/sequencer.ts +262 -116
- package/src/sequencer/timetable.ts +64 -52
- package/src/sequencer/types.ts +1 -1
- package/src/test/index.ts +2 -4
- package/src/test/mock_checkpoint_builder.ts +51 -48
- package/src/test/utils.ts +28 -10
|
@@ -436,25 +436,26 @@ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
436
436
|
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
437
437
|
}
|
|
438
438
|
var _dec, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _initProto;
|
|
439
|
-
import {
|
|
440
|
-
import { BLOBS_PER_CHECKPOINT, FIELDS_PER_BLOB } from '@aztec/constants';
|
|
441
|
-
import { BlockNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
439
|
+
import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
442
440
|
import { randomInt } from '@aztec/foundation/crypto/random';
|
|
443
|
-
import {
|
|
441
|
+
import { flipSignature, generateRecoverableSignature, generateUnrecoverableSignature } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
444
442
|
import { filter } from '@aztec/foundation/iterator';
|
|
445
443
|
import { createLogger } from '@aztec/foundation/log';
|
|
444
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
446
445
|
import { sleep, sleepUntil } from '@aztec/foundation/sleep';
|
|
447
446
|
import { Timer } from '@aztec/foundation/timer';
|
|
448
447
|
import { isErrorClass, unfreeze } from '@aztec/foundation/types';
|
|
449
448
|
import { CommitteeAttestationsAndSigners, MaliciousCommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
450
|
-
import {
|
|
449
|
+
import { validateCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
450
|
+
import { computeQuorum, getSlotStartBuildTimestamp, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
451
451
|
import { Gas } from '@aztec/stdlib/gas';
|
|
452
|
-
import {
|
|
452
|
+
import { InsufficientValidTxsError } from '@aztec/stdlib/interfaces/server';
|
|
453
453
|
import { computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
|
|
454
|
-
import { orderAttestations } from '@aztec/stdlib/p2p';
|
|
454
|
+
import { orderAttestations, trimAttestations } from '@aztec/stdlib/p2p';
|
|
455
455
|
import { AttestationTimeoutError } from '@aztec/stdlib/validators';
|
|
456
456
|
import { Attributes, trackSpan } from '@aztec/telemetry-client';
|
|
457
457
|
import { DutyAlreadySignedError, SlashingProtectionError } from '@aztec/validator-ha-signer/errors';
|
|
458
|
+
import { buildPipelinedParentSimulationOverridesPlan, buildSubmissionSimulationOverridesPlan } from './chain_state_overrides.js';
|
|
458
459
|
import { CheckpointVoter } from './checkpoint_voter.js';
|
|
459
460
|
import { SequencerInterruptedError } from './errors.js';
|
|
460
461
|
import { SequencerState } from './utils.js';
|
|
@@ -463,7 +464,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
463
464
|
return {
|
|
464
465
|
// nullish operator needed for tests
|
|
465
466
|
[Attributes.COINBASE]: this.validatorClient.getCoinbaseForAttestor(this.attestorAddress)?.toString(),
|
|
466
|
-
[Attributes.SLOT_NUMBER]: this.
|
|
467
|
+
[Attributes.SLOT_NUMBER]: this.targetSlot
|
|
467
468
|
};
|
|
468
469
|
}), _dec2 = trackSpan('CheckpointProposalJob.buildBlocksForCheckpoint'), _dec3 = trackSpan('CheckpointProposalJob.waitUntilNextSubslot'), _dec4 = trackSpan('CheckpointProposalJob.buildSingleBlock'), _dec5 = trackSpan('CheckpointProposalJob.waitForMinTxs'), _dec6 = trackSpan('CheckpointProposalJob.waitForAttestations'), _dec7 = trackSpan('CheckpointProposalJob.waitUntilTimeInSlot');
|
|
469
470
|
/**
|
|
@@ -472,8 +473,9 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
472
473
|
* as well as enqueueing votes for slashing and governance proposals. This class is created from
|
|
473
474
|
* the Sequencer once the check for being the proposer for the slot has succeeded.
|
|
474
475
|
*/ export class CheckpointProposalJob {
|
|
475
|
-
|
|
476
|
-
|
|
476
|
+
slotNow;
|
|
477
|
+
targetSlot;
|
|
478
|
+
targetEpoch;
|
|
477
479
|
checkpointNumber;
|
|
478
480
|
syncedToBlockNumber;
|
|
479
481
|
proposer;
|
|
@@ -489,15 +491,18 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
489
491
|
checkpointsBuilder;
|
|
490
492
|
blockSink;
|
|
491
493
|
l1Constants;
|
|
494
|
+
signatureContext;
|
|
492
495
|
config;
|
|
493
496
|
timetable;
|
|
494
497
|
slasherClient;
|
|
495
498
|
epochCache;
|
|
496
499
|
dateProvider;
|
|
497
500
|
metrics;
|
|
501
|
+
checkpointMetrics;
|
|
498
502
|
eventEmitter;
|
|
499
503
|
setStateFn;
|
|
500
504
|
tracer;
|
|
505
|
+
proposedCheckpointData;
|
|
501
506
|
static{
|
|
502
507
|
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
503
508
|
[
|
|
@@ -543,10 +548,17 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
543
548
|
], []));
|
|
544
549
|
}
|
|
545
550
|
log;
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
551
|
+
checkpointEventLog;
|
|
552
|
+
/** Tracks the fire-and-forget L1 submission promise so it can be awaited during shutdown. */ pendingL1Submission;
|
|
553
|
+
/** Pipelined parent chain state used while building and later submitting this checkpoint. */ pipelinedParentSimulationOverridesPlan;
|
|
554
|
+
getSignatureContext() {
|
|
555
|
+
return this.signatureContext;
|
|
556
|
+
}
|
|
557
|
+
constructor(slotNow, targetSlot, targetEpoch, checkpointNumber, syncedToBlockNumber, // TODO(palla/mbps): Can we remove the proposer in favor of attestorAddress? Need to check fisherman-node flows.
|
|
558
|
+
proposer, publisher, attestorAddress, invalidateCheckpoint, validatorClient, globalsBuilder, p2pClient, worldState, l1ToL2MessageSource, l2BlockSource, checkpointsBuilder, blockSink, l1Constants, signatureContext, config, timetable, slasherClient, epochCache, dateProvider, metrics, checkpointMetrics, eventEmitter, setStateFn, tracer, bindings, proposedCheckpointData){
|
|
559
|
+
this.slotNow = slotNow;
|
|
560
|
+
this.targetSlot = targetSlot;
|
|
561
|
+
this.targetEpoch = targetEpoch;
|
|
550
562
|
this.checkpointNumber = checkpointNumber;
|
|
551
563
|
this.syncedToBlockNumber = syncedToBlockNumber;
|
|
552
564
|
this.proposer = proposer;
|
|
@@ -562,58 +574,311 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
562
574
|
this.checkpointsBuilder = checkpointsBuilder;
|
|
563
575
|
this.blockSink = blockSink;
|
|
564
576
|
this.l1Constants = l1Constants;
|
|
577
|
+
this.signatureContext = signatureContext;
|
|
565
578
|
this.config = config;
|
|
566
579
|
this.timetable = timetable;
|
|
567
580
|
this.slasherClient = slasherClient;
|
|
568
581
|
this.epochCache = epochCache;
|
|
569
582
|
this.dateProvider = dateProvider;
|
|
570
583
|
this.metrics = metrics;
|
|
584
|
+
this.checkpointMetrics = checkpointMetrics;
|
|
571
585
|
this.eventEmitter = eventEmitter;
|
|
572
586
|
this.setStateFn = setStateFn;
|
|
573
587
|
this.tracer = tracer;
|
|
588
|
+
this.proposedCheckpointData = proposedCheckpointData;
|
|
574
589
|
_initProto(this);
|
|
575
590
|
this.log = createLogger('sequencer:checkpoint-proposal', {
|
|
576
591
|
...bindings,
|
|
577
|
-
instanceId: `slot-${
|
|
592
|
+
instanceId: `slot-${this.slotNow}`
|
|
593
|
+
});
|
|
594
|
+
this.checkpointEventLog = createLogger('sequencer:checkpoint-events', {
|
|
595
|
+
...bindings,
|
|
596
|
+
instanceId: `slot-${this.slotNow}`
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
/** Awaits the pending L1 submission if one is in progress. Call during shutdown. */ async awaitPendingSubmission() {
|
|
600
|
+
this.log.info('Awaiting pending L1 payload submission');
|
|
601
|
+
await this.pendingL1Submission;
|
|
602
|
+
}
|
|
603
|
+
logCheckpointEvent(eventName, message, fields) {
|
|
604
|
+
this.checkpointEventLog.debug(message, {
|
|
605
|
+
eventName: `sequencer-checkpoint-${eventName}`,
|
|
606
|
+
...fields
|
|
578
607
|
});
|
|
579
608
|
}
|
|
580
609
|
/**
|
|
581
610
|
* Executes the checkpoint proposal job.
|
|
582
|
-
*
|
|
611
|
+
* Builds blocks, assembles checkpoint, and broadcasts the proposal (blocking).
|
|
612
|
+
* Attestation collection, signing, and L1 submission are backgrounded so the
|
|
613
|
+
* work loop can return to IDLE immediately for consecutive slot proposals.
|
|
614
|
+
* Returns the built checkpoint if successful, undefined otherwise.
|
|
583
615
|
*/ async execute() {
|
|
584
616
|
// Enqueue governance and slashing votes (returns promises that will be awaited later)
|
|
585
617
|
// In fisherman mode, we simulate slashing but don't actually publish to L1
|
|
586
618
|
// These are constant for the whole slot, so we only enqueue them once
|
|
587
|
-
const votesPromises = new CheckpointVoter(this.
|
|
588
|
-
// Build
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
619
|
+
const votesPromises = new CheckpointVoter(this.targetSlot, this.publisher, this.attestorAddress, this.validatorClient, this.slasherClient, this.l1Constants, this.config, this.metrics, this.log).enqueueVotes();
|
|
620
|
+
// Build blocks, assemble checkpoint, and broadcast proposal (BLOCKING).
|
|
621
|
+
// Returns after broadcast — attestation collection is deferred.
|
|
622
|
+
const broadcast = await this.proposeCheckpoint();
|
|
623
|
+
if (!broadcast) {
|
|
624
|
+
await Promise.all(votesPromises);
|
|
625
|
+
// Still submit votes even without a checkpoint
|
|
626
|
+
if (!this.config.fishermanMode) {
|
|
627
|
+
this.pendingL1Submission = this.publisher.sendRequestsAt(this.dateProvider.nowAsDate()).then(()=>{});
|
|
628
|
+
}
|
|
629
|
+
return undefined;
|
|
594
630
|
}
|
|
631
|
+
const { checkpoint } = broadcast;
|
|
632
|
+
this.metrics.recordCheckpointProposalSuccess();
|
|
595
633
|
// Do not post anything to L1 if we are fishermen, but do perform L1 fee analysis
|
|
596
634
|
if (this.config.fishermanMode) {
|
|
597
635
|
await this.handleCheckpointEndAsFisherman(checkpoint);
|
|
598
|
-
return;
|
|
636
|
+
return checkpoint;
|
|
599
637
|
}
|
|
600
|
-
//
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
638
|
+
// Background the attestation → signing → L1 pipeline so the work loop is unblocked
|
|
639
|
+
this.pendingL1Submission = this.waitForAttestationsAndEnqueueSubmissionAsync(broadcast, votesPromises);
|
|
640
|
+
// Return the built checkpoint immediately — the work loop is now unblocked
|
|
641
|
+
return checkpoint;
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Background pipeline: collects attestations, signs them, enqueues the checkpoint, and submits to L1.
|
|
645
|
+
* Runs as a fire-and-forget task stored in `pendingL1Submission` so the work loop is unblocked.
|
|
646
|
+
*/ async waitForAttestationsAndEnqueueSubmissionAsync(broadcast, votesPromises) {
|
|
647
|
+
const { checkpoint } = broadcast;
|
|
648
|
+
const isPipelining = this.epochCache.isProposerPipeliningEnabled();
|
|
649
|
+
try {
|
|
650
|
+
// Wait for all votes actions, enqueued at the beginning, to resolve
|
|
651
|
+
await Promise.all(votesPromises);
|
|
652
|
+
// Try to collect attestations from the committee
|
|
653
|
+
const signedAttestations = await this.getSignedCommitteeAttestations(broadcast);
|
|
654
|
+
// If pipelining, wait for the previous checkpoint to land on L1 before submitting,
|
|
655
|
+
// so we can check it matches the proposed checkpoint we used as parent, and has valid attestations.
|
|
656
|
+
if (signedAttestations && (!isPipelining || await this.waitForValidParentCheckpointOnL1())) {
|
|
657
|
+
await this.enqueueCheckpointForSubmission({
|
|
658
|
+
checkpoint,
|
|
659
|
+
...signedAttestations
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
// If we failed to collect attestations, at least check if we need to issue an invalidation
|
|
663
|
+
// Note that if we are not pipelining, we enqueued the invalidation at the beginning
|
|
664
|
+
if (!signedAttestations && isPipelining && await this.waitForSyncedL2SlotNumber(this.slotNow)) {
|
|
665
|
+
const validationStatus = await this.l2BlockSource.getPendingChainValidationStatus();
|
|
666
|
+
if (!validationStatus.valid) {
|
|
667
|
+
this.log.warn(`Checkpoint ${validationStatus.checkpoint.checkpointNumber} has invalid attestations, enqueuing invalidation in spite of attestation collection failure`, {
|
|
668
|
+
checkpoint: validationStatus.checkpoint,
|
|
669
|
+
reason: validationStatus.reason
|
|
670
|
+
});
|
|
671
|
+
await this.enqueueInvalidation(validationStatus);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
// Send whatever was enqueued: votes + (propose | invalidation | nothing).
|
|
675
|
+
// Compute the earliest time to submit: pipeline slot start when pipelining, now otherwise.
|
|
676
|
+
const submitAfter = isPipelining ? new Date(Number(getTimestampForSlot(this.targetSlot, this.l1Constants)) * 1000) : new Date(this.dateProvider.now());
|
|
677
|
+
const l1Response = await this.publisher.sendRequestsAt(submitAfter);
|
|
678
|
+
const proposedAction = l1Response?.successfulActions.find((a)=>a === 'propose');
|
|
679
|
+
if (proposedAction) {
|
|
680
|
+
this.logCheckpointEvent('published', `Checkpoint published for slot ${this.targetSlot}`, {
|
|
681
|
+
slot: this.targetSlot,
|
|
682
|
+
checkpointNumber: this.checkpointNumber,
|
|
683
|
+
successfulActions: l1Response?.successfulActions,
|
|
684
|
+
sentActions: l1Response?.sentActions
|
|
685
|
+
});
|
|
686
|
+
this.eventEmitter.emit('checkpoint-published', {
|
|
687
|
+
checkpoint: this.checkpointNumber,
|
|
688
|
+
slot: this.targetSlot
|
|
689
|
+
});
|
|
690
|
+
const coinbase = checkpoint.header.coinbase;
|
|
691
|
+
await this.metrics.incFilledSlot(this.publisher.getSenderAddress().toString(), coinbase);
|
|
692
|
+
} else {
|
|
693
|
+
this.logCheckpointEvent('publish-failed', `Checkpoint publish failed for slot ${this.targetSlot}`, {
|
|
694
|
+
slot: this.targetSlot,
|
|
695
|
+
checkpointNumber: this.checkpointNumber,
|
|
696
|
+
successfulActions: l1Response?.successfulActions,
|
|
697
|
+
failedActions: l1Response?.failedActions,
|
|
698
|
+
sentActions: l1Response?.sentActions,
|
|
699
|
+
expiredActions: l1Response?.expiredActions,
|
|
700
|
+
reason: 'propose_action_not_successful'
|
|
701
|
+
});
|
|
702
|
+
this.log.warn(`Checkpoint publish failed for slot ${this.targetSlot}`, {
|
|
703
|
+
slot: this.targetSlot,
|
|
704
|
+
checkpointNumber: this.checkpointNumber,
|
|
705
|
+
successfulActions: l1Response?.successfulActions,
|
|
706
|
+
failedActions: l1Response?.failedActions,
|
|
707
|
+
sentActions: l1Response?.sentActions,
|
|
708
|
+
expiredActions: l1Response?.expiredActions,
|
|
709
|
+
reason: 'propose_action_not_successful'
|
|
710
|
+
});
|
|
711
|
+
this.eventEmitter.emit('checkpoint-publish-failed', {
|
|
712
|
+
...l1Response,
|
|
713
|
+
slot: this.targetSlot
|
|
714
|
+
});
|
|
715
|
+
if (isPipelining) {
|
|
716
|
+
this.metrics.recordPipelineDiscard();
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
} catch (err) {
|
|
720
|
+
if (err instanceof SequencerInterruptedError) {
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
this.logCheckpointEvent('publish-failed', `Checkpoint publish failed for slot ${this.targetSlot}`, {
|
|
724
|
+
slot: this.targetSlot,
|
|
725
|
+
checkpointNumber: this.checkpointNumber,
|
|
726
|
+
reason: err instanceof Error ? err.message : String(err)
|
|
727
|
+
});
|
|
728
|
+
this.log.error(`Background attestation/L1 pipeline failed for slot ${this.targetSlot}`, err, {
|
|
729
|
+
slot: this.targetSlot,
|
|
730
|
+
checkpointNumber: this.checkpointNumber,
|
|
731
|
+
reason: err instanceof Error ? err.message : String(err)
|
|
607
732
|
});
|
|
608
|
-
const coinbase = checkpoint?.header.coinbase;
|
|
609
|
-
await this.metrics.incFilledSlot(this.publisher.getSenderAddress().toString(), coinbase);
|
|
610
|
-
return checkpoint;
|
|
611
|
-
} else if (checkpoint) {
|
|
612
733
|
this.eventEmitter.emit('checkpoint-publish-failed', {
|
|
613
|
-
|
|
614
|
-
|
|
734
|
+
slot: this.targetSlot
|
|
735
|
+
});
|
|
736
|
+
if (isPipelining) {
|
|
737
|
+
this.metrics.recordPipelineDiscard();
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
/** Enqueues the checkpoint for L1 submission. Called after pipeline sleep in execute(). */ async enqueueCheckpointForSubmission(result) {
|
|
742
|
+
const { checkpoint, attestations, attestationsSignature } = result;
|
|
743
|
+
this.setStateFn(SequencerState.PUBLISHING_CHECKPOINT, this.targetSlot);
|
|
744
|
+
const aztecSlotDuration = this.l1Constants.slotDuration;
|
|
745
|
+
const submissionSlotStart = Number(getTimestampForSlot(this.targetSlot, this.l1Constants));
|
|
746
|
+
const txTimeoutAt = new Date((submissionSlotStart + aztecSlotDuration) * 1000);
|
|
747
|
+
// If we have been configured to potentially skip publishing checkpoint then roll the dice here
|
|
748
|
+
if (this.config.skipPublishingCheckpointsPercent !== undefined && this.config.skipPublishingCheckpointsPercent > 0) {
|
|
749
|
+
const roll = Math.max(0, randomInt(100));
|
|
750
|
+
if (roll < this.config.skipPublishingCheckpointsPercent) {
|
|
751
|
+
this.log.warn(`Skipping publishing proposal for checkpoint ${checkpoint.number}. Configured percentage: ${this.config.skipPublishingCheckpointsPercent}, generated value: ${roll}`);
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
const isPipelining = this.epochCache.isProposerPipeliningEnabled();
|
|
756
|
+
const submissionSimulationOverridesPlan = buildSubmissionSimulationOverridesPlan({
|
|
757
|
+
pipelinedParentPlan: this.pipelinedParentSimulationOverridesPlan,
|
|
758
|
+
invalidateToPendingCheckpointNumber: this.invalidateCheckpoint?.forcePendingCheckpointNumber,
|
|
759
|
+
lastArchiveRoot: checkpoint.header.lastArchiveRoot,
|
|
760
|
+
pipeliningEnabled: isPipelining
|
|
761
|
+
});
|
|
762
|
+
await this.publisher.enqueueProposeCheckpoint(checkpoint, attestations, attestationsSignature, {
|
|
763
|
+
txTimeoutAt,
|
|
764
|
+
...submissionSimulationOverridesPlan ? {
|
|
765
|
+
simulationOverridesPlan: submissionSimulationOverridesPlan
|
|
766
|
+
} : {}
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* Wait until the archiver syncs past the given L2 slot number.
|
|
771
|
+
* The deadline is the end of `this.targetSlot`, beyond which any pipelined work would miss its
|
|
772
|
+
* L1 submission window and is no longer useful.
|
|
773
|
+
*/ async waitForSyncedL2SlotNumber(waitForSlot) {
|
|
774
|
+
const targetSlotStart = Number(getTimestampForSlot(this.targetSlot, this.l1Constants));
|
|
775
|
+
const targetSlotEndMs = (targetSlotStart + this.l1Constants.slotDuration) * 1000;
|
|
776
|
+
const syncDelayTolerance = this.l1Constants.ethereumSlotDuration * 2 * 1000;
|
|
777
|
+
const timeoutSeconds = Math.max(0.1, (targetSlotEndMs + syncDelayTolerance - this.dateProvider.now()) / 1000);
|
|
778
|
+
try {
|
|
779
|
+
return await retryUntil(async ()=>{
|
|
780
|
+
const syncedSlot = await this.l2BlockSource.getSyncedL2SlotNumber();
|
|
781
|
+
return syncedSlot !== undefined && syncedSlot >= waitForSlot;
|
|
782
|
+
}, `archiver sync past slot ${waitForSlot}`, timeoutSeconds, 0.2);
|
|
783
|
+
} catch {
|
|
784
|
+
this.log.warn(`Archiver did not sync L1 past slot ${waitForSlot} before slot ${this.targetSlot} expired, discarding pipelined work`, {
|
|
785
|
+
checkpointNumber: this.checkpointNumber
|
|
786
|
+
});
|
|
787
|
+
this.emitPipelinedCheckpointDiscarded('archiver-sync-timeout');
|
|
788
|
+
return false;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* Waits for the parent checkpoint to land on L1 before submitting a pipelined checkpoint.
|
|
793
|
+
* Polls until the archiver has synced L1 past the parent's slot, then verifies:
|
|
794
|
+
* - If we built on a proposed parent: it must have landed on L1 with matching hash and valid attestations.
|
|
795
|
+
* - If we built without a proposed parent: no new checkpoint must have appeared for that slot.
|
|
796
|
+
* If the parent has invalid attestations, enqueues an invalidation. Returns whether to proceed with the proposal.
|
|
797
|
+
*/ async waitForValidParentCheckpointOnL1() {
|
|
798
|
+
const parentCheckpointNumber = CheckpointNumber(this.checkpointNumber - 1);
|
|
799
|
+
// Wait until archiver has synced L1 past the parent's slot (slotNow)
|
|
800
|
+
if (!await this.waitForSyncedL2SlotNumber(this.slotNow)) {
|
|
801
|
+
return false;
|
|
802
|
+
}
|
|
803
|
+
const tips = await this.l2BlockSource.getL2Tips();
|
|
804
|
+
const checkpointedNumber = tips.checkpointed.checkpoint.number;
|
|
805
|
+
// We built on top of a proposed checkpoint. Verify it landed on L1 as expected.
|
|
806
|
+
if (this.proposedCheckpointData) {
|
|
807
|
+
// After syncing from L1 we see the chain tip has invalid attestations. This means the parent checkpoint was posted
|
|
808
|
+
// with invalid attestations, or it built on top of something with invalid attestations and didnt invalidate them.
|
|
809
|
+
// Either way, we thought our parent would be valid, so we have to throw away our work. But at least we'll try and
|
|
810
|
+
// invalidate on L1 so we clean up the chain for the next proposer. And we'll slash them, but that's handled elsewhere.
|
|
811
|
+
const validationStatus = await this.l2BlockSource.getPendingChainValidationStatus();
|
|
812
|
+
if (!validationStatus.valid) {
|
|
813
|
+
this.log.warn(`Parent checkpoint ${parentCheckpointNumber} has invalid attestations, discarding pipelined work`, {
|
|
814
|
+
checkpointNumber: this.checkpointNumber,
|
|
815
|
+
reason: validationStatus.reason
|
|
816
|
+
});
|
|
817
|
+
this.emitPipelinedCheckpointDiscarded('parent-invalid-attestations');
|
|
818
|
+
await this.enqueueInvalidation(validationStatus);
|
|
819
|
+
return false;
|
|
820
|
+
}
|
|
821
|
+
// The pending chain is valid. But did the parent checkpoint land on L1 at all?
|
|
822
|
+
if (checkpointedNumber < parentCheckpointNumber) {
|
|
823
|
+
this.log.warn(`Parent checkpoint ${parentCheckpointNumber} did not land on L1, discarding pipelined work`, {
|
|
824
|
+
checkpointNumber: this.checkpointNumber,
|
|
825
|
+
checkpointedNumber
|
|
826
|
+
});
|
|
827
|
+
this.emitPipelinedCheckpointDiscarded('parent-not-on-l1');
|
|
828
|
+
return false;
|
|
829
|
+
}
|
|
830
|
+
// It landed. But is it the one we were expecting?
|
|
831
|
+
const expectedHash = this.proposedCheckpointData.header.hash().toString();
|
|
832
|
+
if (tips.checkpointed.checkpoint.hash !== expectedHash) {
|
|
833
|
+
this.log.warn(`Parent checkpoint ${parentCheckpointNumber} hash mismatch on L1, discarding pipelined work`, {
|
|
834
|
+
checkpointNumber: this.checkpointNumber,
|
|
835
|
+
expectedHash,
|
|
836
|
+
actualHash: tips.checkpointed.checkpoint.hash
|
|
837
|
+
});
|
|
838
|
+
this.emitPipelinedCheckpointDiscarded('parent-hash-mismatch');
|
|
839
|
+
return false;
|
|
840
|
+
}
|
|
841
|
+
return true;
|
|
842
|
+
} else {
|
|
843
|
+
// We didn't see a proposed checkpoint at build time, so we built on checkpointed parent from two slots ago.
|
|
844
|
+
// But if a new checkpoint for the previous slot appeared on L1 in the meantime, our checkpoint assumed the wrong parent,
|
|
845
|
+
// so we have to discard our work. This can happen if we're somehow cut off from p2p and fail to see the checkpoint
|
|
846
|
+
// proposal for the previous slot.
|
|
847
|
+
if (checkpointedNumber > parentCheckpointNumber) {
|
|
848
|
+
this.log.warn(`Unexpected checkpoint ${checkpointedNumber} landed on L1 after we built on top of parent ${parentCheckpointNumber}, discarding pipelined work`, {
|
|
849
|
+
checkpointNumber: this.checkpointNumber,
|
|
850
|
+
checkpointedNumber
|
|
851
|
+
});
|
|
852
|
+
this.emitPipelinedCheckpointDiscarded('unexpected-parent-appeared');
|
|
853
|
+
return false;
|
|
854
|
+
}
|
|
855
|
+
return true;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
/** Emits the pipelined-checkpoint-discarded event and records the metric. */ emitPipelinedCheckpointDiscarded(reason) {
|
|
859
|
+
this.metrics.recordPipelineParentCheckpointMismatch(reason);
|
|
860
|
+
this.eventEmitter.emit('pipelined-checkpoint-discarded', {
|
|
861
|
+
slot: this.targetSlot,
|
|
862
|
+
checkpointNumber: this.checkpointNumber,
|
|
863
|
+
reason
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
/** Simulates and enqueues an invalidation request for the invalid parent checkpoint. */ async enqueueInvalidation(validationStatus) {
|
|
867
|
+
if (this.config.skipInvalidateBlockAsProposer) {
|
|
868
|
+
this.log.warn(`Skipping checkpoint invalidation as proposer due to test configuration`);
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
const invalidateRequest = await this.publisher.simulateInvalidateCheckpoint(validationStatus);
|
|
872
|
+
if (invalidateRequest) {
|
|
873
|
+
const submissionSlotStart = Number(getTimestampForSlot(this.targetSlot, this.l1Constants));
|
|
874
|
+
const txTimeoutAt = new Date((submissionSlotStart + this.l1Constants.slotDuration) * 1000);
|
|
875
|
+
this.publisher.enqueueInvalidateCheckpoint(invalidateRequest, {
|
|
876
|
+
txTimeoutAt
|
|
877
|
+
});
|
|
878
|
+
} else {
|
|
879
|
+
this.log.info(`Invalidation simulation returned undefined, checkpoint may have been removed already`, {
|
|
880
|
+
checkpointNumber: this.checkpointNumber
|
|
615
881
|
});
|
|
616
|
-
return undefined;
|
|
617
882
|
}
|
|
618
883
|
}
|
|
619
884
|
async proposeCheckpoint() {
|
|
@@ -624,29 +889,57 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
624
889
|
hasError: false
|
|
625
890
|
};
|
|
626
891
|
try {
|
|
892
|
+
const now = this.dateProvider.now();
|
|
893
|
+
if (this.epochCache.isProposerPipeliningEnabled() && this.proposedCheckpointData) {
|
|
894
|
+
// Measure against the wall-clock slot whose build window we are currently using.
|
|
895
|
+
// In pipelining mode `targetSlot` is intentionally one slot ahead, which makes the
|
|
896
|
+
// target-slot boundary a full slot away from the actual build start time.
|
|
897
|
+
const slotBoundaryMs = Number(getTimestampForSlot(this.slotNow, this.l1Constants)) * 1000;
|
|
898
|
+
this.checkpointMetrics.recordPipelinedCheckpointBuildStartOffsetFromSlotBoundary(now - slotBoundaryMs);
|
|
899
|
+
}
|
|
900
|
+
this.checkpointMetrics.startCheckpointTiming(now);
|
|
627
901
|
// Get operator configured coinbase and fee recipient for this attestor
|
|
628
902
|
const coinbase = this.validatorClient.getCoinbaseForAttestor(this.attestorAddress);
|
|
629
903
|
const feeRecipient = this.validatorClient.getFeeRecipientForAttestor(this.attestorAddress);
|
|
630
904
|
// Start the checkpoint
|
|
631
|
-
this.setStateFn(SequencerState.INITIALIZING_CHECKPOINT, this.
|
|
632
|
-
this.
|
|
905
|
+
this.setStateFn(SequencerState.INITIALIZING_CHECKPOINT, this.targetSlot);
|
|
906
|
+
this.logCheckpointEvent('slot-started', `Starting checkpoint proposal for slot ${this.targetSlot}`, {
|
|
907
|
+
buildSlot: this.slotNow,
|
|
908
|
+
submissionSlot: this.targetSlot,
|
|
909
|
+
slot: this.targetSlot,
|
|
910
|
+
checkpointNumber: this.checkpointNumber,
|
|
911
|
+
pipelining: this.epochCache.isProposerPipeliningEnabled(),
|
|
912
|
+
proposer: this.proposer?.toString(),
|
|
913
|
+
attestorAddress: this.attestorAddress.toString(),
|
|
914
|
+
publisherAddress: this.publisher.getSenderAddress().toString(),
|
|
915
|
+
coinbase: coinbase.toString()
|
|
916
|
+
});
|
|
917
|
+
this.metrics.incOpenSlot(this.targetSlot, this.proposer?.toString() ?? 'unknown');
|
|
633
918
|
// Enqueues checkpoint invalidation (constant for the whole slot)
|
|
634
919
|
if (this.invalidateCheckpoint && !this.config.skipInvalidateBlockAsProposer) {
|
|
635
920
|
this.publisher.enqueueInvalidateCheckpoint(this.invalidateCheckpoint);
|
|
636
921
|
}
|
|
637
|
-
// Create checkpoint builder for the slot
|
|
638
|
-
|
|
922
|
+
// Create checkpoint builder for the slot.
|
|
923
|
+
// When pipelining, force the proposed checkpoint number and fee header to our parent so the
|
|
924
|
+
// fee computation sees the same chain tip that L1 will see once the previous pipelined checkpoint lands.
|
|
925
|
+
const isPipelining = this.epochCache.isProposerPipeliningEnabled();
|
|
926
|
+
this.pipelinedParentSimulationOverridesPlan = isPipelining ? await buildPipelinedParentSimulationOverridesPlan({
|
|
927
|
+
checkpointNumber: this.checkpointNumber,
|
|
928
|
+
proposedCheckpointData: this.proposedCheckpointData,
|
|
929
|
+
rollup: this.publisher.rollupContract,
|
|
930
|
+
log: this.log
|
|
931
|
+
}) : undefined;
|
|
932
|
+
const checkpointGlobalVariables = await this.globalsBuilder.buildCheckpointGlobalVariables(coinbase, feeRecipient, this.targetSlot, this.pipelinedParentSimulationOverridesPlan);
|
|
639
933
|
// Collect L1 to L2 messages for the checkpoint and compute their hash
|
|
640
934
|
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(this.checkpointNumber);
|
|
641
935
|
const inHash = computeInHashFromL1ToL2Messages(l1ToL2Messages);
|
|
642
936
|
// Collect the out hashes of all the checkpoints before this one in the same epoch
|
|
643
|
-
const
|
|
644
|
-
const previousCheckpointOutHashes = previousCheckpoints.map((c)=>c.getCheckpointOutHash());
|
|
937
|
+
const previousCheckpointOutHashes = (await this.l2BlockSource.getCheckpointsDataForEpoch(this.targetEpoch)).filter((c)=>c.checkpointNumber < this.checkpointNumber).map((c)=>c.checkpointOutHash);
|
|
645
938
|
// Get the fee asset price modifier from the oracle
|
|
646
939
|
const feeAssetPriceModifier = await this.publisher.getFeeAssetPriceModifier();
|
|
647
940
|
const fork = _ts_add_disposable_resource(env, await this.worldState.fork(this.syncedToBlockNumber, {
|
|
648
941
|
closeDelayMs: 12_000
|
|
649
|
-
}),
|
|
942
|
+
}), true);
|
|
650
943
|
// Create checkpoint builder for the entire slot
|
|
651
944
|
const checkpointBuilder = await this.checkpointsBuilder.startCheckpoint(this.checkpointNumber, checkpointGlobalVariables, feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, fork, this.log.getBindings());
|
|
652
945
|
// Options for the validator client when creating block and checkpoint proposals
|
|
@@ -660,6 +953,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
660
953
|
};
|
|
661
954
|
let blocksInCheckpoint = [];
|
|
662
955
|
let blockPendingBroadcast = undefined;
|
|
956
|
+
const checkpointBuildTimer = new Timer();
|
|
663
957
|
try {
|
|
664
958
|
// Main loop: build blocks for the checkpoint
|
|
665
959
|
const result = await this.buildBlocksForCheckpoint(checkpointBuilder, checkpointGlobalVariables.timestamp, inHash, blockProposalOptions);
|
|
@@ -675,77 +969,124 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
675
969
|
throw err;
|
|
676
970
|
}
|
|
677
971
|
if (blocksInCheckpoint.length === 0) {
|
|
678
|
-
this.
|
|
679
|
-
slot: this.
|
|
972
|
+
this.logCheckpointEvent('build-failed', `Checkpoint build failed for slot ${this.targetSlot}`, {
|
|
973
|
+
slot: this.targetSlot,
|
|
974
|
+
checkpointNumber: this.checkpointNumber,
|
|
975
|
+
reason: 'no_blocks_built'
|
|
976
|
+
});
|
|
977
|
+
this.log.warn(`No blocks were built for slot ${this.targetSlot}`, {
|
|
978
|
+
slot: this.targetSlot,
|
|
979
|
+
checkpointNumber: this.checkpointNumber,
|
|
980
|
+
reason: 'no_blocks_built'
|
|
680
981
|
});
|
|
681
982
|
this.eventEmitter.emit('checkpoint-empty', {
|
|
682
|
-
slot: this.
|
|
983
|
+
slot: this.targetSlot
|
|
984
|
+
});
|
|
985
|
+
return undefined;
|
|
986
|
+
}
|
|
987
|
+
const minBlocksForCheckpoint = this.config.minBlocksForCheckpoint;
|
|
988
|
+
if (minBlocksForCheckpoint !== undefined && blocksInCheckpoint.length < minBlocksForCheckpoint) {
|
|
989
|
+
this.logCheckpointEvent('build-failed', `Checkpoint build failed for slot ${this.targetSlot}`, {
|
|
990
|
+
slot: this.targetSlot,
|
|
991
|
+
checkpointNumber: this.checkpointNumber,
|
|
992
|
+
blocksBuilt: blocksInCheckpoint.length,
|
|
993
|
+
minBlocksForCheckpoint,
|
|
994
|
+
reason: 'min_blocks_not_met'
|
|
995
|
+
});
|
|
996
|
+
this.log.warn(`Checkpoint has fewer blocks than minimum (${blocksInCheckpoint.length} < ${minBlocksForCheckpoint}), skipping proposal`, {
|
|
997
|
+
slot: this.targetSlot,
|
|
998
|
+
checkpointNumber: this.checkpointNumber,
|
|
999
|
+
blocksBuilt: blocksInCheckpoint.length,
|
|
1000
|
+
minBlocksForCheckpoint,
|
|
1001
|
+
reason: 'min_blocks_not_met'
|
|
683
1002
|
});
|
|
684
1003
|
return undefined;
|
|
685
1004
|
}
|
|
686
1005
|
// Assemble and broadcast the checkpoint proposal, including the last block that was not
|
|
687
1006
|
// broadcasted yet, and wait to collect the committee attestations.
|
|
688
|
-
this.setStateFn(SequencerState.ASSEMBLING_CHECKPOINT, this.
|
|
1007
|
+
this.setStateFn(SequencerState.ASSEMBLING_CHECKPOINT, this.targetSlot);
|
|
689
1008
|
const checkpoint = await checkpointBuilder.completeCheckpoint();
|
|
690
|
-
//
|
|
1009
|
+
// Final validation: per-block limits are only checked if the operator set them explicitly.
|
|
1010
|
+
// Otherwise, checkpoint-level budgets were already enforced by the redistribution logic.
|
|
1011
|
+
try {
|
|
1012
|
+
validateCheckpoint(checkpoint, {
|
|
1013
|
+
rollupManaLimit: this.l1Constants.rollupManaLimit,
|
|
1014
|
+
maxL2BlockGas: this.config.maxL2BlockGas,
|
|
1015
|
+
maxDABlockGas: this.config.maxDABlockGas,
|
|
1016
|
+
maxTxsPerBlock: this.config.maxTxsPerBlock,
|
|
1017
|
+
maxTxsPerCheckpoint: this.config.maxTxsPerCheckpoint
|
|
1018
|
+
});
|
|
1019
|
+
} catch (err) {
|
|
1020
|
+
this.logCheckpointEvent('build-failed', `Checkpoint build failed for slot ${this.targetSlot}`, {
|
|
1021
|
+
slot: this.targetSlot,
|
|
1022
|
+
checkpointNumber: this.checkpointNumber,
|
|
1023
|
+
blocksBuilt: blocksInCheckpoint.length,
|
|
1024
|
+
reason: 'invalid_checkpoint',
|
|
1025
|
+
checkpoint: checkpoint.header.toInspect()
|
|
1026
|
+
});
|
|
1027
|
+
this.log.error(`Built an invalid checkpoint at slot ${this.slotNow} (skipping proposal)`, err, {
|
|
1028
|
+
slot: this.targetSlot,
|
|
1029
|
+
checkpointNumber: this.checkpointNumber,
|
|
1030
|
+
blocksBuilt: blocksInCheckpoint.length,
|
|
1031
|
+
reason: 'invalid_checkpoint',
|
|
1032
|
+
checkpoint: checkpoint.header.toInspect()
|
|
1033
|
+
});
|
|
1034
|
+
return undefined;
|
|
1035
|
+
}
|
|
1036
|
+
// Record checkpoint-level build metrics
|
|
1037
|
+
this.checkpointMetrics.recordCheckpointBuild(checkpointBuildTimer.ms(), blocksInCheckpoint.length, checkpoint.getStats().txCount, Number(checkpoint.header.totalManaUsed.toBigInt()));
|
|
1038
|
+
this.logCheckpointEvent('built', `Checkpoint built for slot ${this.targetSlot}`, {
|
|
1039
|
+
slot: this.targetSlot,
|
|
1040
|
+
buildSlot: this.slotNow,
|
|
1041
|
+
checkpointNumber: this.checkpointNumber,
|
|
1042
|
+
proposer: this.proposer?.toString(),
|
|
1043
|
+
attestorAddress: this.attestorAddress.toString(),
|
|
1044
|
+
publisherAddress: this.publisher.getSenderAddress().toString(),
|
|
1045
|
+
blocksBuilt: blocksInCheckpoint.length,
|
|
1046
|
+
txCount: checkpoint.getStats().txCount,
|
|
1047
|
+
totalMana: Number(checkpoint.header.totalManaUsed.toBigInt())
|
|
1048
|
+
});
|
|
1049
|
+
// In fisherman mode, return the checkpoint without broadcasting or collecting attestations
|
|
691
1050
|
if (this.config.fishermanMode) {
|
|
692
|
-
this.log.info(`Built checkpoint for slot ${this.
|
|
693
|
-
slot: this.
|
|
1051
|
+
this.log.info(`Built checkpoint for slot ${this.targetSlot} with ${blocksInCheckpoint.length} blocks. ` + `Skipping proposal in fisherman mode.`, {
|
|
1052
|
+
slot: this.targetSlot,
|
|
694
1053
|
checkpoint: checkpoint.header.toInspect(),
|
|
695
1054
|
blocksBuilt: blocksInCheckpoint.length
|
|
696
1055
|
});
|
|
697
1056
|
this.metrics.recordCheckpointSuccess();
|
|
698
|
-
|
|
1057
|
+
// Return a broadcast result with a dummy proposal — fisherman mode skips attestation collection
|
|
1058
|
+
return {
|
|
1059
|
+
checkpoint,
|
|
1060
|
+
proposal: undefined,
|
|
1061
|
+
blockProposedAt: this.dateProvider.now()
|
|
1062
|
+
};
|
|
699
1063
|
}
|
|
700
|
-
// Include the block pending broadcast in the checkpoint proposal if any
|
|
701
|
-
const lastBlock = blockPendingBroadcast && {
|
|
702
|
-
blockHeader: blockPendingBroadcast.block.header,
|
|
703
|
-
indexWithinCheckpoint: blockPendingBroadcast.block.indexWithinCheckpoint,
|
|
704
|
-
txs: blockPendingBroadcast.txs
|
|
705
|
-
};
|
|
706
1064
|
// Create the checkpoint proposal and broadcast it
|
|
707
|
-
const proposal = await this.validatorClient.createCheckpointProposal(checkpoint.header, checkpoint.archive.root, feeAssetPriceModifier,
|
|
1065
|
+
const proposal = await this.validatorClient.createCheckpointProposal(checkpoint.header, checkpoint.archive.root, this.checkpointNumber, feeAssetPriceModifier, blockPendingBroadcast, this.proposer, checkpointProposalOptions);
|
|
708
1066
|
const blockProposedAt = this.dateProvider.now();
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
const blockAttestedAt = this.dateProvider.now();
|
|
713
|
-
this.metrics.recordCheckpointAttestationDelay(blockAttestedAt - blockProposedAt);
|
|
714
|
-
// Proposer must sign over the attestations before pushing them to L1
|
|
715
|
-
const signer = this.proposer ?? this.publisher.getSenderAddress();
|
|
716
|
-
let attestationsSignature;
|
|
717
|
-
try {
|
|
718
|
-
attestationsSignature = await this.validatorClient.signAttestationsAndSigners(attestations, signer, this.slot, this.checkpointNumber);
|
|
719
|
-
} catch (err) {
|
|
720
|
-
// We shouldn't really get here since we yield to another HA node
|
|
721
|
-
// as soon as we see these errors when creating block or checkpoint proposals.
|
|
722
|
-
if (this.handleHASigningError(err, 'Attestations signature')) {
|
|
723
|
-
return undefined;
|
|
724
|
-
}
|
|
725
|
-
throw err;
|
|
1067
|
+
if (!this.config.skipBroadcastProposals) {
|
|
1068
|
+
await this.p2pClient.broadcastCheckpointProposal(proposal);
|
|
1069
|
+
this.checkpointMetrics.noteCheckpointBroadcast(this.dateProvider.now());
|
|
726
1070
|
}
|
|
727
|
-
//
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
txTimeoutAt,
|
|
734
|
-
forcePendingCheckpointNumber: this.invalidateCheckpoint?.forcePendingCheckpointNumber
|
|
735
|
-
});
|
|
736
|
-
return checkpoint;
|
|
1071
|
+
// Return immediately after broadcast — attestation collection happens in the background
|
|
1072
|
+
return {
|
|
1073
|
+
checkpoint,
|
|
1074
|
+
proposal,
|
|
1075
|
+
blockProposedAt
|
|
1076
|
+
};
|
|
737
1077
|
} catch (e) {
|
|
738
1078
|
env.error = e;
|
|
739
1079
|
env.hasError = true;
|
|
740
1080
|
} finally{
|
|
741
|
-
_ts_dispose_resources(env);
|
|
1081
|
+
const result = _ts_dispose_resources(env);
|
|
1082
|
+
if (result) await result;
|
|
742
1083
|
}
|
|
743
1084
|
} catch (err) {
|
|
744
1085
|
if (err && (err instanceof DutyAlreadySignedError || err instanceof SlashingProtectionError)) {
|
|
745
1086
|
// swallow this error. It's already been logged by a function deeper in the stack
|
|
746
1087
|
return undefined;
|
|
747
1088
|
}
|
|
748
|
-
this.log.error(`Error building checkpoint at slot ${this.
|
|
1089
|
+
this.log.error(`Error building checkpoint at slot ${this.targetSlot}`, err);
|
|
749
1090
|
return undefined;
|
|
750
1091
|
}
|
|
751
1092
|
}
|
|
@@ -755,19 +1096,25 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
755
1096
|
const blocksInCheckpoint = [];
|
|
756
1097
|
const txHashesAlreadyIncluded = new Set();
|
|
757
1098
|
const initialBlockNumber = BlockNumber(this.syncedToBlockNumber + 1);
|
|
758
|
-
// Remaining blob fields available for blocks (checkpoint end marker already subtracted)
|
|
759
|
-
let remainingBlobFields = BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB - NUM_CHECKPOINT_END_MARKER_FIELDS;
|
|
760
1099
|
// Last block in the checkpoint will usually be flagged as pending broadcast, so we send it along with the checkpoint proposal
|
|
761
1100
|
let blockPendingBroadcast = undefined;
|
|
762
1101
|
while(true){
|
|
763
1102
|
const blocksBuilt = blocksInCheckpoint.length;
|
|
764
1103
|
const indexWithinCheckpoint = IndexWithinCheckpoint(blocksBuilt);
|
|
765
1104
|
const blockNumber = BlockNumber(initialBlockNumber + blocksBuilt);
|
|
1105
|
+
if (blocksBuilt >= this.config.maxBlocksPerCheckpoint) {
|
|
1106
|
+
this.log.debug(`Reached max blocks per checkpoint`, {
|
|
1107
|
+
slot: this.targetSlot,
|
|
1108
|
+
blocksBuilt,
|
|
1109
|
+
maxBlocksPerCheckpoint: this.config.maxBlocksPerCheckpoint
|
|
1110
|
+
});
|
|
1111
|
+
break;
|
|
1112
|
+
}
|
|
766
1113
|
const secondsIntoSlot = this.getSecondsIntoSlot();
|
|
767
1114
|
const timingInfo = this.timetable.canStartNextBlock(secondsIntoSlot);
|
|
768
1115
|
if (!timingInfo.canStart) {
|
|
769
1116
|
this.log.debug(`Not enough time left in slot to start another block`, {
|
|
770
|
-
slot: this.
|
|
1117
|
+
slot: this.targetSlot,
|
|
771
1118
|
blocksBuilt,
|
|
772
1119
|
secondsIntoSlot
|
|
773
1120
|
});
|
|
@@ -782,68 +1129,63 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
782
1129
|
buildDeadline: timingInfo.deadline ? new Date((this.getSlotStartBuildTimestamp() + timingInfo.deadline) * 1000) : undefined,
|
|
783
1130
|
blockNumber,
|
|
784
1131
|
indexWithinCheckpoint,
|
|
785
|
-
txHashesAlreadyIncluded
|
|
786
|
-
remainingBlobFields
|
|
1132
|
+
txHashesAlreadyIncluded
|
|
787
1133
|
});
|
|
788
|
-
//
|
|
789
|
-
if (
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
1134
|
+
// If we failed to build the block due to insufficient txs, we try again if there is still time left in the slot
|
|
1135
|
+
if ('failure' in buildResult) {
|
|
1136
|
+
// If this was the last subslot, or we're running with a single block per slot, we're done
|
|
1137
|
+
if (timingInfo.isLastBlock || timingInfo.deadline === undefined) {
|
|
1138
|
+
break;
|
|
1139
|
+
}
|
|
1140
|
+
// Otherwise, if there is still time for more blocks, we wait until the next subslot and try again
|
|
793
1141
|
await this.waitUntilNextSubslot(timingInfo.deadline);
|
|
794
1142
|
continue;
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
1143
|
+
}
|
|
1144
|
+
// If there was an error building the block, we just exit the loop and give up the rest of the slot.
|
|
1145
|
+
// We don't want to risk building more blocks if something went wrong.
|
|
1146
|
+
if ('error' in buildResult) {
|
|
799
1147
|
if (!(buildResult.error instanceof SequencerInterruptedError)) {
|
|
800
|
-
this.log.warn(`Halting block building for slot ${this.
|
|
801
|
-
slot: this.
|
|
1148
|
+
this.log.warn(`Halting block building for slot ${this.targetSlot}`, {
|
|
1149
|
+
slot: this.targetSlot,
|
|
802
1150
|
blocksBuilt,
|
|
803
1151
|
error: buildResult.error
|
|
804
1152
|
});
|
|
805
1153
|
}
|
|
806
1154
|
break;
|
|
807
1155
|
}
|
|
808
|
-
const { block, usedTxs
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
// Sync the proposed block to the archiver to make it available
|
|
813
|
-
// Note that the checkpoint builder uses its own fork so it should not need to wait for this syncing
|
|
814
|
-
// Eventually we should refactor the checkpoint builder to not need a separate long-lived fork
|
|
815
|
-
// Fire and forget - don't block the critical path, but log errors
|
|
816
|
-
this.syncProposedBlockToArchiver(block).catch((err)=>{
|
|
817
|
-
this.log.error(`Failed to sync proposed block ${block.number} to archiver`, {
|
|
818
|
-
blockNumber: block.number,
|
|
819
|
-
err
|
|
820
|
-
});
|
|
1156
|
+
const { block, usedTxs } = buildResult;
|
|
1157
|
+
this.checkpointMetrics.noteCheckpointBlockBuilt(this.dateProvider.now(), {
|
|
1158
|
+
isFirstBlock: blocksBuilt === 0,
|
|
1159
|
+
isLastBlock: timingInfo.isLastBlock
|
|
821
1160
|
});
|
|
1161
|
+
blocksInCheckpoint.push(block);
|
|
822
1162
|
usedTxs.forEach((tx)=>txHashesAlreadyIncluded.add(tx.txHash.toString()));
|
|
823
|
-
//
|
|
1163
|
+
// Sign the block proposal. This will throw if HA signing fails.
|
|
1164
|
+
const proposal = await this.createBlockProposal(block, inHash, usedTxs, blockProposalOptions);
|
|
1165
|
+
// Sync the proposed block to the archiver to make it available, only after we've managed to sign the proposal,
|
|
1166
|
+
// so we avoid polluting our archive with a block that would fail.
|
|
1167
|
+
// We wait for the sync to succeed, as this helps catch consistency errors, even if it means we lose some time for block-building.
|
|
1168
|
+
// If this throws, we abort the entire checkpoint.
|
|
1169
|
+
await this.syncProposedBlockToArchiver(block);
|
|
1170
|
+
// If this is the last block, do not broadcast it, since it will be included in the checkpoint proposal.
|
|
824
1171
|
if (timingInfo.isLastBlock) {
|
|
825
|
-
this.log.verbose(`Completed final block ${blockNumber} for slot ${this.
|
|
826
|
-
slot: this.
|
|
1172
|
+
this.log.verbose(`Completed final block ${blockNumber} for slot ${this.targetSlot}`, {
|
|
1173
|
+
slot: this.targetSlot,
|
|
827
1174
|
blockNumber,
|
|
828
1175
|
blocksBuilt
|
|
829
1176
|
});
|
|
830
|
-
blockPendingBroadcast =
|
|
831
|
-
block,
|
|
832
|
-
txs: usedTxs
|
|
833
|
-
};
|
|
1177
|
+
blockPendingBroadcast = proposal;
|
|
834
1178
|
break;
|
|
835
1179
|
}
|
|
836
|
-
//
|
|
837
|
-
|
|
838
|
-
if (!this.config.fishermanMode) {
|
|
839
|
-
const proposal = await this.validatorClient.createBlockProposal(block.header, block.indexWithinCheckpoint, inHash, block.archive.root, usedTxs, this.proposer, blockProposalOptions);
|
|
1180
|
+
// Once we have a signed proposal and the archiver agreed with our proposed block, then we broadcast it.
|
|
1181
|
+
if (proposal && !this.config.skipBroadcastProposals) {
|
|
840
1182
|
await this.p2pClient.broadcastProposal(proposal);
|
|
841
1183
|
}
|
|
842
1184
|
// Wait until the next block's start time
|
|
843
1185
|
await this.waitUntilNextSubslot(timingInfo.deadline);
|
|
844
1186
|
}
|
|
845
|
-
this.log.verbose(`Block building loop completed for slot ${this.
|
|
846
|
-
slot: this.
|
|
1187
|
+
this.log.verbose(`Block building loop completed for slot ${this.targetSlot}`, {
|
|
1188
|
+
slot: this.targetSlot,
|
|
847
1189
|
blocksBuilt: blocksInCheckpoint.length
|
|
848
1190
|
});
|
|
849
1191
|
return {
|
|
@@ -851,82 +1193,116 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
851
1193
|
blockPendingBroadcast
|
|
852
1194
|
};
|
|
853
1195
|
}
|
|
1196
|
+
/** Creates a block proposal for a given block via the validator client (unless in fisherman mode) */ createBlockProposal(block, inHash, usedTxs, blockProposalOptions) {
|
|
1197
|
+
if (this.config.fishermanMode) {
|
|
1198
|
+
this.log.info(`Skipping block proposal for block ${block.number} in fisherman mode`);
|
|
1199
|
+
return Promise.resolve(undefined);
|
|
1200
|
+
}
|
|
1201
|
+
return this.validatorClient.createBlockProposal(block.header, this.checkpointNumber, block.indexWithinCheckpoint, inHash, block.archive.root, usedTxs, this.proposer, blockProposalOptions);
|
|
1202
|
+
}
|
|
854
1203
|
/** Sleeps until it is time to produce the next block in the slot */ async waitUntilNextSubslot(nextSubslotStart) {
|
|
855
|
-
this.setStateFn(SequencerState.WAITING_UNTIL_NEXT_BLOCK, this.
|
|
1204
|
+
this.setStateFn(SequencerState.WAITING_UNTIL_NEXT_BLOCK, this.targetSlot);
|
|
856
1205
|
this.log.verbose(`Waiting until time for the next block at ${nextSubslotStart}s into slot`, {
|
|
857
|
-
slot: this.
|
|
1206
|
+
slot: this.targetSlot
|
|
858
1207
|
});
|
|
859
1208
|
await this.waitUntilTimeInSlot(nextSubslotStart);
|
|
860
1209
|
}
|
|
861
1210
|
/** Builds a single block. Called from the main block building loop. */ async buildSingleBlock(checkpointBuilder, opts) {
|
|
862
|
-
const { blockTimestamp, forceCreate, blockNumber, indexWithinCheckpoint, buildDeadline, txHashesAlreadyIncluded
|
|
863
|
-
this.log.verbose(`Preparing block ${blockNumber} index ${indexWithinCheckpoint} at checkpoint ${this.checkpointNumber} for slot ${this.
|
|
1211
|
+
const { blockTimestamp, forceCreate, blockNumber, indexWithinCheckpoint, buildDeadline, txHashesAlreadyIncluded } = opts;
|
|
1212
|
+
this.log.verbose(`Preparing block ${blockNumber} index ${indexWithinCheckpoint} at checkpoint ${this.checkpointNumber} for slot ${this.targetSlot}`, {
|
|
864
1213
|
...checkpointBuilder.getConstantData(),
|
|
865
1214
|
...opts
|
|
866
1215
|
});
|
|
867
1216
|
try {
|
|
868
1217
|
// Wait until we have enough txs to build the block
|
|
869
|
-
const minTxs = this.
|
|
870
|
-
const { availableTxs, canStartBuilding } = await this.waitForMinTxs(opts);
|
|
1218
|
+
const { availableTxs, canStartBuilding, minTxs } = await this.waitForMinTxs(opts);
|
|
871
1219
|
if (!canStartBuilding) {
|
|
872
|
-
this.
|
|
1220
|
+
this.logCheckpointEvent('block-build-failed', `Block build failed for slot ${this.targetSlot}`, {
|
|
1221
|
+
reason: 'insufficient_txs',
|
|
873
1222
|
blockNumber,
|
|
874
|
-
slot: this.
|
|
875
|
-
|
|
1223
|
+
slot: this.targetSlot,
|
|
1224
|
+
checkpointNumber: this.checkpointNumber,
|
|
1225
|
+
indexWithinCheckpoint,
|
|
1226
|
+
availableTxs,
|
|
1227
|
+
minTxs
|
|
1228
|
+
});
|
|
1229
|
+
this.log.warn(`Not enough txs to build block ${blockNumber} at index ${indexWithinCheckpoint} in slot ${this.targetSlot} (got ${availableTxs} txs but needs ${minTxs})`, {
|
|
1230
|
+
reason: 'insufficient_txs',
|
|
1231
|
+
blockNumber,
|
|
1232
|
+
slot: this.targetSlot,
|
|
1233
|
+
checkpointNumber: this.checkpointNumber,
|
|
1234
|
+
indexWithinCheckpoint,
|
|
1235
|
+
availableTxs,
|
|
1236
|
+
minTxs
|
|
876
1237
|
});
|
|
877
1238
|
this.eventEmitter.emit('block-tx-count-check-failed', {
|
|
878
1239
|
minTxs,
|
|
879
1240
|
availableTxs,
|
|
880
|
-
slot: this.
|
|
1241
|
+
slot: this.targetSlot
|
|
881
1242
|
});
|
|
882
1243
|
this.metrics.recordBlockProposalFailed('insufficient_txs');
|
|
883
|
-
return
|
|
1244
|
+
return {
|
|
1245
|
+
failure: 'insufficient-txs'
|
|
1246
|
+
};
|
|
884
1247
|
}
|
|
885
1248
|
// Create iterator to pending txs. We filter out txs already included in previous blocks in the checkpoint
|
|
886
1249
|
// just in case p2p failed to sync the provisional block and didn't get to remove those txs from the mempool yet.
|
|
887
1250
|
const pendingTxs = filter(this.p2pClient.iterateEligiblePendingTxs(), (tx)=>!txHashesAlreadyIncluded.has(tx.txHash.toString()));
|
|
888
|
-
this.log.debug(`Building block ${blockNumber} at index ${indexWithinCheckpoint} for slot ${this.
|
|
889
|
-
slot: this.
|
|
1251
|
+
this.log.debug(`Building block ${blockNumber} at index ${indexWithinCheckpoint} for slot ${this.targetSlot} with ${availableTxs} available txs`, {
|
|
1252
|
+
slot: this.targetSlot,
|
|
890
1253
|
blockNumber,
|
|
891
1254
|
indexWithinCheckpoint
|
|
892
1255
|
});
|
|
893
|
-
this.setStateFn(SequencerState.CREATING_BLOCK, this.
|
|
894
|
-
//
|
|
895
|
-
|
|
896
|
-
|
|
1256
|
+
this.setStateFn(SequencerState.CREATING_BLOCK, this.targetSlot);
|
|
1257
|
+
// Per-block limits are operator overrides (from SEQ_MAX_L2_BLOCK_GAS etc.) further capped
|
|
1258
|
+
// by remaining checkpoint-level budgets inside CheckpointBuilder before each block is built.
|
|
1259
|
+
// minValidTxs is passed into the builder so it can reject the block *before* updating state.
|
|
1260
|
+
const minValidTxs = forceCreate ? 0 : this.config.minValidTxsPerBlock ?? minTxs;
|
|
897
1261
|
const blockBuilderOptions = {
|
|
898
1262
|
maxTransactions: this.config.maxTxsPerBlock,
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
1263
|
+
maxBlockGas: this.config.maxL2BlockGas !== undefined || this.config.maxDABlockGas !== undefined ? new Gas(this.config.maxDABlockGas ?? Infinity, this.config.maxL2BlockGas ?? Infinity) : undefined,
|
|
1264
|
+
deadline: buildDeadline,
|
|
1265
|
+
isBuildingProposal: true,
|
|
1266
|
+
minValidTxs,
|
|
1267
|
+
maxBlocksPerCheckpoint: this.timetable.maxNumberOfBlocks,
|
|
1268
|
+
perBlockAllocationMultiplier: this.config.perBlockAllocationMultiplier
|
|
903
1269
|
};
|
|
904
|
-
// Actually build the block by executing txs
|
|
1270
|
+
// Actually build the block by executing txs. The builder throws InsufficientValidTxsError
|
|
1271
|
+
// if the number of successfully processed txs is below minValidTxs, ensuring state is not
|
|
1272
|
+
// updated for blocks that will be discarded.
|
|
905
1273
|
const buildResult = await this.buildSingleBlockWithCheckpointBuilder(checkpointBuilder, pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions);
|
|
906
1274
|
// If any txs failed during execution, drop them from the mempool so we don't pick them up again
|
|
907
1275
|
await this.dropFailedTxsFromP2P(buildResult.failedTxs);
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
1276
|
+
if (buildResult.status === 'insufficient-valid-txs') {
|
|
1277
|
+
this.logCheckpointEvent('block-build-failed', `Block build failed for slot ${this.targetSlot}`, {
|
|
1278
|
+
reason: 'insufficient_valid_txs',
|
|
1279
|
+
slot: this.targetSlot,
|
|
1280
|
+
checkpointNumber: this.checkpointNumber,
|
|
1281
|
+
blockNumber,
|
|
1282
|
+
numTxs: buildResult.processedCount,
|
|
1283
|
+
indexWithinCheckpoint,
|
|
1284
|
+
minValidTxs
|
|
1285
|
+
});
|
|
1286
|
+
this.log.warn(`Block ${blockNumber} at index ${indexWithinCheckpoint} on slot ${this.targetSlot} has too few valid txs to be proposed`, {
|
|
1287
|
+
reason: 'insufficient_valid_txs',
|
|
1288
|
+
slot: this.targetSlot,
|
|
1289
|
+
checkpointNumber: this.checkpointNumber,
|
|
915
1290
|
blockNumber,
|
|
916
|
-
numTxs,
|
|
1291
|
+
numTxs: buildResult.processedCount,
|
|
917
1292
|
indexWithinCheckpoint,
|
|
918
|
-
minValidTxs
|
|
919
|
-
buildResult: buildResult.status
|
|
1293
|
+
minValidTxs
|
|
920
1294
|
});
|
|
921
1295
|
this.eventEmitter.emit('block-build-failed', {
|
|
922
1296
|
reason: `Insufficient valid txs`,
|
|
923
|
-
slot: this.
|
|
1297
|
+
slot: this.targetSlot
|
|
924
1298
|
});
|
|
925
1299
|
this.metrics.recordBlockProposalFailed('insufficient_valid_txs');
|
|
926
|
-
return
|
|
1300
|
+
return {
|
|
1301
|
+
failure: 'insufficient-valid-txs'
|
|
1302
|
+
};
|
|
927
1303
|
}
|
|
928
1304
|
// Block creation succeeded, emit stats and metrics
|
|
929
|
-
const {
|
|
1305
|
+
const { block, publicProcessorDuration, usedTxs, blockBuildDuration, numTxs } = buildResult;
|
|
930
1306
|
const blockStats = {
|
|
931
1307
|
eventName: 'l2-block-built',
|
|
932
1308
|
duration: blockBuildDuration,
|
|
@@ -935,31 +1311,41 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
935
1311
|
};
|
|
936
1312
|
const blockHash = await block.hash();
|
|
937
1313
|
const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
|
|
938
|
-
const manaPerSec =
|
|
939
|
-
this.log.info(`Built block ${block.number} at checkpoint ${this.checkpointNumber} for slot ${this.
|
|
1314
|
+
const manaPerSec = block.header.totalManaUsed.toNumberUnsafe() / (blockBuildDuration / 1000);
|
|
1315
|
+
this.log.info(`Built block ${block.number} at checkpoint ${this.checkpointNumber} for slot ${this.targetSlot} with ${numTxs} txs`, {
|
|
940
1316
|
blockHash,
|
|
941
1317
|
txHashes,
|
|
942
1318
|
manaPerSec,
|
|
943
1319
|
...blockStats
|
|
944
1320
|
});
|
|
1321
|
+
// `slot` is the target/submission slot (may be one ahead when pipelining),
|
|
1322
|
+
// `buildSlot` is the wall-clock slot during which the block was actually built.
|
|
945
1323
|
this.eventEmitter.emit('block-proposed', {
|
|
946
1324
|
blockNumber: block.number,
|
|
947
|
-
slot: this.
|
|
1325
|
+
slot: this.targetSlot,
|
|
1326
|
+
buildSlot: this.slotNow
|
|
948
1327
|
});
|
|
949
|
-
this.metrics.recordBuiltBlock(blockBuildDuration,
|
|
1328
|
+
this.metrics.recordBuiltBlock(blockBuildDuration, block.header.totalManaUsed.toNumberUnsafe(), this.targetSlot);
|
|
950
1329
|
return {
|
|
951
1330
|
block,
|
|
952
|
-
usedTxs
|
|
953
|
-
remainingBlobFields: maxBlobFieldsForTxs - usedTxBlobFields
|
|
1331
|
+
usedTxs
|
|
954
1332
|
};
|
|
955
1333
|
} catch (err) {
|
|
956
1334
|
this.eventEmitter.emit('block-build-failed', {
|
|
957
1335
|
reason: err.message,
|
|
958
|
-
slot: this.
|
|
1336
|
+
slot: this.targetSlot
|
|
1337
|
+
});
|
|
1338
|
+
this.logCheckpointEvent('block-build-failed', `Block build failed for slot ${this.targetSlot}`, {
|
|
1339
|
+
reason: err instanceof Error ? err.message : String(err),
|
|
1340
|
+
slot: this.targetSlot,
|
|
1341
|
+
checkpointNumber: this.checkpointNumber,
|
|
1342
|
+
blockNumber
|
|
959
1343
|
});
|
|
960
1344
|
this.log.error(`Error building block`, err, {
|
|
961
|
-
|
|
962
|
-
slot: this.
|
|
1345
|
+
reason: err instanceof Error ? err.message : String(err),
|
|
1346
|
+
slot: this.targetSlot,
|
|
1347
|
+
checkpointNumber: this.checkpointNumber,
|
|
1348
|
+
blockNumber
|
|
963
1349
|
});
|
|
964
1350
|
this.metrics.recordBlockProposalFailed(err.name || 'unknown_error');
|
|
965
1351
|
this.metrics.recordFailedBlock();
|
|
@@ -968,7 +1354,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
968
1354
|
};
|
|
969
1355
|
}
|
|
970
1356
|
}
|
|
971
|
-
/** Uses the checkpoint builder to build a block, catching
|
|
1357
|
+
/** Uses the checkpoint builder to build a block, catching InsufficientValidTxsError. */ async buildSingleBlockWithCheckpointBuilder(checkpointBuilder, pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions) {
|
|
972
1358
|
try {
|
|
973
1359
|
const workTimer = new Timer();
|
|
974
1360
|
const result = await checkpointBuilder.buildBlock(pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions);
|
|
@@ -979,10 +1365,11 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
979
1365
|
status: 'success'
|
|
980
1366
|
};
|
|
981
1367
|
} catch (err) {
|
|
982
|
-
if (isErrorClass(err,
|
|
1368
|
+
if (isErrorClass(err, InsufficientValidTxsError)) {
|
|
983
1369
|
return {
|
|
984
1370
|
failedTxs: err.failedTxs,
|
|
985
|
-
|
|
1371
|
+
processedCount: err.processedCount,
|
|
1372
|
+
status: 'insufficient-valid-txs'
|
|
986
1373
|
};
|
|
987
1374
|
}
|
|
988
1375
|
throw err;
|
|
@@ -1001,14 +1388,15 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1001
1388
|
if (startBuildingDeadline === undefined || now >= startBuildingDeadline) {
|
|
1002
1389
|
return {
|
|
1003
1390
|
canStartBuilding: false,
|
|
1004
|
-
availableTxs
|
|
1391
|
+
availableTxs,
|
|
1392
|
+
minTxs
|
|
1005
1393
|
};
|
|
1006
1394
|
}
|
|
1007
1395
|
// Wait a bit before checking again
|
|
1008
|
-
this.setStateFn(SequencerState.WAITING_FOR_TXS, this.
|
|
1009
|
-
this.log.verbose(`Waiting for enough txs to build block ${blockNumber} at index ${indexWithinCheckpoint} in slot ${this.
|
|
1396
|
+
this.setStateFn(SequencerState.WAITING_FOR_TXS, this.targetSlot);
|
|
1397
|
+
this.log.verbose(`Waiting for enough txs to build block ${blockNumber} at index ${indexWithinCheckpoint} in slot ${this.targetSlot} (have ${availableTxs} but need ${minTxs})`, {
|
|
1010
1398
|
blockNumber,
|
|
1011
|
-
slot: this.
|
|
1399
|
+
slot: this.targetSlot,
|
|
1012
1400
|
indexWithinCheckpoint
|
|
1013
1401
|
});
|
|
1014
1402
|
await this.waitForTxsPollingInterval();
|
|
@@ -1016,16 +1404,41 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1016
1404
|
}
|
|
1017
1405
|
return {
|
|
1018
1406
|
canStartBuilding: true,
|
|
1019
|
-
availableTxs
|
|
1407
|
+
availableTxs,
|
|
1408
|
+
minTxs
|
|
1020
1409
|
};
|
|
1021
1410
|
}
|
|
1411
|
+
async getSignedCommitteeAttestations(broadcast) {
|
|
1412
|
+
const { proposal, blockProposedAt } = broadcast;
|
|
1413
|
+
this.setStateFn(SequencerState.COLLECTING_ATTESTATIONS, this.targetSlot);
|
|
1414
|
+
const attestations = await this.waitForAttestations(proposal);
|
|
1415
|
+
if (!attestations) {
|
|
1416
|
+
return undefined;
|
|
1417
|
+
}
|
|
1418
|
+
this.checkpointMetrics.recordCheckpointAttestationDelay(this.dateProvider.now() - blockProposedAt);
|
|
1419
|
+
// Proposer must sign over the attestations before pushing them to L1
|
|
1420
|
+
const signer = this.proposer ?? this.publisher.getSenderAddress();
|
|
1421
|
+
try {
|
|
1422
|
+
const attestationsSignature = await this.validatorClient.signAttestationsAndSigners(attestations, signer, this.targetSlot, this.checkpointNumber);
|
|
1423
|
+
return {
|
|
1424
|
+
attestations,
|
|
1425
|
+
attestationsSignature
|
|
1426
|
+
};
|
|
1427
|
+
} catch (err) {
|
|
1428
|
+
if (this.handleHASigningError(err, 'Attestations signature')) {
|
|
1429
|
+
return;
|
|
1430
|
+
}
|
|
1431
|
+
this.log.error(`Error signing attestations for checkpoint proposal at slot ${proposal.slotNumber}`, err);
|
|
1432
|
+
return undefined;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1022
1435
|
/**
|
|
1023
1436
|
* Waits for enough attestations to be collected via p2p.
|
|
1024
1437
|
* This is run after all blocks for the checkpoint have been built.
|
|
1025
1438
|
*/ async waitForAttestations(proposal) {
|
|
1026
1439
|
if (this.config.fishermanMode) {
|
|
1027
1440
|
this.log.debug('Skipping attestation collection in fisherman mode');
|
|
1028
|
-
return CommitteeAttestationsAndSigners.empty();
|
|
1441
|
+
return CommitteeAttestationsAndSigners.empty(this.getSignatureContext());
|
|
1029
1442
|
}
|
|
1030
1443
|
const slotNumber = proposal.slotNumber;
|
|
1031
1444
|
const { committee, seed, epoch } = await this.epochCache.getCommittee(slotNumber);
|
|
@@ -1033,47 +1446,91 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1033
1446
|
throw new Error('No committee when collecting attestations');
|
|
1034
1447
|
} else if (committee.length === 0) {
|
|
1035
1448
|
this.log.verbose(`Attesting committee is empty`);
|
|
1036
|
-
return CommitteeAttestationsAndSigners.empty();
|
|
1449
|
+
return CommitteeAttestationsAndSigners.empty(this.getSignatureContext());
|
|
1037
1450
|
} else {
|
|
1038
1451
|
this.log.debug(`Attesting committee length is ${committee.length}`, {
|
|
1039
1452
|
committee
|
|
1040
1453
|
});
|
|
1041
1454
|
}
|
|
1042
|
-
const numberOfRequiredAttestations =
|
|
1455
|
+
const numberOfRequiredAttestations = computeQuorum(committee.length);
|
|
1043
1456
|
if (this.config.skipCollectingAttestations) {
|
|
1044
1457
|
this.log.warn('Skipping attestation collection as per config (attesting with own keys only)');
|
|
1045
|
-
const attestations = await this.validatorClient?.collectOwnAttestations(proposal);
|
|
1046
|
-
|
|
1458
|
+
const attestations = await this.validatorClient?.collectOwnAttestations(proposal, this.checkpointNumber);
|
|
1459
|
+
this.logCheckpointAttestations('collected', committee, attestations ?? [], numberOfRequiredAttestations, {
|
|
1460
|
+
reason: 'collect_own_only'
|
|
1461
|
+
});
|
|
1462
|
+
return new CommitteeAttestationsAndSigners(orderAttestations(attestations ?? [], committee), this.getSignatureContext());
|
|
1047
1463
|
}
|
|
1048
|
-
const attestationTimeAllowed = this.config.enforceTimeTable ? this.timetable.
|
|
1464
|
+
const attestationTimeAllowed = this.config.enforceTimeTable ? this.timetable.getCheckpointAttestationDeadline() : this.l1Constants.slotDuration;
|
|
1049
1465
|
const attestationDeadline = new Date((this.getSlotStartBuildTimestamp() + attestationTimeAllowed) * 1000);
|
|
1050
1466
|
this.metrics.recordRequiredAttestations(numberOfRequiredAttestations, attestationTimeAllowed);
|
|
1051
1467
|
const collectAttestationsTimer = new Timer();
|
|
1052
1468
|
let collectedAttestationsCount = 0;
|
|
1053
1469
|
try {
|
|
1054
|
-
const attestations = await this.validatorClient.collectAttestations(proposal, numberOfRequiredAttestations, attestationDeadline);
|
|
1470
|
+
const attestations = await this.validatorClient.collectAttestations(proposal, numberOfRequiredAttestations, attestationDeadline, this.checkpointNumber);
|
|
1055
1471
|
collectedAttestationsCount = attestations.length;
|
|
1472
|
+
// Trim attestations to minimum required to save L1 calldata gas
|
|
1473
|
+
const localAddresses = this.validatorClient.getValidatorAddresses();
|
|
1474
|
+
const trimmed = trimAttestations(attestations, numberOfRequiredAttestations, this.attestorAddress, localAddresses);
|
|
1475
|
+
if (trimmed.length < attestations.length) {
|
|
1476
|
+
this.log.debug(`Trimmed attestations from ${attestations.length} to ${trimmed.length} for L1 submission`);
|
|
1477
|
+
}
|
|
1056
1478
|
// Rollup contract requires that the signatures are provided in the order of the committee
|
|
1057
|
-
const sorted = orderAttestations(
|
|
1479
|
+
const sorted = orderAttestations(trimmed, committee);
|
|
1480
|
+
this.logCheckpointAttestations('collected', committee, attestations, numberOfRequiredAttestations, {
|
|
1481
|
+
submittedCount: trimmed.length
|
|
1482
|
+
});
|
|
1058
1483
|
// Manipulate the attestations if we've been configured to do so
|
|
1059
|
-
if (this.config.injectFakeAttestation || this.config.shuffleAttestationOrdering) {
|
|
1484
|
+
if (this.config.injectFakeAttestation || this.config.injectHighSValueAttestation || this.config.injectUnrecoverableSignatureAttestation || this.config.shuffleAttestationOrdering) {
|
|
1060
1485
|
return this.manipulateAttestations(proposal.slotNumber, epoch, seed, committee, sorted);
|
|
1061
1486
|
}
|
|
1062
|
-
return new CommitteeAttestationsAndSigners(sorted);
|
|
1487
|
+
return new CommitteeAttestationsAndSigners(sorted, this.getSignatureContext());
|
|
1063
1488
|
} catch (err) {
|
|
1064
1489
|
if (err && err instanceof AttestationTimeoutError) {
|
|
1065
1490
|
collectedAttestationsCount = err.collectedCount;
|
|
1491
|
+
this.logCheckpointAttestations('failed', committee, undefined, numberOfRequiredAttestations, {
|
|
1492
|
+
collectedCount: collectedAttestationsCount,
|
|
1493
|
+
reason: 'timeout'
|
|
1494
|
+
});
|
|
1495
|
+
this.log.error(`Timeout while waiting for attestations for checkpoint proposal at slot ${proposal.slotNumber} (collected ${collectedAttestationsCount}/${numberOfRequiredAttestations})`, err);
|
|
1496
|
+
} else {
|
|
1497
|
+
this.logCheckpointAttestations('failed', committee, undefined, numberOfRequiredAttestations, {
|
|
1498
|
+
collectedCount: collectedAttestationsCount,
|
|
1499
|
+
reason: err instanceof Error ? err.message : String(err)
|
|
1500
|
+
});
|
|
1501
|
+
this.log.error(`Error collecting attestations for checkpoint proposal at slot ${proposal.slotNumber}`, err);
|
|
1066
1502
|
}
|
|
1067
|
-
|
|
1503
|
+
return undefined;
|
|
1068
1504
|
} finally{
|
|
1069
1505
|
this.metrics.recordCollectedAttestations(collectedAttestationsCount, collectAttestationsTimer.ms());
|
|
1070
1506
|
}
|
|
1071
1507
|
}
|
|
1508
|
+
logCheckpointAttestations(status, committee, attestations, requiredAttestations, opts = {}) {
|
|
1509
|
+
const signedValidators = attestations?.map((attestation)=>attestation.getSender()?.toString()).filter((address)=>address !== undefined) ?? [];
|
|
1510
|
+
const collectedCount = opts.collectedCount ?? new Set(signedValidators).size;
|
|
1511
|
+
const missingValidatorCount = status === 'failed' ? Math.max(0, requiredAttestations - collectedCount) : undefined;
|
|
1512
|
+
this.logCheckpointEvent(`attestations-${status}`, `Checkpoint attestations ${status} for slot ${this.targetSlot}`, {
|
|
1513
|
+
slot: this.targetSlot,
|
|
1514
|
+
checkpointNumber: this.checkpointNumber,
|
|
1515
|
+
committeeSize: committee.length,
|
|
1516
|
+
requiredAttestations,
|
|
1517
|
+
collectedAttestations: collectedCount,
|
|
1518
|
+
...opts.submittedCount !== undefined && {
|
|
1519
|
+
submittedAttestations: opts.submittedCount
|
|
1520
|
+
},
|
|
1521
|
+
...missingValidatorCount !== undefined && {
|
|
1522
|
+
missingValidatorCount
|
|
1523
|
+
},
|
|
1524
|
+
...opts.reason !== undefined && {
|
|
1525
|
+
reason: opts.reason
|
|
1526
|
+
}
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1072
1529
|
/** Breaks the attestations before publishing based on attack configs */ manipulateAttestations(slotNumber, epoch, seed, committee, attestations) {
|
|
1073
1530
|
// Compute the proposer index in the committee, since we dont want to tweak it.
|
|
1074
1531
|
// Otherwise, the L1 rollup contract will reject the block outright.
|
|
1075
1532
|
const proposerIndex = Number(this.epochCache.computeProposerIndex(slotNumber, epoch, seed, BigInt(committee.length)));
|
|
1076
|
-
if (this.config.injectFakeAttestation) {
|
|
1533
|
+
if (this.config.injectFakeAttestation || this.config.injectHighSValueAttestation || this.config.injectUnrecoverableSignatureAttestation) {
|
|
1077
1534
|
// Find non-empty attestations that are not from the proposer
|
|
1078
1535
|
const nonProposerIndices = [];
|
|
1079
1536
|
for(let i = 0; i < attestations.length; i++){
|
|
@@ -1083,28 +1540,47 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1083
1540
|
}
|
|
1084
1541
|
if (nonProposerIndices.length > 0) {
|
|
1085
1542
|
const targetIndex = nonProposerIndices[randomInt(nonProposerIndices.length)];
|
|
1086
|
-
this.
|
|
1087
|
-
|
|
1543
|
+
if (this.config.injectHighSValueAttestation) {
|
|
1544
|
+
this.log.warn(`Injecting high-s value attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`);
|
|
1545
|
+
unfreeze(attestations[targetIndex]).signature = flipSignature(attestations[targetIndex].signature);
|
|
1546
|
+
} else if (this.config.injectUnrecoverableSignatureAttestation) {
|
|
1547
|
+
this.log.warn(`Injecting unrecoverable signature attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`);
|
|
1548
|
+
unfreeze(attestations[targetIndex]).signature = generateUnrecoverableSignature();
|
|
1549
|
+
} else {
|
|
1550
|
+
this.log.warn(`Injecting fake attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`);
|
|
1551
|
+
unfreeze(attestations[targetIndex]).signature = generateRecoverableSignature();
|
|
1552
|
+
}
|
|
1088
1553
|
}
|
|
1089
|
-
return new CommitteeAttestationsAndSigners(attestations);
|
|
1554
|
+
return new CommitteeAttestationsAndSigners(attestations, this.getSignatureContext());
|
|
1090
1555
|
}
|
|
1091
1556
|
if (this.config.shuffleAttestationOrdering) {
|
|
1092
1557
|
this.log.warn(`Shuffling attestation ordering in checkpoint for slot ${slotNumber} (proposer #${proposerIndex})`);
|
|
1093
1558
|
const shuffled = [
|
|
1094
1559
|
...attestations
|
|
1095
1560
|
];
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
];
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1561
|
+
// Find two non-proposer positions that both have non-empty signatures to swap.
|
|
1562
|
+
// This ensures the bitmap doesn't change, so the MaliciousCommitteeAttestationsAndSigners
|
|
1563
|
+
// signers array stays correctly aligned with L1's committee reconstruction.
|
|
1564
|
+
const swappable = [];
|
|
1565
|
+
for(let k = 0; k < shuffled.length; k++){
|
|
1566
|
+
if (!shuffled[k].signature.isEmpty() && k !== proposerIndex) {
|
|
1567
|
+
swappable.push(k);
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
if (swappable.length >= 2) {
|
|
1571
|
+
const [i, j] = [
|
|
1572
|
+
swappable[0],
|
|
1573
|
+
swappable[1]
|
|
1574
|
+
];
|
|
1575
|
+
[shuffled[i], shuffled[j]] = [
|
|
1576
|
+
shuffled[j],
|
|
1577
|
+
shuffled[i]
|
|
1578
|
+
];
|
|
1579
|
+
}
|
|
1580
|
+
const signers = new CommitteeAttestationsAndSigners(attestations, this.getSignatureContext()).getSigners();
|
|
1581
|
+
return new MaliciousCommitteeAttestationsAndSigners(shuffled, signers, this.getSignatureContext());
|
|
1106
1582
|
}
|
|
1107
|
-
return new CommitteeAttestationsAndSigners(attestations);
|
|
1583
|
+
return new CommitteeAttestationsAndSigners(attestations, this.getSignatureContext());
|
|
1108
1584
|
}
|
|
1109
1585
|
async dropFailedTxsFromP2P(failedTxs) {
|
|
1110
1586
|
if (failedTxs.length === 0) {
|
|
@@ -1119,8 +1595,12 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1119
1595
|
* Adds the proposed block to the archiver so it's available via P2P.
|
|
1120
1596
|
* Gossip doesn't echo messages back to the sender, so the proposer's archiver/world-state
|
|
1121
1597
|
* would never receive its own block without this explicit sync.
|
|
1598
|
+
*
|
|
1599
|
+
* In fisherman mode we skip this push: the fisherman builds blocks locally for validation
|
|
1600
|
+
* and fee analysis only, and pushing them to the archiver causes spurious reorg cascades
|
|
1601
|
+
* whenever the real proposer's block arrives from L1.
|
|
1122
1602
|
*/ async syncProposedBlockToArchiver(block) {
|
|
1123
|
-
if (this.config.skipPushProposedBlocksToArchiver
|
|
1603
|
+
if (this.config.skipPushProposedBlocksToArchiver || this.config.fishermanMode) {
|
|
1124
1604
|
this.log.warn(`Skipping push of proposed block ${block.number} to archiver`, {
|
|
1125
1605
|
blockNumber: block.number,
|
|
1126
1606
|
slot: block.header.globalVariables.slotNumber
|
|
@@ -1136,19 +1616,19 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1136
1616
|
/** Runs fee analysis and logs checkpoint outcome as fisherman */ async handleCheckpointEndAsFisherman(checkpoint) {
|
|
1137
1617
|
// Perform L1 fee analysis before clearing requests
|
|
1138
1618
|
// The callback is invoked asynchronously after the next block is mined
|
|
1139
|
-
const feeAnalysis = await this.publisher.analyzeL1Fees(this.
|
|
1619
|
+
const feeAnalysis = await this.publisher.analyzeL1Fees(this.targetSlot, (analysis)=>this.metrics.recordFishermanFeeAnalysis(analysis));
|
|
1140
1620
|
if (checkpoint) {
|
|
1141
|
-
this.log.info(`Validation checkpoint building SUCCEEDED for slot ${this.
|
|
1621
|
+
this.log.info(`Validation checkpoint building SUCCEEDED for slot ${this.targetSlot}`, {
|
|
1142
1622
|
...checkpoint.toCheckpointInfo(),
|
|
1143
1623
|
...checkpoint.getStats(),
|
|
1144
1624
|
feeAnalysisId: feeAnalysis?.id
|
|
1145
1625
|
});
|
|
1146
1626
|
} else {
|
|
1147
|
-
this.log.warn(`Validation block building FAILED for slot ${this.
|
|
1148
|
-
slot: this.
|
|
1627
|
+
this.log.warn(`Validation block building FAILED for slot ${this.targetSlot}`, {
|
|
1628
|
+
slot: this.targetSlot,
|
|
1149
1629
|
feeAnalysisId: feeAnalysis?.id
|
|
1150
1630
|
});
|
|
1151
|
-
this.metrics.
|
|
1631
|
+
this.metrics.recordCheckpointProposalFailed('block_build_failed');
|
|
1152
1632
|
}
|
|
1153
1633
|
this.publisher.clearPendingRequests();
|
|
1154
1634
|
}
|
|
@@ -1156,15 +1636,15 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1156
1636
|
* Helper to handle HA double-signing errors. Returns true if the error was handled (caller should yield).
|
|
1157
1637
|
*/ handleHASigningError(err, errorContext) {
|
|
1158
1638
|
if (err instanceof DutyAlreadySignedError) {
|
|
1159
|
-
this.log.info(`${errorContext} for slot ${this.
|
|
1160
|
-
slot: this.
|
|
1639
|
+
this.log.info(`${errorContext} for slot ${this.targetSlot} already signed by another HA node, yielding`, {
|
|
1640
|
+
slot: this.targetSlot,
|
|
1161
1641
|
signedByNode: err.signedByNode
|
|
1162
1642
|
});
|
|
1163
1643
|
return true;
|
|
1164
1644
|
}
|
|
1165
1645
|
if (err instanceof SlashingProtectionError) {
|
|
1166
|
-
this.log.info(`${errorContext} for slot ${this.
|
|
1167
|
-
slot: this.
|
|
1646
|
+
this.log.info(`${errorContext} for slot ${this.targetSlot} blocked by slashing protection, yielding`, {
|
|
1647
|
+
slot: this.targetSlot,
|
|
1168
1648
|
existingMessageHash: err.existingMessageHash,
|
|
1169
1649
|
attemptedMessageHash: err.attemptedMessageHash
|
|
1170
1650
|
});
|
|
@@ -1181,7 +1661,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1181
1661
|
await sleep(TXS_POLLING_MS);
|
|
1182
1662
|
}
|
|
1183
1663
|
getSlotStartBuildTimestamp() {
|
|
1184
|
-
return getSlotStartBuildTimestamp(this.
|
|
1664
|
+
return getSlotStartBuildTimestamp(this.slotNow, this.l1Constants);
|
|
1185
1665
|
}
|
|
1186
1666
|
getSecondsIntoSlot() {
|
|
1187
1667
|
const slotStartTimestamp = this.getSlotStartBuildTimestamp();
|