libp2p / libp2p/js-libp2p

Dial queue optimisation when dealing with DNSADDRs

Open
#3,589 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

need/triage
Dominant language
TypeScript
Stars
2.6k
Forks
546
Avg merge
8h 18m
Merged PRs (30d)
16

Description

A peer can have a DNSADDR:

/dnsaddr/sg1.bootstrap.libp2p.io

This can resolve to 0-n addresses:

%  dig +short TXT _dnsaddr.sg1.bootstrap.libp2p.io
"dnsaddr=/dns/sg1.bootstrap.libp2p.io/tcp/4001/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt"
"dnsaddr=/dns/sg1.bootstrap.libp2p.io/udp/4001/quic-v1/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt"
"dnsaddr=/dns/sg1.bootstrap.libp2p.io/tcp/443/wss/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt"

And also recursive DNSADDR addresses:

 %  dig +short TXT _dnsaddr.bootstrap.libp2p.io 
"dnsaddr=/dnsaddr/sg1.bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt"
"dnsaddr=/dnsaddr/ny5.bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa"
"dnsaddr=/dnsaddr/am6.bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb"
"dnsaddr=/dnsaddr/sv15.bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN"

Performing these look ups during a dial is expensive, and it's possible to pass a set of multiaddrs to libp2p.dial that contains a mix of DNSADDRs and regular addresses.

Currently js-libp2p resolves DNSADDRs before sorting the results and performing dials - instead it could sort the passed list (deprioritising DNSADDRS), then perform dials, only resolving DNSADDRs when they are encountered.

Resolved addresses would need filtering and sorting before dialing, same as the original list, and a list of previously dialed addresses would also be necessary to ensure we don't (fail to) dial an address, then resolve a DNSADDR to a set of addresses that includes one we just failed to dial, and then re-dial it.

A upcoming change to someguy (it powers delegated-ipfs.dev) will resolve DNSADDRs before returning peers, including both the DNSADDR and any resolved addresses in the result, so it would be wasted effort to re-resolve those addresses before dialing.

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 at the libp2p.dial entry point and trace the current DNSADDR resolution, address sorting, and dial flow. Check how resolved addresses are filtered and how previously dialed addresses could be tracked. Done means regular addresses are tried before DNSADDRs, DNSADDRs resolve only when reached, and resolved duplicates are not redialed.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.