@aztec/sequencer-client 0.0.1-commit.9b94fc1 → 0.0.1-commit.9badcec54

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.
Files changed (136) hide show
  1. package/dest/client/sequencer-client.d.ts +26 -16
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +76 -36
  4. package/dest/config.d.ts +35 -9
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +109 -50
  7. package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
  8. package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
  9. package/dest/global_variable_builder/fee_predictor.js +128 -0
  10. package/dest/global_variable_builder/fee_provider.d.ts +21 -0
  11. package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
  12. package/dest/global_variable_builder/fee_provider.js +58 -0
  13. package/dest/global_variable_builder/global_builder.d.ts +25 -17
  14. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  15. package/dest/global_variable_builder/global_builder.js +44 -68
  16. package/dest/global_variable_builder/index.d.ts +4 -2
  17. package/dest/global_variable_builder/index.d.ts.map +1 -1
  18. package/dest/global_variable_builder/index.js +2 -0
  19. package/dest/index.d.ts +2 -3
  20. package/dest/index.d.ts.map +1 -1
  21. package/dest/index.js +1 -2
  22. package/dest/publisher/config.d.ts +53 -20
  23. package/dest/publisher/config.d.ts.map +1 -1
  24. package/dest/publisher/config.js +124 -39
  25. package/dest/publisher/index.d.ts +2 -1
  26. package/dest/publisher/index.d.ts.map +1 -1
  27. package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
  28. package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
  29. package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
  30. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +58 -0
  31. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
  32. package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
  33. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
  34. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
  35. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
  36. package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
  37. package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
  38. package/dest/publisher/l1_tx_failed_store/index.js +2 -0
  39. package/dest/publisher/sequencer-publisher-factory.d.ts +15 -8
  40. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  41. package/dest/publisher/sequencer-publisher-factory.js +28 -4
  42. package/dest/publisher/sequencer-publisher-metrics.d.ts +3 -3
  43. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  44. package/dest/publisher/sequencer-publisher-metrics.js +23 -86
  45. package/dest/publisher/sequencer-publisher.d.ts +114 -80
  46. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  47. package/dest/publisher/sequencer-publisher.js +1008 -242
  48. package/dest/sequencer/chain_state_overrides.d.ts +25 -0
  49. package/dest/sequencer/chain_state_overrides.d.ts.map +1 -0
  50. package/dest/sequencer/chain_state_overrides.js +39 -0
  51. package/dest/sequencer/checkpoint_proposal_job.d.ts +119 -0
  52. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
  53. package/dest/sequencer/checkpoint_proposal_job.js +1355 -0
  54. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
  55. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
  56. package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
  57. package/dest/sequencer/checkpoint_voter.d.ts +34 -0
  58. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
  59. package/dest/sequencer/checkpoint_voter.js +106 -0
  60. package/dest/sequencer/config.d.ts +3 -2
  61. package/dest/sequencer/config.d.ts.map +1 -1
  62. package/dest/sequencer/events.d.ts +47 -0
  63. package/dest/sequencer/events.d.ts.map +1 -0
  64. package/dest/sequencer/events.js +1 -0
  65. package/dest/sequencer/index.d.ts +4 -2
  66. package/dest/sequencer/index.d.ts.map +1 -1
  67. package/dest/sequencer/index.js +3 -1
  68. package/dest/sequencer/metrics.d.ts +38 -7
  69. package/dest/sequencer/metrics.d.ts.map +1 -1
  70. package/dest/sequencer/metrics.js +220 -73
  71. package/dest/sequencer/sequencer.d.ts +138 -134
  72. package/dest/sequencer/sequencer.d.ts.map +1 -1
  73. package/dest/sequencer/sequencer.js +812 -657
  74. package/dest/sequencer/timetable.d.ts +67 -16
  75. package/dest/sequencer/timetable.d.ts.map +1 -1
  76. package/dest/sequencer/timetable.js +158 -64
  77. package/dest/sequencer/types.d.ts +3 -0
  78. package/dest/sequencer/types.d.ts.map +1 -0
  79. package/dest/sequencer/types.js +1 -0
  80. package/dest/sequencer/utils.d.ts +14 -8
  81. package/dest/sequencer/utils.d.ts.map +1 -1
  82. package/dest/sequencer/utils.js +7 -4
  83. package/dest/test/index.d.ts +6 -7
  84. package/dest/test/index.d.ts.map +1 -1
  85. package/dest/test/mock_checkpoint_builder.d.ts +95 -0
  86. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
  87. package/dest/test/mock_checkpoint_builder.js +231 -0
  88. package/dest/test/utils.d.ts +53 -0
  89. package/dest/test/utils.d.ts.map +1 -0
  90. package/dest/test/utils.js +104 -0
  91. package/package.json +31 -30
  92. package/src/client/sequencer-client.ts +102 -62
  93. package/src/config.ts +128 -60
  94. package/src/global_variable_builder/README.md +44 -0
  95. package/src/global_variable_builder/fee_predictor.ts +172 -0
  96. package/src/global_variable_builder/fee_provider.ts +75 -0
  97. package/src/global_variable_builder/global_builder.ts +64 -96
  98. package/src/global_variable_builder/index.ts +3 -1
  99. package/src/index.ts +1 -7
  100. package/src/publisher/config.ts +166 -51
  101. package/src/publisher/index.ts +3 -0
  102. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  103. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +57 -0
  104. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
  105. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  106. package/src/publisher/sequencer-publisher-factory.ts +43 -13
  107. package/src/publisher/sequencer-publisher-metrics.ts +19 -71
  108. package/src/publisher/sequencer-publisher.ts +761 -321
  109. package/src/sequencer/README.md +601 -0
  110. package/src/sequencer/chain_state_overrides.ts +87 -0
  111. package/src/sequencer/checkpoint_proposal_job.ts +1137 -0
  112. package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
  113. package/src/sequencer/checkpoint_voter.ts +119 -0
  114. package/src/sequencer/config.ts +2 -1
  115. package/src/sequencer/events.ts +27 -0
  116. package/src/sequencer/index.ts +3 -1
  117. package/src/sequencer/metrics.ts +273 -83
  118. package/src/sequencer/sequencer.ts +607 -857
  119. package/src/sequencer/timetable.ts +188 -81
  120. package/src/sequencer/types.ts +6 -0
  121. package/src/sequencer/utils.ts +18 -9
  122. package/src/test/index.ts +5 -6
  123. package/src/test/mock_checkpoint_builder.ts +323 -0
  124. package/src/test/utils.ts +167 -0
  125. package/dest/sequencer/block_builder.d.ts +0 -27
  126. package/dest/sequencer/block_builder.d.ts.map +0 -1
  127. package/dest/sequencer/block_builder.js +0 -134
  128. package/dest/tx_validator/nullifier_cache.d.ts +0 -14
  129. package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
  130. package/dest/tx_validator/nullifier_cache.js +0 -24
  131. package/dest/tx_validator/tx_validator_factory.d.ts +0 -17
  132. package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
  133. package/dest/tx_validator/tx_validator_factory.js +0 -53
  134. package/src/sequencer/block_builder.ts +0 -222
  135. package/src/tx_validator/nullifier_cache.ts +0 -30
  136. package/src/tx_validator/tx_validator_factory.ts +0 -132
