[Ethereum] Parity’s “warp” sync, and why is it faster than Geth “fast”

fast-syncparitysynchronizationwarp-sync

A follow-up of one of the classic questions on this site:

One of the answers to this question suggested using Geth's --fast flag to help quickly synchronise the block data.

Now, parity comes with a --warp flag to enable synchronization in 10 minutes.

--warp        Enable syncing from the snapshot over the network. (default: false)

How does the --warp flag work, and how does using it speed up the synchronisation? Are we syncing less data, or are we in some way performing fewer checks on its integrity or source?

Best Answer

It's difficult to give an answer without just re-hashing the explanation on the Parity wiki...

The pertinent part is as follows:

These snapshots can be used to quickly get a full copy of the state at a given block. Every 30,000 blocks, nodes will take a consensus-critical snapshot of that block's state. Any node can fetch these snapshots over the network, enabling a fast sync.

The snapshot itself is comprised of 3 parts:

  1. A manifest, which is basically metadata about the snapshot;
  2. Block chunks, which contain raw block data about blocks and their transaction receipts;
  3. State chunks, which contain data about the state at a given block.

Chunks are currently set to 4MB in size.

So how does this actually speed up the sync? What that wiki page doesn't say is that we only sync the snapshots initially. So for each block at intervals of 30,000, we obtain a set of 4MB chunks. Then in the background we continue to sync the remaining block data.

This is equivalent to Geth's --fast sync, which first syncs the block headers, and then in the background syncs the rest of the data. It's just that --warp is syncing even less data on the first pass, and filling in the bigger gaps later on.

Edit:

See also the relevant official Ethcore blog post, specifically the section entitled Core Strength.