Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce a proper address pipeline #2229

Open
7 tasks
marten-seemann opened this issue Mar 27, 2023 · 3 comments
Open
7 tasks

introduce a proper address pipeline #2229

marten-seemann opened this issue Mar 27, 2023 · 3 comments
Assignees
Labels
effort/weeks Estimated to take multiple weeks exp/wizard Extensive knowledge (implications, ramifications) required P1 High: Likely tackled by core team if no one steps up

Comments

@marten-seemann
Copy link
Contributor

marten-seemann commented Mar 27, 2023

We need to get a lot smarter about address management. Wrapping / replacing addresses via the AddrsFactory doesn't scale.

I'm imagining a new service that's responsible for the entire process of address management.

  1. It ingests in new "address candidates" from various sources: user provided address hints, transports claiming to listen on certain addresses, Identify, relay service etc.
  2. It verifies these addresses using AutoNAT v2.
  3. It groups and categorizes these addresses (public / private / relayed).
  4. It provides interfaces to make these different categories of addresses available to consumers.

Updated(@sukunrt): Using this issue for tracking:

Tasks

Preview Give feedback
@marten-seemann marten-seemann added exp/wizard Extensive knowledge (implications, ramifications) required P0 Critical: Tackled by core team ASAP effort/weeks Estimated to take multiple weeks labels Mar 27, 2023
@p-shahi p-shahi added P1 High: Likely tackled by core team if no one steps up and removed P0 Critical: Tackled by core team ASAP labels May 22, 2023
mergify bot pushed a commit to libp2p/rust-libp2p that referenced this issue May 24, 2023
Previously, a `NetworkBehaviour` could report an `AddressScore` for an external address. This score was a `u32` and addresses would be ranked amongst those.

In reality, an address is either confirmed to be publicly reachable (via a protocol such as AutoNAT) or merely represents a candidate that might be an external address. In a way, addresses are guilty (private) until proven innocent (publicly reachable).

When a `NetworkBehaviour` reports an address candidate, we perform address translation on it to potentially correct for ephemeral ports of TCP. These candidates are then injected back into the `NetworkBehaviour`. Protocols such as AutoNAT can use these addresses as a source for probing their NAT status. Once confirmed, they can emit a `ToSwarm::ExternalAddrConfirmed` event which again will be passed to all `NetworkBehaviour`s.

This simplified approach will allow us implement Kademlia's client-mode (#2032) without additional configuration options: As soon as an address is reported as publicly reachable, we can activate server-mode for that connection.

Related: #3877.
Related: #3953.
Related: #2032.
Related: libp2p/go-libp2p#2229.

Co-authored-by: Max Inden <mail@max-inden.de>

Pull-Request: #3954.
@sukunrt
Copy link
Member

sukunrt commented Jul 11, 2023

We need something like #2293 to test this.

umgefahren pushed a commit to umgefahren/rust-libp2p that referenced this issue Mar 8, 2024
Previously, a `NetworkBehaviour` could report an `AddressScore` for an external address. This score was a `u32` and addresses would be ranked amongst those.

In reality, an address is either confirmed to be publicly reachable (via a protocol such as AutoNAT) or merely represents a candidate that might be an external address. In a way, addresses are guilty (private) until proven innocent (publicly reachable).

When a `NetworkBehaviour` reports an address candidate, we perform address translation on it to potentially correct for ephemeral ports of TCP. These candidates are then injected back into the `NetworkBehaviour`. Protocols such as AutoNAT can use these addresses as a source for probing their NAT status. Once confirmed, they can emit a `ToSwarm::ExternalAddrConfirmed` event which again will be passed to all `NetworkBehaviour`s.

This simplified approach will allow us implement Kademlia's client-mode (libp2p#2032) without additional configuration options: As soon as an address is reported as publicly reachable, we can activate server-mode for that connection.

Related: libp2p#3877.
Related: libp2p#3953.
Related: libp2p#2032.
Related: libp2p/go-libp2p#2229.

Co-authored-by: Max Inden <mail@max-inden.de>

Pull-Request: libp2p#3954.
@sukunrt sukunrt self-assigned this Nov 1, 2024
@MarcoPolo MarcoPolo self-assigned this Nov 5, 2024
@sukunrt sukunrt self-assigned this Nov 29, 2024
@sukunrt
Copy link
Member

sukunrt commented Dec 2, 2024

The flow here is:

  1. Get listen addresses from the swarm.
  2. Different modules take these listen addresses and provide an estimate of the external address corresponding to these listen addrs.
  3. Collect all this info and test them via autonat v2.

So we have an object that's something like:

type AddrDetail struct {
    ListenAddr ma.Multiaddr // Swarm listen addr
    InterfaceAddr ma.Multiaddr // The interface for this address
    ExternalAddr ma.Multiaddr // The public facing address for this address
    Sources map[Source]struct{} // source can be machine interface, Identify, UserProvided(addr factory?), NAT Port Map, Autorelay
}

We then test these via autonat v2 and send updates on eventbus that includes both new addresses and their reachability changes.

@sukunrt
Copy link
Member

sukunrt commented Dec 2, 2024

https://github.com/libp2p/go-libp2p/pull/3075/files

Refactors the existing logic enough to make it readable.

@p-shahi p-shahi pinned this issue Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/weeks Estimated to take multiple weeks exp/wizard Extensive knowledge (implications, ramifications) required P1 High: Likely tackled by core team if no one steps up
Projects
None yet
Development

No branches or pull requests

4 participants