How To Deploy A Casper Node on Linux
Running a node is among the most practical ways to understand and interact with the Casper ecosystem. With that in mind, our article will show you how to deploy a Casper node on Linux. By the end of the guide, you can manage to set up your own node and help boost the network's security.
What is a Casper Node?
A Casper node is a full node on the Casper Network blockchain. It is responsible for storing the blockchain's state, validating transactions, and proposing and voting on blocks. Casper nodes are rewarded with CSPR tokens for their participation in the network.
Running a Casper node is a great way to support the Casper Network and earn CSPR tokens. It is also a good way to learn more about how blockchains work.
Casper Node Setup Requirements
Hardware Specs
To run a Casper Mainnet or Testnet node, ensure your system meets the following hardware specifications:
- CPU: 4 Cores
- RAM: 32 GB
- Storage: 2 TB SSD or network SSD-backed disk
- Operation system: Linux machine running Ubuntu 20.04
Note: The use of SSD is essential because HDDs cannot perform random writes at the required performance level to stay in sync with the full speed of the network.
Disc Space Usage for Non-Archival Nodes:
For non-archival nodes, disk usage will decrease once data recovery is implemented. It is recommended to gradually increase the disk space as needed while closely monitoring the server's capability for this expansion.
CPU Requirements
Running a Casper node on older hardware may lead to unexpected crashes if the CPU does not support instructions used by official Casper binaries, including AVX2 and Intel SHA extensions.
To avoid these issues, it is advisable to have a CPU with one of the following architectures:
- AMD Zen
- Intel Ice Lake or newer architecture
Network Requirements
The Casper node uses the following ports:
- 35000: This is the main networking port for the node. It is required to be externally visible so that other nodes on the network can connect to it.
- 7777: This is the RPC endpoint for interaction with the JSON-RPC API.
- 8888: This is the REST endpoint for status and metrics. This endpoint provides information about the node's health and performance.
- 9999: This is the SSE endpoint for event stream.
Of these ports, only 35000 is required to be open for your node to function. However, opening 8888 will allow others to know about general network health.
Note: The CPU requirements mentioned above only apply to official Casper binaries released by the project. If you are compiling your node from scratch, you have the option to disable the mentioned extensions. Check out the Hardware Specs page for future updates.
How to Deploy a Casper Node on Linux
Required Clean Up
Before setting up a Casper node, ensure you clean up state (if you previously ran a node on the box)
sudo systemctl stop casper-node-launcher.servicesudo apt remove -y casper-clientsudo apt remove -y casper-nodesudo apt remove -y casper-node-launchersudo rm /etc/casper/casper-node-launcher-state.tomlsudo rm -rf /etc/casper/1_*sudo rm -rf /var/lib/casper/*
Set up repository
Set up the Casper Labs repository for packages using the commands:
echo "deb https://repo.casperlabs.io/releases" bionic main | sudo tee -a /etc/apt/sources.list.d/casper.listcurl -O https://repo.casperlabs.io/casper-repo-pubkey.ascsudo apt-key add casper-repo-pubkey.ascsudo apt update
Install casper-node-launcher
sudo apt install -y casper-client casper-node-launcher jq
Enable Bash Auto-Completion for casper-client (Optional)
sudo casper-client generate-completion
You can change bash
to the --shell
argument:
--shell <STRING> The type of shell to generate the completion script for [default: bash] [possible values: zsh, bash, fish, powershell, elvish]sudo casper-client generate-completion --shell powershell
You can activate the new auto-completion script for the current shell by sourcing it or by logging out and logging in again:
source /usr/share/bash-completion/completions/casper-client
After you have sourced the new auto-completion script, you can press the tab
key when you are typing a command in the casper-client
to get auto-completion suggestions.
Installing All Protocols
On Mainnet, run:
sudo -u casper /etc/casper/node_util.py stage_protocols casper.conf
On Testnet, run:
sudo -u casper /etc/casper/node_util.py stage_protocols casper-test.conf
Validator Keys
The following command is for creating validator keys (if you don't have them):
sudo -u casper casper-client keygen /etc/casper/validator_keys
Getting a Trusted Hash
To get a trusted hash, run the following command, replacing node_address with the address of a node on the network of your choice:
sudo sed -i "/trusted_hash =/c\trusted_hash = '$(casper-client get-block --node-address http://3.14.161.135:7777 -b 20 | jq -r .result.block.hash | tr -d '\n')'" /etc/casper/1_0_0/config.toml
The list of active peers is available at https://cspr.live/tools/peers.
Starting the Node
To start the node, you can run the following commands:
sudo /etc/casper/node_util.py rotate_logssudo /etc/casper/node_util.py start
Monitoring the Synchronization Process
To get the node synchronization details, you can run the following command:
/etc/casper/node_util.py watch
When you first run the watch
command, you may see the message RPC: Not Ready
. This means that the node is not yet synchronized with the network. Once the node is synchronized, the status will change to RPC: Ready
and you will see a similar output:
Last Block: 630151 (Era: 4153)Peer Count: 297Uptime: 4days 6h 40m 18s 553msBuild: 1.4.5-a7f6a648d-casper-mainnetKey: 0147b4cae09d64ab6acd02dd0868722be9a9bcc355c2fdff7c2c244cbfcd30f158Next Upgrade: NoneRPC: Ready● casper-node-launcher.service - Casper Node Launcher Loaded: loaded (/lib/systemd/system/casper-node-launcher.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2022-03-16 21:08:50 UTC; 4 days ago Docs: https://docs.casper.network Main PID: 2934 (casper-node-lau) Tasks: 12 (limit: 4915) CGroup: /system.slice/casper-node-launcher.service ├─ 2934 /usr/bin/casper-node-launcher └─16842 /var/lib/casper/bin/1_4_5/casper-node validator /etc/casper/1_4_5/config.toml
If the node is not displaying an active (running) status, it is either stopped or currently undergoing a restart.
Monitoring the Running Node
To monitor your running node, you can use two of the tools below:
- Status.py: https://github.com/RapidMark/casper-tools
- Grafana: https://github.com/matsuro-hadouken/casper-tools
Make sure you check out Casper Docs for further updates, as well as how to upgrade your node and how to join the network.