- Information
- Requirements
- How-to Test
- Notes
This is a modified version of PBFT consensus algorithm [1]. PBFT was designed as a method to solve the Byzantine General's Problem [2] in a distributed system. This methode is designed to optimize the resourse usage and reduce network latency.
There are a few types of byzantine faults:-
- Failure to return a result
- Respond with the wrong or misleading result
- Respond with varying results to different nodes in the system
The faults are simplified into two, offline (failure to return a result) and malicious/falsifying (responding with a wrong result or giving varying results to different nodes). For the sake of simplicity, the normal malicious nodes and commander malicious nodes have separate behaviour. The normal malicious node will respond with the wrong result, while the commander malicious node will respond with varying results to different system nodes.
- Python >= 3.11.1
- Aiohttp >= 3.8.5
- curl >= 7.81.0
Run python main.py
to establish the nodes within the network.
Example
C:\practical-byzantine-fault-tolerance> python ./CCRO/main.py
C:\practical-byzantine-fault-tolerance> python ./PBFT/main.py
Total Nodes: 4 -> [0, 1, 2, 3]
Byzantine Nodes: 1 -> [2]
Commander Node: 1 -> 0
Communication Node: 1
Starting Nodes
Node 0 started on http://0.0.0.0:8080
Node 1 started on http://0.0.0.0:8081
Node 2 started on http://0.0.0.0:8082
Node 3 started on http://0.0.0.0:8083
Node 0 is the commander node.
Running on http://0.0.0.0:8080
This output shows the number of nodes within the system, which nodes are byzantine and which are commander, the URL for each node, and the commander node's URL.
You can test each node's status by using the endpoint /status
with curl to see if it is online or offline such as follows: curl http://localhost:8080
Finally, to initiate the consensus send a POST request with a JSON file containing
sample file ( sample run case.txt
) is prodided for the same.
{"data": "anything-here-doesnt-matter"}
to the commander node's URL with the endpoint /preprepare
. The following command can be used to test the commander node: curl -X POST -H "Content-Type: application/json" -d '{"data": "very-important-data"}' http://localhost:{commander port}/preprepare
. Please change the commander port as necessary.
Once consensus is reached, the execution time of the algorithm will be outputted along with the results replies from the nodes.
Example
PBFT Consensus Time: 0.050912s
Node 0 -> 4 Correct 3 Corrupt
Node 1 -> 5 Correct 2 Corrupt
Node 2 -> 5 Correct 2 Corrupt
Node 3 -> 4 Correct 2 Corrupt
Things to note.
- This is a simple implementation of the consensus model.
- To change the number of byzantine nodes or the type of byzantine nodes existing within the system must be changed manually.
- Maximum 30 byzantine nodes for offline, and 20 for malicious as the error
OSError: [Errno 24] Too many open files
will be raised. (PS: I've changed my ulimit to 1040000). Results may be different. - Results for the execution time were from testing on a Linux OS.
Khobragade Atul Yashwant (B20CS027),Anirudh Bajaj (B20CS005), Diksha Jena (B20CS013), R. Amshu Naik (B20CS046), Seema (B20CS064), Tanisha Jain (B20CS093)