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
@@ -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::<ExecDispatch>::new(wasm_method.into(), heap_pages, max_runtime_instances);
let executor = NativeElseWasmExecutor::<ExecDispatch>::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::<ExecDispatch>::new(wasm_method.into(), heap_pages, max_runtime_instances);
let executor = NativeElseWasmExecutor::<ExecDispatch>::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::<ExecDispatch>::new(wasm_method.into(), heap_pages, max_runtime_instances);
let executor = NativeElseWasmExecutor::<ExecDispatch>::new(
wasm_method.into(),
heap_pages,
max_runtime_instances,
);
let block_hash = shared.block_at::<Block>()?;
let block: Block = rpc_api::get_block::<Block, _>(shared.url.clone(), block_hash).await?;