User Setup

This tutorial is meant to get a single node syncing to the Cardano blockchain! We have skipped certain steps and security in order to make this tutorial as easy as possible - DO NOT USE this tutorial to form a mainnet stake pool. Please use our intermediate guides for the mainnet.

This tutorial is for use with the official Raspberry Pi 64-bit OS and is solely for development educational purposes to get a Raspberry Pi Cardano node syncing to the blockchain.

Summary

  1. Environment Setup

  2. Downloading the binaries needed to build a Cardano node relay

  3. Download configuration files from IOHK/Cardano-node

  4. Edit the config settings

  5. Download a database snapshot to speed up the sync process

  6. Run the basic passive relay node to connect to the testnet

  7. Monitor the relay node with Guild Operators gLiveView

Setting up our environment

  • We must first update our OS and install needed upgrades if available.

It is highly recommended to update the operating system every time you boot up and log in to your Raspberry Pi to prevent security vulnerabilities.

# We are using the sudo prefix to run commands as non-root-user
​
sudo apt update
sudo apt upgrade -y
  • We can now reboot the Pi and let the updates take effect by running this command in a terminal.

sudo reboot

Make our directories

testnet
mainnet
testnet
mkdir -p $HOME/.local/bin
mkdir -p $HOME/testnet-relay/files
mainnet
mkdir -p $HOME/.local/bin
mkdir -p $HOME/mainnet-relay/files

Add ~/.local/bin to our $PATH

echo PATH="$HOME/.local/bin:$PATH" >> $HOME/.bashrc

Create our bash variables

