spaces-checkpoint
Fast-sync for spaced nodes by downloading a verified snapshot of the database state.
Generating a checkpoint
Run from the workspace root with a fully synced spaced data directory:
This will:
- Read the current tip (block hash + height) from
root.sdb - Create
checkpoint-<height>.tar.gzcontainingroot.sdb,nums.sdb, andindex.sqlite - Update
checkpoint/src/integrity.rswith the SHA-256 digest - If
--uploadis specified, upload the archive andlatest.jsonto S3
Uploading
Upload to an S3-compatible bucket with --upload:
# AWS S3
# Cloudflare R2
Requires the AWS CLI to be installed and configured.
This uploads both checkpoint-<height>.tar.gz and latest.json to the bucket. latest.json contains the height, block hash, and digest so consumers can check for newer checkpoints without downloading the full archive.
Usage
Add to your Cargo.toml (without the CLI tools):
= { = "../checkpoint", = false }
Three functions, you control the flow:
use ;
if needs_checkpoint
Return values
ensure_checkpoint returns:
Ok(true)— checkpoint appliedOk(false)— server unreachable after retries, fall back to full syncErr(CheckpointError)— local filesystem error
fetch_latest returns:
Ok(Some(Checkpoint))— latest checkpoint metadata from serverOk(None)— server unreachableErr(CheckpointError)— invalid response