Deploying Tangle Collator and Relayer
It is likely that network participants that are running a Tangle collator node may also want to run a relayer node. This guide will walk you through the process of deploying a Tangle collator and a Webb Relayer. By the end of this document, you will have set up a Webb Relayer at a publicly accessible endpoint alongside a Tangle Collator node both of which will be running within a Docker container.
Prerequisites
It is a requirement to have Docker installed on the Linux machine, for instructions on how to install Docker on the machine please visit the offical Docker installation documentation here (opens in a new tab).
When connecting to Tangle on Kusama, it will take a few days to completely sync the embedded relay chain. Make sure that your system meets the requirements which can read here.
Using Docker Compose
The quickest and easiest way to get started is to make use of our published Docker Tangle image. In doing so, users simply create a local directory to store the chain data, download the latest chainspec for parachain testnet, set their keys, and run the start command to get up and running.
1. Pull the Tangle Docker image:
We will used the pre-built Tangle Docker image to generate and insert the required keys for our node.
# Only use "main" if you know what you are doing, it will use the latest and maybe unstable version of the node.
docker pull ghcr.io/webb-tools/tangle/tangle-parachain:main
2. Create a local directory to store the chain data:
Let us create a directory where we will store all the data for our node. This includes the chain data, keys, and logs.
mkdir /var/lib/tangle/
3. Generate and store keys:
We need to generate the required keys for our node. For more information on these keys, please see the Required Keys section. The keys we need to generate include the following:
- DKG key (Ecdsa)
- Aura key (Sr25519)
- Account key (Sr25519)
Let's now insert our required secret keys, we will not pass the SURI in the command, instead it will be interactive, where you should paste your SURI when the command asks for it.
Account Keys
# it will ask for your suri, enter it.
docker run --rm -it --platform linux/amd64 --network="host" -v "/var/lib/data" \
ghcr.io/webb-tools/tangle/tangle-parachain:main \
key insert --base-path /var/lib/tangle/ \
--chain /data/chainspecs/tangle-parachain.json \
--scheme Sr25519 \
--key-type acco
Aura Keys
docker run --rm -it --platform linux/amd64 --network="host" -v "/var/lib/data" \
ghcr.io/webb-tools/tangle/tangle-parachain:main \
key insert --base-path /var/lib/tangle/ \
--chain /data/chainspecs/tangle-parachain.json \
--scheme Sr25519 \
--key-type aura
Im-online Keys - these keys are optional
docker run --rm -it --platform linux/amd64 --network="host" -v "/var/lib/data" \
ghcr.io/webb-tools/tangle/tangle-parachain:main \
key insert --base-path /var/lib/tangle/ \
--chain /data/chainspecs/tangle-parachain.json \
--scheme Sr25519 \
--key-type imon
DKG Keys
docker run --rm -it --platform linux/amd64 --network="host" -v "/var/lib/data" \
ghcr.io/webb-tools/tangle/tangle-parachain:main \
tangle-parachain key insert --base-path /data \
--chain /data/chainspecs/tangle-parachain.json \
--scheme Ecdsa \
--key-type wdkg
To ensure you have successfully generated the keys correctly run:
ls ~/webb/tangle/collator/chains/*/keystore
# You should see a some file(s) there, these are the keys.
4.Creating Docker compose file:
Now that we have generated the keys, we can start the Tangle Collator and Relayer. We will use the docker-compose
file provided
in the Tangle repo (opens in a new tab).
Let's start by creating a docker-compose file:
nano ~/webb/tangle/docker-compose.yml
Add the following lines:
# This an example of a docker compose file which contains both Relayer and Tangle Node.
version: "3"
services:
webb_relayer:
# Here you should checkout
# https://github.com/webb-tools/relayer/pkgs/container/relayer/versions?filters%5Bversion_type%5D=tagged
# For the latest stable version. Only use "edge" if
# you know what you are doing, it will use the latest and maybe
# unstable version of the relayer.
image: ghcr.io/webb-tools/relayer:${RELAYER_RELEASE_VERSION}
container_name: webb_relayer
env_file: .env
depends_on:
- caddy
ports:
- "$WEBB_PORT:$WEBB_PORT"
volumes:
- $PWD/config:/config
- relayer_data:/store
restart: always
command: /webb-relayer -vvv -c /config
tangle_parachain:
# Here you should checkout
# https://github.com/webb-tools/tangle/pkgs/container/tangle-parachain/versions?filters%5Bversion_type%5D=tagged
# For the latest stable version. Only use "main" if
# you know what you are doing, it will use the latest and maybe
# unstable version of the node.
image: ghcr.io/webb-tools/tangle/tangle-parachain:${TANGLE_RELEASE_VERSION}
container_name: tangle_parachain
env_file: .env
ports:
- "30333:30333"
- "9933:9933"
- "9944:9944"
- "9615:9615"
volumes:
- tangle_data:/data
restart: always
entrypoint: /tangle-parachain
command:
[
"--base-path=/data",
"--collator",
"--chain=/data/chainspecs/parachain.json",
"--",
"--execution=wasm",
]
volumes:
relayer_data:
driver: local
driver_opts:
type: none
o: bind
device: $PWD/relayer/data
tangle_data:
driver: local
driver_opts:
type: none
o: bind
device: $PWD/tangle/collator
5. Set environment variables:
Prior to spinning up the Docker containers, we need to set some environment variables. Below displays an example .env
file
but you will need to update to reflect your own environment.
export TANGLE_RELEASE_VERSION=main
export RELAYER_RELEASE_VERSION=0.5.0-rc1
export BASE_PATH=/tmp/data/
export CHAINSPEC_PATH=/tmp/chainspec
export WEBB_PORT=9955
5. Start Relayer and Collator node:
With our keys generated and our docker-compose file created, we can now start the relayer and collator node.
docker compose up -d
The docker-compose
file will spin up a container running Tangle Collator node and another running a Webb Relayer.
Update the Client
As Tangle development continues, it will sometimes be necessary to upgrade your node software. Node operators will be notified on our Discord channel when upgrades are available and whether they are necessary (some client upgrades are optional). The upgrade process is straightforward and is the same for a full node or collator.
- Stop the docker container:
sudo docker stop `CONTAINER_ID`
-
Get the latest version of Tangle from the Tangle GitHub Release page
-
Use the latest version to spin up your node. To do so, replace the version in the Full Node or Collator command with the latest and run it
Once your node is running again, you should see logs in your terminal.
Purge Your Node
If you need a fresh instance of your Tangle node, you can purge your node by removing the associated data directory.
You'll first need to stop the Docker container:
sudo docker stop `CONTAINER_ID`
If you did not use the -v flag to specify a local directory for storing your chain data when you spun up your node, then the data folder is related to the Docker container itself. Therefore, removing the Docker container will remove the chain data.
If you did spin up your node with the -v flag, you will need to purge the specified directory. For example, for the suggested data directly, you can run the following command to purge your parachain and relay chain data:
# purges parachain data
sudo rm -rf /data/chains/*
# purges relay chain data
sudo rm -rf /data/polkadot/*
Now that your chain data has been purged, you can start a new node with a fresh data directory!