From cfffad88668cfdebf632a59c4fbfada001ef8251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 19 Feb 2021 22:32:14 +0100 Subject: [PATCH] Hacks --- client/basic-authorship/src/basic_authorship.rs | 2 +- client/consensus/aura/src/lib.rs | 2 +- client/consensus/slots/src/lib.rs | 8 +++++--- frame/executive/src/lib.rs | 2 +- primitives/consensus/common/src/block_import.rs | 8 ++++++++ 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/client/basic-authorship/src/basic_authorship.rs b/client/basic-authorship/src/basic_authorship.rs index 067695e5a84da..78a107d0152d0 100644 --- a/client/basic-authorship/src/basic_authorship.rs +++ b/client/basic-authorship/src/basic_authorship.rs @@ -200,7 +200,7 @@ impl sp_consensus::Proposer for inherent_data, inherent_digests, deadline, - record_proof, + true.into(), ).await; if tx.send(res).is_err() { trace!("Could not send block production result to proposer!"); diff --git a/client/consensus/aura/src/lib.rs b/client/consensus/aura/src/lib.rs index ebf17deba7c73..2906c6867ea2e 100644 --- a/client/consensus/aura/src/lib.rs +++ b/client/consensus/aura/src/lib.rs @@ -172,7 +172,7 @@ pub fn start_aura( /// Build and return the aura worker. /// /// The caller is responsible for running the returned worker. -pub fn build_aura_worker( +pub fn build_aura_worker( client: Arc, block_import: I, env: E, diff --git a/client/consensus/slots/src/lib.rs b/client/consensus/slots/src/lib.rs index 6fce11b6c6ff0..8c05032a5530a 100644 --- a/client/consensus/slots/src/lib.rs +++ b/client/consensus/slots/src/lib.rs @@ -350,7 +350,7 @@ pub trait SimpleSlotWorker { proposal_work.and_then(move |(proposal, claim)| async move { let (block, storage_proof) = (proposal.block, proposal.proof); - let (header, body) = block.clone().deconstruct(); + let (header, body) = block.deconstruct(); let header_num = *header.number(); let header_hash = header.hash(); let parent_hash = *header.parent_hash(); @@ -358,7 +358,7 @@ pub trait SimpleSlotWorker { let block_import_params = block_import_params_maker( header, &header_hash, - body, + body.clone(), proposal.storage_changes, claim, epoch_data, @@ -378,6 +378,8 @@ pub trait SimpleSlotWorker { "hash_previously" => ?header_hash, ); + let post_header = block_import_params.post_header(); + if let Err(err) = block_import.lock().import_block(block_import_params, Default::default()) { warn!( target: logging_target, @@ -393,7 +395,7 @@ pub trait SimpleSlotWorker { ); } - Ok(SlotResult { block, storage_proof }) + Ok(SlotResult { block: B::new(post_header, body), storage_proof }) }).then(|r| async move { r.map_err(|e| warn!(target: "slots", "Encountered consensus error: {:?}", e)).ok() }).boxed() diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index df1ae17df613f..a2c395dcef6ab 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -309,7 +309,7 @@ where } // any final checks - Self::final_checks(&header); + // Self::final_checks(&header); } }; } diff --git a/primitives/consensus/common/src/block_import.rs b/primitives/consensus/common/src/block_import.rs index 41b5f391f65ca..ba108ebad6f44 100644 --- a/primitives/consensus/common/src/block_import.rs +++ b/primitives/consensus/common/src/block_import.rs @@ -206,6 +206,14 @@ impl BlockImportParams { } } + pub fn post_header(&self) -> Block::Header { + let mut hdr = self.header.clone(); + for digest_item in &self.post_digests { + hdr.digest_mut().push(digest_item.clone()); + } + hdr + } + /// Auxiliary function for "converting" the transaction type. /// /// Actually this just sets `storage_changes` to `None` and makes rustc think that `Self` now