Use block header for building finality (#9914)

This commit is contained in:
Nicolas Gotchac 2018-11-14 13:05:49 +01:00 committed by Thibaut Sardan
parent 052380b8de
commit ac974a180d
3 changed files with 9 additions and 7 deletions

View File

@ -481,7 +481,7 @@ impl Importer {
let mut batch = DBTransaction::new();
let ancestry_actions = self.engine.ancestry_actions(&block, &mut chain.ancestry_with_metadata_iter(*parent));
let ancestry_actions = self.engine.ancestry_actions(&header, &mut chain.ancestry_with_metadata_iter(*parent));
let receipts = block.receipts;
let traces = block.traces.drain();

View File

@ -798,6 +798,7 @@ impl AuthorityRound {
}
};
let epoch_transition_hash = epoch_manager.epoch_transition_hash;
let ancestry_iter = ancestry.map(|header| {
let mut signers = vec![*header.author()];
signers.extend(parent_empty_steps_signers.drain(..));
@ -815,10 +816,11 @@ impl AuthorityRound {
None
}
})
.while_some();
.while_some()
.take_while(|&(h, _)| h != epoch_transition_hash);
if let Err(_) = epoch_manager.finality_checker.build_ancestry_subchain(ancestry_iter) {
debug!(target: "engine", "inconsistent validator set within epoch");
if let Err(e) = epoch_manager.finality_checker.build_ancestry_subchain(ancestry_iter) {
debug!(target: "engine", "inconsistent validator set within epoch: {:?}", e);
return Vec::new();
}
}
@ -1448,9 +1450,9 @@ impl Engine<EthereumMachine> for AuthorityRound {
super::total_difficulty_fork_choice(new, current)
}
fn ancestry_actions(&self, block: &ExecutedBlock, ancestry: &mut Iterator<Item=ExtendedHeader>) -> Vec<AncestryAction> {
fn ancestry_actions(&self, header: &Header, ancestry: &mut Iterator<Item=ExtendedHeader>) -> Vec<AncestryAction> {
let finalized = self.build_finality(
block.header(),
header,
&mut ancestry.take_while(|e| !e.is_finalized).map(|e| e.header),
);

View File

@ -429,7 +429,7 @@ pub trait Engine<M: Machine>: Sync + Send {
/// Gather all ancestry actions. Called at the last stage when a block is committed. The Engine must guarantee that
/// the ancestry exists.
fn ancestry_actions(&self, _block: &M::LiveBlock, _ancestry: &mut Iterator<Item=M::ExtendedHeader>) -> Vec<AncestryAction> {
fn ancestry_actions(&self, _header: &M::Header, _ancestry: &mut Iterator<Item=M::ExtendedHeader>) -> Vec<AncestryAction> {
Vec::new()
}