Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Remove the wasmtime feature flag #12684

Merged
merged 4 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bin/node-template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ name = "node-template"
[dependencies]
clap = { version = "4.0.9", features = ["derive"] }

sc-cli = { version = "0.10.0-dev", path = "../../../client/cli", features = ["wasmtime"] }
sc-cli = { version = "0.10.0-dev", path = "../../../client/cli" }
sp-core = { version = "7.0.0", path = "../../../primitives/core" }
sc-executor = { version = "0.10.0-dev", path = "../../../client/executor", features = ["wasmtime"] }
sc-service = { version = "0.10.0-dev", path = "../../../client/service", features = ["wasmtime"] }
sc-executor = { version = "0.10.0-dev", path = "../../../client/executor" }
sc-service = { version = "0.10.0-dev", path = "../../../client/service" }
sc-telemetry = { version = "4.0.0-dev", path = "../../../client/telemetry" }
sc-keystore = { version = "4.0.0-dev", path = "../../../client/keystore" }
sc-transaction-pool = { version = "4.0.0-dev", path = "../../../client/transaction-pool" }
Expand Down
5 changes: 0 additions & 5 deletions bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ try-runtime-cli = { version = "0.10.0-dev", optional = true, path = "../../../ut
serde_json = "1.0.85"

[target.'cfg(any(target_arch="x86_64", target_arch="aarch64"))'.dependencies]
node-executor = { version = "3.0.0-dev", path = "../executor", features = ["wasmtime"] }
sc-cli = { version = "0.10.0-dev", optional = true, path = "../../../client/cli", features = ["wasmtime"] }
sc-service = { version = "0.10.0-dev", default-features = false, path = "../../../client/service", features = [
"wasmtime",
] }
sp-trie = { version = "7.0.0", default-features = false, path = "../../../primitives/trie", features = [
"memory-tracker",
] }
Expand Down
1 change: 0 additions & 1 deletion bin/node/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ sp-keyring = { version = "7.0.0", path = "../../../primitives/keyring" }
sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" }

[features]
wasmtime = ["sc-executor/wasmtime"]
stress-test = []

[[bench]]
Expand Down
8 changes: 4 additions & 4 deletions bin/node/executor/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ use kitchensink_runtime::{
use node_executor::ExecutorDispatch;
use node_primitives::{BlockNumber, Hash};
use node_testing::keyring::*;
#[cfg(feature = "wasmtime")]
use sc_executor::WasmtimeInstantiationStrategy;
use sc_executor::{Externalities, NativeElseWasmExecutor, RuntimeVersionOf, WasmExecutionMethod};
use sc_executor::{
Externalities, NativeElseWasmExecutor, RuntimeVersionOf, WasmExecutionMethod,
WasmtimeInstantiationStrategy,
};
use sp_core::{
storage::well_known_keys,
traits::{CodeExecutor, RuntimeCode},
Expand Down Expand Up @@ -161,7 +162,6 @@ fn bench_execute_block(c: &mut Criterion) {
let execution_methods = vec![
ExecutionMethod::Native,
ExecutionMethod::Wasm(WasmExecutionMethod::Interpreted),
#[cfg(feature = "wasmtime")]
ExecutionMethod::Wasm(WasmExecutionMethod::Compiled {
instantiation_strategy: WasmtimeInstantiationStrategy::PoolingCopyOnWrite,
}),
Expand Down
4 changes: 1 addition & 3 deletions bin/node/testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ sc-block-builder = { version = "0.10.0-dev", path = "../../../client/block-build
sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" }
sc-client-db = { version = "0.10.0-dev", features = ["rocksdb"], path = "../../../client/db" }
sc-consensus = { version = "0.10.0-dev", path = "../../../client/consensus/common" }
sc-executor = { version = "0.10.0-dev", features = [
"wasmtime",
], path = "../../../client/executor" }
sc-executor = { version = "0.10.0-dev", path = "../../../client/executor" }
sc-service = { version = "0.10.0-dev", features = [
"test-helpers",
"rocksdb",
Expand Down
3 changes: 1 addition & 2 deletions client/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,5 @@ sp-version = { version = "5.0.0", path = "../../primitives/version" }
tempfile = "3.1.0"

[features]
default = ["rocksdb", "wasmtime"]
default = ["rocksdb"]
rocksdb = ["sc-client-db/rocksdb"]
wasmtime = ["sc-service/wasmtime"]
61 changes: 4 additions & 57 deletions client/cli/src/arg_enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

//! Definitions of [`ValueEnum`] types.

use clap::{builder::PossibleValue, ValueEnum};
use clap::ValueEnum;

/// The instantiation strategy to use in compiled mode.
#[derive(Debug, Clone, Copy, ValueEnum)]
Expand Down Expand Up @@ -51,59 +51,16 @@ pub const DEFAULT_WASMTIME_INSTANTIATION_STRATEGY: WasmtimeInstantiationStrategy
WasmtimeInstantiationStrategy::PoolingCopyOnWrite;

/// How to execute Wasm runtime code.
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum WasmExecutionMethod {
/// Uses an interpreter.
#[clap(name = "interpreted-i-know-what-i-do")]
Interpreted,
/// Uses a compiled runtime.
Compiled,
}

const INTERPRETED_NAME: &str = "interpreted-i-know-what-i-do";

impl clap::ValueEnum for WasmExecutionMethod {
/// All possible argument values, in display order.
fn value_variants<'a>() -> &'a [Self] {
let variants = &[Self::Interpreted, Self::Compiled];
if cfg!(feature = "wasmtime") {
variants
} else {
&variants[..1]
}
}

/// Parse an argument into `Self`.
fn from_str(s: &str, _: bool) -> Result<Self, String> {
if s.eq_ignore_ascii_case(INTERPRETED_NAME) {
Ok(Self::Interpreted)
} else if s.eq_ignore_ascii_case("compiled") {
#[cfg(feature = "wasmtime")]
{
Ok(Self::Compiled)
}
#[cfg(not(feature = "wasmtime"))]
{
Err("`Compiled` variant requires the `wasmtime` feature to be enabled".into())
}
} else {
Err(format!("Unknown variant `{}`", s))
}
}

/// The canonical argument value.
///
/// The value is `None` for skipped variants.
fn to_possible_value(&self) -> Option<PossibleValue> {
match self {
#[cfg(feature = "wasmtime")]
WasmExecutionMethod::Compiled => Some(PossibleValue::new("compiled")),
#[cfg(not(feature = "wasmtime"))]
WasmExecutionMethod::Compiled => None,
WasmExecutionMethod::Interpreted => Some(PossibleValue::new(INTERPRETED_NAME)),
}
}
}

impl std::fmt::Display for WasmExecutionMethod {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Expand All @@ -121,7 +78,6 @@ pub fn execution_method_from_cli(
) -> sc_service::config::WasmExecutionMethod {
match execution_method {
WasmExecutionMethod::Interpreted => sc_service::config::WasmExecutionMethod::Interpreted,
#[cfg(feature = "wasmtime")]
WasmExecutionMethod::Compiled => sc_service::config::WasmExecutionMethod::Compiled {
instantiation_strategy: match _instantiation_strategy {
WasmtimeInstantiationStrategy::PoolingCopyOnWrite =>
Expand All @@ -136,21 +92,12 @@ pub fn execution_method_from_cli(
sc_service::config::WasmtimeInstantiationStrategy::LegacyInstanceReuse,
},
},
#[cfg(not(feature = "wasmtime"))]
WasmExecutionMethod::Compiled => panic!(
"Substrate must be compiled with \"wasmtime\" feature for compiled Wasm execution"
),
}
}

/// The default [`WasmExecutionMethod`].
#[cfg(feature = "wasmtime")]
pub const DEFAULT_WASM_EXECUTION_METHOD: WasmExecutionMethod = WasmExecutionMethod::Compiled;

/// The default [`WasmExecutionMethod`].
#[cfg(not(feature = "wasmtime"))]
pub const DEFAULT_WASM_EXECUTION_METHOD: WasmExecutionMethod = WasmExecutionMethod::Interpreted;

#[allow(missing_docs)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)]
#[value(rename_all = "kebab-case")]
Expand Down
3 changes: 1 addition & 2 deletions client/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -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"]
15 changes: 1 addition & 14 deletions client/executor/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _;
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -163,55 +157,48 @@ fn bench_call_instance(c: &mut Criterion) {
let _ = env_logger::try_init();

let strategies = [
#[cfg(feature = "wasmtime")]
(
"legacy_instance_reuse",
Method::Compiled {
instantiation_strategy: InstantiationStrategy::LegacyInstanceReuse,
precompile: false,
},
),
#[cfg(feature = "wasmtime")]
(
"recreate_instance_vanilla",
Method::Compiled {
instantiation_strategy: InstantiationStrategy::RecreateInstance,
precompile: false,
},
),
#[cfg(feature = "wasmtime")]
(
"recreate_instance_cow_fresh",
Method::Compiled {
instantiation_strategy: InstantiationStrategy::RecreateInstanceCopyOnWrite,
precompile: false,
},
),
#[cfg(feature = "wasmtime")]
(
"recreate_instance_cow_precompiled",
Method::Compiled {
instantiation_strategy: InstantiationStrategy::RecreateInstanceCopyOnWrite,
precompile: true,
},
),
#[cfg(feature = "wasmtime")]
(
"pooling_vanilla",
Method::Compiled {
instantiation_strategy: InstantiationStrategy::Pooling,
precompile: false,
},
),
#[cfg(feature = "wasmtime")]
(
"pooling_cow_fresh",
Method::Compiled {
instantiation_strategy: InstantiationStrategy::PoolingCopyOnWrite,
precompile: false,
},
),
#[cfg(feature = "wasmtime")]
(
"pooling_cow_precompiled",
Method::Compiled {
Expand Down
5 changes: 0 additions & 5 deletions client/executor/src/integration_tests/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _;
Expand Down
Loading