Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ChonkyBFT types #209

Merged
merged 10 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions node/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node/actors/bft/src/leader/replica_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl StateMachine {
.retain(|view_number, _| active_views.contains(view_number));

// Now we check if we have enough weight to continue.
if weight < self.config.genesis().validators.threshold() {
if weight < self.config.genesis().validators.quorum_threshold() {
return Ok(());
};

Expand Down
2 changes: 1 addition & 1 deletion node/actors/bft/src/leader/replica_prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl StateMachine {
.retain(|view_number, _| active_views.contains(view_number));

// Now we check if we have enough weight to continue.
if weight < self.config.genesis().validators.threshold() {
if weight < self.config.genesis().validators.quorum_threshold() {
return Ok(());
}

Expand Down
2 changes: 1 addition & 1 deletion node/actors/bft/src/leader/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ async fn replica_prepare_different_messages() {

let mut replica_commit_result = None;
// The rest of the validators until threshold sign other_replica_prepare
for i in validators / 2..util.genesis().validators.threshold() as usize {
for i in validators / 2..util.genesis().validators.quorum_threshold() as usize {
replica_commit_result = util
.process_replica_prepare(ctx, util.keys[i].sign_msg(other_replica_prepare.clone()))
.await
Expand Down
4 changes: 2 additions & 2 deletions node/actors/bft/src/testonly/ut_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl UTHarness {
let res = self.process_replica_prepare(ctx, msg).await;
match (
(i + 1) as u64 * self.genesis().validators.iter().next().unwrap().weight
< self.genesis().validators.threshold(),
< self.genesis().validators.quorum_threshold(),
first_match,
) {
(true, _) => assert!(res.unwrap().is_none()),
Expand Down Expand Up @@ -256,7 +256,7 @@ impl UTHarness {
.process_replica_commit(ctx, key.sign_msg(msg.clone()));
match (
(i + 1) as u64 * self.genesis().validators.iter().next().unwrap().weight
< self.genesis().validators.threshold(),
< self.genesis().validators.quorum_threshold(),
first_match,
) {
(true, _) => res.unwrap(),
Expand Down
2 changes: 1 addition & 1 deletion node/actors/bft/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn run_test(behavior: Behavior, network: Network) {
let mut nodes = vec![(behavior, 1u64); NODES];
// validator::threshold(NODES) will calculate required nodes to validate a message
// given each node weight is 1
let honest_nodes_amount = validator::threshold(NODES as u64) as usize;
let honest_nodes_amount = validator::quorum_threshold(NODES as u64) as usize;
for n in &mut nodes[0..honest_nodes_amount] {
n.0 = Behavior::Honest;
}
Expand Down
50 changes: 31 additions & 19 deletions node/libs/roles/src/proto/validator/messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,57 +39,69 @@ message Block {
message View {
reserved 1,2;
reserved "protocol_version","fork";

optional GenesisHash genesis = 4; // required
optional uint64 number = 3; // required; ViewNumber
}

message ConsensusMsg {
oneof t {// required
ReplicaPrepare replica_prepare = 1;
reserved 1, 3, 4;
reserved "replica_prepare", "leader_prepare", "leader_commit";

oneof t { // required
ReplicaCommit replica_commit = 2;
LeaderPrepare leader_prepare = 3;
LeaderCommit leader_commit = 4;
ReplicaTimeout replica_timeout = 5;
pompon0 marked this conversation as resolved.
Show resolved Hide resolved
ReplicaNewView replica_new_view = 6;
LeaderProposal leader_proposal = 7;
}
}

message ReplicaPrepare {
message ReplicaCommit {
optional View view = 1; // required
optional BlockHeader proposal = 2; // required
}

message ReplicaTimeout {
optional View view = 1; // required
optional ReplicaCommit high_vote = 2; // optional
optional CommitQC high_qc = 3; // optional
}

message ReplicaCommit {
optional View view = 1; // required
optional BlockHeader proposal = 2; // required
message ReplicaNewView {
optional ProposalJustification justification = 1; // required
}

message LeaderPrepare {
message LeaderProposal {
optional BlockHeader proposal = 1; // required
optional bytes proposal_payload = 2; // optional (depending on justification)
optional PrepareQC justification = 3; // required
optional ProposalJustification justification = 3; // required
}

message LeaderCommit {
optional CommitQC justification = 1; // required
message CommitQC {
optional ReplicaCommit msg = 1; // required
optional std.BitVector signers = 2; // required
optional AggregateSignature sig = 3; // required
}

message PrepareQC {
message TimeoutQC {
optional View view = 4; // required
repeated ReplicaPrepare msgs = 1; // required
repeated ReplicaTimeout msgs = 1; // required
repeated std.BitVector signers = 2; // required
optional AggregateSignature sig = 3; // required
}

message CommitQC {
optional ReplicaCommit msg = 1; // required
optional std.BitVector signers = 2; // required
optional AggregateSignature sig = 3; // required
message ProposalJustification {
oneof t { // required
CommitQC commit_qc = 1;
TimeoutQC timeout_qc = 2;
}
}

message Phase {
oneof t {
oneof t { // required
std.Void prepare = 1;
std.Void commit = 2;
std.Void timeout = 3;
}
}

Expand Down
Loading
Loading