Skip to content

RFC: Identify should remember discovered peers and assist in peer discovery using addresses_of_peer #2216

Closed
@thomaseizinger

Description

While implementing an address book here, I realized that we might be able to achieve the same functionality by adjusting how our existing protocols work. In particular, not all of our discovery-like protocols are currently assisting in peer discovery via addresses_of_peer. Identify for example does not override addresses_of_peer.

What do people think about changing that so that we remember the reported addresses of peers that we have discovered? I think the only issue here is that we potentially have an unbounded memory growth because there isn't really a natural event that we could leverage to clean-up old addresses.

Solutions I could think of:

  1. Use a LRU cache and simply cap its storage at some number of entries.
  2. Assign a TTL to each entry and have it expire automatically.

Ideally, Identify would also react to dial failures and remove entries that it reported but which turned out to be useless.

Having Identify remember reported addresses is particularly useful if:

  1. Node A knows about its own, externally reachable address
  2. Node B does not know about external addresses of node A
  3. Node A dials node B
  4. Node B learns via /identify about A's external addresses
  5. The Connection between node A and B gets closed

If Identify would remember the externally reachable addresses that have previously been identified, Node B would now be able to establish a connection to A by simply dialing its PeerId.
Currently, users of rust-libp2p have to actively handle IdentifyEvent and add all reported addresses to some other NetworkBehaviour that will report it as part of addresses_of_peer later.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions