Skip to main content

Setup L2-parachain node

We use docker to run the node in a container:

info

A parachain always also runs a relaychain tracking relaychain blocks so we will also need the relaychain chain-spec:

  • 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 3 files to the folder:

  • Open docker-compose.yml and insert <YOUR SERVER IP> 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:
    node:
    image: "gluechain/mainnet-glue-para-node:glue-v0.2.0"
    command: "--node-key <NODE KEY>
    --chain /node/glue-main-raw.json \
    --ethapi=txpool \
    --trie-cache-size 2073741824 \
    --db-cache 30000 \
    --base-path /node/data \
    --bootnodes /ip4/82.220.91.85/tcp/30645/p2p/12D3KooWSyDYvsPMdcaiwZrJ3XHvH4fpxmiBHoyPw4rZJ5aVDMSi /ip4/185.178.192.73/tcp/30633/p2p/12D3KooWPMbmnsoKACiX8xjnz7LtsR6sZtAthJ7sjtwPuVtgzRQZ /ip4/82.220.91.85/tcp/30634/ws/p2p/12D3KooWPU6p6inZGXrcqwYRv52FpoHpWvf9goQ2eFQPxjVrauyx \
    --port 30633 \
    --rpc-port 9963 \
    --rpc-external \
    --unsafe-rpc-external \
    --rpc-methods unsafe \
    --rpc-cors all \
    --database=rocksdb \
    --pruning=archive \
    --public-addr=/ip4/<YOUR SERVER IP>/tcp/<YOUR PORT SPECIFIED WITH --port ABOVE> \
    -- \
    --chain /node/glue-relaychain-main-raw.json \
    --bootnodes /ip4/82.220.38.222/tcp/30350/p2p/12D3KooWM7aJBsDma7q2gZmKm5d92Sbuqg54HtJEqDPUrdunepWF /ip4/185.142.214.6/tcp/30350/ws/p2p/12D3KooWJBQfccTBw9uvj93WwGGWManXTeGmJSL8BG4huzjpu6ad /ip4/185.178.192.73/tcp/30350/p2p/12D3KooWMx2yh6DvypMrYzg7Go96JAsHDdLNyzipEQXaaobVTiaX /ip4/82.220.91.85/tcp/30350/p2p/12D3KooWKsKk7P62LcaqspsUD5FhmojYmDZv4aeS11Fqe63dA7GR /ip4/82.220.91.69/tcp/30350/ws/p2p/12D3KooWDSDiXhhvLTasSvkHS7pwMGVczPSvFDVHDW25Lhvi3o8z /ip4/82.220.91.85/tcp/30351/ws/p2p/12D3KooWGrcHbYMfswS2SWTRJzVyQoWR7fRY5eXtNgyJK5RCVMiA \
    --port 30643 \
    --rpc-port 9961"
    ports:
    - "30633:30633"
    - '9963:9963'
    - "30643:30643"
    - "9961:9961"
    volumes:
    - ./:/node
    restart: always

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 ([🌗] 🆕 Imported is enough to know bootnodes discovery worked, and 💤 Idle 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)​

  • install caddy

  • copy this file to /etc/caddy/Caddyfile

    glue-l2-node.<YOUR DOMAIN> {
    @websockets {
    header Connection *Upgrade*
    header Upgrade websocket
    }
    reverse_proxy @websockets localhost:9963
    reverse_proxy localhost:9963 {
    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