Refactor NativeExecutor to support multiple Wasm execution methods (#3677)

* executor: Move definitions of externals out of wasm_executor module.

* executor: Create WasmRuntime trait.

This will be used to decouple the runtime cache from wasmi execution.

* executor: Remove WasmExecutor and move methods to wasmi_execution.

These will now be crate-internal functions and there is no need
for the struct.

* executor: Set default default_heap_pages in NativeExecutor.

* cli: CLI configuration for Wasm execution method.

* executor: Remove wasmi-specific code from wasm_runtime.

* Respond to review comments.
This commit is contained in:
Jim Posen
2019-10-08 12:57:12 +02:00
committed by GitHub
parent 2c77262c8f
commit 6cebbbf8b2
22 changed files with 1359 additions and 1237 deletions
+8 -2
View File
@@ -167,7 +167,10 @@ where TGen: RuntimeGenesis, TCSExt: Extension {
pruning: config.pruning.clone(),
};
let executor = NativeExecutor::<TExecDisp>::new(config.default_heap_pages);
let executor = NativeExecutor::<TExecDisp>::new(
config.wasm_method,
config.default_heap_pages,
);
let fork_blocks = config.chain_spec
.extensions()
@@ -239,7 +242,10 @@ where TGen: RuntimeGenesis, TCSExt: Extension {
pruning: config.pruning.clone(),
};
let executor = NativeExecutor::<TExecDisp>::new(config.default_heap_pages);
let executor = NativeExecutor::<TExecDisp>::new(
config.wasm_method,
config.default_heap_pages,
);
let db_storage = client_db::light::LightStorage::new(db_settings)?;
let light_blockchain = client::light::new_light_blockchain(db_storage);
+4
View File
@@ -19,6 +19,7 @@
pub use client::ExecutionStrategies;
pub use client_db::PruningMode;
pub use network::config::{ExtTransport, NetworkConfiguration, Roles};
pub use substrate_executor::WasmExecutionMethod;
use std::{path::PathBuf, net::SocketAddr};
use transaction_pool;
@@ -60,6 +61,8 @@ pub struct Configuration<C, G, E = NoExtension> {
pub custom: C,
/// Node name.
pub name: String,
/// Wasm execution method.
pub wasm_method: WasmExecutionMethod,
/// Execution strategies.
pub execution_strategies: ExecutionStrategies,
/// RPC over HTTP binding address. `None` if disabled.
@@ -116,6 +119,7 @@ impl<C, G, E> Configuration<C, G, E> where
state_cache_child_ratio: Default::default(),
custom: Default::default(),
pruning: PruningMode::default(),
wasm_method: WasmExecutionMethod::Interpreted,
execution_strategies: Default::default(),
rpc_http: None,
rpc_ws: None,