Fix handling of justifications (#2086)

* util: fork-tree: check predicate first while traversing tree

* core: sync: keep track of justifications sent to the import queue

* core: grandpa: verify authority set changes dependencies

* core: fork-tree: add more tests

* core: grandpa: extend enacts_standard_change tests
This commit is contained in:
André Silva
2019-03-22 19:07:24 +01:00
committed by Arkadiy Paronyan
parent 7469713dea
commit 25ec793e35
5 changed files with 204 additions and 49 deletions
@@ -358,17 +358,18 @@ impl<B: BlockT> BlockImporter<B> {
let success = self.justification_import.as_ref().map(|justification_import| {
justification_import.import_justification(hash, number, justification)
.map_err(|e| {
debug!("Justification import failed with {:?} for hash: {:?} number: {:?} coming from node: {:?}", e, hash, number, who);
debug!(target: "sync", "Justification import failed with {:?} for hash: {:?} number: {:?} coming from node: {:?}", e, hash, number, who);
e
}).is_ok()
}).unwrap_or(false);
if let Some(link) = self.link.as_ref() {
link.justification_imported(who, &hash, number, success);
}
}
fn handle_import_blocks(&mut self, origin: BlockOrigin, blocks: Vec<IncomingBlock<B>>) {
trace!(target:"sync", "Scheduling {} blocks for import", blocks.len());
trace!(target: "sync", "Scheduling {} blocks for import", blocks.len());
self.worker_sender
.send(BlockImportWorkerMsg::ImportBlocks(origin, blocks))
.expect("1. This is holding a sender to the worker, 2. the worker should not quit while a sender is still held; qed");
@@ -423,7 +424,7 @@ impl<B: BlockT, V: 'static + Verifier<B>> BlockImportWorker<B, V> {
_ => Default::default(),
};
trace!(target:"sync", "Starting import of {} blocks {}", count, blocks_range);
trace!(target: "sync", "Starting import of {} blocks {}", count, blocks_range);
let mut results = vec![];