Skip to content

Dial queue optimisation when dealing with DNSADDRs #3589

Description

@achingbrain

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    need/triageNeeds initial labeling and prioritization

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions