State sync
info
State synchronization enables a new node to seamlessly integrate into the network by retrieving a snapshot of the application state at a recent height, rather than fetching and replaying all historical blocks. Given that the application state is typically more compact than the blocks themselves, and the restoration process is significantly quicker than block replay, this method can drastically diminish the network synchronization duration from days to mere minutes.
Instructionsβ
Stop the service and reset the dataβ
sudo systemctl stop lavad
cp $HOME/.lava/data/priv_validator_state.json $HOME/.lava/priv_validator_state.json.backup
lavad tendermint unsafe-reset-all --keep-addr-book --home $HOME/.lava
Get and configure the state sync informationβ
STATE_SYNC_RPC=https://lava-mainnet-1-rpc.owlstake.com:443
STATE_SYNC_PEER=d9bfa29e0cf9c4ce0cc9c26d98e5d97228f93b0b@65.108.233.103:14456
LATEST_HEIGHT=$(curl -s $STATE_SYNC_RPC/block | jq -r .result.block.header.height)
SYNC_BLOCK_HEIGHT=$(($LATEST_HEIGHT - 1000))
SYNC_BLOCK_HASH=$(curl -s "$STATE_SYNC_RPC/block?height=$SYNC_BLOCK_HEIGHT" | jq -r .result.block_id.hash)
sed -i \
-e "s|^enable *=.*|enable = true|" \
-e "s|^rpc_servers *=.*|rpc_servers = \"$STATE_SYNC_RPC,$STATE_SYNC_RPC\"|" \
-e "s|^trust_height *=.*|trust_height = $SYNC_BLOCK_HEIGHT|" \
-e "s|^trust_hash *=.*|trust_hash = \"$SYNC_BLOCK_HASH\"|" \
-e "s|^persistent_peers *=.*|persistent_peers = \"$STATE_SYNC_PEER\"|" \
$HOME/.lava/config/config.toml
mv $HOME/.lava/priv_validator_state.json.backup $HOME/.lava/data/priv_validator_state.json
Restart the service and check the logβ
sudo systemctl start lavad && sudo journalctl -u lavad -f --no-hostname -o cat