@aztec/sequencer-client 0.0.1-commit.b655e406 → 0.0.1-commit.b6e433891

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