Name all the tasks! (#6726)

* Remove any implementation of `Spawn` or `Executor` from our task executors

* Fix compilation

* Rename `SpawnBlockingExecutor`

* Update primitives/core/src/traits.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Fix tests

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
Bastian Köcher
2020-07-26 14:56:17 +02:00
committed by GitHub
parent 2ec131142b
commit 9310f15ac2
43 changed files with 280 additions and 280 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ pub use light::*;
pub use notifications::*;
pub use proof_provider::*;
pub use sp_state_machine::{StorageProof, ExecutionStrategy, CloneableSpawn};
pub use sp_state_machine::{StorageProof, ExecutionStrategy};
/// Usage Information Provider interface
///
@@ -358,7 +358,7 @@ mod tests {
fn should_cease_building_block_when_deadline_is_reached() {
// given
let client = Arc::new(substrate_test_runtime_client::new());
let spawner = sp_core::testing::SpawnBlockingExecutor::new();
let spawner = sp_core::testing::TaskExecutor::new();
let txpool = BasicPool::new_full(
Default::default(),
Arc::new(FullChainApi::new(client.clone(), None)),
@@ -412,7 +412,7 @@ mod tests {
#[test]
fn should_not_panic_when_deadline_is_reached() {
let client = Arc::new(substrate_test_runtime_client::new());
let spawner = sp_core::testing::SpawnBlockingExecutor::new();
let spawner = sp_core::testing::TaskExecutor::new();
let txpool = BasicPool::new_full(
Default::default(),
Arc::new(FullChainApi::new(client.clone(), None)),
@@ -448,7 +448,7 @@ mod tests {
fn proposed_storage_changes_should_match_execute_block_storage_changes() {
let (client, backend) = TestClientBuilder::new().build_with_backend();
let client = Arc::new(client);
let spawner = sp_core::testing::SpawnBlockingExecutor::new();
let spawner = sp_core::testing::TaskExecutor::new();
let txpool = BasicPool::new_full(
Default::default(),
Arc::new(FullChainApi::new(client.clone(), None)),
@@ -511,7 +511,7 @@ mod tests {
fn should_not_remove_invalid_transactions_when_skipping() {
// given
let mut client = Arc::new(substrate_test_runtime_client::new());
let spawner = sp_core::testing::SpawnBlockingExecutor::new();
let spawner = sp_core::testing::TaskExecutor::new();
let txpool = BasicPool::new_full(
Default::default(),
Arc::new(FullChainApi::new(client.clone(), None)),
+1 -1
View File
@@ -31,7 +31,7 @@
//! # };
//! # use sc_transaction_pool::{BasicPool, FullChainApi};
//! # let client = Arc::new(substrate_test_runtime_client::new());
//! # let spawner = sp_core::testing::SpawnBlockingExecutor::new();
//! # let spawner = sp_core::testing::TaskExecutor::new();
//! # let txpool = BasicPool::new_full(
//! # Default::default(),
//! # Arc::new(FullChainApi::new(client.clone(), None)),
@@ -220,7 +220,7 @@ mod tests {
let (client, select_chain) = builder.build_with_longest_chain();
let client = Arc::new(client);
let inherent_data_providers = InherentDataProviders::new();
let spawner = sp_core::testing::SpawnBlockingExecutor::new();
let spawner = sp_core::testing::TaskExecutor::new();
let pool = Arc::new(BasicPool::with_revalidation_type(
Options::default(), api(), None, RevalidationType::Full, spawner,
));
@@ -288,7 +288,7 @@ mod tests {
let (client, select_chain) = builder.build_with_longest_chain();
let client = Arc::new(client);
let inherent_data_providers = InherentDataProviders::new();
let spawner = sp_core::testing::SpawnBlockingExecutor::new();
let spawner = sp_core::testing::TaskExecutor::new();
let pool = Arc::new(BasicPool::with_revalidation_type(
Options::default(), api(), None, RevalidationType::Full, spawner,
));
@@ -360,7 +360,7 @@ mod tests {
let client = Arc::new(client);
let inherent_data_providers = InherentDataProviders::new();
let pool_api = api();
let spawner = sp_core::testing::SpawnBlockingExecutor::new();
let spawner = sp_core::testing::TaskExecutor::new();
let pool = Arc::new(BasicPool::with_revalidation_type(
Options::default(), pool_api.clone(), None, RevalidationType::Full, spawner,
));
+9 -6
View File
@@ -23,14 +23,17 @@ use std::{
};
use codec::{Encode, Decode};
use sp_core::{convert_hash, NativeOrEncoded, traits::CodeExecutor, offchain::storage::OffchainOverlayedChanges};
use sp_core::{
convert_hash, NativeOrEncoded, traits::{CodeExecutor, SpawnNamed},
offchain::storage::OffchainOverlayedChanges,
};
use sp_runtime::{
generic::BlockId, traits::{One, Block as BlockT, Header as HeaderT, HashFor},
};
use sp_externalities::Extensions;
use sp_state_machine::{
self, Backend as StateBackend, OverlayedChanges, ExecutionStrategy, create_proof_check_backend,
execution_proof_check_on_trie_backend, ExecutionManager, StorageProof, CloneableSpawn,
execution_proof_check_on_trie_backend, ExecutionManager, StorageProof,
};
use hash_db::Hasher;
@@ -220,7 +223,7 @@ pub fn prove_execution<Block, S, E>(
/// Proof should include both environment preparation proof and method execution proof.
pub fn check_execution_proof<Header, E, H>(
executor: &E,
spawn_handle: Box<dyn CloneableSpawn>,
spawn_handle: Box<dyn SpawnNamed>,
request: &RemoteCallRequest<Header>,
remote_proof: StorageProof,
) -> ClientResult<Vec<u8>>
@@ -251,7 +254,7 @@ pub fn check_execution_proof<Header, E, H>(
/// Proof should include both environment preparation proof and method execution proof.
pub fn check_execution_proof_with_make_header<Header, E, H, MakeNextHeader>(
executor: &E,
spawn_handle: Box<dyn CloneableSpawn>,
spawn_handle: Box<dyn SpawnNamed>,
request: &RemoteCallRequest<Header>,
remote_proof: StorageProof,
make_next_header: MakeNextHeader,
@@ -275,7 +278,7 @@ pub fn check_execution_proof_with_make_header<Header, E, H, MakeNextHeader>(
let backend_runtime_code = sp_state_machine::backend::BackendRuntimeCode::new(&trie_backend);
let runtime_code = backend_runtime_code.runtime_code()?;
execution_proof_check_on_trie_backend::<H, Header::Number, _>(
execution_proof_check_on_trie_backend::<H, Header::Number, _, _>(
&trie_backend,
&mut changes,
executor,
@@ -286,7 +289,7 @@ pub fn check_execution_proof_with_make_header<Header, E, H, MakeNextHeader>(
)?;
// execute method
execution_proof_check_on_trie_backend::<H, Header::Number, _>(
execution_proof_check_on_trie_backend::<H, Header::Number, _, _>(
&trie_backend,
&mut changes,
executor,
+9 -7
View File
@@ -24,8 +24,7 @@ use std::marker::PhantomData;
use hash_db::{HashDB, Hasher, EMPTY_PREFIX};
use codec::{Decode, Encode};
use sp_core::{convert_hash, traits::CodeExecutor};
use sp_core::storage::{ChildInfo, ChildType};
use sp_core::{convert_hash, traits::{CodeExecutor, SpawnNamed}, storage::{ChildInfo, ChildType}};
use sp_runtime::traits::{
Block as BlockT, Header as HeaderT, Hash, HashFor, NumberFor,
AtLeast32Bit, CheckedConversion,
@@ -33,7 +32,7 @@ use sp_runtime::traits::{
use sp_state_machine::{
ChangesTrieRootsStorage, ChangesTrieAnchorBlockId, ChangesTrieConfigurationRange,
InMemoryChangesTrieStorage, TrieBackend, read_proof_check, key_changes_proof_check_with_db,
read_child_proof_check, CloneableSpawn,
read_child_proof_check,
};
pub use sp_state_machine::StorageProof;
use sp_blockchain::{Error as ClientError, Result as ClientResult};
@@ -46,20 +45,23 @@ pub use sc_client_api::{
},
cht,
};
use crate::blockchain::Blockchain;
use crate::call_executor::check_execution_proof;
use crate::{blockchain::Blockchain, call_executor::check_execution_proof};
/// Remote data checker.
pub struct LightDataChecker<E, H, B: BlockT, S: BlockchainStorage<B>> {
blockchain: Arc<Blockchain<S>>,
executor: E,
spawn_handle: Box<dyn CloneableSpawn>,
spawn_handle: Box<dyn SpawnNamed>,
_hasher: PhantomData<(B, H)>,
}
impl<E, H, B: BlockT, S: BlockchainStorage<B>> LightDataChecker<E, H, B, S> {
/// Create new light data checker.
pub fn new(blockchain: Arc<Blockchain<S>>, executor: E, spawn_handle: Box<dyn CloneableSpawn>) -> Self {
pub fn new(
blockchain: Arc<Blockchain<S>>,
executor: E,
spawn_handle: Box<dyn SpawnNamed>,
) -> Self {
Self {
blockchain, executor, spawn_handle, _hasher: PhantomData
}
+2 -3
View File
@@ -19,9 +19,8 @@
//! Light client components.
use sp_runtime::traits::{Block as BlockT, HashFor};
use sc_client_api::CloneableSpawn;
use std::sync::Arc;
use sp_core::traits::CodeExecutor;
use sp_core::traits::{CodeExecutor, SpawnNamed};
pub mod backend;
pub mod blockchain;
@@ -34,7 +33,7 @@ pub use {backend::*, blockchain::*, call_executor::*, fetcher::*};
pub fn new_fetch_checker<E, B: BlockT, S: BlockchainStorage<B>>(
blockchain: Arc<Blockchain<S>>,
executor: E,
spawn_handle: Box<dyn CloneableSpawn>,
spawn_handle: Box<dyn SpawnNamed>,
) -> LightDataChecker<E, HashFor<B>, B, S>
where
E: CodeExecutor,
@@ -88,7 +88,7 @@ fn build_test_full_node(config: config::NetworkConfiguration)
Box::new(client.clone()),
None,
None,
&sp_core::testing::SpawnBlockingExecutor::new(),
&sp_core::testing::TaskExecutor::new(),
None,
));
@@ -98,7 +98,7 @@ fn import_single_good_block_without_header_fails() {
#[test]
fn async_import_queue_drops() {
let executor = sp_core::testing::SpawnBlockingExecutor::new();
let executor = sp_core::testing::TaskExecutor::new();
// Perform this test multiple times since it exhibits non-deterministic behavior.
for _ in 0..100 {
let verifier = PassThroughVerifier::new(true);
+2 -2
View File
@@ -648,7 +648,7 @@ pub trait TestNetFactory: Sized {
Box::new(block_import.clone()),
justification_import,
finality_proof_import,
&sp_core::testing::SpawnBlockingExecutor::new(),
&sp_core::testing::TaskExecutor::new(),
None,
));
@@ -728,7 +728,7 @@ pub trait TestNetFactory: Sized {
Box::new(block_import.clone()),
justification_import,
finality_proof_import,
&sp_core::testing::SpawnBlockingExecutor::new(),
&sp_core::testing::TaskExecutor::new(),
None,
));
+1 -1
View File
@@ -334,7 +334,7 @@ mod tests {
// Compare.
assert!(timestamp.unix_millis() > 0);
assert_eq!(timestamp.unix_millis(), d);
assert!(timestamp.unix_millis() >= d);
}
#[test]
+1 -1
View File
@@ -247,7 +247,7 @@ mod tests {
let _ = env_logger::try_init();
let client = Arc::new(substrate_test_runtime_client::new());
let spawner = sp_core::testing::SpawnBlockingExecutor::new();
let spawner = sp_core::testing::TaskExecutor::new();
let pool = TestPool(BasicPool::new_full(
Default::default(),
Arc::new(FullChainApi::new(client.clone(), None)),
+1 -1
View File
@@ -61,7 +61,7 @@ impl Default for TestSetup {
let client_builder = substrate_test_runtime_client::TestClientBuilder::new();
let client = Arc::new(client_builder.set_keystore(keystore.clone()).build());
let spawner = sp_core::testing::SpawnBlockingExecutor::new();
let spawner = sp_core::testing::TaskExecutor::new();
let pool = BasicPool::new_full(
Default::default(),
Arc::new(FullChainApi::new(client.clone(), None)),
+26
View File
@@ -22,6 +22,11 @@
#![warn(missing_docs)]
use futures::{compat::Future01CompatExt, FutureExt};
use rpc::futures::future::{Executor, ExecuteError, Future};
use sp_core::traits::SpawnNamed;
use std::sync::Arc;
mod metadata;
pub use sc_rpc_api::DenyUnsafe;
@@ -35,3 +40,24 @@ pub mod state;
pub mod system;
#[cfg(test)]
mod testing;
/// Task executor that is being used by RPC subscriptions.
#[derive(Clone)]
pub struct SubscriptionTaskExecutor(Arc<dyn SpawnNamed>);
impl SubscriptionTaskExecutor {
/// Create a new `Self` with the given spawner.
pub fn new(spawn: impl SpawnNamed + 'static) -> Self {
Self(Arc::new(spawn))
}
}
impl Executor<Box<dyn Future<Item = (), Error = ()> + Send>> for SubscriptionTaskExecutor {
fn execute(
&self,
future: Box<dyn Future<Item = (), Error = ()> + Send>,
) -> Result<(), ExecuteError<Box<dyn Future<Item = (), Error = ()> + Send>>> {
self.0.spawn("substrate_rpc_subscription", future.compat().map(drop).boxed());
Ok(())
}
}
+5 -5
View File
@@ -24,8 +24,7 @@ use crate::{
config::{Configuration, KeystoreConfig, PrometheusConfig, OffchainWorkerConfig},
};
use sc_client_api::{
light::RemoteBlockchain, ForkBlocks, BadBlocks, CloneableSpawn, UsageProvider,
ExecutorProvider,
light::RemoteBlockchain, ForkBlocks, BadBlocks, UsageProvider, ExecutorProvider,
};
use sp_utils::mpsc::{tracing_unbounded, TracingUnboundedSender, TracingUnboundedReceiver};
use sc_chain_spec::get_extension;
@@ -55,7 +54,7 @@ use sc_telemetry::{telemetry, SUBSTRATE_INFO};
use sp_transaction_pool::MaintainedTransactionPool;
use prometheus_endpoint::Registry;
use sc_client_db::{Backend, DatabaseSettings};
use sp_core::traits::CodeExecutor;
use sp_core::traits::{CodeExecutor, SpawnNamed};
use sp_runtime::BuildStorage;
use sc_client_api::{
BlockBackend, BlockchainEvents,
@@ -334,7 +333,7 @@ pub fn new_client<E, Block, RA>(
fork_blocks: ForkBlocks<Block>,
bad_blocks: BadBlocks<Block>,
execution_extensions: ExecutionExtensions<Block>,
spawn_handle: Box<dyn CloneableSpawn>,
spawn_handle: Box<dyn SpawnNamed>,
prometheus_registry: Option<Registry>,
config: ClientConfig,
) -> Result<(
@@ -750,7 +749,8 @@ fn gen_handler<TBl, TBackend, TExPool, TRpc, TCl>(
chain_type: config.chain_spec.chain_type(),
};
let subscriptions = SubscriptionManager::new(Arc::new(spawn_handle));
let task_executor = sc_rpc::SubscriptionTaskExecutor::new(spawn_handle);
let subscriptions = SubscriptionManager::new(Arc::new(task_executor));
let (chain, state, child_state) = if let (Some(remote_blockchain), Some(on_demand)) =
(remote_blockchain, on_demand) {
@@ -27,9 +27,12 @@ use sp_state_machine::{
};
use sc_executor::{RuntimeVersion, RuntimeInfo, NativeVersion};
use sp_externalities::Extensions;
use sp_core::{NativeOrEncoded, NeverNativeValue, traits::CodeExecutor, offchain::storage::OffchainOverlayedChanges};
use sp_core::{
NativeOrEncoded, NeverNativeValue, traits::{CodeExecutor, SpawnNamed},
offchain::storage::OffchainOverlayedChanges,
};
use sp_api::{ProofRecorder, InitializeBlock, StorageTransactionCache};
use sc_client_api::{backend, call_executor::CallExecutor, CloneableSpawn};
use sc_client_api::{backend, call_executor::CallExecutor};
use super::client::ClientConfig;
/// Call executor that executes methods locally, querying all required
@@ -37,7 +40,7 @@ use super::client::ClientConfig;
pub struct LocalCallExecutor<B, E> {
backend: Arc<B>,
executor: E,
spawn_handle: Box<dyn CloneableSpawn>,
spawn_handle: Box<dyn SpawnNamed>,
client_config: ClientConfig,
}
@@ -46,7 +49,7 @@ impl<B, E> LocalCallExecutor<B, E> {
pub fn new(
backend: Arc<B>,
executor: E,
spawn_handle: Box<dyn CloneableSpawn>,
spawn_handle: Box<dyn SpawnNamed>,
client_config: ClientConfig,
) -> Self {
LocalCallExecutor {
@@ -242,7 +245,7 @@ where
method: &str,
call_data: &[u8]
) -> Result<(Vec<u8>, StorageProof), sp_blockchain::Error> {
sp_state_machine::prove_execution_on_trie_backend::<_, _, NumberFor<Block>, _>(
sp_state_machine::prove_execution_on_trie_backend::<_, _, NumberFor<Block>, _, _>(
trie_state,
overlay,
&self.executor,
@@ -92,8 +92,8 @@ use rand::Rng;
#[cfg(feature="test-helpers")]
use {
sp_core::traits::CodeExecutor,
sc_client_api::{CloneableSpawn, in_mem},
sp_core::traits::{CodeExecutor, SpawnNamed},
sc_client_api::in_mem,
sc_executor::RuntimeInfo,
super::call_executor::LocalCallExecutor,
};
@@ -149,7 +149,7 @@ pub fn new_in_mem<E, Block, S, RA>(
genesis_storage: &S,
keystore: Option<sp_core::traits::BareCryptoStorePtr>,
prometheus_registry: Option<Registry>,
spawn_handle: Box<dyn CloneableSpawn>,
spawn_handle: Box<dyn SpawnNamed>,
config: ClientConfig,
) -> sp_blockchain::Result<Client<
in_mem::Backend<Block>,
@@ -189,7 +189,7 @@ pub fn new_with_backend<B, E, Block, S, RA>(
executor: E,
build_genesis_storage: &S,
keystore: Option<sp_core::traits::BareCryptoStorePtr>,
spawn_handle: Box<dyn CloneableSpawn>,
spawn_handle: Box<dyn SpawnNamed>,
prometheus_registry: Option<Registry>,
config: ClientConfig,
) -> sp_blockchain::Result<Client<B, LocalCallExecutor<B, E>, Block, RA>>
+4 -7
View File
@@ -21,17 +21,14 @@
use std::sync::Arc;
use sc_executor::RuntimeInfo;
use sp_core::traits::CodeExecutor;
use sp_core::traits::{CodeExecutor, SpawnNamed};
use sp_runtime::BuildStorage;
use sp_runtime::traits::{Block as BlockT, HashFor};
use sp_blockchain::Result as ClientResult;
use prometheus_endpoint::Registry;
use super::call_executor::LocalCallExecutor;
use super::client::{Client,ClientConfig};
use sc_client_api::{
light::Storage as BlockchainStorage, CloneableSpawn,
};
use super::{call_executor::LocalCallExecutor, client::{Client, ClientConfig}};
use sc_client_api::light::Storage as BlockchainStorage;
use sc_light::{Backend, GenesisCallExecutor};
@@ -40,7 +37,7 @@ pub fn new_light<B, S, RA, E>(
backend: Arc<Backend<S, HashFor<B>>>,
genesis_storage: &dyn BuildStorage,
code_executor: E,
spawn_handle: Box<dyn CloneableSpawn>,
spawn_handle: Box<dyn SpawnNamed>,
prometheus_registry: Option<Registry>,
) -> ClientResult<
Client<
+1 -1
View File
@@ -556,7 +556,7 @@ mod tests {
// given
let (client, longest_chain) = TestClientBuilder::new().build_with_longest_chain();
let client = Arc::new(client);
let spawner = sp_core::testing::SpawnBlockingExecutor::new();
let spawner = sp_core::testing::TaskExecutor::new();
let pool = BasicPool::new_full(
Default::default(),
Arc::new(FullChainApi::new(client.clone(), None)),
@@ -19,8 +19,6 @@ use log::{debug, error};
use futures::{
Future, FutureExt, StreamExt,
future::{select, Either, BoxFuture},
compat::*,
task::{Spawn, FutureObj, SpawnError},
sink::SinkExt,
};
use prometheus_endpoint::{
@@ -28,7 +26,6 @@ use prometheus_endpoint::{
PrometheusError,
CounterVec, HistogramOpts, HistogramVec, Opts, Registry, U64
};
use sc_client_api::CloneableSpawn;
use sp_utils::mpsc::{TracingUnboundedSender, TracingUnboundedReceiver, tracing_unbounded};
use crate::{config::{TaskExecutor, TaskType, JoinFuture}, Error};
@@ -132,14 +129,6 @@ impl SpawnTaskHandle {
}
}
impl Spawn for SpawnTaskHandle {
fn spawn_obj(&self, future: FutureObj<'static, ()>)
-> Result<(), SpawnError> {
self.spawn("unnamed", future);
Ok(())
}
}
impl sp_core::traits::SpawnNamed for SpawnTaskHandle {
fn spawn_blocking(&self, name: &'static str, future: BoxFuture<'static, ()>) {
self.spawn_blocking(name, future);
@@ -150,21 +139,6 @@ impl sp_core::traits::SpawnNamed for SpawnTaskHandle {
}
}
impl sc_client_api::CloneableSpawn for SpawnTaskHandle {
fn clone(&self) -> Box<dyn CloneableSpawn> {
Box::new(Clone::clone(self))
}
}
type Boxed01Future01 = Box<dyn futures01::Future<Item = (), Error = ()> + Send + 'static>;
impl futures01::future::Executor<Boxed01Future01> for SpawnTaskHandle {
fn execute(&self, future: Boxed01Future01) -> Result<(), futures01::future::ExecuteError<Boxed01Future01>>{
self.spawn("unnamed", future.compat().map(drop));
Ok(())
}
}
/// A wrapper over `SpawnTaskHandle` that will notify a receiver whenever any
/// task spawned through it fails. The service should be on the receiver side
/// and will shut itself down whenever it receives any message, i.e. an
@@ -37,9 +37,9 @@ use substrate_test_runtime_client::{
runtime::{Hash, Block, Header}, TestClient, ClientBlockImportExt,
};
use sp_api::{InitializeBlock, StorageTransactionCache, ProofRecorder, OffchainOverlayedChanges};
use sp_consensus::{BlockOrigin};
use sp_consensus::BlockOrigin;
use sc_executor::{NativeExecutor, WasmExecutionMethod, RuntimeVersion, NativeVersion};
use sp_core::{H256, tasks::executor as tasks_executor, NativeOrEncoded};
use sp_core::{H256, NativeOrEncoded, testing::TaskExecutor};
use sc_client_api::{
blockchain::Info, backend::NewBlockState, Backend as ClientBackend, ProofProvider,
in_mem::{Backend as InMemBackend, Blockchain as InMemoryBlockchain},
@@ -317,7 +317,7 @@ fn execution_proof_is_generated_and_checked() {
// check remote execution proof locally
let local_result = check_execution_proof::<_, _, BlakeTwo256>(
&local_executor(),
tasks_executor(),
Box::new(TaskExecutor::new()),
&RemoteCallRequest {
block: substrate_test_runtime_client::runtime::Hash::default(),
header: remote_header,
@@ -345,7 +345,7 @@ fn execution_proof_is_generated_and_checked() {
// check remote execution proof locally
let execution_result = check_execution_proof_with_make_header::<_, _, BlakeTwo256, _>(
&local_executor(),
tasks_executor(),
Box::new(TaskExecutor::new()),
&RemoteCallRequest {
block: substrate_test_runtime_client::runtime::Hash::default(),
header: remote_header,
@@ -479,7 +479,7 @@ fn prepare_for_read_proof_check() -> (TestChecker, Header, StorageProof, u32) {
let local_checker = LightDataChecker::new(
Arc::new(DummyBlockchain::new(DummyStorage::new())),
local_executor(),
tasks_executor(),
Box::new(TaskExecutor::new()),
);
(local_checker, remote_block_header, remote_read_proof, heap_pages)
}
@@ -527,7 +527,7 @@ fn prepare_for_read_child_proof_check() -> (TestChecker, Header, StorageProof, V
let local_checker = LightDataChecker::new(
Arc::new(DummyBlockchain::new(DummyStorage::new())),
local_executor(),
tasks_executor(),
Box::new(TaskExecutor::new()),
);
(local_checker, remote_block_header, remote_read_proof, child_value)
}
@@ -558,7 +558,7 @@ fn prepare_for_header_proof_check(insert_cht: bool) -> (TestChecker, Hash, Heade
let local_checker = LightDataChecker::new(
Arc::new(DummyBlockchain::new(DummyStorage::new())),
local_executor(),
tasks_executor(),
Box::new(TaskExecutor::new()),
);
(local_checker, local_cht_root, remote_block_header, remote_header_proof)
}
@@ -642,7 +642,7 @@ fn changes_proof_is_generated_and_checked_when_headers_are_not_pruned() {
let local_checker = TestChecker::new(
Arc::new(DummyBlockchain::new(DummyStorage::new())),
local_executor(),
tasks_executor(),
Box::new(TaskExecutor::new()),
);
let local_checker = &local_checker as &dyn FetchChecker<Block>;
let max = remote_client.chain_info().best_number;
@@ -717,7 +717,7 @@ fn changes_proof_is_generated_and_checked_when_headers_are_pruned() {
let local_checker = TestChecker::new(
Arc::new(DummyBlockchain::new(local_storage)),
local_executor(),
tasks_executor(),
Box::new(TaskExecutor::new()),
);
// check proof on local client
@@ -752,7 +752,7 @@ fn check_changes_proof_fails_if_proof_is_wrong() {
let local_checker = TestChecker::new(
Arc::new(DummyBlockchain::new(DummyStorage::new())),
local_executor(),
tasks_executor(),
Box::new(TaskExecutor::new()),
);
let local_checker = &local_checker as &dyn FetchChecker<Block>;
let max = remote_client.chain_info().best_number;
@@ -840,7 +840,7 @@ fn check_changes_tries_proof_fails_if_proof_is_wrong() {
let local_checker = TestChecker::new(
Arc::new(DummyBlockchain::new(DummyStorage::new())),
local_executor(),
tasks_executor(),
Box::new(TaskExecutor::new()),
);
assert!(local_checker.check_changes_tries_proof(4, &remote_proof.roots,
remote_proof.roots_proof.clone()).is_err());
@@ -851,7 +851,7 @@ fn check_changes_tries_proof_fails_if_proof_is_wrong() {
let local_checker = TestChecker::new(
Arc::new(DummyBlockchain::new(local_storage)),
local_executor(),
tasks_executor(),
Box::new(TaskExecutor::new()),
);
let result = local_checker.check_changes_tries_proof(
4, &remote_proof.roots, StorageProof::empty()
@@ -869,7 +869,7 @@ fn check_body_proof_faulty() {
let local_checker = TestChecker::new(
Arc::new(DummyBlockchain::new(DummyStorage::new())),
local_executor(),
tasks_executor(),
Box::new(TaskExecutor::new()),
);
let body_request = RemoteBodyRequest {
@@ -893,7 +893,7 @@ fn check_body_proof_of_same_data_should_succeed() {
let local_checker = TestChecker::new(
Arc::new(DummyBlockchain::new(DummyStorage::new())),
local_executor(),
tasks_executor(),
Box::new(TaskExecutor::new()),
);
let body_request = RemoteBodyRequest {
@@ -40,8 +40,7 @@ use sp_runtime::traits::{
use substrate_test_runtime::TestAPI;
use sp_state_machine::backend::Backend as _;
use sp_api::{ProvideRuntimeApi, OffchainOverlayedChanges};
use sp_core::tasks::executor as tasks_executor;
use sp_core::{H256, ChangesTrieConfiguration, blake2_256};
use sp_core::{H256, ChangesTrieConfiguration, blake2_256, testing::TaskExecutor};
use std::collections::{HashMap, HashSet};
use std::sync::Arc;
use sp_consensus::{
@@ -165,6 +164,7 @@ fn construct_block(
let mut offchain_overlay = OffchainOverlayedChanges::default();
let backend_runtime_code = sp_state_machine::backend::BackendRuntimeCode::new(&backend);
let runtime_code = backend_runtime_code.runtime_code().expect("Code is part of the backend");
let task_executor = Box::new(TaskExecutor::new());
StateMachine::new(
backend,
@@ -176,7 +176,7 @@ fn construct_block(
&header.encode(),
Default::default(),
&runtime_code,
tasks_executor(),
task_executor.clone() as Box<_>,
).execute(
ExecutionStrategy::NativeElseWasm,
).unwrap();
@@ -192,7 +192,7 @@ fn construct_block(
&tx.encode(),
Default::default(),
&runtime_code,
tasks_executor(),
task_executor.clone() as Box<_>,
).execute(
ExecutionStrategy::NativeElseWasm,
).unwrap();
@@ -208,7 +208,7 @@ fn construct_block(
&[],
Default::default(),
&runtime_code,
tasks_executor(),
task_executor.clone() as Box<_>,
).execute(
ExecutionStrategy::NativeElseWasm,
).unwrap();
@@ -262,7 +262,7 @@ fn construct_genesis_should_work_with_native() {
&b1data,
Default::default(),
&runtime_code,
tasks_executor(),
TaskExecutor::new(),
).execute(
ExecutionStrategy::NativeElseWasm,
).unwrap();
@@ -298,7 +298,7 @@ fn construct_genesis_should_work_with_wasm() {
&b1data,
Default::default(),
&runtime_code,
tasks_executor(),
TaskExecutor::new(),
).execute(
ExecutionStrategy::AlwaysWasm,
).unwrap();
@@ -334,7 +334,7 @@ fn construct_genesis_with_bad_transaction_should_panic() {
&b1data,
Default::default(),
&runtime_code,
tasks_executor(),
TaskExecutor::new(),
).execute(
ExecutionStrategy::NativeElseWasm,
);
@@ -1743,7 +1743,7 @@ fn cleans_up_closed_notification_sinks_on_block_import() {
&substrate_test_runtime_client::GenesisParameters::default().genesis_storage(),
None,
None,
sp_core::tasks::executor(),
Box::new(TaskExecutor::new()),
Default::default(),
)
.unwrap();