- Overview
- System Architecture
- Key Features
- Technologies Used
- Getting Started
- API Documentation
- Security Measures
- Testing
- Performance Considerations
- Future Enhancements
- License
This project implements a robust and scalable Proof-of-Work (PoW) blockchain consensus system. It demonstrates a decentralized, secure, and consistent blockchain ledger maintained through the collaboration of multiple system components: Users, Miners, and Trackers.
The system showcases core blockchain concepts including distributed consensus, cryptographic signing, and resistance to various attack vectors. It's designed with modularity and extensibility in mind, making it an excellent starting point for blockchain-based applications or educational purposes.
Our PoW Blockchain Consensus System consists of three main components:
- User: Interacts with the blockchain to read the current state and submit new content.
- Miner: Participates in block mining, and transaction validation, and maintains network consensus.
- Tracker: Maintains system integrity and facilitates miner discovery.
- Users submit content via HTTP requests to Miners.
- Miners broadcast received content to peers and participate in the mining process.
- Upon successful mining, the network broadcasts and validates blocks.
- Miners can register with the Tracker to join the network and discover peers.
- Decentralized consensus through Proof-of-Work
- Cryptographic signing of transactions
- Dynamic miner discovery and registration
- Concurrent processing of transactions
- Resilience against network partitions and malicious actors
- Comprehensive test suite simulating various scenarios including attacks
- Go (Golang): Primary programming language
- Gin Web Framework: Lightweight HTTP routing
- RSA Cryptography: For digital signatures
- SHA-256: For hashing operations
- Treeset: Efficient sorted set implementation
- Go 1.15+
- Git
- Clone the repository:
git clone https://github.com/AllenJWZhu/Distributed-PoW-based-Fault-Tolerant-Blockchain-System.git
- Navigate to the project directory:
cd ../Distributed-PoW-based-Fault-Tolerant-Blockchain-System
- Install dependencies:
go mod tidy
Execute the comprehensive test suite:
make test
Note: Test success is dependent on your system's computing power. Adjust the target difficulty if needed.
- Endpoint:
/get_miners
- Method: GET
- Response: List of active miner ports
- Endpoint:
/register
- Method: POST
- Body:
{"port": <miner_port>}
- Response: Updated list of active miner ports
- Endpoint:
/read
- Method: GET
- Response: Current blockchain state
- Endpoint:
/write
- Method: POST
- Body:
{"user": "<public_key>", "content": "<message>", "timestamp": "<timestamp>", "signature": "<signature>"}
- Endpoint:
/sync
- Method: POST
- Body: List of posts to sync
- Endpoint:
/broadcast
- Method: POST
- Body: Updated blockchain
- RSA key pair generation for user identification
- Digital signatures for post verification
- SHA-256 hashing for block integrity
- Proof-of-Work consensus to prevent Sybil attacks
- Periodic heartbeats to maintain network integrity
Our comprehensive test suite covers:
- Post and block safety
- Malicious user and miner scenarios
- Miner discovery and registration
- Complete system interactions
- Blockchain resilience to network partitions
- Simulated computing power attacks
- Adjustable mining difficulty (TARGET constant)
- Configurable posts per block (PostsPerBlock constant)
- Tunable heartbeat and sync intervals for network optimization
- Implement sharding for improved scalability
- Add support for smart contracts
- Introduce a native cryptocurrency and mining rewards
- Implement a peer-to-peer network layer for direct miner communication
This project is licensed under the MIT License - see the LICENSE file for details.