Cover photo

Ethereum mainnet solo staking notes with Erigon and Lighthouse

Solo staking after the merge is about running an execution client and a consensus client on your own environment.

  • Execution client: Erigon

  • Consensus client: Lighthouse

  • Environment: Ubuntu

Ubuntu setup

Setup a Ubuntu linux server, ssh into it and perform some maintenance.

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

You might want to also install mosh to allow long-lived ssh sessions, i.e., sessions that will survive when your computer sleep.

sudo apt-get install mosh

Also you need to able to compile open-source code, install what’s needed:

sudo apt-get install build-essential

Enable swap space (optional)

Check if swap is enabled:

free -h

Setup swap space:

sudo fallocate -l 20G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo sysctl vm.swappiness=10
sudo sysctl vm.vfs_cache_pressure=50

Make it persistent between reboots.

echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Persist swap params:

sudo vim /etc/sysctl.conf

Add the following to the end of the file:

vm.swappiness=10
vm.vfs_cache_pressure = 50

Execution client: Erigon

Erigon is writing in Go. Setup Go in your system:

wget https://go.dev/dl/go1.19.1.linux-amd64.tar.gz
sudo tar -C /usr/local -xvf go1.19.1.linux-amd64.tar.gz

Append this line to your ~/.profile file to make Go executables available in the command-line:

export PATH=$PATH:/usr/local/go/bin

Apply the change to your bash command-line:

source ~/.profile

Download the actual Erigon source code and build it.

git clone https://github.com/ledgerwatch/erigon.git
cd erigon/
make

Start the sync process

./build/bin/erigon --prune htc --prune.r.before=11184524

By default:

  • data dir (--datadir) will be located in ~/.local/share/erigon

  • default chain (--chain) is mainnet.

Pruning is enable to limit the disk space needed. Old receipts are not needed for Eth2 and you can safely prune them with --prune.r.before=11184524 in combination with --prune htc.

Be patient, it takes several days to complete.

Restarting Erigon syncing if there is a problem

Go inside the data folder, here is what you will get:

-rw------- 1 ubuntu ubuntu     0 Sep 19 11:54 LOCK
drwxr--r-- 2 ubuntu ubuntu  4096 Oct  3 15:24 chaindata
drwxr-xr-x 2 ubuntu ubuntu 36864 Oct  3 18:31 etl-temp
-rw------- 1 ubuntu ubuntu    66 Sep 19 11:54 jwt.hex
-rw------- 1 ubuntu ubuntu    64 Sep 19 11:54 nodekey
drwxr--r-- 3 ubuntu ubuntu  4096 Sep 19 11:54 nodes
drwxr--r-- 4 ubuntu ubuntu 20480 Sep 20 01:10 snapshots
drwxr--r-- 2 ubuntu ubuntu  4096 Sep 19 11:54 txpool

To restart a sync, no need to start from scratch. You can remove the chaindata folder. The sync will start again and re-build from the snapshots folder (ref).

Making Erigon a service

Erigon needs to be made a service to be able to restart automatically when the server is rebooted for any reason. Let’s create a service account named erigon with no access to a shell:

sudo useradd --no-create-home --shell /bin/false erigon

Finishing the first sync

Syncing will be done when this message appear:

INFO[09-28|14:23:02.909] [2/16 Headers] Waiting for Consensus Layer... 

All first 14’999’999 blocks are now downloaded, verified and indexed.

Consensus layer: Lighthouse

Download the linux release here.