Skip to main content

Setup Collator Node

How do you setup a Collator Node?#

This guide covers how to set up a DataHighway Collator Node on the Tanganika Network.

Provisioning a server#

Provision an appropriately sized server from a reputable VPS provider, e.g.: Vultr, DigitalOcean, Linode, OVH, Contabo, Scaleway, Amazon AWS, etc.

We recommend a node with at least 4GB of RAM, and Ubuntu 18.04 x64. Other operating systems will require adjustments to these instructions.

SSH into the server.

Installing DataHighway and setting it up as a system service#

Building the binary from source#

apt updateapt install -y gcc libc6-devapt install -y cmake pkg-config libssl-dev git clang libclang-dev

Prefetch SSH publickeys

ssh-keyscan -H github.com >> ~/.ssh/known_hosts

Install rustup

curl https://sh.rustup.rs -sSf | sh -s -- -ysource $HOME/.cargo/envexport PATH=$HOME/.cargo/bin:$PATH

Clone the DataHighway-DHX/DataHighway-Parachain repository

git clone https://github.com/DataHighway-DHX/DataHighway-Parachaincd DataHighway-Parachain

Checkout to latest release tag. At the time of updating this document, latest release is 3.7.1

git checkout v3.7.1

Build packages

curl https://getsubstrate.io -sSf | bash -s -- --fast && \./scripts/init.sh

Download a prebuilt binary#

Instead of building from source, you can download a prebuilt binary from the official DHX Parachain Github release. To get the prebuilt binary with the chainspec definitions:

Create a datahighway folder in opt:

mkdir /opt/datahighway
  • Datahighway binary
wget https://github.com/DataHighway-DHX/DataHighway-Parachain/releases/download/v3.7.1/datahighway-collator -O /opt/datahighway/datahighway-collator-v3.7.1
  • Kusama relay chainspec file
wget https://github.com/DataHighway-DHX/DataHighway-Parachain/releases/download/v3.7.1/kusama.json -O /opt/datahighway/kusama.json
  • Datahighway chainspec file
wget https://raw.githubusercontent.com/DataHighway-DHX/DataHighway-Parachain/v3.6.0/res/kusama/kusama-parachain-raw.json -O /opt/datahighway/kusama-parachain-raw.json

NOTE: If you're running a v3.6.0 node and want to upgrade to v3.7.1, please be sure to check the GRANDPA ISSUE.#

Set up the node as a system service.#

To do this, navigate into the root directory of the DataHighway-DHX/DataHighway-Parachain repo and execute the following to create the service configuration file.

NOTE: If any command throws something like Permission denied, run it with sudo.

Create a new script at /opt/datahighway/start.sh with the following content:

#!/bin/bash
NAME="Datahighway_mainnet_server_3"RELAY_SPEC="/opt/datahighway/kusama.json"PARA_SPEC="/opt/datahighway/kusama-parachain-raw.json"COLLATOR_PATH="/opt/datahighway/datahighway-collator-v3.7.1"RELAY_PORT="40444"RELAY_RPC_PORT="7676"RELAY_WS_PORT="8787"PARA_RPC_PORT="7677"PARA_WS_PORT="8788"PARA_PORT="50555"PARA_DATABASE_BASE="~/.chains/datahighway-mainnet/para/"RELAY_DATABASE_BASE="~/.chains/datahighway-mainnet/relay/"PARA_BOOTNODE="/ip4/3.127.123.230/tcp/40333/p2p/12D3KooWHJ9NwkCNJ8BFD4BptJybQQSyBJm1mtr3XRpfqWR5vjaj"
CMD="$COLLATOR_PATH --collator \    --chain $PARA_SPEC \    --force-authoring \    --unsafe-ws-external \    --unsafe-rpc-external \    --rpc-cors=all \    --rpc-methods=Unsafe \    --name "\"$NAME\"" \    --port $PARA_PORT \    --rpc-port $PARA_RPC_PORT \    --ws-port $PARA_WS_PORT \    --bootnodes $PARA_BOOTNODE \    --base-path $PARA_DATABASE_BASE \    -- \    --chain $RELAY_SPEC \    --execution wasm \    --port $RELAY_PORT \    --rpc-port $RELAY_RPC_PORT \    --ws-port $RELAY_WS_PORT \    --base-path $RELAY_DATABASE_BASE \"
echo "-----------------------"echo "Executing: $CMD"echo "----------------------"
$CMD

Notes on the parameters:

  • NAME - name of your node
  • RELAY_SPEC - chain spec file of the relay chain (download from the Github Release page)
  • PARA_SPEC - chain spec file of the parachain (download from the Github Release page)
  • PARA_DATABASE_BASE - path to the parachain database
  • RELAY_DATABASE_BASE - path to the relay database

Grant execute permissions to the start script and collator executable:

chmod +x /opt/datahighway/start.shchmod +x /opt/datahighway/datahighway-collator-v3.7.1

To start the collator as a service, run the following script:

{  echo '[Unit]'  echo 'Description=DataHighway'  echo '[Service]'  echo 'Type=simple'  echo 'ExecStart=/opt/datahighway/start.sh'  echo '[Install]'  echo 'WantedBy=multi-user.target'} > /etc/systemd/system/datahighway.service

Double check that the config has been written to /etc/systemd/system/datahighway.service correctly.

cat /etc/systemd/system/datahighway.service

Each time you change the service file you need to reload it

systemctl daemon-reload

Then enable the service so it runs on startup, and then try to start it now:

systemctl enable datahighwaysystemctl start datahighway

Check the status of the service:

systemctl status datahighway

You should see the Tanganika parachain collator node connecting to Kusama relay chain and other collator node peers and syncing the latest blocks. If you like to follow the log output, you can use:

journalctl -u datahighway.service -f

Generate and add your Aura session keys (author ID) for your collator node to sign blocks with on Tanganika:

From /opt/datahighway directory you can run this command:

curl http://127.0.0.1:7677 -H "Content-Type:application/json;charset=utf-8" -d   '{    "jsonrpc":"2.0",    "id":1,    "method":"author_insertKey",    "params": ["aura", "$suri", "$pkey"]  }'

Replace $suri with your node key secret word, eg: same jelly ceiling beauty tunnel delay exile science three winner balance minute

And replace $pkey with the public key generated from $suri, eg: 0x6849bcd876d48609c6d38a6511f53873d571aaece8a73923c1488d496d3f2510

Set Session Keys#

DataHighway is using Collator Selection pallet for registering collators.

  1. Go to the Tanganika Polkadot.js portal: Developer > Extrinsic
  2. Select your collator account and extrinsic type: session / setKeys
  3. Enter the session keys and set proof to 0x00
  4. Submit the transaction.

Register as a Collator candidate#

To start collating, you need to have 10 DHX tokens

  1. Go to the Tanganika Polkadot.js portal: Developer > Extrinsic

  2. Select your collator account and extrinsic type: parachainStaking / joinAsCandidate. Provide the amount of DHX you want to stake. This should be in full denomation, For example if you want to stake 50 DHX, enter 50000000000000000000

  3. Submit the transaction.

Onboarding takes place at n+1 session.