-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[client/network] ban peer for 10s after disconnecting #13747
Conversation
@altonen @dmitry-markin this PR solves the problem from "our" side by ignoring incoming connections which arrive too soon (peers are banned for 10s). |
Is this actually on a connection level? Isn't this just on the "substream" level? Any possibility to add some simple test? When do we ban a peer? Only when they lost all their reputation? Or would we also ban them in other circumstances? |
And the peerset already has some kind of banning or? When a node "runs out of reputation" we already had some banning behavior, but 30 seconds AFAIR or? |
substrate/client/peerset/src/lib.rs Lines 492 to 493 in ee38a52
|
@@ -1533,6 +1552,12 @@ impl NetworkBehaviour for Notifications { | |||
|
|||
// Disabled => Disabled | Incoming | |||
PeerState::Disabled { mut connections, backoff_until } => { | |||
// Do not accept incoming connections if the peer is still banned. | |||
if backoff_until.map_or(false, |t| t > Instant::now()) { | |||
*entry.into_mut() = PeerState::Disabled { connections, backoff_until }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we insert PeerState::DisabledPendingEnable
with a timer here instead? Otherwise it seems we will never progress from this state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 I was under the impression that the peer will try again at some point in the future (i.e. the same code block will be executed again => progress is made).
What was the reason why this wasn't merged last time? |
This comment was marked as resolved.
This comment was marked as resolved.
It doesn't fix it. I'm generally in favor of merging this but the underlying issue for this behavior has to be found out first, otherwise we're just masking it with this change. The reason why this was not merged the last time was because there was some discussion about this behavior in general and how it might blow up in our faces as apparently you're not supposed to do this in the listening end but the dialer is expected to behave correctly. I'm also leaning towards not merging anything connectivity-related because |
I agree ☝️
All the streams within the notifications protocol.
Any time we choose to disconnect from a peer (bad handshake, max peers reached). |
Do we also ban when the peer has less than the minimum reputation in any peerset? |
Yes, but that happens independently in the peerset afaik. |
Closing this until we find out the reason for peers constantly reconnecting to us (see #13778 (comment) for @altonen's thoughts). |
plus do not accept incoming connections if peer is still banned.
Refs https://github.com/paritytech/infrastructure-alerts/issues/26
Refs #13778