State sync

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

C4E
C4E

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 c4ed and reset database

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

Get and configure the state sync information

STATE_SYNC_RPC=https://rpc.cosmos.directory:443/chain4energy
BACKUP_RPC=https://chain4energy-rpc.lavenderfive.com:443
LATEST_HEIGHT=$(curl -s $STATE_SYNC_RPC/block | jq -r .result.block.header.height)
BLOCK_HEIGHT=$(echo 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="8ac87f7f8da5c2a901d64f2c1e86f8b6ee39fef1@seed-m.c4e.apeironnodes.com:41003,edca3b826d61d1e5e7d3dc173954de1324f2e512@seed-m.c4e.apeironnodes.com:27003,30e98bbcf5bb29ed4e4ff685fa8fa84fa0ddff51@tenderseed.ccvalidators.com:26008,54515079bae4cadae2f9b511cffeb9447d4bc98d@c4e.seed.bccnodes.com:30656,86bd5cb6e762f673f1706e5889e039d5406b4b90@c4e.seed.node75.org:10156,54ca81dd509cc6160de7f4b479a96b341d8e830e@rpc.c4e.nodexcapital.com:13956,6da239cb4fe03d957cdb1fdc26af3d083a7f5945@seed.c4e.hexnodes.co:02656,9aa8a73ea9364aa3cf7806d4dd25b6aed88d8152@c4e.seed.mzonder.com:11256,fbf9a48eca1ba873ad766e2cb72a0562596a248f@c4e.seed.stavr.tech:17096,a85a651a3cf1746694560c5b6f76d566c04ca581@c4e-seed.takeshi.team:10256,ebc272824924ea1a27ea3183dd0b9ba713494f83@chain4energy-mainnet-seed.autostake.com:27276,8cb175d973c3c638a4e5d014c030d8599369419f@seeds.cros-nest.com:28656,5e71b5585d186cc32b9f071610f43042b445c05c@seeds.c4e.silentvalidator.com:39656,6b0ffcce9b59b91ceb8eea5d4599e27707e3604a@seeds.stakeup.tech:10210,6cb7ff21d19f139f4ca5e6e2a336e59d2857aba1@seeds.anode.team:10256,e47f4fa12187234dd205f51cb984c8235c3a3511@c4e-seeds.validatrium.club:26656,3ef7e5e7e163500af9baf53480779448461dac18@185.245.182.192:46656,0d1a44cc32e927dd062e0fd45d21475f9836e73d@89.117.58.109:26656,d81f51b4a1aae66792fb1717589fa28975f328b0@164.68.125.243:26656,2e08beed75525c2d583e6413fa5f090801965aba@c4e.doubletop:30655,6f181c91dee34ebf2ea5c4f951c51b8c2c897702@c4e.seed.kalia.network:30656,8739107d0484a4c58c4f980d61f488655597f80c@seed.c4e.validatus.com:2000,8542cd7e6bf9d260fef543bc49e59be5a3fa9074@seed.publicnode.com:26656"

echo -e "Modifying $HOME/.c4e-chain/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/.c4e-chain/config/config.toml

mv $HOME/.c4e-chain/priv_validator_state.json.backup $HOME/.c4e-chain/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/.c4e-chain/wasmonly.tar.zst | tar -xaf - -C $HOME/.c4e-chain

Restart c4ed and check the log

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

Last updated