Note: This article has been updated from Turbo-Geth (old name) to Erigon (new name)
Erigon is an Ethereum client that was originally a fork of the popular Go-Ethereum (Geth) client. It has since seen significant re-writing of the database structure, data model, and sync process enabling node operators to run “Full Archive” without needing > 4TB of storage. Work is even being done to test HDD sync (as opposed to SSD).
In this article I’m going to walk through a step by step setup of how to download, build, and execute Erigon as a service using Supervisor. I’m going to assume you’re running Ubuntu but other Linux distros should work fine/similarly. It may be possible to run on Windows, however, building and running as a service on Windows is an entirely different can of worms that I won’t get into here. If you’d rather use Systemd as opposed to Supervisor, there are other sources available.
At the time of this writing my Erigon installation consumes ~1.2TB of storage at block #12,640,000
I’m going to assume that you’re root for the duration of the setup. If you are using
sudo with these commands, I recommend simply entering root environment with
sudo -i otherwise you will have issues with go not being in your path.
The essentials: build-essential, supervisor, wget, and git
apt-get install -y build-essential supervisor wget git
At the time of this writing/update the most recent Go Language version is 1.17.6. Check here.
wget https://golang.org/dl/go1.17.6.linux-amd64.tar.gz tar -C /usr/local -xzf go1.17.6.linux-amd64.tar.gz
Now you have two choices: Make go available to all user accounts, or just add it to your path:
ln -s /usr/local/go/bin/go /usr/local/bin/go
Just to your own profile:
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile . ~/.profile
A note about updating Go
Whenever you update Go to a new language I recommend deleting the /usr/local/go folder, and re-extracting the new version in its place. Leaving the old folder and extracing on top of it can lead to unexpected behavior with old files. Especially true when updating from 1.15 to 1.16, etc.
Isolated erigon user
Ideally we don’t want our Erigon process running as root so I’m going to create a new user account for the service to run under.
useradd -m -s /bin/bash erigon
We’re going to create a “github” folder under opt where we download the repo and make, and also a “erigon” folder where we hold the binaries we build. Note that I will checkout the
stable branch here!
cd /opt mkdir erigon mkdir github && cd github git clone https://github.com/ledgerwatch/erigon.git cd erigon git checkout stable make cp -r ./build/bin /opt/erigon/
Setting up the Services
Unlike Go-Ethereum (geth), Erigon has a separate RPC service called
rpcdaemon that we also need to setup. I will setup both as Supervisor services.
First, let’s create a data directory for Erigon to work with, as the default sucks (
~/.local/share/erigon). You can change this to whatever you want. I personally have a secondary SSD attached to
/data so I’m going to use that. I’m also going to make the
erigon user the owner of the new folder.
mkdir -p /data/erigon/datadir chown -R erigon:erigon /data/erigon
Next let’s create our service… use your favorite editor and create the following file:
vi /etc/supervisor/conf.d/erigon.conf [program:erigon] command=bash -c '/opt/erigon/build/bin/erigon --datadir="/data/erigon/datadir" --private.api.addr="0.0.0.0:9090"' user=erigon autostart=true autorestart=true stderr_logfile=/var/log/supervisor/erigon.err.log stderr_logfile_maxbytes=1000000 stderr_logfile_backups=10 stdout_logfile=/var/log/supervisor/erigon.out.log stdout_logfile_maxbytes=1000000 stdout_logfile_backups=10 stopwaitsecs=300
Breaking this down section by section, we’re telling Supervisor to create a service called
erigon which will run the
erigon executable, specifying the
datadir. By default the
erigon executable is going to listen only on
127.0.0.1:9090 which is fine if you run the
rpcdaemon on the same system. Or you can set it to
0.0.0.0:9090 like I have done above to listen on all interfaces. Be careful adding additional flags here, as not all geth flags are supported. If you have a static IP address you could also add:
Next we’re telling Supervisor to run it as the
erigon user we created earlier, telling it to auto start and auto restart.
The stderr and stdout lines tell Supervisor where to log the console output to and sets up log rotation. Logs can get rather big if you don’t rotate them.
stopwaitsecs=300 tells Supervisor to wait at least 5 minutes after the kill signal before forcefully shutting it down. This is probably not required for Erigon, but I got into the habit of including it with my Ethereum node processes because nothing sucks more than pre-mature killing of the process resulting in a corrupt DB.
Now, let’s create the service for the
vi /etc/supervisor/conf.d/rpcdaemon.conf [program:rpcdaemon] command=bash -c '/opt/erigon/build/bin/rpcdaemon --datadir="/data/erigon/datadir" --private.api.addr="localhost:9090" --http.addr="0.0.0.0" --http.port=8545 --http.vhosts="*" --http.corsdomain="*" --http.api="eth,debug,net,trace,web3,erigon" --ws' user=erigon autostart=true autorestart=true stderr_logfile=/var/log/supervisor/rpcdaemon.err.log stderr_logfile_maxbytes=1000000 stderr_logfile_backups=10 stdout_logfile=/var/log/supervisor/rpcdaemon.out.log stdout_logfile_maxbytes=1000000 stdout_logfile_backups=10
Here we have created our second service. The important thing here is that we’re pointing
rpcdaemon at the
erigon is listening on. Additionally, rpcdaemon can operate in a “dual mode” where it shares memory from the
erigon binary, so we set
--datadir to point to the datadir folder. From there we’re exposing our RPC endpoint to “all IPs” by using
--http.addr="0.0.0.0" and we’re listening on port 8545. We’ve basically disabled any host or cors checking by using
="*", we’re exposing all available methods (currently:
eth,debug,net,trace,web3,erigon) and we’re also enabling WebSocket support.
The rpcdaemon doesn’t have a database to get corrupted so no need to worry about killing the process.
LISTENING ON ALL IP ADDRESSES AND DISABLING HOST/CORS CHECKING IS NOT RECOMMENDED IF YOUR SERVER IS REACHABLE FROM THE INTERNET.
I assume that most people reading this are just trying to run a node inside their own network, and that some sort of firewall should be protecting their node from external connections. Otherwise, you should setup
ufw or similar on your node to protect your endpoints. Of course if you’re running Erigon on your workstation or you have no reason to access it remotely you can change
127.0.0.1 and then only local connections will be accepted.
If you are running this on a cloud server and you don’t really know what you’re doing here’s a quick firewall using
# Allow SSH form anywhere so we don't get locked out ufw allow ssh # Allow TPC/UDP 30303 from anywhere for peering ufw allow 30303 # Turn on the firewall ufw enable # If you want to allow specific IPs (e.g. 126.96.36.199) to hit your RPC endpoint: ufw allow proto tcp from 188.8.131.52 to any port 8545
Let the nodling commence
systemctl enable supervisor systemctl start supervisor supervisorctl update
This should enable supervisor, telling it to start at startup, and it should start supervisor which in turn should start your
You can check on the status of stuff:
# Check on the erigon service: supervisorctl status erigon tail -f /var/log/supervisor/erigon.err.log # Check on the rpcdaemon status: supervisorctl status rpcdaemon
If for some reason the services don’t start it’s probably a typo in your supervisor config files
Once you make whatever changes you need to make to the config you reload it with this:
Updating Your Node
Updating Erigon is fairly straight forward, we simply pull the latest changes from github, run make, and restart our services.
cd /opt/github/erigon/ git pull make supervisorctl stop rpcdaemon supervisorctl stop erigon cp -r ./build/bin /opt/erigon/ supervisorctl start erigon supervisorctl start rpcdaemon
I would suggest excising some caution in updating, although the Erigon team does their best to ensure that the
stable branch of Erigon is safe and stable, it’s always best to be safe. Also, some updates might not be reversible, as the database model can change, when that happens, the startup of your node after update will include a migration of data (no need to re-sync). However, if you want to downgrade, you would likely have to re-sync.