@@ -1,4 +1,4 @@
1
- import { Attributes, Metrics, ValueType } from '@aztec/telemetry-client';
1
+ import { Attributes, Metrics, createUpDownCounterWithDefault } from '@aztec/telemetry-client';
2
2
  import { formatUnits } from 'viem';
3
3
  export class SequencerMetrics {
4
4
  rollup;
@@ -17,86 +17,101 @@ export class SequencerMetrics {
17
17
  slots;
18
18
  filledSlots;
19
19
  blockProposalFailed;
20
- blockProposalSuccess;
21
- blockProposalPrecheckFailed;
20
+ checkpointProposalSuccess;
21
+ checkpointPrecheckFailed;
22
+ checkpointProposalFailed;
23
+ checkpointSuccess;
22
24
  slashingAttempts;
25
+ pipelineDepth;
26
+ pipelineDiscards;
27
+ // Fisherman fee analysis metrics
28
+ fishermanWouldBeIncluded;
29
+ fishermanTimeBeforeBlock;
30
+ fishermanPendingBlobTxCount;
31
+ fishermanIncludedBlobTxCount;
32
+ fishermanPendingBlobCount;
33
+ fishermanIncludedBlobCount;
34
+ fishermanBlockBlobsFull;
35
+ fishermanMaxBlobCapacity;
36
+ fishermanCalculatedPriorityFee;
37
+ fishermanPriorityFeeDelta;
38
+ fishermanEstimatedCost;
39
+ fishermanEstimatedOverpayment;
40
+ fishermanMinedBlobTxPriorityFee;
41
+ fishermanMinedBlobTxTotalCost;
42
+ blockInterBlockTime;
43
+ lastBlockBuiltTimestamp;
44
+ lastBlockBuiltSlot;
23
45
  lastSeenSlot;
24
46
  constructor(client, rollup, name = 'Sequencer'){
25
47
  this.rollup = rollup;
26
48
  this.meter = client.getMeter(name);
27
49
  this.tracer = client.getTracer(name);
28
- this.blockCounter = this.meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_COUNT);
29
- this.blockBuildDuration = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_DURATION, {
30
- unit: 'ms',
31
- description: 'Duration to build a block',
32
- valueType: ValueType.INT
33
- });
34
- this.blockBuildManaPerSecond = this.meter.createGauge(Metrics.SEQUENCER_BLOCK_BUILD_MANA_PER_SECOND, {
35
- unit: 'mana/s',
36
- description: 'Mana per second when building a block',
37
- valueType: ValueType.INT
38
- });
39
- this.stateTransitionBufferDuration = this.meter.createHistogram(Metrics.SEQUENCER_STATE_TRANSITION_BUFFER_DURATION, {
40
- unit: 'ms',
41
- description: 'The time difference between when the sequencer needed to transition to a new state and when it actually did.',
42
- valueType: ValueType.INT
43
- });
44
- // Init gauges and counters
45
- this.blockCounter.add(0, {
46
- [Attributes.STATUS]: 'failed'
47
- });
48
- this.blockCounter.add(0, {
49
- [Attributes.STATUS]: 'built'
50
- });
51
- this.rewards = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_REWARDS, {
52
- valueType: ValueType.DOUBLE,
53
- description: 'The rewards earned'
54
- });
55
- this.slots = this.meter.createUpDownCounter(Metrics.SEQUENCER_SLOT_COUNT, {
56
- valueType: ValueType.INT,
57
- description: 'The number of slots this sequencer was selected for'
50
+ this.blockCounter = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_BLOCK_COUNT, {
51
+ [Attributes.STATUS]: [
52
+ 'failed',
53
+ 'built'
54
+ ]
58
55
  });
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.blockInterBlockTime = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_INTER_BLOCK_TIME);
59
+ this.stateTransitionBufferDuration = this.meter.createHistogram(Metrics.SEQUENCER_STATE_TRANSITION_BUFFER_DURATION);
60
+ this.rewards = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_SLOT_REWARDS);
61
+ this.slots = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLOT_COUNT);
59
62
  /**
60
63
  * NOTE: we do not track missed slots as a separate metric. That would be difficult to determine
61
64
  * Instead, use a computed metric, `slots - filledSlots` to get the number of slots a sequencer has missed.
62
- */ this.filledSlots = this.meter.createUpDownCounter(Metrics.SEQUENCER_FILLED_SLOT_COUNT, {
63
- valueType: ValueType.INT,
64
- description: 'The number of slots this sequencer has filled'
65
- });
66
- this.timeToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_DURATION, {
67
- description: 'The time spent collecting attestations from committee members',
68
- unit: 'ms',
69
- valueType: ValueType.INT
70
- });
71
- this.allowanceToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_TIME_ALLOWANCE, {
72
- description: 'Maximum amount of time to collect attestations',
73
- unit: 'ms',
74
- valueType: ValueType.INT
75
- });
76
- this.requiredAttestions = this.meter.createGauge(Metrics.SEQUENCER_REQUIRED_ATTESTATIONS_COUNT, {
77
- valueType: ValueType.INT,
78
- description: 'The minimum number of attestations required to publish a block'
79
- });
80
- this.collectedAttestions = this.meter.createGauge(Metrics.SEQUENCER_COLLECTED_ATTESTATIONS_COUNT, {
81
- valueType: ValueType.INT,
82
- description: 'The minimum number of attestations required to publish a block'
83
- });
84
- this.blockProposalFailed = this.meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_PROPOSAL_FAILED_COUNT, {
85
- valueType: ValueType.INT,
86
- description: 'The number of times block proposal failed (including validation builds)'
87
- });
88
- this.blockProposalSuccess = this.meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_PROPOSAL_SUCCESS_COUNT, {
89
- valueType: ValueType.INT,
90
- description: 'The number of times block proposal succeeded (including validation builds)'
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
+ ]
91
80
  });
