https://github.com/wrongbyte/rust-paxos
✨ (WIP) Implementation of multi-decree Paxos algorithm in Rust, for learning purposes.
https://github.com/wrongbyte/rust-paxos
consensus consensus-algorithm distributed-systems paxos
Last synced: 1 day ago
JSON representation
✨ (WIP) Implementation of multi-decree Paxos algorithm in Rust, for learning purposes.
- Host: GitHub
- URL: https://github.com/wrongbyte/rust-paxos
- Owner: wrongbyte
- Created: 2024-11-27T01:22:12.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-08-26T19:27:15.000Z (about 1 month ago)
- Last Synced: 2025-10-04T07:48:11.261Z (6 days ago)
- Topics: consensus, consensus-algorithm, distributed-systems, paxos
- Language: Rust
- Homepage:
- Size: 162 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### [Paxos made simple](https://lamport.azurewebsites.net/pubs/paxos-simple.pdf)
To run, first setup the environment by running `nix develop` in the root of the repository, or allow `direnv` to do it automatically if you have it installed in your machine.
Now run `run`.
You can use the arguments `--nodes` and `rounds` to specify a custom number of nodes and rounds for the simulation. Run `--help` to see the available commands.### Architecture
This is a kind of simplified version of Paxos, so for now it does not support multiple proposers and learners. It also implies that the algorithm will halt if there's no proposer os learner (which is, if their nodes die in the process).In this implementation, the proposer performs the roles of both the proposer and learner, being the "leader" of the round, as stated in the "Paxos made simple" paper:
> The algorithm chooses a leader, which plays the roles of the distinguished proposer and the distinguished learner.
```mermaid
sequenceDiagram
participant Proposer
participant Acceptor
participant LearnerProposer->>Acceptor: Prepare(n)
Acceptor-->>Proposer: Promise(n, v) (highest seen n and value)
Proposer->>Acceptor: Accept(n, v) (proposed value)
Acceptor-->>Proposer: Accepted(n, v)
Acceptor-->>Learner: Learn(v) (accepted value)
Learner-->>Proposer: Acknowledged
```TODO
- [ ] auto format on pre-commit
- [ ] set up sqlite database
- [ ] handle `Lagged` error in broadcast. Congestion window?
- [ ] store node ids (in case some node dies, etc)
- [ ] decouple code
- [ ] allow more learners
- [ ] allow more proposers
- [ ] remove `expect`s and `unwrap`s and improve code in general
- [ ] use a generic interface to allow nodes to rotate positions, so that for each "round" nodes can be assigned different roles instead of fixed acceptors and proposers. Idk about learners
- [ ] distributed fibonacci