Skip to content

Local State Sync

yihuang edited this page Aug 28, 2023 · 15 revisions

In Cronos v1.0.12, we introduced a new set of commands to do local state sync, but before we talk about that, let's understand how a "normal" state sync works, after you setup state-sync in config and start the node, the node will:

  1. discover snapshots on the p2p network.
  2. verify the snapshot metadata by verifying the block headers between the snapshot and the trusted block height.
  3. download snapshot chunks from the p2p network.
  4. restore app state from the snapshot.
  5. bootstrap cometbft state.
  6. start normal sync.

With "normal" state sync, the node does all above steps automatically, it works great when the chain is small, but as the chain grows, the procedure becomes slow and unstable, the local state sync commands try to break down the procedure into smaller steps:

  1. discover snapshots from offline communications, for example community can share the snapshot with a http server.
  2. user download the shared snapshots with whatever tools and import into local snapshot database.
    $ cronosd snapshots load /path/to/downloaded-snapshot.tar.gz
    $ cronosd snapshots list
    <height> <format>
    
  3. restore app state from the snapshot:
    cronosd snapshots restore <height> <format>
    
  4. verify and bootstrap cometbft state based on current app state:
    cronosd tendermint bootstrap-state
    

5: start the node and sync normally.

Snapshot Provider

On the other hand, the snapshot providers can dump local snapshot to the portable tarball using following command:

$ cronosd snapshots dump <height> <format> --output /path/to/snapshot.tar.gz

Or can manually export an arbitrary version of state:

$ cronosd snapshots export --height <height>
$ cronosd snapshots list
<height> <format>
Clone this wiki locally