Eth2 staking on RaspberryPi 4 Part 2

dua.lis.wtf
5 min readDec 15, 2020

--

How to setup auto-start, monitoring dashboards and switch to main-net

See Eth2 staking on RaspberryPi 4 for Part 1

Step11: Autostart and keep validators online using systemd

Create prysm-beacon.service file:

sudo nano /etc/systemd/system/prysm-beacon.service

With contents:

Replace — http-web3provider with your provider URL, like in previous steps

[Unit]
Description=Prysm Beacon chain daemon
[Service]
ExecStartPre=/bin/sh -c 'until ping -c1 google.com; do sleep 1; done;'
ExecStart=/home/pi/prysm/prysm.sh beacon-chain --http-web3provider=https://eth-goerli.alchemyapi.io/v2/xxx --enable-upnp --accept-terms-of-use --datadir=/home/pi/.eth2-testnet --pyrmont
Restart=always
User=pi
[Install]
WantedBy=multi-user.target

Note: After=network.target was not working on my pi, so I replaced it with a ping to google servers.

Save (Ctrl+S) and exit (Ctrl+X).

Create prysm-validator.service file:

sudo nano /etc/systemd/system/prysm-validator.service

With contents:

[Unit]
Description=Prysm Validator daemon
After=prysm-beacon.service
[Service]
ExecStart=/home/pi/prysm/prysm.sh validator --web --wallet-password-file=/home/pi/.walletpassword --wallet-dir=/home/pi/.testnetwallet --accept-terms-of-use --pyrmont
Restart=always
User=pi
[Install]
WantedBy=multi-user.target

Save (Ctrl+S) and exit (Ctrl+X).

Create .walletpassword file:

nano ~/.walletpassword

With plain-text password of your wallet inside:

YOURP@$$W0RD

The auto start script needs it to unlock the wallet automatically.

Now enable the services

sudo systemctl enable prysm-beacon
sudo systemctl enable prysm-validator

and reboot

sudo reboot

After reboot, beacon and the validator should auto start.
You can check the startup errors using:

journalctl -u prysm-beacon
journalctl -u prysm-validator

To see beacon and validator progress use:

watch tail -n 15 /var/log/syslog

Step 12: Monitoring dashboards

Prysm web interface

Since we launched the validator with --web argument. The official prysm dashboards should be ready.
But it’s only accessible to raspberrypi itself.

We will need to forward some local ports.

This will forward all requests from your home computer’s localhost:7500 to the remote instance’s localhost:7500

Open new terminal and use this command to connect to pi:

ssh -L 7500:127.0.0.1:7500 -L 3500:127.0.0.1:3500 -L 8080:127.0.0.1:8080 -L 8081:127.0.0.1:8081 pi@raspberrypi

Now access you should be able to access http://localhost:7500
Use your wallet password to connect.

prysm dashboards

Setting up Prometheus+Grafana

Grafana is open source visualization and analytics software. It allows you to query, visualize, alert on, and explore your metrics.

Download and extract prometheus:

Prometheus must first be installed to fetch the data from the beacon node and validator for Grafana to display.

cd ~
wget https://github.com/prometheus/prometheus/releases/download/v2.23.0/prometheus-2.23.0.linux-armv7.tar.gz
tar xfz prometheus-2.23.0.linux-armv7.tar.gz

Rename extracted directory:

mv prometheus-2.23.0.linux-armv7 prometheus

Setup systemctl service:

sudo nano /etc/systemd/system/prometheus.service

Paste the following text into the file and save and exit:

[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target

[Service]
User=pi
Restart=on-failure

ExecStart=/home/pi/prometheus/prometheus \
--config.file=/home/pi/prometheus/prometheus.yml \
--storage.tsdb.path=/home/pi/prometheus/data

[Install]
WantedBy=multi-user.target

Replace prometheus config

nano ~/prometheus/prometheus.yml

with:

global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
- job_name: 'validator'
static_configs:
- targets: ['localhost:8081']
- job_name: 'beacon node'
static_configs:
- targets: ['localhost:8080']
- job_name: 'slasher'
static_configs:
- targets: ['localhost:8082']

Save (Ctrl+S) and exit (Ctrl+X).

Now enable and start the service

sudo systemctl --now enable prometheus

Download and extract Grafana:

cd ~
sudo apt-get install -y adduser libfontconfig1
wget https://dl.grafana.com/oss/release/grafana_7.3.5_arm64.deb
sudo dpkg -i grafana_7.3.5_arm64.deb

Now enable and start the service

sudo systemctl --now enable grafana-server

Now you can open http://raspberrypi:3000 (replace with your rpi IP) in a browser. By default, the username and the password to this panel are both ‘admin’.

Create a data source and choose Prometheus, then enter in the URL field http://localhost:9090.

Click on Save & Test.

Import this dashboard:
https://docs.prylabs.network/assets/grafana-dashboards/small_amount_validators.json

You should be able to enjoy your dashboard now. Do not forget to save it.

Grafana

Step13: Switching and validating on mainnet

Before proceeding with this step make sure your default rapsberrypi password is changed and it is behind a firewall. I did not cover any security practices in this guide to keep it short.

Let’s stop the services:

sudo systemctl stop prysm-beacon
sudo systemctl stop prysm-validator

Edit prysm-beacon and prysm-validator configs:

sudo nano /etc/systemd/system/prysm-beacon.service

Replace testnet provider with mainnet provider.

--http-web3provider=Get new mainnet URL from alchemyapi.io* or other provider.

*EDIT: I’m using infura now, as alchemy keeps hitting its free tier limits

And remove --datadir=/home/pi/.eth2-testnet --pyrmontarguments

Save (Ctrl+S) and exit (Ctrl+X).

Now for the prysm-validator:

sudo nano /etc/systemd/system/prysm-beacon.service

And remove --wallet-dir=/home/pi/.testnetwallet --pyrmontarguments

Save (Ctrl+S) and exit (Ctrl+X).

Create new deposit seed

Now we’re just repeating steps from Step9 just without --chain prymont

cd ~/eth2.0-deposit-cli
mv validator_keys validator_keys_old
python3 ./eth2deposit/deposit.py new-mnemonic --chain mainnet
deposit-cli tool

Keep your seeds safe

Open a new terminal and download the keys to your local machine (You will need it for next step)

scp -r pi@raspberrypi:eth2.0-deposit-cli/validator_keys validator_keys

Remember the location where above files are saved.

Now we can import the validator keys and start the validators.

~/prysm/prysm.sh validator accounts import --keys-dir=$HOME/eth2.0-deposit-cli/validator_keys

Use the default wallet directory /home/pi/.eth2validators/prysm-wallet-v2

Now we reboot and cross fingers 🤞

sudo reboot

See what’s going on:

watch tail -n 15 /var/log/syslog

Grafana dashboard: http://raspberrypi:3000
Prysm interface: http://localhost:7500 (Might be unresponsive during initial sync, do not forget port forwards)
Beaconchain: https://beaconcha.in/validator/YOUR-PUBLIC-KEY
(Beaconchain lets you setup notification alerts after signing up)

~/prysm/prysm.sh validator accounts list

Keep in mind that you will have to synchronize the blockchain again, since we switched from testnet to mainnet. This time it will be faster since mainnet is smaller at of time of writing.

However currently there is a validator queue of 14 days, as of time of writing.

Now follow the Official Eth2 mainnet launchpad step-by-step process to upload the deposit data and deposit your 32 ETH to become a validator.

launchpad.ethereum.org

Please follow the official Prysm docs for troubleshooting
https://docs.prylabs.network/docs/faq

--

--

No responses yet