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

Commit

Permalink
cli: CLI option for running Substrate with compiled Wasm execution.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimpo committed Oct 28, 2019
1 parent d5b72c6 commit 5f17b08
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,9 @@ is-it-maintained-open-issues = { repository = "paritytech/substrate" }
[profile.release]
# Substrate runtime requires unwinding.
panic = "unwind"

[features]
wasmtime = [
"cli/wasmtime",
]

5 changes: 5 additions & 0 deletions core/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ rpassword = "4.0.1"

[dev-dependencies]
tempdir = "0.3.7"

[features]
wasmtime = [
"service/wasmtime",
]
21 changes: 20 additions & 1 deletion core/cli/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,32 @@ arg_enum! {
pub enum WasmExecutionMethod {
// Uses an interpreter.
Interpreted,
// Uses a compiled runtime.
Compiled,
}
}

impl WasmExecutionMethod {
/// Returns list of variants that are not disabled by feature flags.
fn enabled_variants() -> Vec<&'static str> {
Self::variants()
.iter()
.cloned()
.filter(|&name| cfg!(feature = "wasmtime") || name != "Compiled")
.collect()
}
}

impl Into<service::config::WasmExecutionMethod> for WasmExecutionMethod {
fn into(self) -> service::config::WasmExecutionMethod {
match self {
WasmExecutionMethod::Interpreted => service::config::WasmExecutionMethod::Interpreted,
#[cfg(feature = "wasmtime")]
WasmExecutionMethod::Compiled => service::config::WasmExecutionMethod::Compiled,
#[cfg(not(feature = "wasmtime"))]
WasmExecutionMethod::Compiled => panic!(
"Substrate must be compiled with \"wasmtime\" feature for compiled Wasm execution"
),
}
}
}
Expand Down Expand Up @@ -407,7 +426,7 @@ pub struct RunCmd {
#[structopt(
long = "wasm-execution",
value_name = "METHOD",
possible_values = &WasmExecutionMethod::variants(),
possible_values = &WasmExecutionMethod::enabled_variants(),
case_insensitive = true,
default_value = "Interpreted"
)]
Expand Down
5 changes: 5 additions & 0 deletions core/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../
grandpa = { package = "substrate-finality-grandpa", path = "../../core/finality-grandpa" }
grandpa-primitives = { package = "substrate-finality-grandpa-primitives", path = "../../core/finality-grandpa/primitives" }
tokio = "0.1"

[features]
wasmtime = [
"substrate-executor/wasmtime",
]
7 changes: 7 additions & 0 deletions node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,10 @@ tempfile = "3.1.0"
[build-dependencies]
cli = { package = "substrate-cli", path = "../../core/cli" }
structopt = "0.3.3"

[features]
wasmtime = [
"cli/wasmtime",
"node-executor/wasmtime",
"substrate-service/wasmtime",
]

0 comments on commit 5f17b08

Please sign in to comment.