Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Use block header for building finality (#9914)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngotchac authored and Tbaut committed Nov 14, 2018
1 parent 052380b commit ac974a1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 7 additions & 5 deletions ethcore/src/engines/authority_round/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(..));
Expand All @@ -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();
}
}
Expand Down Expand Up @@ -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),
);

Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/engines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down

0 comments on commit ac974a1

Please sign in to comment.