Add lean_attestation_committee_count Prometheus metric#223
Conversation
Expose the attestation committee count as a Prometheus gauge on node start, matching the leanMetrics spec. The value comes from the existing --attestation-committee-count CLI option.
🤖 Kimi Code ReviewReview SummaryThe PR adds a new metric to track the attestation committee count. The implementation is straightforward and follows the existing patterns in the codebase. Issues Found
Positive Aspects
Automated review by Kimi (Moonshot AI) · custom prompt |
🤖 Codex Code Review
Suggested fix:
No other bugs or security/performance regressions are evident in this PR. It only adds metric plumbing and does not modify fork choice, attestation validation, finalization, state transition, XMSS, or SSZ paths. Automated review by OpenAI Codex · custom prompt |
🤖 Claude Code ReviewHere is the review: PR Review: Add
|
Greptile SummaryThis PR implements the
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| crates/blockchain/src/metrics.rs | Adds set_attestation_committee_count(count: u64) as an IntGauge following the established LazyLock pattern; minor style inconsistency using count as i64 instead of count.try_into().unwrap() used by all other u64-typed parameters in this file. |
| bin/ethlambda/src/main.rs | Correctly calls set_attestation_committee_count at node startup alongside the existing set_node_info and set_node_start_time calls, passing the CLI-parsed attestation_committee_count value. |
Sequence Diagram
sequenceDiagram
participant CLI as CLI (CliOptions)
participant Main as main.rs
participant Metrics as metrics.rs (LazyLock)
participant Prometheus as Prometheus Registry
participant HTTP as /metrics endpoint
CLI->>Main: parse() → attestation_committee_count: u64
Main->>Metrics: set_attestation_committee_count(count)
Metrics->>Prometheus: register_int_gauge!("lean_attestation_committee_count") [once]
Metrics->>Prometheus: IntGauge.set(count as i64)
Main->>HTTP: start_rpc_server(metrics_socket, store)
HTTP-->>Prometheus: gather()
Prometheus-->>HTTP: lean_attestation_committee_count <value>
Prompt To Fix All With AI
This is a comment left during a code review.
Path: crates/blockchain/src/metrics.rs
Line: 371
Comment:
**Inconsistent cast for `u64` parameter**
All other functions in this file that accept `u64` (slots, validator count) use `.try_into().unwrap()` for the `i64` conversion, which panics explicitly on overflow instead of silently wrapping. The new code uses `count as i64`, consistent only with the `usize`-based functions (`update_gossip_signatures`, etc.).
For a committee count this will never matter in practice, but it is inconsistent with the existing `u64` pattern in the file:
```suggestion
LEAN_ATTESTATION_COMMITTEE_COUNT.set(count.try_into().unwrap());
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: 0ae64dc
MegaRedHand
left a comment
There was a problem hiding this comment.
We need to update docs/metrics.md
…style - Document the new metric in the Network Metrics table - Use try_into().unwrap() instead of `as i64` for consistency with other u64-to-i64 conversions in the file
A panic in a metrics setter is worse than a theoretical silent wrap on a value that will never exceed i64::MAX in practice.
151f2d0 to
8f065b7
Compare
|
Done — added |
Motivation
The leanMetrics spec defines a `lean_attestation_committee_count` gauge metric (Network Metrics category) that reports the number of attestation committees. It is collected on node start with no labels. No client has implemented it yet.
The Grafana dashboard in leanMetrics already references it:
```
max(lean_attestation_committee_count{job=~"$job"})
```
Description
How to Test
```
curl -s http://localhost:9090/metrics | grep lean_attestation_committee_count
```