Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
fix: vote for sibling knowledge after parsec reset
Browse files Browse the repository at this point in the history
otherwise the nodes being promoted can't vote yet and the votes would not accumulate.
  • Loading branch information
madadam authored and dirvine committed Jun 22, 2020
1 parent 94ebc7d commit 090663f
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions src/node/stage/approved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1427,11 +1427,12 @@ impl Approved {
fn update_our_section(&mut self, core: &mut Core, details: SectionUpdateDetails) -> Result<()> {
let old_prefix = *self.shared_state.our_prefix();
let was_elder = self.is_our_elder(core.id());
let sibling_prefix = details.sibling.as_ref().map(|sibling| sibling.key.value.0);

self.update_our_key_and_info(core, details.our.key, details.our.info)?;

if let Some(sibling) = details.sibling {
self.update_sibling_key(core, sibling.key);
self.shared_state.sections.update_keys(sibling.key);
self.update_neighbour_info(core, sibling.info);
}

Expand Down Expand Up @@ -1463,6 +1464,16 @@ impl Approved {
return Ok(());
}

// We can update the sibling knowledge already because we know they also reached consensus
// on our `OurKey` so they know our latest key. Need to vote for it first though, to
// accumulate the signatures.
if let Some(prefix) = sibling_prefix {
self.vote_for_event(AccumulatingEvent::TheirKnowledge {
prefix,
knowledge: self.shared_state.our_history.last_key_index(),
})
}

self.send_genesis_updates(core);
self.send_parsec_poke(core);

Expand Down Expand Up @@ -1515,24 +1526,6 @@ impl Approved {
self.prune_neighbour_connections(core, &neighbour_elders_removed);
}

fn update_sibling_key(
&mut self,
core: &Core,
section_key: Proven<(Prefix<XorName>, bls::PublicKey)>,
) {
// We can update their knowledge already because we know they also reached consensus on
// our `OurKey` so they know our latest key. Need to vote for it first though, to
// accumulate the signatures.
if self.is_our_elder(core.id()) {
self.vote_for_event(AccumulatingEvent::TheirKnowledge {
prefix: section_key.value.0,
knowledge: self.shared_state.our_history.last_key_index(),
})
}

self.shared_state.sections.update_keys(section_key);
}

////////////////////////////////////////////////////////////////////////////
// Parsec and Chain management
////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 090663f

Please sign in to comment.