refactor(blockchain): collapse the greedy selection loop guards - #592
Conversation
Follow-up to #590, which made the coverage tie-break deterministic and left the loop around it with three exits for two conditions. `while !remaining_indices.is_empty()` made the `None` arm of the best-candidate lookup unreachable, and that arm in turn made the `proofs.is_empty()` early return redundant. One `loop` with one exit — no candidate, or none that adds coverage — says the same thing, and `best_count` no longer needs a binding just to be compared against zero. A test pins the empty pool that the early return used to shortcut. Also record in the comment that candidates must stay in ascending order, so the `retain` is not later "optimized" into a `swap_remove` that would reintroduce the arbitrary tie-break #590 removed.
🤖 Kimi Code ReviewThe changes to Consensus Safety (Determinism)
Logic Correctness
Performance
Code Quality
Verdict: Approve. The refactoring is sound, the determinism fix is consensus-critical, and the test coverage is appropriate. Automated review by Kimi (Moonshot AI) · kimi-k2.5 · custom prompt |
🤖 Codex Code ReviewNo blocking findings. The change in crates/blockchain/src/block_builder.rs:804 through :829 is behaviorally equivalent for correctness: an empty The added unit test at crates/blockchain/src/block_builder.rs:1992 is appropriate and directly covers the refactor’s empty-input case. Residual risk: this was a static review only. I couldn’t run Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
🤖 Claude Code ReviewReview: PR 592 — collapse the greedy selection loop guardsThis is a small, well-scoped refactor of Correctness of the refactor itselfThe collapse is behaviorally equivalent to the original:
Good catch pinning the empty-pool path with Finding: the new comment's justification for keeping
|
🗒️ Description / Motivation
Follow-up to #590, which made the coverage tie-break in
extend_proofs_greedilydeterministic and left the loop around it with three exits for two conditions.
What Changed
crates/blockchain/src/block_builder.rswhile !remaining_indices.is_empty()made theNonearm of the best-candidate lookup unreachable, and that arm in turn made theproofs.is_empty()early return redundant. Now oneloopwith one exit — no candidate, or none that adds coverage — andbest_countno longer needs a binding just to be compared against zero. The comment records that candidates must stay in ascending order, so theretainis not later "optimized" into aswap_removethat would reintroduce the arbitrary tie-break #590 removedCorrectness / Behavior Guarantees
Pure refactor — same selection, same order, same stopping point. The removed guards were
unreachable or redundant, not load-bearing.
Tests Added / Run
extend_proofs_greedily_selects_nothing_from_an_empty_poolpins the path the earlyreturn used to shortcut.
make fmt,make lint, and the 68ethlambda-blockchainlib tests — all clean oncurrent main.
Related Issues / PRs
✅ Verification Checklist
make fmt— cleanmake lint(clippy with-D warnings) — cleanmake test(cargo test --workspace --profile release-fast) — all passing