Skip to content

Caplin downloader sync

battlmonstr edited this page Nov 2, 2023 · 2 revisions

APIs

  1. Unofficial beacon chain checkpoint sync REST API - allows to get every 32nd block (gaps could be more than 32 sometimes). The last checkpoint is 96 blocks behind the tip. It is a centralized API and requires us to hardcode trusted server IPs. We trust that the blocks they return belong to the canonical chain. The blocks that it returns contain an EL header hash that is needed for verification.
  2. eth2 P2P API (libp2p-based) - allows to get all block bodies, but we don't trust them. We need to stitch them with the checkpoint blocks from (1) in order to verify them.
  3. Official beacon chain API - returns a "beacon state" which contains only the last EL header hash (tip of the canonical chain). We trust it, because it is signed by validators.

Caplin downloader v1

  1. Downloads all checkpoint blocks from (1)
  2. Fills the gaps between the checkpoints from (2). Bodies are downloaded, headers are derived from bodies.
  3. Pushes all the headers and bodies through the execution.proto GRPC API to erigon EL.
  4. The EL headers/bodies downloader stages act as a passive intake inserting headers/bodies into the db.

Caplin sync v1

TODO: describe what happens after the last checkpoint for the last 96 blocks

References