@aztec/sequencer-client 0.0.1-commit.135b523 → 0.0.1-commit.181e2d196

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 (70) hide show
  1. package/dest/client/sequencer-client.d.ts +12 -7
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +15 -4
  4. package/dest/config.d.ts +3 -4
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +29 -19
  7. package/dest/global_variable_builder/global_builder.d.ts +2 -4
  8. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  9. package/dest/publisher/config.d.ts +35 -17
  10. package/dest/publisher/config.d.ts.map +1 -1
  11. package/dest/publisher/config.js +106 -42
  12. package/dest/publisher/index.d.ts +2 -1
  13. package/dest/publisher/index.d.ts.map +1 -1
  14. package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
  15. package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
  16. package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
  17. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +59 -0
  18. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
  19. package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
  20. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
  21. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
  22. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
  23. package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
  24. package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
  25. package/dest/publisher/l1_tx_failed_store/index.js +2 -0
  26. package/dest/publisher/sequencer-publisher-factory.d.ts +11 -3
  27. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  28. package/dest/publisher/sequencer-publisher-factory.js +27 -2
  29. package/dest/publisher/sequencer-publisher.d.ts +26 -7
  30. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  31. package/dest/publisher/sequencer-publisher.js +299 -30
  32. package/dest/sequencer/checkpoint_proposal_job.d.ts +7 -1
  33. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  34. package/dest/sequencer/checkpoint_proposal_job.js +99 -53
  35. package/dest/sequencer/metrics.d.ts +17 -5
  36. package/dest/sequencer/metrics.d.ts.map +1 -1
  37. package/dest/sequencer/metrics.js +86 -15
  38. package/dest/sequencer/sequencer.d.ts +20 -8
  39. package/dest/sequencer/sequencer.d.ts.map +1 -1
  40. package/dest/sequencer/sequencer.js +30 -27
  41. package/dest/sequencer/timetable.d.ts +1 -4
  42. package/dest/sequencer/timetable.d.ts.map +1 -1
  43. package/dest/sequencer/timetable.js +2 -5
  44. package/dest/test/index.d.ts +3 -5
  45. package/dest/test/index.d.ts.map +1 -1
  46. package/dest/test/mock_checkpoint_builder.d.ts +5 -3
  47. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  48. package/dest/test/mock_checkpoint_builder.js +6 -4
  49. package/dest/test/utils.d.ts +3 -3
  50. package/dest/test/utils.d.ts.map +1 -1
  51. package/dest/test/utils.js +5 -4
  52. package/package.json +28 -28
  53. package/src/client/sequencer-client.ts +25 -7
  54. package/src/config.ts +40 -27
  55. package/src/global_variable_builder/global_builder.ts +1 -1
  56. package/src/publisher/config.ts +121 -43
  57. package/src/publisher/index.ts +3 -0
  58. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  59. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
  60. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
  61. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  62. package/src/publisher/sequencer-publisher-factory.ts +38 -6
  63. package/src/publisher/sequencer-publisher.ts +300 -43
  64. package/src/sequencer/checkpoint_proposal_job.ts +135 -48
  65. package/src/sequencer/metrics.ts +92 -18
  66. package/src/sequencer/sequencer.ts +40 -32
  67. package/src/sequencer/timetable.ts +7 -6
  68. package/src/test/index.ts +2 -4
  69. package/src/test/mock_checkpoint_builder.ts +12 -1
  70. package/src/test/utils.ts +5 -2
@@ -9,6 +9,11 @@ import {
9
9
  SlotNumber,
10
10
  } from '@aztec/foundation/branded-types';
11
11
  import { randomInt } from '@aztec/foundation/crypto/random';
12
+ import {
13
+ flipSignature,
14
+ generateRecoverableSignature,
15
+ generateUnrecoverableSignature,
16
+ } from '@aztec/foundation/crypto/secp256k1-signer';
12
17
  import { Fr } from '@aztec/foundation/curves/bn254';
13
18
  import { EthAddress } from '@aztec/foundation/eth-address';
14
19
  import { Signature } from '@aztec/foundation/eth-signature';
@@ -38,7 +43,7 @@ import {
38
43
  } from '@aztec/stdlib/interfaces/server';
