Skip to content

Commit

Permalink
Skip genesis leaf in safety task checks
Browse files Browse the repository at this point in the history
  • Loading branch information
shenkeyao committed Feb 6, 2024
1 parent 94d1e3e commit 886bd1a
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions crates/testing/src/overall_safety_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use hotshot_types::{
error::RoundTimedoutState,
event::{Event, EventType},
simple_certificate::QuorumCertificate,
traits::node_implementation::NodeType,
traits::node_implementation::{ConsensusTime, NodeType},
};
use snafu::Snafu;
use std::{
Expand Down Expand Up @@ -192,12 +192,15 @@ impl<TYPES: NodeType> RoundResult<TYPES> {

let maybe_leaf: Option<Leaf<TYPES>> = result.0.into_iter().last();
if let Some(leaf) = maybe_leaf.clone() {
match self.leaf_map.entry(leaf.clone()) {
std::collections::hash_map::Entry::Occupied(mut o) => {
*o.get_mut() += 1;
}
std::collections::hash_map::Entry::Vacant(v) => {
v.insert(1);
// Skip the genesis leaf.
if leaf.get_view_number() != TYPES::Time::genesis() {
match self.leaf_map.entry(leaf.clone()) {
std::collections::hash_map::Entry::Occupied(mut o) => {
*o.get_mut() += 1;
}
std::collections::hash_map::Entry::Vacant(v) => {
v.insert(1);
}
}
}

Expand Down Expand Up @@ -246,6 +249,11 @@ impl<TYPES: NodeType> RoundResult<TYPES> {
check_block: bool,
transaction_threshold: u64,
) {
// Skip for the genesis leaf.
if key.get_view_number() == TYPES::Time::genesis() {
return;
}

let num_decided = self.success_nodes.len();
let num_failed = self.failed_nodes.len();
let remaining_nodes = total_num_nodes - (num_decided + num_failed);
Expand Down

0 comments on commit 886bd1a

Please sign in to comment.