Guide to Staking on Ethereum 2.0 (Ubuntu/Prater/Nimbus)

Warnings

Acknowledgements and Disclaimer

Support

Prerequisites

Note for Raspberry Pi Users

Requirements

Overview

Step 1— Generate Staking Data

Download the Deposit Tool (Eth2 Deposit CLI)

$ cd ~
$ sudo apt install curl
$ curl -LO https://github.com/ethereum/eth2.0-deposit-cli/releases/download/v1.2.0/eth2deposit-cli-256ea21-linux-amd64.tar.gz
$ sudo tar xvf eth2deposit-cli-256ea21-linux-amd64.tar.gz
$ cd eth2deposit-cli-256ea21-linux-amd64

Run the Deposit Tool (Eth2 Deposit CLI)

$ ./deposit new-mnemonic --num_validators NumberOfValidators --mnemonic_language=english --chain prater
deposit.exe new-mnemonic --num_validators NumberOfValidators --mnemonic_language=english --chain prater

Step 2— Connect to the Server

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

Step 3— Update the Server

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

Step 4— 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 9000
$ sudo ufw allow 3000/tcp
$ sudo ufw allow 9090/tcp
$ sudo ufw enable
$ sudo ufw status numbered

Step 5— Configure Timekeeping

$ timedatectl
$ sudo timedatectl set-ntp on
$ ntpq -p
$ sudo apt-get remove ntp

Step 6— 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 --ws --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 -f -u 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 -f -u geth.service

Step 7 — Install Nimbus Dependencies

$ sudo apt-get install build-essential git

Step 8— Clone and Build Nimbus

$ cd ~
$ git clone https://github.com/status-im/nimbus-eth2
$ cd nimbus-eth2
$ make nimbus_beacon_node

Step 9— Copy the Nimbus Binary

$ sudo cp /$HOME/nimbus-eth2/build/nimbus_beacon_node /usr/local/bin

Step 10 — Import Validator Keys

$ sudo mkdir -p /var/lib/nimbus
$ sudo chown -R <yourusername>:<yourusername> /var/lib/nimbus
$ sudo chmod 700 /var/lib/nimbus
$ ls -dl /var/lib/nimbus
$ cd ~
$ cd /usr/local/bin
$ nimbus_beacon_node deposits import --data-dir=/var/lib/nimbus $HOME/eth2deposit-cli-256ea21-linux-amd64/validator_keys

Step 11 — Configure the Beacon Node and Validator

Setup Accounts and Directories

$ sudo useradd --no-create-home --shell /bin/false nimbus
$ sudo chown -R nimbus:nimbus /var/lib/nimbus
$ ls -dl /var/lib/nimbus

Create and Configure the Service

$ sudo nano /etc/systemd/system/nimbus.service
[Unit]
Description=Nimbus Beacon Node
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=nimbus
Group=nimbus
Restart=always
WorkingDirectory=/var/lib/nimbus
Environment="ClientIP=$(curl -s v4.ident.me)"
ExecStart=/bin/bash -c '/usr/local/bin/nimbus_beacon_node --network=prater --data-dir=/var/lib/nimbus --web3-url=ws://127.0.0.1:8546 --metrics --metrics-port=8008 --rpc --rpc-port=9091 --nat=extip:${ClientIP} --validators-dir=/var/lib/nimbus/validators --secrets-dir=/var/lib/nimbus/secrets --log-level=INFO --log-file=/var/lib/nimbus/beacon_node.log'
[Install]
WantedBy=multi-user.target
$ sudo systemctl daemon-reload
$ sudo systemctl start nimbus
$ sudo systemctl status nimbus
$ sudo systemctl enable nimbus
$ sudo journalctl -fu nimbus.service
Nov 24 22:25:56 ETH-STAKER-001 bash[65560]: INF 2020-11-24 22:25:31.197+00:00 Slot start                                 topics="beacnde" tid=65560 file=nimbus_beacon_node.nim:473 lastSlot=46326 scheduledSlot=46327 beaconTime=6d10h25m24s197ms907us264ns peers=1 head=1e6df25a:242 headEpoch=7 finalized=542c17b2:128 finalizedEpoch=4
Nov 24 22:25:56 ETH-STAKER-001 bash[65560]: NOT 2020-11-24 22:25:31.203+00:00 Syncing in progress; skipping validator duties for now topics="beacval" tid=65560 file=validator_duties.nim:519 slot=46327 headSlot=242
Nov 24 22:25:56 ETH-STAKER-001 bash[65560]: INF 2020-11-24 22:25:31.203+00:00 Slot end topics="beacnde" tid=65560 file=nimbus_beacon_node.nim:559 slot=46327 nextSlot=46328 head=1e6df25a:242 headEpoch=7 finalizedHead=542c17b2:128 finalizedEpoch=4
Nov 24 22:25:56 ETH-STAKER-001 bash[65560]: NOT 2020-11-24 22:25:34.396+00:00 Reached new finalization checkpoint topics="chaindag" tid=65560 file=chain_dag.nim:910 finalizedHead=6ad92bbe:189@192 heads=1 newHead=23e933aa:256

