Repository navigation
fix(p2p): reconnect persistent peers at outgoing capacity - #1490
Conversation
Use bounded outgoing upgrades for reserved peers and keep delayed retries scheduled while existing connections fill normal capacity. Co-Authored-By: GPT-6 Astra <[email protected]>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository: dashpay/tenderdash/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
|
|
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Revalidate reserved upgrade probes when the initially selected victim disconnects.
Review effort: Lite
Findings: None
What changed in this PR
Fixes persistent-peer reconnection when outgoing capacity is saturated.
Changes:
- Adds bounded reserved-peer upgrade probes.
- Tracks pending dials and revalidates capacity.
- Improves retry timers, wakeups, and regression coverage.
| File | Description |
|---|---|
internal/p2p/peermanager.go |
Implements outgoing upgrades and retry scheduling; one moderate issue remains regarding probe revalidation. |
internal/p2p/peermanager_retry_test.go |
Tests retry timing, cancellation, and wakeups. |
internal/p2p/peermanager_reconnect_test.go |
Tests persistent reconnection and upgrade behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Document tryDialNext's return contract and findUpgradeCandidate's direction parameter, share upgradeDirection between tryDialNext and Dialed, and align the max-outgoing-connections config docs and the DoS spec with the reserved-peer probing behavior. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Cover outgoing-capacity rejection paths and protected upgrades while making retry wake and jitter tests bounded and deterministic.
|
@thepastaclaw review No review for |
thepastaclaw
left a comment
There was a problem hiding this comment.
⚠️ DEGRADED — Final validation — Phase 1 + Phase 2
⚠️ DEGRADED review. The primary review models were unavailable (gpt-6-astraunavailable: All credentials for model gpt-6-astra are cooling down (last error: usage_limit_reached: The usage limit has been reache), so this review ran on stand-in models:gpt-5.6-luna→muse-spark-1.3-contributor,gpt-5.6-sol→muse-spark-1.3-contributor,gpt-5.6-terra→muse-spark-1.3-contributor,gpt-6-astra→muse-spark-1.3-contributor. Both review phases and the independent verifiers still ran, but on weaker models, with Phase 1 capped athigheffort. Treat the verdict as provisional; a full-strength re-review will run on the next push once the primary models are back.
PR correctly fixes #1039 via bounded reserved-peer probing and the single-timer dialer rework. The only in-scope defect is the new operator-facing comment claiming max-outgoing-connections=0 means unlimited, which is unreachable from config because node setup maps 0 to MaxConnections/2.
🟡 1 suggestion(s)
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (agent: phase1-reviewer, role: tenderdash-consensus-security); reviewer 3: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: general); reviewer 4: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: tenderdash-consensus-security); final verifier: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: astra-verifier, role: final-verifier)
- Degraded mode:
gpt-6-astraunavailable: All credentials for model gpt-6-astra are cooling down (last error: usage_limit_reached: The usage limit has been reache (detected by probe, since 2026-09-20T20:45:34Z); stand-insgpt-5.6-luna→muse-spark-1.3-contributor,gpt-5.6-sol→muse-spark-1.3-contributor,gpt-5.6-terra→muse-spark-1.3-contributor,gpt-6-astra→muse-spark-1.3-contributor; Phase 1 effort capped athigh - Triage:
normalbymuse-spark-1.3-contributor(standing in forgpt-6-astra) (effort low) — PeerManager dial/retry logic change with bounded upgrade probing is an ordinary logic fix, not consensus, crypto, deserialization, or migration code. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer,glm-5.3-flash— tenderdash-consensus-security (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 99% left, weekly 91% left; passed overgemini-3.8-flash-high(lane failed) - Fresh verifier:
muse-spark-1.3-contributor(standing in forgpt-6-astra) — final-verifier; agentastra-verifier - Phase 2 reviewers:
muse-spark-1.3-contributor(standing in forgpt-6-astra) — general (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6-astra) — tenderdash-consensus-security (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `config/config.go`:
- [SUGGESTION] config/config.go:762-763: New config comment misstates the meaning of MaxOutgoingConnections = 0
This PR added '0 means all connections can be outgoing' to the operator-facing P2PConfig comment (and the same wording to the generated template in config/toml.go). That is true only at the internal PeerManagerOptions layer (internal/p2p/peermanager.go:150-156). At the config layer, node/setup.go:240-246 maps MaxOutgoingConnections == 0 to maxConns/2 before constructing PeerManagerOptions, so an operator setting max-outgoing-connections = 0 gets 32 outgoing slots with the default 64 max connections, not unlimited. Fix the comment in both places to describe the actual fallback.
Out-of-scope follow-up suggestions (2)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- PeerManager.HasDialedMaxPeers is dead code with stale semantics — Out of scope — pre-existing dead code with no callers; this PR does not touch it and its counting semantics do not affect the new dial path. Routine cleanup, not required for this PR's goal.
- Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.
- PeerManagerOptions.Validate can underflow uint16 when MaxConnectedUpgrade exceeds MaxConnected — Out of scope — pre-existing Validate arithmetic not changed by this PR; production configuration (MaxConnectedUpgrade=4, MaxOutgoingConnections validated separately) cannot trigger it. Speculative hardening for a separate issue.
- Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.
|
/self-reviewed |
|
Policy satisfied — this can merge. |
TL;DR: Persistent peers can reconnect when ordinary peers have filled the outgoing connection limit.
User story
As a node operator, I want my configured persistent peers to reconnect reliably while connection usage stays bounded.
Scenario
A persistent peer disconnects and an ordinary peer takes its slot. The node should retry the persistent peer and replace the ordinary connection after a successful probe, rather than remain connected only to the ordinary peer.
Detailed discussion
Issue being fixed or feature implemented
Fixes #1039. With total and outgoing connections both limited to one, an ordinary replacement connection could permanently prevent a disconnected persistent peer from reconnecting. Retry jitter could also leave the dialer asleep after the only scheduled wakeup.
What was done?
How Has This Been Tested?
Go 1.27.1, CGO enabled with the existing native BLS build:
go test -race -p 1 -tags=deadlock ./internal/p2p -count=1 -timeout=180s -vpassed../internal/p2p/...: zero issues; goimports/gofmt and diff checks passed.Breaking Changes
None. No public signature, wire, configuration-format/default or persistence changes. Ordinary outgoing limits remain enforced; reserved-peer probing uses the existing bounded upgrade allowance. The separate early-startup unknown-channel mechanism was already addressed by #1460.
Checklist:
For repository code-owners and collaborators only
🤖 Co-authored by Claudius the Magnificent AI Agent
PR Hygiene ·
f6a74c3When every box is checked the
PR Hygienecheck passes and this can merge.