Setting up a Full Erigon Ethereum Node

While it is certainly possibly to use tools like Infura and Alchemy to make requests against the blockchain, sometimes you want to have your own Ethereum Archive Node to query.

This is the case for The Graph endpoint that we are putting togethr to power the NFTX front end. While we have an enterprise account with Alchemy for requests made through the front end, we want to greatly reduce the latency in the requests to the Eth Node while syncing our subgraphs on our indexing service.

For this we chose a dedicated server from Hetzner, the PX93 18 core server with 2×3.84 and 1×1.92 TB NVME SSD drives, and 128GB ram.

This allows you to get started with Ubuntu 20.04.1 LTS, however it is the mimimal installation which means you need to configure everything from scratch including tools usually budled like htop and git.

First step is to bring everything up and get upgraded.

apt update && apt upgrade

Now that you’re up-to-date the first thing I wanted to install was htop which provides an overview of the server usage inside of a terminal window.

A view of the Hyperthreaded 18 Core CPU…. idle.

To install htop you need to

apt install htop

and then you run you type htop. I run this in a split vertical window on the termail session.

Next up we want to get the Erigon project from GitHub, so we need to install git to do this (you’re going to start to see a pattern for installs on Linux)

apt install git

With GIT installed then we can install the ETH client we want to use, and in this case it is Erigon.

To install/build Erigon we run

git clone --recurse-submodules -j8 https://github.com/ledgerwatch/erigon.git
cd erigon
make erigon
./build/bin/erigon

This will likely fail and you will get an error make: command not found because….. yes that’s right, we don’t have everything installed.

For make to run you need to install <drumroll> — make

apt install make

Now you can run

make erigon

You get another error…. now you’re missing gcc. At the point you will need to keep adding lots of random package, OR, you can just install the dev basics.

apt install build-essential

Now, with build-essential installed, let’s try again.

make erigon

For make to run and create the Erigon ETH node it requires Go to be installed to run, so let’s do that now (I didn’t do that ahead of time because that’s not how the process is mapped out, so you’re most likely to have made that mistake anyway).

You want to run

curl -OL https://golang.org/dl/go1.16.7.linux-amd64.tar.gz

… and amazingly curl is already installed and this will work a treat.

Next, we want to extract the tar.gz file so we run

tar -C /usr/local -xvf go1.16.7.linux-amd64.tar.gz

Then we want to set the Go’s root value by editing the .profile file, which contains a list of commands that the system runs every time you log in.

nano ~/.profile

Then, add the following information to the end of your file:

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

Next, refresh your profile by running the following command:

source ~/.profile

Check that the install has worked by typing in the following command

go version
# you should see 
# go version go1.16.7 linux/amd64 
# or similar

Now, go back and run the following commands withint he erigon folder.

make erigon
./build/bin/erigon

Running Erigon Archive Node with Docker

If you want to run this all on Docker you also need to install Docker

apt install docker.io

Docker doesn’t also install docker-compose those, so you will need to do that separately as well.

curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

Before you run, make sure that the folder permissions for where you’re going to run the data directory is set.

I’m going to run mine from /home/erigon/mainnet and received these errors when running the docker command

ERROR: for erigon_rpcdaemon_1  Cannot start service rpcdaemon: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: process_linux.go:534: writing syncT 'resume' caused: write init-p: broken pipe: unknown

And then then I was running docker ps to check the other containers I could see the following

CONTAINER ID   IMAGE                     COMMAND                  CREATED         STATUS                          PORTS     NAMES
d046a59d3bdf   prom/prometheus:v2.30.2   "/bin/prometheus --l…"   4 minutes ago   Restarting (2) 29 seconds ago             erigon_prometheus_1
67dd815d2aef   thorax/erigon:latest      "erigon --metrics --…"   4 minutes ago   Restarting (1) 26 seconds ago             erigon_erigon_1
b860595e0014   grafana/grafana:8.2.2     "/run.sh"                4 minutes ago   Restarting (1) 29 seconds ago             erigon_grafana_1

To fix the issue I had to run the following on the folder

chmod -R 777 /home/erigon/mainnet

This gave executable access to all the files and folders within, and the next time I ran the below command (I ran the second command because I wanted it in a specific folder).

make docker-compose
#or if you want to run in another directory
XDG_DATA_HOME=/home/erigon/mainnet make docker-compose

Leave a comment

Your email address will not be published. Required fields are marked *