Guide to Staking on Ethereum 2.0 (Ubuntu/Lighthouse)

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 9000
$ 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 Lighthouse

$ cd ~
$ sudo apt install curl
$ curl -LO https://github.com/sigp/lighthouse/releases/download/v1.4.0/lighthouse-v1.4.0-x86_64-unknown-linux-gnu.tar.gz
$ tar xvf lighthouse-v1.4.0-x86_64-unknown-linux-gnu.tar.gz
$ sudo cp lighthouse /usr/local/bin
$ cd /usr/local/bin/
$ ./lighthouse --version # <-- should display version information
$ cd ~
$ sudo rm lighthouse
$ sudo rm lighthouse-v1.4.0-x86_64-unknown-linux-gnu.tar.gz

Step 8 — Import the Validator Keys

Copy the Validator Keystore Files

Import Keystore Files into the Validator Wallet

$ sudo mkdir -p /var/lib/lighthouse
$ sudo chown -R <yourusername>:<yourusername> /var/lib/lighthouse
$ cd /usr/local/bin
$ lighthouse --network mainnet account validator import --directory $HOME/eth2deposit-cli/validator_keys --datadir /var/lib/lighthouse
sudo chown -R root:root /var/lib/lighthouse

Step 9 — Configure the Beacon Node Service

Set up the Beacon Node Account and Directory

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

Create and Configure the Service

$ sudo nano /etc/systemd/system/lighthousebeacon.service
[Unit]
Description=Lighthouse Eth2 Client Beacon Node
Wants=network-online.target
After=network-online.target
[Service]
User=lighthousebeacon
Group=lighthousebeacon
Type=simple
Restart=always
RestartSec=5
ExecStart=/usr/local/bin/lighthouse bn --network mainnet --datadir /var/lib/lighthouse --staking --eth1-endpoints http://127.0.0.1:8545
[Install]
WantedBy=multi-user.target
--eth1-endpoints http://127.0.0.1:8545,https://your3rdpartynode
$ sudo systemctl daemon-reload
$ sudo systemctl start lighthousebeacon
$ sudo systemctl status lighthousebeacon
$ sudo systemctl enable lighthousebeacon
$ sudo journalctl -fu lighthousebeacon.service
INFO Waiting for genesis                     
wait_time: 5 days 5 hrs, peers: 50, service: slot_notifier

Step 10 — Configure the Validator Service

Set up the Validator Node Account and Directory

$ sudo useradd --no-create-home --shell /bin/false lighthousevalidator
$ sudo chown -R lighthousevalidator:lighthousevalidator /var/lib/lighthouse/validators
$ sudo chmod 700 /var/lib/lighthouse/validators
$ ls -dl /var/lib/lighthouse/validators

Create and Configure the Service

$ sudo nano /etc/systemd/system/lighthousevalidator.service
[Unit]
Description=Lighthouse Eth2 Client Validator Node
Wants=network-online.target
After=network-online.target
[Service]
User=lighthousevalidator
Group=lighthousevalidator
Type=simple
Restart=always
RestartSec=5
ExecStart=/usr/local/bin/lighthouse vc --network mainnet --datadir /var/lib/lighthouse --graffiti "<yourgraffiti>"
[Install]
WantedBy=multi-user.target
$ sudo systemctl daemon-reload
$ sudo systemctl start lighthousevalidator
$ sudo systemctl status lighthousevalidator
$ sudo systemctl enable lighthousevalidator
$ sudo journalctl -fu lighthousevalidator.service
INFO Lighthouse started version: Lighthouse/v1.4.0-c6baa0e
INFO Configured for testnet name: mainnet
WARN The mainnet specification is being used. This not recommended (yet).
INFO Starting validator client validator_dir: "/var/lib/lighthouse/validators", beacon_node: http://localhost:5052/
INFO Completed validator discovery new_validators: 0
INFO Enabled validator voting_pubkey: 0xaa...
INFO Enabled validator voting_pubkey: 0x90...
INFO Initialized validators enabled: 2, disabled: 0
INFO Connected to beacon node version: Lighthouse/v1.4.0-c6baa0e/x86_64-linux
INFO Starting node prior to genesis seconds_to_wait: 444946
INFO Waiting for genesis seconds_to_wait: 444946, bn_staking_enabled: true

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 lighthousevalidator
$ sudo systemctl stop lighthousebeacon
$ 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 # <-- Monitor
$ sudo systemctl start lighthousebeacon
$ sudo systemctl status lighthousebeacon # <-- Check for errors
$ sudo journalctl -fu lighthousebeacon # <-- Monitor
$ sudo systemctl start lighthousevalidator
$ sudo systemctl status lighthousevalidator # <-- Check for errors
$ sudo journalctl -fu lighthousevalidator # <-- Monitor

