@aztec/sequencer-client 0.0.1-commit.96bb3f7 → 0.0.1-commit.9d2bcf6d
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.js +1 -1
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +1 -3
- package/dest/global_variable_builder/global_builder.js +2 -2
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/publisher/sequencer-publisher-metrics.d.ts +1 -1
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +12 -4
- package/dest/publisher/sequencer-publisher.d.ts +1 -2
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +39 -18
- package/dest/sequencer/checkpoint_proposal_job.d.ts +32 -9
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +130 -31
- package/dest/sequencer/checkpoint_voter.d.ts +3 -2
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_voter.js +34 -10
- package/dest/sequencer/index.d.ts +1 -2
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +0 -1
- package/dest/sequencer/metrics.d.ts +2 -2
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +27 -17
- package/dest/sequencer/sequencer.d.ts +19 -9
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +72 -12
- package/dest/test/mock_checkpoint_builder.d.ts +17 -13
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +28 -10
- package/dest/test/utils.d.ts +8 -8
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +7 -7
- package/package.json +30 -28
- package/src/client/sequencer-client.ts +1 -1
- package/src/config.ts +1 -3
- package/src/global_variable_builder/global_builder.ts +2 -2
- package/src/index.ts +1 -6
- package/src/publisher/sequencer-publisher-metrics.ts +7 -3
- package/src/publisher/sequencer-publisher.ts +34 -18
- package/src/sequencer/checkpoint_proposal_job.ts +181 -51
- package/src/sequencer/checkpoint_voter.ts +32 -7
- package/src/sequencer/index.ts +0 -1
- package/src/sequencer/metrics.ts +36 -18
- package/src/sequencer/sequencer.ts +89 -11
- package/src/test/mock_checkpoint_builder.ts +64 -34
- package/src/test/utils.ts +19 -12
- package/dest/sequencer/block_builder.d.ts +0 -26
- package/dest/sequencer/block_builder.d.ts.map +0 -1
- package/dest/sequencer/block_builder.js +0 -129
- package/src/sequencer/block_builder.ts +0 -216
|
@@ -436,21 +436,25 @@ 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 { NUM_CHECKPOINT_END_MARKER_FIELDS, getNumBlockEndBlobFields } from '@aztec/blob-lib/encoding';
|
|
439
440
|
import { BLOBS_PER_CHECKPOINT, FIELDS_PER_BLOB } from '@aztec/constants';
|
|
440
|
-
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
441
|
+
import { BlockNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
441
442
|
import { randomInt } from '@aztec/foundation/crypto/random';
|
|
442
443
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
443
444
|
import { filter } from '@aztec/foundation/iterator';
|
|
445
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
444
446
|
import { sleep, sleepUntil } from '@aztec/foundation/sleep';
|
|
445
447
|
import { Timer } from '@aztec/foundation/timer';
|
|
446
|
-
import { unfreeze } from '@aztec/foundation/types';
|
|
448
|
+
import { isErrorClass, unfreeze } from '@aztec/foundation/types';
|
|
447
449
|
import { CommitteeAttestationsAndSigners, MaliciousCommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
448
450
|
import { getSlotStartBuildTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
449
451
|
import { Gas } from '@aztec/stdlib/gas';
|
|
452
|
+
import { NoValidTxsError } from '@aztec/stdlib/interfaces/server';
|
|
450
453
|
import { computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
|
|
451
454
|
import { orderAttestations } from '@aztec/stdlib/p2p';
|
|
452
455
|
import { AttestationTimeoutError } from '@aztec/stdlib/validators';
|
|
453
456
|
import { Attributes, trackSpan } from '@aztec/telemetry-client';
|
|
457
|
+
import { DutyAlreadySignedError, SlashingProtectionError } from '@aztec/validator-ha-signer/errors';
|
|
454
458
|
import { CheckpointVoter } from './checkpoint_voter.js';
|
|
455
459
|
import { SequencerInterruptedError } from './errors.js';
|
|
456
460
|
import { SequencerState } from './utils.js';
|
|
@@ -468,6 +472,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
468
472
|
* as well as enqueueing votes for slashing and governance proposals. This class is created from
|
|
469
473
|
* the Sequencer once the check for being the proposer for the slot has succeeded.
|
|
470
474
|
*/ export class CheckpointProposalJob {
|
|
475
|
+
epoch;
|
|
471
476
|
slot;
|
|
472
477
|
checkpointNumber;
|
|
473
478
|
syncedToBlockNumber;
|
|
@@ -480,6 +485,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
480
485
|
p2pClient;
|
|
481
486
|
worldState;
|
|
482
487
|
l1ToL2MessageSource;
|
|
488
|
+
l2BlockSource;
|
|
483
489
|
checkpointsBuilder;
|
|
484
490
|
blockSink;
|
|
485
491
|
l1Constants;
|
|
@@ -491,7 +497,6 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
491
497
|
metrics;
|
|
492
498
|
eventEmitter;
|
|
493
499
|
setStateFn;
|
|
494
|
-
log;
|
|
495
500
|
tracer;
|
|
496
501
|
static{
|
|
497
502
|
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
@@ -537,8 +542,10 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
537
542
|
]
|
|
538
543
|
], []));
|
|
539
544
|
}
|
|
540
|
-
|
|
541
|
-
|
|
545
|
+
log;
|
|
546
|
+
constructor(epoch, slot, checkpointNumber, syncedToBlockNumber, // TODO(palla/mbps): Can we remove the proposer in favor of attestorAddress? Need to check fisherman-node flows.
|
|
547
|
+
proposer, publisher, attestorAddress, invalidateCheckpoint, validatorClient, globalsBuilder, p2pClient, worldState, l1ToL2MessageSource, l2BlockSource, checkpointsBuilder, blockSink, l1Constants, config, timetable, slasherClient, epochCache, dateProvider, metrics, eventEmitter, setStateFn, tracer, bindings){
|
|
548
|
+
this.epoch = epoch;
|
|
542
549
|
this.slot = slot;
|
|
543
550
|
this.checkpointNumber = checkpointNumber;
|
|
544
551
|
this.syncedToBlockNumber = syncedToBlockNumber;
|
|
@@ -551,6 +558,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
551
558
|
this.p2pClient = p2pClient;
|
|
552
559
|
this.worldState = worldState;
|
|
553
560
|
this.l1ToL2MessageSource = l1ToL2MessageSource;
|
|
561
|
+
this.l2BlockSource = l2BlockSource;
|
|
554
562
|
this.checkpointsBuilder = checkpointsBuilder;
|
|
555
563
|
this.blockSink = blockSink;
|
|
556
564
|
this.l1Constants = l1Constants;
|
|
@@ -562,9 +570,12 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
562
570
|
this.metrics = metrics;
|
|
563
571
|
this.eventEmitter = eventEmitter;
|
|
564
572
|
this.setStateFn = setStateFn;
|
|
565
|
-
this.log = log;
|
|
566
573
|
this.tracer = tracer;
|
|
567
574
|
_initProto(this);
|
|
575
|
+
this.log = createLogger('sequencer:checkpoint-proposal', {
|
|
576
|
+
...bindings,
|
|
577
|
+
instanceId: `slot-${slot}`
|
|
578
|
+
});
|
|
568
579
|
}
|
|
569
580
|
/**
|
|
570
581
|
* Executes the checkpoint proposal job.
|
|
@@ -628,11 +639,14 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
628
639
|
// Collect L1 to L2 messages for the checkpoint and compute their hash
|
|
629
640
|
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(this.checkpointNumber);
|
|
630
641
|
const inHash = computeInHashFromL1ToL2Messages(l1ToL2Messages);
|
|
642
|
+
// Collect the out hashes of all the checkpoints before this one in the same epoch
|
|
643
|
+
const previousCheckpoints = (await this.l2BlockSource.getCheckpointsForEpoch(this.epoch)).filter((c)=>c.number < this.checkpointNumber);
|
|
644
|
+
const previousCheckpointOutHashes = previousCheckpoints.map((c)=>c.getCheckpointOutHash());
|
|
631
645
|
const fork = _ts_add_disposable_resource(env, await this.worldState.fork(this.syncedToBlockNumber, {
|
|
632
646
|
closeDelayMs: 12_000
|
|
633
647
|
}), false);
|
|
634
648
|
// Create checkpoint builder for the entire slot
|
|
635
|
-
const checkpointBuilder = await this.checkpointsBuilder.startCheckpoint(this.checkpointNumber, checkpointGlobalVariables, l1ToL2Messages, fork);
|
|
649
|
+
const checkpointBuilder = await this.checkpointsBuilder.startCheckpoint(this.checkpointNumber, checkpointGlobalVariables, l1ToL2Messages, previousCheckpointOutHashes, fork, this.log.getBindings());
|
|
636
650
|
// Options for the validator client when creating block and checkpoint proposals
|
|
637
651
|
const blockProposalOptions = {
|
|
638
652
|
publishFullTxs: !!this.config.publishTxsWithProposals,
|
|
@@ -642,8 +656,22 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
642
656
|
publishFullTxs: !!this.config.publishTxsWithProposals,
|
|
643
657
|
broadcastInvalidCheckpointProposal: this.config.broadcastInvalidBlockProposal
|
|
644
658
|
};
|
|
645
|
-
|
|
646
|
-
|
|
659
|
+
let blocksInCheckpoint = [];
|
|
660
|
+
let blockPendingBroadcast = undefined;
|
|
661
|
+
try {
|
|
662
|
+
// Main loop: build blocks for the checkpoint
|
|
663
|
+
const result = await this.buildBlocksForCheckpoint(checkpointBuilder, checkpointGlobalVariables.timestamp, inHash, blockProposalOptions);
|
|
664
|
+
blocksInCheckpoint = result.blocksInCheckpoint;
|
|
665
|
+
blockPendingBroadcast = result.blockPendingBroadcast;
|
|
666
|
+
} catch (err) {
|
|
667
|
+
// These errors are expected in HA mode, so we yield and let another HA node handle the slot
|
|
668
|
+
// The only distinction between the 2 errors is SlashingProtectionError throws when the payload is different,
|
|
669
|
+
// which is normal for block building (may have picked different txs)
|
|
670
|
+
if (this.handleHASigningError(err, 'Block proposal')) {
|
|
671
|
+
return undefined;
|
|
672
|
+
}
|
|
673
|
+
throw err;
|
|
674
|
+
}
|
|
647
675
|
if (blocksInCheckpoint.length === 0) {
|
|
648
676
|
this.log.warn(`No blocks were built for slot ${this.slot}`, {
|
|
649
677
|
slot: this.slot
|
|
@@ -683,7 +711,17 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
683
711
|
this.metrics.recordCheckpointAttestationDelay(blockAttestedAt - blockProposedAt);
|
|
684
712
|
// Proposer must sign over the attestations before pushing them to L1
|
|
685
713
|
const signer = this.proposer ?? this.publisher.getSenderAddress();
|
|
686
|
-
|
|
714
|
+
let attestationsSignature;
|
|
715
|
+
try {
|
|
716
|
+
attestationsSignature = await this.validatorClient.signAttestationsAndSigners(attestations, signer, this.slot, this.checkpointNumber);
|
|
717
|
+
} catch (err) {
|
|
718
|
+
// We shouldn't really get here since we yield to another HA node
|
|
719
|
+
// as soon as we see these errors when creating block or checkpoint proposals.
|
|
720
|
+
if (this.handleHASigningError(err, 'Attestations signature')) {
|
|
721
|
+
return undefined;
|
|
722
|
+
}
|
|
723
|
+
throw err;
|
|
724
|
+
}
|
|
687
725
|
// Enqueue publishing the checkpoint to L1
|
|
688
726
|
this.setStateFn(SequencerState.PUBLISHING_CHECKPOINT, this.slot);
|
|
689
727
|
const aztecSlotDuration = this.l1Constants.slotDuration;
|
|
@@ -701,6 +739,10 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
701
739
|
_ts_dispose_resources(env);
|
|
702
740
|
}
|
|
703
741
|
} catch (err) {
|
|
742
|
+
if (err && (err instanceof DutyAlreadySignedError || err instanceof SlashingProtectionError)) {
|
|
743
|
+
// swallow this error. It's already been logged by a function deeper in the stack
|
|
744
|
+
return undefined;
|
|
745
|
+
}
|
|
704
746
|
this.log.error(`Error building checkpoint at slot ${this.slot}`, err);
|
|
705
747
|
return undefined;
|
|
706
748
|
}
|
|
@@ -711,11 +753,13 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
711
753
|
const blocksInCheckpoint = [];
|
|
712
754
|
const txHashesAlreadyIncluded = new Set();
|
|
713
755
|
const initialBlockNumber = BlockNumber(this.syncedToBlockNumber + 1);
|
|
756
|
+
// Remaining blob fields available for blocks (checkpoint end marker already subtracted)
|
|
757
|
+
let remainingBlobFields = BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB - NUM_CHECKPOINT_END_MARKER_FIELDS;
|
|
714
758
|
// Last block in the checkpoint will usually be flagged as pending broadcast, so we send it along with the checkpoint proposal
|
|
715
759
|
let blockPendingBroadcast = undefined;
|
|
716
760
|
while(true){
|
|
717
761
|
const blocksBuilt = blocksInCheckpoint.length;
|
|
718
|
-
const indexWithinCheckpoint = blocksBuilt;
|
|
762
|
+
const indexWithinCheckpoint = IndexWithinCheckpoint(blocksBuilt);
|
|
719
763
|
const blockNumber = BlockNumber(initialBlockNumber + blocksBuilt);
|
|
720
764
|
const secondsIntoSlot = this.getSecondsIntoSlot();
|
|
721
765
|
const timingInfo = this.timetable.canStartNextBlock(secondsIntoSlot);
|
|
@@ -736,8 +780,10 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
736
780
|
buildDeadline: timingInfo.deadline ? new Date((this.getSlotStartBuildTimestamp() + timingInfo.deadline) * 1000) : undefined,
|
|
737
781
|
blockNumber,
|
|
738
782
|
indexWithinCheckpoint,
|
|
739
|
-
txHashesAlreadyIncluded
|
|
783
|
+
txHashesAlreadyIncluded,
|
|
784
|
+
remainingBlobFields
|
|
740
785
|
});
|
|
786
|
+
// TODO(palla/mbps): Review these conditions. We may want to keep trying in some scenarios.
|
|
741
787
|
if (!buildResult && timingInfo.isLastBlock) {
|
|
742
788
|
break;
|
|
743
789
|
} else if (!buildResult && timingInfo.deadline !== undefined) {
|
|
@@ -757,12 +803,21 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
757
803
|
}
|
|
758
804
|
break;
|
|
759
805
|
}
|
|
760
|
-
const { block, usedTxs } = buildResult;
|
|
806
|
+
const { block, usedTxs, remainingBlobFields: newRemainingBlobFields } = buildResult;
|
|
761
807
|
blocksInCheckpoint.push(block);
|
|
808
|
+
// Update remaining blob fields for the next block
|
|
809
|
+
remainingBlobFields = newRemainingBlobFields;
|
|
762
810
|
// Sync the proposed block to the archiver to make it available
|
|
763
811
|
// Note that the checkpoint builder uses its own fork so it should not need to wait for this syncing
|
|
764
812
|
// Eventually we should refactor the checkpoint builder to not need a separate long-lived fork
|
|
765
|
-
|
|
813
|
+
// Fire and forget - don't block the critical path, but log errors
|
|
814
|
+
this.syncProposedBlockToArchiver(block).catch((err)=>{
|
|
815
|
+
this.log.error(`Failed to sync proposed block ${block.number} to archiver`, {
|
|
816
|
+
blockNumber: block.number,
|
|
817
|
+
err
|
|
818
|
+
});
|
|
819
|
+
});
|
|
820
|
+
usedTxs.forEach((tx)=>txHashesAlreadyIncluded.add(tx.txHash.toString()));
|
|
766
821
|
// If this is the last block, exit the loop now so we start collecting attestations
|
|
767
822
|
if (timingInfo.isLastBlock) {
|
|
768
823
|
this.log.verbose(`Completed final block ${blockNumber} for slot ${this.slot}`, {
|
|
@@ -802,7 +857,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
802
857
|
await this.waitUntilTimeInSlot(nextSubslotStart);
|
|
803
858
|
}
|
|
804
859
|
/** Builds a single block. Called from the main block building loop. */ async buildSingleBlock(checkpointBuilder, opts) {
|
|
805
|
-
const { blockTimestamp, forceCreate, blockNumber, indexWithinCheckpoint, buildDeadline, txHashesAlreadyIncluded } = opts;
|
|
860
|
+
const { blockTimestamp, forceCreate, blockNumber, indexWithinCheckpoint, buildDeadline, txHashesAlreadyIncluded, remainingBlobFields } = opts;
|
|
806
861
|
this.log.verbose(`Preparing block ${blockNumber} index ${indexWithinCheckpoint} at checkpoint ${this.checkpointNumber} for slot ${this.slot}`, {
|
|
807
862
|
...checkpointBuilder.getConstantData(),
|
|
808
863
|
...opts
|
|
@@ -834,43 +889,46 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
834
889
|
indexWithinCheckpoint
|
|
835
890
|
});
|
|
836
891
|
this.setStateFn(SequencerState.CREATING_BLOCK, this.slot);
|
|
892
|
+
// Calculate blob fields limit for txs (remaining capacity - this block's end overhead)
|
|
893
|
+
const blockEndOverhead = getNumBlockEndBlobFields(indexWithinCheckpoint === 0);
|
|
894
|
+
const maxBlobFieldsForTxs = remainingBlobFields - blockEndOverhead;
|
|
837
895
|
const blockBuilderOptions = {
|
|
838
896
|
maxTransactions: this.config.maxTxsPerBlock,
|
|
839
897
|
maxBlockSize: this.config.maxBlockSizeInBytes,
|
|
840
898
|
maxBlockGas: new Gas(this.config.maxDABlockGas, this.config.maxL2BlockGas),
|
|
841
|
-
maxBlobFields:
|
|
899
|
+
maxBlobFields: maxBlobFieldsForTxs,
|
|
842
900
|
deadline: buildDeadline
|
|
843
901
|
};
|
|
844
902
|
// Actually build the block by executing txs
|
|
845
|
-
const
|
|
846
|
-
const { publicGas, block, publicProcessorDuration, numTxs, blockBuildingTimer, usedTxs, failedTxs } = await checkpointBuilder.buildBlock(pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions);
|
|
847
|
-
const blockBuildDuration = workTimer.ms();
|
|
903
|
+
const buildResult = await this.buildSingleBlockWithCheckpointBuilder(checkpointBuilder, pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions);
|
|
848
904
|
// If any txs failed during execution, drop them from the mempool so we don't pick them up again
|
|
849
|
-
await this.dropFailedTxsFromP2P(failedTxs);
|
|
905
|
+
await this.dropFailedTxsFromP2P(buildResult.failedTxs);
|
|
850
906
|
// Check if we have created a block with enough txs. If there were invalid txs in the pool, or if execution took
|
|
851
907
|
// too long, then we may not get to minTxsPerBlock after executing public functions.
|
|
852
908
|
const minValidTxs = this.config.minValidTxsPerBlock ?? minTxs;
|
|
853
|
-
|
|
854
|
-
|
|
909
|
+
const numTxs = buildResult.status === 'no-valid-txs' ? 0 : buildResult.numTxs;
|
|
910
|
+
if (buildResult.status === 'no-valid-txs' || !forceCreate && numTxs < minValidTxs) {
|
|
911
|
+
this.log.warn(`Block ${blockNumber} at index ${indexWithinCheckpoint} on slot ${this.slot} has too few valid txs to be proposed`, {
|
|
855
912
|
slot: this.slot,
|
|
856
913
|
blockNumber,
|
|
857
914
|
numTxs,
|
|
858
|
-
indexWithinCheckpoint
|
|
915
|
+
indexWithinCheckpoint,
|
|
916
|
+
minValidTxs,
|
|
917
|
+
buildResult: buildResult.status
|
|
859
918
|
});
|
|
860
|
-
this.eventEmitter.emit('block-
|
|
861
|
-
|
|
862
|
-
availableTxs: numTxs,
|
|
919
|
+
this.eventEmitter.emit('block-build-failed', {
|
|
920
|
+
reason: `Insufficient valid txs`,
|
|
863
921
|
slot: this.slot
|
|
864
922
|
});
|
|
865
923
|
this.metrics.recordBlockProposalFailed('insufficient_valid_txs');
|
|
866
924
|
return undefined;
|
|
867
925
|
}
|
|
868
926
|
// Block creation succeeded, emit stats and metrics
|
|
927
|
+
const { publicGas, block, publicProcessorDuration, usedTxs, usedTxBlobFields, blockBuildDuration } = buildResult;
|
|
869
928
|
const blockStats = {
|
|
870
929
|
eventName: 'l2-block-built',
|
|
871
930
|
duration: blockBuildDuration,
|
|
872
931
|
publicProcessDuration: publicProcessorDuration,
|
|
873
|
-
rollupCircuitsDuration: blockBuildingTimer.ms(),
|
|
874
932
|
...block.getStats()
|
|
875
933
|
};
|
|
876
934
|
const blockHash = await block.hash();
|
|
@@ -889,7 +947,8 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
889
947
|
this.metrics.recordBuiltBlock(blockBuildDuration, publicGas.l2Gas);
|
|
890
948
|
return {
|
|
891
949
|
block,
|
|
892
|
-
usedTxs
|
|
950
|
+
usedTxs,
|
|
951
|
+
remainingBlobFields: maxBlobFieldsForTxs - usedTxBlobFields
|
|
893
952
|
};
|
|
894
953
|
} catch (err) {
|
|
895
954
|
this.eventEmitter.emit('block-build-failed', {
|
|
@@ -907,9 +966,30 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
907
966
|
};
|
|
908
967
|
}
|
|
909
968
|
}
|
|
969
|
+
/** Uses the checkpoint builder to build a block, catching specific txs */ async buildSingleBlockWithCheckpointBuilder(checkpointBuilder, pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions) {
|
|
970
|
+
try {
|
|
971
|
+
const workTimer = new Timer();
|
|
972
|
+
const result = await checkpointBuilder.buildBlock(pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions);
|
|
973
|
+
const blockBuildDuration = workTimer.ms();
|
|
974
|
+
return {
|
|
975
|
+
...result,
|
|
976
|
+
blockBuildDuration,
|
|
977
|
+
status: 'success'
|
|
978
|
+
};
|
|
979
|
+
} catch (err) {
|
|
980
|
+
if (isErrorClass(err, NoValidTxsError)) {
|
|
981
|
+
return {
|
|
982
|
+
failedTxs: err.failedTxs,
|
|
983
|
+
status: 'no-valid-txs'
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
throw err;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
910
989
|
/** Waits until minTxs are available on the pool for building a block. */ async waitForMinTxs(opts) {
|
|
911
|
-
const minTxs = this.config.minTxsPerBlock;
|
|
912
990
|
const { indexWithinCheckpoint, blockNumber, buildDeadline, forceCreate } = opts;
|
|
991
|
+
// We only allow a block with 0 txs in the first block of the checkpoint
|
|
992
|
+
const minTxs = indexWithinCheckpoint > 0 && this.config.minTxsPerBlock === 0 ? 1 : this.config.minTxsPerBlock;
|
|
913
993
|
// Deadline is undefined if we are not enforcing the timetable, meaning we'll exit immediately when out of time
|
|
914
994
|
const startBuildingDeadline = buildDeadline ? new Date(buildDeadline.getTime() - this.timetable.minExecutionTime * 1000) : undefined;
|
|
915
995
|
let availableTxs = await this.p2pClient.getPendingTxCount();
|
|
@@ -964,7 +1044,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
964
1044
|
return new CommitteeAttestationsAndSigners(orderAttestations(attestations ?? [], committee));
|
|
965
1045
|
}
|
|
966
1046
|
const attestationTimeAllowed = this.config.enforceTimeTable ? this.timetable.getMaxAllowedTime(SequencerState.PUBLISHING_CHECKPOINT) : this.l1Constants.slotDuration;
|
|
967
|
-
const attestationDeadline = new Date(this.
|
|
1047
|
+
const attestationDeadline = new Date((this.getSlotStartBuildTimestamp() + attestationTimeAllowed) * 1000);
|
|
968
1048
|
this.metrics.recordRequiredAttestations(numberOfRequiredAttestations, attestationTimeAllowed);
|
|
969
1049
|
const collectAttestationsTimer = new Timer();
|
|
970
1050
|
let collectedAttestationsCount = 0;
|
|
@@ -1038,7 +1118,6 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1038
1118
|
* Gossip doesn't echo messages back to the sender, so the proposer's archiver/world-state
|
|
1039
1119
|
* would never receive its own block without this explicit sync.
|
|
1040
1120
|
*/ async syncProposedBlockToArchiver(block) {
|
|
1041
|
-
// TODO(palla/mbps): Change default to false once block sync is stable.
|
|
1042
1121
|
if (this.config.skipPushProposedBlocksToArchiver !== false) {
|
|
1043
1122
|
this.log.warn(`Skipping push of proposed block ${block.number} to archiver`, {
|
|
1044
1123
|
blockNumber: block.number,
|
|
@@ -1071,6 +1150,26 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1071
1150
|
}
|
|
1072
1151
|
this.publisher.clearPendingRequests();
|
|
1073
1152
|
}
|
|
1153
|
+
/**
|
|
1154
|
+
* Helper to handle HA double-signing errors. Returns true if the error was handled (caller should yield).
|
|
1155
|
+
*/ handleHASigningError(err, errorContext) {
|
|
1156
|
+
if (err instanceof DutyAlreadySignedError) {
|
|
1157
|
+
this.log.info(`${errorContext} for slot ${this.slot} already signed by another HA node, yielding`, {
|
|
1158
|
+
slot: this.slot,
|
|
1159
|
+
signedByNode: err.signedByNode
|
|
1160
|
+
});
|
|
1161
|
+
return true;
|
|
1162
|
+
}
|
|
1163
|
+
if (err instanceof SlashingProtectionError) {
|
|
1164
|
+
this.log.info(`${errorContext} for slot ${this.slot} blocked by slashing protection, yielding`, {
|
|
1165
|
+
slot: this.slot,
|
|
1166
|
+
existingMessageHash: err.existingMessageHash,
|
|
1167
|
+
attemptedMessageHash: err.attemptedMessageHash
|
|
1168
|
+
});
|
|
1169
|
+
return true;
|
|
1170
|
+
}
|
|
1171
|
+
return false;
|
|
1172
|
+
}
|
|
1074
1173
|
/** Waits until a specific time within the current slot */ async waitUntilTimeInSlot(targetSecondsIntoSlot) {
|
|
1075
1174
|
const slotStartTimestamp = this.getSlotStartBuildTimestamp();
|
|
1076
1175
|
const targetTimestamp = slotStartTimestamp + targetSecondsIntoSlot;
|
|
@@ -21,7 +21,8 @@ export declare class CheckpointVoter {
|
|
|
21
21
|
private readonly metrics;
|
|
22
22
|
private readonly log;
|
|
23
23
|
private slotTimestamp;
|
|
24
|
-
private
|
|
24
|
+
private governanceSigner;
|
|
25
|
+
private slashingSigner;
|
|
25
26
|
constructor(slot: SlotNumber, publisher: SequencerPublisher, attestorAddress: EthAddress, validatorClient: ValidatorClient, slasherClient: SlasherClientInterface | undefined, l1Constants: SequencerRollupConstants, config: ResolvedSequencerConfig, metrics: SequencerMetrics, log: Logger);
|
|
26
27
|
/**
|
|
27
28
|
* Enqueues governance and slashing votes with the publisher.
|
|
@@ -31,4 +32,4 @@ export declare class CheckpointVoter {
|
|
|
31
32
|
private enqueueGovernanceVote;
|
|
32
33
|
private enqueueSlashingVote;
|
|
33
34
|
}
|
|
34
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
35
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlY2twb2ludF92b3Rlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NlcXVlbmNlci9jaGVja3BvaW50X3ZvdGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2xFLE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBQ2hFLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLHNCQUFzQixFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFFN0QsT0FBTyxLQUFLLEVBQUUsdUJBQXVCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUMvRSxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSx5QkF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ztJQUNILFlBQVksSUFBSSxDQUFDLE9BQU8sQ0FBQyxPQUFPLEdBQUcsU0FBUyxDQUFDLEVBQUUsT0FBTyxDQUFDLE9BQU8sR0FBRyxTQUFTLENBQUMsQ0FBQyxDQVUzRTtZQUVhLHFCQUFxQjtZQWdDckIsbUJBQW1CO0NBaUNsQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkpoint_voter.d.ts","sourceRoot":"","sources":["../../src/sequencer/checkpoint_voter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"checkpoint_voter.d.ts","sourceRoot":"","sources":["../../src/sequencer/checkpoint_voter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAM/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3D;;GAEG;AACH,qBAAa,eAAe;IAMxB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAbtB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,gBAAgB,CAAuD;IAC/E,OAAO,CAAC,cAAc,CAAuD;IAE7E,YACmB,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,kBAAkB,EAC7B,eAAe,EAAE,UAAU,EAC3B,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,sBAAsB,GAAG,SAAS,EACjD,WAAW,EAAE,wBAAwB,EACrC,MAAM,EAAE,uBAAuB,EAC/B,OAAO,EAAE,gBAAgB,EACzB,GAAG,EAAE,MAAM,EAa7B;IAED;;;OAGG;IACH,YAAY,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC,CAU3E;YAEa,qBAAqB;YAgCrB,mBAAmB;CAiClC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
2
|
+
import { DutyAlreadySignedError } from '@aztec/validator-ha-signer/errors';
|
|
3
|
+
import { DutyType } from '@aztec/validator-ha-signer/types';
|
|
2
4
|
/**
|
|
3
5
|
* Handles governance and slashing voting for a given slot.
|
|
4
6
|
*/ export class CheckpointVoter {
|
|
@@ -12,7 +14,8 @@ import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
|
12
14
|
metrics;
|
|
13
15
|
log;
|
|
14
16
|
slotTimestamp;
|
|
15
|
-
|
|
17
|
+
governanceSigner;
|
|
18
|
+
slashingSigner;
|
|
16
19
|
constructor(slot, publisher, attestorAddress, validatorClient, slasherClient, l1Constants, config, metrics, log){
|
|
17
20
|
this.slot = slot;
|
|
18
21
|
this.publisher = publisher;
|
|
@@ -24,7 +27,18 @@ import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
|
24
27
|
this.metrics = metrics;
|
|
25
28
|
this.log = log;
|
|
26
29
|
this.slotTimestamp = getTimestampForSlot(this.slot, this.l1Constants);
|
|
27
|
-
|
|
30
|
+
// Create separate signers with appropriate duty contexts for governance and slashing votes
|
|
31
|
+
// These use HA protection to ensure only one node signs per slot/duty
|
|
32
|
+
const governanceContext = {
|
|
33
|
+
slot: this.slot,
|
|
34
|
+
dutyType: DutyType.GOVERNANCE_VOTE
|
|
35
|
+
};
|
|
36
|
+
this.governanceSigner = (msg)=>this.validatorClient.signWithAddress(this.attestorAddress, msg, governanceContext).then((s)=>s.toString());
|
|
37
|
+
const slashingContext = {
|
|
38
|
+
slot: this.slot,
|
|
39
|
+
dutyType: DutyType.SLASHING_VOTE
|
|
40
|
+
};
|
|
41
|
+
this.slashingSigner = (msg)=>this.validatorClient.signWithAddress(this.attestorAddress, msg, slashingContext).then((s)=>s.toString());
|
|
28
42
|
}
|
|
29
43
|
/**
|
|
30
44
|
* Enqueues governance and slashing votes with the publisher.
|
|
@@ -55,11 +69,16 @@ import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
|
55
69
|
governanceProposerPayload: governanceProposerPayload.toString()
|
|
56
70
|
});
|
|
57
71
|
try {
|
|
58
|
-
return await this.publisher.enqueueGovernanceCastSignal(governanceProposerPayload, this.slot, this.slotTimestamp, this.attestorAddress, this.
|
|
72
|
+
return await this.publisher.enqueueGovernanceCastSignal(governanceProposerPayload, this.slot, this.slotTimestamp, this.attestorAddress, this.governanceSigner);
|
|
59
73
|
} catch (err) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
74
|
+
if (err instanceof DutyAlreadySignedError) {
|
|
75
|
+
this.log.info(`Governance vote already signed by another node`, {
|
|
76
|
+
slot: this.slot,
|
|
77
|
+
signedByNode: err.signedByNode
|
|
78
|
+
});
|
|
79
|
+
} else {
|
|
80
|
+
this.log.error(`Error enqueueing governance vote`, err);
|
|
81
|
+
}
|
|
63
82
|
return false;
|
|
64
83
|
}
|
|
65
84
|
}
|
|
@@ -74,11 +93,16 @@ import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
|
74
93
|
actionCount: actions.length
|
|
75
94
|
});
|
|
76
95
|
this.metrics.recordSlashingAttempt(actions.length);
|
|
77
|
-
return await this.publisher.enqueueSlashingActions(actions, this.slot, this.slotTimestamp, this.attestorAddress, this.
|
|
96
|
+
return await this.publisher.enqueueSlashingActions(actions, this.slot, this.slotTimestamp, this.attestorAddress, this.slashingSigner);
|
|
78
97
|
} catch (err) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
98
|
+
if (err instanceof DutyAlreadySignedError) {
|
|
99
|
+
this.log.info(`Slashing vote already signed by another node`, {
|
|
100
|
+
slot: this.slot,
|
|
101
|
+
signedByNode: err.signedByNode
|
|
102
|
+
});
|
|
103
|
+
} else {
|
|
104
|
+
this.log.error(`Error enqueueing slashing vote`, err);
|
|
105
|
+
}
|
|
82
106
|
return false;
|
|
83
107
|
}
|
|
84
108
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export * from './block_builder.js';
|
|
2
1
|
export * from './checkpoint_proposal_job.js';
|
|
3
2
|
export * from './checkpoint_voter.js';
|
|
4
3
|
export * from './config.js';
|
|
5
4
|
export * from './events.js';
|
|
6
5
|
export * from './sequencer.js';
|
|
7
|
-
//# 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"}
|
package/dest/sequencer/index.js
CHANGED
|
@@ -49,7 +49,7 @@ export declare class SequencerMetrics {
|
|
|
49
49
|
recordCheckpointSuccess(): void;
|
|
50
50
|
recordBlockProposalFailed(reason?: string): void;
|
|
51
51
|
recordBlockProposalSuccess(): void;
|
|
52
|
-
recordBlockProposalPrecheckFailed(checkType:
|
|
52
|
+
recordBlockProposalPrecheckFailed(checkType: 'slot_already_taken' | 'rollup_contract_check_failed' | 'slot_mismatch' | 'block_number_mismatch'): void;
|
|
53
53
|
recordSlashingAttempt(actionCount: number): void;
|
|
54
54
|
/**
|
|
55
55
|
* Records metrics for a completed fisherman fee analysis
|
|
@@ -57,4 +57,4 @@ export declare class SequencerMetrics {
|
|
|
57
57
|
*/
|
|
58
58
|
recordFishermanFeeAnalysis(analysis: L1FeeAnalysisResult): void;
|
|
59
59
|
}
|
|
60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qB,CAAC,WAAW,EAAE,MAAM,QAExC;IAED;;;OAGG;IACH,0BAA0B,CAAC,QAAQ,EAAE,mBAAmB,QAqFvD;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Attributes, Metrics } from '@aztec/telemetry-client';
|
|
1
|
+
import { Attributes, Metrics, createUpDownCounterWithDefault } from '@aztec/telemetry-client';
|
|
2
2
|
import { formatUnits } from 'viem';
|
|
3
3
|
// TODO(palla/mbps): Review all metrics and add any missing ones per checkpoint
|
|
4
4
|
export class SequencerMetrics {
|
|
@@ -39,35 +39,45 @@ export class SequencerMetrics {
|
|
|
39
39
|
this.rollup = rollup;
|
|
40
40
|
this.meter = client.getMeter(name);
|
|
41
41
|
this.tracer = client.getTracer(name);
|
|
42
|
-
this.blockCounter = this.meter
|
|
42
|
+
this.blockCounter = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_BLOCK_COUNT, {
|
|
43
|
+
[Attributes.STATUS]: [
|
|
44
|
+
'failed',
|
|
45
|
+
'built'
|
|
46
|
+
]
|
|
47
|
+
});
|
|
43
48
|
this.blockBuildDuration = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_DURATION);
|
|
44
49
|
this.blockBuildManaPerSecond = this.meter.createGauge(Metrics.SEQUENCER_BLOCK_BUILD_MANA_PER_SECOND);
|
|
45
50
|
this.stateTransitionBufferDuration = this.meter.createHistogram(Metrics.SEQUENCER_STATE_TRANSITION_BUFFER_DURATION);
|
|
46
51
|
this.checkpointAttestationDelay = this.meter.createHistogram(Metrics.SEQUENCER_CHECKPOINT_ATTESTATION_DELAY);
|
|
47
|
-
// Init gauges and counters
|
|
48
|
-
this.blockCounter.add(0, {
|
|
49
|
-
[Attributes.STATUS]: 'failed'
|
|
50
|
-
});
|
|
51
|
-
this.blockCounter.add(0, {
|
|
52
|
-
[Attributes.STATUS]: 'built'
|
|
53
|
-
});
|
|
54
52
|
this.rewards = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_REWARDS);
|
|
55
|
-
this.slots = this.meter
|
|
53
|
+
this.slots = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLOT_COUNT);
|
|
56
54
|
/**
|
|
57
55
|
* NOTE: we do not track missed slots as a separate metric. That would be difficult to determine
|
|
58
56
|
* Instead, use a computed metric, `slots - filledSlots` to get the number of slots a sequencer has missed.
|
|
59
|
-
*/ this.filledSlots = this.meter
|
|
57
|
+
*/ this.filledSlots = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_FILLED_SLOT_COUNT);
|
|
60
58
|
this.timeToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_DURATION);
|
|
61
59
|
this.allowanceToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_TIME_ALLOWANCE);
|
|
62
60
|
this.requiredAttestions = this.meter.createGauge(Metrics.SEQUENCER_REQUIRED_ATTESTATIONS_COUNT);
|
|
63
61
|
this.collectedAttestions = this.meter.createGauge(Metrics.SEQUENCER_COLLECTED_ATTESTATIONS_COUNT);
|
|
64
|
-
this.blockProposalFailed = this.meter
|
|
65
|
-
this.blockProposalSuccess = this.meter
|
|
66
|
-
this.checkpointSuccess = this.meter
|
|
67
|
-
this.blockProposalPrecheckFailed = this.meter
|
|
68
|
-
|
|
62
|
+
this.blockProposalFailed = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_BLOCK_PROPOSAL_FAILED_COUNT);
|
|
63
|
+
this.blockProposalSuccess = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_BLOCK_PROPOSAL_SUCCESS_COUNT);
|
|
64
|
+
this.checkpointSuccess = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_CHECKPOINT_SUCCESS_COUNT);
|
|
65
|
+
this.blockProposalPrecheckFailed = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_BLOCK_PROPOSAL_PRECHECK_FAILED_COUNT, {
|
|
66
|
+
[Attributes.ERROR_TYPE]: [
|
|
67
|
+
'slot_already_taken',
|
|
68
|
+
'rollup_contract_check_failed',
|
|
69
|
+
'slot_mismatch',
|
|
70
|
+
'block_number_mismatch'
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
this.slashingAttempts = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLASHING_ATTEMPTS_COUNT);
|
|
69
74
|
// Fisherman fee analysis metrics
|
|
70
|
-
this.fishermanWouldBeIncluded = this.meter
|
|
75
|
+
this.fishermanWouldBeIncluded = createUpDownCounterWithDefault(this.meter, Metrics.FISHERMAN_FEE_ANALYSIS_WOULD_BE_INCLUDED, {
|
|
76
|
+
[Attributes.OK]: [
|
|
77
|
+
true,
|
|
78
|
+
false
|
|
79
|
+
]
|
|
80
|
+
});
|
|
71
81
|
this.fishermanTimeBeforeBlock = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_TIME_BEFORE_BLOCK);
|
|
72
82
|
this.fishermanPendingBlobTxCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PENDING_BLOB_TX_COUNT);
|
|
73
83
|
this.fishermanIncludedBlobTxCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_INCLUDED_BLOB_TX_COUNT);
|