Update: How to run Erigon and TrueBlocks in 2024

Resources

Introduction

I’ve had my archive node down for a few months and in the meantime a lot has happened. Erigon has now a built in consensus layer (CL) client called Caplin together with its execution layer (EL). Therefore, there is no need to run a separate CL, like Lighthouse. However, the internal CL does not work with staking (block production) at the moment. Erigon has also came out with a documentation (linked to above) and TrueBlocks has ported all code from C++ to GoLang and released version 1.0.0.

Since I’ve been away, I’ll take the opportunity to set up everything from scratch. The advantage with this is that you don’t have to do prior migrations and troubleshoot when it doesn’t work. The disadvantage is that you’ll have to sync the node and the index again which takes time. In the Erigon docs it says that due to Erigon’s efficient staged sync it takes around 3 days to sync, this was not true in my case. I started to sync the node the 30th of August and it was done the 11th of September, thus taking 12 days on an AMD Ryzen 9 5950X with 64GB RAM.

Prerequisites

For Erigon you will have to install GoLang version 1.19 or higher, GCC 10+ or Clang, and Git. However, I had a failed install (make erigon) with the latest version go1.21.0, but go1.20.7 worked. When installing Go follow the instructions on their website to make sure you remove any previous installation. GCC can generally be installed with your package manager.

For TrueBlocks you need GoLang version 1.18.0 or higher and the following required packages,

sudo apt install build-essential git cmake ninja-build python3 python3-dev libcurl4-openssl-dev clang-format jq

Hardware Requirements

For an Erigon archive node it is recommended to have:

However, I highly recommend at least a 4TB drive, since you want to run TrueBlocks and probably save some data etc.

Install Erigon

git clone --branch v2.53.1 --single-branch https://github.com/ledgerwatch/erigon.git
cd erigon
make erigon

Set up Erigon as Systemd Service

You can run Erigon directly in the terminal, however I like to set up Erigon and TrueBlocks as systemd services. Systemd is a Linux init system that handles processes and lets you run programs in the background, if you are unfamiliar with that you can check out my blog post about it.

To set up the Erigon service,

cd /etc/systemd/system
sudo touch erigon.service
sudo vim erigon.service

Now we can modify the erigon.service, and I have set it up as follows,

[Unit]
Description=Erigon Node
After=network.target network-online.target
Wants=network-online.target

[Service]
WorkingDirectory=/media/node/erigon/erigon/
ExecStart=/media/node/erigon/erigon/build/bin/erigon \
     --datadir=mainnet \
     --private.api.addr=localhost:9090 \
     --authrpc.jwtsecret=/media/node/erigon/erigon/mainnet/jwt.hex \
     --internalcl \
     --torrent.download.rate=20mb \
     --http \
     --ws \
     --http.api=engine,eth,erigon,web3,net,debug,trace,txpool,shh

User=magnus
Restart=always
RestartSec=5s

# Output to syslog
StandardOutput=syslog
StandardError=syslog
#Change this to find app logs in /var/log/syslog
SyslogIdentifier=erigon

[Install]
WantedBy=multi-user.target

erigon.service looks pretty similar to how I’ve previously set it up. However, I’ve now added two new flags --internalcl to add the internal consensus layer client and --torrent.download.rate=20mb to increase the downloading speed. Note also that you don’t have to run a separate service for the RPC daemon to curl the node.

You can see all Erigon flags by cding to /erigon/bin/build and run ./erigon --help.

Run Erigon

To start the Erigon systemd service we run,

sudo systemctl start erigon

Monitor processes

We can monitor the Erigon logs continuously with,

sudo journalctl -u erigon -f

or

sudo tail -f /media/node/erigon/erigon/mainnet/logs/erigon.log

If you want to monitor your complete syslog you can run,

sudo tail -f /var/log/syslog

The Syncing Process

The syncing process was rather smooth and most everything worked as expected. However, at one point I thought the node had stopped syncing because the latest block was the same when querying it for over a day, 16999999. But when I checked the logs, Erigon seemed to be working, and after 2 days the node was at block 18099956.

When the node was just a few minutes behind the current block I tried to remove the flag torrent.download.rate=20mb, this lead to the node lagging behind again and eventually if was behind approximately 1 day in block time.

Note:

Check if Erigon is synced

To check if the archive node is fully synced we can query the latest block, convert it from hex to int, and compare it to the latest validated block at Etherscan,

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc": "2.0", "method":
"eth_blockNumber", "params": [], "id":1}' localhost:8545 | jq -r ".result" | mawk '{ printf "%d\n",
$1 }'

Here we can see that my node’s latest block is 15544659 and Etherscan shows 15544659, and we are thus up to date.

Furthermore, the Ethereum protocol specifies a set of JSON-RPC API methods. These methods are function names that can be used to query the node and they can be found here.

Update Erigon

Every now and then Erigon gets an update, that is usually announced in the Discord channel and the new release can be viewed on Github. You can view what version of Erigon you have by running ./erigon --version from the erigon/build directory. Then you can clone the new version of Erigon, e.g.,

cd erigon
git fetch --tags
git checkout v2.56.2
make erigon

Now you can check the version of Erigon again and see if it has updated.

Install TrueBlocks

Yesterday, version 2.0.0 was pushed to master. If you previously have TrueBlocks installed you need to do a migration. However, here I will install TrueBlocks from scratch.

git clone --depth 1 --branch master https://github.com/TrueBlocks/trueblocks-core
cd trueblocks-core
mkdir build && cd build
cmake ../src
make                   # may be faster with make -j <nproc>

Add export PATH='/path/trueblocks-core/bin:$PATH" to your .bashrc or similar.

Edit TrueBlocks config

chifra config --paths will show you the path to the trueBlocks.toml, which is located at ~/.local/share/trueblocks. The RPC provider (Erigon) is by default set to http://localhost:8545, however I set cachePath = "/media/m2_4tb/trueblocks/cache/" and indexPath = “/media/m2_4tb/trueblocks/index/unchained/”` such that I record the index at my chosen location, it’s around 70GB.

We can now test and see if the installation has worked by running, e.g., chifra blocks 12.

Getting the index

To get the full index you have two options, either to run chifra init --all to download the index or to run chifra scrape to create the index on your local node.