Guide to Staking on Ethereum 2.0 (Ubuntu/Pyrmont/Prysm)

Warnings

Acknowledgements and Disclaimer

Support

Prerequisites

Note for Raspberry Pi Users

Requirements

Overview

Step 0 — Connect to the Server

# adduser <yourusername>
# usermod -aG sudo <yourusername>
# rsync --archive --chown=<yourusername>:<yourusername> ~/.ssh /home/<yourusername>

Step 1 — Update the Server

$ sudo apt update && sudo apt upgrade
$ sudo apt dist-upgrade && sudo apt autoremove

Step 2 — Secure the Server

Configure the firewall

$ sudo ss -tulpn | grep ':<yourSSHportnumber>'
$ sudo ufw allow <yourSSHportnumber>/tcp
$ sudo nano /etc/ssh/sshd_config
$ sudo systemctl restart ssh
$ sudo ufw deny 22/tcp
$ sudo ufw allow 30303
$ sudo ufw allow 13000/tcp
$ sudo ufw allow 12000/udp
$ sudo ufw allow 3000/tcp
$ sudo ufw allow 9090/tcp
$ sudo ufw enable
$ sudo ufw status numbered

Step 3— Install and Run Go Ethereum Node

Install Go Ethereum

$ sudo add-apt-repository -y ppa:ethereum/ethereum
$ sudo apt update
$ sudo apt install geth

Run Go Ethereum as a Background Service

$ sudo useradd --no-create-home --shell /bin/false goeth
$ sudo mkdir -p /var/lib/goethereum
$ sudo chown -R goeth:goeth /var/lib/goethereum
$ sudo nano /etc/systemd/system/geth.service
[Unit]
Description=Ethereum go client
After=network.target
Wants=network.target
[Service]
User=goeth
Group=goeth
Type=simple
Restart=always
RestartSec=5
ExecStart=geth --goerli --http --datadir /var/lib/goethereum
[Install]
WantedBy=default.target
$ sudo systemctl daemon-reload
$ sudo systemctl start geth
$ sudo systemctl status geth
$ sudo systemctl enable geth
$ sudo journalctl -fu geth.service
$ sudo systemctl stop geth
$ sudo nano /etc/systemd/system/geth.service
ExecStart=geth --goerli --http --datadir /var/lib/goethereum --bootnodes "enode://46add44b9f13965f7b9875ac6b85f016f341012d84f975377573800a863526f4da19ae2c620ec73d11591fa9510e992ecc03ad0751f53cc02f7c7ed6d55c7291@94.237.54.114:30313,enode://119f66b04772e8d2e9d352b81a15aa49d565590bfc9a80fe732706919f8ccd00a471cf8433e398c55c4862aadb4aadf3a010201483b87e8358951698aa0b6f07@13.250.50.139:30303"
$ sudo systemctl daemon-reload
$ sudo systemctl start geth
$ sudo journalctl -fu geth.service

Step 4— Install Bazel

$ sudo apt install curl gnupg
$ curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
$ sudo mv bazel.gpg /etc/apt/trusted.gpg.d/
$ echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
$ sudo apt update && sudo apt install bazel
$ sudo apt update && sudo apt full-upgrade
$ sudo apt update && sudo apt install bazel-3.2.0
$ sudo apt install -y libtinfo5 # Terminal handling
$ sudo apt-get install -y libssl-dev # OpenSSL
$ sudo apt-get install -y libgmp-dev # GMP source to build BLS

Step 5— Install and Build Prysm

$ git clone -b v1.0.0-beta.3 --single-branch https://github.com/prysmaticlabs/prysm.git
$ cd prysm
$ bazel build //beacon-chain:beacon-chain --config=release
$ bazel build //validator:validator --config=release

Step 6— Configure the Beacon Chain

Setup Accounts and Directories

$ sudo useradd --no-create-home --shell /bin/false prysm-beaconchain
$ sudo mkdir -p /var/lib/prysm/beaconchain
$ sudo chown -R prysm-beaconchain:prysm-beaconchain /var/lib/prysm/beaconchain

Copy the Beacon Chain Binary

$ cd ~
$ sudo cp prysm/bazel-bin/cmd/beacon-chain/beacon-chain_/beacon-chain /usr/local/bin

Create and Configure the Service

$ sudo nano /etc/systemd/system/prysm-beaconchain.service
[Unit]
Description=Prysm Beaconchain
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=prysm-beaconchain
Group=prysm-beaconchain
Restart=always
RestartSec=5
ExecStart=/usr/local/bin/beacon-chain --pyrmont --datadir=/var/lib/prysm/beaconchain --http-web3provider=http://127.0.0.1:8545 --accept-terms-of-use
[Install]
WantedBy=multi-user.target
$ sudo systemctl daemon-reload
$ sudo systemctl start prysm-beaconchain
$ sudo systemctl status prysm-beaconchain
$ sudo systemctl enable prysm-beaconchain
$ sudo journalctl -fu prysm-beaconchain.service

Step 7— Complete the Pyrmont On-boarding Process

