fix(p2p,eth): remove per-peer dual-connection mechanism, close #2351 #2359#2433
fix(p2p,eth): remove per-peer dual-connection mechanism, close #2351 #2359#2433gzliudan wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Pull request overview
This PR removes XDPoSChain’s per-peer “dual connection” (primary + pair) RLPx mechanism and returns to upstream-style semantics of a single active connection per remote NodeID, routing all ETH/BFT traffic over the single negotiated session.
Changes:
- Enforce single-connection-per-
NodeIDin the p2p server by rejecting duplicates withDiscAlreadyConnected. - Remove pair-peer lifecycle/state from
p2p.Peerand delete the associated test. - Simplify the ETH peer implementation to use only
p.rw, and makepeerSet.Registerstrictly reject duplicate IDs; handler always registers peers with the downloader.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| p2p/server.go | Rejects duplicate NodeID connections and stores only one peer per ID. |
| p2p/peer.go | Removes pair-peer state and the pair-disconnect cascade on shutdown. |
| p2p/peer_test.go | Deletes the pair-peer shutdown test (no longer applicable). |
| p2p/peer_error.go | Removes ErrAddPairPeer; keeps DiscPairPeerStop enum slot as deprecated for wire-number stability. |
| eth/peer.go | Removes pairRw routing and makes peer registration strictly one-per-id. |
| eth/peer_test.go | Adds a regression test that duplicate IDs are rejected by peerSet.Register. |
| eth/handler.go | Removes ErrAddPairPeer special-casing so every peer is registered with the downloader and tx sync. |
a2a4be7 to
4aab775
Compare
…Org#2351 XinFinOrg#2359 XDPoSChain kept two independent RLPx/TCP connections per remote peer (a "primary" and a "pair"), a private divergence from upstream go-ethereum which allows only one connection per NodeID. This adds state-machine complexity (isPair, pairRw, PairPeer, ErrAddPairPeer, DiscPairPeerStop) without measured benefit, and the pair connection already carried both block-sync and BFT traffic, so it never isolated Vote/Timeout/SyncInfo from large BlockBodies/NodeData frames. Revert to a single connection per NodeID (upstream semantics) and route all eth messages, including the XDPoS v2 BFT messages, over that single connection using the existing upstream FIFO write scheduling. No write-priority lane is added; RLPx framing, message ids, capability strings and the handshake are unchanged, so the change is rolling-upgrade safe against legacy pair-capable nodes. Changes: - p2p/server.go: postHandshakeChecks rejects any duplicate NodeID with DiscAlreadyConnected; addPeer no longer stores a second connection. - p2p/peer.go: drop pairPeer field/methods and the DiscPairPeerStop cascade on Peer.run exit. - p2p/peer_error.go: remove ErrAddPairPeer; keep the DiscPairPeerStop enum slot (deprecated) to preserve on-the-wire numbering. - eth/peer.go: remove pairRw; all Send/Request helpers use p.rw; peerSet.Register reverts to one peer per id. - eth/handler.go: drop ErrAddPairPeer special-casing so every peer registers with the downloader and syncs transactions. Refs: XinFinOrg#2359
4aab775 to
aee570b
Compare
Proposed changes
XDPoSChain kept two independent RLPx/TCP connections per remote peer (a "primary" and a "pair"), a private divergence from upstream go-ethereum which allows only one connection per NodeID. This adds state-machine complexity (isPair, pairRw, PairPeer, ErrAddPairPeer, DiscPairPeerStop) without measured benefit, and the pair connection already carried both block-sync and BFT traffic, so it never isolated Vote/Timeout/SyncInfo from large BlockBodies/NodeData frames.
Revert to a single connection per NodeID (upstream semantics) and route all eth messages, including the XDPoS v2 BFT messages, over that single connection using the existing upstream FIFO write scheduling. No write-priority lane is added; RLPx framing, message ids, capability strings and the handshake are unchanged, so the change is rolling-upgrade safe against legacy pair-capable nodes.
Changes:
fix #2351 and #2359
replace #2360
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which parts of the codebase does this PR touch?
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that