From 45d17beb8eacd4334fb6f403978abc5663868c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 28 Jul 2020 20:39:32 +0200 Subject: [PATCH] Use the correct `TaskExecutor` in validation (#1489) --- polkadot/network/src/protocol/mod.rs | 10 ++++++---- polkadot/validation/src/shared_table/mod.rs | 11 +++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/polkadot/network/src/protocol/mod.rs b/polkadot/network/src/protocol/mod.rs index 22e72dcfd6..6dfef09da8 100644 --- a/polkadot/network/src/protocol/mod.rs +++ b/polkadot/network/src/protocol/mod.rs @@ -222,7 +222,7 @@ pub fn start( C: ChainContext + 'static, Api: ProvideRuntimeApi + Send + Sync + 'static, Api::Api: ParachainHost, - SP: SpawnNamed + Clone + Send + 'static, + SP: SpawnNamed + Clone + Send + Unpin + 'static, { const SERVICE_TO_WORKER_BUF: usize = 256; @@ -830,7 +830,7 @@ struct Worker { impl Worker where Api: ProvideRuntimeApi + Send + Sync + 'static, Api::Api: ParachainHost, - Sp: SpawnNamed + Clone, + Sp: SpawnNamed + Clone + Unpin + 'static, Gossip: GossipOps, { // spawns a background task to spawn consensus networking. @@ -882,6 +882,7 @@ impl Worker where self.gossip_handle.clone(), self.background_to_main_sender.clone(), exit, + self.executor.clone(), ).boxed(), ); } @@ -1062,7 +1063,7 @@ async fn worker_loop( ) where Api: ProvideRuntimeApi + Send + Sync + 'static, Api::Api: ParachainHost, - Sp: SpawnNamed + Clone, + Sp: SpawnNamed + Clone + Unpin + 'static, { const BACKGROUND_TO_MAIN_BUF: usize = 16; @@ -1149,6 +1150,7 @@ async fn statement_import_loop( gossip_handle: impl GossipOps, mut to_worker: mpsc::Sender, mut exit: exit_future::Exit, + spawner: impl SpawnNamed + Clone + Unpin + 'static, ) where Api: ProvideRuntimeApi + Send + Sync + 'static, Api::Api: ParachainHost, @@ -1221,7 +1223,7 @@ async fn statement_import_loop( let table = table.clone(); let gossip_handle = gossip_handle.clone(); - let work = producer.prime(api.clone()).validate().map(move |res| { + let work = producer.prime(api.clone(), spawner.clone()).validate().map(move |res| { let validated = match res { Err(e) => { debug!(target: "p_net", "Failed to act on statement: {}", e); diff --git a/polkadot/validation/src/shared_table/mod.rs b/polkadot/validation/src/shared_table/mod.rs index 58cc56cb7f..1e77c21b38 100644 --- a/polkadot/validation/src/shared_table/mod.rs +++ b/polkadot/validation/src/shared_table/mod.rs @@ -37,7 +37,7 @@ use bitvec::bitvec; use super::GroupInfo; use self::includable::IncludabilitySender; -use primitives::Pair; +use primitives::{Pair, traits::SpawnNamed}; use sp_api::ProvideRuntimeApi; use crate::pipeline::{FullOutput, ValidationPool}; @@ -287,8 +287,11 @@ pub struct ParachainWork { impl ParachainWork { /// Prime the parachain work with an API reference for extracting /// chain information. - pub fn prime>(self, api: Arc

) - -> PrimedParachainWork< + pub fn prime>( + self, + api: Arc

, + spawner: impl SpawnNamed + Clone + Unpin + 'static, + ) -> PrimedParachainWork< Fetch, impl Send + FnMut(&PoVBlock, &AbridgedCandidateReceipt) -> Result + Unpin, @@ -312,7 +315,7 @@ impl ParachainWork { &expected_relay_parent, max_block_data_size, n_validators, - primitives::testing::TaskExecutor::new(), + spawner.clone(), )?; full_output.check_consistency(candidate)?;