From 8192248c5202a0586566e5fa4ef0bac656c5a090 Mon Sep 17 00:00:00 2001 From: Robert Habermeier <rphmeier@gmail.com> Date: Fri, 15 Jan 2021 12:03:22 -0500 Subject: [PATCH] Switch to Wasmtime for parachain execution (#2265) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Switch to Wasmtime for parachain execution * Fix the signature for halt's validate_block * wasmtime feature enabled from cli * Adds missing feature Co-authored-by: Sergei Shulepov <sergei@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de> --- polkadot/cli/Cargo.toml | 2 +- polkadot/parachain/Cargo.toml | 1 + polkadot/parachain/src/wasm_executor/mod.rs | 3 +++ polkadot/parachain/test-parachains/halt/src/lib.rs | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/polkadot/cli/Cargo.toml b/polkadot/cli/Cargo.toml index 8b43b52ce3a..50d9a871da6 100644 --- a/polkadot/cli/Cargo.toml +++ b/polkadot/cli/Cargo.toml @@ -40,7 +40,7 @@ substrate-build-script-utils = { git = "https://github.com/paritytech/substrate" [features] default = [ "wasmtime", "db", "cli", "full-node", "trie-memory-tracker", "polkadot-parachain" ] -wasmtime = [ "sc-cli/wasmtime" ] +wasmtime = [ "sc-cli/wasmtime", "polkadot-parachain/wasmtime" ] db = [ "service/db" ] cli = [ "structopt", diff --git a/polkadot/parachain/Cargo.toml b/polkadot/parachain/Cargo.toml index 683828ce03b..58cf4b0d104 100644 --- a/polkadot/parachain/Cargo.toml +++ b/polkadot/parachain/Cargo.toml @@ -32,6 +32,7 @@ shared_memory = { version = "0.10.0", optional = true } [features] default = ["std"] +wasmtime = [ "sc-executor/wasmtime" ] wasm-api = [] std = [ "parity-scale-codec/std", diff --git a/polkadot/parachain/src/wasm_executor/mod.rs b/polkadot/parachain/src/wasm_executor/mod.rs index ba7e516f426..90c689f4905 100644 --- a/polkadot/parachain/src/wasm_executor/mod.rs +++ b/polkadot/parachain/src/wasm_executor/mod.rs @@ -198,6 +198,9 @@ pub fn validate_candidate_internal( spawner: impl SpawnNamed + 'static, ) -> Result<ValidationResult, ValidationError> { let executor = sc_executor::WasmExecutor::new( + #[cfg(all(feature = "wasmtime", not(any(target_os = "android", target_os = "unknown"))))] + sc_executor::WasmExecutionMethod::Compiled, + #[cfg(any(not(feature = "wasmtime"), target_os = "android", target_os = "unknown"))] sc_executor::WasmExecutionMethod::Interpreted, // TODO: Make sure we don't use more than 1GB: https://github.com/paritytech/polkadot/issues/699 Some(1024), diff --git a/polkadot/parachain/test-parachains/halt/src/lib.rs b/polkadot/parachain/test-parachains/halt/src/lib.rs index b82a649e3f1..00314033a4d 100644 --- a/polkadot/parachain/test-parachains/halt/src/lib.rs +++ b/polkadot/parachain/test-parachains/halt/src/lib.rs @@ -50,6 +50,6 @@ pub fn oom(_: core::alloc::Layout) -> ! { #[cfg(not(feature = "std"))] #[no_mangle] -pub extern fn validate_block(params: *const u8, len: usize) -> usize { +pub extern fn validate_block(params: *const u8, len: usize) -> u64 { loop {} } -- GitLab