Add lean_attestations_production_time_seconds metric from leanMetrics PR #30#312
Conversation
duration of the full attestation production flow in produce_attestations (attestation data construction, signing, self-delivery, and gossip publish). Implements leanMetrics PR #30 with buckets [0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 0.75, 1] and updates docs/metrics.md.
🤖 Kimi Code ReviewThe PR is straightforward and correct. It follows the existing patterns for metrics in the codebase and properly instruments the Minor issue:
"Time taken to produce attestation",Change to "Time taken to produce attestations" (plural) to match the metric name Verification notes:
Security/Performance: No concerns. The metric uses thread-safe Automated review by Kimi (Moonshot AI) · kimi-k2.5 · custom prompt |
Greptile SummaryThis PR implements the Confidence Score: 5/5Safe to merge — clean, minimal change that follows existing patterns with no logic or correctness issues. All findings are P2 style suggestions. The implementation is correct: the TimingGuard drops at function return capturing the full loop, buckets in code and docs are consistent, and eager registration ensures the metric appears from process start. No files require special attention.
|
| Filename | Overview |
|---|---|
| crates/blockchain/src/metrics.rs | Adds LEAN_ATTESTATIONS_PRODUCTION_TIME_SECONDS histogram with correct buckets, eager-registers it in init(), and exposes time_attestations_production(). Minor: help string uses singular "attestation" while the metric name implies plural. |
| crates/blockchain/src/lib.rs | Instruments produce_attestations() with a TimingGuard at function entry; RAII correctly captures full end-to-end duration including signing and gossip publish for all validators. |
| docs/metrics.md | Adds Buckets column to Validator Metrics table and documents the new histogram with correct bucket values matching the code. |
Sequence Diagram
sequenceDiagram
participant Scheduler
participant BlockChainServer
participant Metrics
participant Store
participant KeyManager
participant Gossip
Scheduler->>BlockChainServer: produce_attestations(slot)
BlockChainServer->>Metrics: time_attestations_production()
Note over Metrics: TimingGuard starts clock
BlockChainServer->>Store: produce_attestation_data(slot)
Store-->>BlockChainServer: attestation_data
loop for each validator_id
BlockChainServer->>KeyManager: sign_attestation(validator_id, data)
KeyManager-->>BlockChainServer: signature
BlockChainServer->>Store: on_gossip_attestation (self-deliver)
BlockChainServer->>Gossip: publish signed_attestation
end
Note over Metrics: TimingGuard dropped → histogram observed
Prompt To Fix All With AI
This is a comment left during a code review.
Path: crates/blockchain/src/metrics.rs
Line: 233
Comment:
**Singular vs. plural in metric description**
The metric name (`lean_attestations_production_time_seconds`) refers to producing attestations for *all* validators in a slot, but the help string says "Time taken to produce attestation" (singular). Other metrics in this file are consistent between their name and description. Consider aligning to "Time taken to produce attestations for all validators in a slot" for clarity.
```suggestion
"Time taken to produce attestations for all validators in a slot",
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "Add lean_attestations_production_time_se..." | Re-trigger Greptile
🤖 Codex Code ReviewNo actionable findings. This PR is observability-only. The new histogram is registered and exposed correctly in metrics.rs, metrics.rs, and metrics.rs, and the added guard in lib.rs does not alter attestation contents, fork choice, justification/finalization, state transition, XMSS verification, or SSZ behavior. Residual note: I could not complete a local Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
🤖 Claude Code ReviewI have everything needed to write the review. Review: PR #312 —
|
Motivation
Implements the
lean_attestations_production_time_secondshistogram defined inleanEthereum/leanMetrics#30,
which measures the end-to-end time a node spends producing attestations
for all its validators in a given slot.
Description
New Metric
lean_attestations_production_time_secondsImplementation
crates/blockchain/src/metrics.rs: registers the histogram under theValidator Metricsfamily and exposestime_attestations_production(),which returns a
TimingGuardthat observes the duration on drop. Addedto the
init()eager-registration list so the metric appears on/metricsfrom process start.crates/blockchain/src/lib.rs: instrumentsproduce_attestations()with
let _timing = metrics::time_attestations_production();at the topof the function, capturing the full flow:
store::produce_attestation_data)on_gossip_attestationDocumentation
docs/metrics.md: adds aBucketscolumn to the Validator Metricstable (consistent with the other tables in the doc) and lists the new
metric alongside
lean_validators_countandlean_is_aggregator.How to Test
make fmt- passesmake lint- passes (clippy clean)make test- passes/metricsendpoint (port 5054):
attestations each slot.
Related
Store::get_attestation_targetfunction #29)