Skip to content

Commit

Permalink
Merge pull request #2530 from EspressoSystems/keyao/add-genesis-decide
Browse files Browse the repository at this point in the history
[VALIDATED_STATE] - Send Decide event for the genesis block
  • Loading branch information
shenkeyao authored Feb 7, 2024
2 parents 0eac853 + 111c4ad commit 3f4f488
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
25 changes: 23 additions & 2 deletions crates/task-impls/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,30 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, A: ConsensusApi<TYPES, I> +

let consensus = self.consensus.upgradable_read().await;

// Construct the leaf.
// Get the parent leaf.
let parent = if justify_qc.is_genesis {
self.genesis_leaf().await
// Send the `Decide` event for the genesis block if the justify QC is genesis.
let leaf = self.genesis_leaf().await;
match leaf {
Some(ref leaf) => {
self.output_event_stream
.publish(Event {
view_number: TYPES::Time::genesis(),
event: EventType::Decide {
leaf_chain: Arc::new(vec![leaf.clone()]),
qc: Arc::new(justify_qc.clone()),
block_size: None,
},
})
.await;
}
None => {
error!(
"Failed to find the genesis leaf while the justify QC is genesis."
);
}
}
leaf
} else {
consensus
.saved_leaves
Expand Down
6 changes: 5 additions & 1 deletion 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 @@ -445,6 +445,10 @@ impl OverallSafetyPropertiesDescription {
qc,
block_size: maybe_block_size,
} => {
// Skip the genesis leaf.
if leaf_chain.len() == 1 && leaf_chain[0].get_view_number() == TYPES::Time::genesis() {
return (None, state);
}
let paired_up = (leaf_chain.to_vec(), (*qc).clone());
match state.ctx.round_results.entry(view_number) {
Entry::Occupied(mut o) => o.get_mut().insert_into_result(
Expand Down

0 comments on commit 3f4f488

Please sign in to comment.