fix(consensus): remove double record_block(0) at epoch boundary#764
Conversation
…n_epoch_bookkeeping Callers (main.rs BFT-finalize, libp2p gossip + batch-sync) already call epoch_manager.record_block(reward) before run_epoch_bookkeeping. The extra record_block(0) inside the method incremented total_blocks_produced twice for every boundary block, inflating epoch history by 1 block per rollover. Reported by CodeRabbit on PR #763.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughThis PR removes a single call to Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
CodeRabbit finding on PR #763 — valid.
run_epoch_bookkeepingcalledself.epoch_manager.record_block(0)before pushing the finished epoch to history. But every call site already invokedepoch_manager.record_block(reward)before entering this method. The extrarecord_block(0)incrementedtotal_blocks_producedtwice for every boundary block, so epoch history carried an inflated block count (+1 per rollover).Fix: remove the redundant call. The caller's
record_block(reward)is sufficient.What's not fixed
The second CodeRabbit finding (
process_unbondingdrops releases on transfer failure) is pre-existing behavior, not introduced by PR #763. Fixing it requires changingStakeRegistry::process_unbondingreturn semantics — deferred to a dedicated PR.Test plan
cargo check -p sentrix-core -D warningscleanSummary by CodeRabbit