Skip to content

How to run an Erigon Archive Node on Polygon

Update: Polygon requires version v2022.06.01 or newer to sync properly.

We’re going to be building off my previous blog posts to build an Erigon Archive Node on Polygon (the PoS Chain).

We’re going to combine these into a new blog post with new information! Running Erigon instead of bor so we can serve full archive data for Matic/Polygon over on!

I’m not going to go into a ton of details here, you can read the other blog posts for more information but I’ll hit the highlights and new information since writing those blog posts.

The first thing you need to know is that Erigon currently calls this network bor-mainnet don’t ask me why, that’s just what it is…

The second thing you need to know is that Erigon support for Matic/Polygon is very much “Alpha” and I haven’t even successfully sync’d a node myself yet! But I’m trying!

We’re going to build this “native” and without Docker this time.

Let’s begin

I start by installing Go 1.18.3

# Golang (
wget -q -O go${GOVERSION}.linux-amd64.tar.gz${GOVERSION}.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go${GOVERSION}.linux-amd64.tar.gz
rm go${GOVERSION}.linux-amd64.tar.gz
sudo ln -s /usr/local/go/bin/go /usr/local/bin/go

Next I create some directories to work with

mkdir -p /data/github
mkdir -p /data/heimdall/bin
mkdir -p /data/erigon/datadir
mkdir /data/erigon/ethash

Next I clone and build Heimdall (we still need this)

cd /data/github
git clone -b v0.2.9
cd heimdall && make build network=mainnet && cp build/* /data/heimdall/bin/

Notice that I moved the binaries into /data/heimdall/bin

Next I clone and build Erigon from it’s latest alpha release (note: Beta doesn’t work here)

cd /data/github
git clone -b v2022.05.03
cd erigon && make && cp -r build/bin /data/erigon/

Again, I moved the binaries over to /data/erigon/bin/

If you want to you can create non-interactive users for the processes to run under:

# Create users
adduser --system --group heimdall
adduser --system --group erigon

# Set ownership of folders we created ealier
chown -R heimdall:heimdall /data/heimdall
chown -R erigon:erigon /data/erigon

Setting up Heimdall (PoS Client)

Now we need to init heimdalld just like we did in the previous blog posts

# As heimdall user init with home directory set
sudo -u heimdall /data/heimdall/bin/heimdalld init --home /data/heimdall

# As hemidall user replace the genesis file
sudo -u heimdall wget -O /data/heimdall/config/genesis.json

Just like the previous blog post we need to modify the config files

# Set the seed servers
sed -i '/^seeds/c\seeds = "f4f605d60b8ffaaf15240564e58a81103510631c@,4fb1bc820088764a564d4f66bba1963d47d82329@,2eadba4be3ce47ac8db0a3538cb923b57b41c927@,3b23b20017a6f348d329c102ddc0088f0a10a444@,25f5f65a09c56e9f1d2d90618aa70cd358aa68da@"' /data/heimdall/config/config.toml

# Allow CORS (Optional)
sed -i "s#^cors_allowed_origins.*#cors_allowed_origins = [\"*\"]#" /data/heimdall/config/config.toml

Now, we want to download our snapshot (we don’t need a Heimdall archive node…). Same as before get the latest snapshot from

# Set snapshot URL

# Download and extract in one command
wget -c "${SNAPSHOT_URL}" -O - | tar -xz -C /data/heimdall/data

# Reset permissions again
chown -R heimdall:heimdall /data/heimdall

Now heimdalld and heimdallr (the rest server) are ready to run. You can create a systemd service file or use supervisor which I like to do.

apt install -y supervisor

# /etc/supervisor/conf.d/heimdalld.conf
command=bash -c '/data/heimdall/bin/heimdalld --home /data/heimdall start'
# /etc/supervisor/conf.d/heimdallr.conf
command=bash -c '/data/heimdall/bin/heimdalld --home /data/heimdall rest-server --chain-id=137'

Start heimdalld and heimdallr

systemctl daemon-reload
systemctl enable supervisor
systemctl start supervisor
supervisorctl update

Again if everything goes right heimdalld should sync from the snapshot to the current block, you can check with http://localhost:26657/status

You should see "network": "heimdall-137" in the output, if you don’t something went wrong with the init and replacing the genesis.json file… anyway wait for it to say "catching_up": false

Now that the Heimdall stuff is out of the way we can get to the Erigon stuff…

Setting up Erigon Archive Node

Since my previous blog post Erigon has ALSO integrated rpcdaemon directly into erigon so you don’t HAVE to run a secondary process (you still can…). But, regardless there are a few key flags required to sync Polygon…


These should be obvious, but there’s a couple more considerations…

  1. There is a maximum size of 8TB on the Erigon database unless you bump the database page size with --db.pagesize
    • The current database size without snapshots is ~4.2TB
    • The default is 4kb
    • The maximum size is 64kb
    • These settings can impact performance but I’m too lazy to benchmark…
    • If the database hits 8TB with the default settings, there is nothing you can do but re-sync. You can make your own decision here.
  2. --snapshots=true – This turns on the BitTorrent based snapshot mode!

With that out of the way here’s how my supervisor config file looks:

# /etc/supervisor/conf.d/erigon.conf
command=bash -c '/data/erigon/bin/erigon --db.pagesize="64kb" --chain="bor-mainnet" --datadir="/data/erigon/datadir" --ethash.dagdir="/data/erigon/datadir/ethash" --snapshots="true" --bor.heimdall="http://localhost:1317" --http --http.addr="" --http.port="8545" --http.compression --http.vhosts="*" --http.corsdomain="*" --http.api="eth,debug,net,trace,web3,erigon,bor" --ws --ws.compression --rpc.gascap="300000000"'

supervisorctl update and we’re off to the races.

Log files can be seen via tail -f /var/log/supervisor/erigon.err.log etc.

Happy Archive Nodling.

Published inTech

One Comment

  1. Sreeram Sreeram

    Does Erigon support block creation like bor or should I still need to setup another bor node for the same ? My requirement is to only read from the polygon mainnet on daily basis to create an explorer.

Leave a Reply

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