@aztec/sequencer-client 0.0.0-test.0 → 0.0.1-commit.001888fc
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/index.d.ts +1 -1
- package/dest/client/sequencer-client.d.ts +50 -33
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +164 -57
- package/dest/config.d.ts +35 -17
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +150 -81
- package/dest/global_variable_builder/global_builder.d.ts +24 -15
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +63 -44
- package/dest/global_variable_builder/index.d.ts +1 -1
- package/dest/index.d.ts +2 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -3
- package/dest/publisher/config.d.ts +48 -27
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +109 -32
- package/dest/publisher/index.d.ts +4 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/index.js +3 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +59 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/index.js +2 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +52 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -0
- package/dest/publisher/sequencer-publisher-factory.js +76 -0
- package/dest/publisher/sequencer-publisher-metrics.d.ts +5 -4
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +34 -62
- package/dest/publisher/sequencer-publisher.d.ts +158 -93
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +1452 -255
- package/dest/sequencer/checkpoint_proposal_job.d.ts +100 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job.js +1240 -0
- package/dest/sequencer/checkpoint_voter.d.ts +35 -0
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_voter.js +109 -0
- package/dest/sequencer/config.d.ts +7 -1
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/errors.d.ts +11 -0
- package/dest/sequencer/errors.d.ts.map +1 -0
- package/dest/sequencer/errors.js +15 -0
- package/dest/sequencer/events.d.ts +46 -0
- package/dest/sequencer/events.d.ts.map +1 -0
- package/dest/sequencer/events.js +1 -0
- package/dest/sequencer/index.d.ts +4 -2
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +3 -1
- package/dest/sequencer/metrics.d.ts +60 -12
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +283 -67
- package/dest/sequencer/sequencer.d.ts +157 -135
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +966 -523
- package/dest/sequencer/timetable.d.ts +75 -25
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +174 -62
- package/dest/sequencer/types.d.ts +3 -0
- package/dest/sequencer/types.d.ts.map +1 -0
- package/dest/sequencer/types.js +1 -0
- package/dest/sequencer/utils.d.ts +20 -38
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +12 -47
- package/dest/test/index.d.ts +9 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +0 -4
- package/dest/test/mock_checkpoint_builder.d.ts +99 -0
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
- package/dest/test/mock_checkpoint_builder.js +231 -0
- package/dest/test/utils.d.ts +53 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +104 -0
- package/package.json +46 -45
- package/src/client/sequencer-client.ts +220 -104
- package/src/config.ts +172 -96
- package/src/global_variable_builder/global_builder.ts +85 -55
- package/src/index.ts +1 -3
- package/src/publisher/config.ts +150 -59
- package/src/publisher/index.ts +7 -0
- package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
- package/src/publisher/l1_tx_failed_store/index.ts +3 -0
- package/src/publisher/sequencer-publisher-factory.ts +124 -0
- package/src/publisher/sequencer-publisher-metrics.ts +33 -63
- package/src/publisher/sequencer-publisher.ts +1266 -311
- package/src/sequencer/README.md +531 -0
- package/src/sequencer/checkpoint_proposal_job.ts +967 -0
- package/src/sequencer/checkpoint_voter.ts +130 -0
- package/src/sequencer/config.ts +8 -0
- package/src/sequencer/errors.ts +21 -0
- package/src/sequencer/events.ts +27 -0
- package/src/sequencer/index.ts +3 -1
- package/src/sequencer/metrics.ts +362 -73
- package/src/sequencer/sequencer.ts +712 -586
- package/src/sequencer/timetable.ts +224 -64
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +28 -60
- package/src/test/index.ts +11 -5
- package/src/test/mock_checkpoint_builder.ts +323 -0
- package/src/test/utils.ts +167 -0
- package/dest/sequencer/allowed.d.ts +0 -3
- package/dest/sequencer/allowed.d.ts.map +0 -1
- package/dest/sequencer/allowed.js +0 -27
- package/dest/slasher/factory.d.ts +0 -7
- package/dest/slasher/factory.d.ts.map +0 -1
- package/dest/slasher/factory.js +0 -8
- package/dest/slasher/index.d.ts +0 -3
- package/dest/slasher/index.d.ts.map +0 -1
- package/dest/slasher/index.js +0 -2
- package/dest/slasher/slasher_client.d.ts +0 -75
- package/dest/slasher/slasher_client.d.ts.map +0 -1
- package/dest/slasher/slasher_client.js +0 -132
- package/dest/tx_validator/archive_cache.d.ts +0 -14
- package/dest/tx_validator/archive_cache.d.ts.map +0 -1
- package/dest/tx_validator/archive_cache.js +0 -22
- package/dest/tx_validator/gas_validator.d.ts +0 -14
- package/dest/tx_validator/gas_validator.d.ts.map +0 -1
- package/dest/tx_validator/gas_validator.js +0 -78
- package/dest/tx_validator/nullifier_cache.d.ts +0 -16
- package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
- package/dest/tx_validator/nullifier_cache.js +0 -24
- package/dest/tx_validator/phases_validator.d.ts +0 -12
- package/dest/tx_validator/phases_validator.d.ts.map +0 -1
- package/dest/tx_validator/phases_validator.js +0 -80
- package/dest/tx_validator/test_utils.d.ts +0 -23
- package/dest/tx_validator/test_utils.d.ts.map +0 -1
- package/dest/tx_validator/test_utils.js +0 -26
- package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
- package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
- package/dest/tx_validator/tx_validator_factory.js +0 -50
- package/src/sequencer/allowed.ts +0 -36
- package/src/slasher/factory.ts +0 -15
- package/src/slasher/index.ts +0 -2
- package/src/slasher/slasher_client.ts +0 -193
- package/src/tx_validator/archive_cache.ts +0 -28
- package/src/tx_validator/gas_validator.ts +0 -101
- package/src/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/phases_validator.ts +0 -98
- package/src/tx_validator/test_utils.ts +0 -48
- package/src/tx_validator/tx_validator_factory.ts +0 -120
|
@@ -1,78 +1,132 @@
|
|
|
1
|
-
import { Attributes, Metrics,
|
|
2
|
-
import {
|
|
1
|
+
import { Attributes, Metrics, createUpDownCounterWithDefault } from '@aztec/telemetry-client';
|
|
2
|
+
import { formatUnits } from 'viem';
|
|
3
3
|
export class SequencerMetrics {
|
|
4
|
+
rollup;
|
|
4
5
|
tracer;
|
|
6
|
+
meter;
|
|
5
7
|
blockCounter;
|
|
6
8
|
blockBuildDuration;
|
|
7
9
|
blockBuildManaPerSecond;
|
|
8
10
|
stateTransitionBufferDuration;
|
|
9
|
-
|
|
10
|
-
currentBlockSize;
|
|
11
|
-
blockBuilderInsertions;
|
|
11
|
+
// these are gauges because for individual sequencers building a block is not something that happens often enough to warrant a histogram
|
|
12
12
|
timeToCollectAttestations;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
allowanceToCollectAttestations;
|
|
14
|
+
requiredAttestions;
|
|
15
|
+
collectedAttestions;
|
|
16
|
+
rewards;
|
|
17
|
+
slots;
|
|
18
|
+
filledSlots;
|
|
19
|
+
blockProposalFailed;
|
|
20
|
+
checkpointProposalSuccess;
|
|
21
|
+
checkpointPrecheckFailed;
|
|
22
|
+
checkpointProposalFailed;
|
|
23
|
+
checkpointSuccess;
|
|
24
|
+
slashingAttempts;
|
|
25
|
+
checkpointAttestationDelay;
|
|
26
|
+
checkpointBuildDuration;
|
|
27
|
+
checkpointBlockCount;
|
|
28
|
+
checkpointTxCount;
|
|
29
|
+
checkpointTotalMana;
|
|
30
|
+
// Fisherman fee analysis metrics
|
|
31
|
+
fishermanWouldBeIncluded;
|
|
32
|
+
fishermanTimeBeforeBlock;
|
|
33
|
+
fishermanPendingBlobTxCount;
|
|
34
|
+
fishermanIncludedBlobTxCount;
|
|
35
|
+
fishermanPendingBlobCount;
|
|
36
|
+
fishermanIncludedBlobCount;
|
|
37
|
+
fishermanBlockBlobsFull;
|
|
38
|
+
fishermanMaxBlobCapacity;
|
|
39
|
+
fishermanCalculatedPriorityFee;
|
|
40
|
+
fishermanPriorityFeeDelta;
|
|
41
|
+
fishermanEstimatedCost;
|
|
42
|
+
fishermanEstimatedOverpayment;
|
|
43
|
+
fishermanMinedBlobTxPriorityFee;
|
|
44
|
+
fishermanMinedBlobTxTotalCost;
|
|
45
|
+
lastSeenSlot;
|
|
46
|
+
constructor(client, rollup, name = 'Sequencer'){
|
|
47
|
+
this.rollup = rollup;
|
|
48
|
+
this.meter = client.getMeter(name);
|
|
15
49
|
this.tracer = client.getTracer(name);
|
|
16
|
-
this.blockCounter = meter
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
50
|
+
this.blockCounter = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_BLOCK_COUNT, {
|
|
51
|
+
[Attributes.STATUS]: [
|
|
52
|
+
'failed',
|
|
53
|
+
'built'
|
|
54
|
+
]
|
|
21
55
|
});
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
56
|
+
this.blockBuildDuration = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_DURATION);
|
|
57
|
+
this.blockBuildManaPerSecond = this.meter.createGauge(Metrics.SEQUENCER_BLOCK_BUILD_MANA_PER_SECOND);
|
|
58
|
+
this.stateTransitionBufferDuration = this.meter.createHistogram(Metrics.SEQUENCER_STATE_TRANSITION_BUFFER_DURATION);
|
|
59
|
+
this.checkpointAttestationDelay = this.meter.createHistogram(Metrics.SEQUENCER_CHECKPOINT_ATTESTATION_DELAY);
|
|
60
|
+
this.rewards = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_SLOT_REWARDS);
|
|
61
|
+
this.slots = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLOT_COUNT);
|
|
62
|
+
/**
|
|
63
|
+
* NOTE: we do not track missed slots as a separate metric. That would be difficult to determine
|
|
64
|
+
* Instead, use a computed metric, `slots - filledSlots` to get the number of slots a sequencer has missed.
|
|
65
|
+
*/ this.filledSlots = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_FILLED_SLOT_COUNT);
|
|
66
|
+
this.timeToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_DURATION);
|
|
67
|
+
this.allowanceToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_TIME_ALLOWANCE);
|
|
68
|
+
this.requiredAttestions = this.meter.createGauge(Metrics.SEQUENCER_REQUIRED_ATTESTATIONS_COUNT);
|
|
69
|
+
this.collectedAttestions = this.meter.createGauge(Metrics.SEQUENCER_COLLECTED_ATTESTATIONS_COUNT);
|
|
70
|
+
this.blockProposalFailed = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_BLOCK_PROPOSAL_FAILED_COUNT);
|
|
71
|
+
this.checkpointProposalSuccess = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_CHECKPOINT_PROPOSAL_SUCCESS_COUNT);
|
|
72
|
+
this.checkpointSuccess = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_CHECKPOINT_SUCCESS_COUNT);
|
|
73
|
+
this.checkpointPrecheckFailed = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_CHECKPOINT_PRECHECK_FAILED_COUNT, {
|
|
74
|
+
[Attributes.ERROR_TYPE]: [
|
|
75
|
+
'slot_already_taken',
|
|
76
|
+
'rollup_contract_check_failed',
|
|
77
|
+
'slot_mismatch',
|
|
78
|
+
'block_number_mismatch'
|
|
79
|
+
]
|
|
26
80
|
});
|
|
27
|
-
this.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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);
|
|
86
|
+
this.slashingAttempts = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLASHING_ATTEMPTS_COUNT);
|
|
87
|
+
// Fisherman fee analysis metrics
|
|
88
|
+
this.fishermanWouldBeIncluded = createUpDownCounterWithDefault(this.meter, Metrics.FISHERMAN_FEE_ANALYSIS_WOULD_BE_INCLUDED, {
|
|
89
|
+
[Attributes.OK]: [
|
|
90
|
+
true,
|
|
91
|
+
false
|
|
92
|
+
],
|
|
93
|
+
[Attributes.BLOCK_FULL]: [
|
|
94
|
+
'true',
|
|
95
|
+
'false'
|
|
96
|
+
]
|
|
31
97
|
});
|
|
32
|
-
|
|
33
|
-
|
|
98
|
+
this.fishermanTimeBeforeBlock = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_TIME_BEFORE_BLOCK);
|
|
99
|
+
this.fishermanPendingBlobTxCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PENDING_BLOB_TX_COUNT);
|
|
100
|
+
this.fishermanIncludedBlobTxCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_INCLUDED_BLOB_TX_COUNT);
|
|
101
|
+
this.fishermanCalculatedPriorityFee = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_CALCULATED_PRIORITY_FEE);
|
|
102
|
+
this.fishermanPriorityFeeDelta = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PRIORITY_FEE_DELTA);
|
|
103
|
+
this.fishermanEstimatedCost = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_ESTIMATED_COST);
|
|
104
|
+
this.fishermanEstimatedOverpayment = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_ESTIMATED_OVERPAYMENT);
|
|
105
|
+
this.fishermanMinedBlobTxPriorityFee = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_MINED_BLOB_TX_PRIORITY_FEE);
|
|
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
|
+
]
|
|
34
114
|
});
|
|
35
|
-
|
|
36
|
-
observer.observe(sequencerStateToNumber(getState()));
|
|
37
|
-
});
|
|
38
|
-
this.currentBlockNumber = meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_NUMBER, {
|
|
39
|
-
description: 'Current block number',
|
|
40
|
-
valueType: ValueType.INT
|
|
41
|
-
});
|
|
42
|
-
this.currentBlockSize = meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_SIZE, {
|
|
43
|
-
description: 'Current block size',
|
|
44
|
-
valueType: ValueType.INT
|
|
45
|
-
});
|
|
46
|
-
this.timeToCollectAttestations = meter.createGauge(Metrics.SEQUENCER_TIME_TO_COLLECT_ATTESTATIONS, {
|
|
47
|
-
description: 'The time spent collecting attestations from committee members',
|
|
48
|
-
valueType: ValueType.INT
|
|
49
|
-
});
|
|
50
|
-
this.blockBuilderInsertions = meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_INSERTION_TIME, {
|
|
51
|
-
description: 'Timer for tree insertions performed by the block builder',
|
|
52
|
-
unit: 'us',
|
|
53
|
-
valueType: ValueType.INT
|
|
54
|
-
});
|
|
55
|
-
this.setCurrentBlock(0, 0);
|
|
56
|
-
}
|
|
57
|
-
startCollectingAttestationsTimer() {
|
|
58
|
-
const startTime = Date.now();
|
|
59
|
-
const stop = ()=>{
|
|
60
|
-
const duration = Date.now() - startTime;
|
|
61
|
-
this.recordTimeToCollectAttestations(duration);
|
|
62
|
-
};
|
|
63
|
-
return stop.bind(this);
|
|
115
|
+
this.fishermanMaxBlobCapacity = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_MAX_BLOB_CAPACITY);
|
|
64
116
|
}
|
|
65
|
-
|
|
66
|
-
this.
|
|
117
|
+
recordRequiredAttestations(requiredAttestationsCount, allowanceMs) {
|
|
118
|
+
this.requiredAttestions.record(requiredAttestationsCount);
|
|
119
|
+
this.allowanceToCollectAttestations.record(Math.ceil(allowanceMs));
|
|
120
|
+
// reset
|
|
121
|
+
this.collectedAttestions.record(0);
|
|
122
|
+
this.timeToCollectAttestations.record(0);
|
|
67
123
|
}
|
|
68
|
-
|
|
69
|
-
this.
|
|
124
|
+
recordCheckpointAttestationDelay(duration) {
|
|
125
|
+
this.checkpointAttestationDelay.record(duration);
|
|
70
126
|
}
|
|
71
|
-
|
|
72
|
-
this.
|
|
73
|
-
|
|
74
|
-
});
|
|
75
|
-
this.setCurrentBlock(0, 0);
|
|
127
|
+
recordCollectedAttestations(count, durationMs) {
|
|
128
|
+
this.collectedAttestions.record(count);
|
|
129
|
+
this.timeToCollectAttestations.record(Math.ceil(durationMs));
|
|
76
130
|
}
|
|
77
131
|
recordBuiltBlock(buildDurationMs, totalMana) {
|
|
78
132
|
this.blockCounter.add(1, {
|
|
@@ -85,18 +139,180 @@ export class SequencerMetrics {
|
|
|
85
139
|
this.blockCounter.add(1, {
|
|
86
140
|
[Attributes.STATUS]: 'failed'
|
|
87
141
|
});
|
|
88
|
-
this.setCurrentBlock(0, 0);
|
|
89
|
-
}
|
|
90
|
-
recordNewBlock(blockNumber, txCount) {
|
|
91
|
-
this.setCurrentBlock(blockNumber, txCount);
|
|
92
142
|
}
|
|
93
143
|
recordStateTransitionBufferMs(durationMs, state) {
|
|
94
144
|
this.stateTransitionBufferDuration.record(durationMs, {
|
|
95
145
|
[Attributes.SEQUENCER_STATE]: state
|
|
96
146
|
});
|
|
97
147
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
this.
|
|
148
|
+
incOpenSlot(slot, proposer) {
|
|
149
|
+
// sequencer went through the loop a second time. Noop
|
|
150
|
+
if (slot === this.lastSeenSlot) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
this.slots.add(1, {
|
|
154
|
+
[Attributes.BLOCK_PROPOSER]: proposer
|
|
155
|
+
});
|
|
156
|
+
this.lastSeenSlot = slot;
|
|
157
|
+
}
|
|
158
|
+
async incFilledSlot(proposer, coinbase) {
|
|
159
|
+
this.filledSlots.add(1, {
|
|
160
|
+
[Attributes.BLOCK_PROPOSER]: proposer
|
|
161
|
+
});
|
|
162
|
+
this.lastSeenSlot = undefined;
|
|
163
|
+
if (coinbase) {
|
|
164
|
+
try {
|
|
165
|
+
const rewards = await this.rollup.getSequencerRewards(coinbase);
|
|
166
|
+
const fmt = parseFloat(formatUnits(rewards, 18));
|
|
167
|
+
this.rewards.record(fmt, {
|
|
168
|
+
[Attributes.COINBASE]: coinbase.toString()
|
|
169
|
+
});
|
|
170
|
+
} catch {
|
|
171
|
+
// no-op
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
recordCheckpointSuccess() {
|
|
176
|
+
this.checkpointSuccess.add(1);
|
|
177
|
+
}
|
|
178
|
+
recordBlockProposalFailed(reason) {
|
|
179
|
+
this.blockProposalFailed.add(1, {
|
|
180
|
+
...reason && {
|
|
181
|
+
[Attributes.ERROR_TYPE]: reason
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
recordCheckpointProposalSuccess() {
|
|
186
|
+
this.checkpointProposalSuccess.add(1);
|
|
187
|
+
}
|
|
188
|
+
recordCheckpointPrecheckFailed(checkType) {
|
|
189
|
+
this.checkpointPrecheckFailed.add(1, {
|
|
190
|
+
[Attributes.ERROR_TYPE]: checkType
|
|
191
|
+
});
|
|
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
|
+
}
|
|
206
|
+
recordSlashingAttempt(actionCount) {
|
|
207
|
+
this.slashingAttempts.add(actionCount);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Records metrics for a completed fisherman fee analysis
|
|
211
|
+
* @param analysis - The completed fee analysis result
|
|
212
|
+
*/ recordFishermanFeeAnalysis(analysis) {
|
|
213
|
+
// In fisherman mode, we should always have strategy results
|
|
214
|
+
if (!analysis.computedPrices.strategyResults || analysis.computedPrices.strategyResults.length === 0) {
|
|
215
|
+
// This should never happen in fisherman mode - log an error
|
|
216
|
+
// We don't record metrics without strategy IDs as that defeats the purpose
|
|
217
|
+
throw new Error(`No strategy results found in fisherman fee analysis ${analysis.id}. This indicates a bug in the fee analysis.`);
|
|
218
|
+
}
|
|
219
|
+
// Record metrics for each strategy separately
|
|
220
|
+
for (const strategyResult of analysis.computedPrices.strategyResults){
|
|
221
|
+
const strategyAttributes = {
|
|
222
|
+
[Attributes.FISHERMAN_FEE_STRATEGY_ID]: strategyResult.strategyId
|
|
223
|
+
};
|
|
224
|
+
// Record pending block snapshot data (once per strategy for comparison)
|
|
225
|
+
this.fishermanPendingBlobTxCount.record(analysis.pendingSnapshot.pendingBlobTxCount, strategyAttributes);
|
|
226
|
+
this.fishermanPendingBlobCount.record(analysis.pendingSnapshot.pendingBlobCount, strategyAttributes);
|
|
227
|
+
// Record mined block data if available
|
|
228
|
+
if (analysis.minedBlock) {
|
|
229
|
+
this.fishermanIncludedBlobTxCount.record(analysis.minedBlock.includedBlobTxCount, strategyAttributes);
|
|
230
|
+
this.fishermanIncludedBlobCount.record(analysis.minedBlock.includedBlobCount, strategyAttributes);
|
|
231
|
+
// Record actual fees from blob transactions in the mined block
|
|
232
|
+
for (const blobTx of analysis.minedBlock.includedBlobTxs){
|
|
233
|
+
// Record priority fee per gas in Gwei
|
|
234
|
+
const priorityFeeGwei = Number(blobTx.maxPriorityFeePerGas) / 1e9;
|
|
235
|
+
this.fishermanMinedBlobTxPriorityFee.record(priorityFeeGwei, strategyAttributes);
|
|
236
|
+
// Calculate total cost in ETH
|
|
237
|
+
// Cost = (gas * (baseFee + priorityFee)) + (blobCount * blobGasPerBlob * blobBaseFee)
|
|
238
|
+
const baseFee = analysis.minedBlock.baseFeePerGas;
|
|
239
|
+
const effectiveGasPrice = baseFee + blobTx.maxPriorityFeePerGas;
|
|
240
|
+
// Calculate execution cost using actual gas limit from the transaction
|
|
241
|
+
const executionCost = blobTx.gas * effectiveGasPrice;
|
|
242
|
+
// Calculate blob cost using maxFeePerBlobGas * blobCount * GAS_PER_BLOB
|
|
243
|
+
const blobCost = blobTx.maxFeePerBlobGas * BigInt(blobTx.blobCount) * 131072n; // 128KB per blob
|
|
244
|
+
const totalCostWei = executionCost + blobCost;
|
|
245
|
+
const totalCostEth = Number(totalCostWei) / 1e18;
|
|
246
|
+
this.fishermanMinedBlobTxTotalCost.record(totalCostEth, strategyAttributes);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// Record the calculated priority fee for this strategy
|
|
250
|
+
const calculatedPriorityFeeGwei = Number(strategyResult.calculatedPriorityFee) / 1e9;
|
|
251
|
+
this.fishermanCalculatedPriorityFee.record(calculatedPriorityFeeGwei, strategyAttributes);
|
|
252
|
+
// Record analysis results if available
|
|
253
|
+
if (analysis.analysis) {
|
|
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);
|
|
269
|
+
// Record strategy-specific inclusion result
|
|
270
|
+
if (strategyResult.wouldBeIncluded !== undefined) {
|
|
271
|
+
const inclusionAttributes = {
|
|
272
|
+
...strategyAttributes,
|
|
273
|
+
[Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false'
|
|
274
|
+
};
|
|
275
|
+
if (strategyResult.wouldBeIncluded) {
|
|
276
|
+
this.fishermanWouldBeIncluded.add(1, {
|
|
277
|
+
...inclusionAttributes,
|
|
278
|
+
[Attributes.OK]: true
|
|
279
|
+
});
|
|
280
|
+
} else {
|
|
281
|
+
this.fishermanWouldBeIncluded.add(1, {
|
|
282
|
+
...inclusionAttributes,
|
|
283
|
+
[Attributes.OK]: false,
|
|
284
|
+
...strategyResult.exclusionReason && {
|
|
285
|
+
[Attributes.ERROR_TYPE]: strategyResult.exclusionReason
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
// Record strategy-specific priority fee delta
|
|
291
|
+
if (strategyResult.priorityFeeDelta !== undefined) {
|
|
292
|
+
const priorityFeeDeltaGwei = Number(strategyResult.priorityFeeDelta) / 1e9;
|
|
293
|
+
const deltaAttributes = {
|
|
294
|
+
...strategyAttributes,
|
|
295
|
+
[Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false'
|
|
296
|
+
};
|
|
297
|
+
this.fishermanPriorityFeeDelta.record(priorityFeeDeltaGwei, deltaAttributes);
|
|
298
|
+
}
|
|
299
|
+
// Record estimated cost if available
|
|
300
|
+
if (strategyResult.estimatedCostEth !== undefined) {
|
|
301
|
+
const costAttributes = {
|
|
302
|
+
...strategyAttributes,
|
|
303
|
+
[Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false'
|
|
304
|
+
};
|
|
305
|
+
this.fishermanEstimatedCost.record(strategyResult.estimatedCostEth, costAttributes);
|
|
306
|
+
}
|
|
307
|
+
// Record estimated overpayment if available
|
|
308
|
+
if (strategyResult.estimatedOverpaymentEth !== undefined) {
|
|
309
|
+
const overpaymentAttributes = {
|
|
310
|
+
...strategyAttributes,
|
|
311
|
+
[Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false'
|
|
312
|
+
};
|
|
313
|
+
this.fishermanEstimatedOverpayment.record(strategyResult.estimatedOverpaymentEth, overpaymentAttributes);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
101
317
|
}
|
|
102
318
|
}
|