substrate icon indicating copy to clipboard operation
substrate copied to clipboard

Cannot resolve bootnodes' libp2p multiaddr(`/dnsaddr`) in chainspec

Open shunsukew opened this issue 3 years ago • 3 comments

Is there an existing issue?

  • [X] I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • [X] This is not a support question.

Description of bug

libp2p supports /dnsaddr multiaddr(s) by looking up TXT records in DNS. https://github.com/multiformats/multiaddr/blob/master/protocols/DNSADDR.md I assumed that https://github.com/paritytech/substrate/issues/7811 made it possible to use multiaddr. However, Substrate returns errors when /dnsaddr is defined in chainspec's bootnodes list.

Error: Input("Error parsing spec file: Peer id is missing from the address at line 7 column 3")

Steps to reproduce

  1. Register TXT record _dnsaddr.{domain name} and value is dnsaddr=/ip4/{ip address}/tcp/30333/p2p/{parachain node identity}

  2. Make sure libp2p-lookup works

$ libp2p-lookup direct --address /dnsaddr/{domain name}
Lookup for peer with id PeerId("{Actual Peer Identity}") succeeded.
...
  1. Add /dnsaddr to raw chain spec json
{
    "bootNodes": [
        "/dnsaddr/{domain name}"
    ],
...
  1. Pass json file to Substrate --chain args

shunsukew avatar Jul 18 '22 13:07 shunsukew

We have the custom MultiaddrWithPeerId in Substrate. This requires that you have a multi-address that has a peer id attached. A lot of our code currently "requires" that we already know the peer id. We would probably need to change the code to first resolve the peer ids. However, I don't know how to do this actually. @kpp @tomaka do you maybe know if we can resolve a multiaddr that starts with dnsaddr to some "normal" multiaddr? (I mean it is done somewhere in libp2p, I just don't know how complicated it is to do this from the outside)

bkchr avatar Jul 19 '22 07:07 bkchr

This is an expected behavior. There could be multiple records associated with the provided dnsaddr, section #suffix-matching says how to match against peer id in order to get the right record. Even ipfs has to specify p2p|ipfs peer id in their list of bootstrap nodes.

@bkchr do we need a different approach? Something like resolve -> get list of nodes -> add to bootstrap list?

kpp avatar Jul 19 '22 11:07 kpp

@bkchr do we need a different approach? Something like resolve -> get list of nodes -> add to bootstrap list?

Sounds correct to me.

bkchr avatar Jul 28 '22 08:07 bkchr