Skip to content

[discovery] Add support for AutoRelay #699

@jacobheun

Description

@jacobheun

AutoRelay enables libp2p nodes to dynamically find and bind to relays on the network. Once binding (listening) is done, the node can and should advertise its addresses to the network, allowing any other node to dial it over its bound relay(s). While direct connections to nodes are preferable, it's not always possible to do so due to NATs.

Use Cases

Finding Relays

A connected relay

The Circuit Relay module has the ability to ask connected nodes if they support the relay HOP protocol. If they do, the libp2p node can bind to that relay as a listener. A node should record a list of relays and use only a subset of those to avoid binding to a large number of relays, as this is not considerate to those relays.

  1. When a node connects to a peer that announces support for the relay protocol, /libp2p/circuit/relay/0.1.0, it may ask that node if it support HOP.
  2. If the peer supports HOP, libp2p should add it to its list of known relays.
  3. When a known relay is added, libp2p should check to see if it needs a/another relay (to meet some min threshold). If below that threshold, libp2p should bind to that relay and add it to its announced addresses.
    1. When adding announced addresses, libp2p SHOULD avoid adding private addresses of the relay, such as /ip4/127.0.0.1/tcp/4001.
    2. If libp2p does not have enough known relays, it should query the network if possible.
  4. When libp2p updates its addresses, it should update the network.
Remote Relays

When a node with AutoRelay enabled boots, it should search the network for the relay protocol, /libp2p/relay. This search may be done via one of several options leveraging libp2p.contentRouting.findProviders(). Depending on what features are turned on this may include: the DHT, Delegate Routing, and/or the Rendezvous Protocol (WIP).

If a node does not have enough known relays connected, and is unable to connect to other known relays, it should query the network for more relays. This should be done with a backoff to avoid spamming queries.

References:

Metadata

Metadata

Assignees

Labels

EpicP0Critical: Tackled by core team ASAPkind/enhancementA net-new feature or improvement to an existing featurestatus/readyReady to be worked

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions