# State Sync Troubleshooting / Resetting Chain Data

## State Sync Failed!?

There are three main reasons why a state sync will fail:

* RPC connection fails, or is rate limited
* Not enough healthy peers / seeds configured
* Incorrect trusted height / trusted hash

### Steps to reset chain data without losing your accounts:

1\) Stop the node process with `ctrl^c` (or `sudo systemctl stop layer` if it's a service)

2\) Remove the chain data from `~/.layer/data/`, being careful to NOT delete the `priv_validator_state.json` file:

```sh
# Delete the binaries
# This is useful if you're not sure that you downloaded the right binaries:
rm -rf ~/layer/binaries

# deletes chain data
# This is useful if state sync fails and you need to try a different config
rm -rf ~/.layer/data/application.db; \
rm -rf ~/.layer/data/blockstore.db; \
rm -rf ~/.layer/data/cs.wal; \
rm -rf ~/.layer/data/evidence.db; \
rm -rf ~/.layer/data/snapshots; \
rm -rf ~/.layer/data/state.db; \
rm -rf ~/.layer/data/tx_index.db
```

Next, open up your configs.

```sh
nano ~/.layer/config/config.toml
```

Use `ctrl^w` to search, or scroll down to the `[p2p]` section.

```toml
#######################################################
###           P2P Configuration Options             ###
#######################################################
[p2p]

# Address to listen for incoming connections
laddr = "tcp://0.0.0.0:26656"

# Address to advertise to peers for them to dial. If empty, will use the same
# port as the laddr, and will introspect on the listener to figure out the
# address. IP and port are required. Example: 159.89.10.97:26656
external_address = ""

# Comma separated list of seed nodes to connect to
seeds = "f4786bc2a40172e29784b9f8d..."

# Comma separated list of nodes to keep persistent connections to
persistent_peers = "f4786bc2a40172e29784b9f8d69567c474d..."

# Path to address book
addr_book_file = "config/addrbook.json"

# Set true for strict address routability rules
# Set false for private or local networks
addr_book_strict = false

```

Try manually editing the seeds and persistent\_peers to match [those shown here](broken://pages/6obmvOkNkczgoNDiiU4c).

In most cases `addr_book_strict` can be safely changed to `true`.

Find the `[statesync]` section.

```toml
#######################################################
###         State Sync Configuration Options        ###
#######################################################
[statesync]
# State sync rapidly bootstraps a new node by discovering, fetching, and restoring a state machine
# snapshot from peers instead of fetching and replaying historical blocks. Requires some peers in
# the network to take and serve state machine snapshots. State sync is not attempted if the node
# has any local state (LastBlockHeight > 0). The node will have a truncated block history,
# starting from the height of the snapshot.
enable = true

# RPC servers (comma-separated) for light client verification of the synced state machine and
# retrieval of state data for node bootstrapping. Also needs a trusted height and corresponding
# header hash obtained from a trusted source, and a period during which validators can be trusted.
#
# For Cosmos SDK-based chains, trust_period should usually be about 2/3 of the unbonding time (~2
# weeks) during which they can be financially punished (slashed) for misbehavior.
rpc_servers = "https://mainnet.tellorlayer.com/rpc/,https://mainnet.tellorlayer.com/rpc/"
trust_height = 217310
trust_hash = "F526C5B5C79DECDC27F555A96A7B3F33444DE060AD5C9A02A7F5D15C5DBE85"
trust_period = "168h0m0s"

```

***Take a moment to check that\*\*\*\*****&#x20;****`enable = true`****&#x20;****, and check that your\*\*\*\* ****`rpc_servers`****,****&#x20;****`trust_height`****&#x20;****, and\*\*\*\*****&#x20;****`trust_hash`****&#x20;****\*\*\*\*are configured using the steps shown in***[ ***Node Setup***](broken://pages/OzHKVqI8SaLRc9qfBb3m)***. (be careful to choose the tabs that match your system)***

The `trust_period` should be left alone, and the `discovery_time` can be safely increased to "30s".

### Start your Node

{% code overflow="wrap" %}

```sh
./layerd start --price-daemon-enabled=false --home ~/.layer --keyring-backend test --key-name YOUR_ACCOUNT_NAME
```

{% endcode %}

If the sync is working, you will see your node quickly finding, downloading, and applying snapshots.

{% hint style="success" %}
***Notes:***\
\&#xNAN;***- "We need more peers..." messages are normal and can be ignored.***\
\&#xNAN;***- A statesync with good RPCs and Peers can still take an hour or more to finish downloading the state snapshot.***
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tellor.io/tellor/running-tellor/node-setup/state-sync.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
