From ce5f704dd57e4d195c1120b4591ed7128eac0cce Mon Sep 17 00:00:00 2001 From: Andronik Ordian Date: Tue, 8 Jan 2019 13:14:59 +0300 Subject: [PATCH] finality: dont require chain head to be in the chain (#10054) --- ethcore/src/engines/authority_round/mod.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ethcore/src/engines/authority_round/mod.rs b/ethcore/src/engines/authority_round/mod.rs index d1f314aa1..1404e58fe 100644 --- a/ethcore/src/engines/authority_round/mod.rs +++ b/ethcore/src/engines/authority_round/mod.rs @@ -1422,16 +1422,21 @@ impl Engine for AuthorityRound { let mut finality_proof: Vec<_> = itertools::repeat_call(move || { chain(hash).and_then(|header| { hash = *header.parent_hash(); - if header.number() == 0 { return None } - else { return Some(header) } + if header.number() == 0 { None } + else { Some(header) } }) }) .while_some() .take_while(|h| h.hash() != *finalized_hash) .collect(); - let finalized_header = chain(*finalized_hash) - .expect("header is finalized; finalized headers must exist in the chain; qed"); + let finalized_header = if *finalized_hash == chain_head.hash() { + // chain closure only stores ancestry, but the chain head is also unfinalized. + chain_head.clone() + } else { + chain(*finalized_hash) + .expect("header is finalized; finalized headers must exist in the chain; qed") + }; let signal_number = finalized_header.number(); info!(target: "engine", "Applying validator set change signalled at block {}", signal_number);