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

Commit ac974a1

Browse files
ngotchacTbaut
authored andcommitted
Use block header for building finality (#9914)
1 parent 052380b commit ac974a1

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

ethcore/src/client/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ impl Importer {
481481

482482
let mut batch = DBTransaction::new();
483483

484-
let ancestry_actions = self.engine.ancestry_actions(&block, &mut chain.ancestry_with_metadata_iter(*parent));
484+
let ancestry_actions = self.engine.ancestry_actions(&header, &mut chain.ancestry_with_metadata_iter(*parent));
485485

486486
let receipts = block.receipts;
487487
let traces = block.traces.drain();

ethcore/src/engines/authority_round/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ impl AuthorityRound {
798798
}
799799
};
800800

801+
let epoch_transition_hash = epoch_manager.epoch_transition_hash;
801802
let ancestry_iter = ancestry.map(|header| {
802803
let mut signers = vec![*header.author()];
803804
signers.extend(parent_empty_steps_signers.drain(..));
@@ -815,10 +816,11 @@ impl AuthorityRound {
815816
None
816817
}
817818
})
818-
.while_some();
819+
.while_some()
820+
.take_while(|&(h, _)| h != epoch_transition_hash);
819821

820-
if let Err(_) = epoch_manager.finality_checker.build_ancestry_subchain(ancestry_iter) {
821-
debug!(target: "engine", "inconsistent validator set within epoch");
822+
if let Err(e) = epoch_manager.finality_checker.build_ancestry_subchain(ancestry_iter) {
823+
debug!(target: "engine", "inconsistent validator set within epoch: {:?}", e);
822824
return Vec::new();
823825
}
824826
}
@@ -1448,9 +1450,9 @@ impl Engine<EthereumMachine> for AuthorityRound {
14481450
super::total_difficulty_fork_choice(new, current)
14491451
}
14501452

1451-
fn ancestry_actions(&self, block: &ExecutedBlock, ancestry: &mut Iterator<Item=ExtendedHeader>) -> Vec<AncestryAction> {
1453+
fn ancestry_actions(&self, header: &Header, ancestry: &mut Iterator<Item=ExtendedHeader>) -> Vec<AncestryAction> {
14521454
let finalized = self.build_finality(
1453-
block.header(),
1455+
header,
14541456
&mut ancestry.take_while(|e| !e.is_finalized).map(|e| e.header),
14551457
);
14561458

ethcore/src/engines/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ pub trait Engine<M: Machine>: Sync + Send {
429429

430430
/// Gather all ancestry actions. Called at the last stage when a block is committed. The Engine must guarantee that
431431
/// the ancestry exists.
432-
fn ancestry_actions(&self, _block: &M::LiveBlock, _ancestry: &mut Iterator<Item=M::ExtendedHeader>) -> Vec<AncestryAction> {
432+
fn ancestry_actions(&self, _header: &M::Header, _ancestry: &mut Iterator<Item=M::ExtendedHeader>) -> Vec<AncestryAction> {
433433
Vec::new()
434434
}
435435

0 commit comments

Comments
 (0)