Snapchain provides snapshot download functionality, but lacks critical production features:
| Feature | Snapchain | SnapSync |
|---|---|---|
| Resumable Downloads | β No | β Yes |
| File Verification (MD5) | β No | β Yes |
| Resumable Extraction | β No | β Yes |
| Corruption Detection | β No | β Yes |
| Stage Control | β No | β Yes |
| Parallel Downloads | β No | β Yes |
The 80-Day Problem:
When Snapchain's snapshot download or extraction fails:
- β Snapshot is incomplete or corrupted
- β Snapchain falls back to full blockchain sync
- β Current sync speed: ~80 days to catch up
- β Your node is offline for nearly 3 months
SnapSync Solution:
With SnapSync's resumable downloads and extraction:
- β Download interrupted? Resume in < 1 minute
- β Extraction interrupted? Resume from last file
- β Corruption detected? Re-download only bad chunks
- β Zero risk of 80-day sync penalty
Result: Hours instead of months. Production-ready reliability.
- π Resumable Downloads - Continue interrupted downloads with MD5 verification
- π Resumable Extraction - Resume extraction after interruption (no data loss)
- β MD5 Verification - Automatic integrity checking using ETag/MD5 checksums
- β‘ Parallel Downloads - Concurrent chunk downloads (configurable workers, default: 4)
- β‘ Parallel Decompression - Multi-core CPU utilization for fast merging
- π Progress Tracking - Real-time progress bars with accurate ETA
- π Automatic Retry - Built-in retry logic for transient network failures
- ποΈ Stage Control - Download, merge, and extract independently
- π Multi-Shard Support - Efficiently download multiple shards
- π₯οΈ Cross-Platform - Pre-built binaries for Linux and macOS
- β 100% compatible with Snapchain snapshot format
- β
Same directory structure (
.rocksand.rocks.snapshot) - β Drop-in replacement for Snapchain's snapshot download
- β No migration needed - Works with existing Snapchain setup
# From source
cargo install --path .
# Or download pre-built binaries from GitHub Releases# Download and restore all shards (complete workflow)
snapsync --shards 0,1,2
# Download specific shard
snapsync --shards 2 --output .rocks
# Faster downloads with more workers
snapsync --shards 2 --workers 8
# Stage-based execution (download, merge, extract separately)
snapsync --shards 2 --stage download # Download chunks only
snapsync --shards 2 --stage merge # Merge chunks into tar
snapsync --shards 2 --stage extract # Extract tar to directory
# Trust existing files (skip verification, fastest resume)
snapsync --shards 2 --skip-verifysnapsync [OPTIONS]
Options:
-n, --network <NETWORK>
Network name (FARCASTER_NETWORK_MAINNET, FARCASTER_NETWORK_TESTNET, FARCASTER_NETWORK_DEVNET)
[default: FARCASTER_NETWORK_MAINNET]
-s, --shards <SHARDS>...
Shard IDs to download (comma-separated, e.g., "0,1")
-o, --output <OUTPUT>
Output directory for RocksDB data
[default: .rocks]
--snapshot-url <SNAPSHOT_URL>
Snapshot download base URL
[default: https://pub-d352dd8819104a778e20d08888c5a661.r2.dev]
--temp-dir <TEMP_DIR>
Temporary download directory
[default: .rocks.snapshot]
-v, --verbose
Verbose logging
-w, --workers <WORKERS>
Number of concurrent downloads
[default: 4]
-h, --help
Print help
-V, --version
Print versionsnapsync --network FARCASTER_NETWORK_MAINNET --shards 0,1 --output ./data/.rocks
# Or use the default (FARCASTER_NETWORK_MAINNET)
snapsync --shards 0,1 --output ./data/.rockssnapsync --network FARCASTER_NETWORK_TESTNET --shards 0 --output ./testnet-data --verbose# Default is 4 workers, increase for faster downloads
# Note: Worker count is not limited by CPU cores (async I/O)
# Even 2-core CPUs can efficiently handle 8-16 workers
snapsync --shards 0,1,2 --workers 8 --output .rocksSimply run the same command again - SnapSync will:
- Check existing files via HEAD request
- Verify MD5 checksums
- Skip already-verified chunks
- Download only missing or corrupted files
# This will resume from where it left off
snapsync --shards 0,1 --output .rocksSnapSync is 100% compatible with Snapchain's original download logic:
# If you have partial downloads from Snapchain in .rocks.snapshot/
# Just run SnapSync - it will verify and resume automatically
snapsync --shards 0,1 --output .rocks --temp-dir .rocks.snapshotSnapSync will:
- β
Read existing
.rocks.snapshot/directory - β Verify all existing chunks via MD5
- β Skip verified files
- β Download only missing/corrupted chunks
- Fetch Metadata - Downloads
latest.jsonfor each shard containing chunk list - Verify Local Files - Checks if chunks already exist and match remote MD5
- Download Chunks - Streams chunks with progress tracking and MD5 verification
- Decompress - Unzips gzip chunks and merges into single tar
- Extract - Unpacks tar archive into RocksDB directory
- Cleanup - Removes temporary files
When you restart a download:
- β HEAD Request: Queries remote file size and ETag (MD5)
- β Size Check: Compares local file size with remote
- β MD5 Verification: Computes local file MD5 and compares with ETag
- β Skip or Re-download: Uses local file if valid, otherwise re-downloads
This makes interrupted downloads very cheap to resume!
-
lib.rs- Core download and verification logicdownload_snapshots()- Main entry pointverify_local_file()- Resume logicdownload_file()- Streaming download with MD5compute_file_md5()- File integrity checking
-
main.rs- CLI interface built withclap
reqwest- HTTP client for downloadingmd5- Checksum verificationtokio- Async runtimeindicatif- Progress barsflate2+tar- Decompression and extractiontokio-retry2- Automatic retry logic
| Shard Size | Network | Estimated Time |
|---|---|---|
| ~50 GB | 1 Gbps | ~7 minutes |
| ~50 GB | 100 Mbps | ~70 minutes |
- Streaming Downloads: No excessive memory usage
- MD5 During Download: No separate verification pass
- HEAD Requests: Fast resume checks (~100ms per chunk)
- Efficient Retry: Only retries failed chunks
SnapSync handles various error scenarios:
- Network Failures: Automatic retry with exponential backoff
- Corrupted Files: Detected via MD5, automatically deleted and re-downloaded
- Missing Remote Files: Clear error messages
- Disk Space: Errors during write are properly reported
cargo build --releasecargo testcargo check
cargo clippyThis project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
SnapSync - Fast, reliable RocksDB snapshot downloader
Copyright (C) 2024 Farcaster Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Some chunks may not have ETag headers. SnapSync will still download them but can't verify MD5. This is normal for very old snapshots.
Usually indicates:
- Partial download (will be re-downloaded automatically)
- Corrupted local file (will be re-downloaded)
- Check your network connection
- Try a different time (CDN may be congested)
- Use
--verboseto see detailed progress
Ensure you have enough space:
- ~100 GB per shard for data
- ~10-20 GB for temporary files during download
Extracted from the Snapchain codebase and optimized for standalone use.
