Skip to main content
Validators
State-sync

Syncing a node using state-sync

Follow this guide to setup a RPC node using state-sync. This guide was created and tested in MacOS and may need to be modified slightly for your local system.

State-sync nodes

Testnet

RegionIP
US35.224.160.108

Mainnet

RegionIP
US34.69.20.168

Download binary

Make sure you are downloading the same version as our network is using. You can find the available zetacored versions here: https://github.com/zeta-chain/node/tags

  1. Download the binary and give execution perms to the binary:
wget https://github.com/zeta-chain/node/releases/download/[BINARY_VERSION]/zetacored-darwin-amd64 -O /usr/local/bin/zetacored
chmod a+x /usr/local/bin/zetacored

Init base config

  1. Initialize the base folder and config with the following command:
ChainID
Testnetathens_7001-1
Mainnetzetachain_7000-1
MONIKER=$(hostname)
CHAIN_ID="[Replace with desired CHAIN ID]"
zetacored init ${MONIKER} --chain-id $CHAIN_ID

Download config files

  1. Download the genesis.json file and *.toml configuration files:
EnvironmentConfiguration Files Repository
Testnethttps://raw.githubusercontent.com/zeta-chain/network-athens3
Mainnethttps://raw.githubusercontent.com/zeta-chain/network-mainnet
REPOSITORY_URL="[Config File Repository]"
wget ${REPOSITORY_URL}/main/network_files/config/genesis.json -O ~/.zetacored/config/genesis.json
wget ${REPOSITORY_URL}/main/network_files/config/config.toml -O ~/.zetacored/config/config.toml
wget ${REPOSITORY_URL}/main/network_files/config/app.toml -O ~/.zetacored/config/app.toml
wget ${REPOSITORY_URL}/main/network_files/config/client.toml -O ~/.zetacored/config/client.toml

State sync

  1. Fetch the height and hash from our state-sync servers (make sure to replace <closest StateSync IP> with the IP from our state-sync node):
STATE_SYNC_SERVER="[closest StateSync IP]:26657"
TRUST_HEIGHT=$(curl -s http://${STATE_SYNC_SERVER}/block | jq -r '.result.block.header.height')
HEIGHT=$((TRUST_HEIGHT-40000))
TRUST_HASH=$(curl -s "http://${STATE_SYNC_SERVER}/block?height=${HEIGHT}" | jq -r '.result.block_id.hash')

NOTE: You need to sync from LATEST_HEIGHT - 40000 to make sure that the node will fetch an existing state-sync snapshot.

Replace config values

  1. Make sure to replace [closest StateSync IP] with the IP from our state-sync node, also replace with the desired seed node and run this block of code:
EnvironmentSeed Node
Testnet5aaa51a3b9465a32f7f6c9df1d46d4bfcc16aecb@34.30.34.119:26656
Mainnet8d93468c6022fb3b263963bdea46b0a131d247cd@34.28.196.79:26656
RPC_STATE_SYNC_SERVERS="[closest StateSync IP]:26657,[closest StateSync IP]:26657"
SEED="[Seed Node from list]"
EXTERNAL_IP="$(curl -4 icanhazip.com):26656"
sed -i "" -e "s/^enable = .*/enable = \"true\"/" ~/.zetacored/config/config.toml &&
sed -i "" -e "s/^rpc_servers = .*/rpc_servers = \"${RPC_STATE_SYNC_SERVERS}\"/" ~/.zetacored/config/config.toml &&
sed -i "" -e "s/^trust_height = .*/trust_height = \"${HEIGHT}\"/" ~/.zetacored/config/config.toml &&
sed -i "" -e "s/^trust_hash = .*/trust_hash = \"${TRUST_HASH}\"/" ~/.zetacored/config/config.toml &&
sed -i "" -e "s/^moniker = .*/moniker = \"${MONIKER}\"/" ~/.zetacored/config/config.toml &&
sed -i "" -e "s/^external_address = .*/external_address = \"${EXTERNAL_IP}\"/" ~/.zetacored/config/config.toml &&
sed -i "" -e "s/^seeds = .*/seeds = \"${SEED}\"/" ~/.zetacored/config/config.toml &&
sed -i "" -e 's/^max_num_inbound_peers = .*/max_num_inbound_peers = 120/' ~/.zetacored/config/config.toml &&
sed -i "" -e 's/^max_num_outbound_peers = .*/max_num_outbound_peers = 60/' ~/.zetacored/config/config.toml

Generate keys

zetacored keys add ${MONIKER} --keyring-backend test

Start node

zetacored start --home ~/.zetacored/ --log_level info --moniker ${MONIKER} --rpc.laddr tcp://0.0.0.0:26657 --minimum-gas-prices 1.0azeta "--grpc.enable=true"

The node will fetch a snapshot and start applying chunks. Once it gets to the last chunk, it will take a few more minutes to finish the state-sync and start commiting new blocks.

Common errors

Port error

accept tcp [::]:26657: use of closed network connection
  1. Check if something is running on port 26657
sudo lsof -i :26657
  1. Kill any process running on that port
kill -9 PID