Sync with state-sync
Instructions for joining Juno networks with statesync
THIS CONFIGURATION IS NOT CURRENTLY WORKING. SUPPORT IS IN DEVELOPMENT.

Introduction

State-sync is a module built into the Cosmos SDK to allow validators to rapidly join the network by syncing your node with a snapshot enabled RPC from a trusted block height.
This greatly reduces the time required for a validator or sentry to sync with the network from days to minutes. The limitations of this are that there is not a full transaction history, just the most recent state that the state-sync RPC has stored. An advantage of state-sync is that the database is very small in comparison to a fully synced node, therefore using state-sync to resync your node to the network can help keep running costs lower by minimising storage usage.
By syncing to the network with state-sync, a node can avoid having to go through all the upgrade procedures and can sync with the most recent binary only.
For nodes that are intended to serve data for dapps, explorers or any other RPC requiring full history, state-syncing to the network would not be appropriate.

Uni testnet state-sync

Kingnodes operate and maintain a snapshot RPC for the uni testnet network.
This documentation assumes you have followed the instructions for Joining Testnets and Setting up Cosmovisor.
The state-sync configuration is as follows:
1
# snapshot-interval specifies the block interval at which local state sync snapshots are
2
# taken (0 to disable). Must be a multiple of pruning-keep-every.
3
snapshot-interval = 2000
4
5
# snapshot-keep-recent specifies the number of recent snapshots to keep and serve (0 to keep all).
6
snapshot-keep-recent = 10
Copied!
Set SNAP_RPC variable to the kingnodes snapshot RPC
1
SNAP_RPC="https://rpc.uni.kingnodes.com:443"
Copied!
Fetch the LATEST_HEIGHT from the snapshot RPC, set the state-sync BLOCK_HEIGHT and fetch the TRUST_HASH from the snapshot RPC. The BLOCK_HEIGHT to sync is determined by subtracting the snapshot-interval from the LATEST_HEIGHT.
1
LATEST_HEIGHT=$(curl -s $SNAP_RPC/block | jq -r .result.block.header.height); \
2
BLOCK_HEIGHT=$((LATEST_HEIGHT - 2000)); \
3
TRUST_HASH=$(curl -s "$SNAP_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)
Copied!
Check variables to ensure they have been set
1
echo $LATEST_HEIGHT $BLOCK_HEIGHT $TRUST_HASH
2
3
# output should be something similar to:
4
# 1002969 1000969 0B532538F74C946B82D1697704B25F2D8E12D989766B30AF5F8730A7A7A94CDB
Copied!
If you have not already, set some persistent peers.
Set the required variables in ~/.juno/config/config.toml
1
sed -i.bak -E "s|^(enable[[:space:]]+=[[:space:]]+).*$|\1true| ; \
2
s|^(rpc_servers[[:space:]]+=[[:space:]]+).*$|\1\"$SNAP_RPC,$SNAP_RPC\"| ; \
3
s|^(trust_height[[:space:]]+=[[:space:]]+).*$|\1$BLOCK_HEIGHT| ; \
4
s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"| ; \
5
s|^(seeds[[:space:]]+=[[:space:]]+).*$|\1\"\"|" $HOME/.juno/config/config.toml
Copied!
Stop the node and reset the node database
WARNING: This will erase your node database. If you are already running validator, be sure you backed up your config/priv_validator_key.json and config/node_key.json prior to running unsafe-reset-all.
It is recommended to copy data/priv_validator_state.json to a backup and restore it after unsafe-reset-all to avoid potential double signing.
1
sudo systemctl stop cosmovisor && cosmovisor unsafe-reset-all
Copied!
Restart node and check logs
1
sudo systemctl restart junod && journalctl -u cosmovisor -f
Copied!