@aztec/sequencer-client 0.0.0-test.0 → 0.0.1-commit.03f7ef2
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 +30 -29
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +82 -60
- package/dest/config.d.ts +15 -16
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +113 -70
- package/dest/global_variable_builder/global_builder.d.ts +25 -14
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +60 -42
- package/dest/global_variable_builder/index.d.ts +1 -1
- 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 +15 -12
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +32 -19
- package/dest/publisher/index.d.ts +3 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/index.js +3 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +44 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -0
- package/dest/publisher/sequencer-publisher-factory.js +51 -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 +37 -2
- package/dest/publisher/sequencer-publisher.d.ts +132 -86
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +755 -248
- package/dest/sequencer/block_builder.d.ts +26 -0
- package/dest/sequencer/block_builder.d.ts.map +1 -0
- package/dest/sequencer/block_builder.js +129 -0
- 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 +640 -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 +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 +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 -12
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +274 -48
- package/dest/sequencer/sequencer.d.ts +132 -135
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +519 -521
- package/dest/sequencer/timetable.d.ts +76 -24
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +177 -61
- 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 +10 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +0 -4
- 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 -3
- package/dest/tx_validator/nullifier_cache.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.d.ts +11 -11
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.js +28 -25
- package/package.json +45 -45
- package/src/client/sequencer-client.ts +105 -105
- package/src/config.ts +126 -81
- package/src/global_variable_builder/global_builder.ts +82 -53
- package/src/index.ts +8 -2
- package/src/publisher/config.ts +45 -32
- package/src/publisher/index.ts +4 -0
- package/src/publisher/sequencer-publisher-factory.ts +92 -0
- package/src/publisher/sequencer-publisher-metrics.ts +26 -4
- package/src/publisher/sequencer-publisher.ts +955 -293
- package/src/sequencer/README.md +531 -0
- package/src/sequencer/block_builder.ts +217 -0
- package/src/sequencer/checkpoint_builder.ts +217 -0
- package/src/sequencer/checkpoint_proposal_job.ts +703 -0
- package/src/sequencer/checkpoint_voter.ts +105 -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 +5 -1
- package/src/sequencer/metrics.ts +355 -50
- package/src/sequencer/sequencer.ts +631 -594
- package/src/sequencer/timetable.ts +221 -62
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +28 -60
- package/src/test/index.ts +13 -4
- package/src/test/mock_checkpoint_builder.ts +247 -0
- package/src/test/utils.ts +137 -0
- package/src/tx_validator/tx_validator_factory.ts +46 -33
- 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/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/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/phases_validator.ts +0 -98
- package/src/tx_validator/test_utils.ts +0 -48
|
@@ -1,78 +1,187 @@
|
|
|
1
1
|
import { Attributes, Metrics, ValueType } from '@aztec/telemetry-client';
|
|
2
|
-
import {
|
|
2
|
+
import { formatUnits } from 'viem';
|
|
3
|
+
// TODO(palla/mbps): Review all metrics and add any missing ones per checkpoint
|
|
3
4
|
export class SequencerMetrics {
|
|
5
|
+
rollup;
|
|
4
6
|
tracer;
|
|
7
|
+
meter;
|
|
5
8
|
blockCounter;
|
|
6
9
|
blockBuildDuration;
|
|
7
10
|
blockBuildManaPerSecond;
|
|
8
11
|
stateTransitionBufferDuration;
|
|
9
|
-
|
|
10
|
-
currentBlockSize;
|
|
11
|
-
blockBuilderInsertions;
|
|
12
|
+
// these are gauges because for individual sequencers building a block is not something that happens often enough to warrant a histogram
|
|
12
13
|
timeToCollectAttestations;
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
allowanceToCollectAttestations;
|
|
15
|
+
requiredAttestions;
|
|
16
|
+
collectedAttestions;
|
|
17
|
+
rewards;
|
|
18
|
+
slots;
|
|
19
|
+
filledSlots;
|
|
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;
|
|
37
|
+
lastSeenSlot;
|
|
38
|
+
constructor(client, rollup, name = 'Sequencer'){
|
|
39
|
+
this.rollup = rollup;
|
|
40
|
+
this.meter = client.getMeter(name);
|
|
15
41
|
this.tracer = client.getTracer(name);
|
|
16
|
-
this.blockCounter = meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_COUNT);
|
|
17
|
-
this.blockBuildDuration = meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_DURATION, {
|
|
42
|
+
this.blockCounter = this.meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_COUNT);
|
|
43
|
+
this.blockBuildDuration = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_DURATION, {
|
|
18
44
|
unit: 'ms',
|
|
19
45
|
description: 'Duration to build a block',
|
|
20
46
|
valueType: ValueType.INT
|
|
21
47
|
});
|
|
22
|
-
this.blockBuildManaPerSecond = meter.createGauge(Metrics.SEQUENCER_BLOCK_BUILD_MANA_PER_SECOND, {
|
|
48
|
+
this.blockBuildManaPerSecond = this.meter.createGauge(Metrics.SEQUENCER_BLOCK_BUILD_MANA_PER_SECOND, {
|
|
23
49
|
unit: 'mana/s',
|
|
24
50
|
description: 'Mana per second when building a block',
|
|
25
51
|
valueType: ValueType.INT
|
|
26
52
|
});
|
|
27
|
-
this.stateTransitionBufferDuration = meter.createHistogram(Metrics.SEQUENCER_STATE_TRANSITION_BUFFER_DURATION, {
|
|
53
|
+
this.stateTransitionBufferDuration = this.meter.createHistogram(Metrics.SEQUENCER_STATE_TRANSITION_BUFFER_DURATION, {
|
|
28
54
|
unit: 'ms',
|
|
29
55
|
description: 'The time difference between when the sequencer needed to transition to a new state and when it actually did.',
|
|
30
56
|
valueType: ValueType.INT
|
|
31
57
|
});
|
|
32
|
-
|
|
33
|
-
|
|
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,',
|
|
61
|
+
valueType: ValueType.INT
|
|
62
|
+
});
|
|
63
|
+
// Init gauges and counters
|
|
64
|
+
this.blockCounter.add(0, {
|
|
65
|
+
[Attributes.STATUS]: 'failed'
|
|
66
|
+
});
|
|
67
|
+
this.blockCounter.add(0, {
|
|
68
|
+
[Attributes.STATUS]: 'built'
|
|
34
69
|
});
|
|
35
|
-
|
|
36
|
-
|
|
70
|
+
this.rewards = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_REWARDS, {
|
|
71
|
+
valueType: ValueType.DOUBLE,
|
|
72
|
+
description: 'The rewards earned'
|
|
37
73
|
});
|
|
38
|
-
this.
|
|
39
|
-
|
|
74
|
+
this.slots = this.meter.createUpDownCounter(Metrics.SEQUENCER_SLOT_COUNT, {
|
|
75
|
+
valueType: ValueType.INT,
|
|
76
|
+
description: 'The number of slots this sequencer was selected for'
|
|
77
|
+
});
|
|
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, {
|
|
82
|
+
valueType: ValueType.INT,
|
|
83
|
+
description: 'The number of slots this sequencer has filled'
|
|
84
|
+
});
|
|
85
|
+
this.timeToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_DURATION, {
|
|
86
|
+
description: 'The time spent collecting attestations from committee members',
|
|
87
|
+
unit: 'ms',
|
|
40
88
|
valueType: ValueType.INT
|
|
41
89
|
});
|
|
42
|
-
this.
|
|
43
|
-
description: '
|
|
90
|
+
this.allowanceToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_TIME_ALLOWANCE, {
|
|
91
|
+
description: 'Maximum amount of time to collect attestations',
|
|
92
|
+
unit: 'ms',
|
|
44
93
|
valueType: ValueType.INT
|
|
45
94
|
});
|
|
46
|
-
this.
|
|
47
|
-
|
|
95
|
+
this.requiredAttestions = this.meter.createGauge(Metrics.SEQUENCER_REQUIRED_ATTESTATIONS_COUNT, {
|
|
96
|
+
valueType: ValueType.INT,
|
|
97
|
+
description: 'The minimum number of attestations required to publish a block'
|
|
98
|
+
});
|
|
99
|
+
this.collectedAttestions = this.meter.createGauge(Metrics.SEQUENCER_COLLECTED_ATTESTATIONS_COUNT, {
|
|
100
|
+
valueType: ValueType.INT,
|
|
101
|
+
description: 'The minimum number of attestations required to publish a block'
|
|
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',
|
|
48
131
|
valueType: ValueType.INT
|
|
49
132
|
});
|
|
50
|
-
this.
|
|
51
|
-
description: '
|
|
52
|
-
unit: 'us',
|
|
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',
|
|
53
135
|
valueType: ValueType.INT
|
|
54
136
|
});
|
|
55
|
-
this.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
+
});
|
|
64
171
|
}
|
|
65
|
-
|
|
66
|
-
this.
|
|
172
|
+
recordRequiredAttestations(requiredAttestationsCount, allowanceMs) {
|
|
173
|
+
this.requiredAttestions.record(requiredAttestationsCount);
|
|
174
|
+
this.allowanceToCollectAttestations.record(Math.ceil(allowanceMs));
|
|
175
|
+
// reset
|
|
176
|
+
this.collectedAttestions.record(0);
|
|
177
|
+
this.timeToCollectAttestations.record(0);
|
|
67
178
|
}
|
|
68
|
-
|
|
69
|
-
this.
|
|
179
|
+
recordBlockAttestationDelay(duration) {
|
|
180
|
+
this.blockAttestationDelay.record(duration);
|
|
70
181
|
}
|
|
71
|
-
|
|
72
|
-
this.
|
|
73
|
-
|
|
74
|
-
});
|
|
75
|
-
this.setCurrentBlock(0, 0);
|
|
182
|
+
recordCollectedAttestations(count, durationMs) {
|
|
183
|
+
this.collectedAttestions.record(count);
|
|
184
|
+
this.timeToCollectAttestations.record(Math.ceil(durationMs));
|
|
76
185
|
}
|
|
77
186
|
recordBuiltBlock(buildDurationMs, totalMana) {
|
|
78
187
|
this.blockCounter.add(1, {
|
|
@@ -85,18 +194,135 @@ export class SequencerMetrics {
|
|
|
85
194
|
this.blockCounter.add(1, {
|
|
86
195
|
[Attributes.STATUS]: 'failed'
|
|
87
196
|
});
|
|
88
|
-
this.setCurrentBlock(0, 0);
|
|
89
|
-
}
|
|
90
|
-
recordNewBlock(blockNumber, txCount) {
|
|
91
|
-
this.setCurrentBlock(blockNumber, txCount);
|
|
92
197
|
}
|
|
93
198
|
recordStateTransitionBufferMs(durationMs, state) {
|
|
94
199
|
this.stateTransitionBufferDuration.record(durationMs, {
|
|
95
200
|
[Attributes.SEQUENCER_STATE]: state
|
|
96
201
|
});
|
|
97
202
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
this.
|
|
203
|
+
incOpenSlot(slot, proposer) {
|
|
204
|
+
// sequencer went through the loop a second time. Noop
|
|
205
|
+
if (slot === this.lastSeenSlot) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
this.slots.add(1, {
|
|
209
|
+
[Attributes.BLOCK_PROPOSER]: proposer
|
|
210
|
+
});
|
|
211
|
+
this.lastSeenSlot = slot;
|
|
212
|
+
}
|
|
213
|
+
async incFilledSlot(proposer, coinbase) {
|
|
214
|
+
this.filledSlots.add(1, {
|
|
215
|
+
[Attributes.BLOCK_PROPOSER]: proposer
|
|
216
|
+
});
|
|
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
|
+
});
|
|
247
|
+
}
|
|
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
|
+
}
|
|
101
327
|
}
|
|
102
328
|
}
|