diff --git a/README.md b/README.md index 0a70d547..0f978745 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ More details are available [in the book][reference-link-implementation-details]. - Import AlephBFT in your crate ```toml [dependencies] - aleph-bft = "^0.40" + aleph-bft = "^0.41" ``` - The main entry point is the `run_session` function, which returns a Future that runs the consensus algorithm. diff --git a/consensus/src/backup/loader.rs b/consensus/src/backup/loader.rs index c52618a6..a2cf339f 100644 --- a/consensus/src/backup/loader.rs +++ b/consensus/src/backup/loader.rs @@ -111,11 +111,8 @@ impl BackupLoader { )); } - let parent_ids = &full_unit.as_pre_unit().control_hash().parents; - // Sanity check: verify that all unit's parents appeared in backup before it. - for (parent_id, round) in parent_ids.iter() { - let parent = UnitCoord::new(*round, parent_id); + for parent in full_unit.as_pre_unit().control_hash().parents() { if !already_loaded_coords.contains(&parent) { return Err(LoaderError::InconsistentData(coord)); } diff --git a/consensus/src/units/mod.rs b/consensus/src/units/mod.rs index 04dbb507..1acba579 100644 --- a/consensus/src/units/mod.rs +++ b/consensus/src/units/mod.rs @@ -61,21 +61,19 @@ pub struct ControlHash { } impl ControlHash { - pub(crate) fn new(parents_round_lookup: &NodeMap<(H::Hash, Round)>) -> Self { - let mut parents_round_map = NodeMap::with_size(parents_round_lookup.size()); - for (parent_index, (_, parent_round)) in parents_round_lookup.iter() { - parents_round_map.insert(parent_index, *parent_round); + pub(crate) fn new(parents_with_rounds_and_hashes: &NodeMap<(H::Hash, Round)>) -> Self { + let mut parents_with_rounds = NodeMap::with_size(parents_with_rounds_and_hashes.size()); + for (parent_index, (_, parent_round)) in parents_with_rounds_and_hashes.iter() { + parents_with_rounds.insert(parent_index, *parent_round); } ControlHash { - parents: parents_round_map, - combined_hash: Self::create_control_hash(parents_round_lookup), + parents: parents_with_rounds, + combined_hash: Self::create_control_hash(parents_with_rounds_and_hashes), } } - /// Calculate parent control hash, which includes all parent hashes into account. + /// Calculate parent control hash, which includes all parent hashes and their rounds into account. pub(crate) fn create_control_hash(parent_map: &NodeMap<(H::Hash, Round)>) -> H::Hash { - // we include parent rounds with calculating hash but this is okay - we cannot - // have two units with the same hash but different rounds parent_map.using_encoded(H::hash) }