@aztec/sequencer-client 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0

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 (162) hide show
  1. package/README.md +281 -21
  2. package/dest/client/sequencer-client.d.ts +41 -18
  3. package/dest/client/sequencer-client.d.ts.map +1 -1
  4. package/dest/client/sequencer-client.js +88 -43
  5. package/dest/config.d.ts +41 -8
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +146 -55
  8. package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
  9. package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
  10. package/dest/global_variable_builder/fee_predictor.js +138 -0
  11. package/dest/global_variable_builder/fee_provider.d.ts +21 -0
  12. package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
  13. package/dest/global_variable_builder/fee_provider.js +80 -0
  14. package/dest/global_variable_builder/global_builder.d.ts +20 -26
  15. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  16. package/dest/global_variable_builder/global_builder.js +28 -75
  17. package/dest/global_variable_builder/index.d.ts +4 -2
  18. package/dest/global_variable_builder/index.d.ts.map +1 -1
  19. package/dest/global_variable_builder/index.js +2 -0
  20. package/dest/index.d.ts +2 -3
  21. package/dest/index.d.ts.map +1 -1
  22. package/dest/index.js +1 -2
  23. package/dest/publisher/config.d.ts +57 -20
  24. package/dest/publisher/config.d.ts.map +1 -1
  25. package/dest/publisher/config.js +134 -39
  26. package/dest/publisher/index.d.ts +2 -1
  27. package/dest/publisher/index.d.ts.map +1 -1
  28. package/dest/publisher/l1_to_l2_messaging.d.ts +21 -0
  29. package/dest/publisher/l1_to_l2_messaging.d.ts.map +1 -0
  30. package/dest/publisher/l1_to_l2_messaging.js +70 -0
  31. package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
  32. package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
  33. package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
  34. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +98 -0
  35. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
  36. package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +68 -0
  37. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
  38. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
  39. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +36 -0
  40. package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
  41. package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
  42. package/dest/publisher/l1_tx_failed_store/index.js +3 -0
  43. package/dest/publisher/sequencer-bundle-simulator.d.ts +96 -0
  44. package/dest/publisher/sequencer-bundle-simulator.d.ts.map +1 -0
  45. package/dest/publisher/sequencer-bundle-simulator.js +198 -0
  46. package/dest/publisher/sequencer-publisher-factory.d.ts +15 -8
  47. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  48. package/dest/publisher/sequencer-publisher-factory.js +28 -4
  49. package/dest/publisher/sequencer-publisher-metrics.d.ts +3 -3
  50. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  51. package/dest/publisher/sequencer-publisher-metrics.js +23 -86
  52. package/dest/publisher/sequencer-publisher.d.ts +152 -90
  53. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  54. package/dest/publisher/sequencer-publisher.js +1257 -421
  55. package/dest/publisher/write_json.d.ts +11 -0
  56. package/dest/publisher/write_json.d.ts.map +1 -0
  57. package/dest/publisher/write_json.js +57 -0
  58. package/dest/sequencer/automine/automine_factory.d.ts +56 -0
  59. package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
  60. package/dest/sequencer/automine/automine_factory.js +85 -0
  61. package/dest/sequencer/automine/automine_sequencer.d.ts +189 -0
  62. package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
  63. package/dest/sequencer/automine/automine_sequencer.js +690 -0
  64. package/dest/sequencer/automine/index.d.ts +3 -0
  65. package/dest/sequencer/automine/index.d.ts.map +1 -0
  66. package/dest/sequencer/automine/index.js +2 -0
  67. package/dest/sequencer/checkpoint_proposal_job.d.ts +158 -0
  68. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
  69. package/dest/sequencer/checkpoint_proposal_job.js +1801 -0
  70. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
  71. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
  72. package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
  73. package/dest/sequencer/checkpoint_voter.d.ts +34 -0
  74. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
  75. package/dest/sequencer/checkpoint_voter.js +106 -0
  76. package/dest/sequencer/config.d.ts +3 -2
  77. package/dest/sequencer/config.d.ts.map +1 -1
  78. package/dest/sequencer/events.d.ts +103 -0
  79. package/dest/sequencer/events.d.ts.map +1 -0
  80. package/dest/sequencer/events.js +1 -0
  81. package/dest/sequencer/index.d.ts +4 -2
  82. package/dest/sequencer/index.d.ts.map +1 -1
  83. package/dest/sequencer/index.js +3 -1
  84. package/dest/sequencer/metrics.d.ts +42 -7
  85. package/dest/sequencer/metrics.d.ts.map +1 -1
  86. package/dest/sequencer/metrics.js +241 -72
  87. package/dest/sequencer/requests_tracker.d.ts +22 -0
  88. package/dest/sequencer/requests_tracker.d.ts.map +1 -0
  89. package/dest/sequencer/requests_tracker.js +33 -0
  90. package/dest/sequencer/sequencer.d.ts +251 -138
  91. package/dest/sequencer/sequencer.d.ts.map +1 -1
  92. package/dest/sequencer/sequencer.js +1190 -704
  93. package/dest/sequencer/types.d.ts +3 -0
  94. package/dest/sequencer/types.d.ts.map +1 -0
  95. package/dest/sequencer/types.js +1 -0
  96. package/dest/sequencer/utils.d.ts +14 -8
  97. package/dest/sequencer/utils.d.ts.map +1 -1
  98. package/dest/sequencer/utils.js +7 -4
  99. package/dest/test/index.d.ts +8 -9
  100. package/dest/test/index.d.ts.map +1 -1
  101. package/dest/test/mock_checkpoint_builder.d.ts +95 -0
  102. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
  103. package/dest/test/mock_checkpoint_builder.js +231 -0
  104. package/dest/test/utils.d.ts +67 -0
  105. package/dest/test/utils.d.ts.map +1 -0
  106. package/dest/test/utils.js +122 -0
  107. package/package.json +32 -29
  108. package/src/client/sequencer-client.ts +118 -66
  109. package/src/config.ts +173 -64
  110. package/src/global_variable_builder/README.md +44 -0
  111. package/src/global_variable_builder/fee_predictor.ts +182 -0
  112. package/src/global_variable_builder/fee_provider.ts +97 -0
  113. package/src/global_variable_builder/global_builder.ts +45 -110
  114. package/src/global_variable_builder/index.ts +3 -1
  115. package/src/index.ts +1 -7
  116. package/src/publisher/config.ts +182 -46
  117. package/src/publisher/index.ts +3 -0
  118. package/src/publisher/l1_to_l2_messaging.ts +85 -0
  119. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  120. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +164 -0
  121. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +47 -0
  122. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  123. package/src/publisher/sequencer-bundle-simulator.ts +254 -0
  124. package/src/publisher/sequencer-publisher-factory.ts +43 -13
  125. package/src/publisher/sequencer-publisher-metrics.ts +19 -71
  126. package/src/publisher/sequencer-publisher.ts +1042 -542
  127. package/src/publisher/write_json.ts +78 -0
  128. package/src/sequencer/README.md +243 -0
  129. package/src/sequencer/automine/README.md +60 -0
  130. package/src/sequencer/automine/automine_factory.ts +152 -0
  131. package/src/sequencer/automine/automine_sequencer.ts +796 -0
  132. package/src/sequencer/automine/index.ts +6 -0
  133. package/src/sequencer/checkpoint_proposal_job.ts +1652 -0
  134. package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
  135. package/src/sequencer/checkpoint_voter.ts +119 -0
  136. package/src/sequencer/config.ts +2 -1
  137. package/src/sequencer/events.ts +88 -0
  138. package/src/sequencer/index.ts +3 -1
  139. package/src/sequencer/metrics.ts +302 -83
  140. package/src/sequencer/requests_tracker.ts +43 -0
  141. package/src/sequencer/sequencer.ts +1011 -898
  142. package/src/sequencer/types.ts +6 -0
  143. package/src/sequencer/utils.ts +18 -9
  144. package/src/test/index.ts +7 -8
  145. package/src/test/mock_checkpoint_builder.ts +323 -0
  146. package/src/test/utils.ts +218 -0
  147. package/dest/sequencer/block_builder.d.ts +0 -28
  148. package/dest/sequencer/block_builder.d.ts.map +0 -1
  149. package/dest/sequencer/block_builder.js +0 -134
  150. package/dest/sequencer/timetable.d.ts +0 -50
  151. package/dest/sequencer/timetable.d.ts.map +0 -1
  152. package/dest/sequencer/timetable.js +0 -137
  153. package/dest/tx_validator/nullifier_cache.d.ts +0 -14
  154. package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
  155. package/dest/tx_validator/nullifier_cache.js +0 -24
  156. package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
  157. package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
  158. package/dest/tx_validator/tx_validator_factory.js +0 -53
  159. package/src/sequencer/block_builder.ts +0 -222
  160. package/src/sequencer/timetable.ts +0 -188
  161. package/src/tx_validator/nullifier_cache.ts +0 -30
  162. package/src/tx_validator/tx_validator_factory.ts +0 -133
@@ -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;
@@ -8,6 +8,7 @@ export class SequencerMetrics {
8
8
  blockBuildDuration;
9
9
  blockBuildManaPerSecond;
10
10
  stateTransitionBufferDuration;
11
+ stateDuration;
11
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
  allowanceToCollectAttestations;
@@ -17,86 +18,112 @@ export class SequencerMetrics {
17
18
  slots;
18
19
  filledSlots;
19
20
  blockProposalFailed;
20
- blockProposalSuccess;
21
- blockProposalPrecheckFailed;
21
+ checkpointProposalSuccess;
22
+ checkpointPrecheckFailed;
23
+ checkpointProposalFailed;
24
+ checkpointSuccess;
22
25
  slashingAttempts;
26
+ pipelineDepth;
27
+ pipelineDiscards;
28
+ pipelineParentCheckpointMismatches;
29
+ // Fisherman fee analysis metrics
30
+ fishermanWouldBeIncluded;
31
+ fishermanTimeBeforeBlock;
32
+ fishermanPendingBlobTxCount;
33
+ fishermanIncludedBlobTxCount;
34
+ fishermanPendingBlobCount;
35
+ fishermanIncludedBlobCount;
36
+ fishermanBlockBlobsFull;
37
+ fishermanMaxBlobCapacity;
38
+ fishermanCalculatedPriorityFee;
39
+ fishermanPriorityFeeDelta;
40
+ fishermanEstimatedCost;
41
+ fishermanEstimatedOverpayment;
42
+ fishermanMinedBlobTxPriorityFee;
43
+ fishermanMinedBlobTxTotalCost;
44
+ blockInterBlockTime;
45
+ lastBlockBuiltTimestamp;
46
+ lastBlockBuiltSlot;
23
47
  lastSeenSlot;
24
48
  constructor(client, rollup, name = 'Sequencer'){
25
49
  this.rollup = rollup;
26
50
  this.meter = client.getMeter(name);
27
51
  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'
52
+ this.blockCounter = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_BLOCK_COUNT, {
53
+ [Attributes.STATUS]: [
54
+ 'failed',
55
+ 'built'
56
+ ]
58
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.blockInterBlockTime = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_INTER_BLOCK_TIME);
61
+ this.stateTransitionBufferDuration = this.meter.createHistogram(Metrics.SEQUENCER_STATE_TRANSITION_BUFFER_DURATION);
62
+ this.stateDuration = this.meter.createHistogram(Metrics.SEQUENCER_STATE_DURATION);
63
+ this.rewards = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_SLOT_REWARDS);
64
+ this.slots = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLOT_COUNT);
59
65
  /**
60
66
  * NOTE: we do not track missed slots as a separate metric. That would be difficult to determine
61
67
  * 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'
68
+ */ this.filledSlots = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_FILLED_SLOT_COUNT);
69
+ this.timeToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_DURATION);
70
+ this.allowanceToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_TIME_ALLOWANCE);
71
+ this.requiredAttestions = this.meter.createGauge(Metrics.SEQUENCER_REQUIRED_ATTESTATIONS_COUNT);
72
+ this.collectedAttestions = this.meter.createGauge(Metrics.SEQUENCER_COLLECTED_ATTESTATIONS_COUNT);
73
+ this.blockProposalFailed = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_BLOCK_PROPOSAL_FAILED_COUNT);
74
+ this.checkpointProposalSuccess = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_CHECKPOINT_PROPOSAL_SUCCESS_COUNT);
75
+ this.checkpointSuccess = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_CHECKPOINT_SUCCESS_COUNT);
76
+ this.checkpointPrecheckFailed = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_CHECKPOINT_PRECHECK_FAILED_COUNT, {
77
+ [Attributes.ERROR_TYPE]: [
78
+ 'slot_already_taken',
79
+ 'rollup_contract_check_failed',
80
+ 'slot_mismatch',
81
+ 'block_number_mismatch'
82
+ ]
65
83
  });
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
84
+ this.checkpointProposalFailed = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_CHECKPOINT_PROPOSAL_FAILED_COUNT);
85
+ this.slashingAttempts = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLASHING_ATTEMPTS_COUNT);
86
+ this.pipelineDepth = this.meter.createGauge(Metrics.SEQUENCER_PIPELINE_DEPTH);
87
+ this.pipelineDiscards = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_PIPELINE_DISCARDS_COUNT);
88
+ this.pipelineParentCheckpointMismatches = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_PIPELINE_PARENT_CHECKPOINT_MISMATCH_COUNT, {
89
+ [Attributes.ERROR_TYPE]: [
90
+ 'archiver-sync-timeout',
91
+ 'parent-not-on-l1',
92
+ 'parent-hash-mismatch',
93
+ 'parent-invalid-attestations',
94
+ 'unexpected-parent-appeared'
95
+ ]
70
96
  });
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
97
+ this.pipelineDepth.record(0);
98
+ // Fisherman fee analysis metrics
99
+ this.fishermanWouldBeIncluded = createUpDownCounterWithDefault(this.meter, Metrics.FISHERMAN_FEE_ANALYSIS_WOULD_BE_INCLUDED, {
100
+ [Attributes.OK]: [
101
+ true,
102
+ false
103
+ ],
104
+ [Attributes.BLOCK_FULL]: [
105
+ 'true',
106
+ 'false'
107
+ ]
75
108
  });
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)'
91
- });
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'
95
- });
96
- this.slashingAttempts = this.meter.createUpDownCounter(Metrics.SEQUENCER_SLASHING_ATTEMPTS_COUNT, {
97
- valueType: ValueType.INT,
98
- description: 'The number of slashing action attempts'
109
+ this.fishermanTimeBeforeBlock = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_TIME_BEFORE_BLOCK);
110
+ this.fishermanPendingBlobTxCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PENDING_BLOB_TX_COUNT);
111
+ this.fishermanIncludedBlobTxCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_INCLUDED_BLOB_TX_COUNT);
112
+ this.fishermanCalculatedPriorityFee = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_CALCULATED_PRIORITY_FEE);
113
+ this.fishermanPriorityFeeDelta = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PRIORITY_FEE_DELTA);
114
+ this.fishermanEstimatedCost = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_ESTIMATED_COST);
115
+ this.fishermanEstimatedOverpayment = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_ESTIMATED_OVERPAYMENT);
116
+ this.fishermanMinedBlobTxPriorityFee = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_MINED_BLOB_TX_PRIORITY_FEE);
117
+ this.fishermanMinedBlobTxTotalCost = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_MINED_BLOB_TX_TOTAL_COST);
118
+ this.fishermanPendingBlobCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PENDING_BLOB_COUNT);
119
+ this.fishermanIncludedBlobCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_INCLUDED_BLOB_COUNT);
120
+ this.fishermanBlockBlobsFull = createUpDownCounterWithDefault(this.meter, Metrics.FISHERMAN_FEE_ANALYSIS_BLOCK_BLOBS_FULL, {
121
+ [Attributes.OK]: [
122
+ true,
123
+ false
124
+ ]
99
125
  });
