@aztec/sequencer-client 0.0.1-commit.96bb3f7 → 0.0.1-commit.a072138
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 +28 -9
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +134 -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 +17 -9
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +67 -11
- 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 +183 -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 +82 -10
- 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,34 @@ _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 (err instanceof DutyAlreadySignedError) {
|
|
671
|
+
this.log.info(`Checkpoint proposal for slot ${this.slot} already signed by another HA node, yielding`, {
|
|
672
|
+
slot: this.slot,
|
|
673
|
+
signedByNode: err.signedByNode
|
|
674
|
+
});
|
|
675
|
+
return undefined;
|
|
676
|
+
}
|
|
677
|
+
if (err instanceof SlashingProtectionError) {
|
|
678
|
+
this.log.info(`Checkpoint proposal for slot ${this.slot} blocked by slashing protection, yielding`, {
|
|
679
|
+
slot: this.slot,
|
|
680
|
+
existingMessageHash: err.existingMessageHash,
|
|
681
|
+
attemptedMessageHash: err.attemptedMessageHash
|
|
682
|
+
});
|
|
683
|
+
return undefined;
|
|
684
|
+
}
|
|
685
|
+
throw err;
|
|
686
|
+
}
|
|
647
687
|
if (blocksInCheckpoint.length === 0) {
|
|
648
688
|
this.log.warn(`No blocks were built for slot ${this.slot}`, {
|
|
649
689
|
slot: this.slot
|
|
@@ -683,7 +723,29 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
683
723
|
this.metrics.recordCheckpointAttestationDelay(blockAttestedAt - blockProposedAt);
|
|
684
724
|
// Proposer must sign over the attestations before pushing them to L1
|
|
685
725
|
const signer = this.proposer ?? this.publisher.getSenderAddress();
|
|
686
|
-
|
|
726
|
+
let attestationsSignature;
|
|
727
|
+
try {
|
|
728
|
+
attestationsSignature = await this.validatorClient.signAttestationsAndSigners(attestations, signer, this.slot, this.checkpointNumber);
|
|
729
|
+
} catch (err) {
|
|
730
|
+
// We shouldn't really get here since we yield to another HA node
|
|
731
|
+
// as soon as we see these errors when creating block proposals.
|
|
732
|
+
if (err instanceof DutyAlreadySignedError) {
|
|
733
|
+
this.log.info(`Attestations signature for slot ${this.slot} already signed by another HA node, yielding`, {
|
|
734
|
+
slot: this.slot,
|
|
735
|
+
signedByNode: err.signedByNode
|
|
736
|
+
});
|
|
737
|
+
return undefined;
|
|
738
|
+
}
|
|
739
|
+
if (err instanceof SlashingProtectionError) {
|
|
740
|
+
this.log.info(`Attestations signature for slot ${this.slot} blocked by slashing protection, yielding`, {
|
|
741
|
+
slot: this.slot,
|
|
742
|
+
existingMessageHash: err.existingMessageHash,
|
|
743
|
+
attemptedMessageHash: err.attemptedMessageHash
|
|
744
|
+
});
|
|
745
|
+
return undefined;
|
|
746
|
+
}
|
|
747
|
+
throw err;
|
|
748
|
+
}
|
|
687
749
|
// Enqueue publishing the checkpoint to L1
|
|
688
750
|
this.setStateFn(SequencerState.PUBLISHING_CHECKPOINT, this.slot);
|
|
689
751
|
const aztecSlotDuration = this.l1Constants.slotDuration;
|
|
@@ -701,6 +763,10 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
701
763
|
_ts_dispose_resources(env);
|
|
702
764
|
}
|
|
703
765
|
} catch (err) {
|
|
766
|
+
if (err && (err instanceof DutyAlreadySignedError || err instanceof SlashingProtectionError)) {
|
|
767
|
+
// swallow this error. It's already been logged by a function deeper in the stack
|
|
768
|
+
return undefined;
|
|
769
|
+
}
|
|
704
770
|
this.log.error(`Error building checkpoint at slot ${this.slot}`, err);
|
|
705
771
|
return undefined;
|
|
706
772
|
}
|
|
@@ -711,11 +777,13 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
711
777
|
const blocksInCheckpoint = [];
|
|
712
778
|
const txHashesAlreadyIncluded = new Set();
|
|
713
779
|
const initialBlockNumber = BlockNumber(this.syncedToBlockNumber + 1);
|
|
780
|
+
// Remaining blob fields available for blocks (checkpoint end marker already subtracted)
|
|
781
|
+
let remainingBlobFields = BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB - NUM_CHECKPOINT_END_MARKER_FIELDS;
|
|
714
782
|
// Last block in the checkpoint will usually be flagged as pending broadcast, so we send it along with the checkpoint proposal
|
|
715
783
|
let blockPendingBroadcast = undefined;
|
|
716
784
|
while(true){
|
|
717
785
|
const blocksBuilt = blocksInCheckpoint.length;
|
|
718
|
-
const indexWithinCheckpoint = blocksBuilt;
|
|
786
|
+
const indexWithinCheckpoint = IndexWithinCheckpoint(blocksBuilt);
|
|
719
787
|
const blockNumber = BlockNumber(initialBlockNumber + blocksBuilt);
|
|
720
788
|
const secondsIntoSlot = this.getSecondsIntoSlot();
|
|
721
789
|
const timingInfo = this.timetable.canStartNextBlock(secondsIntoSlot);
|
|
@@ -736,8 +804,10 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
736
804
|
buildDeadline: timingInfo.deadline ? new Date((this.getSlotStartBuildTimestamp() + timingInfo.deadline) * 1000) : undefined,
|
|
737
805
|
blockNumber,
|
|
738
806
|
indexWithinCheckpoint,
|
|
739
|
-
txHashesAlreadyIncluded
|
|
807
|
+
txHashesAlreadyIncluded,
|
|
808
|
+
remainingBlobFields
|
|
740
809
|
});
|
|
810
|
+
// TODO(palla/mbps): Review these conditions. We may want to keep trying in some scenarios.
|
|
741
811
|
if (!buildResult && timingInfo.isLastBlock) {
|
|
742
812
|
break;
|
|
743
813
|
} else if (!buildResult && timingInfo.deadline !== undefined) {
|
|
@@ -757,12 +827,21 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
757
827
|
}
|
|
758
828
|
break;
|
|
759
829
|
}
|
|
760
|
-
const { block, usedTxs } = buildResult;
|
|
830
|
+
const { block, usedTxs, remainingBlobFields: newRemainingBlobFields } = buildResult;
|
|
761
831
|
blocksInCheckpoint.push(block);
|
|
832
|
+
// Update remaining blob fields for the next block
|
|
833
|
+
remainingBlobFields = newRemainingBlobFields;
|
|
762
834
|
// Sync the proposed block to the archiver to make it available
|
|
763
835
|
// Note that the checkpoint builder uses its own fork so it should not need to wait for this syncing
|
|
764
836
|
// Eventually we should refactor the checkpoint builder to not need a separate long-lived fork
|
|
765
|
-
|
|
837
|
+
// Fire and forget - don't block the critical path, but log errors
|
|
838
|
+
this.syncProposedBlockToArchiver(block).catch((err)=>{
|
|
839
|
+
this.log.error(`Failed to sync proposed block ${block.number} to archiver`, {
|
|
840
|
+
blockNumber: block.number,
|
|
841
|
+
err
|
|
842
|
+
});
|
|
843
|
+
});
|
|
844
|
+
usedTxs.forEach((tx)=>txHashesAlreadyIncluded.add(tx.txHash.toString()));
|
|
766
845
|
// If this is the last block, exit the loop now so we start collecting attestations
|
|
767
846
|
if (timingInfo.isLastBlock) {
|
|
768
847
|
this.log.verbose(`Completed final block ${blockNumber} for slot ${this.slot}`, {
|
|
@@ -802,7 +881,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
802
881
|
await this.waitUntilTimeInSlot(nextSubslotStart);
|
|
803
882
|
}
|
|
804
883
|
/** Builds a single block. Called from the main block building loop. */ async buildSingleBlock(checkpointBuilder, opts) {
|
|
805
|
-
const { blockTimestamp, forceCreate, blockNumber, indexWithinCheckpoint, buildDeadline, txHashesAlreadyIncluded } = opts;
|
|
884
|
+
const { blockTimestamp, forceCreate, blockNumber, indexWithinCheckpoint, buildDeadline, txHashesAlreadyIncluded, remainingBlobFields } = opts;
|
|
806
885
|
this.log.verbose(`Preparing block ${blockNumber} index ${indexWithinCheckpoint} at checkpoint ${this.checkpointNumber} for slot ${this.slot}`, {
|
|
807
886
|
...checkpointBuilder.getConstantData(),
|
|
808
887
|
...opts
|
|
@@ -834,43 +913,46 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
834
913
|
indexWithinCheckpoint
|
|
835
914
|
});
|
|
836
915
|
this.setStateFn(SequencerState.CREATING_BLOCK, this.slot);
|
|
916
|
+
// Calculate blob fields limit for txs (remaining capacity - this block's end overhead)
|
|
917
|
+
const blockEndOverhead = getNumBlockEndBlobFields(indexWithinCheckpoint === 0);
|
|
918
|
+
const maxBlobFieldsForTxs = remainingBlobFields - blockEndOverhead;
|
|
837
919
|
const blockBuilderOptions = {
|
|
838
920
|
maxTransactions: this.config.maxTxsPerBlock,
|
|
839
921
|
maxBlockSize: this.config.maxBlockSizeInBytes,
|
|
840
922
|
maxBlockGas: new Gas(this.config.maxDABlockGas, this.config.maxL2BlockGas),
|
|
841
|
-
maxBlobFields:
|
|
923
|
+
maxBlobFields: maxBlobFieldsForTxs,
|
|
842
924
|
deadline: buildDeadline
|
|
843
925
|
};
|
|
844
926
|
// 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();
|
|
927
|
+
const buildResult = await this.buildSingleBlockWithCheckpointBuilder(checkpointBuilder, pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions);
|
|
848
928
|
// If any txs failed during execution, drop them from the mempool so we don't pick them up again
|
|
849
|
-
await this.dropFailedTxsFromP2P(failedTxs);
|
|
929
|
+
await this.dropFailedTxsFromP2P(buildResult.failedTxs);
|
|
850
930
|
// Check if we have created a block with enough txs. If there were invalid txs in the pool, or if execution took
|
|
851
931
|
// too long, then we may not get to minTxsPerBlock after executing public functions.
|
|
852
932
|
const minValidTxs = this.config.minValidTxsPerBlock ?? minTxs;
|
|
853
|
-
|
|
854
|
-
|
|
933
|
+
const numTxs = buildResult.status === 'no-valid-txs' ? 0 : buildResult.numTxs;
|
|
934
|
+
if (buildResult.status === 'no-valid-txs' || !forceCreate && numTxs < minValidTxs) {
|
|
935
|
+
this.log.warn(`Block ${blockNumber} at index ${indexWithinCheckpoint} on slot ${this.slot} has too few valid txs to be proposed`, {
|
|
855
936
|
slot: this.slot,
|
|
856
937
|
blockNumber,
|
|
857
938
|
numTxs,
|
|
858
|
-
indexWithinCheckpoint
|
|
939
|
+
indexWithinCheckpoint,
|
|
940
|
+
minValidTxs,
|
|
941
|
+
buildResult: buildResult.status
|
|
859
942
|
});
|
|
860
|
-
this.eventEmitter.emit('block-
|
|
861
|
-
|
|
862
|
-
availableTxs: numTxs,
|
|
943
|
+
this.eventEmitter.emit('block-build-failed', {
|
|
944
|
+
reason: `Insufficient valid txs`,
|
|
863
945
|
slot: this.slot
|
|
864
946
|
});
|
|
865
947
|
this.metrics.recordBlockProposalFailed('insufficient_valid_txs');
|
|
866
948
|
return undefined;
|
|
867
949
|
}
|
|
868
950
|
// Block creation succeeded, emit stats and metrics
|
|
951
|
+
const { publicGas, block, publicProcessorDuration, usedTxs, usedTxBlobFields, blockBuildDuration } = buildResult;
|
|
869
952
|
const blockStats = {
|
|
870
953
|
eventName: 'l2-block-built',
|
|
871
954
|
duration: blockBuildDuration,
|
|
872
955
|
publicProcessDuration: publicProcessorDuration,
|
|
873
|
-
rollupCircuitsDuration: blockBuildingTimer.ms(),
|
|
874
956
|
...block.getStats()
|
|
875
957
|
};
|
|
876
958
|
const blockHash = await block.hash();
|
|
@@ -889,7 +971,8 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
889
971
|
this.metrics.recordBuiltBlock(blockBuildDuration, publicGas.l2Gas);
|
|
890
972
|
return {
|
|
891
973
|
block,
|
|
892
|
-
usedTxs
|
|
974
|
+
usedTxs,
|
|
975
|
+
remainingBlobFields: maxBlobFieldsForTxs - usedTxBlobFields
|
|
893
976
|
};
|
|
894
977
|
} catch (err) {
|
|
895
978
|
this.eventEmitter.emit('block-build-failed', {
|
|
@@ -907,9 +990,30 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
907
990
|
};
|
|
908
991
|
}
|
|
909
992
|
}
|
|
993
|
+
/** Uses the checkpoint builder to build a block, catching specific txs */ async buildSingleBlockWithCheckpointBuilder(checkpointBuilder, pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions) {
|
|
994
|
+
try {
|
|
995
|
+
const workTimer = new Timer();
|
|
996
|
+
const result = await checkpointBuilder.buildBlock(pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions);
|
|
997
|
+
const blockBuildDuration = workTimer.ms();
|
|
998
|
+
return {
|
|
999
|
+
...result,
|
|
1000
|
+
blockBuildDuration,
|
|
1001
|
+
status: 'success'
|
|
1002
|
+
};
|
|
1003
|
+
} catch (err) {
|
|
1004
|
+
if (isErrorClass(err, NoValidTxsError)) {
|
|
1005
|
+
return {
|
|
1006
|
+
failedTxs: err.failedTxs,
|
|
1007
|
+
status: 'no-valid-txs'
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
throw err;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
910
1013
|
/** Waits until minTxs are available on the pool for building a block. */ async waitForMinTxs(opts) {
|
|
911
|
-
const minTxs = this.config.minTxsPerBlock;
|
|
912
1014
|
const { indexWithinCheckpoint, blockNumber, buildDeadline, forceCreate } = opts;
|
|
1015
|
+
// We only allow a block with 0 txs in the first block of the checkpoint
|
|
1016
|
+
const minTxs = indexWithinCheckpoint > 0 && this.config.minTxsPerBlock === 0 ? 1 : this.config.minTxsPerBlock;
|
|
913
1017
|
// Deadline is undefined if we are not enforcing the timetable, meaning we'll exit immediately when out of time
|
|
914
1018
|
const startBuildingDeadline = buildDeadline ? new Date(buildDeadline.getTime() - this.timetable.minExecutionTime * 1000) : undefined;
|
|
915
1019
|
let availableTxs = await this.p2pClient.getPendingTxCount();
|
|
@@ -964,7 +1068,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
964
1068
|
return new CommitteeAttestationsAndSigners(orderAttestations(attestations ?? [], committee));
|
|
965
1069
|
}
|
|
966
1070
|
const attestationTimeAllowed = this.config.enforceTimeTable ? this.timetable.getMaxAllowedTime(SequencerState.PUBLISHING_CHECKPOINT) : this.l1Constants.slotDuration;
|
|
967
|
-
const attestationDeadline = new Date(this.
|
|
1071
|
+
const attestationDeadline = new Date((this.getSlotStartBuildTimestamp() + attestationTimeAllowed) * 1000);
|
|
968
1072
|
this.metrics.recordRequiredAttestations(numberOfRequiredAttestations, attestationTimeAllowed);
|
|
969
1073
|
const collectAttestationsTimer = new Timer();
|
|
970
1074
|
let collectedAttestationsCount = 0;
|
|
@@ -1038,7 +1142,6 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1038
1142
|
* Gossip doesn't echo messages back to the sender, so the proposer's archiver/world-state
|
|
1039
1143
|
* would never receive its own block without this explicit sync.
|
|
1040
1144
|
*/ async syncProposedBlockToArchiver(block) {
|
|
1041
|
-
// TODO(palla/mbps): Change default to false once block sync is stable.
|
|
1042
1145
|
if (this.config.skipPushProposedBlocksToArchiver !== false) {
|
|
1043
1146
|
this.log.warn(`Skipping push of proposed block ${block.number} to archiver`, {
|
|
1044
1147
|
blockNumber: block.number,
|
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlY2twb2ludF92b3Rlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NlcXVlbmNlci9jaGVja3BvaW50X3ZvdGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2xFLE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBQ2hFLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLHNCQUFzQixFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFFN0QsT0FBTyxLQUFLLEVBQUUsdUJBQXVCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUMvRSxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQU0vRCxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHFDQUFxQyxDQUFDO0FBQzlFLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sY0FBYyxDQUFDO0FBQ3J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dDckIsbUJBQW1CO0NBaUNsQyJ9
|
|
@@ -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
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
60
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWV0cmljcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3Jj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UFBTSxRQU0xRDtJQUVELGlCQUFpQixTQUloQjtJQUVELDZCQUE2QixDQUFDLFVBQVUsRUFBRSxNQUFNLEVBQUUsS0FBSyxFQUFFLGNBQWMsUUFJdEU7SUFFRCxXQUFXLENBQUMsSUFBSSxFQUFFLFVBQVUsRUFBRSxRQUFRLEVBQUUsTUFBTSxRQVc3QztJQUVLLGFBQWEsQ0FBQyxRQUFRLEVBQUUsTUFBTSxFQUFFLFFBQVEsRUFBRSxHQUFHLEdBQUcsVUFBVSxHQUFHLFNBQVMsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBaUIzRjtJQUVELHVCQUF1QixTQUV0QjtJQUVELHlCQUF5QixDQUFDLE1BQU0sQ0FBQyxFQUFFLE1BQU0sUUFJeEM7SUFFRCwwQkFBMEIsU0FFekI7SUFFRCxpQ0FBaUMsQ0FDL0IsU0FBUyxFQUFFLG9CQUFvQixHQUFHLDhCQUE4QixHQUFHLGVBQWUsR0FBRyx1QkFBdUIsUUFLN0c7SUFFRCxxQkFBcUIsQ0FBQyxXQUFXLEVBQUUsTUFBTSxRQUV4QztJQUVEOzs7T0FHRztJQUNILDBCQUEwQixDQUFDLFFBQVEsRUFBRSxtQkFBbUIsUUFxRnZEO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/sequencer/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAML,KAAK,eAAe,EACpB,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/sequencer/metrics.ts"],"names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|
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);
|