Skip to content

fix(dash-spv): spread peers across network groups - #1372

Draft
xdustinface wants to merge 1 commit into
fix/rate-sized-capfrom
fix/peer-diversity
Draft

xdustinface wants to merge 1 commit into
fix/rate-sized-capfrom
fix/peer-diversity

Conversation

@xdustinface

Copy link
Copy Markdown
Collaborator

Most testnet seeds sit in 68.67.122.0/24, so a uniform sample of addresses keeps a client inside that block. When the block is congested every peer is slow alike, and underserving_peer has nothing to compare.

PeerDiscoverer::get now orders candidates by network group, a /16 for IPv4 and a /32 for IPv6, and tries groups with no connected peer first. While work is queued and the link is not stalled, repair_round swaps the slowest peer of the most crowded group for an address from a group the set lacks, at most once per SWAP_COOLDOWN. Configured peers are never swapped. A node lacking a required service is banned instead of redialed every round, gossiped addresses are learned only if they advertise every required service, and the supervisor re-checks the set on every FILL_TICK.

Stacked on #1371, and will be retargeted to dev when that one merges.

@coderabbitai

coderabbitai Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.91599% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.93%. Comparing base (a92d094) to head (707faf6).

Files with missing lines Patch % Lines
dash-spv/src/network/manager.rs 98.14% 4 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                   @@
##           fix/rate-sized-cap    #1372      +/-   ##
======================================================
+ Coverage               81.11%   85.93%   +4.82%     
======================================================
  Files                     171      268      +97     
  Lines                   46147    71266   +25119     
======================================================
+ Hits                    37430    61240   +23810     
- Misses                   8717    10026    +1309     
Flag Coverage Δ
core 82.80% <ø> (ø)
rpc 52.10% <ø> (ø)
spv 94.78% <98.91%> (?)
wallet 83.53% <ø> (ø)
Files with missing lines Coverage Δ
dash-spv/src/client/config.rs 82.16% <100.00%> (ø)
dash-spv/src/network/bans.rs 95.23% <100.00%> (ø)
dash-spv/src/network/discovery.rs 93.75% <100.00%> (ø)
dash-spv/src/network/peer.rs 92.13% <100.00%> (ø)
dash-spv/src/network/manager.rs 94.45% <98.14%> (ø)

... and 92 files with indirect coverage changes

@github-actions github-actions Bot added the merge-conflict The PR conflicts with the target branch. label Nov 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

@github-actions github-actions Bot removed the merge-conflict The PR conflicts with the target branch. label Nov 10, 2026
Most testnet seeds sit in 68.67.122.0/24, so a uniform sample keeps a client inside that block. When the block is congested every peer is slow alike and `underserving_peer` sees nothing to compare.

- `PeerDiscoverer::get` orders candidates by `NetGroup`, a /16 for IPv4 and a /32 for IPv6: groups with no connected peer first, one address per group in turn, then the connected groups. It takes the connected and banned addresses, so a banned group cannot shrink the batch. Exclusive peers are not grouped.
- While work is queued and the link is not stalled, `repair_round` swaps the slowest peer of the largest group with two or more peers for an address of a group the set lacks, at most one probe per `SWAP_COOLDOWN`. Every newly learned `addr` wakes the supervisor. Configured peers are never swapped for their group.
- A node lacking a required service is banned with `Ban::MissingServices` for as long as a misbehaving one, so its group falls through to its next address instead of redialing it every round. Gossiped `addr` and `addrv2` entries are learned only if they advertise every required service.
- The supervisor re-checks the set on every `FILL_TICK`. It slept on the timer only while the set was short or crowded, so a full set waited for the next unrelated wake: a peer whose rate became known after the last round was never judged, and a slow peer flagged while `SWAP_COOLDOWN` held the swap back was never re-checked, since the flow controller wakes the supervisor only once per slow peer. A round with nothing to do returns before probing. `a_running_supervisor_swaps_a_slow_peer_once_it_is_measured` drives the real loop and fails with the old gate.
- `NetworkState` is built apart from its tasks, so tests can drive the supervisor on a state of their own.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant