March 16, 2022
How to bootstrap any tendermint (cosmos) node using State-Sync
State sync rapidly bootstraps a new node by discovering, fetching, and restoring a state machine snapshot from peers instead of fetching and replaying historical blocks. Requires some peers in the network to take and serve state machine snapshots.
Step by step gude how to bootstrap Cosmic-Horizon darkmatter-1 testnet chain
# set variables CHAIN_HOME=$HOME/.coho CHAIN_SERVICE=cohod CHAIN_BINARY=cohod # set rpc endpoints and peers SNAPSHOT_RPC1="http://62.171.147.117:26657" SNAPSHOT_RPC2="http://62.171.152.201:26657" PEER1="[email protected]:26656" PEER2="[email protected]:26656" # stop the chain service and perform reset sudo systemctl stop $CHAIN_SERVICE && $CHAIN_BINARY unsafe-reset-all # set state sync config variables LATEST_HEIGHT=$(curl -s $SNAPSHOT_RPC1/block | jq -r .result.block.header.height) BLOCK_HEIGHT=$((LATEST_HEIGHT - 2000)) TRUST_HASH=$(curl -s "$SNAPSHOT_RPC1/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash) # check echo $LATEST_HEIGHT $BLOCK_HEIGHT $TRUST_HASH # set peers peers="$PEER1,$PEER2" sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$peers\"/" $CHAIN_HOME/config/config.toml # write config to config.toml (onde command) sed -i.bak -E "s|^(enable[[:space:]]+=[[:space:]]+).*$|\1true| ; \ s|^(rpc_servers[[:space:]]+=[[:space:]]+).*$|\1\"$SNAPSHOT_RPC1,$SNAPSHOT_RPC2\"| ; \ s|^(trust_height[[:space:]]+=[[:space:]]+).*$|\1$BLOCK_HEIGHT| ; \ s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"| ; \ s|^(seeds[[:space:]]+=[[:space:]]+).*$|\1\"\"|" $CHAIN_HOME/config/config.toml # start the service sudo systemctl start $CHAIN_SERVICE # check a logs sudo journalctl -u $CHAIN_SERVICE -f