Deploying an Ethereum Archive Node on bare metal
In order to run your own Indexer on Ethereum Network, you need to have a fast and reliable entry point. There are several providers offering Ethereum Node as a Service, but their free trials are quite limited, and paid services quickly get expensive.
The most cost-effective and reliable way is to run your own Ethereum Archive Node. The Archive Node provides an archive of Blockhain’s historical states. This type of node is useful when querying historical blockchain data that is not accessible on full nodes.
For our Archive Node, we have selected a bare-metal server on Hetzner with mirrored NVMe-SSD drives. For reliable indexing, this is not the place to save money. Nodes are resource hungry and there is no skimping on hardware.
We will use Erigon(https://github.com/ledgerwatch/erigon) implementation. Having used it previously, it has always impressed us with a quick sync and relatively low space requirements. At the time of writing the full Archive Ethereum Node needs just over 2TB of space.
With the upcoming Ethereum Merge we will use the Alpha Version of the Erigon which is already “merge” compatible.
|Hard Drives||2×3.4TB SSD NVME|
|OS||Ubuntu 22.04.1 LTS|
Erigon does not distribute the binaries for their releases (besides their Docker containers). Since we are installing Erigon on a bare-metal server we just going to build it ourselves.
We will have to fetch the latest version of GO, Erigon source code and a few tools to build it on Ubuntu:
apt-get install -y build-essential wget git mkdir downloads cd downloads/ wget https://go.dev/dl/go1.19.linux-amd64.tar.gz tar -C /usr/local -xzvf go1.19.linux-amd64.tar.gz ln -s /usr/local/go/bin/go /usr/local/bin/go
Checkout and build Erigon software:
cd /root/ mkdir build cd build mkdir github && cd github git clone https://github.com/ledgerwatch/erigon.git cd erigon git checkout v2022.08.03 make
useradd -m -d /home/erigon -s /bin/bash erigon mkdir /opt/erigon cp -r ./build/bin /opt/erigon/
Configure the data folder assuming you /mnt/data directory is on an SSD volume:
mkdir -p /mnt/data/erigon chown erigon:erigon /mnt/data/erigon
Create a Systemd Service for Erigon daemon to start automatically on boot and in case of failures:
cat <<EOF >> /etc/systemd/system/erigon.service1 [Unit] Description=Erigon Ethereum Client [Service] User=erigon WorkingDirectory=/home/erigon ExecStart=/opt/erigon/bin/erigon --datadir=/mnt/data/erigon/ --private.api.addr=192.168.0.1:9090 --txpool.api.addr=192.168.0.1:9090 --http.addr=192.168.0.1 --ws --http.api=eth,erigon,web3,net,debug,trace,txpool --metrics --metrics.addr=192.168.0.1 --metrics.port=6060 Restart=always RestartSec=5s [Install] WantedBy=multi-user.target EOF systemctl enable erigon.service systemctl start erigon.service
You should be able to see that Erigon has started successfully by checking logs in /var/log/syslog
Some configuration parameters we have used to start the service:
|–datadir=/mnt/data/erigon/||Path to the folder where Erigon will create and store its Database. This should be located on SSD drives|
|–private.api.addr=192.168.0.1:9090||If you have multiple interfaces on your server, you want to listen only for connections on the local network|
|–ws||start web services API(this is needed for Graph Indexer)|
|–http.api=eth,erigon,web3,net,debug,trace,txpool||list of APIs to enable|
|–metrics –metrics.addr=192.168.0.1 –metrics.port=6060||enable metrics API and expose it on the local network|
In this post, we are deploying Erigon with an RPC daemon running on a secure local network. If you are looking into exposing it via the WEB or want added security you need to look into “–authrpc.*” flags to add authentication.
For monitoring the Erigon Node, we will use our trusty Prometheus which is already deployed on our internal Kubernetes Cluster.
There are just a few things to do to add monitoring.
Add scraping config for an externally hosted API:
- job_name: erigon1 static_configs: - targets: - erigon1:6060 labels: host: erigon1 app: erigon metrics_path: /debug/metrics/prometheus
import Erigon Grafana Dashboard from the URL https://raw.githubusercontent.com/ledgerwatch/erigon/devel/cmd/prometheus/dashboards/erigon.json
and watch for the Data to sync before we progress with the Graph Indexer Deployment