https://github.com/lambdasistemi/chain-follower
Abstract chain follower types — Follower, Intersector, ProgressOrRewind
https://github.com/lambdasistemi/chain-follower
blockchain chain-sync follower haskell
Last synced: 3 months ago
JSON representation
Abstract chain follower types — Follower, Intersector, ProgressOrRewind
- Host: GitHub
- URL: https://github.com/lambdasistemi/chain-follower
- Owner: lambdasistemi
- License: apache-2.0
- Created: 2026-03-19T20:11:46.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-03-27T13:09:02.000Z (3 months ago)
- Last Synced: 2026-03-27T23:51:10.946Z (3 months ago)
- Topics: blockchain, chain-sync, follower, haskell
- Language: Haskell
- Size: 920 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# chain-follower
Generic blockchain synchronization library with rollback support, phase management, and formally verified correctness.
**[Documentation](https://lambdasistemi.github.io/chain-follower/)**
## What it does
Chain Follower sits between a chain source and your application backend. It manages block ingestion across two phases (bulk restoration and near-tip following), stores inverse operations for rollback, and guarantees that fork resolution produces the correct final state regardless of the traversal path.
Core correctness properties are proved in Lean 4 and mirrored as QuickCheck properties via `ChainFollower.Laws`.
## Quick start
```bash
# Run the tutorial (demonstrates full lifecycle)
nix run github:lambdasistemi/chain-follower#tutorial
# Development shell
nix develop
# Build, test, lint
just ci
```
## Modules
| Module | Purpose |
|--------|---------|
| `ChainFollower.Backend` | CPS backend interface: `Restoring`, `Following`, `Init` |
| `ChainFollower.Runner` | State machine: `processBlock`, `rollbackTo` |
| `ChainFollower.Rollbacks.*` | Swap-partition rollback store |
| `ChainFollower.MockChain` | `BlockTree`, DFS walk, canonical path |
| `ChainFollower.Laws` | Testable backend laws derived from Lean proofs |
## Lean formalization
The `lean/` directory contains machine-checked proofs:
- `swap_inverse_restores` -- swap is an involution
- `rollback_restores` -- multi-step rollback via reversed inverse log
- `dfs_equiv_canonical` -- DFS walk of a well-formed block tree equals the canonical path (fully proved, no sorry)
## License
Apache-2.0