Loading...

Our State Sync server setup

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.
Our `app.toml` settings related to state-sync is as follows
# Prune Type
pruning = "custom"

# Prune Strategy
pruning-keep-every = 2000

# State-Sync Snapshot Strategy
snapshot-interval = 2000
snapshot-keep-recent = 5
Our state-sync RPC server
https://injective-rpc.tienthuattoan.com

Stop the service and reset the data

sudo systemctl stop injectived
cp $HOME/.injectived/data/priv_validator_state.json $HOME/.injectived/priv_validator_state.json.backup
injectived tendermint unsafe-reset-all --keep-addr-book --home $HOME/.injectived
Get and configure the state sync information
SNAP_RPC="https://injective-rpc.tienthuattoan.com:443"

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

sed -i.bak -E "s|^(enable[[:space:]]+=[[:space:]]+).*$|\1true| ; \
s|^(rpc_servers[[:space:]]+=[[:space:]]+).*$|\1\"$SNAP_RPC,$SNAP_RPC\"| ; \
s|^(trust_height[[:space:]]+=[[:space:]]+).*$|\1$BLOCK_HEIGHT| ; \
s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"|" $HOME/.injectived/config/config.toml
  
mv $HOME/.injectived/priv_validator_state.json.backup $HOME/.injectived/data/priv_validator_state.json

Download latest wasm (optional)

If the chain does not support copy of the wasm folder, you can download it manually. We have taken out the cache sub-folder to ensure the wasm folder is compatible for all CPUs.

Version Size Link
2.1.2 210M injective_wasmonly.tar.lz4
# Remove the empty wasm folder if you have an empty one
rm -r ~/.injectived/wasm

# Get our wasm folder
wget -O injective_wasmonly.tar.lz4 https://snapshots.tienthuattoan.com/mainnet/injective/injective_wasmonly.tar.lz4

# Extract the wasm folder into the right place
lz4 -c -d injective_wasmonly.tar.lz4 | tar -x -C $HOME/.injectived

Restart the service

sudo systemctl restart injectived
sudo journalctl -u injectived -f