-
Notifications
You must be signed in to change notification settings - Fork 839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
notifications/libp2p: Punish notification protocol misbehavior on outbound substreams #7781
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
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.
And we are 1000% sure that this behavior is not triggered by our own implementation? :D
let index: usize = set_id.into(); | ||
let protocol_name = self.notification_protocols.get(index); | ||
|
||
error!( |
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.
error!( | |
debug!( |
What should the operator do with this line?
@@ -479,11 +479,13 @@ where | |||
Poll::Pending => {}, | |||
Poll::Ready(Some(result)) => match result { | |||
Ok(_) => { | |||
error!( | |||
warn!( |
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.
warn!( | |
debug!( |
|
||
error!( | ||
target: LOG_TARGET, | ||
"Received protocol mismatch for peer {:?} on protocol {:?}", |
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.
May be generate the same message as in the reputation change below to better describe the error? "Protocol mismatch" sounds too cryptic.
@@ -399,6 +399,14 @@ pub enum NotificationsOut { | |||
/// Message that has been received. | |||
message: BytesMut, | |||
}, | |||
|
|||
/// The remote peer has misbehaved and the connection has been closed. |
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 would explain that right now this corresponds to the specific case of receiving data in outbound substream.
@@ -329,6 +329,9 @@ pub enum NotifsHandlerOut { | |||
CloseDesired { |
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.
May be also update the comment above to reflect that CloseDesired
is emitted when the remote either wishes to close the connection or misbehaves?
@@ -329,6 +329,9 @@ pub enum NotifsHandlerOut { | |||
CloseDesired { | |||
/// Index of the protocol in the list of protocols passed at initialization. | |||
protocol_index: usize, | |||
|
|||
/// Whether the remote has misbehaved and did not comply with the notification spec. | |||
protocol_misbehavior: bool, |
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.
Nit: may be introduce
enum CloseReason {
ClosedByRemoteOrIoError, // naming could be better, may be just `Connection`?
ProtocolMisbehavior,
}
?
This PR punishes behaviors that deviate from the notification spec. When a peer misbehaves by writing data on an unidirectional read stream, the peer is banned and disconnected immediately.
In this PR:
NotificationOutError
is enriched with termination reason and made publically available for higher levelsCloseDesired
eventsCloses: #7722
cc @paritytech/networking