fix(peermanager): prefer connected peers in selection#1309
Merged
Conversation
Filter/lightpush peer selection (Automatic -> SelectRandom, and the service-slot pubsub path) chose uniformly at random among all peers that support the protocol+pubsub topic, with no regard for connectedness. A light node that has learned many peers via discv5/peer-exchange — some of them stale/unreachable (e.g. torn-down nodes whose ENRs a bootstrap node still advertised) — would therefore keep picking dead peers, churning on failed dials and missing messages, even while a perfectly good already- connected service node (e.g. the static fleet node) was available. Add preferConnectedPeers: bias selection toward peers we are currently connected to, falling back to the full candidate set when none are connected (so behavior is unchanged when there is no connected candidate). Relates to status-im/status-go#7513. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
igor-sirotin
marked this pull request as ready for review
June 9, 2026 12:58
igor-sirotin
requested review from
chaitanyaprem and
richard-ramos
as code owners
June 9, 2026 12:58
Ivansete-status
approved these changes
Jun 9, 2026
Ivansete-status
left a comment
Collaborator
There was a problem hiding this comment.
LGTM! Great idea
Comment on lines
+95
to
+96
| // Prefer peers we are already connected to, so we don't churn on dialing | ||
| // stale/unreachable peers learned via discovery or peer-exchange. |
Collaborator
There was a problem hiding this comment.
The func name is pretty self-explanatory
Suggested change
| // Prefer peers we are already connected to, so we don't churn on dialing | |
| // stale/unreachable peers learned via discovery or peer-exchange. |
igor-sirotin
added a commit
to status-im/status-go
that referenced
this pull request
Jun 9, 2026
Release tag including the prefer-connected-peers selection fix (logos-messaging/logos-delivery-go#1309), which keeps light-client filter/lightpush off stale/unreachable peers and fixes the flaky light-client message tests (#7513). Supersedes the temporary branch pin. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
igor-sirotin
added a commit
to status-im/status-go
that referenced
this pull request
Jun 9, 2026
Release tag including the prefer-connected-peers selection fix (logos-messaging/logos-delivery-go#1309), which keeps light-client filter/lightpush off stale/unreachable peers and fixes the flaky light-client message tests (#7513). Supersedes the temporary branch pin. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
igor-sirotin
added a commit
to status-im/status-go
that referenced
this pull request
Jun 9, 2026
Release tag including the prefer-connected-peers selection fix (logos-messaging/logos-delivery-go#1309), which keeps light-client filter/lightpush off stale/unreachable peers and fixes the flaky light-client message tests (#7513). Supersedes the temporary branch pin. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
igor-sirotin
added a commit
to status-im/status-go
that referenced
this pull request
Jun 9, 2026
* test: discovery mix full and light clients * docs: known issue wakufleetconfig.json not found * test: enable bridge network by default to prevent discovery * fix: logs * test(waku): use nwaku PR #3939 fleet image + num-shards-in-network=65 quay.io/wakuorg/nwaku-pr:3939 is the build of logos-messaging/logos-delivery#3939, the candidate fix for the light-client PX stale-ENR flake (#7513). Also enables store peer-exchange. * test: allow finding more peers * chore(deps): bump go-waku with filter prefer-connected-peers fix Pulls waku-org/go-waku fix/filter-prefer-connected-peers, which makes peer selection prefer already-connected peers. This stops light-client filter/lightpush from churning on stale/unreachable peers learned via peer-exchange, which was causing the flaky light-client message tests (#7513). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(waku): use released nwaku v0.38.1 fleet (drop #3939) Test the go-waku prefer-connected-peers fix in isolation: the status-go image already carries it (go.mod -> go-waku fix branch), so point the fleet at the released wakuorg/nwaku:v0.38.1 instead of the #3939 build. The client-side fix should keep light clients off stale peers regardless of fleet-side stale-ENR pruning. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore(deps): bump go-waku to v0.10.2 Release tag including the prefer-connected-peers selection fix (logos-messaging/logos-delivery-go#1309), which keeps light-client filter/lightpush off stale/unreachable peers and fixes the flaky light-client message tests (#7513). Supersedes the temporary branch pin. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore: go mod tidy --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
Filter/lightpush peer selection (
Automatic→SelectRandom, and theservice-slot pubsub-topic path in
selectServicePeer) picks uniformly atrandom among all peers that support the protocol + pubsub topic, with no
regard for connectedness.
A light node that has learned many peers via discv5 / peer-exchange — some of
them stale or unreachable (e.g. torn-down nodes whose ENRs a bootstrap node is
still advertising) — therefore keeps selecting dead peers for its filter
subscriptions. It churns on failed dials (
all dials failed) and thesubscription for a content topic can stay down long enough to miss messages,
even while an already-connected, reachable service node is available.
This is the proximate cause of the flaky status-go light-client functional
tests (status-im/status-go#7513): in CI a failing light node was observed
re-dialing ~18 dead peer-exchange peers 30–70× each over 70s while a perfectly
good connected fleet node sat unused.
Change
Add
preferConnectedPeers: bias selection toward peers we are currentlyconnected to, falling back to the full candidate set when none are
connected (so behavior is unchanged when there is no connected candidate).
Applied in both
SelectRandomand theselectServicePeerpubsub-topic path.Notes
peermanagerselection tests pass unchanged(they don't connect the candidate peers, so the fallback returns the full
set as before).
because libp2p
identifyoverwrites the manually-added supported protocolsafter connection (the existing
SelectPeerWithLowestRTTtest is ordered lastfor the same reason); happy to add one if you have a preferred harness.
bootstrap node from serving stale ENRs); this PR makes the client resilient
regardless of what it is served.
🤖 Generated with Claude Code