2

Right now I have one cloud instance running a node, and 2 local instances on the same computer. On my local instances, in the bootnodes flag I pass the address to my cloud instance. Initially I was expecting that this would result in (2 peers) showing up on each of my local instances, but only my cloud instance shows (2 peers), the local instances show (1 peer), which is the cloud instance.

Now my initial mental model was that this cloud instance would just be used as a means to sync up or discover other nodes in the network, and the nodes would then decide amongst themselves how to send communication to the fastest/nearest node, rather than the bootnode. Resulting in (2 peers) showing for each node (local or remote).

What I am asking is a networking question, does it happen that my local nodes could be communicating between themselves without going through the remote instance? Say local A produced a block, will that information be relayed directly to local B or through remote and then to local B?

Also, is it possible to use the bootnode as just a discovery point for other nodes? If not, is it possible to specify multiple bootnodes (if yes how)?

2
  • may I ask how you set up your cloud machine? I'm trying to do the same, but for some reason I can't get my local nodes to connect to the cloud node. Apr 30, 2022 at 22:03
  • @edmassarani I suggest you ask a question on this forum and provide enough details to your problems to make it a good question. May 1, 2022 at 8:58

1 Answer 1

4

To directly answer the question as stated: yes, you can connect to multiple bootnodes.

Libp2p is meant to discover nodes from its connected nodes by using a Kademlia implementation of a Distributed Hash Table (DHT).

Oftentimes, in my experience, nodes on the same machine often discover each other without bootnodes through the use of MDNS, which libp2p also implements. This is, for example, why you can run two nodes on a --local development chain without updating the chain-spec and it will work.

You can specify multiple bootnodes either in the chain spec JSON file or override them on the command line with the --bootnodes flag.

For example, here's the Rococo v2_1 chain-spec, which gives many boot nodes.

{
  "name": "Rococo",
  "id": "rococo_v2_1",
  "chainType": "Live",
  "bootNodes": [
    "/ip4/34.90.151.124/tcp/30333/p2p/12D3KooWF7BUbG5ErMZ47ZdarRwtpZamgcZqxwpnFzkhjc1spHnP",
    "/ip4/34.90.151.124/tcp/30334/ws/p2p/12D3KooWF7BUbG5ErMZ47ZdarRwtpZamgcZqxwpnFzkhjc1spHnP",
    "/ip4/34.90.137.14/tcp/30333/p2p/12D3KooWLcpkpvjr5ccgtUdTSYtNDjEdsDcPNrt2Rb7yXuAf7bUE",
    "/ip4/34.90.137.14/tcp/30334/ws/p2p/12D3KooWLcpkpvjr5ccgtUdTSYtNDjEdsDcPNrt2Rb7yXuAf7bUE",
    "/ip4/35.204.67.254/tcp/30333/p2p/12D3KooWGjEEDmNbBkXLM1uKMseK9iYD3osKA4JGdGKMZDCusjd6",
    "/ip4/35.204.67.254/tcp/30334/ws/p2p/12D3KooWGjEEDmNbBkXLM1uKMseK9iYD3osKA4JGdGKMZDCusjd6",
    "/ip4/34.90.121.39/tcp/30333/p2p/12D3KooWBhkZQydNHDR3XSehnrfj1KNFCdpwgDrYpX54FrUR1FRS",
    "/ip4/34.90.121.39/tcp/30334/ws/p2p/12D3KooWBhkZQydNHDR3XSehnrfj1KNFCdpwgDrYpX54FrUR1FRS",
    "/ip4/34.91.145.35/tcp/30333/p2p/12D3KooWBuLAMevZexnFKCgTyoz3AnHQn98D9cfe1Mg3kPoCjkwf",
    "/ip4/34.91.145.35/tcp/30334/ws/p2p/12D3KooWBuLAMevZexnFKCgTyoz3AnHQn98D9cfe1Mg3kPoCjkwf",
    "/ip4/34.91.77.80/tcp/30333/p2p/12D3KooWA5BAM71y9NtV5NH6EjANgYKRZ8jNLJ5z8GJ5RPdjt63n",
    "/ip4/34.91.77.80/tcp/30334/ws/p2p/12D3KooWA5BAM71y9NtV5NH6EjANgYKRZ8jNLJ5z8GJ5RPdjt63n",
    "/ip4/34.91.84.25/tcp/30333/p2p/12D3KooWSV4VqhBHZKKBsZKmVU462qRW9PmXTSuYvuajt1P93djA",
    "/ip4/34.91.84.25/tcp/30334/ws/p2p/12D3KooWSV4VqhBHZKKBsZKmVU462qRW9PmXTSuYvuajt1P93djA",
    "/ip4/34.91.97.19/tcp/30333/p2p/12D3KooWD6wC88atMMyVeP6ZKg9sK7QmUL8x8m1RxMW8rhv2vWyg",
    "/ip4/34.91.97.19/tcp/30334/ws/p2p/12D3KooWD6wC88atMMyVeP6ZKg9sK7QmUL8x8m1RxMW8rhv2vWyg"
  ],
  # ... much omitted
}

And the help text for --bootnodes is:

--bootnodes <ADDR>...                                        
            Specify a list of bootnodes
2
  • I haven't seen ws/.. before, does it stand for web socket? If yes why would a node need websocket for peering? Apr 7, 2022 at 4:42
  • Yes, it's for websockets. I think that the intention 'ws' addresses are published so nodes running in the browser can connect over websockets. Since they can't use tcp.
    – rob
    Apr 7, 2022 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.