Appendix B — Updating Lighthouse

$ cd ~
$ sudo apt install curl
$ curl -LO https://github.com/sigp/lighthouse/releases/download/v1.4.0/lighthouse-v1.4.0-x86_64-unknown-linux-gnu.tar.gz
$ sudo systemctl stop lighthousevalidator
$ sudo systemctl stop lighthousebeacon
$ tar xvf lighthouse-v1.4.0-x86_64-unknown-linux-gnu.tar.gz
$ sudo cp lighthouse /usr/local/bin
$ sudo systemctl start lighthousebeacon
$ sudo systemctl status lighthousebeacon # <-- Check for errors
$ sudo journalctl -fu lighthousebeacon # <-- Monitor
$ sudo systemctl start lighthousevalidator
$ sudo systemctl status lighthousevalidator # <-- Check for errors
$ sudo journalctl -fu lighthousevalidator # <-- Monitor
$ cd ~
$ sudo rm lighthouse
$ sudo rm lighthouse-v1.4.0-x86_64-unknown-linux-gnu.tar.gz

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 lighthousevalidator
$ sudo chown -R <yourusername>:<yourusername> /var/lib/lighthouse/validators
$ cd /usr/local/bin
$ lighthouse --network mainnet account validator import --directory $HOME/eth2deposit-cli/validator_keys --datadir /var/lib/lighthouse
Skipping import of keystore for existing public key: "/home/ethstaker/eth2deposit-cli/validator_keys/keystore-m_12381_3600_2_0_0-1616386570.json"
Keystore found at "/home/ethstaker/eth2deposit-cli/validator_keys/keystore-m_12381_3600_4_0_0-1616386614.json":- Public key: 0x87ad7e70c1e95c287a0666d723cc4575cb1ae3f972cdede9e5c64270229a0918165ecc72c8a2bf01ae49075a63c06681
- UUID: f38f9224-a95b-4820-b39e-0f1815a49c2a
If you enter the password it will be stored as plain-text in validator_definitions.yml so that it is not required each time the validator client starts.Enter the keystore password, or press enter to omit it:Password is correct.Successfully imported keystore.
Successfully updated validator_definitions.yml.
Successfully imported 2 validators (3 skipped).
$ sudo chown -R lighthousevalidator:lighthousevalidator /var/lib/lighthouse/validators
$ sudo systemctl start lighthousevalidator
$ sudo systemctl status lighthousevalidator # <-- Check for errors
$ sudo journalctl -fu lighthousevalidator # <-- Monitor
INFO Completed validator discovery new_validators: 0
INFO Enabled validator voting_pubkey: 0x969...97e
INFO Enabled validator voting_pubkey: 0x979...a89
INFO Enabled validator voting_pubkey: 0xac6...363
INFO Enabled validator voting_pubkey: 0x87a...681
INFO Enabled validator voting_pubkey: 0xb46...26a
INFO Initialized validators enabled: 5, disabled: 0

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 lighthousebeacon.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 lighthousebeacon.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
> lvextend -l +100%FREE -r /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.