https://github.com/murphsicles/vsr
@consensus/vsr — Viewstamped Replication consensus for Zeta
https://github.com/murphsicles/vsr
Last synced: 22 days ago
JSON representation
@consensus/vsr — Viewstamped Replication consensus for Zeta
- Host: GitHub
- URL: https://github.com/murphsicles/vsr
- Owner: murphsicles
- License: mit
- Created: 2026-06-07T01:39:35.000Z (about 2 months ago)
- Default Branch: master
- Last Pushed: 2026-06-07T02:38:49.000Z (about 2 months ago)
- Last Synced: 2026-06-07T03:40:52.301Z (about 2 months ago)
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vsr — Viewstamped Replication consensus for Zeta
**Namespace:** `@consensus/vsr`
Viewstamped Replication (VSR) consensus protocol implementation.
Replica state machine, view change, prepare/commit log replication,
and quorum-based fault tolerance.
## Protocol
```
Client → Primary: REQUEST
Primary → Followers: PREPARE
Followers → Primary: PREPARE_OK
Primary → All: COMMIT (after quorum)
Primary → Client: REPLY
On failure:
Follower → All: START_VIEW_CHANGE
Candidates → All: DO_VIEW_CHANGE
New Primary → All: START_VIEW
```
## Key structs
| Struct | Purpose |
|--------|---------|
| `Replica` | Core state machine (view, role, op, commit) |
| `LogEntry` | Prepared operation with checksum |
| `Prepare` | Primary-to-follower replication message |
| `ViewChangeState` | View change tracking |
## API
- `Replica_new(id, cluster_size)` — create replica
- `on_request(request, client)` — process client request on primary
- `on_prepare(prepare)` — follower receives prepare
- `on_prepare_ok(sender, slot, view)` — primary counts votes
- `start_view_change()` — initiate view change
- `do_view_change(new_view, log, sender)` — cast vote
- `start_view(new_view, op, commit)` — accept new view
## License
MIT — The Zeta Foundation