@aztec/sequencer-client 0.0.1-commit.5daedc8 → 0.0.1-commit.6201a7b05

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 +113 -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 +1010 -244
  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 +138 -0
  52. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
  53. package/dest/sequencer/checkpoint_proposal_job.js +1665 -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 +52 -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 +42 -7
  69. package/dest/sequencer/metrics.d.ts.map +1 -1
  70. package/dest/sequencer/metrics.js +241 -72
  71. package/dest/sequencer/sequencer.d.ts +146 -135
  72. package/dest/sequencer/sequencer.d.ts.map +1 -1
  73. package/dest/sequencer/sequencer.js +841 -661
  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 +105 -0
  91. package/package.json +31 -30
  92. package/src/client/sequencer-client.ts +102 -62
  93. package/src/config.ts +132 -59
  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 +763 -325
  109. package/src/sequencer/README.md +600 -0
  110. package/src/sequencer/chain_state_overrides.ts +87 -0
  111. package/src/sequencer/checkpoint_proposal_job.ts +1498 -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 +32 -0
  116. package/src/sequencer/index.ts +3 -1
  117. package/src/sequencer/metrics.ts +302 -83
  118. package/src/sequencer/sequencer.ts +641 -863
  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 +185 -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,5 +1,6 @@
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';
3
4
  import type { SlotNumber } from '@aztec/foundation/branded-types';
4
5
  import {
5
6
  Attributes,
@@ -10,7 +11,7 @@ import {
10
11
  type TelemetryClient,
11
12
  type Tracer,
12
13
  type UpDownCounter,
13
- ValueType,
14
+ createUpDownCounterWithDefault,
14
15
  } from '@aztec/telemetry-client';
15
16
 
16
17
  import { type Hex, formatUnits } from 'viem';
@@ -25,6 +26,7 @@ export class SequencerMetrics {
25
26
  private blockBuildDuration: Histogram;
26
27
  private blockBuildManaPerSecond: Gauge;
27
28
  private stateTransitionBufferDuration: Histogram;
29
+ private stateDuration: Histogram;
28
30
 
29
31
  // these are gauges because for individual sequencers building a block is not something that happens often enough to warrant a histogram
30
32
  private timeToCollectAttestations: Gauge;
@@ -38,9 +40,34 @@ export class SequencerMetrics {
38
40
  private filledSlots: UpDownCounter;
39
41
 
40
42
  private blockProposalFailed: UpDownCounter;
41
- private blockProposalSuccess: UpDownCounter;
42
- private blockProposalPrecheckFailed: UpDownCounter;
43
+ private checkpointProposalSuccess: UpDownCounter;
44
+ private checkpointPrecheckFailed: UpDownCounter;
45
+ private checkpointProposalFailed: UpDownCounter;
46
+ private checkpointSuccess: UpDownCounter;
43
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;
44
71
 
45
72
  private lastSeenSlot?: SlotNumber;
46
73
 
@@ -52,104 +79,138 @@ export class SequencerMetrics {
52
79
  this.meter = client.getMeter(name);
53
80
  this.tracer = client.getTracer(name);
54
81
 
55
- this.blockCounter = this.meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_COUNT);
56
-
57
- this.blockBuildDuration = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_DURATION, {
58
- unit: 'ms',
59
- description: 'Duration to build a block',
60
- valueType: ValueType.INT,
82
+ this.blockCounter = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_BLOCK_COUNT, {
83
+ [Attributes.STATUS]: ['failed', 'built'],
61
84
  });
62
85
 
63
- this.blockBuildManaPerSecond = this.meter.createGauge(Metrics.SEQUENCER_BLOCK_BUILD_MANA_PER_SECOND, {
64
- unit: 'mana/s',
65
- description: 'Mana per second when building a block',
66
- valueType: ValueType.INT,
67
- });
86
+ this.blockBuildDuration = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_DURATION);
68
87
 
69
- this.stateTransitionBufferDuration = this.meter.createHistogram(
70
- Metrics.SEQUENCER_STATE_TRANSITION_BUFFER_DURATION,
71
- {
72
- unit: 'ms',
73
- description:
74
- 'The time difference between when the sequencer needed to transition to a new state and when it actually did.',
75
- valueType: ValueType.INT,
76
- },
77
- );
88
+ this.blockBuildManaPerSecond = this.meter.createGauge(Metrics.SEQUENCER_BLOCK_BUILD_MANA_PER_SECOND);
78
89
 
79
- // Init gauges and counters
80
- this.blockCounter.add(0, {
81
- [Attributes.STATUS]: 'failed',
82
- });
83
- this.blockCounter.add(0, {
84
- [Attributes.STATUS]: 'built',
85
- });
90
+ this.blockInterBlockTime = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_INTER_BLOCK_TIME);
86
91
 
87
- this.rewards = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_REWARDS, {
88
- valueType: ValueType.DOUBLE,
89
- description: 'The rewards earned',
90
- });
92
+ this.stateTransitionBufferDuration = this.meter.createHistogram(Metrics.SEQUENCER_STATE_TRANSITION_BUFFER_DURATION);
91
93
 
92
- this.slots = this.meter.createUpDownCounter(Metrics.SEQUENCER_SLOT_COUNT, {
93
- valueType: ValueType.INT,
94
- description: 'The number of slots this sequencer was selected for',
95
- });
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);
96
99
 
97
100
  /**
98
101
  * NOTE: we do not track missed slots as a separate metric. That would be difficult to determine
99
102
  * Instead, use a computed metric, `slots - filledSlots` to get the number of slots a sequencer has missed.
100
103
  */
