A toy blockchain based on the exercises from the course "Distributed Systems and Security" from Aarhus University. This repo aims at implementing the exercises in Rust as opposed to Go as was used in the course.
For detailed information about each exercise, please refer to the task description.
- Exercise A
- Exercise B
- Exercise C (Has bugs 😞)
- Exercise D (May skip, not too connected to E)
- Exercise E
In this exercise, you will implement a simple peer-to-peer network that functions as a distributed chat room. The key features include:
- Command Line Interface: The chat client runs as a command-line program.
- Peer Connection: Upon startup, the client requests the IP address and port of an existing peer. If the peer is not found, it starts its own network.
- Client Details: The client prints its IP address and port for incoming connections.
- Messaging: The client prompts the user for text strings. When a string is typed, it is broadcast to all connected clients.
- Message Handling: The system ensures that messages are printed at all clients without revealing the sender's information.
This exercise extends the previous chat system into a distributed ledger with the following features:
- Ledger Management: Each client maintains a ledger that tracks accounts and balances.
- Transactions: Clients can make transactions, and all peers update their ledgers accordingly.
- Eventual Consistency: The system ensures that if all clients stop sending transactions, all ledgers will eventually converge to the same state.
- Peer Connections: Clients connect to a list of peers and forward transactions to maintain ledger consistency.
Enhance the ledger system with signed transactions:
- Signed Transactions: Transactions are now signed with RSA keys, ensuring only account owners can authorize transactions.
- Validation: Transactions are validated based on their signature and non-negative amounts.
- RSA Integration: Encode and decode RSA public keys for transaction processing.
Modify the system to achieve total order for transactions:
- Sequencer Role: A designated sequencer establishes the order of transactions.
- Block Creation: The sequencer creates blocks containing transaction IDs and signs them.
- Order Enforcement: Clients process transactions based on the sequencer's block order.
Implement a proof-of-stake based blockchain with total order:
- Genesis Block: Includes special public keys with initial balances.
- Proof-of-Stake: A tree-based blockchain where block creation is based on the stake (account balance).
- Transaction Fees: Implement transaction fees and rewards for block creators.
- Testing: Validate the system's performance, including handling invalid transactions, rollbacks, and resistance to malicious peers.
To get started with this project:
-
Clone the Repository:
git clone https://github.com/rasmus-kirk/p2p cd p2p
-
Build the Project: Ensure you have Rust installed and use Cargo to build the project.
cargo build
-
Run the Client: Execute the command-line client to start interacting with the peer-to-peer network.
cargo run
Unit Tests: Run the unit test suite:
cargo test