Get Goerli ETH

Generate Validator Keys

$ cd ~
$ curl -LO https://github.com/ethereum/eth2.0-deposit-cli/releases/download/v1.1.0/eth2deposit-cli-ed5a6d3-linux-amd64.tar.gz
$ tar xvf eth2deposit-cli-ed5a6d3-linux-amd64.tar.gz
$ cd eth2deposit-cli-ed5a6d3-linux-amd64
$ rm -rf eth2deposit-cli-ed5a6d3-linux-amd64.tar.gz
$ ./deposit new-mnemonic --num_validators <numberofvalidators> --mnemonic_language=english --chain pyrmont

Fund the Validator Keys

Check the Status of Your Validators

Step 8 — Create the Validator Wallet

$ sudo mkdir -p /var/lib/prysm/validator
$ sudo chown -R <yourusername>:<yourusername> /var/lib/prysm/validator
$ cd prysm
$ bazel run //validator:validator -- accounts import --keys-dir=<PathToValidatorKeys> --accept-terms-of-use --pyrmont
Enter a wallet directory (default: /home/ethstaker/.eth2validators/prysm-wallet-v2):
/var/lib/prysm/validator
Password requirements: at least 8 characters including at least 1 alphabetical character, 1 number, and 1 unicode special character. Must not be a common password nor easy to guess
New wallet password:
Confirm password:
[2020-11-18 21:47:26] INFO accounts: Successfully created new wallet wallet-path=/var/lib/prysm/validator
Enter the password for your imported accounts:
Importing accounts, this may take a while...
Importing accounts... 100% [==========================================] [2s:0s]
Successfully imported 2 accounts, view all of them by running accounts list
$ bazel run //validator:validator -- accounts list --pyrmont --wallet-dir /var/lib/prysm/validator --accept-terms-of-use
Showing 2 validator accounts
View the eth1 deposit transaction data for your accounts by running `validator accounts list --show-deposit-data
Account 0 | loosely-apparent-feline
[validating public key] 0x8c8b19c544d79bdaf60d7dcc86ebaeeed5d804d2ecb4c66e5b27e19a664a81457a1c02a873a110e1d332abce5800cf7f
Account 1 | remarkably-tight-herring
[validating public key] 0xa79583298ecbd5564fce6ccefe2e69967705aff950235dc59ae303fa210b029b565c08303eb18cf02ecc26c429059d7f
$ touch /var/lib/prysm/validator/password.txt
$ sudo nano /var/lib/prysm/validator/password.txt
$ sudo chmod go-rw /var/lib/prysm/validator/password.txt

Step 9— Configure the Validator

Setup Accounts and Directories

$ sudo useradd --no-create-home --shell /bin/false prysm-validator
$ sudo chown -R prysm-validator:prysm-validator /var/lib/prysm/validator
$ cd ~
$ sudo cp prysm/bazel-bin/cmd/validator/validator_/validator /usr/local/bin

Create and Configure the Service

$ sudo nano /etc/systemd/system/prysm-validator.service
[Unit]
Description=Validator
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=prysm-validator
Group=prysm-validator
Restart=always
RestartSec=5
ExecStart=/usr/local/bin/validator --pyrmont --datadir=/var/lib/prysm/validator --wallet-dir=/var/lib/prysm/validator --wallet-password-file=/var/lib/prysm/validator/password.txt --graffiti="<POAPString>" --accept-terms-of-use
[Install]
WantedBy=multi-user.target
$ sudo systemctl daemon-reload
$ sudo systemctl start prysm-validator
$ sudo systemctl status prysm-validator
$ sudo systemctl enable prysm-validator
$ sudo journalctl -fu prysm-validator.service
Nov 18 21:54:35 ETH-STAKER-001 validator[119395]: time="2020-11-18 21:54:35" level=info msg="Waiting for deposit to be observed by beacon node" prefix=validator pubKey=0x8c8b19c544d7 status="UNKNOWN_STATUS"

Step 10 — Install Prometheus

Create User Accounts

$ sudo useradd --no-create-home --shell /bin/false prometheus
$ sudo useradd --no-create-home --shell /bin/false node_exporter

Create Directories

$ sudo mkdir /etc/prometheus
$ sudo mkdir /var/lib/prometheus
$ sudo chown -R prometheus:prometheus /etc/prometheus
$ sudo chown -R prometheus:prometheus /var/lib/prometheus

Download Prometheus software

$ cd ~
$ curl -LO https://github.com/prometheus/prometheus/releases/download/v2.22.0/prometheus-2.22.0.linux-amd64.tar.gz
$ tar xvf prometheus-2.22.0.linux-amd64.tar.gz
$ sudo cp prometheus-2.22.0.linux-amd64/prometheus /usr/local/bin/
$ sudo cp prometheus-2.22.0.linux-amd64/promtool /usr/local/bin/
$ sudo chown -R prometheus:prometheus /usr/local/bin/prometheus
$ sudo chown -R prometheus:prometheus /usr/local/bin/promtool
$ sudo cp -r prometheus-2.22.0.linux-amd64/consoles /etc/prometheus
$ sudo cp -r prometheus-2.22.0.linux-amd64/console_libraries /etc/prometheus
$ sudo chown -R prometheus:prometheus /etc/prometheus/consoles
$ sudo chown -R prometheus:prometheus /etc/prometheus/console_libraries
$ rm -rf prometheus-2.22.0.linux-amd64.tar.gz prometheus-2.22.0.linux-amd64

Edit the Configuration File

$ sudo nano /etc/prometheus/prometheus.yml
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: 'node_exporter'
static_configs:
- targets: ['localhost:9100']
$ sudo chown -R prometheus:prometheus /etc/prometheus/prometheus.yml
$ sudo -u prometheus /usr/local/bin/prometheus \
--config.file /etc/prometheus/prometheus.yml \
--storage.tsdb.path /var/lib/prometheus/ \
--web.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries
level=info ts=2020-10-21T07:18:00.434Z caller=main.go:684 msg="Server is ready to receive web requests."

Set Prometheus to Auto-Start as a Service

$ sudo nano /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=prometheus
Group=prometheus
Restart=always
RestartSec=5
ExecStart=/usr/local/bin/prometheus \
--config.file /etc/prometheus/prometheus.yml \
--storage.tsdb.path /var/lib/prometheus/ \
--web.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries
[Install]
WantedBy=multi-user.target
$ sudo systemctl daemon-reload
$ sudo systemctl start prometheus
$ sudo systemctl status prometheus
$ sudo systemctl enable prometheus

Step 11 — Install Node Exporter

$ cd ~
$ curl -LO https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gz
$ tar xvf node_exporter-1.0.1.linux-amd64.tar.gz
$ sudo cp node_exporter-1.0.1.linux-amd64/node_exporter /usr/local/bin
$ sudo chown -R node_exporter:node_exporter /usr/local/bin/node_exporter
$ rm -rf node_exporter-1.0.1.linux-amd64.tar.gz node_exporter-1.0.1.linux-amd64

Set Node Exporter to Auto-Start as a Service

$ sudo nano /etc/systemd/system/node_exporter.service
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target
$ sudo systemctl daemon-reload
$ sudo systemctl start node_exporter
$ sudo systemctl status node_exporter
$ sudo systemctl enable node_exporter

Test Prometheus and Node Exporter

http://<yourserverip>:9090/new/graph?g0.expr=node_memory_MemFree_bytes&g0.tab=1&g0.stacked=0&g0.range_input=1h
http://<yourserverip>:9090/graph?g0.range_input=1h&g0.expr=validator_balance&g0.tab=1

Step 12 — Install Grafana

$ wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
$ sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
$ sudo apt update
$ apt-cache policy grafana
grafana:
Installed: (none)
Candidate: 7.2.1
Version table:
7.2.1 500
500 https://packages.grafana.com/oss/deb stable/main amd64 Packages
7.2.0 500
500 https://packages.grafana.com/oss/deb stable/main amd64 Packages
7.1.5 500
500 https://packages.grafana.com/oss/deb stable/main amd64
...
$ sudo apt install grafana
$ sudo systemctl start grafana-server
$ sudo systemctl status grafana-server
$ sudo systemctl enable grafana-server

Configure Grafana Login

Configure the Grafana Data Source

Add data source screen.
Data source configuration.
Data source is confirmed working.

Import a Grafana Dashboard

Ethereum staking dashboard in Grafana.

Final Remarks

Appendix — Updating Prysm

$ sudo apt install -y libtinfo5 # Terminal handling
$ sudo apt-get install -y libssl-dev # OpenSSL
$ sudo apt-get install -y libgmp-dev # GMP source to build BLS
$ cd ~ 
$ rm -r prysm
$ git clone -b v1.0.0-beta.3 https://github.com/prysmaticlabs/prysm.git
$ cd prysm
$ bazel build //beacon-chain:beacon-chain --config=release
$ bazel build //validator:validator --config=release
$ cd ~
$ sudo systemctl stop prysm-validator
$ sudo systemctl stop prysm-beaconchain
$ sudo cp prysm/bazel-bin/beacon-chain/beacon-chain_/beacon-chain /usr/local/bin
$ sudo cp prysm/bazel-bin/validator/validator_/validator /usr/local/bin
$ sudo systemctl start prysm-beaconchain
$ sudo systemctl status prysm-beaconchain # <-- Check for errors.
$ sudo journalctl -fu prysm-beaconchain # <-- Check for errors.
$ sudo systemctl start prysm-validator
$ sudo systemctl status prysm-validator # <-- Check for errors.
$ sudo journalctl -fu prysm-validator # <-- Check for errors.

--

--

--

Passionate about Ethereum and decentralized technology.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Somer Esat

Somer Esat

Passionate about Ethereum and decentralized technology.

More from Medium

Fraud and security in DeFi: how do investors manage these risks?

Should More African States Adopt Bitcoin As Their Reserve Currency?

What the heck is Tokenomics? Please no math.

Ethereum- The Revolutionary Story of DeFi Monarch