[INFO] [12-05|15:40:53.923]
########b oo d####b.
## '##
##aaaa ##d###b. dP .d####b. .d####b. ##d###b. aaad#'
## ##' '## ## ##' '## ##' '## ##' '## '##
## ## ## ##. .## ##. .## ## ## .##
########P dP dP '####P## '#####P' dP dP d#####P
.##
d####P
[INFO] [12-05|15:40:53.923] Starting Erigon on Ethereum mainnet...
During the last week Erigon 3 Alpha 6
and the documentation for Erigon 3
have been
released:
Please stay up-to-date with the latest releases and documentation before installing
Erigon
. E.g., in Alpha 6
, the default mode is full node and not archive node, and in
the future there might be other changes as well.
As of now, the most up-to-date info about Erigon 3 is in the README.md
on their Github
(you have to switch to the latest Erigon 3 branch).
erigon version v3.0.0-alpha5
.--prune
. In this blog post, I will only use Erigon
as an archive node.I’ve been running Erigon 2 archive nodes for a long time and it has been working great.
However, I’ve lately had issues with disk space on my main server. The Erigon state db
file mdbx.dat
has been around 2.3TB and then I’ve had additional snapshot files of
approximately 1TB. When my disk became almost full I read that I could remove the
snapshot directory since this was used for sharing the data through torrenting. However,
this was incorrect and when I removed these data I lost access to the history of the
chain although the main data file mdbx.dat
was untouched. The reason is because Erigon
stores old blocks in snapshots. Because of this I decided to try out Erigon 3, which
seems to use less disk space.
Erigon 3 should take only around 2TB
of disk space since chaindata
should be less
than 15GB
, it’s even okay to rm -rf chaindata
since all historic data are stored in
snapshots. Another advantage is an increased sync speed, now the full history of
Ethereum mainnet syncs in around 12 hours.
Erigon combines an execution layer (EL) client and an Ethereum consensus layer (CL) client called Caplin.
For Erigon 3 you will have to install GoLang version 1.22 or higher, GCC 10+ or Clang, and Git. 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.
Installing and running Erigon 3 is done in the same way as Erigon 2.
git clone --branch v3.0.0-alpha5 --single-branch https://github.com/erigontech/erigon.git
cd erigon
make erigon
./build/bin/erigon --version
The version printed for me is erigon version 3.00.0-alpha5-78f3647d
.
All releases and release notes can be found here.
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 nvim 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/m2_4tb/erigon/erigon/
ExecStart=/media/m2_4tb/erigon/erigon/build/bin/erigon \
--datadir=mainnet \
--private.api.addr=localhost:9090 \
--authrpc.jwtsecret=/media/m2_4tb/erigon/erigon/mainnet/jwt.hex \
--torrent.download.rate=128mb \
--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 removed the flag --internalcl
since this is now by default. You can see all Erigon
flags by cd
ing to /erigon/bin/build
and run ./erigon --help
. Note also that you
don’t have to run a separate service for the RPC daemon to “curl” the node.
To start the Erigon systemd service we run,
sudo systemctl start erigon
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
Or if you want to monitor your complete syslog
you can run,
sudo tail -f /var/log/syslog
The syncing process was rather smooth, everything worked as expected, and the archive node was fully synced over night. From my understanding, one reason why this works so well is because Erigon 3 shares the chain history very effectively using torrenting.
One thing to note is that a large bottleneck is also disk I/O. If you use an m2 SSD with good read/write speed, the sync process will be must faster.
Now the complete archive node is significantly smaller,
[magnus@ThinkStation/media/m2_4tb/erigon] du -sh
1,8T .
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 }'
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.
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 v3.0.0-alpha5
make erigon
Now you can check the version of Erigon again and see if it has updated,
cd build/bin/
./erigon --version