MinBFT
MinBFT is a Rust implementation based on the equally named Byzantine fault-tolerant
consensus algorithm presented in the paper Efficient Byzantine Fault-Tolerance.
MinBFT requires a Unique Sequential Identifier Generator (USIG) implementation.
A USIG implementation compatible with this MinBFT implementation can be found
here.
Note that this implementation does not use Trusted Execution Environments and,
thus, should not be used in untrusted environments.
This implementation was created as part of the ABCperf project.
An integration in ABCperf also exists.
MinBFT in Action
use anyhow::Result;
use std::{num::NonZeroU64, time::Duration};
use serde::{Deserialize, Serialize};
use shared_ids::{ReplicaId, ClientId, RequestId};
use usig::{Usig, noop::UsigNoOp};
use minbft::{MinBft, Config, Output, RequestPayload, PeerMessage, timeout::{TimeoutType}};
#[derive(Deserialize, Serialize, Clone, Debug, Eq, PartialEq)]
struct SamplePayload {}
impl RequestPayload for SamplePayload {
fn id(&self) -> RequestId {
todo!()
}
fn verify(&self, id: ClientId) -> Result<()> {
todo!()
}
}
fn handle_output<U: Usig>(output: Output<SamplePayload, U>) {
let Output { broadcasts, responses, timeout_requests, .. } = output;
for broadcast in broadcasts.iter() {
todo!();
}
for response in responses.iter() {
todo!();
}
for timeout_request in timeout_requests.iter() {
todo!();
}
}
fn main() {
let n = NonZeroU64::new(10).unwrap();
let t = n.get() / 2;
let replica_id = ReplicaId::from_u64(0);
let config = Config {
n: n.try_into().unwrap(),
t,
id: replica_id,
max_batch_size: Some(1.try_into().expect("> 0")),
batch_timeout: Duration::from_secs(1),
initial_timeout_duration: Duration::from_secs(1),
checkpoint_period: NonZeroU64::new(2).unwrap(),
};
let usig = UsigNoOp::default();
let (mut minbft, output) = MinBft::<SamplePayload, _>::new(
usig,
config,
)
.unwrap();
handle_output(output);
let some_client_message: SamplePayload = todo!();
let output = minbft.handle_client_message(ClientId::from_u64(0), some_client_message);
handle_output(output);
}
Contact
Feel free to reach out via GitHub,
matrix, or mail.
License
Licensed under MIT license.