-
Notifications
You must be signed in to change notification settings - Fork 2.7k
network: Detect early that NotificationOutSubstream
was closed by the remote
#13396
Conversation
…if we don't write data into it.
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.
👍
client/network/src/protocol/notifications/upgrade/notifications.rs
Outdated
Show resolved
Hide resolved
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.
Test case showing that it detects the closed substream correctly without writing to it would be nice
Co-authored-by: Anton <[email protected]>
Sounds like a good idea! |
Done! As a bonus we got a test for |
Actually, I observed the same behavior on a raw tokio socket, so probably libp2p just mimics sockets with its substreams. |
To be honest, I'm not quite sure now that extending CC @altonen |
When and where would you call |
Okay, I will just add a comment to |
…o data was written
…sed by the remote (paritytech#13396)" (paritytech#13409) This reverts commit dfa654d.
…sed by the remote (paritytech#13396)" (paritytech#13409) This reverts commit dfa654d.
…sed by the remote (paritytech#13396)" (paritytech#13409) This reverts commit dfa654d.
…sed by the remote (paritytech#13396)" (paritytech#13409) This reverts commit dfa654d.
…3983) This PR brings the fix paritytech/substrate#13396 to polkadot-sdk. In the past, due to insufficient inbound slot count on polkadot & kusama, this fix led to low peer count. The situation has improved since then after changing the default ratio between `--in-peers` & `--out-peers`. Nevertheless, it's expected that the reported total peer count with this fix is going to be lower than without it. This should be seen as the correct number of working connections reported, as opposed to also reporting already closed connections, and not as lower count of working connections with peers. This PR also removes the peer eviction mechanism, as closed substream detection is a more granular way of detecting peers that stopped syncing with us. The burn-in has been already performed as part of testing these changes in #3426. --------- Co-authored-by: Aaro Altonen <[email protected]>
…3983) This PR brings the fix paritytech/substrate#13396 to polkadot-sdk. In the past, due to insufficient inbound slot count on polkadot & kusama, this fix led to low peer count. The situation has improved since then after changing the default ratio between `--in-peers` & `--out-peers`. Nevertheless, it's expected that the reported total peer count with this fix is going to be lower than without it. This should be seen as the correct number of working connections reported, as opposed to also reporting already closed connections, and not as lower count of working connections with peers. This PR also removes the peer eviction mechanism, as closed substream detection is a more granular way of detecting peers that stopped syncing with us. The burn-in has been already performed as part of testing these changes in #3426. --------- Co-authored-by: Aaro Altonen <[email protected]>
…aritytech#3983) This PR brings the fix paritytech/substrate#13396 to polkadot-sdk. In the past, due to insufficient inbound slot count on polkadot & kusama, this fix led to low peer count. The situation has improved since then after changing the default ratio between `--in-peers` & `--out-peers`. Nevertheless, it's expected that the reported total peer count with this fix is going to be lower than without it. This should be seen as the correct number of working connections reported, as opposed to also reporting already closed connections, and not as lower count of working connections with peers. This PR also removes the peer eviction mechanism, as closed substream detection is a more granular way of detecting peers that stopped syncing with us. The burn-in has been already performed as part of testing these changes in paritytech#3426. --------- Co-authored-by: Aaro Altonen <[email protected]>
…aritytech#3983) This PR brings the fix paritytech/substrate#13396 to polkadot-sdk. In the past, due to insufficient inbound slot count on polkadot & kusama, this fix led to low peer count. The situation has improved since then after changing the default ratio between `--in-peers` & `--out-peers`. Nevertheless, it's expected that the reported total peer count with this fix is going to be lower than without it. This should be seen as the correct number of working connections reported, as opposed to also reporting already closed connections, and not as lower count of working connections with peers. This PR also removes the peer eviction mechanism, as closed substream detection is a more granular way of detecting peers that stopped syncing with us. The burn-in has been already performed as part of testing these changes in paritytech#3426. --------- Co-authored-by: Aaro Altonen <[email protected]>
Detect that
NotificationOutSubstream
was closed by the remote even if we don't write data into it.Fixes paritytech/polkadot-sdk#526.
Description
In
Notifications
we use two duplex substreams for outgoing and incoming notifications. After the initial handshake, each substream becames a unidirectional stream of data. Unfortunately,Sink::poll_flush
called on libp2p socket does not produce an error if the substream was dropped on the remote until we write some data into it. In order to overcome this limitation, this PR adds polling of the out_substream for incoming messages (which should be none) in<NotificationOutSubstream as Sink>::poll_flush
to detect that the stream has terminated (was dropped/closed by the remote).It may be worth filing a bug to libp2p to expose that the stream was dropped (reset) by the remote via
Sink::poll_flush
even if no data was written into it before the flushing.