> For the complete documentation index, see [llms.txt](https://services.stakeangle.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://services.stakeangle.com/mainnets/tgrade/state-sync.md).

# 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 tgrade
tgrade tendermint unsafe-reset-all --home $HOME/.tgrade --keep-addr-book
```

2. **Add peers.**

```
SEEDS="8639bc931d5721a64afc1ea52ca63ae40161bd26@194.163.144.63:26656,4557e0d0f4d543480b96ba9da3c167e4dfb32e14@167.99.67.252:26656,2df762919720bca5f46042f77148de73c06049d8@seed.tgrade.validator.run:26656"
PEERS="0a63421f67d02e7fb823ea6d6ceb8acf758df24d@142.132.226.137:26656,4a319eead699418e974e8eed47c2de6332c3f825@167.235.255.9:26656,6918efd409684d64694cac485dbcc27dfeea4f38@49.12.240.203:26656"
sed -i -e "s/^seeds *=.*/seeds = \"$SEEDS\"/; s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $HOME/.tgrade/config/config.toml
```

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

```
RPC="https://tgrade-rpc.stakeangle.com:443"
RECENT_HEIGHT=$(curl -s $RPC/block | jq -r .result.block.header.height)
TRUST_HEIGHT=$((RECENT_HEIGHT - 500))
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/.tgrade/config/config.toml
```

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

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

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