Skip to content

Snapsync

Egor Lysenko edited this page Feb 23, 2022 · 1 revision

Snapsync mode

Snapsync mode outline

Snapsync synchronization mode allows to securely download recent finalized EVM state without processing prior transactions. Once snapsync is finalized, node switches to the default fullsync mode.

Snapsync synchronization mode in go-opera relies on two parts:

  • LLR auxiliary consensus mechanism to securely download block/epoch records, along with EVM state root of a first block in latest epoch
  • Snapsync protocol to securely download EVM state from peers, given the EVM state root which is finalized by LLR

In order to start snapsync protocol, LLR should only download latest epoch record, but not necessarily all block records. Since there's much more blocks than epochs, blocks download and processing will work in parallel with snapspync protocol.

Once all block/epoch records are downloaded, and latest EVM state is accessible, the snapsync may be finalized.

Snapsync protocol outline

Snapsync protocol downloads the EVM state in two stages:

  1. Downloads continuous batches of EVM items, provided with Merkle paths for instant verification. Note: single Merkle path for a continues batch of items is much cheaper than multiple Merkle paths for each individual item - this way, it's roughly as fast as a simple file download.
  2. Continuously requests missing or outdated items until the state is fully healed

Note: state root may change multiple times during both step 1 and 2. first stage aims to (quickly) download (some) items (which aren't guaranteed to stay actual after a next state root change), while state heal stage is needed to (relatively slowly) fix the mistakes in the state. Given that state changes gradually (which is guaranteed by the limited gas per second consumption), the majority of data downloaded via first stage should stay actual until snapsync finalization.

Except using LLR instead of Ethash (for secure block/epoch records download), snapsync protocol is used as in the Ethereum protocol, which is described in more details here: https://github.com/ethereum/devp2p/blob/master/caps/snap.md