101
- this.filledSlots = this.meter.createUpDownCounter(Metrics.SEQUENCER_FILLED_SLOT_COUNT, {
102
- valueType: ValueType.INT,
103
- description: 'The number of slots this sequencer has filled',
104
- });
104
+ this.filledSlots = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_FILLED_SLOT_COUNT);
105
105
 
106
- this.timeToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_DURATION, {
107
- description: 'The time spent collecting attestations from committee members',
108
- unit: 'ms',
109
- valueType: ValueType.INT,
110
- });
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
+ );
111
123
 
112
- this.allowanceToCollectAttestations = this.meter.createGauge(
113
- Metrics.SEQUENCER_COLLECT_ATTESTATIONS_TIME_ALLOWANCE,
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,
114
129
  {
115
- description: 'Maximum amount of time to collect attestations',
116
- unit: 'ms',
117
- valueType: ValueType.INT,
130
+ [Attributes.ERROR_TYPE]: [
131
+ 'slot_already_taken',
132
+ 'rollup_contract_check_failed',
133
+ 'slot_mismatch',
134
+ 'block_number_mismatch',
135
+ ],
118
136
  },
119
137
  );
120
138
 
121
- this.requiredAttestions = this.meter.createGauge(Metrics.SEQUENCER_REQUIRED_ATTESTATIONS_COUNT, {
122
- valueType: ValueType.INT,
123
- description: 'The minimum number of attestations required to publish a block',
124
- });
139
+ this.checkpointProposalFailed = createUpDownCounterWithDefault(
140
+ this.meter,
141
+ Metrics.SEQUENCER_CHECKPOINT_PROPOSAL_FAILED_COUNT,
142
+ );
125
143
 
126
- this.collectedAttestions = this.meter.createGauge(Metrics.SEQUENCER_COLLECTED_ATTESTATIONS_COUNT, {
127
- valueType: ValueType.INT,
128
- description: 'The minimum number of attestations required to publish a block',
129
- });
144
+ this.slashingAttempts = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLASHING_ATTEMPTS_COUNT);
130
145
 
131
- this.blockProposalFailed = this.meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_PROPOSAL_FAILED_COUNT, {
132
- valueType: ValueType.INT,
133
- description: 'The number of times block proposal failed (including validation builds)',
134
- });
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);
135
162
 
136
- this.blockProposalSuccess = this.meter.createUpDownCounter(Metrics.SEQUENCER_BLOCK_PROPOSAL_SUCCESS_COUNT, {
137
- valueType: ValueType.INT,
138
- description: 'The number of times block proposal succeeded (including validation builds)',
139
- });
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);
140
202
 
141
- this.blockProposalPrecheckFailed = this.meter.createUpDownCounter(
142
- Metrics.SEQUENCER_BLOCK_PROPOSAL_PRECHECK_FAILED_COUNT,
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,
143
208
  {
144
- valueType: ValueType.INT,
145
- description: 'The number of times block proposal pre-build checks failed',
209
+ [Attributes.OK]: [true, false],
146
210
  },
147
211
  );
148
212
 
149
- this.slashingAttempts = this.meter.createUpDownCounter(Metrics.SEQUENCER_SLASHING_ATTEMPTS_COUNT, {
150
- valueType: ValueType.INT,
151
- description: 'The number of slashing action attempts',
152
- });
213
+ this.fishermanMaxBlobCapacity = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_MAX_BLOB_CAPACITY);
153
214
  }
154
215
 
155
216
  public recordRequiredAttestations(requiredAttestationsCount: number, allowanceMs: number) {
@@ -166,12 +227,20 @@ export class SequencerMetrics {
166
227
  this.timeToCollectAttestations.record(Math.ceil(durationMs));
167
228
  }
168
229
 
169
- recordBuiltBlock(buildDurationMs: number, totalMana: number) {
230
+ recordBuiltBlock(buildDurationMs: number, totalMana: number, slot: SlotNumber) {
170
231
  this.blockCounter.add(1, {
171
232
  [Attributes.STATUS]: 'built',
172
233
  });
173
234
  this.blockBuildDuration.record(Math.ceil(buildDurationMs));
174
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;
175
244
  }
176
245
 
177
246
  recordFailedBlock() {
@@ -186,6 +255,26 @@ export class SequencerMetrics {
186
255
  });
187
256
  }
188
257
 
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
+
189
278
  incOpenSlot(slot: SlotNumber, proposer: string) {
190
279
  // sequencer went through the loop a second time. Noop
191
280
  if (slot === this.lastSeenSlot) {
@@ -218,23 +307,153 @@ export class SequencerMetrics {
218
307
  }
219
308
  }
220
309
 
310
+ recordCheckpointSuccess() {
311
+ this.checkpointSuccess.add(1);
312
+ }
313
+
221
314
  recordBlockProposalFailed(reason?: string) {
222
315
  this.blockProposalFailed.add(1, {
223
316
  ...(reason && { [Attributes.ERROR_TYPE]: reason }),
224
317
  });
225
318
  }
226
319
 
227
- recordBlockProposalSuccess() {
228
- this.blockProposalSuccess.add(1);
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 });
229
328
  }
230
329
 
231
- recordBlockProposalPrecheckFailed(checkType: string) {
232
- this.blockProposalPrecheckFailed.add(1, {
233
- [Attributes.ERROR_TYPE]: checkType,
330
+ recordCheckpointProposalFailed(reason?: string) {
331
+ this.checkpointProposalFailed.add(1, {
332
+ ...(reason && { [Attributes.ERROR_TYPE]: reason }),
234
333
  });
235
334
  }
236
335
 
237
336
  recordSlashingAttempt(actionCount: number) {
238
337
  this.slashingAttempts.add(actionCount);
239
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
+ }
240
459
  }