Guide to Staking on Ethereum 2.0 (Ubuntu/Prysm)

Acknowledgements

Disclaimer

Support

Prerequisites

Testnet to Mainnet

Requirements

Activation

Overview

Step 1 — Generate Staking Data

Download the Deposit Tool (Deposit CLI)

Run the Deposit Tool (Eth2 Deposit CLI)

./deposit new-mnemonic --num_validators <NumberOfValidators> --chain mainnet
deposit.exe new-mnemonic --num_validators <NumberOfValidators> --chain mainnet

Final Steps

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

Modify the Default SSH Port

$ sudo ss -tulpn | grep ':<YourSSHPortNumber>'
$ sudo nano /etc/ssh/sshd_config
Port <YourSSHPortNumber>
$ sudo systemctl restart ssh

Configure the Firewall

$ sudo apt install ufw
$ sudo ufw default deny incoming
$ sudo ufw default allow outgoing
$ sudo ufw allow <yourSSHportnumber>/tcp
$ sudo ufw deny 22/tcp
$ sudo ufw allow 30303
$ sudo ufw allow 13000/tcp
$ sudo ufw allow 12000/udp
$ 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 — Set up an Ethereum (Eth1) Node

Install Go Ethereum

$ sudo add-apt-repository -y ppa:ethereum/ethereum
$ sudo apt update
$ sudo apt install geth
$ 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=Go Ethereum Client
After=network.target
Wants=network.target
[Service]
User=goeth
Group=goeth
Type=simple
Restart=always
RestartSec=5
ExecStart=geth --http --datadir /var/lib/goethereum --cache 2048 --maxpeers 30
[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

Check Sync Status

geth attach http://127.0.0.1:8545
> eth.syncing

Check Connected Peers

geth attach http://127.0.0.1:8545
> net.peerCount

Add Bootnodes (Optional)

$ sudo systemctl stop geth
$ sudo nano /etc/systemd/system/geth.service
ExecStart=geth --http --datadir /var/lib/goethereum --cache 2048 --maxpeers 30 --bootnodes "enode://d0b4a09d072b3f021e233fe55d43dc404a77eeaed32da9860cc72a5523c90d31ef9fab7f3da87967bc52c1118ca3241c0eced50290a87e0a91a271b5fac8d0a6@157.230.142.236:30303,enode://5070366042daaf15752fea340e7ffce3fd8fc576ac846034bd551c3eebac76db122a73fe8418804c5070a5e6d690fae133d9953f85d7aa00375d9a4a06741dbc@116.202.231.71:30303"
$ sudo systemctl daemon-reload
$ sudo systemctl start geth
$ sudo journalctl -fu geth.service

Step 7 — Download Prysm

$ cd ~
$ sudo apt install curl
$ curl -LO https://github.com/prysmaticlabs/prysm/releases/download/v1.4.2/beacon-chain-v1.4.2-linux-amd64$ curl -LO https://github.com/prysmaticlabs/prysm/releases/download/v1.4.2/validator-v1.4.2-linux-amd64
$ mv beacon-chain-v1.4.2-linux-amd64 beacon-chain
$ mv validator-v1.4.2-linux-amd64 validator
$ chmod +x beacon-chain
$ chmod +x validator
$ sudo cp beacon-chain /usr/local/bin
$ sudo cp validator /usr/local/bin
$ cd ~
$ sudo rm beacon-chain && sudo rm validator

Step 8 — Import the Validator Keys

Copy the Validator Keystore Files

Import Keystore Files into the Validator

$ sudo mkdir -p /var/lib/prysm/validator
$ sudo chown -R <yourusername>:<yourusername> /var/lib/prysm/validator
$ cd /usr/local/bin
$ validator accounts import --keys-dir=$HOME/eth2deposit-cli/validator_keys

Create a Wallet Password File

$ sudo nano /var/lib/prysm/validator/password.txt

Step 9 — Configure the Prysm Beacon Node

Set up the Account and Directory

$ sudo useradd --no-create-home --shell /bin/false prysmbeacon
$ sudo mkdir -p /var/lib/prysm/beacon
$ sudo chown -R prysmbeacon:prysmbeacon /var/lib/prysm/beacon
$ sudo chmod 700 /var/lib/prysm/beacon
$ ls -dl /var/lib/prysm/beacon

Create and Configure the Service

$ sudo nano /etc/systemd/system/prysmbeacon.service
[Unit]
Description=Prysm Eth2 Client Beacon Node
Wants=network-online.target
After=network-online.target
[Service]
User=prysmbeacon
Group=prysmbeacon
Type=simple
Restart=always
RestartSec=5
ExecStart=/usr/local/bin/beacon-chain --datadir=/var/lib/prysm/beacon --http-web3provider=http://127.0.0.1:8545 --suggested-fee-recipient=0xYourAddress --accept-terms-of-use
[Install]
WantedBy=multi-user.target
ExecStart=/usr/local/bin/beacon-chain --datadir=/var/lib/prysm/beacon --http-web3provider=http://127.0.0.1:8545 --fallback-web3provider=https://3rdPartyProviderURL --suggested-fee-recipient=0xYourWalletAddress --accept-terms-of-use
$ sudo systemctl daemon-reload
$ sudo systemctl start prysmbeacon
$ sudo systemctl status prysmbeacon
$ sudo systemctl enable prysmbeacon
$ sudo journalctl -fu prysmbeacon.service
Nov 27 06:20:48 ETH-STAKER-001 bash[44829]: time="2020-11-27 06:20:48" level=info msg="Processing deposits from Ethereum 1 chain" deposits=1024 genesisValidators=1019 prefix=powchain
Nov 27 06:16:29 ETH-STAKER-001 bash[44747]: time="2020-11-27 06:16:29" level=error msg="Could not connect to powchain endpoint" error="could not dial eth1 nodes: eth1 node using incorrect chain id, 0 != 1" prefix=powchain

Step 10 — Configure the Prysm Validator Client

Set up the Account and Directory

$ sudo useradd --no-create-home --shell /bin/false prysmvalidator
$ sudo chown -R prysmvalidator:prysmvalidator /var/lib/prysm/validator
$ sudo chmod 700 /var/lib/prysm/validator
$ ls -dl /var/lib/prysm/validator
$ sudo chmod -R 700 /var/lib/prysm/validator/password.txt
$ sudo ls -lh /var/lib/prysm/validator/

Create and Configure the Service

$ sudo nano /etc/systemd/system/prysmvalidator.service
[Unit]
Description=Prysm Eth2 Validator Client
Wants=network-online.target
After=network-online.target
[Service]
User=prysmvalidator
Group=prysmvalidator
Type=simple
Restart=always
RestartSec=5
ExecStart=/usr/local/bin/validator --datadir=/var/lib/prysm/validator --wallet-dir=/var/lib/prysm/validator --wallet-password-file=/var/lib/prysm/validator/password.txt --graffiti="<yourgraffiti>" --accept-terms-of-use
[Install]
WantedBy=multi-user.target
$ sudo systemctl daemon-reload
$ sudo systemctl start prysmvalidator
$ sudo systemctl status prysmvalidator
$ sudo systemctl enable prysmvalidator
$ sudo journalctl -fu prysmvalidator.service
ETH-STAKER-001 systemd[1]: Started Prysm Eth2 Validator Client.
level=warning msg="Running on ETH2 Mainnet" prefix=flags
level=info msg="Opened validator wallet" keymanager-kind=direct level=info msg="Checking DB" databasePath="/var/lib/prysm/validator" level=info msg="Starting validator node" prefix=node
...
level=info msg="Validating for public key" prefix=validator publicKey=0x9072a8f02c18
level=info msg="Validating for public key" prefix=validator publicKey=0xaa5ff8b63560
level=info msg="Waiting for beacon chain start log from the ETH 1.0 deposit contract" prefix=validator
level=info msg="Beacon chain started" genesisTime=2020-12-01 12:00:23 +0000 UTC prefix=validator
level=info msg="Waiting for deposit to be observed by beacon node" prefix=validator pubKey=0x9072a8f02c18 status="UNKNOWN_STATUS"

Step 11 — Fund the Validator Keys

Check the Status of Your Validator Deposits

Step 12 — Monitoring

Final Remarks and Recommended Next Steps

Further Reading

Appendix A — Updating Geth

$ sudo systemctl stop prysmvalidator
$ sudo systemctl stop prysmbeacon
$ sudo systemctl stop geth
$ sudo apt update && sudo apt upgrade
$ sudo systemctl start geth
$ sudo systemctl status geth # <-- Check for errors
$ sudo journalctl -fu geth.service # <-- Monitor
$ sudo systemctl start prysmbeacon
$ sudo systemctl status prysmbeacon # <-- Check for errors
$ sudo journalctl -fu prysmbeacon.service # <-- Monitor
$ sudo systemctl start prysmvalidator
$ sudo systemctl status prysmvalidator # <-- Check for errors
$ sudo journalctl -fu prysmvalidator.service # <-- Monitor

Appendix B — Updating Prysm

$ cd ~
$ sudo apt install curl
$ curl -LO https://github.com/prysmaticlabs/prysm/releases/download/v1.4.2/beacon-chain-v1.4.2-linux-amd64$ curl -LO https://github.com/prysmaticlabs/prysm/releases/download/v1.4.2/validator-v1.4.2-linux-amd64
$ sudo systemctl stop prysmvalidator
$ sudo systemctl stop prysmbeacon
$ mv beacon-chain-v1.4.2-linux-amd64 beacon-chain
$ mv validator-v1.4.2-linux-amd64 validator
$ chmod +x beacon-chain
$ chmod +x validator
$ sudo cp beacon-chain /usr/local/bin
$ sudo cp validator /usr/local/bin
$ sudo systemctl daemon-reload
$ sudo systemctl start prysmbeacon
$ sudo systemctl status prysmbeacon # <-- Check for errors
$ sudo journalctl -fu prysmbeacon.service # <-- Monitor
$ sudo systemctl start prysmvalidator
$ sudo systemctl status prysmvalidator # <-- Check for errors
$ sudo journalctl -fu prysmvalidator.service # <-- Monitor
$ cd ~
$ sudo rm beacon-chain && sudo rm validator

Appendix C — Adding a Validator

Check Validator Queue Times

Generate Deposit Data

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

Copy the Validator Keystore Files

Import Keystore Files into the Validator Wallet

$ sudo systemctl stop prysmvalidator
$ sudo chown -R <yourusername>:<yourusername> /var/lib/prysm/validator
$ cd /usr/local/bin
$ validator accounts import --keys-dir=$HOME/eth2deposit-cli/validator_keys
Enter a wallet directory (default: /home/ethStaker/.eth2validators/prysm-wallet-v2):
/var/lib/prysm/validator
Wallet password:
Enter the password for your imported accounts:
Importing accounts, this may take a while...
Importing accounts... 100% [==========================================] [3s:0s]
Successfully imported 3 accounts, view all of them by running `accounts list`
$ validator accounts list --wallet-dir=/var/lib/prysm/validator
[2021-08-01 02:29:36]  WARN flags: Running on Ethereum Consensus Mainnet
Wallet password:
(keymanager kind) imported wallet
Showing 3 validator accounts
View the eth1 deposit transaction data for your accounts by running `validator accounts list --show-deposit-data`
Account 0 | probably-ruling-flea
[validating public key] 0xa6366498da34ad9cf086c69db1d5cf0c6f80ed992b06204fa6b4d41d00a4c984f22bbd7d5a0f0ed1b969271281dec1ea
Account 1 | sharply-touching-jawfish
[validating public key] 0xb088c003ec1ea5c0a5fd2cf33bf31c4261311180d2d87bed308a5eb3f2024b88c241fbee00fdf110a6e40c46b0a6e800
Account 2 | multiply-humorous-gopher
[validating public key] 0x8678814850e976e8d4e9e9f7c977ca13798b5b0288db857b7e5db63554f6ae8833080896c3b21248cb346799debc4ab3
$ sudo chown -R prysmvalidator:prysmvalidator /var/lib/prysm/validator
$ sudo systemctl start prysmvalidator
$ sudo systemctl status prysmvalidator # <-- Check for errors
$ sudo journalctl -fu prysmvalidator.service # <-- Monitor
msg="Validating for public key" prefix=validator publicKey=0xa6366498da34
msg="Validating for public key" prefix=validator publicKey=0xb088c003ec1e
msg="Validating for public key" prefix=validator publicKey=0x8678814850e9

Appendix D — Pruning Geth

ethstaker@ETH-STAKER-002:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 796M 996K 795M 1% /run
/dev/hda1 155G 74G 82G 48% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/vda15 105M 5.2M 100M 5% /boot/efi
tmpfs 796M 0 796M 0% /run/user/1000
ethstaker@ETH-STAKER-002:~$

Start the Prune Operation

$ sudo systemctl stop geth
$ sudo journalctl -fu prysmbeacon.service
$ sudo journalctl -fu prysmvalidator.service
$ sudo nano /etc/systemd/system/geth.service
[Unit]
Description=Go Ethereum Client
After=network.target
Wants=network.target
[Service]
User=goeth
Group=goeth
Type=simple
Restart=always
RestartSec=5
ExecStart=geth --http --datadir /var/lib/goethereum --cache 2048 --maxpeers 30 snapshot prune-state
[Install]
WantedBy=default.target
$ sudo systemctl daemon-reload
$ sudo systemctl start geth
$ sudo systemctl status geth
$ sudo systemctl stop geth
$ sudo nano /etc/systemd/system/geth.service
[Unit]
Description=Go Ethereum Client
After=network.target
Wants=network.target
[Service]
User=goeth
Group=goeth
Type=simple
Restart=always
RestartSec=5
ExecStart=geth --http --datadir /var/lib/goethereum --cache 2048 --maxpeers 30
[Install]
WantedBy=default.target
$ sudo systemctl daemon-reload
$ sudo systemctl start geth
$ sudo systemctl status geth # <-- Check for errors
$ sudo journalctl -fu geth.service # <-- Monitor
$ sudo journalctl -fu prysmbeacon.service 

Appendix E — Clear Systemd Journal Logs

$ sudo journalctl --disk-usage
$ sudo journalctl --flush --rotate 
$ sudo journalctl --vacuum-time=3days
$ sudo journalctl --verify

Automatically Limit Log Size

$ sudo nano /etc/systemd/journald.conf
$ sudo systemctl restart systemd-journald

Appendix F — 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

Full Disclaimer

Unlisted

--

--

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.