paritytech / cumulus

Write Parachains on Substrate
GNU General Public License v3.0
620 stars 380 forks source link

How to properly test bootnodes with light clients #1957

Open pmensik opened 1 year ago

pmensik commented 1 year ago

Hello, I hope I am asking in the right repository :-) I wanted to set up a bootnode for Polkadot/Kusama/Westend networks and I ran into an issue - how to test that the websocket configuration with my own certificate is really working? I didn't find any documentation on this so I thought I will ask here. This is what I have tried

  1. I tested the bootnode on other node running with custom polkadot.json spec which lists only my bootnode. This works both for IP and DNS records of my bootnode
  2. I tried to test the light client connection with disabling all the other bootnodes in Substrate Connect browser extension and allowing only mine - this seems to work but I know that light clients work even without extension so it's not really conclusive. Also the extension by which bootnode is connected to the network doesn't show which specific RPC/bootnode is used for connection.
  3. I cloned smoldot repository and edited chainspec again in bin/polkadot.json - the weird issue is that sometimes even official Parity bootnodes won't work so it doesn't produce conclusive results as well. I actually tried to test various bootnodes while was at it and again, most of them didn't work - Polkadot JS times out while connecting to the RPC.

So now I am pretty much lost and wondering what would be the best to conclusively test that my bootnode configuration for WSS is working before I create PR to the polkadot repository. FYI, the bootnode I am trying to set up is

/dns/polkadot-bootnode.polkadotters.com/tcp/30333/p2p/12D3KooWCgNAXvn3spYBeieVWeZ5V5jcMha5Qq1hLMtGTcFPk93Y /dns/polkadot-bootnode.polkadotters.com/tcp/30334/ws/p2p/12D3KooWCgNAXvn3spYBeieVWeZ5V5jcMha5Qq1hLMtGTcFPk93Y

Thanks a lot for any hints!

wirednkod commented 1 year ago

Hey @pmensik . You will probably need a TLS certificate on your bootnode (also wss) in order to workaround the browser's security measures. You can have a look at this post that says some things that you could test as well, but overall browsers do not allow non secure connections - thus a wss would be needed

pmensik commented 1 year ago

Hey @wirednkod, thanks for the reply! Yeah, I already have done the whole setup, I was just wondering how to test it and make sure it's really working. In other words, if there is some other way than interacting with smoldot directly since I found it a bit inconclusive (sometimes even Parity bootnodes won't work). But I am gonna try to play with it a bit more. By the way, I just have a two questions regarding the bootnode config

  1. I can see that Parity bootnodes are having only one record in the specfile (with /443/wss/p2p). Does that mean that bootnode just needs to provide its WSS address and not a plain one in a form of /tcp/30333/p2p? The reason I am asking is that some bootnodes are actually providing both types of addresses.
  2. What is the default port for WS (WSS)? Is it 30334 or 9944?

I include my config for clarity

Nginx

server {
  server_name polkadot-bootnode.polkadotters.com;
  access_log /var/log/nginx/polkadot-bootnode.log;
  listen 443 ssl;
  gzip off;

  location / {
    proxy_pass http://127.0.0.1:30334;
    proxy_http_version 1.1;
    # setting the headers
  }

  ssl_certificate /etc/letsencrypt/live/polkadot-bootnode.polkadotters.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/polkadot-bootnode.polkadotters.com/privkey.pem;
  include /etc/letsencrypt/options-ssl-nginx.conf;
  ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}

Node config

ExecStart=/usr/local/bin/polkadot \
  --name Polkadotters-Bootnode \
  --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' \
  --base-path '/var/lib/polkadot' \
  --chain=polkadot 
  --listen-addr /ip4/0.0.0.0/tcp/30333 \
  --listen-addr /ip4/0.0.0.0/tcp/30334/ws \
  --public-addr /dns/polkadot-bootnode.polkadotters.com/tcp/30333 \
  --public-addr /dns/polkadot-bootnode.polkadotters.com/tcp/30334/ws \
  --ws-external \
  --rpc-external \
  --rpc-methods Safe \
  --rpc-cors all \
wirednkod commented 1 year ago

You can interact with smoldot straight by using the demo provided in it's repo: https://github.com/paritytech/smoldot/blob/main/bin/wasm-node/javascript/demo/demo.mjs

Unfortunately I cannot give you a definitive answer on your second question but for the first one I am aware that these are the bootnodes that light client correctly interacts with. The rest are there since the creation of the chainspec some time ago.