Skip to content

Commit

Permalink
litep2p/peerset: Do not disconnect all peers on SetReservedPeers co…
Browse files Browse the repository at this point in the history
…mmand (#6016)

Previously, when receiving the `SetReservedPeers { reserved }` all peers
not in the `reserved` set were removed.

This is incorrect, the intention of `SetReservedPeers` is to change the
active set of reserved peers and disconnect previously reserved peers
not in the new set.

While at it, have added a few other improvements to make the peerset
more robust:
- `SetReservedPeers`: does not disconnect all peers
- `SetReservedPeers`: if a reserved peer is no longer reserved, the
peerset tries to move the peers to the regular set if the slots allow
this move. This ensures the (now regular) peer counts towards slot
allocation.
- every 1 seconds: If we don't have enough connect peers, add the
reserved peers to the list that the peerstore ignores. Reserved peers
are already connected and the peerstore might return otherwise a
reserved peer


### Next Steps

- [x] More testing

cc @paritytech/networking

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Co-authored-by: Dmitry Markin <dmitry@markin.tech>
Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
3 people authored Nov 6, 2024
1 parent a479161 commit ccb2a88
Showing 3 changed files with 414 additions and 157 deletions.
15 changes: 15 additions & 0 deletions prdoc/pr_6016.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
title: Litep2p network backend do not disconnect all peers on SetReservedPeers command

doc:
- audience: [ Node Dev, Node Operator ]
description: |
Previously, when the `SetReservedPeers` was received, all peers except the new
reserved peers were disconnected.
This PR ensures that previously reserved nodes are kept connected as regular nodes if
enough slots are available.
While at it, this PR excludes reserved peers from the candidates of peers obtained from
the peerstore.

crates:
- name: sc-network
bump: patch
Loading

0 comments on commit ccb2a88

Please sign in to comment.