126
+ this.fishermanMaxBlobCapacity = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_MAX_BLOB_CAPACITY);
100
127
  }
101
128
  recordRequiredAttestations(requiredAttestationsCount, allowanceMs) {
102
129
  this.requiredAttestions.record(requiredAttestationsCount);
@@ -109,12 +136,19 @@ export class SequencerMetrics {
109
136
  this.collectedAttestions.record(count);
110
137
  this.timeToCollectAttestations.record(Math.ceil(durationMs));
111
138
  }
112
- recordBuiltBlock(buildDurationMs, totalMana) {
139
+ recordBuiltBlock(buildDurationMs, totalMana, slot) {
113
140
  this.blockCounter.add(1, {
114
141
  [Attributes.STATUS]: 'built'
115
142
  });
116
143
  this.blockBuildDuration.record(Math.ceil(buildDurationMs));
117
144
  this.blockBuildManaPerSecond.record(Math.ceil(totalMana * 1000 / buildDurationMs));
145
+ // Only record inter-block time between blocks built within the same slot.
146
+ const now = Date.now();
147
+ if (this.lastBlockBuiltTimestamp !== undefined && this.lastBlockBuiltSlot === slot) {
148
+ this.blockInterBlockTime.record(now - this.lastBlockBuiltTimestamp);
149
+ }
150
+ this.lastBlockBuiltTimestamp = now;
151
+ this.lastBlockBuiltSlot = slot;
118
152
  }
119
153
  recordFailedBlock() {
120
154
  this.blockCounter.add(1, {
@@ -126,6 +160,22 @@ export class SequencerMetrics {
126
160
  [Attributes.SEQUENCER_STATE]: state
127
161
  });
128
162
  }
163
+ recordStateDuration(durationMs, state) {
164
+ this.stateDuration.record(Math.ceil(durationMs), {
165
+ [Attributes.SEQUENCER_STATE]: state
166
+ });
167
+ }
168
+ recordPipelineDepth(depth) {
169
+ this.pipelineDepth.record(depth);
170
+ }
171
+ recordPipelineDiscard(count = 1) {
172
+ this.pipelineDiscards.add(count);
173
+ }
174
+ recordPipelineParentCheckpointMismatch(reason) {
175
+ this.pipelineParentCheckpointMismatches.add(1, {
176
+ [Attributes.ERROR_TYPE]: reason
177
+ });
178
+ }
129
179
  incOpenSlot(slot, proposer) {
130
180
  // sequencer went through the loop a second time. Noop
131
181
  if (slot === this.lastSeenSlot) {
@@ -153,6 +203,9 @@ export class SequencerMetrics {
153
203
  }
154
204
  }
155
205
  }
206
+ recordCheckpointSuccess() {
207
+ this.checkpointSuccess.add(1);
208
+ }
156
209
  recordBlockProposalFailed(reason) {
157
210
  this.blockProposalFailed.add(1, {
158
211
  ...reason && {
@@ -160,15 +213,131 @@ export class SequencerMetrics {
160
213
  }
161
214
  });
162
215
  }
163
- recordBlockProposalSuccess() {
164
- this.blockProposalSuccess.add(1);
216
+ recordCheckpointProposalSuccess() {
217
+ this.checkpointProposalSuccess.add(1);
165
218
  }
166
- recordBlockProposalPrecheckFailed(checkType) {
167
- this.blockProposalPrecheckFailed.add(1, {
219
+ recordCheckpointPrecheckFailed(checkType) {
220
+ this.checkpointPrecheckFailed.add(1, {
168
221
  [Attributes.ERROR_TYPE]: checkType
169
222
  });
170
223
  }
224
+ recordCheckpointProposalFailed(reason) {
225
+ this.checkpointProposalFailed.add(1, {
226
+ ...reason && {
227
+ [Attributes.ERROR_TYPE]: reason
228
+ }
229
+ });
230
+ }
171
231
  recordSlashingAttempt(actionCount) {
172
232
  this.slashingAttempts.add(actionCount);
173
233
  }
234
+ /**
235
+ * Records metrics for a completed fisherman fee analysis
236
+ * @param analysis - The completed fee analysis result
237
+ */ recordFishermanFeeAnalysis(analysis) {
238
+ // In fisherman mode, we should always have strategy results
239
+ if (!analysis.computedPrices.strategyResults || analysis.computedPrices.strategyResults.length === 0) {
240
+ // This should never happen in fisherman mode - log an error
241
+ // We don't record metrics without strategy IDs as that defeats the purpose
242
+ throw new Error(`No strategy results found in fisherman fee analysis ${analysis.id}. This indicates a bug in the fee analysis.`);
243
+ }
244
+ // Record metrics for each strategy separately
245
+ for (const strategyResult of analysis.computedPrices.strategyResults){
246
+ const strategyAttributes = {
247
+ [Attributes.FISHERMAN_FEE_STRATEGY_ID]: strategyResult.strategyId
248
+ };
249
+ // Record pending block snapshot data (once per strategy for comparison)
250
+ this.fishermanPendingBlobTxCount.record(analysis.pendingSnapshot.pendingBlobTxCount, strategyAttributes);
251
+ this.fishermanPendingBlobCount.record(analysis.pendingSnapshot.pendingBlobCount, strategyAttributes);
252
+ // Record mined block data if available
253
+ if (analysis.minedBlock) {
254
+ this.fishermanIncludedBlobTxCount.record(analysis.minedBlock.includedBlobTxCount, strategyAttributes);
255
+ this.fishermanIncludedBlobCount.record(analysis.minedBlock.includedBlobCount, strategyAttributes);
256
+ // Record actual fees from blob transactions in the mined block
257
+ for (const blobTx of analysis.minedBlock.includedBlobTxs){
258
+ // Record priority fee per gas in Gwei
259
+ const priorityFeeGwei = Number(blobTx.maxPriorityFeePerGas) / 1e9;
260
+ this.fishermanMinedBlobTxPriorityFee.record(priorityFeeGwei, strategyAttributes);
261
+ // Calculate total cost in ETH
262
+ // Cost = (gas * (baseFee + priorityFee)) + (blobCount * blobGasPerBlob * blobBaseFee)
263
+ const baseFee = analysis.minedBlock.baseFeePerGas;
264
+ const effectiveGasPrice = baseFee + blobTx.maxPriorityFeePerGas;
265
+ // Calculate execution cost using actual gas limit from the transaction
266
+ const executionCost = blobTx.gas * effectiveGasPrice;
267
+ // Calculate blob cost using maxFeePerBlobGas * blobCount * GAS_PER_BLOB
268
+ const blobCost = blobTx.maxFeePerBlobGas * BigInt(blobTx.blobCount) * 131072n; // 128KB per blob
269
+ const totalCostWei = executionCost + blobCost;
270
+ const totalCostEth = Number(totalCostWei) / 1e18;
271
+ this.fishermanMinedBlobTxTotalCost.record(totalCostEth, strategyAttributes);
272
+ }
273
+ }
274
+ // Record the calculated priority fee for this strategy
275
+ const calculatedPriorityFeeGwei = Number(strategyResult.calculatedPriorityFee) / 1e9;
276
+ this.fishermanCalculatedPriorityFee.record(calculatedPriorityFeeGwei, strategyAttributes);
277
+ // Record analysis results if available
278
+ if (analysis.analysis) {
279
+ this.fishermanTimeBeforeBlock.record(Math.ceil(analysis.analysis.timeBeforeBlockMs), strategyAttributes);
280
+ // Record whether the block reached 100% blob capacity
281
+ if (analysis.analysis.blockBlobsFull) {
282
+ this.fishermanBlockBlobsFull.add(1, {
283
+ ...strategyAttributes,
284
+ [Attributes.OK]: true
285
+ });
286
+ } else {
287
+ this.fishermanBlockBlobsFull.add(1, {
288
+ ...strategyAttributes,
289
+ [Attributes.OK]: false
290
+ });
291
+ }
292
+ // Record the max blob capacity for this block
293
+ this.fishermanMaxBlobCapacity.record(analysis.analysis.maxBlobCapacity, strategyAttributes);
294
+ // Record strategy-specific inclusion result
295
+ if (strategyResult.wouldBeIncluded !== undefined) {
296
+ const inclusionAttributes = {
297
+ ...strategyAttributes,
298
+ [Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false'
299
+ };
300
+ if (strategyResult.wouldBeIncluded) {
301
+ this.fishermanWouldBeIncluded.add(1, {
302
+ ...inclusionAttributes,
303
+ [Attributes.OK]: true
304
+ });
305
+ } else {
306
+ this.fishermanWouldBeIncluded.add(1, {
307
+ ...inclusionAttributes,
308
+ [Attributes.OK]: false,
309
+ ...strategyResult.exclusionReason && {
310
+ [Attributes.ERROR_TYPE]: strategyResult.exclusionReason
311
+ }
312
+ });
313
+ }
314
+ }
315
+ // Record strategy-specific priority fee delta
316
+ if (strategyResult.priorityFeeDelta !== undefined) {
317
+ const priorityFeeDeltaGwei = Number(strategyResult.priorityFeeDelta) / 1e9;
318
+ const deltaAttributes = {
319
+ ...strategyAttributes,
320
+ [Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false'
321
+ };
322
+ this.fishermanPriorityFeeDelta.record(priorityFeeDeltaGwei, deltaAttributes);
323
+ }
324
+ // Record estimated cost if available
325
+ if (strategyResult.estimatedCostEth !== undefined) {
326
+ const costAttributes = {
327
+ ...strategyAttributes,
328
+ [Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false'
329
+ };
330
+ this.fishermanEstimatedCost.record(strategyResult.estimatedCostEth, costAttributes);
331
+ }
332
+ // Record estimated overpayment if available
333
+ if (strategyResult.estimatedOverpaymentEth !== undefined) {
334
+ const overpaymentAttributes = {
335
+ ...strategyAttributes,
336
+ [Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false'
337
+ };
338
+ this.fishermanEstimatedOverpayment.record(strategyResult.estimatedOverpaymentEth, overpaymentAttributes);
339
+ }
340
+ }
341
+ }
342
+ }
174
343
  }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Tracks fire-and-forget requests so a shutdown path can interrupt any in-flight work and await it to
3
+ * settle. Each tracked request is a promise plus an optional interrupt callback; the entry removes itself
4
+ * from the bag once its promise settles, so the tracker only ever holds requests that are still in flight.
5
+ */
6
+ export declare class RequestsTracker {
7
+ private readonly requests;
8
+ private nextId;
9
+ /** Number of in-flight requests currently tracked. */
10
+ get size(): number;
11
+ /**
12
+ * Tracks a fire-and-forget request. `interrupt`, when provided, is invoked by {@link interruptRequests}
13
+ * to cancel the in-flight work so its promise settles promptly. The entry auto-removes once `promise`
14
+ * settles, whether it resolves or rejects.
15
+ */
16
+ trackRequest(promise: Promise<unknown>, interrupt?: () => void): void;
17
+ /** Interrupts every in-flight request that was tracked with an interrupt callback. */
18
+ interruptRequests(): void;
19
+ /** Awaits every currently in-flight request to settle. */
20
+ awaitRequests(): Promise<void>;
21
+ }
22
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVxdWVzdHNfdHJhY2tlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NlcXVlbmNlci9yZXF1ZXN0c190cmFja2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBOzs7O0dBSUc7QUFDSCxxQkFBYSxlQUFlO0lBQzFCLE9BQU8sQ0FBQyxRQUFRLENBQUMsUUFBUSxDQUFxQztJQUM5RCxPQUFPLENBQUMsTUFBTSxDQUFLO0lBRW5CLHNEQUFzRDtJQUN0RCxJQUFXLElBQUksSUFBSSxNQUFNLENBRXhCO0lBRUQ7Ozs7T0FJRztJQUNJLFlBQVksQ0FBQyxPQUFPLEVBQUUsT0FBTyxDQUFDLE9BQU8sQ0FBQyxFQUFFLFNBQVMsQ0FBQyxFQUFFLE1BQU0sSUFBSSxHQUFHLElBQUksQ0FPM0U7SUFFRCxzRkFBc0Y7SUFDL0UsaUJBQWlCLElBQUksSUFBSSxDQUkvQjtJQUVELDBEQUEwRDtJQUM3QyxhQUFhLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUUxQztDQUNGIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requests_tracker.d.ts","sourceRoot":"","sources":["../../src/sequencer/requests_tracker.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqC;IAC9D,OAAO,CAAC,MAAM,CAAK;IAEnB,sDAAsD;IACtD,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;;OAIG;IACI,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI,CAO3E;IAED,sFAAsF;IAC/E,iBAAiB,IAAI,IAAI,CAI/B;IAED,0DAA0D;IAC7C,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAE1C;CACF"}
@@ -0,0 +1,33 @@
1
+ /** A tracked request: the awaitable to wait on, plus an optional interrupt to cancel it early. */ /**
2
+ * Tracks fire-and-forget requests so a shutdown path can interrupt any in-flight work and await it to
3
+ * settle. Each tracked request is a promise plus an optional interrupt callback; the entry removes itself
4
+ * from the bag once its promise settles, so the tracker only ever holds requests that are still in flight.
5
+ */ export class RequestsTracker {
6
+ requests = new Map();
7
+ nextId = 0;
8
+ /** Number of in-flight requests currently tracked. */ get size() {
9
+ return this.requests.size;
10
+ }
11
+ /**
12
+ * Tracks a fire-and-forget request. `interrupt`, when provided, is invoked by {@link interruptRequests}
13
+ * to cancel the in-flight work so its promise settles promptly. The entry auto-removes once `promise`
14
+ * settles, whether it resolves or rejects.
15
+ */ trackRequest(promise, interrupt) {
16
+ const id = this.nextId++;
17
+ const settled = promise.then(()=>this.requests.delete(id), ()=>this.requests.delete(id));
18
+ this.requests.set(id, {
19
+ promise: settled,
20
+ interrupt
21
+ });
22
+ }
23
+ /** Interrupts every in-flight request that was tracked with an interrupt callback. */ interruptRequests() {
24
+ for (const { interrupt } of this.requests.values()){
25
+ interrupt?.();
26
+ }
27
+ }
28
+ /** Awaits every currently in-flight request to settle. */ async awaitRequests() {
29
+ await Promise.all([
30
+ ...this.requests.values()
31
+ ].map((request)=>request.promise));
32
+ }
33
+ }