92
- this.blockProposalPrecheckFailed = this.meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_PROPOSAL_PRECHECK_FAILED_COUNT, {
93
- valueType: ValueType.INT,
94
- description: 'The number of times block proposal pre-build checks failed'
81
+ this.checkpointProposalFailed = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_CHECKPOINT_PROPOSAL_FAILED_COUNT);
82
+ this.slashingAttempts = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLASHING_ATTEMPTS_COUNT);
83
+ this.pipelineDepth = this.meter.createGauge(Metrics.SEQUENCER_PIPELINE_DEPTH);
84
+ this.pipelineDiscards = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_PIPELINE_DISCARDS_COUNT);
85
+ this.pipelineDepth.record(0);
86
+ // Fisherman fee analysis metrics
87
+ this.fishermanWouldBeIncluded = createUpDownCounterWithDefault(this.meter, Metrics.FISHERMAN_FEE_ANALYSIS_WOULD_BE_INCLUDED, {
88
+ [Attributes.OK]: [
89
+ true,
90
+ false
91
+ ],
92
+ [Attributes.BLOCK_FULL]: [
93
+ 'true',
94
+ 'false'
95
+ ]
95
96
  });
96
- this.slashingAttempts = this.meter.createUpDownCounter(Metrics.SEQUENCER_SLASHING_ATTEMPTS_COUNT, {
97
- valueType: ValueType.INT,
98
- description: 'The number of slashing action attempts'
97
+ this.fishermanTimeBeforeBlock = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_TIME_BEFORE_BLOCK);
98
+ this.fishermanPendingBlobTxCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PENDING_BLOB_TX_COUNT);
99
+ this.fishermanIncludedBlobTxCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_INCLUDED_BLOB_TX_COUNT);
100
+ this.fishermanCalculatedPriorityFee = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_CALCULATED_PRIORITY_FEE);
101
+ this.fishermanPriorityFeeDelta = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PRIORITY_FEE_DELTA);
102
+ this.fishermanEstimatedCost = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_ESTIMATED_COST);
103
+ this.fishermanEstimatedOverpayment = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_ESTIMATED_OVERPAYMENT);
104
+ this.fishermanMinedBlobTxPriorityFee = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_MINED_BLOB_TX_PRIORITY_FEE);
105
+ this.fishermanMinedBlobTxTotalCost = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_MINED_BLOB_TX_TOTAL_COST);
106
+ this.fishermanPendingBlobCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PENDING_BLOB_COUNT);
107
+ this.fishermanIncludedBlobCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_INCLUDED_BLOB_COUNT);
108
+ this.fishermanBlockBlobsFull = createUpDownCounterWithDefault(this.meter, Metrics.FISHERMAN_FEE_ANALYSIS_BLOCK_BLOBS_FULL, {
109
+ [Attributes.OK]: [
110
+ true,
111
+ false
112
+ ]
99
113
  });
