# 📥 State Syns

#### *Stop the service and reset the data* <a href="#stop-the-service-and-reset-the-data" id="stop-the-service-and-reset-the-data"></a>

```bash
sudo systemctl stop celestia-appd
cp $HOME/.celestia-app/data/priv_validator_state.json $HOME/.celestia-app/priv_validator_state.json.backup
celestia-appd tendermint unsafe-reset-all --home $HOME/.celestia-app
```

#### *Get height and hash*

```bash
SNAP_RPC=https://celestia-mainnet-rpc.validexis.com:443
LATEST_HEIGHT=$(curl -s $SNAP_RPC/block | jq -r .result.block.header.height)
BLOCK_HEIGHT=$((LATEST_HEIGHT - 1000))
TRUST_HASH=$(curl -s "$SNAP_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)
echo $LATEST_HEIGHT $BLOCK_HEIGHT $TRUST_HASH
```

#### *Download addrbook*

```bash
wget -O $HOME/.celestia-app/config/addrbook.json https://mainnets1.validexis.com/celestia/addrbook.json
```

#### *Adding the variables to config.tom*l

```bash
sed -E -i.bak \
  -e "s|^(enable[[:space:]]*=[[:space:]]*).*$|\1true|" \
  -e "s|^(rpc_servers[[:space:]]*=[[:space:]]*).*$|\1\"$SNAP_RPC,$SNAP_RPC\"|" \
  -e "s|^(trust_height[[:space:]]*=[[:space:]]*).*$|\1$BLOCK_HEIGHT|" \
  -e "s|^(trust_hash[[:space:]]*=[[:space:]]*).*$|\1\"$TRUST_HASH\"|" \
  -e "s|^(seeds[[:space:]]*=[[:space:]]*).*$|\1\"\"|" \
  $HOME/.celestia-app/config/config.toml

mv $HOME/.celestia-app/priv_validator_state.json.backup $HOME/.celestia-app/data/priv_validator_state.json
```

#### Restart the service and check the log <a href="#restart-the-service-and-check-the-log" id="restart-the-service-and-check-the-log"></a>

```bash
sudo systemctl start celestia-appd && sudo journalctl -u celestia-appd -f --no-hostname -o cat
```
