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
SNAP_RPC=https://sei.rpc.kjnodes.com:443
PEER=d9bfa29e0cf9c4ce0cc9c26d98e5d97228f93b0b@sei.rpc.kjnodes.com:16856
LATEST_HEIGHT=$(curl -s "$SNAP_RPC/block" | jq -r .block.header.height)
SYNC_BLOCK_HEIGHT=$(($(echo "$LATEST_HEIGHT" | awk '{printf "%d000\n", $0 / 1000}') - 1000))
TRUST_HASH=$(curl -s "$SNAP_RPC/block?height=$BLOCK_HEIGHT" | jq -r .block_id.hash)
echo $LATEST_HEIGHT $BLOCK_HEIGHT $TRUST_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\"|" \
$HOME/.sei/config/config.toml
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