State sync

With our state sync services you will be able to catch up latest chain block in matter of minutes

BitCanna
BitCanna

State Sync allows a new node to join the network by fetching a snapshot of the application state at a recent height instead of fetching and replaying all historical blocks. Since the application state is generally much smaller than the blocks, and restoring it is much faster than replaying blocks, this can reduce the time to sync with the network from days to minutes.

Instructions

Stop bcnad and reset database

sudo systemctl stop bcnad
cp $HOME/.bcna/data/priv_validator_state.json $HOME/.bcna/priv_validator_state.json.backup
bcnad tendermint unsafe-reset-all --home $HOME/.bcna --keep-addr-book

Get and configure the state sync information

STATE_SYNC_RPC=https://rpc.cosmos.directory:443/bitcanna
BACKUP_RPC=https://bitcanna-rpc.lavenderfive.com:443
LATEST_HEIGHT=$(curl -s $STATE_SYNC_RPC/block | jq -r .result.block.header.height)
BLOCK_HEIGHT=$(LATEST_HEIGHT | awk '{print $1 - ($1 % 6000)}'); \
TRUST_HASH=$(curl -s "$STATE_SYNC_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)
SEEDS="d6aa4c9f3ccecb0cc52109a95962b4618d69dd3f@seed1.bitcanna.io:26656,e2e7c704f766ef6b9e2c8dd61d963f8393b87966@seed3.bitcanna.io:26656,f0e6c86d769bf5c52f78e01864091690e731643f@bitcanna-seed.panthea.eu:37656,20e1000e88125698264454a884812746c2eb4807@seeds.lavenderfive.com:13056,258f523c96efde50d5fe0a9faeea8a3e83be22ca@seed.bitcanna-1.bitcanna.aviaone.com:10263,33ab202dfef5e08d5d0346e7b3cfaab2a946198a@seeds.bitcanna-mainnet.hexnodes.co:27656,d5ed854872ad96f114737889ac9521ea3a29e3a3@bitcanna-seed.oldcat.io:26656,d37062587a2aba2a5256b7363f722f4acb4b8e2f@seed-node.mms.team:30656,10ed1e176d874c8bb3c7c065685d2da6a4b86475@seed-bcna.ibs.team:16656,951cadb1888c0360dce506c1eff925cb6eb47e06@seeds-2.anode.team:10258,09ba537d6563018b97c502979c3478df4decf426@bitcanna-seed.genznodes.dev:20656,8542cd7e6bf9d260fef543bc49e59be5a3fa9074@seed.publicnode.com:26656,71df77a8f57af72a4d2b4e842c9ac7eaec31cc09@mainnet-seed.konsortech.xyz:27156,7546889cad5cb44012a9b190bee9c5a8d92d47cd@cottage.sopko.net:31656"

echo -e "Modifying $HOME/.bcna/config/config.toml based on the following values:"
echo -e "RPC Address:          $STATE_SYNC_RPC"
echo -e "Latest Block Height:  $LATEST_HEIGHT"
echo -e "Sync Block Height:    $BLOCK_HEIGHT"
echo -e "Trust Hash:           $TRUST_HASH"

sed -i \
  -e "s|^enable *=.*|enable = true|" \
  -e "s|^rpc_servers *=.*|rpc_servers = \"$STATE_SYNC_RPC,$BACKUP_RPC\"|" \
  -e "s|^trust_height *=.*|trust_height = $BLOCK_HEIGHT|" \
  -e "s|^trust_hash *=.*|trust_hash = \"$TRUST_HASH\"|" \
  -e "s|^seeds *=.*|seeds = \"$SEEDS\"|" \
  $HOME/.bcna/config/config.toml

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

Download latest wasm

Currently state sync does not support copy of the wasm folder. Therefore, you will have to download it manually.

curl -L https://snapshots.lavenderfive.com/wasm/$HOME/.bcna/wasmonly.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.bcna

Restart bcnad and check the log

sudo systemctl restart bcnad && sudo journalctl -u bcnad -f --no-hostname -o cat

Last updated