39
44
  import { type L1ToL2MessageSource, computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
40
45
  import type { BlockProposalOptions, CheckpointProposal, CheckpointProposalOptions } from '@aztec/stdlib/p2p';
41
- import { orderAttestations } from '@aztec/stdlib/p2p';
46
+ import { orderAttestations, trimAttestations } from '@aztec/stdlib/p2p';
42
47
  import type { L2BlockBuiltStats } from '@aztec/stdlib/stats';
43
48
  import { type FailedTx, Tx } from '@aztec/stdlib/tx';
44
49
  import { AttestationTimeoutError } from '@aztec/stdlib/validators';
@@ -129,7 +134,7 @@ export class CheckpointProposalJob implements Traceable {
129
134
  await Promise.all(votesPromises);
130
135
 
131
136
  if (checkpoint) {
132
- this.metrics.recordBlockProposalSuccess();
137
+ this.metrics.recordCheckpointProposalSuccess();
133
138
  }
134
139
 
135
140
  // Do not post anything to L1 if we are fishermen, but do perform L1 fee analysis
@@ -186,18 +191,21 @@ export class CheckpointProposalJob implements Traceable {
186
191
  const inHash = computeInHashFromL1ToL2Messages(l1ToL2Messages);
187
192
 
188
193
  // Collect the out hashes of all the checkpoints before this one in the same epoch
189
- const previousCheckpoints = (await this.l2BlockSource.getCheckpointsForEpoch(this.epoch)).filter(
190
- c => c.number < this.checkpointNumber,
191
- );
192
- const previousCheckpointOutHashes = previousCheckpoints.map(c => c.getCheckpointOutHash());
194
+ const previousCheckpointOutHashes = (await this.l2BlockSource.getCheckpointsDataForEpoch(this.epoch))
195
+ .filter(c => c.checkpointNumber < this.checkpointNumber)
196
+ .map(c => c.checkpointOutHash);
197
+
198
+ // Get the fee asset price modifier from the oracle
199
+ const feeAssetPriceModifier = await this.publisher.getFeeAssetPriceModifier();
193
200
 
194
201
  // Create a long-lived forked world state for the checkpoint builder
195
- using fork = await this.worldState.fork(this.syncedToBlockNumber, { closeDelayMs: 12_000 });
202
+ await using fork = await this.worldState.fork(this.syncedToBlockNumber, { closeDelayMs: 12_000 });
196
203
 
197
204
  // Create checkpoint builder for the entire slot
198
205
  const checkpointBuilder = await this.checkpointsBuilder.startCheckpoint(
199
206
  this.checkpointNumber,
200
207
  checkpointGlobalVariables,
208
+ feeAssetPriceModifier,
201
209
  l1ToL2Messages,
202
210
  previousCheckpointOutHashes,
203
211
  fork,
@@ -217,6 +225,7 @@ export class CheckpointProposalJob implements Traceable {
217
225
 
218
226
  let blocksInCheckpoint: L2Block[] = [];
219
227
  let blockPendingBroadcast: { block: L2Block; txs: Tx[] } | undefined = undefined;
228
+ const checkpointBuildTimer = new Timer();
220
229
 
221
230
  try {
222
231
  // Main loop: build blocks for the checkpoint
@@ -232,19 +241,7 @@ export class CheckpointProposalJob implements Traceable {
232
241
  // These errors are expected in HA mode, so we yield and let another HA node handle the slot
233
242
  // The only distinction between the 2 errors is SlashingProtectionError throws when the payload is different,
234
243
  // which is normal for block building (may have picked different txs)
235
- if (err instanceof DutyAlreadySignedError) {
236
- this.log.info(`Checkpoint proposal for slot ${this.slot} already signed by another HA node, yielding`, {
237
- slot: this.slot,
238
- signedByNode: err.signedByNode,
239
- });
240
- return undefined;
241
- }
242
- if (err instanceof SlashingProtectionError) {
243
- this.log.info(`Checkpoint proposal for slot ${this.slot} blocked by slashing protection, yielding`, {
244
- slot: this.slot,
245
- existingMessageHash: err.existingMessageHash,
246
- attemptedMessageHash: err.attemptedMessageHash,
247
- });
244
+ if (this.handleHASigningError(err, 'Block proposal')) {
248
245
  return undefined;
249
246
  }
250
247
  throw err;
@@ -256,11 +253,28 @@ export class CheckpointProposalJob implements Traceable {
256
253
  return undefined;
257
254
  }
258
255
 
256
+ const minBlocksForCheckpoint = this.config.minBlocksForCheckpoint;
257
+ if (minBlocksForCheckpoint !== undefined && blocksInCheckpoint.length < minBlocksForCheckpoint) {
258
+ this.log.warn(
259
+ `Checkpoint has fewer blocks than minimum (${blocksInCheckpoint.length} < ${minBlocksForCheckpoint}), skipping proposal`,
260
+ { slot: this.slot, blocksBuilt: blocksInCheckpoint.length, minBlocksForCheckpoint },
261
+ );
262
+ return undefined;
263
+ }
264
+
259
265
  // Assemble and broadcast the checkpoint proposal, including the last block that was not
260
266
  // broadcasted yet, and wait to collect the committee attestations.
261
267
  this.setStateFn(SequencerState.ASSEMBLING_CHECKPOINT, this.slot);
262
268
  const checkpoint = await checkpointBuilder.completeCheckpoint();
263
269
 
270
+ // Record checkpoint-level build metrics
271
+ this.metrics.recordCheckpointBuild(
272
+ checkpointBuildTimer.ms(),
273
+ blocksInCheckpoint.length,
274
+ checkpoint.getStats().txCount,
275
+ Number(checkpoint.header.totalManaUsed.toBigInt()),
276
+ );
277
+
264
278
  // Do not collect attestations nor publish to L1 in fisherman mode
265
279
  if (this.config.fishermanMode) {
266
280
  this.log.info(
@@ -287,6 +301,7 @@ export class CheckpointProposalJob implements Traceable {
287
301
  const proposal = await this.validatorClient.createCheckpointProposal(
288
302
  checkpoint.header,
289
303
  checkpoint.archive.root,
304
+ feeAssetPriceModifier,
290
305
  lastBlock,
291
306
  this.proposer,
292
307
  checkpointProposalOptions,
@@ -313,20 +328,8 @@ export class CheckpointProposalJob implements Traceable {
313
328
  );
314
329
  } catch (err) {
315
330
  // We shouldn't really get here since we yield to another HA node
316
- // as soon as we see these errors when creating block proposals.
317
- if (err instanceof DutyAlreadySignedError) {
318
- this.log.info(`Attestations signature for slot ${this.slot} already signed by another HA node, yielding`, {
319
- slot: this.slot,
320
- signedByNode: err.signedByNode,
321
- });
322
- return undefined;
323
- }
324
- if (err instanceof SlashingProtectionError) {
325
- this.log.info(`Attestations signature for slot ${this.slot} blocked by slashing protection, yielding`, {
326
- slot: this.slot,
327
- existingMessageHash: err.existingMessageHash,
328
- attemptedMessageHash: err.attemptedMessageHash,
329
- });
331
+ // as soon as we see these errors when creating block or checkpoint proposals.
332
+ if (this.handleHASigningError(err, 'Attestations signature')) {
330
333
  return undefined;
331
334
  }
332
335
  throw err;
@@ -337,6 +340,21 @@ export class CheckpointProposalJob implements Traceable {
337
340
  const aztecSlotDuration = this.l1Constants.slotDuration;
338
341
  const slotStartBuildTimestamp = this.getSlotStartBuildTimestamp();
339
342
  const txTimeoutAt = new Date((slotStartBuildTimestamp + aztecSlotDuration) * 1000);
343
+
344
+ // If we have been configured to potentially skip publishing checkpoint then roll the dice here
345
+ if (
346
+ this.config.skipPublishingCheckpointsPercent !== undefined &&
347
+ this.config.skipPublishingCheckpointsPercent > 0
348
+ ) {
349
+ const result = Math.max(0, randomInt(100));
350
+ if (result < this.config.skipPublishingCheckpointsPercent) {
351
+ this.log.warn(
352
+ `Skipping publishing proposal for checkpoint ${checkpoint.number}. Configured percentage: ${this.config.skipPublishingCheckpointsPercent}, generated value: ${result}`,
353
+ );
354
+ return checkpoint;
355
+ }
356
+ }
357
+
340
358
  await this.publisher.enqueueProposeCheckpoint(checkpoint, attestations, attestationsSignature, {
341
359
  txTimeoutAt,
342
360
  forcePendingCheckpointNumber: this.invalidateCheckpoint?.forcePendingCheckpointNumber,
@@ -540,7 +558,7 @@ export class CheckpointProposalJob implements Traceable {
540
558
  // Create iterator to pending txs. We filter out txs already included in previous blocks in the checkpoint
541
559
  // just in case p2p failed to sync the provisional block and didn't get to remove those txs from the mempool yet.
542
560
  const pendingTxs = filter(
543
- this.p2pClient.iteratePendingTxs(),
561
+ this.p2pClient.iterateEligiblePendingTxs(),
544
562
  tx => !txHashesAlreadyIncluded.has(tx.txHash.toString()),
545
563
  );
546
564
 
@@ -674,7 +692,7 @@ export class CheckpointProposalJob implements Traceable {
674
692
  `Waiting for enough txs to build block ${blockNumber} at index ${indexWithinCheckpoint} in slot ${this.slot} (have ${availableTxs} but need ${minTxs})`,
675
693
  { blockNumber, slot: this.slot, indexWithinCheckpoint },
676
694
  );
677
- await sleep(TXS_POLLING_MS);
695
+ await this.waitForTxsPollingInterval();
678
696
  availableTxs = await this.p2pClient.getPendingTxCount();
679
697
  }
680
698
 
@@ -730,11 +748,28 @@ export class CheckpointProposalJob implements Traceable {
730
748
 
731
749
  collectedAttestationsCount = attestations.length;
732
750
 
751
+ // Trim attestations to minimum required to save L1 calldata gas
752
+ const localAddresses = this.validatorClient.getValidatorAddresses();
753
+ const trimmed = trimAttestations(
754
+ attestations,
755
+ numberOfRequiredAttestations,
756
+ this.attestorAddress,
757
+ localAddresses,
758
+ );
759
+ if (trimmed.length < attestations.length) {
760
+ this.log.debug(`Trimmed attestations from ${attestations.length} to ${trimmed.length} for L1 submission`);
761
+ }
762
+
733
763
  // Rollup contract requires that the signatures are provided in the order of the committee
734
- const sorted = orderAttestations(attestations, committee);
764
+ const sorted = orderAttestations(trimmed, committee);
735
765
 
736
766
  // Manipulate the attestations if we've been configured to do so
737
- if (this.config.injectFakeAttestation || this.config.shuffleAttestationOrdering) {
767
+ if (
768
+ this.config.injectFakeAttestation ||
769
+ this.config.injectHighSValueAttestation ||
770
+ this.config.injectUnrecoverableSignatureAttestation ||
771
+ this.config.shuffleAttestationOrdering
772
+ ) {
738
773
  return this.manipulateAttestations(proposal.slotNumber, epoch, seed, committee, sorted);
739
774
  }
740
775
 
@@ -763,7 +798,11 @@ export class CheckpointProposalJob implements Traceable {
763
798
  this.epochCache.computeProposerIndex(slotNumber, epoch, seed, BigInt(committee.length)),
764
799
  );
765
800
 
766
- if (this.config.injectFakeAttestation) {
801
+ if (
802
+ this.config.injectFakeAttestation ||
803
+ this.config.injectHighSValueAttestation ||
804
+ this.config.injectUnrecoverableSignatureAttestation
805
+ ) {
767
806
  // Find non-empty attestations that are not from the proposer
768
807
  const nonProposerIndices: number[] = [];
769
808
  for (let i = 0; i < attestations.length; i++) {
@@ -773,8 +812,20 @@ export class CheckpointProposalJob implements Traceable {
773
812
  }
774
813
  if (nonProposerIndices.length > 0) {
775
814
  const targetIndex = nonProposerIndices[randomInt(nonProposerIndices.length)];
776
- this.log.warn(`Injecting fake attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`);
777
- unfreeze(attestations[targetIndex]).signature = Signature.random();
815
+ if (this.config.injectHighSValueAttestation) {
816
+ this.log.warn(
817
+ `Injecting high-s value attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`,
818
+ );
819
+ unfreeze(attestations[targetIndex]).signature = flipSignature(attestations[targetIndex].signature);
820
+ } else if (this.config.injectUnrecoverableSignatureAttestation) {
821
+ this.log.warn(
822
+ `Injecting unrecoverable signature attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`,
823
+ );
824
+ unfreeze(attestations[targetIndex]).signature = generateUnrecoverableSignature();
825
+ } else {
826
+ this.log.warn(`Injecting fake attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`);
827
+ unfreeze(attestations[targetIndex]).signature = generateRecoverableSignature();
828
+ }
778
829
  }
779
830
  return new CommitteeAttestationsAndSigners(attestations);
780
831
  }
@@ -783,11 +834,20 @@ export class CheckpointProposalJob implements Traceable {
783
834
  this.log.warn(`Shuffling attestation ordering in checkpoint for slot ${slotNumber} (proposer #${proposerIndex})`);
784
835
 
785
836
  const shuffled = [...attestations];
786
- const [i, j] = [(proposerIndex + 1) % shuffled.length, (proposerIndex + 2) % shuffled.length];
787
- const valueI = shuffled[i];
788
- const valueJ = shuffled[j];
789
- shuffled[i] = valueJ;
790
- shuffled[j] = valueI;
837
+
838
+ // Find two non-proposer positions that both have non-empty signatures to swap.
839
+ // This ensures the bitmap doesn't change, so the MaliciousCommitteeAttestationsAndSigners
840
+ // signers array stays correctly aligned with L1's committee reconstruction.
841
+ const swappable: number[] = [];
842
+ for (let k = 0; k < shuffled.length; k++) {
843
+ if (!shuffled[k].signature.isEmpty() && k !== proposerIndex) {
844
+ swappable.push(k);
845
+ }
846
+ }
847
+ if (swappable.length >= 2) {
848
+ const [i, j] = [swappable[0], swappable[1]];
849
+ [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
850
+ }
791
851
 
792
852
  const signers = new CommitteeAttestationsAndSigners(attestations).getSigners();
793
853
  return new MaliciousCommitteeAttestationsAndSigners(shuffled, signers);
@@ -803,7 +863,7 @@ export class CheckpointProposalJob implements Traceable {
803
863
  const failedTxData = failedTxs.map(fail => fail.tx);
804
864
  const failedTxHashes = failedTxData.map(tx => tx.getTxHash());
805
865
  this.log.verbose(`Dropping failed txs ${failedTxHashes.join(', ')}`);
806
- await this.p2pClient.deleteTxs(failedTxHashes);
866
+ await this.p2pClient.handleFailedExecution(failedTxHashes);
807
867
  }
808
868
 
809
869
  /**
@@ -845,12 +905,34 @@ export class CheckpointProposalJob implements Traceable {
845
905
  slot: this.slot,
846
906
  feeAnalysisId: feeAnalysis?.id,
847
907
  });
848
- this.metrics.recordBlockProposalFailed('block_build_failed');
908
+ this.metrics.recordCheckpointProposalFailed('block_build_failed');
849
909
  }
850
910
 
851
911
  this.publisher.clearPendingRequests();
852
912
  }
853
913
 
914
+ /**
915
+ * Helper to handle HA double-signing errors. Returns true if the error was handled (caller should yield).
916
+ */
917
+ private handleHASigningError(err: any, errorContext: string): boolean {
918
+ if (err instanceof DutyAlreadySignedError) {
919
+ this.log.info(`${errorContext} for slot ${this.slot} already signed by another HA node, yielding`, {
920
+ slot: this.slot,
921
+ signedByNode: err.signedByNode,
922
+ });
923
+ return true;
924
+ }
925
+ if (err instanceof SlashingProtectionError) {
926
+ this.log.info(`${errorContext} for slot ${this.slot} blocked by slashing protection, yielding`, {
927
+ slot: this.slot,
928
+ existingMessageHash: err.existingMessageHash,
929
+ attemptedMessageHash: err.attemptedMessageHash,
930
+ });
931
+ return true;
932
+ }
933
+ return false;
934
+ }
935
+
854
936
  /** Waits until a specific time within the current slot */
855
937
  @trackSpan('CheckpointProposalJob.waitUntilTimeInSlot')
856
938
  protected async waitUntilTimeInSlot(targetSecondsIntoSlot: number): Promise<void> {
@@ -859,6 +941,11 @@ export class CheckpointProposalJob implements Traceable {
859
941
  await sleepUntil(new Date(targetTimestamp * 1000), this.dateProvider.nowAsDate());
860
942
  }
861
943
 
944
+ /** Waits the polling interval for transactions. Extracted for test overriding. */
945
+ protected async waitForTxsPollingInterval(): Promise<void> {
946
+ await sleep(TXS_POLLING_MS);
947
+ }
948
+
862
949
  private getSlotStartBuildTimestamp(): number {
863
950
  return getSlotStartBuildTimestamp(this.slot, this.l1Constants);
864
951
  }
@@ -18,7 +18,6 @@ import { type Hex, formatUnits } from 'viem';
18
18
 
19
19
  import type { SequencerState } from './utils.js';
20
20
 
21
- // TODO(palla/mbps): Review all metrics and add any missing ones per checkpoint
22
21
  export class SequencerMetrics {
23
22
  public readonly tracer: Tracer;
24
23
  private meter: Meter;
@@ -40,17 +39,26 @@ export class SequencerMetrics {
40
39
  private filledSlots: UpDownCounter;
41
40
 
42
41
  private blockProposalFailed: UpDownCounter;
43
- private blockProposalSuccess: UpDownCounter;
44
- private blockProposalPrecheckFailed: UpDownCounter;
42
+ private checkpointProposalSuccess: UpDownCounter;
43
+ private checkpointPrecheckFailed: UpDownCounter;
44
+ private checkpointProposalFailed: UpDownCounter;
45
45
  private checkpointSuccess: UpDownCounter;
46
46
  private slashingAttempts: UpDownCounter;
47
47
  private checkpointAttestationDelay: Histogram;
48
+ private checkpointBuildDuration: Histogram;
49
+ private checkpointBlockCount: Gauge;
50
+ private checkpointTxCount: Gauge;
51
+ private checkpointTotalMana: Gauge;
48
52
 
49
53
  // Fisherman fee analysis metrics
50
54
  private fishermanWouldBeIncluded: UpDownCounter;
51
55
  private fishermanTimeBeforeBlock: Histogram;
52
56
  private fishermanPendingBlobTxCount: Histogram;
53
57
  private fishermanIncludedBlobTxCount: Histogram;
58
+ private fishermanPendingBlobCount: Histogram;
59
+ private fishermanIncludedBlobCount: Histogram;
60
+ private fishermanBlockBlobsFull: UpDownCounter;
61
+ private fishermanMaxBlobCapacity: Histogram;
54
62
  private fishermanCalculatedPriorityFee: Histogram;
55
63
  private fishermanPriorityFeeDelta: Histogram;
56
64
  private fishermanEstimatedCost: Histogram;
@@ -80,7 +88,7 @@ export class SequencerMetrics {
80
88
 
81
89
  this.checkpointAttestationDelay = this.meter.createHistogram(Metrics.SEQUENCER_CHECKPOINT_ATTESTATION_DELAY);
82
90
 
83
- this.rewards = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_REWARDS);
91
+ this.rewards = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_SLOT_REWARDS);
84
92
 
85
93
  this.slots = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLOT_COUNT);
86
94
 
@@ -103,16 +111,16 @@ export class SequencerMetrics {
103
111
  Metrics.SEQUENCER_BLOCK_PROPOSAL_FAILED_COUNT,
104
112
  );
105
113
 
106
- this.blockProposalSuccess = createUpDownCounterWithDefault(
114
+ this.checkpointProposalSuccess = createUpDownCounterWithDefault(
107
115
  this.meter,
108
- Metrics.SEQUENCER_BLOCK_PROPOSAL_SUCCESS_COUNT,
116
+ Metrics.SEQUENCER_CHECKPOINT_PROPOSAL_SUCCESS_COUNT,
109
117
  );
110
118
 
111
119
  this.checkpointSuccess = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_CHECKPOINT_SUCCESS_COUNT);
112
120
 
113
- this.blockProposalPrecheckFailed = createUpDownCounterWithDefault(
121
+ this.checkpointPrecheckFailed = createUpDownCounterWithDefault(
114
122
  this.meter,
115
- Metrics.SEQUENCER_BLOCK_PROPOSAL_PRECHECK_FAILED_COUNT,
123
+ Metrics.SEQUENCER_CHECKPOINT_PRECHECK_FAILED_COUNT,
116
124
  {
117
125
  [Attributes.ERROR_TYPE]: [
118
126
  'slot_already_taken',
@@ -123,6 +131,16 @@ export class SequencerMetrics {
123
131
  },
124
132
  );
125
133
 
134
+ this.checkpointProposalFailed = createUpDownCounterWithDefault(
135
+ this.meter,
136
+ Metrics.SEQUENCER_CHECKPOINT_PROPOSAL_FAILED_COUNT,
137
+ );
138
+
139
+ this.checkpointBuildDuration = this.meter.createHistogram(Metrics.SEQUENCER_CHECKPOINT_BUILD_DURATION);
140
+ this.checkpointBlockCount = this.meter.createGauge(Metrics.SEQUENCER_CHECKPOINT_BLOCK_COUNT);
141
+ this.checkpointTxCount = this.meter.createGauge(Metrics.SEQUENCER_CHECKPOINT_TX_COUNT);
142
+ this.checkpointTotalMana = this.meter.createGauge(Metrics.SEQUENCER_CHECKPOINT_TOTAL_MANA);
143
+
126
144
  this.slashingAttempts = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLASHING_ATTEMPTS_COUNT);
127
145
 
128
146
  // Fisherman fee analysis metrics
@@ -131,6 +149,7 @@ export class SequencerMetrics {
131
149
  Metrics.FISHERMAN_FEE_ANALYSIS_WOULD_BE_INCLUDED,
132
150
  {
133
151
  [Attributes.OK]: [true, false],
152
+ [Attributes.BLOCK_FULL]: ['true', 'false'],
134
153
  },
135
154
  );
136
155
 
@@ -161,6 +180,20 @@ export class SequencerMetrics {
161
180
  this.fishermanMinedBlobTxTotalCost = this.meter.createHistogram(
162
181
  Metrics.FISHERMAN_FEE_ANALYSIS_MINED_BLOB_TX_TOTAL_COST,
163
182
  );
183
+
184
+ this.fishermanPendingBlobCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PENDING_BLOB_COUNT);
185
+
186
+ this.fishermanIncludedBlobCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_INCLUDED_BLOB_COUNT);
187
+
188
+ this.fishermanBlockBlobsFull = createUpDownCounterWithDefault(
189
+ this.meter,
190
+ Metrics.FISHERMAN_FEE_ANALYSIS_BLOCK_BLOBS_FULL,
191
+ {
192
+ [Attributes.OK]: [true, false],
193
+ },
194
+ );
195
+
196
+ this.fishermanMaxBlobCapacity = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_MAX_BLOB_CAPACITY);
164
197
  }
165
198
 
166
199
  public recordRequiredAttestations(requiredAttestationsCount: number, allowanceMs: number) {
@@ -243,18 +276,30 @@ export class SequencerMetrics {
243
276
  });
244
277
  }
245
278
 
246
- recordBlockProposalSuccess() {
247
- this.blockProposalSuccess.add(1);
279
+ recordCheckpointProposalSuccess() {
280
+ this.checkpointProposalSuccess.add(1);
248
281
  }
249
282
 
250
- recordBlockProposalPrecheckFailed(
283
+ recordCheckpointPrecheckFailed(
251
284
  checkType: 'slot_already_taken' | 'rollup_contract_check_failed' | 'slot_mismatch' | 'block_number_mismatch',
252
285
  ) {
253
- this.blockProposalPrecheckFailed.add(1, {
254
- [Attributes.ERROR_TYPE]: checkType,
286
+ this.checkpointPrecheckFailed.add(1, { [Attributes.ERROR_TYPE]: checkType });
287
+ }
288
+
289
+ recordCheckpointProposalFailed(reason?: string) {
290
+ this.checkpointProposalFailed.add(1, {
291
+ ...(reason && { [Attributes.ERROR_TYPE]: reason }),
255
292
  });
256
293
  }
257
294
 
295
+ /** Records aggregate metrics for a completed checkpoint build. */
296
+ recordCheckpointBuild(durationMs: number, blockCount: number, txCount: number, totalMana: number) {
297
+ this.checkpointBuildDuration.record(Math.ceil(durationMs));
298
+ this.checkpointBlockCount.record(blockCount);
299
+ this.checkpointTxCount.record(txCount);
300
+ this.checkpointTotalMana.record(totalMana);
301
+ }
302
+
258
303
  recordSlashingAttempt(actionCount: number) {
259
304
  this.slashingAttempts.add(actionCount);
260
305
  }
@@ -281,10 +326,12 @@ export class SequencerMetrics {
281
326
 
282
327
  // Record pending block snapshot data (once per strategy for comparison)
283
328
  this.fishermanPendingBlobTxCount.record(analysis.pendingSnapshot.pendingBlobTxCount, strategyAttributes);
329
+ this.fishermanPendingBlobCount.record(analysis.pendingSnapshot.pendingBlobCount, strategyAttributes);
284
330
 
285
331
  // Record mined block data if available
286
332
  if (analysis.minedBlock) {
287
333
  this.fishermanIncludedBlobTxCount.record(analysis.minedBlock.includedBlobTxCount, strategyAttributes);
334
+ this.fishermanIncludedBlobCount.record(analysis.minedBlock.includedBlobCount, strategyAttributes);
288
335
 
289
336
  // Record actual fees from blob transactions in the mined block
290
337
  for (const blobTx of analysis.minedBlock.includedBlobTxs) {
@@ -318,13 +365,28 @@ export class SequencerMetrics {
318
365
  if (analysis.analysis) {
319
366
  this.fishermanTimeBeforeBlock.record(Math.ceil(analysis.analysis.timeBeforeBlockMs), strategyAttributes);
320
367
 
368
+ // Record whether the block reached 100% blob capacity
369
+ if (analysis.analysis.blockBlobsFull) {
370
+ this.fishermanBlockBlobsFull.add(1, { ...strategyAttributes, [Attributes.OK]: true });
371
+ } else {
372
+ this.fishermanBlockBlobsFull.add(1, { ...strategyAttributes, [Attributes.OK]: false });
373
+ }
374
+
375
+ // Record the max blob capacity for this block
376
+ this.fishermanMaxBlobCapacity.record(analysis.analysis.maxBlobCapacity, strategyAttributes);
377
+
321
378
  // Record strategy-specific inclusion result
322
379
  if (strategyResult.wouldBeIncluded !== undefined) {
380
+ const inclusionAttributes = {
381
+ ...strategyAttributes,
382
+ [Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false',
383
+ };
384
+
323
385
  if (strategyResult.wouldBeIncluded) {
324
- this.fishermanWouldBeIncluded.add(1, { ...strategyAttributes, [Attributes.OK]: true });
386
+ this.fishermanWouldBeIncluded.add(1, { ...inclusionAttributes, [Attributes.OK]: true });
325
387
  } else {
326
388
  this.fishermanWouldBeIncluded.add(1, {
327
- ...strategyAttributes,
389
+ ...inclusionAttributes,
328
390
  [Attributes.OK]: false,
329
391
  ...(strategyResult.exclusionReason && { [Attributes.ERROR_TYPE]: strategyResult.exclusionReason }),
330
392
  });
@@ -334,17 +396,29 @@ export class SequencerMetrics {
334
396
  // Record strategy-specific priority fee delta
335
397
  if (strategyResult.priorityFeeDelta !== undefined) {
336
398
  const priorityFeeDeltaGwei = Number(strategyResult.priorityFeeDelta) / 1e9;
337
- this.fishermanPriorityFeeDelta.record(priorityFeeDeltaGwei, strategyAttributes);
399
+ const deltaAttributes = {
400
+ ...strategyAttributes,
401
+ [Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false',
402
+ };
403
+ this.fishermanPriorityFeeDelta.record(priorityFeeDeltaGwei, deltaAttributes);
338
404
  }
339
405
 
340
406
  // Record estimated cost if available
341
407
  if (strategyResult.estimatedCostEth !== undefined) {
342
- this.fishermanEstimatedCost.record(strategyResult.estimatedCostEth, strategyAttributes);
408
+ const costAttributes = {
409
+ ...strategyAttributes,
410
+ [Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false',
411
+ };
412
+ this.fishermanEstimatedCost.record(strategyResult.estimatedCostEth, costAttributes);
343
413
  }
344
414
 
345
415
  // Record estimated overpayment if available
346
416
  if (strategyResult.estimatedOverpaymentEth !== undefined) {
347
- this.fishermanEstimatedOverpayment.record(strategyResult.estimatedOverpaymentEth, strategyAttributes);
417
+ const overpaymentAttributes = {
418
+ ...strategyAttributes,
419
+ [Attributes.BLOCK_FULL]: analysis.analysis.blockBlobsFull ? 'true' : 'false',
420
+ };
421
+ this.fishermanEstimatedOverpayment.record(strategyResult.estimatedOverpaymentEth, overpaymentAttributes);
348
422
  }
349
423
  }
350
424
  }