Make choosing an executor (native/wasm) an explicit part of service construction (#9525)

* Split native executor stuff from wasm executor stuff

* Remove `native_runtime_version` in places

* Fix warning

* Fix test warning

* Remove redundant NativeRuntimeInfo trait

* Add a warning for use_native

* Run cargo fmt

* Revert "Add a warning for use_native"

This reverts commit 9494f765a06037e991dd60524f2ed1b14649bfd6.

* Make choosing an executor (native/wasm) an explicit part of service construction

* Add Cargo.lock

* Rename Executor to ExecutorDispatch

* Update bin/node/executor/src/lib.rs

Co-authored-by: Squirrel <gilescope@gmail.com>

* Fix tests

* Fix minor node-executor error

* Fix node cli command thing

Co-authored-by: Squirrel <gilescope@gmail.com>
This commit is contained in:
Ashley
2021-08-18 14:26:41 +02:00
committed by GitHub
parent 2de7e51c2a
commit bad4544507
33 changed files with 271 additions and 186 deletions
+10 -3
View File
@@ -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<T> = (
TFullClient<
<T as ChainInfo>::Block,
<T as ChainInfo>::RuntimeApi,
<T as ChainInfo>::Executor,
NativeElseWasmExecutor<<T as ChainInfo>::ExecutorDispatch>,
>,
>,
Arc<
@@ -83,7 +84,7 @@ where
T: ChainInfo + 'static,
<T::RuntimeApi as ConstructRuntimeApi<
T::Block,
TFullClient<T::Block, T::RuntimeApi, T::Executor>,
TFullClient<T::Block, T::RuntimeApi, NativeElseWasmExecutor<T::ExecutorDispatch>>,
>>::RuntimeApi: Core<T::Block>
+ Metadata<T::Block>
+ OffchainWorkerApi<T::Block>
@@ -106,8 +107,14 @@ where
default_config(task_executor, chain_spec),
};
let executor = NativeElseWasmExecutor::<T::ExecutorDispatch>::new(
config.wasm_method,
config.default_heap_pages,
config.max_runtime_instances,
);
let (client, backend, keystore, mut task_manager) =
new_full_parts::<T::Block, T::RuntimeApi, T::Executor>(&config, None)?;
new_full_parts::<T::Block, T::RuntimeApi, _>(&config, None, executor)?;
let client = Arc::new(client);
let select_chain = sc_consensus::LongestChain::new(backend.clone());