testnet
mainnet
testnet
echo export NODE_HOME=$HOME/testnet-relay >> $HOME/.bashrc
echo export NODE_FILES=$HOME/testnet-relay/files >> $HOME/.bashrc
echo export NODE_CONFIG=testnet >> $HOME/.bashrc
echo export NODE_BUILD_NUM=$(curl https://hydra.iohk.io/job/Cardano/iohk-nix/cardano-deployment/latest-finished/download/1/index.html | grep -e "build" | sed 's/.*build\/\([0-9]*\)\/download.*/\1/g') >> $HOME/.bashrc
echo export CARDANO_NODE_SOCKET_PATH="$NODE_HOME/db/socket" >> $HOME/.bashrc
source $HOME/.bashrc
mainnet
echo export NODE_HOME=$HOME/mainnet-relay >> $HOME/.bashrc
echo export NODE_FILES=$HOME/mainnet-relay/files >> $HOME/.bashrc
echo export NODE_CONFIG=mainnet >> $HOME/.bashrc
echo export NODE_BUILD_NUM=$(curl https://hydra.iohk.io/job/Cardano/iohk-nix/cardano-deployment/latest-finished/download/1/index.html | grep -e "build" | sed 's/.*build\/\([0-9]*\)\/download.*/\1/g') >> $HOME/.bashrc
echo export CARDANO_NODE_SOCKET_PATH="$NODE_HOME/db/socket" >> $HOME/.bashrc
source $HOME/.bashrc
sudo reboot

Download the Cardano-node static build

Provided By

Link to Cardano Static Build

​ZW3RK 1PCT Haskell CI Support Pool

​https://ci.zw3rk.com/build/1758​

Now we need to download the zip file above to our Pi's home directory and then move it to the right location so we can call on it later to start the node.

# First change to the home directory
cd $HOME
​
# Now we can download the cardano-node
wget https://ci.zw3rk.com/build/1758/download/1/aarch64-unknown-linux-musl-cardano-node-1.27.0.zip
  • Use unzip command on the downloaded zip file and extract its contents.

    unzip aarch64-unknown-linux-musl-cardano-node-1.27.0.zip
  • Next, we need to make sure the newly downloaded "cardano-node" folder and its contents are present.

If you are unsure if the file downloaded properly or need the name of the folder/files, we can use the Linux ls command.

Now we need to move the cardano-node folder into our local binary directory.

mv cardano-node/* ~/.local/bin

Before we proceed let's make sure the cardano-node and cardano-cli is in our $PATH

cardano-node version
cardano-cli version

Now we can move into our files folder, and download the four Cardano node configuration files we need from the official IOHK website and or documentation. We will be using the "wget" command to download the files.

cd $NODE_FILES
wget https://hydra.iohk.io/build/${NODE_BUILD_NUM}/download/1/${NODE_CONFIG}-byron-genesis.json
wget https://hydra.iohk.io/build/${NODE_BUILD_NUM}/download/1/${NODE_CONFIG}-topology.json
wget https://hydra.iohk.io/build/${NODE_BUILD_NUM}/download/1/${NODE_CONFIG}-shelley-genesis.json
wget https://hydra.iohk.io/build/${NODE_BUILD_NUM}/download/1/${NODE_CONFIG}-config.json
  • Use the nano bash editor to change a few things in our "testnet-config.json" file

  • Change the "TraceBlockFetchDecisions" line from "false" to "true"

  • Change the "hasEKG" to 12600

  • Change the "hasPrometheus" address/port to 12700

sudo nano testnet-config.json

Create the systemd files

We will use the Linux systemd service manager to handle the starting, stopping, and restarting of our Cardano node relay.

If you'd like to find out more about Linux and systemd go to the Linux manual page.

sudo nano $HOME/.local/bin/cardano-service

Now we need to make the cardano-node startup script

How to start the cardano-node can be found here on the Cardano documentation.

Testnet
Mainnet
Testnet
#!/bin/bash
DIRECTORY=/home/pi/testnet-relay
FILES=/home/pi/testnet-relay/files
PORT=3001
HOSTADDR=0.0.0.0
TOPOLOGY=${FILES}/testnet-topology.json
DB_PATH=${DIRECTORY}/db
SOCKET_PATH=${DIRECTORY}/db/socket
CONFIG=${FILES}/testnet-config.json
​
cardano-node +RTS -N4 --disable-delayed-os-memory-return -qg -qb -c -RTS run \
--topology ${TOPOLOGY} \
--database-path ${DB_PATH} \
--socket-path ${SOCKET_PATH} \
--host-addr ${HOSTADDR} \
--port ${PORT} \
--config ${CONFIG}
Mainnet
#!/bin/bash
DIRECTORY=/home/pi/mainnet-relay
FILES=/home/pi/mainnet-relay/files
PORT=3001
HOSTADDR=0.0.0.0
TOPOLOGY=${FILES}/mainnet-topology.json
DB_PATH=${DIRECTORY}/db
SOCKET_PATH=${DIRECTORY}/db/socket
CONFIG=${FILES}/mainnet-config.json
​
cardano-node +RTS -N4 --disable-delayed-os-memory-return -qg -qb -c -RTS run \
--topology ${TOPOLOGY} \
--database-path ${DB_PATH} \
--socket-path ${SOCKET_PATH} \
--host-addr ${HOSTADDR} \
--port ${PORT} \
--config ${CONFIG}

Now we must give access permission to our new systemd service script

sudo chmod +x $HOME/.local/bin/cardano-service
sudo nano /etc/systemd/system/cardano-node.service
Testnet
Mainnet
Testnet
# The Cardano Node Service (part of systemd)
# file: /etc/systemd/system/cardano-node.service
​
[Unit]
Description = Cardano node service
Wants = network-online.target
After = network-online.target
​
[Service]
User = pi
Type = simple
WorkingDirectory= /home/pi/testnet-relay
ExecStart = /bin/bash -c "PATH=/home/pi/.local/bin:$PATH exec /home/pi/.local/bin/cardano-service"
KillSignal=SIGINT
RestartKillSignal=SIGINT
TimeoutStopSec=3
LimitNOFILE=32768
Restart=always
RestartSec=5
​
[Install]
WantedBy= multi-user.target
Mainnet
# The Cardano Node Service (part of systemd)
# file: /etc/systemd/system/cardano-node.service
​
[Unit]
Description = Cardano node service
Wants = network-online.target
After = network-online.target
​
[Service]
User = pi
Type = simple
WorkingDirectory= /home/pi/mainnet-relay
ExecStart = /bin/bash -c "PATH=/home/pi/.local/bin:$PATH exec /home/pi/.local/bin/cardano-service"
KillSignal=SIGINT
RestartKillSignal=SIGINT
TimeoutStopSec=3
LimitNOFILE=32768
Restart=always
RestartSec=5
​
[Install]
WantedBy= multi-user.target

We now should reload our systemd service to make sure it picks up our cardano-service

sudo systemctl daemon-reload

If we don't want to call "sudo systemctl" everytime we want to start, stop, or restart the cardano-node service we can create a "function" that will be added into our .bashrc shell script that will do this for us

​https://www.routerhosting.com/knowledge-base/what-is-linux-bashrc-and-how-to-use-it-full-guide/​

​

nano $HOME/.bashrc
cardano-service() {
sudo systemctl "$1" cardano-node.service
}
source $HOME/.bashrc

Download a snapshot of the blockchain to speed the sync process

We have been provided a snapshot of the testnet database thanks to Star Forge Pool [OTG]. If you don't want to download a database, you may skip this step. Beware, if you skip downloading our snapshot it may take up to 28 hours to get the node fully synced.

Make sure you have not started a Cardano node before proceeding. πŸ›‘

First, make sure the cardano-service we created earlier is stopped, then we download the database in our testnet-relay/files. You can run the following commands to begin our download.

# Make sure you do not have the cardano-node running in the background
cardano-service stop
cd $NODE_HOME
# Remove old db and its contents if present
rm -r db/
#Download testnet db snapshot
wget -r -np -nH -R "index.html*" -e robots=off https://test-db.adamantium.online/db/

Finish syncing to the blockchain

  • Now we can start the "passive" relay node to begin syncing to the blockchain.

cd $HOME
cardano-service enable
cardano-service start
cardano-service status

Setting up gLiveView to monitor the node during its syncing process

Now you can change to the $NODE_FILES folder and then download the gLiveView monitor service

sudo apt-get install jq
cd $NODE_FILES
curl -s -o gLiveView.sh https://raw.githubusercontent.com/cardano-community/guild-operators/master/scripts/cnode-helper-scripts/gLiveView.sh
curl -s -o env https://raw.githubusercontent.com/cardano-community/guild-operators/master/scripts/cnode-helper-scripts/env
chmod 755 gLiveView.sh
  • Need to change the "CNODE_PORT" to the port you set on your cardano-node, in our case let's change it to 3001.

sudo nano env
  • Finally, we can exit the nano editor and just run the gLiveView script.

./gLiveView.sh

If you want to monitor your Raspberry Pi performance you can use the following commands.

Get Cpu Temp
Use htop for CPU and RAM Performance
Get Cpu Temp
vcgencmd measure_temp
Use htop for CPU and RAM Performance
htop

References: