Rework the event system of `sc-network`
This PR introduces NotificationService which gives protocols direct access to the ConnectionHandler and allows them to bypass NetworkWorker when communicating with remote peers. When a protocol is initialized, a handle pair is created and the other half of the handle is given to the protocol which allows it to send and receive notifications and peer events from network. The other half is given to Notifications which it uses to communicate with the protocol directly.
PR also introduces the concept of configurable handshakes. This allows us to do two things:
- allow protocols to start using custom handshakes
- allow protocols to decide whether they want to accept or reject the inbound substream
Previously Peerset was entirely in control of choosing which peers to accept/reject which caused problems with /block-announces/1. The slot allocation is part of ProtocolController which may be incorporated into NotificationService in the future but whether the peer is accepted or rejected is now done by both the protocol and by Peerset.
polkadot companion: https://github.com/paritytech/polkadot/pull/7582 cumulus companion: https://github.com/paritytech/cumulus/pull/2983
Fixes paritytech/polkadot-sdk#515, fixes paritytech/polkadot-sdk#554, fixes paritytech/polkadot-sdk#512, fixes paritytech/polkadot-sdk#556
Introduced a MessageSink abstraction which should make the NotificationService easier to use. After https://github.com/paritytech/substrate/pull/14236 is merged and the NetworkBridgeRx issues are resolved, this is ready for review.
Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.
@paritytech-cicd-pr Requester could not be detected as a member of an allowed organization.