From 45d17beb8eacd4334fb6f403978abc5663868c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= <bkchr@users.noreply.github.com> 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 22e72dcfd6e..6dfef09da8b 100644 --- a/polkadot/network/src/protocol/mod.rs +++ b/polkadot/network/src/protocol/mod.rs @@ -222,7 +222,7 @@ pub fn start<C, Api, SP>( C: ChainContext + 'static, Api: ProvideRuntimeApi<Block> + Send + Sync + 'static, Api::Api: ParachainHost<Block, Error = sp_blockchain::Error>, - SP: SpawnNamed + Clone + Send + 'static, + SP: SpawnNamed + Clone + Send + Unpin + 'static, { const SERVICE_TO_WORKER_BUF: usize = 256; @@ -830,7 +830,7 @@ struct Worker<Api, Sp, Gossip> { impl<Api, Sp, Gossip> Worker<Api, Sp, Gossip> where Api: ProvideRuntimeApi<Block> + Send + Sync + 'static, Api::Api: ParachainHost<Block, Error = sp_blockchain::Error>, - Sp: SpawnNamed + Clone, + Sp: SpawnNamed + Clone + Unpin + 'static, Gossip: GossipOps, { // spawns a background task to spawn consensus networking. @@ -882,6 +882,7 @@ impl<Api, Sp, Gossip> Worker<Api, Sp, Gossip> where self.gossip_handle.clone(), self.background_to_main_sender.clone(), exit, + self.executor.clone(), ).boxed(), ); } @@ -1062,7 +1063,7 @@ async fn worker_loop<Api, Sp>( ) where Api: ProvideRuntimeApi<Block> + Send + Sync + 'static, Api::Api: ParachainHost<Block, Error = sp_blockchain::Error>, - Sp: SpawnNamed + Clone, + Sp: SpawnNamed + Clone + Unpin + 'static, { const BACKGROUND_TO_MAIN_BUF: usize = 16; @@ -1149,6 +1150,7 @@ async fn statement_import_loop<Api>( gossip_handle: impl GossipOps, mut to_worker: mpsc::Sender<BackgroundToWorkerMsg>, mut exit: exit_future::Exit, + spawner: impl SpawnNamed + Clone + Unpin + 'static, ) where Api: ProvideRuntimeApi<Block> + Send + Sync + 'static, Api::Api: ParachainHost<Block, Error = sp_blockchain::Error>, @@ -1221,7 +1223,7 @@ async fn statement_import_loop<Api>( 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 58cc56cb7fe..1e77c21b38c 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<Fetch> { impl<Fetch: Future + Unpin> ParachainWork<Fetch> { /// Prime the parachain work with an API reference for extracting /// chain information. - pub fn prime<P: ProvideRuntimeApi<Block>>(self, api: Arc<P>) - -> PrimedParachainWork< + pub fn prime<P: ProvideRuntimeApi<Block>>( + self, + api: Arc<P>, + spawner: impl SpawnNamed + Clone + Unpin + 'static, + ) -> PrimedParachainWork< Fetch, impl Send + FnMut(&PoVBlock, &AbridgedCandidateReceipt) -> Result<FullOutput, Error> + Unpin, @@ -312,7 +315,7 @@ impl<Fetch: Future + Unpin> ParachainWork<Fetch> { &expected_relay_parent, max_block_data_size, n_validators, - primitives::testing::TaskExecutor::new(), + spawner.clone(), )?; full_output.check_consistency(candidate)?; -- GitLab