diff --git a/Cargo.lock b/Cargo.lock index 08db695b05ef7..5bff4b47b18bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4224,6 +4224,7 @@ dependencies = [ "sc-consensus-epochs", "sc-consensus-slots", "sc-consensus-uncles", + "sc-executor", "sc-finality-grandpa", "sc-keystore", "sc-network", @@ -4296,6 +4297,7 @@ dependencies = [ "parity-scale-codec", "sc-cli", "sc-client-api", + "sc-executor", "sc-service", "sp-blockchain", "sp-core", diff --git a/bin/node-template/node/src/command.rs b/bin/node-template/node/src/command.rs index b4f0a1804f66c..1e7e4edb79950 100644 --- a/bin/node-template/node/src/command.rs +++ b/bin/node-template/node/src/command.rs @@ -119,7 +119,7 @@ pub fn run() -> sc_cli::Result<()> { if cfg!(feature = "runtime-benchmarks") { let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| cmd.run::(config)) + runner.sync_run(|config| cmd.run::(config)) } else { Err("Benchmarking wasn't enabled when building the node. You can enable it with \ `--features runtime-benchmarks`." diff --git a/bin/node-template/node/src/service.rs b/bin/node-template/node/src/service.rs index 6f41dcb1d6510..0f09ef436acad 100644 --- a/bin/node-template/node/src/service.rs +++ b/bin/node-template/node/src/service.rs @@ -3,7 +3,7 @@ use node_template_runtime::{self, opaque::Block, RuntimeApi}; use sc_client_api::{ExecutorProvider, RemoteBackend}; use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams}; -pub use sc_executor::NativeExecutor; +pub use sc_executor::NativeElseWasmExecutor; use sc_finality_grandpa::SharedVoterState; use sc_keystore::LocalKeystore; use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; @@ -13,9 +13,9 @@ use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; use std::{sync::Arc, time::Duration}; // Our native executor instance. -pub struct Executor; +pub struct ExecutorDispatch; -impl sc_executor::NativeExecutionDispatch for Executor { +impl sc_executor::NativeExecutionDispatch for ExecutorDispatch { type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; fn dispatch(method: &str, data: &[u8]) -> Option> { @@ -27,7 +27,8 @@ impl sc_executor::NativeExecutionDispatch for Executor { } } -type FullClient = sc_service::TFullClient; +type FullClient = + sc_service::TFullClient>; type FullBackend = sc_service::TFullBackend; type FullSelectChain = sc_consensus::LongestChain; @@ -68,10 +69,17 @@ pub fn new_partial( }) .transpose()?; + let executor = NativeElseWasmExecutor::::new( + config.wasm_method, + config.default_heap_pages, + config.max_runtime_instances, + ); + let (client, backend, keystore_container, task_manager) = - sc_service::new_full_parts::( + sc_service::new_full_parts::( &config, telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), + executor, )?; let client = Arc::new(client); @@ -336,10 +344,17 @@ pub fn new_light(mut config: Configuration) -> Result }) .transpose()?; + let executor = NativeElseWasmExecutor::::new( + config.wasm_method, + config.default_heap_pages, + config.max_runtime_instances, + ); + let (client, backend, keystore_container, mut task_manager, on_demand) = - sc_service::new_light_parts::( + sc_service::new_light_parts::( &config, telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), + executor, )?; let mut telemetry = telemetry.map(|(worker, telemetry)| { diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index b595aa4b034d0..2caefebbbf3b3 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -72,6 +72,7 @@ sc-rpc = { version = "4.0.0-dev", path = "../../../client/rpc" } sc-basic-authorship = { version = "0.10.0-dev", path = "../../../client/basic-authorship" } sc-service = { version = "0.10.0-dev", default-features = false, path = "../../../client/service" } sc-telemetry = { version = "4.0.0-dev", path = "../../../client/telemetry" } +sc-executor = { version = "0.10.0-dev", path = "../../../client/executor" } sc-authority-discovery = { version = "0.10.0-dev", path = "../../../client/authority-discovery" } sc-sync-state-rpc = { version = "0.10.0-dev", path = "../../../client/sync-state-rpc" } diff --git a/bin/node/cli/src/command.rs b/bin/node/cli/src/command.rs index b904ea99e8f9f..a660b8985b644 100644 --- a/bin/node/cli/src/command.rs +++ b/bin/node/cli/src/command.rs @@ -17,7 +17,7 @@ // along with this program. If not, see . use crate::{chain_spec, service, service::new_partial, Cli, Subcommand}; -use node_executor::Executor; +use node_executor::ExecutorDispatch; use node_runtime::{Block, RuntimeApi}; use sc_cli::{ChainSpec, Result, Role, RuntimeVersion, SubstrateCli}; use sc_service::PartialComponents; @@ -87,13 +87,13 @@ pub fn run() -> Result<()> { Some(Subcommand::Inspect(cmd)) => { let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| cmd.run::(config)) + runner.sync_run(|config| cmd.run::(config)) }, Some(Subcommand::Benchmark(cmd)) => if cfg!(feature = "runtime-benchmarks") { let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| cmd.run::(config)) + runner.sync_run(|config| cmd.run::(config)) } else { Err("Benchmarking wasn't enabled when building the node. \ You can enable it with `--features runtime-benchmarks`." @@ -159,7 +159,7 @@ pub fn run() -> Result<()> { sc_service::TaskManager::new(config.task_executor.clone(), registry) .map_err(|e| sc_cli::Error::Service(sc_service::Error::Prometheus(e)))?; - Ok((cmd.run::(config), task_manager)) + Ok((cmd.run::(config), task_manager)) }) }, #[cfg(not(feature = "try-runtime"))] diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index bd3c92d9aa142..845e5c83e8834 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -21,23 +21,26 @@ //! Service implementation. Specialized wrapper over substrate service. use futures::prelude::*; -use node_executor::Executor; +use node_executor::ExecutorDispatch; use node_primitives::Block; use node_runtime::RuntimeApi; use sc_client_api::{ExecutorProvider, RemoteBackend}; use sc_consensus_babe::{self, SlotProportion}; +use sc_executor::NativeElseWasmExecutor; use sc_network::{Event, NetworkService}; use sc_service::{config::Configuration, error::Error as ServiceError, RpcHandlers, TaskManager}; use sc_telemetry::{Telemetry, TelemetryWorker}; use sp_runtime::traits::Block as BlockT; use std::sync::Arc; -type FullClient = sc_service::TFullClient; +type FullClient = + sc_service::TFullClient>; type FullBackend = sc_service::TFullBackend; type FullSelectChain = sc_consensus::LongestChain; type FullGrandpaBlockImport = grandpa::GrandpaBlockImport; -type LightClient = sc_service::TLightClient; +type LightClient = + sc_service::TLightClient>; pub fn new_partial( config: &Configuration, @@ -75,10 +78,17 @@ pub fn new_partial( }) .transpose()?; + let executor = NativeElseWasmExecutor::::new( + config.wasm_method, + config.default_heap_pages, + config.max_runtime_instances, + ); + let (client, backend, keystore_container, task_manager) = - sc_service::new_full_parts::( + sc_service::new_full_parts::( &config, telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), + executor, )?; let client = Arc::new(client); @@ -447,10 +457,17 @@ pub fn new_light_base( }) .transpose()?; + let executor = NativeElseWasmExecutor::::new( + config.wasm_method, + config.default_heap_pages, + config.max_runtime_instances, + ); + let (client, backend, keystore_container, mut task_manager, on_demand) = - sc_service::new_light_parts::( + sc_service::new_light_parts::( &config, telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), + executor, )?; let mut telemetry = telemetry.map(|(worker, telemetry)| { diff --git a/bin/node/executor/benches/bench.rs b/bin/node/executor/benches/bench.rs index 485298e8c4287..0058a5c70340f 100644 --- a/bin/node/executor/benches/bench.rs +++ b/bin/node/executor/benches/bench.rs @@ -18,14 +18,14 @@ use codec::{Decode, Encode}; use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; use frame_support::Hashable; -use node_executor::Executor; +use node_executor::ExecutorDispatch; use node_primitives::{BlockNumber, Hash}; use node_runtime::{ constants::currency::*, Block, BuildStorage, Call, CheckedExtrinsic, GenesisConfig, Header, UncheckedExtrinsic, }; use node_testing::keyring::*; -use sc_executor::{Externalities, NativeExecutor, RuntimeVersionOf, WasmExecutionMethod}; +use sc_executor::{Externalities, NativeElseWasmExecutor, RuntimeVersionOf, WasmExecutionMethod}; use sp_core::{ storage::well_known_keys, traits::{CodeExecutor, RuntimeCode}, @@ -77,7 +77,7 @@ fn new_test_ext(genesis_config: &GenesisConfig) -> TestExternalities( - executor: &NativeExecutor, + executor: &NativeElseWasmExecutor, ext: &mut E, number: BlockNumber, parent_hash: Hash, @@ -157,7 +157,7 @@ fn construct_block( fn test_blocks( genesis_config: &GenesisConfig, - executor: &NativeExecutor, + executor: &NativeElseWasmExecutor, ) -> Vec<(Vec, Hash)> { let mut test_ext = new_test_ext(genesis_config); let mut block1_extrinsics = vec![CheckedExtrinsic { @@ -191,7 +191,7 @@ fn bench_execute_block(c: &mut Criterion) { ExecutionMethod::Wasm(wasm_method) => (false, wasm_method), }; - let executor = NativeExecutor::new(wasm_method, None, 8); + let executor = NativeElseWasmExecutor::new(wasm_method, None, 8); let runtime_code = RuntimeCode { code_fetcher: &sp_core::traits::WrappedRuntimeCode(compact_code_unwrap().into()), hash: vec![1, 2, 3], diff --git a/bin/node/executor/src/lib.rs b/bin/node/executor/src/lib.rs index a2e0455a96fae..9a7a0c4d3c110 100644 --- a/bin/node/executor/src/lib.rs +++ b/bin/node/executor/src/lib.rs @@ -18,13 +18,13 @@ //! A `CodeExecutor` specialization which uses natively compiled runtime when the wasm to be //! executed is equivalent to the natively compiled code. -pub use sc_executor::NativeExecutor; +pub use sc_executor::NativeElseWasmExecutor; -// Declare an instance of the native executor named `Executor`. Include the wasm binary as the -// equivalent wasm code. -pub struct Executor; +// Declare an instance of the native executor named `ExecutorDispatch`. Include the wasm binary as +// the equivalent wasm code. +pub struct ExecutorDispatch; -impl sc_executor::NativeExecutionDispatch for Executor { +impl sc_executor::NativeExecutionDispatch for ExecutorDispatch { type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; fn dispatch(method: &str, data: &[u8]) -> Option> { diff --git a/bin/node/executor/tests/common.rs b/bin/node/executor/tests/common.rs index 337b4b0c15f92..a0edb46a0d6ae 100644 --- a/bin/node/executor/tests/common.rs +++ b/bin/node/executor/tests/common.rs @@ -18,7 +18,7 @@ use codec::{Decode, Encode}; use frame_support::Hashable; use frame_system::offchain::AppCrypto; -use sc_executor::{error::Result, NativeExecutor, WasmExecutionMethod}; +use sc_executor::{error::Result, NativeElseWasmExecutor, WasmExecutionMethod}; use sp_consensus_babe::{ digests::{PreDigest, SecondaryPlainPreDigest}, Slot, BABE_ENGINE_ID, @@ -35,7 +35,7 @@ use sp_runtime::{ }; use sp_state_machine::TestExternalities as CoreTestExternalities; -use node_executor::Executor; +use node_executor::ExecutorDispatch; use node_primitives::{BlockNumber, Hash}; use node_runtime::{ constants::currency::*, Block, BuildStorage, CheckedExtrinsic, Header, Runtime, @@ -95,8 +95,8 @@ pub fn from_block_number(n: u32) -> Header { Header::new(n, Default::default(), Default::default(), [69; 32].into(), Default::default()) } -pub fn executor() -> NativeExecutor { - NativeExecutor::new(WasmExecutionMethod::Interpreted, None, 8) +pub fn executor() -> NativeElseWasmExecutor { + NativeElseWasmExecutor::new(WasmExecutionMethod::Interpreted, None, 8) } pub fn executor_call< diff --git a/bin/node/inspect/Cargo.toml b/bin/node/inspect/Cargo.toml index c4fd1fb3adc9f..1570e5dbf8e44 100644 --- a/bin/node/inspect/Cargo.toml +++ b/bin/node/inspect/Cargo.toml @@ -15,6 +15,7 @@ codec = { package = "parity-scale-codec", version = "2.0.0" } derive_more = "0.99" sc-cli = { version = "0.10.0-dev", path = "../../../client/cli" } sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" } +sc-executor = { version = "0.10.0-dev", path = "../../../client/executor" } sc-service = { version = "0.10.0-dev", default-features = false, path = "../../../client/service" } sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" } sp-core = { version = "4.0.0-dev", path = "../../../primitives/core" } diff --git a/bin/node/inspect/src/command.rs b/bin/node/inspect/src/command.rs index a2c63d684bf96..9bf69511689c4 100644 --- a/bin/node/inspect/src/command.rs +++ b/bin/node/inspect/src/command.rs @@ -23,6 +23,7 @@ use crate::{ Inspector, }; use sc_cli::{CliConfiguration, ImportParams, Result, SharedParams}; +use sc_executor::NativeElseWasmExecutor; use sc_service::{new_full_client, Configuration, NativeExecutionDispatch}; use sp_runtime::traits::Block; use std::str::FromStr; @@ -36,7 +37,13 @@ impl InspectCmd { RA: Send + Sync + 'static, EX: NativeExecutionDispatch + 'static, { - let client = new_full_client::(&config, None)?; + let executor = NativeElseWasmExecutor::::new( + config.wasm_method, + config.default_heap_pages, + config.max_runtime_instances, + ); + + let client = new_full_client::(&config, None, executor)?; let inspect = Inspector::::new(client); match &self.command { diff --git a/bin/node/test-runner-example/src/lib.rs b/bin/node/test-runner-example/src/lib.rs index a4101556681a6..04c099a2f4c23 100644 --- a/bin/node/test-runner-example/src/lib.rs +++ b/bin/node/test-runner-example/src/lib.rs @@ -22,6 +22,7 @@ use grandpa::GrandpaBlockImport; use sc_consensus_babe::BabeBlockImport; use sc_consensus_manual_seal::consensus::babe::SlotTimestampProvider; +use sc_executor::NativeElseWasmExecutor; use sc_service::{TFullBackend, TFullClient}; use sp_runtime::generic::Era; use test_runner::{ChainInfo, SignatureVerificationOverride}; @@ -30,9 +31,9 @@ type BlockImport = BabeBlockImport, Self::Block>; type BlockImport = BlockImport< Self::Block, TFullBackend, - TFullClient, + TFullClient>, Self::SelectChain, >; type SignedExtras = node_runtime::SignedExtra; diff --git a/bin/node/testing/src/bench.rs b/bin/node/testing/src/bench.rs index f6ed2418410ed..a1f9bc8710565 100644 --- a/bin/node/testing/src/bench.rs +++ b/bin/node/testing/src/bench.rs @@ -46,7 +46,7 @@ use sc_client_api::{ }; use sc_client_db::PruningMode; use sc_consensus::{BlockImport, BlockImportParams, ForkChoiceStrategy, ImportResult, ImportedAux}; -use sc_executor::{NativeExecutor, WasmExecutionMethod}; +use sc_executor::{NativeElseWasmExecutor, WasmExecutionMethod}; use sp_api::ProvideRuntimeApi; use sp_block_builder::BlockBuilder; use sp_consensus::BlockOrigin; @@ -390,7 +390,7 @@ impl BenchDb { let backend = sc_service::new_db_backend(db_config).expect("Should not fail"); let client = sc_service::new_client( backend.clone(), - NativeExecutor::new(WasmExecutionMethod::Compiled, None, 8), + NativeElseWasmExecutor::new(WasmExecutionMethod::Compiled, None, 8), &keyring.generate_genesis(), None, None, diff --git a/bin/node/testing/src/client.rs b/bin/node/testing/src/client.rs index 9538cd47d88a6..8bd75834c5496 100644 --- a/bin/node/testing/src/client.rs +++ b/bin/node/testing/src/client.rs @@ -24,7 +24,7 @@ use sp_runtime::BuildStorage; pub use substrate_test_client::*; /// Call executor for `node-runtime` `TestClient`. -pub type Executor = sc_executor::NativeExecutor; +pub type ExecutorDispatch = sc_executor::NativeElseWasmExecutor; /// Default backend type. pub type Backend = sc_client_db::Backend; @@ -32,7 +32,7 @@ pub type Backend = sc_client_db::Backend; /// Test client type. pub type Client = client::Client< Backend, - client::LocalCallExecutor, + client::LocalCallExecutor, node_primitives::Block, node_runtime::RuntimeApi, >; @@ -64,7 +64,7 @@ pub trait TestClientBuilderExt: Sized { impl TestClientBuilderExt for substrate_test_client::TestClientBuilder< node_primitives::Block, - client::LocalCallExecutor, + client::LocalCallExecutor, Backend, GenesisParameters, > diff --git a/client/consensus/babe/src/tests.rs b/client/consensus/babe/src/tests.rs index 4b4e0a9d0f3d3..c033f4535be0b 100644 --- a/client/consensus/babe/src/tests.rs +++ b/client/consensus/babe/src/tests.rs @@ -55,7 +55,7 @@ type Error = sp_blockchain::Error; type TestClient = substrate_test_runtime_client::client::Client< substrate_test_runtime_client::Backend, - substrate_test_runtime_client::Executor, + substrate_test_runtime_client::ExecutorDispatch, TestBlock, substrate_test_runtime_client::runtime::RuntimeApi, >; diff --git a/client/executor/src/lib.rs b/client/executor/src/lib.rs index e4442960ea24e..041db87bc82ab 100644 --- a/client/executor/src/lib.rs +++ b/client/executor/src/lib.rs @@ -39,7 +39,7 @@ mod wasm_runtime; pub use codec::Codec; pub use native_executor::{ - with_externalities_safe, NativeExecutionDispatch, NativeExecutor, WasmExecutor, + with_externalities_safe, NativeElseWasmExecutor, NativeExecutionDispatch, WasmExecutor, }; #[doc(hidden)] pub use sp_core::traits::Externalities; diff --git a/client/executor/src/native_executor.rs b/client/executor/src/native_executor.rs index c0542554c7314..38dba55b5f87c 100644 --- a/client/executor/src/native_executor.rs +++ b/client/executor/src/native_executor.rs @@ -311,7 +311,7 @@ impl RuntimeVersionOf for WasmExecutor { /// A generic `CodeExecutor` implementation that uses a delegate to determine wasm code equivalence /// and dispatch to native code when possible, falling back on `WasmExecutor` when not. -pub struct NativeExecutor { +pub struct NativeElseWasmExecutor { /// Dummy field to avoid the compiler complaining about us not using `D`. _dummy: std::marker::PhantomData, /// Native runtime version info. @@ -320,7 +320,7 @@ pub struct NativeExecutor { wasm: WasmExecutor, } -impl NativeExecutor { +impl NativeElseWasmExecutor { /// Create new instance. /// /// # Parameters @@ -356,7 +356,7 @@ impl NativeExecutor { None, ); - NativeExecutor { + NativeElseWasmExecutor { _dummy: Default::default(), native_version: D::native_version(), wasm: wasm_executor, @@ -364,7 +364,7 @@ impl NativeExecutor { } } -impl RuntimeVersionOf for NativeExecutor { +impl RuntimeVersionOf for NativeElseWasmExecutor { fn runtime_version( &self, ext: &mut dyn Externalities, @@ -377,7 +377,7 @@ impl RuntimeVersionOf for NativeExecutor { } } -impl GetNativeVersion for NativeExecutor { +impl GetNativeVersion for NativeElseWasmExecutor { fn native_version(&self) -> &NativeVersion { &self.native_version } @@ -508,7 +508,7 @@ fn preregister_builtin_ext(module: Arc) { }); } -impl CodeExecutor for NativeExecutor { +impl CodeExecutor for NativeElseWasmExecutor { type Error = Error; fn call< @@ -586,9 +586,9 @@ impl CodeExecutor for NativeExecutor { } } -impl Clone for NativeExecutor { +impl Clone for NativeElseWasmExecutor { fn clone(&self) -> Self { - NativeExecutor { + NativeElseWasmExecutor { _dummy: Default::default(), native_version: D::native_version(), wasm: self.wasm.clone(), @@ -596,7 +596,7 @@ impl Clone for NativeExecutor { } } -impl sp_core::traits::ReadRuntimeVersion for NativeExecutor { +impl sp_core::traits::ReadRuntimeVersion for NativeElseWasmExecutor { fn read_runtime_version( &self, wasm_code: &[u8], @@ -618,9 +618,9 @@ mod tests { } } - pub struct MyExecutor; + pub struct MyExecutorDispatch; - impl NativeExecutionDispatch for MyExecutor { + impl NativeExecutionDispatch for MyExecutorDispatch { type ExtendHostFunctions = (my_interface::HostFunctions, my_interface::HostFunctions); fn dispatch(method: &str, data: &[u8]) -> Option> { @@ -634,7 +634,11 @@ mod tests { #[test] fn native_executor_registers_custom_interface() { - let executor = NativeExecutor::::new(WasmExecutionMethod::Interpreted, None, 8); + let executor = NativeElseWasmExecutor::::new( + WasmExecutionMethod::Interpreted, + None, + 8, + ); my_interface::HostFunctions::host_functions().iter().for_each(|function| { assert_eq!(executor.wasm.host_functions.iter().filter(|f| f == &function).count(), 2); }); diff --git a/client/network/test/src/lib.rs b/client/network/test/src/lib.rs index 7668aa8fd56e3..bb49cef8c642c 100644 --- a/client/network/test/src/lib.rs +++ b/client/network/test/src/lib.rs @@ -126,7 +126,7 @@ impl Verifier for PassThroughVerifier { pub type PeersFullClient = Client< substrate_test_runtime_client::Backend, - substrate_test_runtime_client::Executor, + substrate_test_runtime_client::ExecutorDispatch, Block, substrate_test_runtime_client::runtime::RuntimeApi, >; diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 9b5390710cd80..fb83fdb00ca43 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -37,7 +37,7 @@ use sc_client_api::{ }; use sc_client_db::{Backend, DatabaseSettings}; use sc_consensus::import_queue::ImportQueue; -use sc_executor::{NativeExecutionDispatch, NativeExecutor, RuntimeVersionOf}; +use sc_executor::RuntimeVersionOf; use sc_keystore::LocalKeystore; use sc_network::{ block_request_handler::{self, BlockRequestHandler}, @@ -128,39 +128,39 @@ where } /// Full client type. -pub type TFullClient = - Client, TFullCallExecutor, TBl, TRtApi>; +pub type TFullClient = + Client, TFullCallExecutor, TBl, TRtApi>; /// Full client backend type. pub type TFullBackend = sc_client_db::Backend; /// Full client call executor type. -pub type TFullCallExecutor = - crate::client::LocalCallExecutor, NativeExecutor>; +pub type TFullCallExecutor = + crate::client::LocalCallExecutor, TExec>; /// Light client type. -pub type TLightClient = - TLightClientWithBackend>; +pub type TLightClient = + TLightClientWithBackend>; /// Light client backend type. pub type TLightBackend = sc_light::Backend, HashFor>; /// Light call executor type. -pub type TLightCallExecutor = sc_light::GenesisCallExecutor< +pub type TLightCallExecutor = sc_light::GenesisCallExecutor< sc_light::Backend, HashFor>, crate::client::LocalCallExecutor< TBl, sc_light::Backend, HashFor>, - NativeExecutor, + TExec, >, >; -type TFullParts = - (TFullClient, Arc>, KeystoreContainer, TaskManager); +type TFullParts = + (TFullClient, Arc>, KeystoreContainer, TaskManager); -type TLightParts = ( - Arc>, +type TLightParts = ( + Arc>, Arc>, KeystoreContainer, TaskManager, @@ -172,12 +172,9 @@ pub type TLightBackendWithHash = sc_light::Backend, THash>; /// Light client type with a specific backend. -pub type TLightClientWithBackend = Client< +pub type TLightClientWithBackend = Client< TBackend, - sc_light::GenesisCallExecutor< - TBackend, - crate::client::LocalCallExecutor>, - >, + sc_light::GenesisCallExecutor>, TBl, TRtApi, >; @@ -262,26 +259,28 @@ impl KeystoreContainer { } /// Creates a new full client for the given config. -pub fn new_full_client( +pub fn new_full_client( config: &Configuration, telemetry: Option, -) -> Result, Error> + executor: TExec, +) -> Result, Error> where TBl: BlockT, - TExecDisp: NativeExecutionDispatch + 'static, + TExec: CodeExecutor + RuntimeVersionOf + Clone, TBl::Hash: FromStr, { - new_full_parts(config, telemetry).map(|parts| parts.0) + new_full_parts(config, telemetry, executor).map(|parts| parts.0) } /// Create the initial parts of a full node. -pub fn new_full_parts( +pub fn new_full_parts( config: &Configuration, telemetry: Option, -) -> Result, Error> + executor: TExec, +) -> Result, Error> where TBl: BlockT, - TExecDisp: NativeExecutionDispatch + 'static, + TExec: CodeExecutor + RuntimeVersionOf + Clone, TBl::Hash: FromStr, { let keystore_container = KeystoreContainer::new(&config.keystore)?; @@ -291,12 +290,6 @@ where TaskManager::new(config.task_executor.clone(), registry)? }; - let executor = NativeExecutor::::new( - config.wasm_method, - config.default_heap_pages, - config.max_runtime_instances, - ); - let chain_spec = &config.chain_spec; let fork_blocks = get_extension::>(chain_spec.extensions()) .cloned() @@ -368,13 +361,14 @@ where } /// Create the initial parts of a light node. -pub fn new_light_parts( +pub fn new_light_parts( config: &Configuration, telemetry: Option, -) -> Result, Error> + executor: TExec, +) -> Result, Error> where TBl: BlockT, - TExecDisp: NativeExecutionDispatch + 'static, + TExec: CodeExecutor + RuntimeVersionOf + Clone, { let keystore_container = KeystoreContainer::new(&config.keystore)?; let task_manager = { @@ -382,12 +376,6 @@ where TaskManager::new(config.task_executor.clone(), registry)? }; - let executor = NativeExecutor::::new( - config.wasm_method, - config.default_heap_pages, - config.max_runtime_instances, - ); - let db_storage = { let db_settings = sc_client_db::DatabaseSettings { state_cache_size: config.state_cache_size, diff --git a/client/service/src/client/call_executor.rs b/client/service/src/client/call_executor.rs index 23cc08b7e1887..41cc1526fa3e0 100644 --- a/client/service/src/client/call_executor.rs +++ b/client/service/src/client/call_executor.rs @@ -360,17 +360,20 @@ where mod tests { use super::*; use sc_client_api::in_mem; - use sc_executor::{NativeExecutor, WasmExecutionMethod}; + use sc_executor::{NativeElseWasmExecutor, WasmExecutionMethod}; use sp_core::{ testing::TaskExecutor, traits::{FetchRuntimeCode, WrappedRuntimeCode}, }; - use substrate_test_runtime_client::{runtime, GenesisInit, LocalExecutor}; + use substrate_test_runtime_client::{runtime, GenesisInit, LocalExecutorDispatch}; #[test] fn should_get_override_if_exists() { - let executor = - NativeExecutor::::new(WasmExecutionMethod::Interpreted, Some(128), 1); + let executor = NativeElseWasmExecutor::::new( + WasmExecutionMethod::Interpreted, + Some(128), + 1, + ); let overrides = crate::client::wasm_override::dummy_overrides(&executor); let onchain_code = WrappedRuntimeCode(substrate_test_runtime::wasm_binary_unwrap().into()); diff --git a/client/service/src/client/wasm_override.rs b/client/service/src/client/wasm_override.rs index a04a48f9c4b49..6d5a071269d4d 100644 --- a/client/service/src/client/wasm_override.rs +++ b/client/service/src/client/wasm_override.rs @@ -204,19 +204,20 @@ where #[cfg(test)] mod tests { use super::*; - use sc_executor::{NativeExecutor, WasmExecutionMethod}; + use sc_executor::{NativeElseWasmExecutor, WasmExecutionMethod}; use std::fs::{self, File}; - use substrate_test_runtime_client::LocalExecutor; + use substrate_test_runtime_client::LocalExecutorDispatch; fn wasm_test(fun: F) where - F: Fn(&Path, &[u8], &NativeExecutor), + F: Fn(&Path, &[u8], &NativeElseWasmExecutor), { - let exec = NativeExecutor::::new( - WasmExecutionMethod::Interpreted, - Some(128), - 1, - ); + let exec = + NativeElseWasmExecutor::::new( + WasmExecutionMethod::Interpreted, + Some(128), + 1, + ); let bytes = substrate_test_runtime::wasm_binary_unwrap(); let dir = tempfile::tempdir().expect("Create a temporary directory"); fun(dir.path(), bytes, &exec); @@ -226,8 +227,11 @@ mod tests { #[test] fn should_get_runtime_version() { let wasm = WasmBlob::new(substrate_test_runtime::wasm_binary_unwrap().to_vec()); - let executor = - NativeExecutor::::new(WasmExecutionMethod::Interpreted, Some(128), 1); + let executor = NativeElseWasmExecutor::::new( + WasmExecutionMethod::Interpreted, + Some(128), + 1, + ); let version = WasmOverride::runtime_version(&executor, &wasm, Some(128)) .expect("should get the `RuntimeVersion` of the test-runtime wasm blob"); diff --git a/client/service/test/src/client/light.rs b/client/service/test/src/client/light.rs index da4363b881027..fb9566d208f76 100644 --- a/client/service/test/src/client/light.rs +++ b/client/service/test/src/client/light.rs @@ -30,7 +30,7 @@ use sc_client_api::{ RemoteBodyRequest, RemoteCallRequest, RemoteChangesRequest, RemoteHeaderRequest, RemoteReadChildRequest, RemoteReadRequest, Storage, StorageProof, StorageProvider, }; -use sc_executor::{NativeExecutor, RuntimeVersion, WasmExecutionMethod}; +use sc_executor::{NativeElseWasmExecutor, RuntimeVersion, WasmExecutionMethod}; use sc_light::{ backend::{Backend, GenesisOrUnavailableState}, blockchain::{Blockchain, BlockchainCache}, @@ -258,8 +258,9 @@ impl CallExecutor for DummyCallExecutor { } } -fn local_executor() -> NativeExecutor { - NativeExecutor::new(WasmExecutionMethod::Interpreted, None, 8) +fn local_executor() -> NativeElseWasmExecutor +{ + NativeElseWasmExecutor::new(WasmExecutionMethod::Interpreted, None, 8) } #[test] @@ -446,7 +447,7 @@ fn code_is_executed_at_genesis_only() { } type TestChecker = LightDataChecker< - NativeExecutor, + NativeElseWasmExecutor, Block, DummyStorage, >; diff --git a/client/service/test/src/client/mod.rs b/client/service/test/src/client/mod.rs index bd1f5be8d5cd4..295e941f7ceb1 100644 --- a/client/service/test/src/client/mod.rs +++ b/client/service/test/src/client/mod.rs @@ -62,9 +62,9 @@ mod light; const TEST_ENGINE_ID: ConsensusEngineId = *b"TEST"; -pub struct Executor; +pub struct ExecutorDispatch; -impl sc_executor::NativeExecutionDispatch for Executor { +impl sc_executor::NativeExecutionDispatch for ExecutorDispatch { type ExtendHostFunctions = (); fn dispatch(method: &str, data: &[u8]) -> Option> { @@ -76,14 +76,14 @@ impl sc_executor::NativeExecutionDispatch for Executor { } } -fn executor() -> sc_executor::NativeExecutor { - sc_executor::NativeExecutor::new(sc_executor::WasmExecutionMethod::Interpreted, None, 8) +fn executor() -> sc_executor::NativeElseWasmExecutor { + sc_executor::NativeElseWasmExecutor::new(sc_executor::WasmExecutionMethod::Interpreted, None, 8) } pub fn prepare_client_with_key_changes() -> ( client::Client< substrate_test_runtime_client::Backend, - substrate_test_runtime_client::Executor, + substrate_test_runtime_client::ExecutorDispatch, Block, RuntimeApi, >, @@ -2106,7 +2106,7 @@ fn cleans_up_closed_notification_sinks_on_block_import() { LocalCallExecutor< Block, in_mem::Backend, - sc_executor::NativeExecutor, + sc_executor::NativeElseWasmExecutor, >, substrate_test_runtime_client::runtime::Block, substrate_test_runtime_client::runtime::RuntimeApi, diff --git a/primitives/api/test/tests/decl_and_impl.rs b/primitives/api/test/tests/decl_and_impl.rs index ae24ed1cb8fec..8d1b04a37a9fa 100644 --- a/primitives/api/test/tests/decl_and_impl.rs +++ b/primitives/api/test/tests/decl_and_impl.rs @@ -136,7 +136,7 @@ mock_impl_runtime_apis! { type TestClient = substrate_test_runtime_client::client::Client< substrate_test_runtime_client::Backend, - substrate_test_runtime_client::Executor, + substrate_test_runtime_client::ExecutorDispatch, Block, RuntimeApi, >; diff --git a/primitives/api/test/tests/runtime_calls.rs b/primitives/api/test/tests/runtime_calls.rs index b0b14ec1e944e..101f92fd6c7d7 100644 --- a/primitives/api/test/tests/runtime_calls.rs +++ b/primitives/api/test/tests/runtime_calls.rs @@ -206,7 +206,11 @@ fn record_proof_works() { // Use the proof backend to execute `execute_block`. let mut overlay = Default::default(); - let executor = NativeExecutor::::new(WasmExecutionMethod::Interpreted, None, 8); + let executor = NativeElseWasmExecutor::::new( + WasmExecutionMethod::Interpreted, + None, + 8, + ); execution_proof_check_on_trie_backend::<_, u64, _, _>( &backend, &mut overlay, diff --git a/test-utils/client/src/lib.rs b/test-utils/client/src/lib.rs index 3eb7eb0b7174c..9bc411af5d3ed 100644 --- a/test-utils/client/src/lib.rs +++ b/test-utils/client/src/lib.rs @@ -27,7 +27,7 @@ pub use sc_client_api::{ BadBlocks, ForkBlocks, }; pub use sc_client_db::{self, Backend}; -pub use sc_executor::{self, NativeExecutor, WasmExecutionMethod}; +pub use sc_executor::{self, NativeElseWasmExecutor, WasmExecutionMethod}; pub use sc_service::{client, RpcHandlers, RpcSession}; pub use sp_consensus; pub use sp_keyring::{ @@ -73,14 +73,14 @@ impl GenesisInit for () { } /// A builder for creating a test client instance. -pub struct TestClientBuilder { +pub struct TestClientBuilder { execution_strategies: ExecutionStrategies, genesis_init: G, /// The key is an unprefixed storage key, this only contains /// default child trie content. child_storage_extension: HashMap, StorageChild>, backend: Arc, - _executor: std::marker::PhantomData, + _executor: std::marker::PhantomData, keystore: Option, fork_blocks: ForkBlocks, bad_blocks: BadBlocks, @@ -88,16 +88,16 @@ pub struct TestClientBuilder { no_genesis: bool, } -impl Default - for TestClientBuilder, G> +impl Default + for TestClientBuilder, G> { fn default() -> Self { Self::with_default_backend() } } -impl - TestClientBuilder, G> +impl + TestClientBuilder, G> { /// Create new `TestClientBuilder` with default backend. pub fn with_default_backend() -> Self { @@ -122,8 +122,8 @@ impl } } -impl - TestClientBuilder +impl + TestClientBuilder { /// Create a new instance of the test client builder. pub fn with_backend(backend: Arc) -> Self { @@ -210,13 +210,13 @@ impl /// Build the test client with the given native executor. pub fn build_with_executor( self, - executor: Executor, + executor: ExecutorDispatch, ) -> ( - client::Client, + client::Client, sc_consensus::LongestChain, ) where - Executor: sc_client_api::CallExecutor + 'static, + ExecutorDispatch: sc_client_api::CallExecutor + 'static, Backend: sc_client_api::backend::Backend, >::OffchainStorage: 'static, { @@ -264,8 +264,13 @@ impl } } -impl - TestClientBuilder>, Backend, G> +impl + TestClientBuilder< + Block, + client::LocalCallExecutor>, + Backend, + G, + > { /// Build the test client with the given native executor. pub fn build_with_native_executor( @@ -274,20 +279,20 @@ impl ) -> ( client::Client< Backend, - client::LocalCallExecutor>, + client::LocalCallExecutor>, Block, RuntimeApi, >, sc_consensus::LongestChain, ) where - I: Into>>, - E: sc_executor::NativeExecutionDispatch + 'static, + I: Into>>, + D: sc_executor::NativeExecutionDispatch + 'static, Backend: sc_client_api::backend::Backend + 'static, { - let executor = executor - .into() - .unwrap_or_else(|| NativeExecutor::new(WasmExecutionMethod::Interpreted, None, 8)); + let executor = executor.into().unwrap_or_else(|| { + NativeElseWasmExecutor::new(WasmExecutionMethod::Interpreted, None, 8) + }); let executor = LocalCallExecutor::new( self.backend.clone(), executor, diff --git a/test-utils/runtime/client/src/lib.rs b/test-utils/runtime/client/src/lib.rs index 00a8b9495fa6c..dc5ccadc4574f 100644 --- a/test-utils/runtime/client/src/lib.rs +++ b/test-utils/runtime/client/src/lib.rs @@ -51,8 +51,8 @@ pub mod prelude { }; // Client structs pub use super::{ - Backend, Executor, LightBackend, LightExecutor, LocalExecutor, NativeExecutor, TestClient, - TestClientBuilder, WasmExecutionMethod, + Backend, ExecutorDispatch, LightBackend, LightExecutor, LocalExecutorDispatch, + NativeElseWasmExecutor, TestClient, TestClientBuilder, WasmExecutionMethod, }; // Keyring pub use super::{AccountKeyring, Sr25519Keyring}; @@ -60,9 +60,9 @@ pub mod prelude { /// A unit struct which implements `NativeExecutionDispatch` feeding in the /// hard-coded runtime. -pub struct LocalExecutor; +pub struct LocalExecutorDispatch; -impl sc_executor::NativeExecutionDispatch for LocalExecutor { +impl sc_executor::NativeExecutionDispatch for LocalExecutorDispatch { type ExtendHostFunctions = (); fn dispatch(method: &str, data: &[u8]) -> Option> { @@ -78,10 +78,10 @@ impl sc_executor::NativeExecutionDispatch for LocalExecutor { pub type Backend = substrate_test_client::Backend; /// Test client executor. -pub type Executor = client::LocalCallExecutor< +pub type ExecutorDispatch = client::LocalCallExecutor< substrate_test_runtime::Block, Backend, - NativeExecutor, + NativeElseWasmExecutor, >; /// Test client light database backend. @@ -96,7 +96,7 @@ pub type LightExecutor = sc_light::GenesisCallExecutor< sc_client_db::light::LightStorage, HashFor, >, - NativeExecutor, + NativeElseWasmExecutor, >, >; @@ -174,13 +174,13 @@ pub type TestClientBuilder = substrate_test_client::TestClientBuilder< GenesisParameters, >; -/// Test client type with `LocalExecutor` and generic Backend. +/// Test client type with `LocalExecutorDispatch` and generic Backend. pub type Client = client::Client< B, client::LocalCallExecutor< substrate_test_runtime::Block, B, - sc_executor::NativeExecutor, + sc_executor::NativeElseWasmExecutor, >, substrate_test_runtime::Block, substrate_test_runtime::RuntimeApi, @@ -195,7 +195,7 @@ pub trait DefaultTestClientBuilderExt: Sized { fn new() -> Self; } -impl DefaultTestClientBuilderExt for TestClientBuilder { +impl DefaultTestClientBuilderExt for TestClientBuilder { fn new() -> Self { Self::with_default_backend() } @@ -277,7 +277,7 @@ impl TestClientBuilderExt client::LocalCallExecutor< substrate_test_runtime::Block, B, - sc_executor::NativeExecutor, + sc_executor::NativeElseWasmExecutor, >, B, > where @@ -436,6 +436,6 @@ pub fn new_light_fetcher() -> LightFetcher { } /// Create a new native executor. -pub fn new_native_executor() -> sc_executor::NativeExecutor { - sc_executor::NativeExecutor::new(sc_executor::WasmExecutionMethod::Interpreted, None, 8) +pub fn new_native_executor() -> sc_executor::NativeElseWasmExecutor { + sc_executor::NativeElseWasmExecutor::new(sc_executor::WasmExecutionMethod::Interpreted, None, 8) } diff --git a/test-utils/runtime/src/system.rs b/test-utils/runtime/src/system.rs index 15f1a2e654dc8..334569d055a0c 100644 --- a/test-utils/runtime/src/system.rs +++ b/test-utils/runtime/src/system.rs @@ -349,7 +349,7 @@ mod tests { use super::*; use crate::{wasm_binary_unwrap, Header, Transfer}; - use sc_executor::{NativeExecutor, WasmExecutionMethod}; + use sc_executor::{NativeElseWasmExecutor, WasmExecutionMethod}; use sp_core::{ map, traits::{CodeExecutor, RuntimeCode}, @@ -373,8 +373,8 @@ mod tests { } } - fn executor() -> NativeExecutor { - NativeExecutor::new(WasmExecutionMethod::Interpreted, None, 8) + fn executor() -> NativeElseWasmExecutor { + NativeElseWasmExecutor::new(WasmExecutionMethod::Interpreted, None, 8) } fn new_test_ext() -> TestExternalities { diff --git a/test-utils/test-runner/src/client.rs b/test-utils/test-runner/src/client.rs index 80b11e7bff7fc..6622c1f919428 100644 --- a/test-utils/test-runner/src/client.rs +++ b/test-utils/test-runner/src/client.rs @@ -26,6 +26,7 @@ use manual_seal::{ run_manual_seal, EngineCommand, ManualSealParams, }; use sc_client_api::backend::Backend; +use sc_executor::NativeElseWasmExecutor; use sc_service::{ build_network, new_full_parts, spawn_tasks, BuildNetworkParams, ChainSpec, Configuration, SpawnTasksParams, TFullBackend, TFullClient, TaskExecutor, TaskManager, @@ -50,7 +51,7 @@ type ClientParts = ( TFullClient< ::Block, ::RuntimeApi, - ::Executor, + NativeElseWasmExecutor<::ExecutorDispatch>, >, >, Arc< @@ -83,7 +84,7 @@ where T: ChainInfo + 'static, , + TFullClient>, >>::RuntimeApi: Core + Metadata + OffchainWorkerApi @@ -106,8 +107,14 @@ where default_config(task_executor, chain_spec), }; + let executor = NativeElseWasmExecutor::::new( + config.wasm_method, + config.default_heap_pages, + config.max_runtime_instances, + ); + let (client, backend, keystore, mut task_manager) = - new_full_parts::(&config, None)?; + new_full_parts::(&config, None, executor)?; let client = Arc::new(client); let select_chain = sc_consensus::LongestChain::new(backend.clone()); diff --git a/test-utils/test-runner/src/lib.rs b/test-utils/test-runner/src/lib.rs index 4f5f20a8f3985..ca2c518fd6926 100644 --- a/test-utils/test-runner/src/lib.rs +++ b/test-utils/test-runner/src/lib.rs @@ -62,9 +62,9 @@ //! //! type BlockImport = BabeBlockImport>; //! -//! pub struct Executor; +//! pub struct ExecutorDispatch; //! -//! impl sc_executor::NativeExecutionDispatch for Executor { +//! impl sc_executor::NativeExecutionDispatch for ExecutorDispatch { //! type ExtendHostFunctions = SignatureVerificationOverride; //! //! fn dispatch(method: &str, data: &[u8]) -> Option> { @@ -81,8 +81,8 @@ //! impl ChainInfo for Requirements { //! /// Provide a Block type with an OpaqueExtrinsic //! type Block = node_primitives::Block; -//! /// Provide an Executor type for the runtime -//! type Executor = Executor; +//! /// Provide an ExecutorDispatch type for the runtime +//! type ExecutorDispatch = ExecutorDispatch; //! /// Provide the runtime itself //! type Runtime = node_runtime::Runtime; //! /// A touch of runtime api @@ -93,7 +93,7 @@ //! type BlockImport = BlockImport< //! Self::Block, //! TFullBackend, -//! TFullClient, +//! TFullClient>, //! Self::SelectChain, //! >; //! /// and a dash of SignedExtensions @@ -119,7 +119,7 @@ //! /// The function signature tells you all you need to know. ;) //! fn create_client_parts(config: &Configuration) -> Result< //! ( -//! Arc>, +//! Arc>>, //! Arc>, //! KeyStorePtr, //! TaskManager, @@ -128,7 +128,7 @@ //! dyn ConsensusDataProvider< //! Self::Block, //! Transaction = TransactionFor< -//! TFullClient, +//! TFullClient>, //! Self::Block //! >, //! > @@ -143,7 +143,7 @@ //! backend, //! keystore, //! task_manager, -//! ) = new_full_parts::(config)?; +//! ) = new_full_parts::>(config)?; //! let client = Arc::new(client); //! //! let inherent_providers = InherentDataProviders::new(); @@ -235,7 +235,7 @@ //! ``` use sc_consensus::BlockImport; -use sc_executor::NativeExecutionDispatch; +use sc_executor::{NativeElseWasmExecutor, NativeExecutionDispatch}; use sc_service::TFullClient; use sp_api::{ConstructRuntimeApi, TransactionFor}; use sp_consensus::SelectChain; @@ -257,8 +257,8 @@ pub trait ChainInfo: Sized { /// Opaque block type type Block: BlockT; - /// Executor type - type Executor: NativeExecutionDispatch + 'static; + /// ExecutorDispatch dispatch type + type ExecutorDispatch: NativeExecutionDispatch + 'static; /// Runtime type Runtime: frame_system::Config; @@ -267,7 +267,14 @@ pub trait ChainInfo: Sized { type RuntimeApi: Send + Sync + 'static - + ConstructRuntimeApi>; + + ConstructRuntimeApi< + Self::Block, + TFullClient< + Self::Block, + Self::RuntimeApi, + NativeElseWasmExecutor, + >, + >; /// select chain type. type SelectChain: SelectChain + 'static; @@ -280,7 +287,11 @@ pub trait ChainInfo: Sized { Self::Block, Error = sp_consensus::Error, Transaction = TransactionFor< - TFullClient, + TFullClient< + Self::Block, + Self::RuntimeApi, + NativeElseWasmExecutor, + >, Self::Block, >, > + 'static; diff --git a/test-utils/test-runner/src/node.rs b/test-utils/test-runner/src/node.rs index c76e20648d117..9114013b747f7 100644 --- a/test-utils/test-runner/src/node.rs +++ b/test-utils/test-runner/src/node.rs @@ -29,6 +29,7 @@ use sc_client_api::{ backend::{self, Backend}, CallExecutor, ExecutorProvider, }; +use sc_executor::NativeElseWasmExecutor; use sc_service::{TFullBackend, TFullCallExecutor, TFullClient, TaskManager}; use sc_transaction_pool_api::TransactionPool; use sp_api::{OverlayedChanges, StorageTransactionCache}; @@ -51,7 +52,7 @@ pub struct Node { /// handle to the running node. task_manager: Option, /// client instance - client: Arc>, + client: Arc>>, /// transaction pool pool: Arc< dyn TransactionPool< @@ -86,7 +87,9 @@ where pub fn new( rpc_handler: Arc>, task_manager: TaskManager, - client: Arc>, + client: Arc< + TFullClient>, + >, pool: Arc< dyn TransactionPool< Block = ::Block, @@ -126,7 +129,9 @@ where } /// Return a reference to the Client - pub fn client(&self) -> Arc> { + pub fn client( + &self, + ) -> Arc>> { self.client.clone() } @@ -150,7 +155,7 @@ where /// Executes closure in an externalities provided environment. pub fn with_state(&self, closure: impl FnOnce() -> R) -> R where - as CallExecutor>::Error: + > as CallExecutor>::Error: std::fmt::Debug, { let id = BlockId::Hash(self.client.info().best_hash); diff --git a/utils/frame/benchmarking-cli/src/command.rs b/utils/frame/benchmarking-cli/src/command.rs index 671386a721a02..7ba714abe3556 100644 --- a/utils/frame/benchmarking-cli/src/command.rs +++ b/utils/frame/benchmarking-cli/src/command.rs @@ -25,7 +25,7 @@ use frame_support::traits::StorageInfo; use linked_hash_map::LinkedHashMap; use sc_cli::{CliConfiguration, ExecutionStrategy, Result, SharedParams}; use sc_client_db::BenchmarkingState; -use sc_executor::NativeExecutor; +use sc_executor::NativeElseWasmExecutor; use sc_service::{Configuration, NativeExecutionDispatch}; use sp_core::offchain::{ testing::{TestOffchainExt, TestTransactionPoolExt}, @@ -133,7 +133,7 @@ impl BenchmarkCmd { )?; let state_without_tracking = BenchmarkingState::::new(genesis_storage, cache_size, self.record_proof, false)?; - let executor = NativeExecutor::::new( + let executor = NativeElseWasmExecutor::::new( wasm_method, self.heap_pages, 2, // The runtime instances cache size. diff --git a/utils/frame/try-runtime/cli/src/lib.rs b/utils/frame/try-runtime/cli/src/lib.rs index 1f1eef70e1b93..047829d94da66 100644 --- a/utils/frame/try-runtime/cli/src/lib.rs +++ b/utils/frame/try-runtime/cli/src/lib.rs @@ -21,7 +21,7 @@ use parity_scale_codec::{Decode, Encode}; use remote_externalities::{rpc_api, Builder, Mode, OfflineConfig, OnlineConfig, SnapshotConfig}; use sc_chain_spec::ChainSpec; use sc_cli::{CliConfiguration, ExecutionStrategy, WasmExecutionMethod}; -use sc_executor::NativeExecutor; +use sc_executor::NativeElseWasmExecutor; use sc_service::{Configuration, NativeExecutionDispatch}; use sp_core::{ hashing::twox_128, @@ -192,8 +192,11 @@ where let mut changes = Default::default(); let max_runtime_instances = config.max_runtime_instances; - let executor = - NativeExecutor::::new(wasm_method.into(), heap_pages, max_runtime_instances); + let executor = NativeElseWasmExecutor::::new( + wasm_method.into(), + heap_pages, + max_runtime_instances, + ); let ext = { let builder = match command.state { @@ -265,8 +268,11 @@ where let mut changes = Default::default(); let max_runtime_instances = config.max_runtime_instances; - let executor = - NativeExecutor::::new(wasm_method.into(), heap_pages, max_runtime_instances); + let executor = NativeElseWasmExecutor::::new( + wasm_method.into(), + heap_pages, + max_runtime_instances, + ); let mode = match command.state { State::Live { snapshot_path, modules } => { @@ -346,8 +352,11 @@ where let mut changes = Default::default(); let max_runtime_instances = config.max_runtime_instances; - let executor = - NativeExecutor::::new(wasm_method.into(), heap_pages, max_runtime_instances); + let executor = NativeElseWasmExecutor::::new( + wasm_method.into(), + heap_pages, + max_runtime_instances, + ); let block_hash = shared.block_at::()?; let block: Block = rpc_api::get_block::(shared.url.clone(), block_hash).await?;