Introduce proper mechanism for tracking other protocols peer sets #7006
Labels
D2-substantial
Can be fixed by an experienced coder with a working knowledge of the codebase.
T0-node
This PR/Issue is related to the topic “node”.
Currently, the reserved nodes mechanism is used to make additional protocols track the sync protocol peer set.
This is done by subscribing to
SyncEvent::PeerConnected(PeerId)
andSyncEvent::PeerDisconnected(PeerId)
sync events and adding/removing such peers to the reserved set of the protocol tracking the sync protocol peer set.The reserved peers mechanism was intended for operators to control the peers a local node is connecting to, and its use to sync peer sets of the syncing protocol and other protocols is a hack. This leads to race conditions like #6573 (comment) when the sync event is missed and requires other hacks like network starter (attempted to get removed in #6400).
Instead of tracking sync peer set via sync events a proper mechanism should be introduced. Possible implications should be carefully considered before implementing it: for example, sync events allow filtering the set of peers by the protocol logic before marking them as reserved, and a purely
PeerStore
/PeerSet
based mechanism of tracking peers won't allow this.The text was updated successfully, but these errors were encountered: