Repository navigation
fix(p2p): initialize peer routing before publishing readiness - #1464
Conversation
Create the send queue and register peer channels before PeerStatusUp so subscribers can send immediately without losing their first message. Add a deterministic regression test that pauses queue creation and checks that readiness is published only once the outgoing route exists. Co-Authored-By: Codex <[email protected]>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .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 |
PR HygieneState: waiting-self-review · commit
Self-review is an author attestation that you have read the diff: This report does not bypass CI or repository protection rules. |
|
✅ Final review complete — no blockers (commit a2741b8) · triage: low · Phase 2 only (queue backlog) |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 2 only (queue backlog)
The change initializes the peer's outgoing queue and channel routing before publishing PeerStatusUp, directly addressing the readiness race described by the PR. The deterministic regression test verifies readiness is withheld while queue creation is blocked and that routing state exists once readiness is announced; no in-scope correctness, security, or concurrency defects were found.
Review provenance
Source: reviewer 1: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6-astra (agent: phase2-reviewer, role: tenderdash-consensus-security); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)
- Triage:
lowbygpt-6-astra(effort low) — This is a small, well-contained initialization-order fix in the peer router with a deterministic regression test; although it affects message delivery timing, it does not change a critical surface such as consensus, cryptography, storage migrations, or peer-facing deserialization. - Phase 1 reviewers: not run (skipped for throughput: 15 PRs queued, above the 10 limit)
- Fresh verifier:
gpt-6-astra— final-verifier; agentastra-verifier - Phase 2 reviewers:
gpt-6-astra— general (completed, effort medium); agentphase2-reviewer,gpt-6-astra— tenderdash-consensus-security (completed, effort medium); agentphase2-reviewer
TL;DR: Prevent the first message to a newly connected peer from being dropped after the peer has already been announced as ready.
Issue being fixed or feature implemented
A peer can be announced as ready before its outgoing queue exists. Sending immediately after that notification drops the message as targeting an unconnected peer. This caused tests (02) on PR #1460 to receive 9 of 10 messages and time out in
TestRouter_Channel_Enqueue_Timeout.User story
As a node operator, I want messages sent when a peer becomes ready to reach that peer reliably.
Scenario
A subscriber sends a message immediately after receiving
PeerStatusUp. The router must already have the peer's send queue and supported channels registered.What was done?
Detailed discussion
Initialize the peer queue and channel map before calling
PeerManager.Ready. Add a deterministic regression test that pauses queue creation and verifies that no readiness event has been published, then verifies readiness and routing registration once initialization completes.This PR branches directly from
v1.8-devand is independent of #1460.How Has This Been Tested?
TestRouter_ReadyAfterQueuefails on the base withpeer advertised readiness before its send queue exists.go test -race -tags deadlock ./internal/p2p -count=1.make lint LINT_BASE=origin/v1.8-dev: 0 issues.gofmtandgit diff --check.Breaking Changes
None. Readiness notifications are delivered after the outgoing route has been initialized.
Checklist:
For repository code-owners and collaborators only
🤖 Co-authored by Claudius the Magnificent AI Agent