Remove the wasmtime feature flag (#12684)

* Remove the `wasmtime` feature flag

* rustfmt
This commit is contained in:
Koute
2022-11-18 22:21:44 +09:00
committed by GitHub
parent 970354cecc
commit 4214bc527c
17 changed files with 20 additions and 126 deletions
+1 -2
View File
@@ -23,7 +23,7 @@ wasmi = "0.13"
codec = { package = "parity-scale-codec", version = "3.0.0" }
sc-executor-common = { version = "0.10.0-dev", path = "common" }
sc-executor-wasmi = { version = "0.10.0-dev", path = "wasmi" }
sc-executor-wasmtime = { version = "0.10.0-dev", path = "wasmtime", optional = true }
sc-executor-wasmtime = { version = "0.10.0-dev", path = "wasmtime" }
sp-api = { version = "4.0.0-dev", path = "../../primitives/api" }
sp-core = { version = "7.0.0", path = "../../primitives/core" }
sp-core-hashing-proc-macro = { version = "5.0.0", path = "../../primitives/core/hashing/proc-macro" }
@@ -61,5 +61,4 @@ default = ["std"]
# This crate does not have `no_std` support, we just require this for tests
std = []
wasm-extern-trace = []
wasmtime = ["sc-executor-wasmtime"]
wasmer-sandbox = ["sc-executor-common/wasmer-sandbox"]
+1 -14
View File
@@ -23,7 +23,6 @@ use sc_executor_common::{
runtime_blob::RuntimeBlob,
wasm_runtime::{WasmInstance, WasmModule},
};
#[cfg(feature = "wasmtime")]
use sc_executor_wasmtime::InstantiationStrategy;
use sc_runtime_test::wasm_binary_unwrap as test_runtime;
use sp_wasm_interface::HostFunctions as _;
@@ -35,11 +34,7 @@ use std::sync::{
#[derive(Clone)]
enum Method {
Interpreted,
#[cfg(feature = "wasmtime")]
Compiled {
instantiation_strategy: InstantiationStrategy,
precompile: bool,
},
Compiled { instantiation_strategy: InstantiationStrategy, precompile: bool },
}
// This is just a bog-standard Kusama runtime with an extra
@@ -67,7 +62,6 @@ fn initialize(
allow_missing_func_imports,
)
.map(|runtime| -> Arc<dyn WasmModule> { Arc::new(runtime) }),
#[cfg(feature = "wasmtime")]
Method::Compiled { instantiation_strategy, precompile } => {
let config = sc_executor_wasmtime::Config {
allow_missing_func_imports,
@@ -163,7 +157,6 @@ fn bench_call_instance(c: &mut Criterion) {
let _ = env_logger::try_init();
let strategies = [
#[cfg(feature = "wasmtime")]
(
"legacy_instance_reuse",
Method::Compiled {
@@ -171,7 +164,6 @@ fn bench_call_instance(c: &mut Criterion) {
precompile: false,
},
),
#[cfg(feature = "wasmtime")]
(
"recreate_instance_vanilla",
Method::Compiled {
@@ -179,7 +171,6 @@ fn bench_call_instance(c: &mut Criterion) {
precompile: false,
},
),
#[cfg(feature = "wasmtime")]
(
"recreate_instance_cow_fresh",
Method::Compiled {
@@ -187,7 +178,6 @@ fn bench_call_instance(c: &mut Criterion) {
precompile: false,
},
),
#[cfg(feature = "wasmtime")]
(
"recreate_instance_cow_precompiled",
Method::Compiled {
@@ -195,7 +185,6 @@ fn bench_call_instance(c: &mut Criterion) {
precompile: true,
},
),
#[cfg(feature = "wasmtime")]
(
"pooling_vanilla",
Method::Compiled {
@@ -203,7 +192,6 @@ fn bench_call_instance(c: &mut Criterion) {
precompile: false,
},
),
#[cfg(feature = "wasmtime")]
(
"pooling_cow_fresh",
Method::Compiled {
@@ -211,7 +199,6 @@ fn bench_call_instance(c: &mut Criterion) {
precompile: false,
},
),
#[cfg(feature = "wasmtime")]
(
"pooling_cow_precompiled",
Method::Compiled {
@@ -18,11 +18,6 @@
//! Tests that are only relevant for Linux.
// Constrain this only to wasmtime for the time being. Without this rustc will complain on unused
// imports and items. The alternative is to plop `cfg(feature = wasmtime)` everywhere which seems
// borthersome.
#![cfg(feature = "wasmtime")]
use super::mk_test_runtime;
use crate::WasmExecutionMethod;
use codec::Encode as _;
@@ -52,7 +52,6 @@ macro_rules! test_wasm_execution {
}
#[test]
#[cfg(feature = "wasmtime")]
fn [<$method_name _compiled_recreate_instance_cow>]() {
$method_name(WasmExecutionMethod::Compiled {
instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy::RecreateInstanceCopyOnWrite
@@ -60,7 +59,6 @@ macro_rules! test_wasm_execution {
}
#[test]
#[cfg(feature = "wasmtime")]
fn [<$method_name _compiled_recreate_instance_vanilla>]() {
$method_name(WasmExecutionMethod::Compiled {
instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy::RecreateInstance
@@ -68,7 +66,6 @@ macro_rules! test_wasm_execution {
}
#[test]
#[cfg(feature = "wasmtime")]
fn [<$method_name _compiled_pooling_cow>]() {
$method_name(WasmExecutionMethod::Compiled {
instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy::PoolingCopyOnWrite
@@ -76,7 +73,6 @@ macro_rules! test_wasm_execution {
}
#[test]
#[cfg(feature = "wasmtime")]
fn [<$method_name _compiled_pooling_vanilla>]() {
$method_name(WasmExecutionMethod::Compiled {
instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy::Pooling
@@ -84,7 +80,6 @@ macro_rules! test_wasm_execution {
}
#[test]
#[cfg(feature = "wasmtime")]
fn [<$method_name _compiled_legacy_instance_reuse>]() {
$method_name(WasmExecutionMethod::Compiled {
instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy::LegacyInstanceReuse
@@ -120,7 +115,6 @@ macro_rules! test_wasm_execution_sandbox {
}
#[test]
#[cfg(feature = "wasmtime")]
fn [<$method_name _compiled_pooling_cow_host_executor>]() {
$method_name(WasmExecutionMethod::Compiled {
instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy::PoolingCopyOnWrite
@@ -128,7 +122,6 @@ macro_rules! test_wasm_execution_sandbox {
}
#[test]
#[cfg(feature = "wasmtime")]
fn [<$method_name _compiled_pooling_cow_embedded_executor>]() {
$method_name(WasmExecutionMethod::Compiled {
instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy::PoolingCopyOnWrite
@@ -136,7 +129,6 @@ macro_rules! test_wasm_execution_sandbox {
}
#[test]
#[cfg(feature = "wasmtime")]
fn [<$method_name _compiled_pooling_vanilla_host_executor>]() {
$method_name(WasmExecutionMethod::Compiled {
instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy::Pooling
@@ -144,7 +136,6 @@ macro_rules! test_wasm_execution_sandbox {
}
#[test]
#[cfg(feature = "wasmtime")]
fn [<$method_name _compiled_pooling_vanilla_embedded_executor>]() {
$method_name(WasmExecutionMethod::Compiled {
instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy::Pooling
@@ -152,7 +143,6 @@ macro_rules! test_wasm_execution_sandbox {
}
#[test]
#[cfg(feature = "wasmtime")]
fn [<$method_name _compiled_recreate_instance_cow_host_executor>]() {
$method_name(WasmExecutionMethod::Compiled {
instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy::RecreateInstanceCopyOnWrite
@@ -160,7 +150,6 @@ macro_rules! test_wasm_execution_sandbox {
}
#[test]
#[cfg(feature = "wasmtime")]
fn [<$method_name _compiled_recreate_instance_cow_embedded_executor>]() {
$method_name(WasmExecutionMethod::Compiled {
instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy::RecreateInstanceCopyOnWrite
@@ -168,7 +157,6 @@ macro_rules! test_wasm_execution_sandbox {
}
#[test]
#[cfg(feature = "wasmtime")]
fn [<$method_name _compiled_recreate_instance_vanilla_host_executor>]() {
$method_name(WasmExecutionMethod::Compiled {
instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy::RecreateInstance
@@ -176,7 +164,6 @@ macro_rules! test_wasm_execution_sandbox {
}
#[test]
#[cfg(feature = "wasmtime")]
fn [<$method_name _compiled_recreate_instance_vanilla_embedded_executor>]() {
$method_name(WasmExecutionMethod::Compiled {
instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy::RecreateInstance
@@ -184,7 +171,6 @@ macro_rules! test_wasm_execution_sandbox {
}
#[test]
#[cfg(feature = "wasmtime")]
fn [<$method_name _compiled_legacy_instance_reuse_host_executor>]() {
$method_name(WasmExecutionMethod::Compiled {
instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy::LegacyInstanceReuse
@@ -192,7 +178,6 @@ macro_rules! test_wasm_execution_sandbox {
}
#[test]
#[cfg(feature = "wasmtime")]
fn [<$method_name _compiled_legacy_instance_reuse_embedded_executor>]() {
$method_name(WasmExecutionMethod::Compiled {
instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy::LegacyInstanceReuse
@@ -253,7 +238,6 @@ fn call_not_existing_function(wasm_method: WasmExecutionMethod) {
Error::AbortedDueToTrap(error) => {
let expected = match wasm_method {
WasmExecutionMethod::Interpreted => "Other: Function `missing_external` is only a stub. Calling a stub is not allowed.",
#[cfg(feature = "wasmtime")]
WasmExecutionMethod::Compiled { .. } => "call to a missing function env:missing_external"
};
assert_eq!(error.message, expected);
@@ -273,7 +257,6 @@ fn call_yet_another_not_existing_function(wasm_method: WasmExecutionMethod) {
Error::AbortedDueToTrap(error) => {
let expected = match wasm_method {
WasmExecutionMethod::Interpreted => "Other: Function `yet_another_missing_external` is only a stub. Calling a stub is not allowed.",
#[cfg(feature = "wasmtime")]
WasmExecutionMethod::Compiled { .. } => "call to a missing function env:yet_another_missing_external"
};
assert_eq!(error.message, expected);
@@ -577,7 +560,6 @@ fn should_trap_when_heap_exhausted(wasm_method: WasmExecutionMethod) {
.unwrap_err();
match err {
#[cfg(feature = "wasmtime")]
Error::AbortedDueToTrap(error)
if matches!(wasm_method, WasmExecutionMethod::Compiled { .. }) =>
{
@@ -886,8 +868,8 @@ fn unreachable_intrinsic(wasm_method: WasmExecutionMethod) {
Error::AbortedDueToTrap(error) => {
let expected = match wasm_method {
WasmExecutionMethod::Interpreted => "unreachable",
#[cfg(feature = "wasmtime")]
WasmExecutionMethod::Compiled { .. } => "wasm trap: wasm `unreachable` instruction executed",
WasmExecutionMethod::Compiled { .. } =>
"wasm trap: wasm `unreachable` instruction executed",
};
assert_eq!(error.message, expected);
},
-2
View File
@@ -50,8 +50,6 @@ pub use wasm_runtime::{read_embedded_version, WasmExecutionMethod};
pub use wasmi;
pub use sc_executor_common::{error, sandbox};
#[cfg(feature = "wasmtime")]
pub use sc_executor_wasmtime::InstantiationStrategy as WasmtimeInstantiationStrategy;
/// Extracts the runtime version of a given runtime code.
@@ -46,7 +46,6 @@ pub enum WasmExecutionMethod {
/// Uses the Wasmi interpreter.
Interpreted,
/// Uses the Wasmtime compiled runtime.
#[cfg(feature = "wasmtime")]
Compiled {
/// The instantiation strategy to use.
instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy,
@@ -314,7 +313,6 @@ where
)
.map(|runtime| -> Arc<dyn WasmModule> { Arc::new(runtime) })
},
#[cfg(feature = "wasmtime")]
WasmExecutionMethod::Compiled { instantiation_strategy } =>
sc_executor_wasmtime::create_runtime::<H>(
blob,
@@ -33,7 +33,7 @@ sc-allocator = { version = "4.1.0-dev", path = "../../allocator" }
sc-executor-common = { version = "0.10.0-dev", path = "../common" }
sp-runtime-interface = { version = "7.0.0", path = "../../../primitives/runtime-interface" }
sp-sandbox = { version = "0.10.0-dev", path = "../../../primitives/sandbox" }
sp-wasm-interface = { version = "7.0.0", features = ["wasmtime"], path = "../../../primitives/wasm-interface" }
sp-wasm-interface = { version = "7.0.0", path = "../../../primitives/wasm-interface" }
# Here we include the rustix crate in the exactly same semver-compatible version as used by
# wasmtime and enable its 'use-libc' flag.