@aztec/sequencer-client 0.0.1-commit.24de95ac → 0.0.1-commit.2606882
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/README.md +281 -21
- package/dest/client/index.d.ts +1 -1
- package/dest/client/sequencer-client.d.ts +26 -16
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +78 -37
- package/dest/config.d.ts +37 -8
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +139 -48
- package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
- package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_predictor.js +128 -0
- package/dest/global_variable_builder/fee_provider.d.ts +21 -0
- package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_provider.js +58 -0
- package/dest/global_variable_builder/global_builder.d.ts +24 -20
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +44 -65
- package/dest/global_variable_builder/index.d.ts +4 -2
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- package/dest/global_variable_builder/index.js +2 -0
- package/dest/index.d.ts +2 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -2
- package/dest/publisher/config.d.ts +55 -20
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +124 -34
- package/dest/publisher/index.d.ts +2 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +58 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/index.js +2 -0
- package/dest/publisher/sequencer-bundle-simulator.d.ts +96 -0
- package/dest/publisher/sequencer-bundle-simulator.d.ts.map +1 -0
- package/dest/publisher/sequencer-bundle-simulator.js +198 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +15 -8
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +28 -4
- package/dest/publisher/sequencer-publisher-metrics.d.ts +3 -3
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +23 -86
- package/dest/publisher/sequencer-publisher.d.ts +137 -97
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +1001 -416
- package/dest/sequencer/automine/automine_factory.d.ts +54 -0
- package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_factory.js +84 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts +151 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_sequencer.js +509 -0
- package/dest/sequencer/chain_state_overrides.d.ts +61 -0
- package/dest/sequencer/chain_state_overrides.d.ts.map +1 -0
- package/dest/sequencer/chain_state_overrides.js +98 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts +150 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job.js +1792 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
- package/dest/sequencer/checkpoint_voter.d.ts +34 -0
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_voter.js +106 -0
- package/dest/sequencer/config.d.ts +3 -2
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/errors.d.ts +1 -1
- package/dest/sequencer/errors.d.ts.map +1 -1
- package/dest/sequencer/events.d.ts +92 -0
- package/dest/sequencer/events.d.ts.map +1 -0
- package/dest/sequencer/events.js +1 -0
- package/dest/sequencer/index.d.ts +6 -2
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +5 -1
- package/dest/sequencer/metrics.d.ts +48 -4
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +257 -50
- package/dest/sequencer/sequencer.d.ts +175 -144
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +1022 -567
- package/dest/sequencer/timetable.d.ts +64 -16
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +154 -64
- 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 +14 -8
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +7 -4
- package/dest/test/index.d.ts +6 -7
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +95 -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 +105 -0
- package/package.json +32 -30
- package/src/client/sequencer-client.ts +105 -60
- package/src/config.ts +163 -57
- package/src/global_variable_builder/README.md +44 -0
- package/src/global_variable_builder/fee_predictor.ts +172 -0
- package/src/global_variable_builder/fee_provider.ts +75 -0
- package/src/global_variable_builder/global_builder.ts +63 -92
- package/src/global_variable_builder/index.ts +3 -1
- package/src/index.ts +5 -2
- package/src/publisher/config.ts +174 -51
- package/src/publisher/index.ts +3 -0
- package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +57 -0
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
- package/src/publisher/l1_tx_failed_store/index.ts +3 -0
- package/src/publisher/sequencer-bundle-simulator.ts +254 -0
- package/src/publisher/sequencer-publisher-factory.ts +45 -14
- package/src/publisher/sequencer-publisher-metrics.ts +19 -71
- package/src/publisher/sequencer-publisher.ts +795 -538
- package/src/sequencer/README.md +243 -0
- package/src/sequencer/automine/README.md +46 -0
- package/src/sequencer/automine/automine_factory.ts +145 -0
- package/src/sequencer/automine/automine_sequencer.ts +595 -0
- package/src/sequencer/chain_state_overrides.ts +162 -0
- package/src/sequencer/checkpoint_proposal_job.ts +1632 -0
- package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
- package/src/sequencer/checkpoint_voter.ts +119 -0
- package/src/sequencer/config.ts +2 -1
- package/src/sequencer/events.ts +76 -0
- package/src/sequencer/index.ts +5 -1
- package/src/sequencer/metrics.ts +330 -62
- package/src/sequencer/sequencer.ts +831 -748
- package/src/sequencer/timetable.ts +181 -81
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +18 -9
- package/src/test/index.ts +5 -6
- package/src/test/mock_checkpoint_builder.ts +323 -0
- package/src/test/utils.ts +185 -0
- package/dest/sequencer/block_builder.d.ts +0 -27
- package/dest/sequencer/block_builder.d.ts.map +0 -1
- package/dest/sequencer/block_builder.js +0 -130
- package/dest/tx_validator/nullifier_cache.d.ts +0 -14
- package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
- package/dest/tx_validator/nullifier_cache.js +0 -24
- package/dest/tx_validator/tx_validator_factory.d.ts +0 -17
- package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
- package/dest/tx_validator/tx_validator_factory.js +0 -53
- package/src/sequencer/block_builder.ts +0 -218
- package/src/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/tx_validator_factory.ts +0 -132
package/src/sequencer/metrics.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
-
import type { RollupContract } from '@aztec/ethereum';
|
|
2
|
+
import type { RollupContract } from '@aztec/ethereum/contracts';
|
|
3
|
+
import type { L1FeeAnalysisResult } from '@aztec/ethereum/l1-fee-analysis';
|
|
4
|
+
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
5
|
import {
|
|
4
6
|
Attributes,
|
|
5
7
|
type Gauge,
|
|
@@ -9,7 +11,7 @@ import {
|
|
|
9
11
|
type TelemetryClient,
|
|
10
12
|
type Tracer,
|
|
11
13
|
type UpDownCounter,
|
|
12
|
-
|
|
14
|
+
createUpDownCounterWithDefault,
|
|
13
15
|
} from '@aztec/telemetry-client';
|
|
14
16
|
|
|
15
17
|
import { type Hex, formatUnits } from 'viem';
|
|
@@ -24,6 +26,7 @@ export class SequencerMetrics {
|
|
|
24
26
|
private blockBuildDuration: Histogram;
|
|
25
27
|
private blockBuildManaPerSecond: Gauge;
|
|
26
28
|
private stateTransitionBufferDuration: Histogram;
|
|
29
|
+
private stateDuration: Histogram;
|
|
27
30
|
|
|
28
31
|
// these are gauges because for individual sequencers building a block is not something that happens often enough to warrant a histogram
|
|
29
32
|
private timeToCollectAttestations: Gauge;
|
|
@@ -36,7 +39,37 @@ export class SequencerMetrics {
|
|
|
36
39
|
private slots: UpDownCounter;
|
|
37
40
|
private filledSlots: UpDownCounter;
|
|
38
41
|
|
|
39
|
-
private
|
|
42
|
+
private blockProposalFailed: UpDownCounter;
|
|
43
|
+
private checkpointProposalSuccess: UpDownCounter;
|
|
44
|
+
private checkpointPrecheckFailed: UpDownCounter;
|
|
45
|
+
private checkpointProposalFailed: UpDownCounter;
|
|
46
|
+
private checkpointSuccess: UpDownCounter;
|
|
47
|
+
private slashingAttempts: UpDownCounter;
|
|
48
|
+
private pipelineDepth: Gauge;
|
|
49
|
+
private pipelineDiscards: UpDownCounter;
|
|
50
|
+
private pipelineParentCheckpointMismatches: UpDownCounter;
|
|
51
|
+
|
|
52
|
+
// Fisherman fee analysis metrics
|
|
53
|
+
private fishermanWouldBeIncluded: UpDownCounter;
|
|
54
|
+
private fishermanTimeBeforeBlock: Histogram;
|
|
55
|
+
private fishermanPendingBlobTxCount: Histogram;
|
|
56
|
+
private fishermanIncludedBlobTxCount: Histogram;
|
|
57
|
+
private fishermanPendingBlobCount: Histogram;
|
|
58
|
+
private fishermanIncludedBlobCount: Histogram;
|
|
59
|
+
private fishermanBlockBlobsFull: UpDownCounter;
|
|
60
|
+
private fishermanMaxBlobCapacity: Histogram;
|
|
61
|
+
private fishermanCalculatedPriorityFee: Histogram;
|
|
62
|
+
private fishermanPriorityFeeDelta: Histogram;
|
|
63
|
+
private fishermanEstimatedCost: Histogram;
|
|
64
|
+
private fishermanEstimatedOverpayment: Histogram;
|
|
65
|
+
private fishermanMinedBlobTxPriorityFee: Histogram;
|
|
66
|
+
private fishermanMinedBlobTxTotalCost: Histogram;
|
|
67
|
+
|
|
68
|
+
private blockInterBlockTime: Histogram;
|
|
69
|
+
private lastBlockBuiltTimestamp?: number;
|
|
70
|
+
private lastBlockBuiltSlot?: SlotNumber;
|
|
71
|
+
|
|
72
|
+
private lastSeenSlot?: SlotNumber;
|
|
40
73
|
|
|
41
74
|
constructor(
|
|
42
75
|
client: TelemetryClient,
|
|
@@ -46,81 +79,138 @@ export class SequencerMetrics {
|
|
|
46
79
|
this.meter = client.getMeter(name);
|
|
47
80
|
this.tracer = client.getTracer(name);
|
|
48
81
|
|
|
49
|
-
this.blockCounter = this.meter
|
|
50
|
-
|
|
51
|
-
this.blockBuildDuration = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_DURATION, {
|
|
52
|
-
unit: 'ms',
|
|
53
|
-
description: 'Duration to build a block',
|
|
54
|
-
valueType: ValueType.INT,
|
|
82
|
+
this.blockCounter = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_BLOCK_COUNT, {
|
|
83
|
+
[Attributes.STATUS]: ['failed', 'built'],
|
|
55
84
|
});
|
|
56
85
|
|
|
57
|
-
this.
|
|
58
|
-
unit: 'mana/s',
|
|
59
|
-
description: 'Mana per second when building a block',
|
|
60
|
-
valueType: ValueType.INT,
|
|
61
|
-
});
|
|
86
|
+
this.blockBuildDuration = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_DURATION);
|
|
62
87
|
|
|
63
|
-
this.
|
|
64
|
-
Metrics.SEQUENCER_STATE_TRANSITION_BUFFER_DURATION,
|
|
65
|
-
{
|
|
66
|
-
unit: 'ms',
|
|
67
|
-
description:
|
|
68
|
-
'The time difference between when the sequencer needed to transition to a new state and when it actually did.',
|
|
69
|
-
valueType: ValueType.INT,
|
|
70
|
-
},
|
|
71
|
-
);
|
|
88
|
+
this.blockBuildManaPerSecond = this.meter.createGauge(Metrics.SEQUENCER_BLOCK_BUILD_MANA_PER_SECOND);
|
|
72
89
|
|
|
73
|
-
|
|
74
|
-
this.blockCounter.add(0, {
|
|
75
|
-
[Attributes.STATUS]: 'failed',
|
|
76
|
-
});
|
|
77
|
-
this.blockCounter.add(0, {
|
|
78
|
-
[Attributes.STATUS]: 'built',
|
|
79
|
-
});
|
|
90
|
+
this.blockInterBlockTime = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_INTER_BLOCK_TIME);
|
|
80
91
|
|
|
81
|
-
this.
|
|
82
|
-
valueType: ValueType.DOUBLE,
|
|
83
|
-
description: 'The rewards earned',
|
|
84
|
-
});
|
|
92
|
+
this.stateTransitionBufferDuration = this.meter.createHistogram(Metrics.SEQUENCER_STATE_TRANSITION_BUFFER_DURATION);
|
|
85
93
|
|
|
86
|
-
this.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
this.stateDuration = this.meter.createHistogram(Metrics.SEQUENCER_STATE_DURATION);
|
|
95
|
+
|
|
96
|
+
this.rewards = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_SLOT_REWARDS);
|
|
97
|
+
|
|
98
|
+
this.slots = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLOT_COUNT);
|
|
90
99
|
|
|
91
100
|
/**
|
|
92
101
|
* NOTE: we do not track missed slots as a separate metric. That would be difficult to determine
|
|
93
102
|
* Instead, use a computed metric, `slots - filledSlots` to get the number of slots a sequencer has missed.
|
|
94
103
|
*/
|
|
95
|
-
this.filledSlots = this.meter
|
|
96
|
-
valueType: ValueType.INT,
|
|
97
|
-
description: 'The number of slots this sequencer has filled',
|
|
98
|
-
});
|
|
104
|
+
this.filledSlots = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_FILLED_SLOT_COUNT);
|
|
99
105
|
|
|
100
|
-
this.timeToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_DURATION
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
106
|
+
this.timeToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_DURATION);
|
|
107
|
+
|
|
108
|
+
this.allowanceToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_TIME_ALLOWANCE);
|
|
109
|
+
|
|
110
|
+
this.requiredAttestions = this.meter.createGauge(Metrics.SEQUENCER_REQUIRED_ATTESTATIONS_COUNT);
|
|
111
|
+
|
|
112
|
+
this.collectedAttestions = this.meter.createGauge(Metrics.SEQUENCER_COLLECTED_ATTESTATIONS_COUNT);
|
|
113
|
+
|
|
114
|
+
this.blockProposalFailed = createUpDownCounterWithDefault(
|
|
115
|
+
this.meter,
|
|
116
|
+
Metrics.SEQUENCER_BLOCK_PROPOSAL_FAILED_COUNT,
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
this.checkpointProposalSuccess = createUpDownCounterWithDefault(
|
|
120
|
+
this.meter,
|
|
121
|
+
Metrics.SEQUENCER_CHECKPOINT_PROPOSAL_SUCCESS_COUNT,
|
|
122
|
+
);
|
|
105
123
|
|
|
106
|
-
this.
|
|
107
|
-
|
|
124
|
+
this.checkpointSuccess = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_CHECKPOINT_SUCCESS_COUNT);
|
|
125
|
+
|
|
126
|
+
this.checkpointPrecheckFailed = createUpDownCounterWithDefault(
|
|
127
|
+
this.meter,
|
|
128
|
+
Metrics.SEQUENCER_CHECKPOINT_PRECHECK_FAILED_COUNT,
|
|
108
129
|
{
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
130
|
+
[Attributes.ERROR_TYPE]: [
|
|
131
|
+
'slot_already_taken',
|
|
132
|
+
'rollup_contract_check_failed',
|
|
133
|
+
'slot_mismatch',
|
|
134
|
+
'block_number_mismatch',
|
|
135
|
+
],
|
|
112
136
|
},
|
|
113
137
|
);
|
|
114
138
|
|
|
115
|
-
this.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
139
|
+
this.checkpointProposalFailed = createUpDownCounterWithDefault(
|
|
140
|
+
this.meter,
|
|
141
|
+
Metrics.SEQUENCER_CHECKPOINT_PROPOSAL_FAILED_COUNT,
|
|
142
|
+
);
|
|
119
143
|
|
|
120
|
-
this.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
144
|
+
this.slashingAttempts = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLASHING_ATTEMPTS_COUNT);
|
|
145
|
+
|
|
146
|
+
this.pipelineDepth = this.meter.createGauge(Metrics.SEQUENCER_PIPELINE_DEPTH);
|
|
147
|
+
this.pipelineDiscards = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_PIPELINE_DISCARDS_COUNT);
|
|
148
|
+
this.pipelineParentCheckpointMismatches = createUpDownCounterWithDefault(
|
|
149
|
+
this.meter,
|
|
150
|
+
Metrics.SEQUENCER_PIPELINE_PARENT_CHECKPOINT_MISMATCH_COUNT,
|
|
151
|
+
{
|
|
152
|
+
[Attributes.ERROR_TYPE]: [
|
|
153
|
+
'archiver-sync-timeout',
|
|
154
|
+
'parent-not-on-l1',
|
|
155
|
+
'parent-hash-mismatch',
|
|
156
|
+
'parent-invalid-attestations',
|
|
157
|
+
'unexpected-parent-appeared',
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
);
|
|
161
|
+
this.pipelineDepth.record(0);
|
|
162
|
+
|
|
163
|
+
// Fisherman fee analysis metrics
|
|
164
|
+
this.fishermanWouldBeIncluded = createUpDownCounterWithDefault(
|
|
165
|
+
this.meter,
|
|
166
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_WOULD_BE_INCLUDED,
|
|
167
|
+
{
|
|
168
|
+
[Attributes.OK]: [true, false],
|
|
169
|
+
[Attributes.BLOCK_FULL]: ['true', 'false'],
|
|
170
|
+
},
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
this.fishermanTimeBeforeBlock = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_TIME_BEFORE_BLOCK);
|
|
174
|
+
|
|
175
|
+
this.fishermanPendingBlobTxCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PENDING_BLOB_TX_COUNT);
|
|
176
|
+
|
|
177
|
+
this.fishermanIncludedBlobTxCount = this.meter.createHistogram(
|
|
178
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_INCLUDED_BLOB_TX_COUNT,
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
this.fishermanCalculatedPriorityFee = this.meter.createHistogram(
|
|
182
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_CALCULATED_PRIORITY_FEE,
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
this.fishermanPriorityFeeDelta = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PRIORITY_FEE_DELTA);
|
|
186
|
+
|
|
187
|
+
this.fishermanEstimatedCost = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_ESTIMATED_COST);
|
|
188
|
+
|
|
189
|
+
this.fishermanEstimatedOverpayment = this.meter.createHistogram(
|
|
190
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_ESTIMATED_OVERPAYMENT,
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
this.fishermanMinedBlobTxPriorityFee = this.meter.createHistogram(
|
|
194
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_MINED_BLOB_TX_PRIORITY_FEE,
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
this.fishermanMinedBlobTxTotalCost = this.meter.createHistogram(
|
|
198
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_MINED_BLOB_TX_TOTAL_COST,
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
this.fishermanPendingBlobCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PENDING_BLOB_COUNT);
|
|
202
|
+
|
|
203
|
+
this.fishermanIncludedBlobCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_INCLUDED_BLOB_COUNT);
|
|
204
|
+
|
|
205
|
+
this.fishermanBlockBlobsFull = createUpDownCounterWithDefault(
|
|
206
|
+
this.meter,
|
|
207
|
+
Metrics.FISHERMAN_FEE_ANALYSIS_BLOCK_BLOBS_FULL,
|
|
208
|
+
{
|
|
209
|
+
[Attributes.OK]: [true, false],
|
|
210
|
+
},
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
this.fishermanMaxBlobCapacity = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_MAX_BLOB_CAPACITY);
|
|
124
214
|
}
|
|
125
215
|
|
|
126
216
|
public recordRequiredAttestations(requiredAttestationsCount: number, allowanceMs: number) {
|
|
@@ -137,12 +227,20 @@ export class SequencerMetrics {
|
|
|
137
227
|
this.timeToCollectAttestations.record(Math.ceil(durationMs));
|
|
138
228
|
}
|
|
139
229
|
|
|
140
|
-
recordBuiltBlock(buildDurationMs: number, totalMana: number) {
|
|
230
|
+
recordBuiltBlock(buildDurationMs: number, totalMana: number, slot: SlotNumber) {
|
|
141
231
|
this.blockCounter.add(1, {
|
|
142
232
|
[Attributes.STATUS]: 'built',
|
|
143
233
|
});
|
|
144
234
|
this.blockBuildDuration.record(Math.ceil(buildDurationMs));
|
|
145
235
|
this.blockBuildManaPerSecond.record(Math.ceil((totalMana * 1000) / buildDurationMs));
|
|
236
|
+
|
|
237
|
+
// Only record inter-block time between blocks built within the same slot.
|
|
238
|
+
const now = Date.now();
|
|
239
|
+
if (this.lastBlockBuiltTimestamp !== undefined && this.lastBlockBuiltSlot === slot) {
|
|
240
|
+
this.blockInterBlockTime.record(now - this.lastBlockBuiltTimestamp);
|
|
241
|
+
}
|
|
242
|
+
this.lastBlockBuiltTimestamp = now;
|
|
243
|
+
this.lastBlockBuiltSlot = slot;
|
|
146
244
|
}
|
|
147
245
|
|
|
148
246
|
recordFailedBlock() {
|
|
@@ -157,7 +255,27 @@ export class SequencerMetrics {
|
|
|
157
255
|
});
|
|
158
256
|
}
|
|
159
257
|
|
|
160
|
-
|
|
258
|
+
recordStateDuration(durationMs: number, state: SequencerState) {
|
|
259
|
+
this.stateDuration.record(Math.ceil(durationMs), {
|
|
260
|
+
[Attributes.SEQUENCER_STATE]: state,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
recordPipelineDepth(depth: number) {
|
|
265
|
+
this.pipelineDepth.record(depth);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
recordPipelineDiscard(count = 1) {
|
|
269
|
+
this.pipelineDiscards.add(count);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
recordPipelineParentCheckpointMismatch(reason: string) {
|
|
273
|
+
this.pipelineParentCheckpointMismatches.add(1, {
|
|
274
|
+
[Attributes.ERROR_TYPE]: reason,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
incOpenSlot(slot: SlotNumber, proposer: string) {
|
|
161
279
|
// sequencer went through the loop a second time. Noop
|
|
162
280
|
if (slot === this.lastSeenSlot) {
|
|
163
281
|
return;
|
|
@@ -188,4 +306,154 @@ export class SequencerMetrics {
|
|
|
188
306
|
}
|
|
189
307
|
}
|
|
190
308
|
}
|
|
309
|
+
|
|
310
|
+
recordCheckpointSuccess() {
|
|
311
|
+
this.checkpointSuccess.add(1);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
recordBlockProposalFailed(reason?: string) {
|
|
315
|
+
this.blockProposalFailed.add(1, {
|
|
316
|
+
...(reason && { [Attributes.ERROR_TYPE]: reason }),
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
recordCheckpointProposalSuccess() {
|
|
321
|
+
this.checkpointProposalSuccess.add(1);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
recordCheckpointPrecheckFailed(
|
|
325
|
+
checkType: 'slot_already_taken' | 'rollup_contract_check_failed' | 'slot_mismatch' | 'block_number_mismatch',
|
|
326
|
+
) {
|
|
327
|
+
this.checkpointPrecheckFailed.add(1, { [Attributes.ERROR_TYPE]: checkType });
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
recordCheckpointProposalFailed(reason?: string) {
|
|
331
|
+
this.checkpointProposalFailed.add(1, {
|
|
332
|
+
...(reason && { [Attributes.ERROR_TYPE]: reason }),
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
recordSlashingAttempt(actionCount: number) {
|
|
337
|
+
this.slashingAttempts.add(actionCount);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Records metrics for a completed fisherman fee analysis
|
|
342
|
+
* @param analysis - The completed fee analysis result
|
|
343
|
+
*/
|
|
344
|
+
recordFishermanFeeAnalysis(analysis: L1FeeAnalysisResult) {
|
|
345
|
+
// In fisherman mode, we should always have strategy results
|
|
346
|
+
if (!analysis.computedPrices.strategyResults || analysis.computedPrices.strategyResults.length === 0) {
|
|
347
|
+
// This should never happen in fisherman mode - log an error
|
|
348
|
+
// We don't record metrics without strategy IDs as that defeats the purpose
|
|
349
|
+
throw new Error(
|
|
350
|
+
`No strategy results found in fisherman fee analysis ${analysis.id}. This indicates a bug in the fee analysis.`,
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// Record metrics for each strategy separately
|
|
355
|
+
for (const strategyResult of analysis.computedPrices.strategyResults) {
|
|
356
|
+
const strategyAttributes = {
|
|
357
|
+
[Attributes.FISHERMAN_FEE_STRATEGY_ID]: strategyResult.strategyId,
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
// Record pending block snapshot data (once per strategy for comparison)
|
|
361
|
+
this.fishermanPendingBlobTxCount.record(analysis.pendingSnapshot.pendingBlobTxCount, strategyAttributes);
|
|
362
|
+
this.fishermanPendingBlobCount.record(analysis.pendingSnapshot.pendingBlobCount, strategyAttributes);
|
|
363
|
+
|
|
364
|
+
// Record mined block data if available
|
|
365
|
+
if (analysis.minedBlock) {
|
|
366
|
+
this.fishermanIncludedBlobTxCount.record(analysis.minedBlock.includedBlobTxCount, strategyAttributes);
|
|
367
|
+
this.fishermanIncludedBlobCount.record(analysis.minedBlock.includedBlobCount, strategyAttributes);
|
|
368
|
+
|
|
369
|
+
// Record actual fees from blob transactions in the mined block
|
|
370
|
+
for (const blobTx of analysis.minedBlock.includedBlobTxs) {
|
|
371
|
+
// Record priority fee per gas in Gwei
|
|
372
|
+
const priorityFeeGwei = Number(blobTx.maxPriorityFeePerGas) / 1e9;
|
|
373
|
+
this.fishermanMinedBlobTxPriorityFee.record(priorityFeeGwei, strategyAttributes);
|
|
374
|
+
|
|
375
|
+
// Calculate total cost in ETH
|
|
376
|
+
// Cost = (gas * (baseFee + priorityFee)) + (blobCount * blobGasPerBlob * blobBaseFee)
|
|
377
|
+
const baseFee = analysis.minedBlock.baseFeePerGas;
|
|
378
|
+
const effectiveGasPrice = baseFee + blobTx.maxPriorityFeePerGas;
|
|
379
|
+
|
|
380
|
+
// Calculate execution cost using actual gas limit from the transaction
|
|
381
|
+
const executionCost = blobTx.gas * effectiveGasPrice;
|
|
382
|
+
|
|
383
|
+
// Calculate blob cost using maxFeePerBlobGas * blobCount * GAS_PER_BLOB
|
|
384
|
+
const blobCost = blobTx.maxFeePerBlobGas * BigInt(blobTx.blobCount) * 131072n; // 128KB per blob
|
|
385
|
+
|
|
386
|
+
const totalCostWei = executionCost + blobCost;
|
|
387
|
+
const totalCostEth = Number(totalCostWei) / 1e18;
|
|
388
|
+
|
|
389
|
+
this.fishermanMinedBlobTxTotalCost.record(totalCostEth, strategyAttributes);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// Record the calculated priority fee for this strategy
|
|
394
|
+
const calculatedPriorityFeeGwei = Number(strategyResult.calculatedPriorityFee) / 1e9;
|
|
395
|
+
this.fishermanCalculatedPriorityFee.record(calculatedPriorityFeeGwei, strategyAttributes);
|
|
396
|
+
|
|
397
|
+
// Record analysis results if available
|
|
398
|
+
if (analysis.analysis) {
|
|
399
|
+
this.fishermanTimeBeforeBlock.record(Math.ceil(analysis.analysis.timeBeforeBlockMs), strategyAttributes);
|
|
400
|
+
|
|
401
|
+
// Record whether the block reached 100% blob capacity
|
|
402
|
+
if (analysis.analysis.blockBlobsFull) {
|
|
403
|
+
this.fishermanBlockBlobsFull.add(1, { ...strategyAttributes, [Attributes.OK]: true });
|
|
404
|
+
} else {
|
|
405
|
+
this.fishermanBlockBlobsFull.add(1, { ...strategyAttributes, [Attributes.OK]: false });
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Record the max blob capacity for this block
|
|
409
|
+
this.fishermanMaxBlobCapacity.record(analysis.analysis.maxBlobCapacity, strategyAttributes);
|
|
410
|
+
|
|
411
|
+
// Record strategy-specific inclusion result
|
|
412
|
+
if (strategyResult.wouldBeIncluded !== undefined) {
|
|
413
|
+
const inclusionAttributes = {
|
|
414
|
+
...strategyAttributes,
|
|
415
|
+
[Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false',
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
if (strategyResult.wouldBeIncluded) {
|
|
419
|
+
this.fishermanWouldBeIncluded.add(1, { ...inclusionAttributes, [Attributes.OK]: true });
|
|
420
|
+
} else {
|
|
421
|
+
this.fishermanWouldBeIncluded.add(1, {
|
|
422
|
+
...inclusionAttributes,
|
|
423
|
+
[Attributes.OK]: false,
|
|
424
|
+
...(strategyResult.exclusionReason && { [Attributes.ERROR_TYPE]: strategyResult.exclusionReason }),
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// Record strategy-specific priority fee delta
|
|
430
|
+
if (strategyResult.priorityFeeDelta !== undefined) {
|
|
431
|
+
const priorityFeeDeltaGwei = Number(strategyResult.priorityFeeDelta) / 1e9;
|
|
432
|
+
const deltaAttributes = {
|
|
433
|
+
...strategyAttributes,
|
|
434
|
+
[Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false',
|
|
435
|
+
};
|
|
436
|
+
this.fishermanPriorityFeeDelta.record(priorityFeeDeltaGwei, deltaAttributes);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// Record estimated cost if available
|
|
440
|
+
if (strategyResult.estimatedCostEth !== undefined) {
|
|
441
|
+
const costAttributes = {
|
|
442
|
+
...strategyAttributes,
|
|
443
|
+
[Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false',
|
|
444
|
+
};
|
|
445
|
+
this.fishermanEstimatedCost.record(strategyResult.estimatedCostEth, costAttributes);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// Record estimated overpayment if available
|
|
449
|
+
if (strategyResult.estimatedOverpaymentEth !== undefined) {
|
|
450
|
+
const overpaymentAttributes = {
|
|
451
|
+
...strategyAttributes,
|
|
452
|
+
[Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false',
|
|
453
|
+
};
|
|
454
|
+
this.fishermanEstimatedOverpayment.record(strategyResult.estimatedOverpaymentEth, overpaymentAttributes);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
191
459
|
}
|