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.

Stop the service and reset the data

sudo systemctl stop sei.service
cp $HOME/.sei/data/priv_validator_state.json $HOME/.sei/priv_validator_state.json.backup
rm -rf $HOME/.sei/data

Get and configure the state sync information

LATEST_HEIGHT=$(curl -s "$SNAP_RPC/block" | jq -r .block.header.height)
TRUST_HASH=$(curl -s "$SNAP_RPC/block?height=$BLOCK_HEIGHT" | jq -r .block_id.hash)


sed -i.bak -E \
  -e "s|^(enable[[:space:]]+=[[:space:]]+).*$|\1true|" \
  -e "s|^(rpc-servers[[:space:]]+=[[:space:]]+).*$|\1\"$STATE_SYNC_RPC,$STATE_SYNC_RPC\"|" \
  -e "s|^(trust-height[[:space:]]+=[[:space:]]+).*$|\1$BLOCK_HEIGHT|" \
  -e "s|^(trust-hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"|" \
  -e "s|^(use-p2p[[:space:]]+=[[:space:]]+).*$|\1true|" \
  -e "s|^(persistent-peers[[:space:]]+=[[:space:]]+).*$|\1\"$PEER\"|" \

mkdir $HOME/.sei/data
mv $HOME/.sei/priv_validator_state.json.backup $HOME/.sei/data/priv_validator_state.json

Restart the service and check the log

sudo systemctl start sei.service && sudo journalctl -u sei.service -f --no-hostname -o cat