Repository navigation
fix(blocksync): removeTimedoutPeers deadlock found via Byzantine prevote gossip race - #5839
Conversation
f0776de to
e57476e
Compare
|
@greptile review |
Greptile SummaryThis PR fixes a circular deadlock in
Confidence Score: 4/5Safe to merge; the deadlock fix is correct and the test change removes a known race, with one style concern about panic-safety of explicit mutex unlocks. Both code paths in removeTimedoutPeers and onTimeout now release the mutex before the blocking sendError call, correctly breaking the circular wait. The only open concern is that the explicit pool.mtx.Unlock() call (replacing defer) leaves the lock permanently held if a panic fires in the critical section; a goroutine closure with a deferred unlock would be safer. The Byzantine test change is straightforward and makes the test deterministic. blocksync/pool.go — the explicit mutex unlock pattern in removeTimedoutPeers and onTimeout warrants a second look for panic-safety. Important Files Changed
|
…ote gossip race (cometbft#5839) --- Fix the CI failure at: https://github.com/cometbft/cometbft/actions/runs/25498058929/job/74823025038 That run revealed two issues: 1. removeTimedoutPeers and onTimeout held pool.mtx while calling sendError, which blocks on errorsCh. The reactor loop (the only consumer) may itself wait for pool.mtx via AddBlock, forming a circular deadlock. 2. The split-delivery of conflicting prevotes required gossip to propagate before height 2 committed, which raced under -race. Fix: send both conflicting prevotes to every peer directly so each validator detects the equivocation without relying on gossip timing. Follows up on cometbft#5814 #### PR checklist - [x] Tests written/updated - [ ] Changelog entry added in `CHANGELOG.md` - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments
The byzantine node split its two conflicting prevotes between peers, and the honest validators (3 of 4 equal-power votes) could commit height 2 before gossip carried the other vote to any of them. Late votes are dropped as a height mismatch, so no evidence was ever produced and the test timed out after 20s. Send both votes to every peer and give the byzantine validator 2/5 of the power, so the honest nodes cannot finish height 2 without its prevote and each one sees the conflict. Also stop the block subscribers on Cancelled. Ports upstream cometbft/cometbft#5839, #6041, and #5814.
Fix the CI failure at:
https://github.com/cometbft/cometbft/actions/runs/25498058929/job/74823025038
That run revealed two issues:
removeTimedoutPeers and onTimeout held pool.mtx while calling
sendError, which blocks on errorsCh. The reactor loop (the only
consumer) may itself wait for pool.mtx via AddBlock, forming a
circular deadlock.
The split-delivery of conflicting prevotes required gossip to
propagate before height 2 committed, which raced under -race.
Fix: send both conflicting prevotes to every peer directly so each
validator detects the equivocation without relying on gossip timing.
Follows up on #5814
PR checklist
CHANGELOG.mddocs/orspec/) and code comments