Step 12 — Fund the Validator Keys

Get Göerli ETH

Complete the Launchpad

Check the Status of Your Validators

Step 13 — Monitoring: 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.29.2/prometheus-2.29.2.linux-amd64.tar.gz
$ tar xvf prometheus-2.29.2.linux-amd64.tar.gz
$ sudo cp prometheus-2.29.2.linux-amd64/prometheus /usr/local/bin/
$ sudo cp prometheus-2.29.2.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.29.2.linux-amd64/consoles /etc/prometheus
$ sudo cp -r prometheus-2.29.2.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.29.2.linux-amd64.tar.gz prometheus-2.29.2.linux-amd64

Edit the Configuration File

$ sudo nano /etc/prometheus/prometheus.yml
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'nimbus'
static_configs:
- targets: ['localhost:8008']
- 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=2021-09-06T16:57:40.941Z caller=main.go:784 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 14 — Monitoring: Install Node Exporter

$ cd ~
$ curl -LO https://github.com/prometheus/node_exporter/releases/download/v1.2.2/node_exporter-1.2.2.linux-amd64.tar.gz
$ tar xvf node_exporter-1.2.2.linux-amd64.tar.gz
$ sudo cp node_exporter-1.2.2.linux-amd64/node_exporter /usr/local/bin
$ sudo chown -R node_exporter:node_exporter /usr/local/bin/node_exporter
$ rm -rf node_exporter-1.2.2.linux-amd64.tar.gz node_exporter-1.2.2.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 (Optional)

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

Step 15 —Monitoring: 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: 8.1.2
Version table:
8.1.2 500
500 https://packages.grafana.com/oss/deb stable/main amd64 Packages
8.1.1 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

Import a Grafana Dashboard

Final Remarks and Recommended Next Steps

Further Reading

Appendix A — Updating Geth

$ sudo systemctl stop geth
$ sudo systemctl stop nimbus
$ sudo apt update && upgrade
$ sudo systemctl start geth
$ sudo systemctl status geth # <-- Check for errors
$ sudo journalctl -f -u geth # <-- Monitor
$ sudo systemctl start nimbus
$ sudo systemctl status nimbus # <-- Check for errors
$ sudo journalctl -f -u nimbus.service # <-- Monitor

Appendix B— Updating Nimbus

$ cd ~
$ cd nimbus-eth2
$ git pull && make update
$ make nimbus_beacon_node
$ sudo systemctl stop nimbus
$ sudo cp /$HOME/nimbus-eth2/build/nimbus_beacon_node /usr/local/bin
$ sudo systemctl start nimbus
$ sudo systemctl status nimbus # <-- Check for errors
$ sudo journalctl -fu nimbus.service # <-- Monitor

Appendix C — Adding Validators

Generate Deposit Data

./deposit existing-mnemonic --validator_start_index <ValidatorStartIndex> --num_validators <NumberOfValidators> --chain prater
deposit.exe existing-mnemonic --validator_start_index <ValidatorStartIndex> --num_validators <NumberOfValidators> --chain prater

Copy the Validator Keystore Files

Import Keystore Files into the Validator Wallet

$ sudo systemctl stop nimbus
$ sudo chown -R <yourusername>:<yourusername> /var/lib/nimbus
$ cd ~
$ cd /usr/local/bin
$ nimbus_beacon_node deposits import --data-dir=/var/lib/nimbus $HOME/eth2deposit-cli-256ea21-linux-amd64/validator_keys
$ sudo chown -R nimbus:nimbus /var/lib/nimbus
$ sudo systemctl start nimbus
$ sudo systemctl status nimbus # <-- Check for errors
$ sudo journalctl -fu nimbus.service # <-- Monitor

Appendix D — Exiting Validators

$ cd ~
$ cd /usr/local/bin
$ nimbus_beacon_node deposits exit --validator=ValidatorPublicKey --data-dir=/var/lib/nimbus

Appendix E — Expanding the Logical Volume

$ sudo lvdisplay # <-- Check your logical volume size
$ sudo lvm
> lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
> exit
$ sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
$ df -h # <-- Check results

--

--

--

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

What are Crypto DAOs & How Blockchain Governance Will Rule Them All

Is Bitcoin really Driving the Altcoin Market?

How to Buy Wrapped Celo Dollar (wCUSD) on Uniswap V2

HavenProtocol (XHV) — Financial Privacy On Steroids