Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Split Peerset into reputation store & ProtocolControllers #13611

Merged
merged 106 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
143bc98
WIP: Introduce `ProtocolController`
dmitry-markin Mar 11, 2023
5256f19
Code review suggestions: docs and `trace`->`info`
dmitry-markin Mar 16, 2023
c333aac
Apply suggestions from code review
dmitry-markin Mar 16, 2023
b50f134
Rename `ConnectionState`->`PeerState` and reduce states to `Connected…
dmitry-markin Mar 16, 2023
2670615
Get rid of `Peer` abstraction
dmitry-markin Mar 16, 2023
f6b9bca
Apply suggestions from code review
dmitry-markin Mar 16, 2023
6c6fb75
Rework peer management + implement `alloc_slots`
dmitry-markin Mar 17, 2023
7d7d1d8
minor: naming
dmitry-markin Mar 17, 2023
de8e6d2
Apply suggestions from code review
dmitry-markin Mar 20, 2023
4ab043d
Apply review suggestions
dmitry-markin Mar 20, 2023
770a38a
Refactor `on_peer_dropped()`
dmitry-markin Mar 20, 2023
f4401cf
minor: fix docs
dmitry-markin Mar 20, 2023
91a66ec
Add more docs
dmitry-markin Mar 20, 2023
fd43963
Don't put connected peers into the list of regular nodes
dmitry-markin Mar 20, 2023
63385ff
minor: docs
dmitry-markin Mar 20, 2023
368eaed
WIP: add tests
dmitry-markin Mar 20, 2023
4c95216
minor: take no more connection candidates than slots available
dmitry-markin Mar 20, 2023
d09dc00
Test both connect/accept for reserved nodes
dmitry-markin Mar 21, 2023
7a25e8a
Test banned reserved nodes, fix `alloc_slots`
dmitry-markin Mar 21, 2023
9747eaf
Add more tests
dmitry-markin Mar 21, 2023
0b4a4c2
minor: remove unneded tokio dev dependecy
dmitry-markin Mar 21, 2023
29d6e35
Add test for disconnecting reserved peers
dmitry-markin Mar 22, 2023
d95562f
minor: clean `PeerSet` from `PeerStore` methods
dmitry-markin Mar 22, 2023
7a58b7e
Pass ignored nodes as hash set of references to `PeerStore`
dmitry-markin Mar 22, 2023
c1bb601
minor test fixes
dmitry-markin Mar 22, 2023
013ee1d
Better validation of `PeerStore` output
dmitry-markin Mar 22, 2023
7551cd0
Rename trait `PeerStore`->`PeerReputationProvider`
dmitry-markin Mar 22, 2023
4fb10a1
WIP: introduce `PeerStore` reputation storage
dmitry-markin Mar 22, 2023
67ae9cb
Apply suggestions from code review
dmitry-markin Mar 24, 2023
57d7ebd
minor: rustfmt
dmitry-markin Mar 24, 2023
7ac4180
Remove `DropReason` from peer dropped events
dmitry-markin Mar 24, 2023
4636536
Fix handling of invalid `PeerStore` output in `alloc_slots`
dmitry-markin Mar 24, 2023
e865c19
Implement `PeerStore`
dmitry-markin Mar 24, 2023
2587cdc
minor: docs
dmitry-markin Mar 24, 2023
06f8fdf
minor: TODO
dmitry-markin Mar 24, 2023
56d380b
minor: another TODO
dmitry-markin Mar 24, 2023
85bdadb
Merge remote-tracking branch 'origin/master' into dm-peerset-splitting
dmitry-markin Mar 28, 2023
9c69f2d
Retain peer info for one hour after it was last updated
dmitry-markin Mar 31, 2023
554dbf8
Construct `PeerStore` from the list of bootnodes
dmitry-markin Mar 31, 2023
72ec71f
WIP: plug `PeerStore` and `ProtocolController` into `Peerset`
dmitry-markin Apr 4, 2023
086fb5b
WIP: implement `PeerStore` and `ProtocolController` polling via `Peer…
dmitry-markin Apr 4, 2023
7e370d9
Apply suggestions from code review
dmitry-markin Apr 5, 2023
64ee662
minor: improve error reporting
dmitry-markin Apr 5, 2023
c9109d7
Apply review suggestions
dmitry-markin Apr 5, 2023
8677480
WIP: update `PeerSet` use to match `PeerStore` and `ProtocolControlle…
dmitry-markin Apr 7, 2023
ff43c19
WIP: try to make `sc-network` compile
dmitry-markin Apr 7, 2023
f53e1a1
Restore the original API of `Peerset`
dmitry-markin Apr 10, 2023
4e1b773
docs: apply review suggestions
dmitry-markin Apr 10, 2023
23bf89b
Make substrate compile
dmitry-markin Apr 10, 2023
d74f8b9
Get rid of `PeersState`
dmitry-markin Apr 10, 2023
bfb9c7f
Fix bug with removing reserved node in `ProtocolController`, improve …
dmitry-markin Apr 11, 2023
c7aaf9f
minor: comment
dmitry-markin Apr 11, 2023
14c4f53
Merge remote-tracking branch 'origin/master' into dm-peerset-splitting
dmitry-markin Apr 11, 2023
82c3351
Apply suggestions from code review
dmitry-markin Apr 13, 2023
90b018c
Apply more code review suggestions
dmitry-markin Apr 13, 2023
d839590
minor: use boxing instead of generics for `PeerStoreHandle` reference…
dmitry-markin Apr 14, 2023
7c8ac45
Test `PeerInfo::decay_reputation`
dmitry-markin Apr 17, 2023
06cb192
Make concurrency issues slightly milder
dmitry-markin Apr 20, 2023
bc4f608
Improve situation a little more
dmitry-markin Apr 20, 2023
8ed59d3
Try to make it work using rendezvous channels
dmitry-markin Apr 20, 2023
a2b9ca4
Make fuzz test skip over commands between `incoming` and `accept`/`re…
dmitry-markin Apr 26, 2023
14315a0
Update comment re concurrency issues with `ProtocolController`<->`Not…
dmitry-markin Apr 26, 2023
27178f8
Clean things up and fix warnings
dmitry-markin Apr 27, 2023
1ef145c
Fix error with assigning to local variable instead of reference
dmitry-markin Apr 27, 2023
535410b
Update tests with new incoming request handling logic
dmitry-markin Apr 27, 2023
1065fc6
Make `Notifications` skip over `Peerset` commands between `incoming` …
dmitry-markin Apr 28, 2023
9730a41
Fix `reconnect_after_disconnect` test
dmitry-markin Apr 29, 2023
92001f6
Merge remote-tracking branch 'origin/master' into dm-peerset-splitting
dmitry-markin Apr 30, 2023
42f14b9
Fix rustdoc
dmitry-markin Apr 30, 2023
752d70b
Remove unused `ProtocolHandle::disconnect_peer`
dmitry-markin Apr 30, 2023
2fbfe6c
Add logging of reputation changes
dmitry-markin Apr 30, 2023
dc85f1f
Fix warnings
dmitry-markin Apr 30, 2023
9b33297
minor: change log level
dmitry-markin Apr 30, 2023
198504f
minor: remove unused import
dmitry-markin Apr 30, 2023
9e86b38
Apply suggestions from code review
dmitry-markin May 8, 2023
b3a72ad
minor: add more logging
dmitry-markin May 8, 2023
e03f852
Document event prioritization requirements in `ProtocolController`
dmitry-markin May 9, 2023
9a51e22
Rename `PeerReputationProvider` -> `PeerStoreProvider`
dmitry-markin May 9, 2023
a4e32a6
Add comment re dropped entries and `num_known_peers`
dmitry-markin May 9, 2023
0322d3d
Revert "Remove unused `ProtocolHandle::disconnect_peer`"
dmitry-markin May 9, 2023
0944c8e
Disconnect peers with reputation below `BANNED_THRESHOLD`
dmitry-markin May 9, 2023
fba6f2d
Switch to `parking_lot::Mutex`
dmitry-markin May 9, 2023
c94ea21
WIP: introduce outstanding events/actions handling
dmitry-markin May 10, 2023
34b2d1b
WIP: defer/process outstanding `SetReservedPeers` and `SetReservedOnly`
dmitry-markin May 11, 2023
ace2dd0
WIP: implement ACKing of `ProtocolController` messages
dmitry-markin May 11, 2023
76d4132
WIP: ACKs in `ProtocolController` (mostly done, but fuzz fails)
dmitry-markin May 12, 2023
4066995
minor: remove debugging logging
dmitry-markin May 12, 2023
80d3ff6
Merge remote-tracking branch 'origin/master' into dm-peerset-splitting
dmitry-markin May 12, 2023
1fc523d
Fix failed merge of `master`
dmitry-markin May 12, 2023
ccdde89
minor: revert number of iterations in `fuzz` test
dmitry-markin May 12, 2023
2415e2a
Relax event order requirements in fuzz test
dmitry-markin May 15, 2023
4ee2a32
Relax `ProtocolController` message order requirements in `Notifications`
dmitry-markin May 15, 2023
6fcd68c
Get rid of ACKs
dmitry-markin May 15, 2023
8a268b2
Merge remote-tracking branch 'origin/master' into dm-peerset-splitting
dmitry-markin May 15, 2023
9dfd6fe
Update docs to match the implementation
dmitry-markin May 15, 2023
4a2257f
Merge remote-tracking branch 'origin/master' into dm-peerset-splitting
dmitry-markin May 15, 2023
601e4f6
Fix `Notifications` tests
dmitry-markin May 16, 2023
a99847c
Merge remote-tracking branch 'origin/master' into dm-peerset-splitting
dmitry-markin May 16, 2023
263db27
Delete `Peerset` test duplicating `ProtocolController` tests
dmitry-markin May 16, 2023
47edf31
minor: add issue references in TODOs
dmitry-markin May 18, 2023
b50d998
Apply suggestions from code review
dmitry-markin May 18, 2023
2cd0188
rustfmt
dmitry-markin May 18, 2023
a0dcac4
monor: format after `rustfmt`
dmitry-markin May 18, 2023
6960b8f
Add in/out slot counters logging
dmitry-markin May 22, 2023
b7a5a48
Merge remote-tracking branch 'origin/master' into dm-peerset-splitting
dmitry-markin May 22, 2023
a03b9a0
Make clippy happy
dmitry-markin May 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/network/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ where
}

/// Returns the list of reserved peers.
pub fn reserved_peers(&self) -> impl Iterator<Item = &PeerId> {
fn reserved_peers(&self) -> impl Iterator<Item = &PeerId> {
self.network_service.behaviour().user_protocol().reserved_peers()
}
}
Expand Down
1 change: 1 addition & 0 deletions client/peerset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ log = "0.4.17"
serde_json = "1.0.85"
wasm-timer = "0.2"
sc-utils = { version = "4.0.0-dev", path = "../utils" }
sp-arithmetic = { version = "6.0.0", path = "../../primitives/arithmetic" }

[dev-dependencies]
rand = "0.8.5"
22 changes: 22 additions & 0 deletions client/peerset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
//! will at all time try to maintain a connection with.

mod peersstate;
mod protocol_controller;

use futures::{channel::oneshot, prelude::*};
use log::{debug, error, trace};
Expand Down Expand Up @@ -176,6 +177,26 @@ impl PeersetHandle {
// The channel can only be closed if the peerset no longer exists.
rx.await.map_err(|_| ())
}

/// Checks whether the peer has a reputation value below [`BANNED_THRESHOLD`].
pub fn is_banned(&self, peer_id: PeerId) -> bool {
todo!("will be implemented after `Peerset` is converted into shared struct");
}

/// Report disconnect to adjust peers reputation value.
pub fn report_disconnect(&self, peer_id: PeerId) {
todo!("will be implemented after `Peerset` is converted into shared struct");
}

/// Get the candidates for an outgoing connection.
pub fn outgoing_candidates(
&self,
count: usize,
ignored: HashSet<PeerId>,
) -> impl Iterator<Item = &PeerId> {
todo!("supply `count` peers with highest reputation, but not from `ignored`");
[].into_iter()
}
}

/// Message that can be sent by the peer set manager (PSM).
Expand Down Expand Up @@ -764,6 +785,7 @@ impl Stream for Peerset {
}

/// Reason for calling [`Peerset::dropped`].
#[derive(Debug)]
pub enum DropReason {
/// Substream or connection has been closed for an unknown reason.
Unknown,
Expand Down
Loading