libp2p / libp2p/rust-libp2p

quic: index hole-punches by remote address and `PeerId`

Open
#4,067 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

difficulty:hard
Dominant language
Rust
Stars
5.6k
Forks
1.3k
Avg merge
8h 47m
Merged PRs (30d)
19

Description

Description

In https://github.com/libp2p/rust-libp2p/commit/cf3e4c6860d591fb53b40fc95f40ef9a9b6af363, we added hole punching for QUIC. Currently, the map of active hole punches is indexed only by the remote's address.

This presents a problem if multiple peers share a single UDP socket.

To be fully correct, we should index our hole punches by socket address AND expected PeerId. To implement this however, we need to upgrade the connection in the QUIC transport, as the incoming connection is just a Future.

How this upgrade should happen is unclear:

  1. Spawning a new task from inside the Transport would create potentially unbounded work where a remote node can spam us with incoming connections.
  2. Running the upgrade on the main task would introduce latency to usercode that also drives NetworkBehaviours.
  3. Having a single background task remove the parallelism we have for connection upgrades in the Swarm.

One possible solution that we've debated is to move away from upgrading connections in the Swarm and instead change the Transport interface to do this for us. To still have parallelism for those, each Transport implementation would have to do this itself. Additionally, dial and dial_as_listener would no longer be able to return a Future but would have to return a DialId and the established connection as part of its event in poll.

This in turn presents a new problem: We need to be able to cancel in-progress dials to implement something like happy-eyeballs. Currently, we can just drop the returned Future.

Are you planning to do it yourself in a pull request?

No.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the QUIC hole-punching implementation and the Transport and Swarm connection-upgrade paths described in the issue. Compare the proposed upgrade designs, including dial cancellation and parallelism, and consider the work complete only when active hole punches are keyed by socket address and expected PeerId without unbounded work or added usercode latency.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.