@aztec/sequencer-client 4.0.0-nightly.20250907 → 4.0.0-nightly.20260107
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 +10 -8
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +40 -28
- package/dest/config.d.ts +13 -5
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +82 -25
- package/dest/global_variable_builder/global_builder.d.ts +19 -13
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +41 -28
- package/dest/global_variable_builder/index.d.ts +1 -1
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/publisher/config.d.ts +11 -8
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +21 -13
- package/dest/publisher/index.d.ts +2 -2
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/index.js +1 -1
- package/dest/publisher/sequencer-publisher-factory.d.ts +11 -5
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +9 -2
- package/dest/publisher/sequencer-publisher-metrics.d.ts +4 -4
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +1 -1
- package/dest/publisher/sequencer-publisher.d.ts +76 -69
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +290 -180
- package/dest/sequencer/block_builder.d.ts +6 -10
- package/dest/sequencer/block_builder.d.ts.map +1 -1
- package/dest/sequencer/block_builder.js +21 -10
- package/dest/sequencer/checkpoint_builder.d.ts +63 -0
- package/dest/sequencer/checkpoint_builder.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_builder.js +131 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts +74 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job.js +642 -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 +85 -0
- package/dest/sequencer/config.d.ts +3 -2
- 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 +5 -1
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +4 -0
- package/dest/sequencer/metrics.d.ts +37 -20
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +211 -85
- package/dest/sequencer/sequencer.d.ts +109 -121
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +798 -525
- package/dest/sequencer/timetable.d.ts +57 -21
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +150 -68
- 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 -28
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +12 -24
- package/dest/test/index.d.ts +4 -2
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +83 -0
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
- package/dest/test/mock_checkpoint_builder.js +179 -0
- package/dest/test/utils.d.ts +49 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +94 -0
- package/dest/tx_validator/nullifier_cache.d.ts +1 -1
- package/dest/tx_validator/nullifier_cache.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.d.ts +4 -3
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.js +12 -9
- package/package.json +32 -31
- package/src/client/sequencer-client.ts +34 -40
- package/src/config.ts +89 -29
- package/src/global_variable_builder/global_builder.ts +56 -48
- package/src/index.ts +2 -0
- package/src/publisher/config.ts +32 -19
- package/src/publisher/index.ts +1 -1
- package/src/publisher/sequencer-publisher-factory.ts +19 -6
- package/src/publisher/sequencer-publisher-metrics.ts +3 -3
- package/src/publisher/sequencer-publisher.ts +410 -240
- package/src/sequencer/README.md +531 -0
- package/src/sequencer/block_builder.ts +28 -30
- package/src/sequencer/checkpoint_builder.ts +217 -0
- package/src/sequencer/checkpoint_proposal_job.ts +706 -0
- package/src/sequencer/checkpoint_voter.ts +105 -0
- package/src/sequencer/config.ts +2 -1
- package/src/sequencer/errors.ts +21 -0
- package/src/sequencer/events.ts +27 -0
- package/src/sequencer/index.ts +4 -0
- package/src/sequencer/metrics.ts +269 -94
- package/src/sequencer/sequencer.ts +506 -676
- package/src/sequencer/timetable.ts +181 -91
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +24 -29
- package/src/test/index.ts +3 -1
- package/src/test/mock_checkpoint_builder.ts +247 -0
- package/src/test/utils.ts +137 -0
- package/src/tx_validator/tx_validator_factory.ts +13 -7
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Attributes, Metrics, ValueType } from '@aztec/telemetry-client';
|
|
2
2
|
import { formatUnits } from 'viem';
|
|
3
|
-
|
|
3
|
+
// TODO(palla/mbps): Review all metrics and add any missing ones per checkpoint
|
|
4
4
|
export class SequencerMetrics {
|
|
5
|
-
coinbase;
|
|
6
5
|
rollup;
|
|
7
6
|
tracer;
|
|
8
7
|
meter;
|
|
@@ -10,9 +9,6 @@ export class SequencerMetrics {
|
|
|
10
9
|
blockBuildDuration;
|
|
11
10
|
blockBuildManaPerSecond;
|
|
12
11
|
stateTransitionBufferDuration;
|
|
13
|
-
currentBlockNumber;
|
|
14
|
-
currentBlockSize;
|
|
15
|
-
blockBuilderInsertions;
|
|
16
12
|
// these are gauges because for individual sequencers building a block is not something that happens often enough to warrant a histogram
|
|
17
13
|
timeToCollectAttestations;
|
|
18
14
|
allowanceToCollectAttestations;
|
|
@@ -21,19 +17,26 @@ export class SequencerMetrics {
|
|
|
21
17
|
rewards;
|
|
22
18
|
slots;
|
|
23
19
|
filledSlots;
|
|
24
|
-
|
|
20
|
+
blockProposalFailed;
|
|
21
|
+
blockProposalSuccess;
|
|
22
|
+
blockProposalPrecheckFailed;
|
|
23
|
+
checkpointSuccess;
|
|
24
|
+
slashingAttempts;
|
|
25
|
+
blockAttestationDelay;
|
|
26
|
+
// Fisherman fee analysis metrics
|
|
27
|
+
fishermanWouldBeIncluded;
|
|
28
|
+
fishermanTimeBeforeBlock;
|
|
29
|
+
fishermanPendingBlobTxCount;
|
|
30
|
+
fishermanIncludedBlobTxCount;
|
|
31
|
+
fishermanCalculatedPriorityFee;
|
|
32
|
+
fishermanPriorityFeeDelta;
|
|
33
|
+
fishermanEstimatedCost;
|
|
34
|
+
fishermanEstimatedOverpayment;
|
|
35
|
+
fishermanMinedBlobTxPriorityFee;
|
|
36
|
+
fishermanMinedBlobTxTotalCost;
|
|
25
37
|
lastSeenSlot;
|
|
26
|
-
constructor(client,
|
|
27
|
-
this.coinbase = coinbase;
|
|
38
|
+
constructor(client, rollup, name = 'Sequencer'){
|
|
28
39
|
this.rollup = rollup;
|
|
29
|
-
this.observe = async (observer)=>{
|
|
30
|
-
let rewards = 0n;
|
|
31
|
-
rewards = await this.rollup.getSequencerRewards(this.coinbase);
|
|
32
|
-
const fmt = parseFloat(formatUnits(rewards, 18));
|
|
33
|
-
observer.observe(this.rewards, fmt, {
|
|
34
|
-
[Attributes.COINBASE]: this.coinbase.toString()
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
40
|
this.meter = client.getMeter(name);
|
|
38
41
|
this.tracer = client.getTracer(name);
|
|
39
42
|
this.blockCounter = this.meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_COUNT);
|
|
@@ -52,37 +55,19 @@ export class SequencerMetrics {
|
|
|
52
55
|
description: 'The time difference between when the sequencer needed to transition to a new state and when it actually did.',
|
|
53
56
|
valueType: ValueType.INT
|
|
54
57
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
currentState.addCallback((observer)=>{
|
|
59
|
-
observer.observe(sequencerStateToNumber(getState()));
|
|
60
|
-
});
|
|
61
|
-
this.currentBlockNumber = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_NUMBER, {
|
|
62
|
-
description: 'Current block number',
|
|
63
|
-
valueType: ValueType.INT
|
|
64
|
-
});
|
|
65
|
-
this.currentBlockSize = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_SIZE, {
|
|
66
|
-
description: 'Current block size',
|
|
67
|
-
valueType: ValueType.INT
|
|
68
|
-
});
|
|
69
|
-
this.blockBuilderInsertions = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_INSERTION_TIME, {
|
|
70
|
-
description: 'Timer for tree insertions performed by the block builder',
|
|
71
|
-
unit: 'us',
|
|
58
|
+
this.blockAttestationDelay = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_ATTESTATION_DELAY, {
|
|
59
|
+
unit: 'ms',
|
|
60
|
+
description: 'The time difference between block proposal and minimal attestation count reached,',
|
|
72
61
|
valueType: ValueType.INT
|
|
73
62
|
});
|
|
74
63
|
// Init gauges and counters
|
|
75
|
-
this.setCurrentBlock(0, 0);
|
|
76
|
-
this.blockCounter.add(0, {
|
|
77
|
-
[Attributes.STATUS]: 'cancelled'
|
|
78
|
-
});
|
|
79
64
|
this.blockCounter.add(0, {
|
|
80
65
|
[Attributes.STATUS]: 'failed'
|
|
81
66
|
});
|
|
82
67
|
this.blockCounter.add(0, {
|
|
83
68
|
[Attributes.STATUS]: 'built'
|
|
84
69
|
});
|
|
85
|
-
this.rewards = this.meter.
|
|
70
|
+
this.rewards = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_REWARDS, {
|
|
86
71
|
valueType: ValueType.DOUBLE,
|
|
87
72
|
description: 'The rewards earned'
|
|
88
73
|
});
|
|
@@ -90,14 +75,13 @@ export class SequencerMetrics {
|
|
|
90
75
|
valueType: ValueType.INT,
|
|
91
76
|
description: 'The number of slots this sequencer was selected for'
|
|
92
77
|
});
|
|
93
|
-
|
|
78
|
+
/**
|
|
79
|
+
* NOTE: we do not track missed slots as a separate metric. That would be difficult to determine
|
|
80
|
+
* Instead, use a computed metric, `slots - filledSlots` to get the number of slots a sequencer has missed.
|
|
81
|
+
*/ this.filledSlots = this.meter.createUpDownCounter(Metrics.SEQUENCER_FILLED_SLOT_COUNT, {
|
|
94
82
|
valueType: ValueType.INT,
|
|
95
83
|
description: 'The number of slots this sequencer has filled'
|
|
96
84
|
});
|
|
97
|
-
this.missedSlots = this.meter.createUpDownCounter(Metrics.SEQUENCER_MISSED_SLOT_COUNT, {
|
|
98
|
-
valueType: ValueType.INT,
|
|
99
|
-
description: 'The number of slots this sequencer has missed to fill'
|
|
100
|
-
});
|
|
101
85
|
this.timeToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_DURATION, {
|
|
102
86
|
description: 'The time spent collecting attestations from committee members',
|
|
103
87
|
unit: 'ms',
|
|
@@ -116,21 +100,75 @@ export class SequencerMetrics {
|
|
|
116
100
|
valueType: ValueType.INT,
|
|
117
101
|
description: 'The minimum number of attestations required to publish a block'
|
|
118
102
|
});
|
|
103
|
+
this.blockProposalFailed = this.meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_PROPOSAL_FAILED_COUNT, {
|
|
104
|
+
valueType: ValueType.INT,
|
|
105
|
+
description: 'The number of times block proposal failed (including validation builds)'
|
|
106
|
+
});
|
|
107
|
+
this.blockProposalSuccess = this.meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_PROPOSAL_SUCCESS_COUNT, {
|
|
108
|
+
valueType: ValueType.INT,
|
|
109
|
+
description: 'The number of times block proposal succeeded (including validation builds)'
|
|
110
|
+
});
|
|
111
|
+
this.checkpointSuccess = this.meter.createUpDownCounter(Metrics.SEQUENCER_CHECKPOINT_SUCCESS_COUNT, {
|
|
112
|
+
valueType: ValueType.INT,
|
|
113
|
+
description: 'The number of times checkpoint publishing succeeded'
|
|
114
|
+
});
|
|
115
|
+
this.blockProposalPrecheckFailed = this.meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_PROPOSAL_PRECHECK_FAILED_COUNT, {
|
|
116
|
+
valueType: ValueType.INT,
|
|
117
|
+
description: 'The number of times block proposal pre-build checks failed'
|
|
118
|
+
});
|
|
119
|
+
this.slashingAttempts = this.meter.createUpDownCounter(Metrics.SEQUENCER_SLASHING_ATTEMPTS_COUNT, {
|
|
120
|
+
valueType: ValueType.INT,
|
|
121
|
+
description: 'The number of slashing action attempts'
|
|
122
|
+
});
|
|
123
|
+
// Fisherman fee analysis metrics
|
|
124
|
+
this.fishermanWouldBeIncluded = this.meter.createUpDownCounter(Metrics.FISHERMAN_FEE_ANALYSIS_WOULD_BE_INCLUDED, {
|
|
125
|
+
valueType: ValueType.INT,
|
|
126
|
+
description: 'Whether the transaction would have been included in the block'
|
|
127
|
+
});
|
|
128
|
+
this.fishermanTimeBeforeBlock = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_TIME_BEFORE_BLOCK, {
|
|
129
|
+
unit: 'ms',
|
|
130
|
+
description: 'Time in ms between fee analysis and block being mined',
|
|
131
|
+
valueType: ValueType.INT
|
|
132
|
+
});
|
|
133
|
+
this.fishermanPendingBlobTxCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PENDING_BLOB_TX_COUNT, {
|
|
134
|
+
description: 'Number of blob transactions seen in the pending block',
|
|
135
|
+
valueType: ValueType.INT
|
|
136
|
+
});
|
|
137
|
+
this.fishermanIncludedBlobTxCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_INCLUDED_BLOB_TX_COUNT, {
|
|
138
|
+
description: 'Number of blob transactions that got included in the mined block',
|
|
139
|
+
valueType: ValueType.INT
|
|
140
|
+
});
|
|
141
|
+
this.fishermanCalculatedPriorityFee = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_CALCULATED_PRIORITY_FEE, {
|
|
142
|
+
unit: 'gwei',
|
|
143
|
+
description: 'Priority fee calculated by each strategy',
|
|
144
|
+
valueType: ValueType.DOUBLE
|
|
145
|
+
});
|
|
146
|
+
this.fishermanPriorityFeeDelta = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PRIORITY_FEE_DELTA, {
|
|
147
|
+
unit: 'gwei',
|
|
148
|
+
description: 'Difference between our priority fee and minimum included priority fee',
|
|
149
|
+
valueType: ValueType.DOUBLE
|
|
150
|
+
});
|
|
151
|
+
this.fishermanEstimatedCost = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_ESTIMATED_COST, {
|
|
152
|
+
unit: 'eth',
|
|
153
|
+
description: 'Estimated total cost in ETH for the transaction with this strategy',
|
|
154
|
+
valueType: ValueType.DOUBLE
|
|
155
|
+
});
|
|
156
|
+
this.fishermanEstimatedOverpayment = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_ESTIMATED_OVERPAYMENT, {
|
|
157
|
+
unit: 'eth',
|
|
158
|
+
description: 'Estimated overpayment in ETH vs minimum required for inclusion',
|
|
159
|
+
valueType: ValueType.DOUBLE
|
|
160
|
+
});
|
|
161
|
+
this.fishermanMinedBlobTxPriorityFee = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_MINED_BLOB_TX_PRIORITY_FEE, {
|
|
162
|
+
unit: 'gwei',
|
|
163
|
+
description: 'Priority fee per gas for blob transactions in mined blocks',
|
|
164
|
+
valueType: ValueType.DOUBLE
|
|
165
|
+
});
|
|
166
|
+
this.fishermanMinedBlobTxTotalCost = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_MINED_BLOB_TX_TOTAL_COST, {
|
|
167
|
+
unit: 'eth',
|
|
168
|
+
description: 'Total cost in ETH for blob transactions in mined blocks',
|
|
169
|
+
valueType: ValueType.DOUBLE
|
|
170
|
+
});
|
|
119
171
|
}
|
|
120
|
-
setCoinbase(coinbase) {
|
|
121
|
-
this.coinbase = coinbase;
|
|
122
|
-
}
|
|
123
|
-
start() {
|
|
124
|
-
this.meter.addBatchObservableCallback(this.observe, [
|
|
125
|
-
this.rewards
|
|
126
|
-
]);
|
|
127
|
-
}
|
|
128
|
-
stop() {
|
|
129
|
-
this.meter.removeBatchObservableCallback(this.observe, [
|
|
130
|
-
this.rewards
|
|
131
|
-
]);
|
|
132
|
-
}
|
|
133
|
-
observe;
|
|
134
172
|
recordRequiredAttestations(requiredAttestationsCount, allowanceMs) {
|
|
135
173
|
this.requiredAttestions.record(requiredAttestationsCount);
|
|
136
174
|
this.allowanceToCollectAttestations.record(Math.ceil(allowanceMs));
|
|
@@ -138,19 +176,13 @@ export class SequencerMetrics {
|
|
|
138
176
|
this.collectedAttestions.record(0);
|
|
139
177
|
this.timeToCollectAttestations.record(0);
|
|
140
178
|
}
|
|
179
|
+
recordBlockAttestationDelay(duration) {
|
|
180
|
+
this.blockAttestationDelay.record(duration);
|
|
181
|
+
}
|
|
141
182
|
recordCollectedAttestations(count, durationMs) {
|
|
142
183
|
this.collectedAttestions.record(count);
|
|
143
184
|
this.timeToCollectAttestations.record(Math.ceil(durationMs));
|
|
144
185
|
}
|
|
145
|
-
recordBlockBuilderTreeInsertions(timeUs) {
|
|
146
|
-
this.blockBuilderInsertions.record(Math.ceil(timeUs));
|
|
147
|
-
}
|
|
148
|
-
recordCancelledBlock() {
|
|
149
|
-
this.blockCounter.add(1, {
|
|
150
|
-
[Attributes.STATUS]: 'cancelled'
|
|
151
|
-
});
|
|
152
|
-
this.setCurrentBlock(0, 0);
|
|
153
|
-
}
|
|
154
186
|
recordBuiltBlock(buildDurationMs, totalMana) {
|
|
155
187
|
this.blockCounter.add(1, {
|
|
156
188
|
[Attributes.STATUS]: 'built'
|
|
@@ -162,41 +194,135 @@ export class SequencerMetrics {
|
|
|
162
194
|
this.blockCounter.add(1, {
|
|
163
195
|
[Attributes.STATUS]: 'failed'
|
|
164
196
|
});
|
|
165
|
-
this.setCurrentBlock(0, 0);
|
|
166
|
-
}
|
|
167
|
-
recordNewBlock(blockNumber, txCount) {
|
|
168
|
-
this.setCurrentBlock(blockNumber, txCount);
|
|
169
197
|
}
|
|
170
198
|
recordStateTransitionBufferMs(durationMs, state) {
|
|
171
199
|
this.stateTransitionBufferDuration.record(durationMs, {
|
|
172
200
|
[Attributes.SEQUENCER_STATE]: state
|
|
173
201
|
});
|
|
174
202
|
}
|
|
175
|
-
|
|
203
|
+
incOpenSlot(slot, proposer) {
|
|
176
204
|
// sequencer went through the loop a second time. Noop
|
|
177
205
|
if (slot === this.lastSeenSlot) {
|
|
178
206
|
return;
|
|
179
207
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
if (typeof slot === 'bigint') {
|
|
186
|
-
this.slots.add(1, {
|
|
187
|
-
[Attributes.BLOCK_PROPOSER]: proposer
|
|
188
|
-
});
|
|
189
|
-
}
|
|
208
|
+
this.slots.add(1, {
|
|
209
|
+
[Attributes.BLOCK_PROPOSER]: proposer
|
|
210
|
+
});
|
|
190
211
|
this.lastSeenSlot = slot;
|
|
191
212
|
}
|
|
192
|
-
incFilledSlot(proposer) {
|
|
213
|
+
async incFilledSlot(proposer, coinbase) {
|
|
193
214
|
this.filledSlots.add(1, {
|
|
194
215
|
[Attributes.BLOCK_PROPOSER]: proposer
|
|
195
216
|
});
|
|
196
217
|
this.lastSeenSlot = undefined;
|
|
218
|
+
if (coinbase) {
|
|
219
|
+
try {
|
|
220
|
+
const rewards = await this.rollup.getSequencerRewards(coinbase);
|
|
221
|
+
const fmt = parseFloat(formatUnits(rewards, 18));
|
|
222
|
+
this.rewards.record(fmt, {
|
|
223
|
+
[Attributes.COINBASE]: coinbase.toString()
|
|
224
|
+
});
|
|
225
|
+
} catch {
|
|
226
|
+
// no-op
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
recordCheckpointSuccess() {
|
|
231
|
+
this.checkpointSuccess.add(1);
|
|
232
|
+
}
|
|
233
|
+
recordBlockProposalFailed(reason) {
|
|
234
|
+
this.blockProposalFailed.add(1, {
|
|
235
|
+
...reason && {
|
|
236
|
+
[Attributes.ERROR_TYPE]: reason
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
recordBlockProposalSuccess() {
|
|
241
|
+
this.blockProposalSuccess.add(1);
|
|
242
|
+
}
|
|
243
|
+
recordBlockProposalPrecheckFailed(checkType) {
|
|
244
|
+
this.blockProposalPrecheckFailed.add(1, {
|
|
245
|
+
[Attributes.ERROR_TYPE]: checkType
|
|
246
|
+
});
|
|
197
247
|
}
|
|
198
|
-
|
|
199
|
-
this.
|
|
200
|
-
|
|
248
|
+
recordSlashingAttempt(actionCount) {
|
|
249
|
+
this.slashingAttempts.add(actionCount);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Records metrics for a completed fisherman fee analysis
|
|
253
|
+
* @param analysis - The completed fee analysis result
|
|
254
|
+
*/ recordFishermanFeeAnalysis(analysis) {
|
|
255
|
+
// In fisherman mode, we should always have strategy results
|
|
256
|
+
if (!analysis.computedPrices.strategyResults || analysis.computedPrices.strategyResults.length === 0) {
|
|
257
|
+
// This should never happen in fisherman mode - log an error
|
|
258
|
+
// We don't record metrics without strategy IDs as that defeats the purpose
|
|
259
|
+
throw new Error(`No strategy results found in fisherman fee analysis ${analysis.id}. This indicates a bug in the fee analysis.`);
|
|
260
|
+
}
|
|
261
|
+
// Record metrics for each strategy separately
|
|
262
|
+
for (const strategyResult of analysis.computedPrices.strategyResults){
|
|
263
|
+
const strategyAttributes = {
|
|
264
|
+
[Attributes.FISHERMAN_FEE_STRATEGY_ID]: strategyResult.strategyId
|
|
265
|
+
};
|
|
266
|
+
// Record pending block snapshot data (once per strategy for comparison)
|
|
267
|
+
this.fishermanPendingBlobTxCount.record(analysis.pendingSnapshot.pendingBlobTxCount, strategyAttributes);
|
|
268
|
+
// Record mined block data if available
|
|
269
|
+
if (analysis.minedBlock) {
|
|
270
|
+
this.fishermanIncludedBlobTxCount.record(analysis.minedBlock.includedBlobTxCount, strategyAttributes);
|
|
271
|
+
// Record actual fees from blob transactions in the mined block
|
|
272
|
+
for (const blobTx of analysis.minedBlock.includedBlobTxs){
|
|
273
|
+
// Record priority fee per gas in Gwei
|
|
274
|
+
const priorityFeeGwei = Number(blobTx.maxPriorityFeePerGas) / 1e9;
|
|
275
|
+
this.fishermanMinedBlobTxPriorityFee.record(priorityFeeGwei, strategyAttributes);
|
|
276
|
+
// Calculate total cost in ETH
|
|
277
|
+
// Cost = (gas * (baseFee + priorityFee)) + (blobCount * blobGasPerBlob * blobBaseFee)
|
|
278
|
+
const baseFee = analysis.minedBlock.baseFeePerGas;
|
|
279
|
+
const effectiveGasPrice = baseFee + blobTx.maxPriorityFeePerGas;
|
|
280
|
+
// Calculate execution cost using actual gas limit from the transaction
|
|
281
|
+
const executionCost = blobTx.gas * effectiveGasPrice;
|
|
282
|
+
// Calculate blob cost using maxFeePerBlobGas * blobCount * GAS_PER_BLOB
|
|
283
|
+
const blobCost = blobTx.maxFeePerBlobGas * BigInt(blobTx.blobCount) * 131072n; // 128KB per blob
|
|
284
|
+
const totalCostWei = executionCost + blobCost;
|
|
285
|
+
const totalCostEth = Number(totalCostWei) / 1e18;
|
|
286
|
+
this.fishermanMinedBlobTxTotalCost.record(totalCostEth, strategyAttributes);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
// Record the calculated priority fee for this strategy
|
|
290
|
+
const calculatedPriorityFeeGwei = Number(strategyResult.calculatedPriorityFee) / 1e9;
|
|
291
|
+
this.fishermanCalculatedPriorityFee.record(calculatedPriorityFeeGwei, strategyAttributes);
|
|
292
|
+
// Record analysis results if available
|
|
293
|
+
if (analysis.analysis) {
|
|
294
|
+
this.fishermanTimeBeforeBlock.record(Math.ceil(analysis.analysis.timeBeforeBlockMs), strategyAttributes);
|
|
295
|
+
// Record strategy-specific inclusion result
|
|
296
|
+
if (strategyResult.wouldBeIncluded !== undefined) {
|
|
297
|
+
if (strategyResult.wouldBeIncluded) {
|
|
298
|
+
this.fishermanWouldBeIncluded.add(1, {
|
|
299
|
+
...strategyAttributes,
|
|
300
|
+
[Attributes.OK]: true
|
|
301
|
+
});
|
|
302
|
+
} else {
|
|
303
|
+
this.fishermanWouldBeIncluded.add(1, {
|
|
304
|
+
...strategyAttributes,
|
|
305
|
+
[Attributes.OK]: false,
|
|
306
|
+
...strategyResult.exclusionReason && {
|
|
307
|
+
[Attributes.ERROR_TYPE]: strategyResult.exclusionReason
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
// Record strategy-specific priority fee delta
|
|
313
|
+
if (strategyResult.priorityFeeDelta !== undefined) {
|
|
314
|
+
const priorityFeeDeltaGwei = Number(strategyResult.priorityFeeDelta) / 1e9;
|
|
315
|
+
this.fishermanPriorityFeeDelta.record(priorityFeeDeltaGwei, strategyAttributes);
|
|
316
|
+
}
|
|
317
|
+
// Record estimated cost if available
|
|
318
|
+
if (strategyResult.estimatedCostEth !== undefined) {
|
|
319
|
+
this.fishermanEstimatedCost.record(strategyResult.estimatedCostEth, strategyAttributes);
|
|
320
|
+
}
|
|
321
|
+
// Record estimated overpayment if available
|
|
322
|
+
if (strategyResult.estimatedOverpaymentEth !== undefined) {
|
|
323
|
+
this.fishermanEstimatedOverpayment.record(strategyResult.estimatedOverpaymentEth, strategyAttributes);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
201
327
|
}
|
|
202
328
|
}
|