Maxim
3 min readJun 3, 2023

πŸ“Έ Get snapshots.

All snapshots can be found here https://snapshot.polygon.technology/

Time to sync the node:
- 3–4 days from the moment of starting the downloads from the Snapshots website above
- 3–6 weeks if synced from scratch with the Erigon built-in torrent snapshots

How to check the synchronization after installing and running the Polygon node, enter the command in the terminal:

curl --data '{"method":"eth_blockNumber","params":[],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" localhost:8545

you will get the block number need converted to decimal and compare with the current one https://polygonscan.com/

Install pre-requisites:

sudo apt install -y build-essential bsdmainutils aria2 dtrx screen clang 
cmake curl httpie jq nano wget docker.io docker-compose

## install go
wget https://go.dev/dl/go1.20.4.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.20.4.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go version

Download Erigon and Heimdall snapshots, untar them, and move their contents:

#download erigon snapshot (replace url with latest snapshot)
aria2c - file-allocation=none -c -x 10 -s 10 https://snapshot-download.polygon.technology/erigon-mainnet-archive-2023-03-02.tar.gz
#download heimdall snapshot (replace url with latest snapshot)
aria2c - file-allocation=none -c -x 10 -s 10 https://snapshot-download.polygon.technology/heimdall-mainnet-fullnode-2023-03-30.tar.zst
#untar the archive
dtrx erigon-mainnet-archive-2023–03–02.tar.gz
#untar the archive
tar -I zstd -xvf heimdall-mainnet-fullnode-2023–03–30.tar.zst
#make directories for datadirs
mkdir -p /root/.local/share/erigon/datadir
mkdir -p /root/.local/share/heimdall/data
#move the data
mv erigon-mainnet-archive-2023–03–02/* /root/.local/share/erigon/datadir
mv heimdall-mainnet-fullnode-2023–03–30/* /root/.local/share/heimdall/data
#remove leftovers
rm erigon-mainnet-archive-2023–03–02.tar.gz
rm -rf erigon-mainnet-archive-2023–03–02
rm heimdall-mainnet-fullnode-2023–03–30.tar.gz
rm -rf heimdall-mainnet-fullnode-2023–03–30

Clone Erigon and install

git clone -b v2.35.2 - recurse-submodules <https://github.com/ledgerwatch/erigon>
cd erigon
make

Clone Heimdall and install

git clone -b v0.3.0 <https://github.com/maticnetwork/heimdall>
cd heimdall
make build network=mainnet

Configure heimdall

/root/heimdall/build/heimdalld init - home /root/.local/share/heimdall/

wget -O /root/.local/share/heimdall/config/genesis.json https://raw.githubusercontent.com/maticnetwork/launch/master/mainnet-v1/without-sentry/heimdall/config/genesis.json
sed -i '/^seeds/c\\seeds = "f4f605d60b8ffaaf15240564e58a81103510631c@159.203.9.164:26656,4fb1bc820088764a564d4f66bba1963d47d82329@44.232.55.71:26656,2eadba4be3ce47ac8db0a3538cb923b57b41c927@35.199.4.13:26656,3b23b20017a6f348d329c102ddc0088f0a10a444@35.221.13.28:26656,25f5f65a09c56e9f1d2d90618aa70cd358aa68da@35.230.116.151:26656"' /root/.local/share/heimdall/config/config.toml
sed -i "s#^cors_allowed_origins.*#cors_allowed_origins = [\\"*\\"]#" /root/.local/share/heimdall/config/config.toml

Create systemd files for Erigon, Heimdalld and Heimdallr

#erigon service file
[Unit]
Description=Erigon Polygon Service
After=network.target
StartLimitIntervalSec=60
StartLimitBurst=3
[Service]
Type=simple
Restart=on-failure
RestartSec=5
TimeoutSec=900
User=root
Nice=0
LimitNOFILE=200000
WorkingDirectory=/root/.local/share/erigon/
ExecStart=/root/erigon/build/bin/erigon - chain="bor-mainnet" - datadir="/root/.local/share/erigon/datadir" - ethash.dagdir="/root/.local/share/erigon/datadir/ethash" - snapshots="true" - bor.heimdall="<http://localhost:1317>" - http - http.addr="0.0.0.0" - http.port="8545" - http.compression - http.vhosts="*" - http.corsdomain="*" - http.api="eth,debug,net,trace,web3,erigon,bor" - ws - ws.compression - rpc.gascap="300000000" - metrics - metrics.addr="0.0.0.0" - metrics.port="6969"
KillSignal=SIGHUP
[Install]
WantedBy=multi-user.target
#heimdalld service file
[Unit]
Description=Heimdalld
After=network.target
StartLimitIntervalSec=60
StartLimitBurst=3
[Service]
Type=simple
Restart=on-failure
RestartSec=5
TimeoutSec=900
User=root
Nice=0
LimitNOFILE=200000
WorkingDirectory=/root/.local/share/heimdall/
ExecStart=/root/heimdall/build/heimdalld - home /root/.local/share/heimdall/ start
KillSignal=SIGHUP
[Install]
WantedBy=multi-user.target
#heimdallr service file
[Unit]
Description=Heimdallr
After=network.target
StartLimitIntervalSec=60
StartLimitBurst=3
[Service]
Type=simple
Restart=on-failure
RestartSec=5
TimeoutSec=900
User=root
Nice=0
LimitNOFILE=200000
WorkingDirectory=/root/.local/share/heimdall/
ExecStart=/root/heimdall/build/heimdalld - home /root/.local/share/heimdall/ rest-server - chain-id=137
KillSignal=SIGHUP
[Install]
WantedBy=multi-user.target

Start heimdalld and heimdallr services:

sudo systemctl daemon-reload
sudo systemctl enable heimdalld
sudo systemctl enable heimdallr
sudo systemctl start heimdalld heimdallr

Checking if Heimdall is catching up:

sudo journalctl -fu heimdalld
#for logs
curl <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

Starting Erigon:

#ONLY AFTER heildall caught up to the chainhead
sudo systemctl enable erigon
sudo systemctl start erigon

Checking status of Erigon sync:

sudo journalctl -fu erigon
Maxim
Maxim

No responses yet