Skip to content

Choose a network

Height33,320,449 Producing blocks Chain IDcosmoshub-4 Versionv28.3.0 Explorer (opens in a new tab)

Cosmos Hub state sync

State sync starts a Cosmos Hub node from a recent block that our RPC serves, instead of replaying the chain's history.

Step 1: Stop the node, back up the validator state and reset

sudo service cosmoshub stop
cp $HOME/.gaia/data/priv_validator_state.json $HOME/.gaia/priv_validator_state.json.backup
gaiad tendermint unsafe-reset-all --home $HOME/.gaia --keep-addr-book

Step 2: Configure state sync

The commands read a trusted height and hash from https://cosmoshub-rpc.stakerhouse.com, set the peer to sync from and restore the validator state.

SYNC_RPC="https://cosmoshub-rpc.stakerhouse.com:443"
SYNC_PEER="4b3b1797b3c00716d805efc2594f9228a06cea98@[2607:5300:60:744b::1]:10056"
LATEST_HEIGHT=$(curl -s $SYNC_RPC/block | jq -r .result.block.header.height)
BLOCK_HEIGHT=$((LATEST_HEIGHT - 2000))
TRUST_HASH=$(curl -s "$SYNC_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)

sed -i \
-e "s|^enable *=.*|enable = true|" \
-e "s|^rpc_servers *=.*|rpc_servers = \"$SYNC_RPC,$SYNC_RPC\"|" \
-e "s|^trust_height *=.*|trust_height = $BLOCK_HEIGHT|" \
-e "s|^trust_hash *=.*|trust_hash = \"$TRUST_HASH\"|" \
-e "s|^persistent_peers *=.*|persistent_peers = \"$SYNC_PEER\"|" \
$HOME/.gaia/config/config.toml

mv $HOME/.gaia/priv_validator_state.json.backup $HOME/.gaia/data/priv_validator_state.json

Step 3: Start the node and follow the logs

sudo service cosmoshub start && sudo journalctl -fu cosmoshub -o cat