114
+ this.fishermanMaxBlobCapacity = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_MAX_BLOB_CAPACITY);
100
115
  }
101
116
  recordRequiredAttestations(requiredAttestationsCount, allowanceMs) {
102
117
  this.requiredAttestions.record(requiredAttestationsCount);
@@ -109,12 +124,19 @@ export class SequencerMetrics {
109
124
  this.collectedAttestions.record(count);
110
125
  this.timeToCollectAttestations.record(Math.ceil(durationMs));
111
126
  }
112
- recordBuiltBlock(buildDurationMs, totalMana) {
127
+ recordBuiltBlock(buildDurationMs, totalMana, slot) {
113
128
  this.blockCounter.add(1, {
114
129
  [Attributes.STATUS]: 'built'
115
130
  });
116
131
  this.blockBuildDuration.record(Math.ceil(buildDurationMs));
117
132
  this.blockBuildManaPerSecond.record(Math.ceil(totalMana * 1000 / buildDurationMs));
133
+ // Only record inter-block time between blocks built within the same slot.
134
+ const now = Date.now();
135
+ if (this.lastBlockBuiltTimestamp !== undefined && this.lastBlockBuiltSlot === slot) {
136
+ this.blockInterBlockTime.record(now - this.lastBlockBuiltTimestamp);
137
+ }
138
+ this.lastBlockBuiltTimestamp = now;
139
+ this.lastBlockBuiltSlot = slot;
118
140
  }
119
141
  recordFailedBlock() {
120
142
  this.blockCounter.add(1, {
@@ -126,6 +148,12 @@ export class SequencerMetrics {
126
148
  [Attributes.SEQUENCER_STATE]: state
127
149
  });
128
150
  }
151
+ recordPipelineDepth(depth) {
152
+ this.pipelineDepth.record(depth);
153
+ }
154
+ recordPipelineDiscard(count = 1) {
155
+ this.pipelineDiscards.add(count);
156
+ }
129
157
  incOpenSlot(slot, proposer) {
130
158
  // sequencer went through the loop a second time. Noop
131
159
  if (slot === this.lastSeenSlot) {
@@ -153,6 +181,9 @@ export class SequencerMetrics {
153
181
  }
154
182
  }
155
183
  }
184
+ recordCheckpointSuccess() {
185
+ this.checkpointSuccess.add(1);
186
+ }
156
187
  recordBlockProposalFailed(reason) {
157
188
  this.blockProposalFailed.add(1, {
158
189
  ...reason && {
@@ -160,15 +191,131 @@ export class SequencerMetrics {
160
191
  }
161
192
  });
162
193
  }
163
- recordBlockProposalSuccess() {
164
- this.blockProposalSuccess.add(1);
194
+ recordCheckpointProposalSuccess() {
195
+ this.checkpointProposalSuccess.add(1);
165
196
  }
166
- recordBlockProposalPrecheckFailed(checkType) {
167
- this.blockProposalPrecheckFailed.add(1, {
197
+ recordCheckpointPrecheckFailed(checkType) {
198
+ this.checkpointPrecheckFailed.add(1, {
168
199
  [Attributes.ERROR_TYPE]: checkType
169
200
  });
170
201
  }
202
+ recordCheckpointProposalFailed(reason) {
203
+ this.checkpointProposalFailed.add(1, {
204
+ ...reason && {
205
+ [Attributes.ERROR_TYPE]: reason
206
+ }
207
+ });
208
+ }
171
209
  recordSlashingAttempt(actionCount) {
172
210
  this.slashingAttempts.add(actionCount);
173
211
  }
212
+ /**
213
+ * Records metrics for a completed fisherman fee analysis
214
+ * @param analysis - The completed fee analysis result
215
+ */ recordFishermanFeeAnalysis(analysis) {
216
+ // In fisherman mode, we should always have strategy results
217
+ if (!analysis.computedPrices.strategyResults || analysis.computedPrices.strategyResults.length === 0) {
218
+ // This should never happen in fisherman mode - log an error
219
+ // We don't record metrics without strategy IDs as that defeats the purpose
220
+ throw new Error(`No strategy results found in fisherman fee analysis ${analysis.id}. This indicates a bug in the fee analysis.`);
221
+ }
222
+ // Record metrics for each strategy separately
223
+ for (const strategyResult of analysis.computedPrices.strategyResults){
224
+ const strategyAttributes = {
225
+ [Attributes.FISHERMAN_FEE_STRATEGY_ID]: strategyResult.strategyId
226
+ };
227
+ // Record pending block snapshot data (once per strategy for comparison)
228
+ this.fishermanPendingBlobTxCount.record(analysis.pendingSnapshot.pendingBlobTxCount, strategyAttributes);
229
+ this.fishermanPendingBlobCount.record(analysis.pendingSnapshot.pendingBlobCount, strategyAttributes);
230
+ // Record mined block data if available
231
+ if (analysis.minedBlock) {
232
+ this.fishermanIncludedBlobTxCount.record(analysis.minedBlock.includedBlobTxCount, strategyAttributes);
233
+ this.fishermanIncludedBlobCount.record(analysis.minedBlock.includedBlobCount, strategyAttributes);
234
+ // Record actual fees from blob transactions in the mined block
235
+ for (const blobTx of analysis.minedBlock.includedBlobTxs){
236
+ // Record priority fee per gas in Gwei
237
+ const priorityFeeGwei = Number(blobTx.maxPriorityFeePerGas) / 1e9;
238
+ this.fishermanMinedBlobTxPriorityFee.record(priorityFeeGwei, strategyAttributes);
239
+ // Calculate total cost in ETH
240
+ // Cost = (gas * (baseFee + priorityFee)) + (blobCount * blobGasPerBlob * blobBaseFee)
241
+ const baseFee = analysis.minedBlock.baseFeePerGas;
242
+ const effectiveGasPrice = baseFee + blobTx.maxPriorityFeePerGas;
243
+ // Calculate execution cost using actual gas limit from the transaction
244
+ const executionCost = blobTx.gas * effectiveGasPrice;
245
+ // Calculate blob cost using maxFeePerBlobGas * blobCount * GAS_PER_BLOB
246
+ const blobCost = blobTx.maxFeePerBlobGas * BigInt(blobTx.blobCount) * 131072n; // 128KB per blob
247
+ const totalCostWei = executionCost + blobCost;
248
+ const totalCostEth = Number(totalCostWei) / 1e18;
249
+ this.fishermanMinedBlobTxTotalCost.record(totalCostEth, strategyAttributes);
250
+ }
251
+ }
252
+ // Record the calculated priority fee for this strategy
253
+ const calculatedPriorityFeeGwei = Number(strategyResult.calculatedPriorityFee) / 1e9;
254
+ this.fishermanCalculatedPriorityFee.record(calculatedPriorityFeeGwei, strategyAttributes);
255
+ // Record analysis results if available
256
+ if (analysis.analysis) {
257
+ this.fishermanTimeBeforeBlock.record(Math.ceil(analysis.analysis.timeBeforeBlockMs), strategyAttributes);
258
+ // Record whether the block reached 100% blob capacity
259
+ if (analysis.analysis.blockBlobsFull) {
260
+ this.fishermanBlockBlobsFull.add(1, {
261
+ ...strategyAttributes,
262
+ [Attributes.OK]: true
263
+ });
264
+ } else {
265
+ this.fishermanBlockBlobsFull.add(1, {
266
+ ...strategyAttributes,
267
+ [Attributes.OK]: false
268
+ });
269
+ }
270
+ // Record the max blob capacity for this block
271
+ this.fishermanMaxBlobCapacity.record(analysis.analysis.maxBlobCapacity, strategyAttributes);
272
+ // Record strategy-specific inclusion result
273
+ if (strategyResult.wouldBeIncluded !== undefined) {
274
+ const inclusionAttributes = {
275
+ ...strategyAttributes,
276
+ [Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false'
277
+ };
278
+ if (strategyResult.wouldBeIncluded) {
279
+ this.fishermanWouldBeIncluded.add(1, {
280
+ ...inclusionAttributes,
281
+ [Attributes.OK]: true
282
+ });
283
+ } else {
284
+ this.fishermanWouldBeIncluded.add(1, {
285
+ ...inclusionAttributes,
286
+ [Attributes.OK]: false,
287
+ ...strategyResult.exclusionReason && {
288
+ [Attributes.ERROR_TYPE]: strategyResult.exclusionReason
289
+ }
290
+ });
291
+ }
292
+ }
293
+ // Record strategy-specific priority fee delta
294
+ if (strategyResult.priorityFeeDelta !== undefined) {
295
+ const priorityFeeDeltaGwei = Number(strategyResult.priorityFeeDelta) / 1e9;
296
+ const deltaAttributes = {
297
+ ...strategyAttributes,
298
+ [Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false'
299
+ };
300
+ this.fishermanPriorityFeeDelta.record(priorityFeeDeltaGwei, deltaAttributes);
301
+ }
302
+ // Record estimated cost if available
303
+ if (strategyResult.estimatedCostEth !== undefined) {
304
+ const costAttributes = {
305
+ ...strategyAttributes,
306
+ [Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false'
307
+ };
308
+ this.fishermanEstimatedCost.record(strategyResult.estimatedCostEth, costAttributes);
309
+ }
310
+ // Record estimated overpayment if available
311
+ if (strategyResult.estimatedOverpaymentEth !== undefined) {
312
+ const overpaymentAttributes = {
313
+ ...strategyAttributes,
314
+ [Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false'
315
+ };
316
+ this.fishermanEstimatedOverpayment.record(strategyResult.estimatedOverpaymentEth, overpaymentAttributes);
317
+ }
318
+ }
319
+ }
320
+ }
174
321
  }