-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
difficulty:moderatehelp wantedpriority:importantThe changes needed are critical for libp2p, or are blocking another projectThe changes needed are critical for libp2p, or are blocking another project
Description
Description
Today there is no way to send generic local and remote node information from one NetworkBehaviour
to another NetworkBehaviour
, apart from NetworkBehaviour::inject_new_external_addr
.
Examples of such generic information could be:
- Supported protocols by the local peer.
- Supported protocols of a remote peer.
- Addresses of a remote peer.
Motivation
One example use-case is the exchange of information betweenlibp2p-identify
and libp2p-kad
to support Kademlia Client Mode (see #2032).
libp2p-kad
needs to know whether a remote peer advertises/ipfs/kad/1.0.0
via the identify protocol to decide whether to include the remote peer in its routing table or not.libp2p-identify
needs to know whether the local node runs in client or in server mode, i.e. supports the/ipfs/kad/1.0.0
or not.
See #2521 which is currently blocked on this.
Proposal
Below is an initial action plan proposal based on a meeting with @MarcoPolo.
- Proof of concept 1 (communicating remote metadata across behaviours)
- Extend
NetworkBehaviourAction
withNetworkBehaviourAction::ReportRemoteMetaData
, containing a delta update. - Add
NetworkBehaviourAction::inject_remote_metadata
. - Write a
Select
NetworkBehaviour
which takes twoNetworkBehaviour
implementations and passesReportRemoteMetaData
emitted by one behaviour to the other viainject_remote_metadata
. - Showcase how
libp2p-kad
can learn supported protocols of remote peers fromlibp2p-identify
.
- Extend
- Proof of concept 2 (communicating local metadata across behaviours)
- Extend
NetworkBehaviourAction
withNetworkBehaviourAction::ReportSupportedProtocol
which eachNetworkBehaviour
emits when it supports a protocol as a listener and which is passed to otherNetworkBehaviour
s via theSelect
NetworkBehaviour
. - Showcase how remote peers can learn that
libp2p-kad
moved from client mode into server mode vialibp2p-identify
.
- Extend
- In case proof of concepts looks good, don't merge but consolidate
inject_*
methods into singleinject_event
method with a singleenum
. Motivation here is to not have yet anotherinject_***
method onNetworkBehaviour
. - Adjust proof of concepts, implement
Select
behaviour logic inlibp2p-swarm-derive
and merge. - Add method on
Swarm
(e.g.add_remote_metadata
) which would callNetworkBehaviour::inject_event(Event::RemoteMetaData)
on the rootNetworkBehaviour
. - Design
AddressBook
type which eachNetworkBehaviour
can instantiate and pass a reference frominject_event
into to track peer metadata.
Open questions
Are you planning to do it yourself in a pull request?
No, or at least not any time soon.
Metadata
Metadata
Assignees
Labels
difficulty:moderatehelp wantedpriority:importantThe changes needed are critical for libp2p, or are blocking another projectThe changes needed are critical for libp2p, or are blocking another project