Building Collator node

Let's get started

Let's start with updating our server. Connect to your server and update:
1
sudo apt-get update
2
sudo apt-get upgrade
3
sudo apt install -y adduser libfontconfig1
Copied!

Build the node

To build a collator node, you have 3 different options

Build from source

Building a node from source code is the most complicated path, but will also provide the best optimized node version for your server.
Make sure your server is ready to build a collator:
1
## Install Rust
2
##
3
curl https://sh.rustup.rs -sSf | sh
4
source $HOME/.cargo/env
5
rustup update nightly
6
rustup target add wasm32-unknown-unknown --toolchain nightly
7
8
## Compilation required software
9
##
10
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
11
sudo apt install cmake
12
sudo apt install git
13
sudo apt install build-essential
14
sudo apt update
15
sudo apt install clang
Copied!
Clone the Astar repository:
1
git clone https://github.com/AstarNetwork/Astar.git
2
cd Astar
Copied!
Make sure you have the latest commit in place:
1
git checkout
2
git pull
Copied!
Compile the node binary:
1
CARGO_PROFILE_RELEASE_LTO=true RUSTFLAGS="-C codegen-units=1" cargo build --release
Copied!

Build from binaries

The easiest way to install an Astar node is to download the binaries. You can find them here:
GitHub - AstarNetwork/Astar: The dApp Hub for blockchains of the future
GitHub
Astar releases
Get the file and extract:
1
wget $(curl -s https://api.github.com/repos/AstarNetwork/Astar/releases/latest | grep "tag_name" | awk '{print "https://github.com/PlasmNetwork/Plasm/releases/download/" substr($2, 2, length($2)-3) "/astar-collator-" substr($2, 3, length($2)-4) "-ubuntu-x86_64.tar.gz"}')
2
tar -xvf astar-collator*.tar.gz
Copied!

Run a Docker container

You can find here the Astar Docker hub.
Docker documentation is not detailed for collators because we don't recommend to run a collator from a container. If you do have good reasons to do so, you can refer to our Docker archive node guide and adapt with the commands below.

Start node

Create a dedicated user for the node and move the node binary:
1
sudo useradd --no-create-home --shell /usr/sbin/nologin astar
2
sudo cp ./astar-collator /usr/local/bin
3
chmod +x astar-collator*.tar.gz
Copied!
Create a dedicated directory for the chain storage data:
1
sudo mkdir /var/lib/astar
2
sudo chown astar:astar /var/lib/astar
Copied!
Let's first go to our binary directory and start the node manually:
Astar
Shiden
Shibuya
1
cd /usr/local/bin
2
./astar-collator --validator --chain astar --name ${COLLATOR_NAME} --parachain-id 2006 --rpc-cors all --base-path /var/lib/astar --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' --execution wasm --state-cache-size 1
Copied!
1
cd /usr/local/bin
2
./astar-collator --validator --chain shiden --parachain-id 2007 --name ${COLLATOR_NAME} --rpc-cors all --base-path /var/lib/astar --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' --execution wasm --state-cache-size 1
Copied!
1
cd /usr/local/bin
2
./astar-collator --validator --chain shibuya --parachain-id 1000 --name ${COLLATOR_NAME} --rpc-cors all --base-path /var/lib/astar --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' --execution wasm --state-cache-size 1
Copied!
Type in the place of ${COLLATOR_NAME}, how you would like to call your node.
Check on https://telemetry.polkadot.io/ to see your node syncing.
Useful commands to be used in screen: ctrl+a+d (detach actual session) screen ls (this will list all running screens) screen -r (restore a screen session)
Stop the manual node and kill the screen session:
1
ctrl+c
2
ctrl+a+k
Copied!

Set systemd service

To run a stable collator node, a systemd service has to be set and activated. This will ensure that the node is restarting even after a server reboot.
Create a service file
1
sudo nano /etc/systemd/system/astar.service
Copied!
Add service parameters:
Astar
Shiden
Shibuya
1
[Unit]
2
Description=Astar Collator
3
4
[Service]
5
User=astar
6
Group=astar
7
8
ExecStart=/usr/local/bin/astar-collator \
9
--collator \
10
--rpc-cors all \
11
--name ${COLLATOR_NAME} \
12
--chain astar \
13
--parachain-id 2006 \
14
--base-path /var/lib/astar \
15
--telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' \
16
--execution wasm \
17
--state-cache-size 1
18
19
Restart=always
20
RestartSec=120
21
22
[Install]
23
WantedBy=multi-user.target
Copied!
1
[Unit]
2
Description=Shiden Collator
3
4
[Service]
5
User=astar
6
Group=astar
7
8
ExecStart=/usr/local/bin/astar-collator \
9
--collator \
10
--rpc-cors all \
11
--name ${COLLATOR_NAME} \
12
--chain shiden \
13
--parachain-id 2007 \
14
--base-path /var/lib/astar \
15
--telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' \
16
--execution wasm \
17
--state-cache-size 1
18
19
Restart=always
20
RestartSec=120
21
22
[Install]
23
WantedBy=multi-user.target
Copied!
1
[Unit]
2
Description=Shibuya Collator
3
4
[Service]
5
User=astar
6
Group=astar
7
8
ExecStart=/usr/local/bin/astar-collator \
9
--collator \
10
--rpc-cors all \
11
--name ${COLLATOR_NAME} \
12
--chain shibuya \
13
--parachain-id 1000 \
14
--base-path /var/lib/astar \
15
--telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' \
16
--execution wasm \
17
--state-cache-size 1
18
19
Restart=always
20
RestartSec=120
21
22
[Install]
23
WantedBy=multi-user.target
Copied!
Do not forget to change ${COLLATOR_NAME}
Start the service:
1
sudo systemctl start astar.service
Copied!
Check the node log and that everything is syncing fine:
1
journalctl -f -u astar.service -n100
Copied!
Enable the service:
1
sudo systemctl enable astar.service
Copied!

Finalizing

To finalize your collator you need to:
  • Setup an account
  • Author your session key
  • Set up your session key
  • Verify your identity
  • Bond tokens
All these steps can be found here: