Skip to content

Commit ffbd2b5

Browse files
committed
add docs on how to implement new protocols
1 parent b39da3d commit ffbd2b5

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

README.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ This is a Gradle monorepo that contains the following modules:
77
- `simulator`: The core benchmarking suite. Currently also includes the protocol implementations.
88
- `webui`: A web interface for the benchmarking suite.
99

10-
```
11-
TODO restructure project later into the following modules:
12-
- `byzzbench-core`: The core benchmarking suite
13-
- `byzzbench-webui`: A web interface for the benchmarking suite
14-
- `byzzbench-protocols`: Implementations of various BFT protocols
15-
```
16-
1710
## Prerequisites
1811

1912
For the benchmarking suite to work, you need to have the following installed on your system:
@@ -57,6 +50,10 @@ To run the web interface, run the following command:
5750

5851
The UI should then be available at http://localhost:3000.
5952

53+
## Documentation
54+
55+
- [Implementing new BFT Protocols](docs/implementing-protocols.md)
56+
6057
## Simulator Structure
6158

6259
```mermaid

docs/implementing-protocols.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Implementing new BFT Protocols
2+
3+
This document describes the steps to implement a new BFT protocol in ByzzBench.
4+
5+
A BFT Protocol implementation in ByzzBench consists of the following components:
6+
7+
- A protocol replica that *extends* `Replica<T>`: these are the nodes that run the protocol and communicate with each other
8+
via messages. `T` is the type of each of the entries in the commit log (this should be simplified!).
9+
- Example: [PBFT-Java Replica](../simulator/src/main/java/byzzbench/simulator/protocols/pbft_java/PbftReplica.java)
10+
- The `Replica` constructor requires a `replicaId`, `nodeIds` (set of all replica IDs in the *cluster*), `transport` (the virtualized network instance) and a `commitLog` (instance where all committed operations from the replica are sent to).
11+
- A set of protocol message POJOs that *implement* `MessagePayload`: these are the messages that are exchanged between replicas.
12+
- They just need to have a `String getType()` method that returns e.g. that it is a `PREPARE` message.
13+
- Examples from PBFT-Java: [Checkpoint](../simulator/src/main/java/byzzbench/simulator/protocols/pbft_java/message/CheckpointMessage.java), [Commit](../simulator/src/main/java/byzzbench/simulator/protocols/pbft_java/message/CommitMessage.java), [NewView](../simulator/src/main/java/byzzbench/simulator/protocols/pbft_java/message/NewViewMessage.java), [Phase](../simulator/src/main/java/byzzbench/simulator/protocols/pbft_java/message/PhaseMessage.java), [Prepare](../simulator/src/main/java/byzzbench/simulator/protocols/pbft_java/message/PrepareMessage.java), [PrePrepare](../simulator/src/main/java/byzzbench/simulator/protocols/pbft_java/message/PrePrepareMessage.java), [Reply](../simulator/src/main/java/byzzbench/simulator/protocols/pbft_java/message/ReplyMessage.java), [Request](../simulator/src/main/java/byzzbench/simulator/protocols/pbft_java/message/RequestMessage.java), [ViewChange](../simulator/src/main/java/byzzbench/simulator/protocols/pbft_java/message/ViewChangeMessage.java)
14+
15+
## Communication and Timeouts
16+
17+
Communication between replicas is done via message-passing through the `Transport`. The `Replica` superclass exposes a few methods:
18+
19+
- `sendMessage`: send a message to a recipient
20+
- `multicastMessage`: send a message to a set of replicas
21+
- `broadcastMessage`: send a message to every other replica
22+
- `broadcastMessageIncludingSelf`: send a message to every replica, including self
23+
24+
Timeouts are implemented via callbacks to a `Runnable`, also handled by the `Transport`:
25+
26+
- `setTimeout(Runnable, timeout)`: Creates a timeout event of `timeout` milliseconds, which will then invoke the `Runnable`. The time is currently being ignored, and is instead triggered just like any other event by the scheduler.
27+
- `clearAllTimeouts()`: Invalidates all outstanding timeouts for the current replica.
28+
29+
## Commit Log
30+
31+
Each replica has its own instance of a `CommitLog`: an immutable and total ordered sequence of records. This is used to check whether safety invariants of distributed consensus are broken.

0 commit comments

Comments
 (0)