# State Sync

{% hint style="info" %}
State Sync allows to sync a new node by fetching a snapshot of the network state at a recent height, instead of fetching and replaying all historical blocks.
{% endhint %}

{% hint style="info" %}
Some networks which use `wasm` may not yet support `wasm` folder transfers with State Sync. In this case you may need to download `wasm` folder separately.
{% endhint %}

{% hint style="info" %}
Depending on network, State Sync may need different amount of RAM to successfully fish sync process. It is recommended to have at least 8GB RAM.
{% endhint %}

1. **Stop existing service and reset database.**

```
sudo systemctl stop axoned
axoned tendermint unsafe-reset-all --home $HOME/.axoned --keep-addr-book
```

2. **Add peers.**

```
peers="e13c4a54ffd3d6dc71da5238471904ad8e303935@141.95.11.201:26656,2d524b4f87fc684e276abe8fe748e2ca45b767b6@85.202.163.243:26656,e97341e910d0f8c92257f16d38dcf5513196dd41@65.109.125.172:26632,a963a7a927a49dd66e9bf1c1a04127d34d7edb6f@65.21.227.52:26332,dcc0c9c254bdb81107b61f30ddb5f9ed32f24645@168.119.143.51:18656,740741048700f4e8cc1fb6609bddc569e5b9d6d5@65.108.236.5:20056,ea1d3b5b70ac85d553a645561fbfd95577afee4c@148.113.153.62:26656,9ae2608641ed016c38a5357c5ab1051da2cafba2@148.72.141.245:26616"
sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $HOME/.axoned/config/config.toml
```

3. **Fill variables with data for State Sync.**

```
RPC="https://axone-rpc.stakeangle.com:443"
RECENT_HEIGHT=$(curl -s $RPC/block | jq -r .result.block.header.height)
TRUST_HEIGHT=$((RECENT_HEIGHT - 2000))
TRUST_HASH=$(curl -s "$RPC/block?height=$TRUST_HEIGHT" | jq -r .result.block_id.hash)

echo $RECENT_HEIGHT $TRUST_HEIGHT $TRUST_HASH
```

4. **Add variable values to config.toml.**

```
sed -i.bak -E "s|^(enable[[:space:]]+=[[:space:]]+).*$|\1true| ; \
s|^(rpc_servers[[:space:]]+=[[:space:]]+).*$|\1\"$RPC,$RPC\"| ; \
s|^(trust_height[[:space:]]+=[[:space:]]+).*$|\1$TRUST_HEIGHT| ; \
s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"|" $HOME/.axoned/config/config.toml
```

5. **Start service and check journal.**

```
sudo systemctl restart axoned
sudo journalctl -u axoned -f -o cat
```

{% hint style="info" %}
State Sync typically takes up to 10 minutes.&#x20;
{% endhint %}
