Skip to main content

Setup relaychain node

We use docker to run the node in a container:

info
  • Create a folder for the node on your server:

    mkdir -p mainnet-collator-x data
    WIP

    Ensure your folder for the collator has a unique name in case you run other collators/validators on the same machine. Otherwise docker compose might treat them as the same container.

  • Copy the 2 files to the folder:

  • Use the subkey utility to generate a unique ID for the p2p protocol:

    docker run -it --rm --name subkey parity/subkey generate-node-key

    which outputs the node-key as last output line

    12D3KooWGhRoTxJrh3nWyh2EsbB9V6Zk7S3KhDRxWZepNJ9UX4cw
    886c2b63f665d5634b639adef8d4108e64ab5505511c724f31d41b1e8538a8d9
  • Open docker-compose.yml and insert <YOUR SERVER IP>, <BOOT NODES>, <NODE KEY>, generated previously and optionally adapt the ports and docker image tag if outdated (it's not set to latest tag by default to avoid suddenly breaking your applications because of upcoming incompatibilites with newer images).

    Highlight changes
    services:
    validator:
    image: gluechain/mainnet-relay-node:glue-v0.1.0
    command: "--chain /node/chain-specs/glue-relaychain-main-raw.json \
    --node-key <NODE KEY> \
    --base-path /node/data \
    --public-addr=/ip4/<YOUR SERVER IP>/tcp/30351 \
    --bootnodes <BOOT NODES> \
    --port 30351 \
    --rpc-port 9951 \
    --rpc-external \
    --unsafe-rpc-external \
    --rpc-methods unsafe \
    --rpc-cors all \
    --pruning archive \
    --enable-offchain-indexing=true"
    ports:
    - "30351:30351"
    - "9951:9951"
    volumes:
    - ./:/node
    restart: always
    Node-key

    The node-key argument is not mandatory but highly recommended for nodes that are later promoted to be validators. It ensures that your node retains its identity, making it discoverable by peers without the risk of conflicting identities across sessions. If not specified, a node-key will be generated on first startup and written to a file only.

On the server:

  • Install docker

  • Run docker compose up -d in the same folder.

  • Check logs with docker compose logs -f and see if it logs that it's syncing, 💤 Idle (X peers) tells you that node is synced.

  • Once synced, go ahead and expose the collator (9934) over a reverse proxy of your choice (nginx, caddy)

Upgrade node​

When being notified that a new binary version is ready, you should change the image in docker-compose.yml to the defined version. We recommend using specific version and not latest for maximum reproducibiltiy of issues.

Then restart while ensuring it pulls the changed version (you can validate in the output that a new version is pulled indeed):

docker compose up -d --build

Setup reverse proxy (load balancing)​

If you use caddy it's as simple as:

  • install caddy

  • copy this file to /etc/caddy/Caddyfile

    glue-relaychain-node.<YOUR DOMAIN> {
    @websockets {
    header Connection *Upgrade*
    header Upgrade websocket
    }
    reverse_proxy @websockets localhost:9951
    reverse_proxy localhost:9951 {
    transport http {
    versions 1.1
    }
    }
    }
  • [Optional] add multiple host:port upstreams to activate load balancing

  • Validate proxy config

    caddy validate --config /etc/caddy/Caddyfile
  • Restart proxy

    systemctl restart caddy