# Block, Height & State-Sync Source with KSYNC

{% embed url="<https://app.kaon.kyve.network/#/sources/source-1>" %}
<https://app.kaon.kyve.network/#/sources/source-1>
{% endembed %}

The following doc covers a step by step guide on how to sync sourced nodes with validated block data stored with KYVE and how to apply the validated state-sync snapshots at any historical height with KSYNC. This allows Source node operators to sync from genesis to live height without the need of relying on peers and furthermore allows sourced node operators and developers to sync to any historical height within minutes.

For further information about the KYVE Protocol architecture, please take a look at the [documentation](https://docs.kyve.network/protocol_devs/overview).&#x20;

* Block data pool: <https://app.kaon.kyve.network/#/pools/24>
* Snapshot data pool: <https://app.kaon.kyve.network/#/pools/25> (contains state-sync snapshots at a 3,000 block interval)

## Install KSYNC

Install the latest KSYNC version v1.4.5 with&#x20;

```
go install github.com/KYVENetwork/ksync/cmd/ksync@latest
```

Verify the installation with

```
ksync version
```

More information about KSYNC can be found here: <https://docs.kyve.network/ksync>

## Install sourced

If sourced is not installed yet install sourced with

```
git clone 
https://github.com/Source-Protocol-Cosmos/source.git

cd source
git checkout v3.0.1
make build

./sourced version
```

Init source with

```
./sourced init <moniker> –chain-id source-1

curl -s  https://raw.githubusercontent.com/Source-Protocol-Cosmos/mainnet/master/source-1/genesis.json > ~/.source/config/genesis.json
```

## Example 1: Block-Sync from genesis:

Now that everything is installed you can block-sync with KSYNC with the following command:

```
ksync block-sync --binary="/path/to/sourced" --chain-id=kaon-1 --source=source
```

KSYNC will now rapidly sync all blocks until it hits the last block stored by the data pool.

## State-Sync to height 6,000

In order to state-sync to live height simply execute the following command (96,000 is in the time of writing the newest snapshot, if the pool runs for a few more weeks it would be at live height)

```
ksync state-sync --binary="/path/to/sourced" --chain-id=kaon-1 --source=source --target-height=6000 -r
```

After the state-sync is completed you can start syncing blocks from the network normally

```
./sourced start --p2p.seeds=7347b05f140e4ed5d3da7b26c754a486dc1d2ecd@source-mainnet-seed.itrocket.net:32656
```

## Height-Sync to height 9,496

In order to rapidly sync to any historical height within minutes KSYNC uses both state and block-sync to reach the target height as quickly as possible:

```
ksync height-sync --binary="/path/to/sourced" --chain-id=kaon-1 --source=source --target-height=9496 -r
```

After the target height was reached you can inspect the state at this height in order for example to checkout account balances at this specific height.

<br>


---

# 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.sourceprotocol.io/nodes-and-validators/block-height-and-state-sync-source-with-ksync.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.
