fix(blockchain): count lean_attestations_valid_total on gossip only#522
Conversation
leanSpec defines lean_attestations_valid_total as the running count of attestations that pass all validation checks, paired with lean_attestations_invalid_total (rejected during validation). ethlambda additionally incremented it once per participating validator for every block-included attestation, which: - broke valid/invalid symmetry: invalid is only counted on the gossip validation path, so valid was inflated with no matching invalid path; - double-counted votes already seen and counted on gossip; - mixed units: a gossip aggregate counts as 1, while the same voters count as N when packed into a block. Drop the block-inclusion counting so the counter measures exactly the gossip validation pipeline, matching leanSpec. Votes arriving inside a block remain counted by lean_state_transition_attestations_processed_total. Every remaining call site increments by one, so simplify the helper to a no-argument inc().
🤖 Kimi Code ReviewThe PR correctly fixes a metric semantic issue where block-included attestations were being counted in the gossip validation pipeline counter. The change aligns crates/blockchain/src/metrics.rs:709-716
crates/blockchain/src/store.rs:685-692
Verification needed: Minor suggestion: Overall: Correct and safe change. Automated review by Kimi (Moonshot AI) · kimi-k2.5 · custom prompt |
🤖 Claude Code ReviewThis is a small, well-scoped metrics fix. The change is correct and matches its stated intent. ReviewCorrectness: The fix is sound. Removing the block-inclusion increment in Verification of no leftover dependents: Documentation: The doc comments added (metrics.rs:709-713, store.rs:685-689) clearly explain the invariant and point to the companion counter ( Minor observations (non-blocking):
Overall: a clean, well-justified metrics correctness fix with good commit/PR documentation. No functional or safety concerns. Automated review by Claude (Anthropic) · sonnet · custom prompt |
🤖 Codex Code ReviewFindings
No consensus, fork-choice, or memory-safety issues stood out in this diff beyond the metric-semantics problem above. I couldn’t run Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
Greptile SummaryThis PR makes the valid-attestation metric count successful gossip validations only. The main changes are:
Confidence Score: 5/5This looks safe to merge.
|
| Filename | Overview |
|---|---|
| crates/blockchain/src/metrics.rs | Changes the valid-attestation metric helper from an arbitrary increment to a single increment. |
| crates/blockchain/src/store.rs | Updates both gossip call sites and removes valid-attestation increments from block processing. |
Reviews (1): Last reviewed commit: "fix(blockchain): count lean_attestations..." | Re-trigger Greptile
Problem
lean_attestations_valid_totalis defined by leanSpec as the running count of attestations that pass all validation checks (paired withlean_attestations_invalid_total, "rejected during validation"). It is a validation-pipeline counter; leanSpec increments it once per validated gossip attestation (source="gossip").ethlambda additionally incremented it once per participating validator for every block-included attestation (
on_block_core), which:inc_attestations_invalidonly fires on the gossip validation path (store.rs:391,:479), sovalidwas inflated with no matchinginvalidcounterpart;1, while the same voters count asNwhen packed into a block.Change
Drop the block-inclusion counting so the counter measures exactly the gossip validation pipeline, matching leanSpec. Votes arriving inside a block remain counted by
lean_state_transition_attestations_processed_total. Every remaining call site increments by one, so the helper is simplified to a no-argumentinc().Verification
make fmt,make lint(clean),cargo test -p ethlambda-blockchain(46 unit tests pass), full workspace build. Fork-choice/signature spec tests require downloaded fixtures (absent in this env) and are unaffected by a metrics-only change.