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
@@ -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<Block> for DummyCallExecutor {
}
}
fn local_executor() -> NativeExecutor<substrate_test_runtime_client::LocalExecutor> {
NativeExecutor::new(WasmExecutionMethod::Interpreted, None, 8)
fn local_executor() -> NativeElseWasmExecutor<substrate_test_runtime_client::LocalExecutorDispatch>
{
NativeElseWasmExecutor::new(WasmExecutionMethod::Interpreted, None, 8)
}
#[test]
@@ -446,7 +447,7 @@ fn code_is_executed_at_genesis_only() {
}
type TestChecker = LightDataChecker<
NativeExecutor<substrate_test_runtime_client::LocalExecutor>,
NativeElseWasmExecutor<substrate_test_runtime_client::LocalExecutorDispatch>,
Block,
DummyStorage,
>;
@@ -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<Vec<u8>> {
@@ -76,14 +76,14 @@ impl sc_executor::NativeExecutionDispatch for Executor {
}
}
fn executor() -> sc_executor::NativeExecutor<Executor> {
sc_executor::NativeExecutor::new(sc_executor::WasmExecutionMethod::Interpreted, None, 8)
fn executor() -> sc_executor::NativeElseWasmExecutor<ExecutorDispatch> {
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<Block>,
sc_executor::NativeExecutor<LocalExecutor>,
sc_executor::NativeElseWasmExecutor<LocalExecutorDispatch>,
>,
substrate_test_runtime_client::runtime::Block,
substrate_test_runtime_client::runtime::RuntimeApi,