P2P: fix peer-set desync that can abort the node - #667
Open
thomasbuilds wants to merge 1 commit into
Open
Conversation
thomasbuilds
force-pushed
the
fix-peer-set-id-reuse
branch
from
August 9, 2026 04:42
7a06b31 to
319f862
Compare
Boog900
requested changes
Aug 11, 2026
On clearnet a peer can have its `InternalPeerID` reused by a connection in the opposite direction: drop the outbound connection we hold, then reconnect inbound from the address we dialled. `ClosedConnectionFuture` carries only that id, so when it fires the entry in `peers` may belong to the new connection rather than the one that closed. `remove_dead_peers` removed it regardless, dropping the `StoredClient` and disconnecting a live peer. `outbound_peers` was only pruned when that entry was outbound, so a slot taken over by an inbound connection left a stale id for `random_peer_for_stem` to `unwrap`. As the workspace sets `panic = "abort"`, that ends the process rather than the request. Drop `outbound_peers` rather than fix its bookkeeping: it had a single consumer, and keeping it in sync with `peers` is what failed. Outbound peers are filtered from `peers` on demand, so an inbound peer cannot be selected for Dandelion++ stemming, and an entry is only removed once its own handle is closed.
thomasbuilds
force-pushed
the
fix-peer-set-id-reuse
branch
from
August 12, 2026 01:51
319f862 to
627468b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On clearnet a peer can have its
InternalPeerIDreused by a connection in the opposite direction: drop the outbound connection we hold, then reconnect inbound from the address we dialled.ClosedConnectionFuturecarries only that id, so when it fires the entry inpeersmay belong to the new connection rather than the one that closed.remove_dead_peersremoved it regardless, dropping theStoredClientand disconnecting a live peer.outbound_peerswas only pruned when that entry was outbound, so a slot taken over by an inbound connection left a stale id forrandom_peer_for_stemtounwrap. As the workspace setspanic = "abort", that ends the process rather than the request.Drop
outbound_peersrather than fix its bookkeeping: it had a single consumer, and keeping it in sync withpeersis what failed. Outbound peers are filtered frompeerson demand, so an inbound peer cannot be selected for Dandelion++ stemming, and an entry is only removed once its own handle is closed.