@aztec/sequencer-client 0.0.1-commit.c80b6263 → 0.0.1-commit.cf93bcc56
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 +12 -7
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +15 -4
- package/dest/config.d.ts +3 -4
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +17 -12
- package/dest/global_variable_builder/global_builder.d.ts +2 -4
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/publisher/config.d.ts +31 -17
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +101 -42
- package/dest/publisher/sequencer-publisher-factory.d.ts +11 -3
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +13 -2
- package/dest/publisher/sequencer-publisher.d.ts +16 -8
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +80 -39
- package/dest/sequencer/checkpoint_proposal_job.d.ts +29 -6
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +97 -53
- package/dest/sequencer/metrics.d.ts +17 -5
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +86 -15
- package/dest/sequencer/sequencer.d.ts +12 -7
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +24 -26
- package/dest/sequencer/timetable.d.ts +1 -4
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +1 -4
- 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 -5
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +6 -6
- package/dest/test/utils.d.ts +3 -3
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +5 -4
- package/package.json +28 -28
- package/src/client/sequencer-client.ts +25 -7
- package/src/config.ts +26 -19
- package/src/global_variable_builder/global_builder.ts +1 -1
- package/src/publisher/config.ts +112 -43
- package/src/publisher/sequencer-publisher-factory.ts +23 -6
- package/src/publisher/sequencer-publisher.ts +96 -45
- package/src/sequencer/checkpoint_proposal_job.ts +134 -70
- package/src/sequencer/metrics.ts +92 -18
- package/src/sequencer/sequencer.ts +32 -31
- package/src/sequencer/timetable.ts +6 -5
- package/src/test/index.ts +2 -4
- package/src/test/mock_checkpoint_builder.ts +14 -5
- package/src/test/utils.ts +5 -2
|
@@ -438,17 +438,18 @@ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
438
438
|
var _dec, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _initProto;
|
|
439
439
|
import { NUM_CHECKPOINT_END_MARKER_FIELDS, getNumBlockEndBlobFields } from '@aztec/blob-lib/encoding';
|
|
440
440
|
import { BLOBS_PER_CHECKPOINT, FIELDS_PER_BLOB } from '@aztec/constants';
|
|
441
|
-
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
441
|
+
import { BlockNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
442
442
|
import { randomInt } from '@aztec/foundation/crypto/random';
|
|
443
443
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
444
444
|
import { filter } from '@aztec/foundation/iterator';
|
|
445
445
|
import { createLogger } from '@aztec/foundation/log';
|
|
446
446
|
import { sleep, sleepUntil } from '@aztec/foundation/sleep';
|
|
447
447
|
import { Timer } from '@aztec/foundation/timer';
|
|
448
|
-
import { unfreeze } from '@aztec/foundation/types';
|
|
448
|
+
import { isErrorClass, unfreeze } from '@aztec/foundation/types';
|
|
449
449
|
import { CommitteeAttestationsAndSigners, MaliciousCommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
450
450
|
import { getSlotStartBuildTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
451
451
|
import { Gas } from '@aztec/stdlib/gas';
|
|
452
|
+
import { NoValidTxsError } from '@aztec/stdlib/interfaces/server';
|
|
452
453
|
import { computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
|
|
453
454
|
import { orderAttestations } from '@aztec/stdlib/p2p';
|
|
454
455
|
import { AttestationTimeoutError } from '@aztec/stdlib/validators';
|
|
@@ -589,7 +590,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
589
590
|
// Wait until the voting promises have resolved, so all requests are enqueued (not sent)
|
|
590
591
|
await Promise.all(votesPromises);
|
|
591
592
|
if (checkpoint) {
|
|
592
|
-
this.metrics.
|
|
593
|
+
this.metrics.recordCheckpointProposalSuccess();
|
|
593
594
|
}
|
|
594
595
|
// Do not post anything to L1 if we are fishermen, but do perform L1 fee analysis
|
|
595
596
|
if (this.config.fishermanMode) {
|
|
@@ -639,13 +640,14 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
639
640
|
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(this.checkpointNumber);
|
|
640
641
|
const inHash = computeInHashFromL1ToL2Messages(l1ToL2Messages);
|
|
641
642
|
// Collect the out hashes of all the checkpoints before this one in the same epoch
|
|
642
|
-
const
|
|
643
|
-
|
|
643
|
+
const previousCheckpointOutHashes = (await this.l2BlockSource.getCheckpointsDataForEpoch(this.epoch)).filter((c)=>c.checkpointNumber < this.checkpointNumber).map((c)=>c.checkpointOutHash);
|
|
644
|
+
// Get the fee asset price modifier from the oracle
|
|
645
|
+
const feeAssetPriceModifier = await this.publisher.getFeeAssetPriceModifier();
|
|
644
646
|
const fork = _ts_add_disposable_resource(env, await this.worldState.fork(this.syncedToBlockNumber, {
|
|
645
647
|
closeDelayMs: 12_000
|
|
646
|
-
}),
|
|
648
|
+
}), true);
|
|
647
649
|
// Create checkpoint builder for the entire slot
|
|
648
|
-
const checkpointBuilder = await this.checkpointsBuilder.startCheckpoint(this.checkpointNumber, checkpointGlobalVariables, l1ToL2Messages, previousCheckpointOutHashes, fork, this.log.getBindings());
|
|
650
|
+
const checkpointBuilder = await this.checkpointsBuilder.startCheckpoint(this.checkpointNumber, checkpointGlobalVariables, feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, fork, this.log.getBindings());
|
|
649
651
|
// Options for the validator client when creating block and checkpoint proposals
|
|
650
652
|
const blockProposalOptions = {
|
|
651
653
|
publishFullTxs: !!this.config.publishTxsWithProposals,
|
|
@@ -657,6 +659,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
657
659
|
};
|
|
658
660
|
let blocksInCheckpoint = [];
|
|
659
661
|
let blockPendingBroadcast = undefined;
|
|
662
|
+
const checkpointBuildTimer = new Timer();
|
|
660
663
|
try {
|
|
661
664
|
// Main loop: build blocks for the checkpoint
|
|
662
665
|
const result = await this.buildBlocksForCheckpoint(checkpointBuilder, checkpointGlobalVariables.timestamp, inHash, blockProposalOptions);
|
|
@@ -666,19 +669,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
666
669
|
// These errors are expected in HA mode, so we yield and let another HA node handle the slot
|
|
667
670
|
// The only distinction between the 2 errors is SlashingProtectionError throws when the payload is different,
|
|
668
671
|
// which is normal for block building (may have picked different txs)
|
|
669
|
-
if (err
|
|
670
|
-
this.log.info(`Checkpoint proposal for slot ${this.slot} already signed by another HA node, yielding`, {
|
|
671
|
-
slot: this.slot,
|
|
672
|
-
signedByNode: err.signedByNode
|
|
673
|
-
});
|
|
674
|
-
return undefined;
|
|
675
|
-
}
|
|
676
|
-
if (err instanceof SlashingProtectionError) {
|
|
677
|
-
this.log.info(`Checkpoint proposal for slot ${this.slot} blocked by slashing protection, yielding`, {
|
|
678
|
-
slot: this.slot,
|
|
679
|
-
existingMessageHash: err.existingMessageHash,
|
|
680
|
-
attemptedMessageHash: err.attemptedMessageHash
|
|
681
|
-
});
|
|
672
|
+
if (this.handleHASigningError(err, 'Block proposal')) {
|
|
682
673
|
return undefined;
|
|
683
674
|
}
|
|
684
675
|
throw err;
|
|
@@ -692,10 +683,21 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
692
683
|
});
|
|
693
684
|
return undefined;
|
|
694
685
|
}
|
|
686
|
+
const minBlocksForCheckpoint = this.config.minBlocksForCheckpoint;
|
|
687
|
+
if (minBlocksForCheckpoint !== undefined && blocksInCheckpoint.length < minBlocksForCheckpoint) {
|
|
688
|
+
this.log.warn(`Checkpoint has fewer blocks than minimum (${blocksInCheckpoint.length} < ${minBlocksForCheckpoint}), skipping proposal`, {
|
|
689
|
+
slot: this.slot,
|
|
690
|
+
blocksBuilt: blocksInCheckpoint.length,
|
|
691
|
+
minBlocksForCheckpoint
|
|
692
|
+
});
|
|
693
|
+
return undefined;
|
|
694
|
+
}
|
|
695
695
|
// Assemble and broadcast the checkpoint proposal, including the last block that was not
|
|
696
696
|
// broadcasted yet, and wait to collect the committee attestations.
|
|
697
697
|
this.setStateFn(SequencerState.ASSEMBLING_CHECKPOINT, this.slot);
|
|
698
698
|
const checkpoint = await checkpointBuilder.completeCheckpoint();
|
|
699
|
+
// Record checkpoint-level build metrics
|
|
700
|
+
this.metrics.recordCheckpointBuild(checkpointBuildTimer.ms(), blocksInCheckpoint.length, checkpoint.getStats().txCount, Number(checkpoint.header.totalManaUsed.toBigInt()));
|
|
699
701
|
// Do not collect attestations nor publish to L1 in fisherman mode
|
|
700
702
|
if (this.config.fishermanMode) {
|
|
701
703
|
this.log.info(`Built checkpoint for slot ${this.slot} with ${blocksInCheckpoint.length} blocks. ` + `Skipping proposal in fisherman mode.`, {
|
|
@@ -713,7 +715,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
713
715
|
txs: blockPendingBroadcast.txs
|
|
714
716
|
};
|
|
715
717
|
// Create the checkpoint proposal and broadcast it
|
|
716
|
-
const proposal = await this.validatorClient.createCheckpointProposal(checkpoint.header, checkpoint.archive.root, lastBlock, this.proposer, checkpointProposalOptions);
|
|
718
|
+
const proposal = await this.validatorClient.createCheckpointProposal(checkpoint.header, checkpoint.archive.root, feeAssetPriceModifier, lastBlock, this.proposer, checkpointProposalOptions);
|
|
717
719
|
const blockProposedAt = this.dateProvider.now();
|
|
718
720
|
await this.p2pClient.broadcastCheckpointProposal(proposal);
|
|
719
721
|
this.setStateFn(SequencerState.COLLECTING_ATTESTATIONS, this.slot);
|
|
@@ -727,20 +729,8 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
727
729
|
attestationsSignature = await this.validatorClient.signAttestationsAndSigners(attestations, signer, this.slot, this.checkpointNumber);
|
|
728
730
|
} catch (err) {
|
|
729
731
|
// We shouldn't really get here since we yield to another HA node
|
|
730
|
-
// as soon as we see these errors when creating block proposals.
|
|
731
|
-
if (err
|
|
732
|
-
this.log.info(`Attestations signature for slot ${this.slot} already signed by another HA node, yielding`, {
|
|
733
|
-
slot: this.slot,
|
|
734
|
-
signedByNode: err.signedByNode
|
|
735
|
-
});
|
|
736
|
-
return undefined;
|
|
737
|
-
}
|
|
738
|
-
if (err instanceof SlashingProtectionError) {
|
|
739
|
-
this.log.info(`Attestations signature for slot ${this.slot} blocked by slashing protection, yielding`, {
|
|
740
|
-
slot: this.slot,
|
|
741
|
-
existingMessageHash: err.existingMessageHash,
|
|
742
|
-
attemptedMessageHash: err.attemptedMessageHash
|
|
743
|
-
});
|
|
732
|
+
// as soon as we see these errors when creating block or checkpoint proposals.
|
|
733
|
+
if (this.handleHASigningError(err, 'Attestations signature')) {
|
|
744
734
|
return undefined;
|
|
745
735
|
}
|
|
746
736
|
throw err;
|
|
@@ -750,6 +740,14 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
750
740
|
const aztecSlotDuration = this.l1Constants.slotDuration;
|
|
751
741
|
const slotStartBuildTimestamp = this.getSlotStartBuildTimestamp();
|
|
752
742
|
const txTimeoutAt = new Date((slotStartBuildTimestamp + aztecSlotDuration) * 1000);
|
|
743
|
+
// If we have been configured to potentially skip publishing checkpoint then roll the dice here
|
|
744
|
+
if (this.config.skipPublishingCheckpointsPercent !== undefined && this.config.skipPublishingCheckpointsPercent > 0) {
|
|
745
|
+
const result = Math.max(0, randomInt(100));
|
|
746
|
+
if (result < this.config.skipPublishingCheckpointsPercent) {
|
|
747
|
+
this.log.warn(`Skipping publishing proposal for checkpoint ${checkpoint.number}. Configured percentage: ${this.config.skipPublishingCheckpointsPercent}, generated value: ${result}`);
|
|
748
|
+
return checkpoint;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
753
751
|
await this.publisher.enqueueProposeCheckpoint(checkpoint, attestations, attestationsSignature, {
|
|
754
752
|
txTimeoutAt,
|
|
755
753
|
forcePendingCheckpointNumber: this.invalidateCheckpoint?.forcePendingCheckpointNumber
|
|
@@ -759,7 +757,8 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
759
757
|
env.error = e;
|
|
760
758
|
env.hasError = true;
|
|
761
759
|
} finally{
|
|
762
|
-
_ts_dispose_resources(env);
|
|
760
|
+
const result = _ts_dispose_resources(env);
|
|
761
|
+
if (result) await result;
|
|
763
762
|
}
|
|
764
763
|
} catch (err) {
|
|
765
764
|
if (err && (err instanceof DutyAlreadySignedError || err instanceof SlashingProtectionError)) {
|
|
@@ -782,7 +781,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
782
781
|
let blockPendingBroadcast = undefined;
|
|
783
782
|
while(true){
|
|
784
783
|
const blocksBuilt = blocksInCheckpoint.length;
|
|
785
|
-
const indexWithinCheckpoint = blocksBuilt;
|
|
784
|
+
const indexWithinCheckpoint = IndexWithinCheckpoint(blocksBuilt);
|
|
786
785
|
const blockNumber = BlockNumber(initialBlockNumber + blocksBuilt);
|
|
787
786
|
const secondsIntoSlot = this.getSecondsIntoSlot();
|
|
788
787
|
const timingInfo = this.timetable.canStartNextBlock(secondsIntoSlot);
|
|
@@ -806,6 +805,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
806
805
|
txHashesAlreadyIncluded,
|
|
807
806
|
remainingBlobFields
|
|
808
807
|
});
|
|
808
|
+
// TODO(palla/mbps): Review these conditions. We may want to keep trying in some scenarios.
|
|
809
809
|
if (!buildResult && timingInfo.isLastBlock) {
|
|
810
810
|
break;
|
|
811
811
|
} else if (!buildResult && timingInfo.deadline !== undefined) {
|
|
@@ -904,7 +904,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
904
904
|
}
|
|
905
905
|
// Create iterator to pending txs. We filter out txs already included in previous blocks in the checkpoint
|
|
906
906
|
// just in case p2p failed to sync the provisional block and didn't get to remove those txs from the mempool yet.
|
|
907
|
-
const pendingTxs = filter(this.p2pClient.
|
|
907
|
+
const pendingTxs = filter(this.p2pClient.iterateEligiblePendingTxs(), (tx)=>!txHashesAlreadyIncluded.has(tx.txHash.toString()));
|
|
908
908
|
this.log.debug(`Building block ${blockNumber} at index ${indexWithinCheckpoint} for slot ${this.slot} with ${availableTxs} available txs`, {
|
|
909
909
|
slot: this.slot,
|
|
910
910
|
blockNumber,
|
|
@@ -922,35 +922,35 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
922
922
|
deadline: buildDeadline
|
|
923
923
|
};
|
|
924
924
|
// Actually build the block by executing txs
|
|
925
|
-
const
|
|
926
|
-
const { publicGas, block, publicProcessorDuration, numTxs, blockBuildingTimer, usedTxs, failedTxs, usedTxBlobFields } = await checkpointBuilder.buildBlock(pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions);
|
|
927
|
-
const blockBuildDuration = workTimer.ms();
|
|
925
|
+
const buildResult = await this.buildSingleBlockWithCheckpointBuilder(checkpointBuilder, pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions);
|
|
928
926
|
// If any txs failed during execution, drop them from the mempool so we don't pick them up again
|
|
929
|
-
await this.dropFailedTxsFromP2P(failedTxs);
|
|
927
|
+
await this.dropFailedTxsFromP2P(buildResult.failedTxs);
|
|
930
928
|
// Check if we have created a block with enough txs. If there were invalid txs in the pool, or if execution took
|
|
931
929
|
// too long, then we may not get to minTxsPerBlock after executing public functions.
|
|
932
930
|
const minValidTxs = this.config.minValidTxsPerBlock ?? minTxs;
|
|
933
|
-
|
|
934
|
-
|
|
931
|
+
const numTxs = buildResult.status === 'no-valid-txs' ? 0 : buildResult.numTxs;
|
|
932
|
+
if (buildResult.status === 'no-valid-txs' || !forceCreate && numTxs < minValidTxs) {
|
|
933
|
+
this.log.warn(`Block ${blockNumber} at index ${indexWithinCheckpoint} on slot ${this.slot} has too few valid txs to be proposed`, {
|
|
935
934
|
slot: this.slot,
|
|
936
935
|
blockNumber,
|
|
937
936
|
numTxs,
|
|
938
|
-
indexWithinCheckpoint
|
|
937
|
+
indexWithinCheckpoint,
|
|
938
|
+
minValidTxs,
|
|
939
|
+
buildResult: buildResult.status
|
|
939
940
|
});
|
|
940
|
-
this.eventEmitter.emit('block-
|
|
941
|
-
|
|
942
|
-
availableTxs: numTxs,
|
|
941
|
+
this.eventEmitter.emit('block-build-failed', {
|
|
942
|
+
reason: `Insufficient valid txs`,
|
|
943
943
|
slot: this.slot
|
|
944
944
|
});
|
|
945
945
|
this.metrics.recordBlockProposalFailed('insufficient_valid_txs');
|
|
946
946
|
return undefined;
|
|
947
947
|
}
|
|
948
948
|
// Block creation succeeded, emit stats and metrics
|
|
949
|
+
const { publicGas, block, publicProcessorDuration, usedTxs, usedTxBlobFields, blockBuildDuration } = buildResult;
|
|
949
950
|
const blockStats = {
|
|
950
951
|
eventName: 'l2-block-built',
|
|
951
952
|
duration: blockBuildDuration,
|
|
952
953
|
publicProcessDuration: publicProcessorDuration,
|
|
953
|
-
rollupCircuitsDuration: blockBuildingTimer.ms(),
|
|
954
954
|
...block.getStats()
|
|
955
955
|
};
|
|
956
956
|
const blockHash = await block.hash();
|
|
@@ -988,9 +988,30 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
988
988
|
};
|
|
989
989
|
}
|
|
990
990
|
}
|
|
991
|
+
/** Uses the checkpoint builder to build a block, catching specific txs */ async buildSingleBlockWithCheckpointBuilder(checkpointBuilder, pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions) {
|
|
992
|
+
try {
|
|
993
|
+
const workTimer = new Timer();
|
|
994
|
+
const result = await checkpointBuilder.buildBlock(pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions);
|
|
995
|
+
const blockBuildDuration = workTimer.ms();
|
|
996
|
+
return {
|
|
997
|
+
...result,
|
|
998
|
+
blockBuildDuration,
|
|
999
|
+
status: 'success'
|
|
1000
|
+
};
|
|
1001
|
+
} catch (err) {
|
|
1002
|
+
if (isErrorClass(err, NoValidTxsError)) {
|
|
1003
|
+
return {
|
|
1004
|
+
failedTxs: err.failedTxs,
|
|
1005
|
+
status: 'no-valid-txs'
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
throw err;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
991
1011
|
/** Waits until minTxs are available on the pool for building a block. */ async waitForMinTxs(opts) {
|
|
992
|
-
const minTxs = this.config.minTxsPerBlock;
|
|
993
1012
|
const { indexWithinCheckpoint, blockNumber, buildDeadline, forceCreate } = opts;
|
|
1013
|
+
// We only allow a block with 0 txs in the first block of the checkpoint
|
|
1014
|
+
const minTxs = indexWithinCheckpoint > 0 && this.config.minTxsPerBlock === 0 ? 1 : this.config.minTxsPerBlock;
|
|
994
1015
|
// Deadline is undefined if we are not enforcing the timetable, meaning we'll exit immediately when out of time
|
|
995
1016
|
const startBuildingDeadline = buildDeadline ? new Date(buildDeadline.getTime() - this.timetable.minExecutionTime * 1000) : undefined;
|
|
996
1017
|
let availableTxs = await this.p2pClient.getPendingTxCount();
|
|
@@ -1010,7 +1031,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1010
1031
|
slot: this.slot,
|
|
1011
1032
|
indexWithinCheckpoint
|
|
1012
1033
|
});
|
|
1013
|
-
await
|
|
1034
|
+
await this.waitForTxsPollingInterval();
|
|
1014
1035
|
availableTxs = await this.p2pClient.getPendingTxCount();
|
|
1015
1036
|
}
|
|
1016
1037
|
return {
|
|
@@ -1112,7 +1133,7 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1112
1133
|
const failedTxData = failedTxs.map((fail)=>fail.tx);
|
|
1113
1134
|
const failedTxHashes = failedTxData.map((tx)=>tx.getTxHash());
|
|
1114
1135
|
this.log.verbose(`Dropping failed txs ${failedTxHashes.join(', ')}`);
|
|
1115
|
-
await this.p2pClient.
|
|
1136
|
+
await this.p2pClient.handleFailedExecution(failedTxHashes);
|
|
1116
1137
|
}
|
|
1117
1138
|
/**
|
|
1118
1139
|
* Adds the proposed block to the archiver so it's available via P2P.
|
|
@@ -1147,15 +1168,38 @@ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('Checkpoint
|
|
|
1147
1168
|
slot: this.slot,
|
|
1148
1169
|
feeAnalysisId: feeAnalysis?.id
|
|
1149
1170
|
});
|
|
1150
|
-
this.metrics.
|
|
1171
|
+
this.metrics.recordCheckpointProposalFailed('block_build_failed');
|
|
1151
1172
|
}
|
|
1152
1173
|
this.publisher.clearPendingRequests();
|
|
1153
1174
|
}
|
|
1175
|
+
/**
|
|
1176
|
+
* Helper to handle HA double-signing errors. Returns true if the error was handled (caller should yield).
|
|
1177
|
+
*/ handleHASigningError(err, errorContext) {
|
|
1178
|
+
if (err instanceof DutyAlreadySignedError) {
|
|
1179
|
+
this.log.info(`${errorContext} for slot ${this.slot} already signed by another HA node, yielding`, {
|
|
1180
|
+
slot: this.slot,
|
|
1181
|
+
signedByNode: err.signedByNode
|
|
1182
|
+
});
|
|
1183
|
+
return true;
|
|
1184
|
+
}
|
|
1185
|
+
if (err instanceof SlashingProtectionError) {
|
|
1186
|
+
this.log.info(`${errorContext} for slot ${this.slot} blocked by slashing protection, yielding`, {
|
|
1187
|
+
slot: this.slot,
|
|
1188
|
+
existingMessageHash: err.existingMessageHash,
|
|
1189
|
+
attemptedMessageHash: err.attemptedMessageHash
|
|
1190
|
+
});
|
|
1191
|
+
return true;
|
|
1192
|
+
}
|
|
1193
|
+
return false;
|
|
1194
|
+
}
|
|
1154
1195
|
/** Waits until a specific time within the current slot */ async waitUntilTimeInSlot(targetSecondsIntoSlot) {
|
|
1155
1196
|
const slotStartTimestamp = this.getSlotStartBuildTimestamp();
|
|
1156
1197
|
const targetTimestamp = slotStartTimestamp + targetSecondsIntoSlot;
|
|
1157
1198
|
await sleepUntil(new Date(targetTimestamp * 1000), this.dateProvider.nowAsDate());
|
|
1158
1199
|
}
|
|
1200
|
+
/** Waits the polling interval for transactions. Extracted for test overriding. */ async waitForTxsPollingInterval() {
|
|
1201
|
+
await sleep(TXS_POLLING_MS);
|
|
1202
|
+
}
|
|
1159
1203
|
getSlotStartBuildTimestamp() {
|
|
1160
1204
|
return getSlotStartBuildTimestamp(this.slot, this.l1Constants);
|
|
1161
1205
|
}
|
|
@@ -21,15 +21,24 @@ export declare class SequencerMetrics {
|
|
|
21
21
|
private slots;
|
|
22
22
|
private filledSlots;
|
|
23
23
|
private blockProposalFailed;
|
|
24
|
-
private
|
|
25
|
-
private
|
|
24
|
+
private checkpointProposalSuccess;
|
|
25
|
+
private checkpointPrecheckFailed;
|
|
26
|
+
private checkpointProposalFailed;
|
|
26
27
|
private checkpointSuccess;
|
|
27
28
|
private slashingAttempts;
|
|
28
29
|
private checkpointAttestationDelay;
|
|
30
|
+
private checkpointBuildDuration;
|
|
31
|
+
private checkpointBlockCount;
|
|
32
|
+
private checkpointTxCount;
|
|
33
|
+
private checkpointTotalMana;
|
|
29
34
|
private fishermanWouldBeIncluded;
|
|
30
35
|
private fishermanTimeBeforeBlock;
|
|
31
36
|
private fishermanPendingBlobTxCount;
|
|
32
37
|
private fishermanIncludedBlobTxCount;
|
|
38
|
+
private fishermanPendingBlobCount;
|
|
39
|
+
private fishermanIncludedBlobCount;
|
|
40
|
+
private fishermanBlockBlobsFull;
|
|
41
|
+
private fishermanMaxBlobCapacity;
|
|
33
42
|
private fishermanCalculatedPriorityFee;
|
|
34
43
|
private fishermanPriorityFeeDelta;
|
|
35
44
|
private fishermanEstimatedCost;
|
|
@@ -48,8 +57,11 @@ export declare class SequencerMetrics {
|
|
|
48
57
|
incFilledSlot(proposer: string, coinbase: Hex | EthAddress | undefined): Promise<void>;
|
|
49
58
|
recordCheckpointSuccess(): void;
|
|
50
59
|
recordBlockProposalFailed(reason?: string): void;
|
|
51
|
-
|
|
52
|
-
|
|
60
|
+
recordCheckpointProposalSuccess(): void;
|
|
61
|
+
recordCheckpointPrecheckFailed(checkType: 'slot_already_taken' | 'rollup_contract_check_failed' | 'slot_mismatch' | 'block_number_mismatch'): void;
|
|
62
|
+
recordCheckpointProposalFailed(reason?: string): void;
|
|
63
|
+
/** Records aggregate metrics for a completed checkpoint build. */
|
|
64
|
+
recordCheckpointBuild(durationMs: number, blockCount: number, txCount: number, totalMana: number): void;
|
|
53
65
|
recordSlashingAttempt(actionCount: number): void;
|
|
54
66
|
/**
|
|
55
67
|
* Records metrics for a completed fisherman fee analysis
|
|
@@ -57,4 +69,4 @@ export declare class SequencerMetrics {
|
|
|
57
69
|
*/
|
|
58
70
|
recordFishermanFeeAnalysis(analysis: L1FeeAnalysisResult): void;
|
|
59
71
|
}
|
|
60
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
72
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjoz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QUFFLE1BQU0sRUFBRSxVQUFVLEVBQUUsTUFBTSxFQUFFLE9BQU8sRUFBRSxNQUFNLEVBQUUsU0FBUyxFQUFFLE1BQU0sUUFLL0Y7SUFFRCxxQkFBcUIsQ0FBQyxXQUFXLEVBQUUsTUFBTSxRQUV4QztJQUVEOzs7T0FHRztJQUNILDBCQUEwQixDQUFDLFFBQVEsRUFBRSxtQkFBbUIsUUFrSHZEO0NBQ0YifQ==
|
|
@@ -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,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,GAAG,EAAe,MAAM,MAAM,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
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,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,GAAG,EAAe,MAAM,MAAM,CAAC;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A0B,CAAC,QAAQ,EAAE,mBAAmB,QAkHvD;CACF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Attributes, Metrics, createUpDownCounterWithDefault } from '@aztec/telemetry-client';
|
|
2
2
|
import { formatUnits } from 'viem';
|
|
3
|
-
// TODO(palla/mbps): Review all metrics and add any missing ones per checkpoint
|
|
4
3
|
export class SequencerMetrics {
|
|
5
4
|
rollup;
|
|
6
5
|
tracer;
|
|
@@ -18,16 +17,25 @@ export class SequencerMetrics {
|
|
|
18
17
|
slots;
|
|
19
18
|
filledSlots;
|
|
20
19
|
blockProposalFailed;
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
checkpointProposalSuccess;
|
|
21
|
+
checkpointPrecheckFailed;
|
|
22
|
+
checkpointProposalFailed;
|
|
23
23
|
checkpointSuccess;
|
|
24
24
|
slashingAttempts;
|
|
25
25
|
checkpointAttestationDelay;
|
|
26
|
+
checkpointBuildDuration;
|
|
27
|
+
checkpointBlockCount;
|
|
28
|
+
checkpointTxCount;
|
|
29
|
+
checkpointTotalMana;
|
|
26
30
|
// Fisherman fee analysis metrics
|
|
27
31
|
fishermanWouldBeIncluded;
|
|
28
32
|
fishermanTimeBeforeBlock;
|
|
29
33
|
fishermanPendingBlobTxCount;
|
|
30
34
|
fishermanIncludedBlobTxCount;
|
|
35
|
+
fishermanPendingBlobCount;
|
|
36
|
+
fishermanIncludedBlobCount;
|
|
37
|
+
fishermanBlockBlobsFull;
|
|
38
|
+
fishermanMaxBlobCapacity;
|
|
31
39
|
fishermanCalculatedPriorityFee;
|
|
32
40
|
fishermanPriorityFeeDelta;
|
|
33
41
|
fishermanEstimatedCost;
|
|
@@ -49,7 +57,7 @@ export class SequencerMetrics {
|
|
|
49
57
|
this.blockBuildManaPerSecond = this.meter.createGauge(Metrics.SEQUENCER_BLOCK_BUILD_MANA_PER_SECOND);
|
|
50
58
|
this.stateTransitionBufferDuration = this.meter.createHistogram(Metrics.SEQUENCER_STATE_TRANSITION_BUFFER_DURATION);
|
|
51
59
|
this.checkpointAttestationDelay = this.meter.createHistogram(Metrics.SEQUENCER_CHECKPOINT_ATTESTATION_DELAY);
|
|
52
|
-
this.rewards = this.meter.createGauge(Metrics.
|
|
60
|
+
this.rewards = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_SLOT_REWARDS);
|
|
53
61
|
this.slots = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLOT_COUNT);
|
|
54
62
|
/**
|
|
55
63
|
* NOTE: we do not track missed slots as a separate metric. That would be difficult to determine
|
|
@@ -60,9 +68,9 @@ export class SequencerMetrics {
|
|
|
60
68
|
this.requiredAttestions = this.meter.createGauge(Metrics.SEQUENCER_REQUIRED_ATTESTATIONS_COUNT);
|
|
61
69
|
this.collectedAttestions = this.meter.createGauge(Metrics.SEQUENCER_COLLECTED_ATTESTATIONS_COUNT);
|
|
62
70
|
this.blockProposalFailed = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_BLOCK_PROPOSAL_FAILED_COUNT);
|
|
63
|
-
this.
|
|
71
|
+
this.checkpointProposalSuccess = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_CHECKPOINT_PROPOSAL_SUCCESS_COUNT);
|
|
64
72
|
this.checkpointSuccess = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_CHECKPOINT_SUCCESS_COUNT);
|
|
65
|
-
this.
|
|
73
|
+
this.checkpointPrecheckFailed = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_CHECKPOINT_PRECHECK_FAILED_COUNT, {
|
|
66
74
|
[Attributes.ERROR_TYPE]: [
|
|
67
75
|
'slot_already_taken',
|
|
68
76
|
'rollup_contract_check_failed',
|
|
@@ -70,12 +78,21 @@ export class SequencerMetrics {
|
|
|
70
78
|
'block_number_mismatch'
|
|
71
79
|
]
|
|
72
80
|
});
|
|
81
|
+
this.checkpointProposalFailed = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_CHECKPOINT_PROPOSAL_FAILED_COUNT);
|
|
82
|
+
this.checkpointBuildDuration = this.meter.createHistogram(Metrics.SEQUENCER_CHECKPOINT_BUILD_DURATION);
|
|
83
|
+
this.checkpointBlockCount = this.meter.createGauge(Metrics.SEQUENCER_CHECKPOINT_BLOCK_COUNT);
|
|
84
|
+
this.checkpointTxCount = this.meter.createGauge(Metrics.SEQUENCER_CHECKPOINT_TX_COUNT);
|
|
85
|
+
this.checkpointTotalMana = this.meter.createGauge(Metrics.SEQUENCER_CHECKPOINT_TOTAL_MANA);
|
|
73
86
|
this.slashingAttempts = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLASHING_ATTEMPTS_COUNT);
|
|
74
87
|
// Fisherman fee analysis metrics
|
|
75
88
|
this.fishermanWouldBeIncluded = createUpDownCounterWithDefault(this.meter, Metrics.FISHERMAN_FEE_ANALYSIS_WOULD_BE_INCLUDED, {
|
|
76
89
|
[Attributes.OK]: [
|
|
77
90
|
true,
|
|
78
91
|
false
|
|
92
|
+
],
|
|
93
|
+
[Attributes.BLOCK_FULL]: [
|
|
94
|
+
'true',
|
|
95
|
+
'false'
|
|
79
96
|
]
|
|
80
97
|
});
|
|
81
98
|
this.fishermanTimeBeforeBlock = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_TIME_BEFORE_BLOCK);
|
|
@@ -87,6 +104,15 @@ export class SequencerMetrics {
|
|
|
87
104
|
this.fishermanEstimatedOverpayment = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_ESTIMATED_OVERPAYMENT);
|
|
88
105
|
this.fishermanMinedBlobTxPriorityFee = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_MINED_BLOB_TX_PRIORITY_FEE);
|
|
89
106
|
this.fishermanMinedBlobTxTotalCost = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_MINED_BLOB_TX_TOTAL_COST);
|
|
107
|
+
this.fishermanPendingBlobCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PENDING_BLOB_COUNT);
|
|
108
|
+
this.fishermanIncludedBlobCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_INCLUDED_BLOB_COUNT);
|
|
109
|
+
this.fishermanBlockBlobsFull = createUpDownCounterWithDefault(this.meter, Metrics.FISHERMAN_FEE_ANALYSIS_BLOCK_BLOBS_FULL, {
|
|
110
|
+
[Attributes.OK]: [
|
|
111
|
+
true,
|
|
112
|
+
false
|
|
113
|
+
]
|
|
114
|
+
});
|
|
115
|
+
this.fishermanMaxBlobCapacity = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_MAX_BLOB_CAPACITY);
|
|
90
116
|
}
|
|
91
117
|
recordRequiredAttestations(requiredAttestationsCount, allowanceMs) {
|
|
92
118
|
this.requiredAttestions.record(requiredAttestationsCount);
|
|
@@ -156,14 +182,27 @@ export class SequencerMetrics {
|
|
|
156
182
|
}
|
|
157
183
|
});
|
|
158
184
|
}
|
|
159
|
-
|
|
160
|
-
this.
|
|
185
|
+
recordCheckpointProposalSuccess() {
|
|
186
|
+
this.checkpointProposalSuccess.add(1);
|
|
161
187
|
}
|
|
162
|
-
|
|
163
|
-
this.
|
|
188
|
+
recordCheckpointPrecheckFailed(checkType) {
|
|
189
|
+
this.checkpointPrecheckFailed.add(1, {
|
|
164
190
|
[Attributes.ERROR_TYPE]: checkType
|
|
165
191
|
});
|
|
166
192
|
}
|
|
193
|
+
recordCheckpointProposalFailed(reason) {
|
|
194
|
+
this.checkpointProposalFailed.add(1, {
|
|
195
|
+
...reason && {
|
|
196
|
+
[Attributes.ERROR_TYPE]: reason
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
/** Records aggregate metrics for a completed checkpoint build. */ recordCheckpointBuild(durationMs, blockCount, txCount, totalMana) {
|
|
201
|
+
this.checkpointBuildDuration.record(Math.ceil(durationMs));
|
|
202
|
+
this.checkpointBlockCount.record(blockCount);
|
|
203
|
+
this.checkpointTxCount.record(txCount);
|
|
204
|
+
this.checkpointTotalMana.record(totalMana);
|
|
205
|
+
}
|
|
167
206
|
recordSlashingAttempt(actionCount) {
|
|
168
207
|
this.slashingAttempts.add(actionCount);
|
|
169
208
|
}
|
|
@@ -184,9 +223,11 @@ export class SequencerMetrics {
|
|
|
184
223
|
};
|
|
185
224
|
// Record pending block snapshot data (once per strategy for comparison)
|
|
186
225
|
this.fishermanPendingBlobTxCount.record(analysis.pendingSnapshot.pendingBlobTxCount, strategyAttributes);
|
|
226
|
+
this.fishermanPendingBlobCount.record(analysis.pendingSnapshot.pendingBlobCount, strategyAttributes);
|
|
187
227
|
// Record mined block data if available
|
|
188
228
|
if (analysis.minedBlock) {
|
|
189
229
|
this.fishermanIncludedBlobTxCount.record(analysis.minedBlock.includedBlobTxCount, strategyAttributes);
|
|
230
|
+
this.fishermanIncludedBlobCount.record(analysis.minedBlock.includedBlobCount, strategyAttributes);
|
|
190
231
|
// Record actual fees from blob transactions in the mined block
|
|
191
232
|
for (const blobTx of analysis.minedBlock.includedBlobTxs){
|
|
192
233
|
// Record priority fee per gas in Gwei
|
|
@@ -211,16 +252,34 @@ export class SequencerMetrics {
|
|
|
211
252
|
// Record analysis results if available
|
|
212
253
|
if (analysis.analysis) {
|
|
213
254
|
this.fishermanTimeBeforeBlock.record(Math.ceil(analysis.analysis.timeBeforeBlockMs), strategyAttributes);
|
|
255
|
+
// Record whether the block reached 100% blob capacity
|
|
256
|
+
if (analysis.analysis.blockBlobsFull) {
|
|
257
|
+
this.fishermanBlockBlobsFull.add(1, {
|
|
258
|
+
...strategyAttributes,
|
|
259
|
+
[Attributes.OK]: true
|
|
260
|
+
});
|
|
261
|
+
} else {
|
|
262
|
+
this.fishermanBlockBlobsFull.add(1, {
|
|
263
|
+
...strategyAttributes,
|
|
264
|
+
[Attributes.OK]: false
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
// Record the max blob capacity for this block
|
|
268
|
+
this.fishermanMaxBlobCapacity.record(analysis.analysis.maxBlobCapacity, strategyAttributes);
|
|
214
269
|
// Record strategy-specific inclusion result
|
|
215
270
|
if (strategyResult.wouldBeIncluded !== undefined) {
|
|
271
|
+
const inclusionAttributes = {
|
|
272
|
+
...strategyAttributes,
|
|
273
|
+
[Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false'
|
|
274
|
+
};
|
|
216
275
|
if (strategyResult.wouldBeIncluded) {
|
|
217
276
|
this.fishermanWouldBeIncluded.add(1, {
|
|
218
|
-
...
|
|
277
|
+
...inclusionAttributes,
|
|
219
278
|
[Attributes.OK]: true
|
|
220
279
|
});
|
|
221
280
|
} else {
|
|
222
281
|
this.fishermanWouldBeIncluded.add(1, {
|
|
223
|
-
...
|
|
282
|
+
...inclusionAttributes,
|
|
224
283
|
[Attributes.OK]: false,
|
|
225
284
|
...strategyResult.exclusionReason && {
|
|
226
285
|
[Attributes.ERROR_TYPE]: strategyResult.exclusionReason
|
|
@@ -231,15 +290,27 @@ export class SequencerMetrics {
|
|
|
231
290
|
// Record strategy-specific priority fee delta
|
|
232
291
|
if (strategyResult.priorityFeeDelta !== undefined) {
|
|
233
292
|
const priorityFeeDeltaGwei = Number(strategyResult.priorityFeeDelta) / 1e9;
|
|
234
|
-
|
|
293
|
+
const deltaAttributes = {
|
|
294
|
+
...strategyAttributes,
|
|
295
|
+
[Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false'
|
|
296
|
+
};
|
|
297
|
+
this.fishermanPriorityFeeDelta.record(priorityFeeDeltaGwei, deltaAttributes);
|
|
235
298
|
}
|
|
236
299
|
// Record estimated cost if available
|
|
237
300
|
if (strategyResult.estimatedCostEth !== undefined) {
|
|
238
|
-
|
|
301
|
+
const costAttributes = {
|
|
302
|
+
...strategyAttributes,
|
|
303
|
+
[Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false'
|
|
304
|
+
};
|
|
305
|
+
this.fishermanEstimatedCost.record(strategyResult.estimatedCostEth, costAttributes);
|
|
239
306
|
}
|
|
240
307
|
// Record estimated overpayment if available
|
|
241
308
|
if (strategyResult.estimatedOverpaymentEth !== undefined) {
|
|
242
|
-
|
|
309
|
+
const overpaymentAttributes = {
|
|
310
|
+
...strategyAttributes,
|
|
311
|
+
[Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false'
|
|
312
|
+
};
|
|
313
|
+
this.fishermanEstimatedOverpayment.record(strategyResult.estimatedOverpaymentEth, overpaymentAttributes);
|
|
243
314
|
}
|
|
244
315
|
}
|
|
245
316
|
}
|