Repository navigation
fix(p2p): stop a congested peer from stalling consensus round-state gossip - #1625
Conversation
Drop state-channel messages when a peer queue is full, count the drop, and complete delivery notifications. A slow peer must not hold up the round-state updates other peers need to send proposals and votes. State messages are retried or advisory; preserve blocking enqueue for other channels whose messages may not be retried. Keep periodic round state refresh intact to recover announcements dropped during congestion. Cover full-queue unicast and broadcast, recovery after draining, drop accounting, and unchanged data/PEX backpressure. <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub> Co-Authored-By: Codex (gpt-6-astra) <[email protected]>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
|
✅ Final review complete — no blockers (commit 8a9ce97) · triage: normal |
Match the debug log the blocking enqueue path emits when the peer queue is closed. <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replace the hardcoded consensus state channel check in routeChannel with a DropOnFullPeerQueue channel descriptor option, enabled for the state channel. <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub> Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The PR correctly removes head-of-line blocking for the consensus state channel while preserving blocking behavior for other channels, and the available code checks passed. Two non-blocking issues remain: VoteSetBits responses use a retry path but remain exposed to the same channel-level blocking, and the new descriptor comment inaccurately describes closed-queue drops.
🟡 1 suggestion(s) | 💬 1 nitpick(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: VoteSetBits responses remain exposed to channel-level head-of-line blocking
internal/p2p/channel_params.go:167-174
VoteSetBits responses use the same per-channel routeChannel goroutine and blocking peer-queue enqueue as before, so one full peer queue can still delay responses to every other peer on channel 0x23. This sibling path is recoverable because sendVoteSetBits gives up after its short timeout and the requesting peer asks again on a later gossip tick, but that recovery mechanism matches the rationale used for the non-blocking state channel. Enable DropOnFullPeerQueue for VoteSetBitsChannel as well, or create a tracked follow-up issue explaining why its remaining backpressure is intentional.
source: muse-spark-1.3-contributor (phase1-reviewer: general)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.1-sol(effort low) — This is a contained but behavior-changing P2P routing and concurrency fix that affects consensus message delivery and backpressure, without directly changing consensus rules or another critical surface listed for the critical tier. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Second Phase-2 pass: on this first full review every Phase-2 reviewer also ran a second, independent time, and the verifier weighed both sets
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— tenderdash-consensus-security (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— tenderdash-consensus-security (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `internal/p2p/channel_params.go`:
- [SUGGESTION] internal/p2p/channel_params.go:167-174: VoteSetBits responses remain exposed to channel-level head-of-line blocking
VoteSetBits responses use the same per-channel routeChannel goroutine and blocking peer-queue enqueue as before, so one full peer queue can still delay responses to every other peer on channel 0x23. This sibling path is recoverable because sendVoteSetBits gives up after its short timeout and the requesting peer asks again on a later gossip tick, but that recovery mechanism matches the rationale used for the non-blocking state channel. Enable DropOnFullPeerQueue for VoteSetBitsChannel as well, or create a tracked follow-up issue explaining why its remaining backpressure is intentional.
In `internal/p2p/conn/connection.go`:
- [NITPICK] internal/p2p/conn/connection.go:666-670: DropOnFullPeerQueue documentation misstates closed-queue drops
The comment says dropped messages are counted and not logged, but the DropOnFullPeerQueue branch also handles closed queues at router.go:379-381. Those drops are logged at debug level and are not added to PeerQueueDroppedMsgs, so the documentation does not describe all behavior controlled by this field.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ate-refresh-stall
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
/skip-bots |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The current head includes the documentation correction for closed-queue drops, and all completed build, test, vet, lint, vulnerability, and protocol checks pass. No new independent issues were identified beyond the carried-forward VoteSetBits routing concern.
🟡 1 suggestion(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: VoteSetBits responses remain exposed to channel-level head-of-line blocking
internal/p2p/channel_params.go:167-174
VoteSetBitsChannel still leaves DropOnFullPeerQueue disabled, so routeChannel uses its blocking enqueue path. A peer that stops reading can fill its shared outbound queue; when a VoteSetBits response for that peer reaches the router, the channel goroutine blocks and responses for healthy peers wait behind it. The five-millisecond sendVoteSetBits timeout only bounds the reactor-to-router handoff and cannot unblock a router goroutine already waiting on the peer queue. This remains part of the recoverable maj23 vote catch-up path described by the PR. Enabling the descriptor flag alone is not sufficient: sendVoteSetBits records the answer whenever Channel.Send returns successfully, but a non-blocking router drop can occur after that handoff, falsely suppressing retries. The channel therefore needs either delivery-aware drop handling or another non-blocking strategy that preserves the retry bookkeeping.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general, tenderdash-consensus-security)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.1-sol(effort low) — This is a contained but behaviorally significant router and concurrency change affecting consensus-state gossip, without modifying consensus rules, cryptography, or peer-facing deserialization. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— tenderdash-consensus-security (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `internal/p2p/channel_params.go`:
- [SUGGESTION] internal/p2p/channel_params.go:167-174: VoteSetBits responses remain exposed to channel-level head-of-line blocking
`VoteSetBitsChannel` still leaves `DropOnFullPeerQueue` disabled, so `routeChannel` uses its blocking enqueue path. A peer that stops reading can fill its shared outbound queue; when a VoteSetBits response for that peer reaches the router, the channel goroutine blocks and responses for healthy peers wait behind it. The five-millisecond `sendVoteSetBits` timeout only bounds the reactor-to-router handoff and cannot unblock a router goroutine already waiting on the peer queue. This remains part of the recoverable maj23 vote catch-up path described by the PR. Enabling the descriptor flag alone is not sufficient: `sendVoteSetBits` records the answer whenever `Channel.Send` returns successfully, but a non-blocking router drop can occur after that handoff, falsely suppressing retries. The channel therefore needs either delivery-aware drop handling or another non-blocking strategy that preserves the retry bookkeeping.
|
Policy satisfied — this can merge. |
TL;DR
A single slow or congested peer could stop a validator from telling its other peers which consensus round it is in. Validators then stopped sending each other proposals and the network got stuck on one height, voting nil round after round. This change makes sure a slow peer only misses its own round-state updates and no longer holds up everyone else's.
User story
As a validator operator, I want my node to keep reaching consensus with healthy peers while one of its peers is slow, to keep the chain producing blocks.
Scenario
Steps to reproduce
Actual behavior
Round-state announcements to every peer are delayed by several seconds. The proposer believes its peers are still in the old round, so it does not send them the proposal. Validators prevote and precommit nil round after round. In CI,
TestReactorValidatorSetChangesfails this way in 4 of 6 runs since #1598, against 0 of about 40 runs before it.Expected behavior
Round-state announcements keep flowing to healthy peers. The congested peer misses some of its own announcements and catches up through the periodic re-announcement added in #1598.
Detailed discussion
Root cause. The router has one
routeChannelgoroutine per channel, and it enqueues each outbound envelope into each target peer's queue with a blocking send (internal/p2p/router.go). When one peer's queue is full, that goroutine blocks, and so does every message on that channel to every other peer: head-of-line blocking. A goroutine dump of a stalledTestReactorValidatorSetChangesrun shows the consensus state channel (0x20) goroutine blocked on that send on 5 of 7 nodes. Timestamped logs showNewRoundSteparriving about 5s late at the stuck height, against 0.1–0.4s before it.Fix. A new channel descriptor option,
DropOnFullPeerQueue, makes the router use a non-blocking enqueue for that channel. It is enabled only forConsensusStateChannel. When the peer queue is full, the router:PeerQueueDroppedMsgs(ch_idlabel).The state-channel messages are either advisory or repeated (
NewRoundStepthrough the periodic refresh from #1598,HasVote,VoteSetMaj23/VoteSetBitsthrough the maj23 query loop), so losing one to a congested peer is recoverable. All other channels keep blocking enqueue, because their messages (proposals, block parts, votes, PEX) are not necessarily retried.Out of scope.
simpleQueuesizing discussed in fix(p2p): trim the simple priority queue below its limit #1597.Tests.
internal/p2p/router_queue_test.gocovers:dev);Results, local,
-race -tags deadlock:devTestReactorValidatorSetChangesTestReactorValidatorSetChangesalso passed once on unmodifieddevlocally, so these local runs do not prove the flake is gone. CI history is the deciding signal.🤖 Co-authored by Claudius the Magnificent AI Agent
🤖 Generated with Claude Code
PR Hygiene ·
8a9ce97internal/p2p/channel_params.go,internal/p2p/conn/connection.go,internal/p2p/router.goand 1 more) — approved by lklimekWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.