Skip to content

Commit 0e90dec

Browse files
yjhmelodybkchr
authored andcommitted
Remove wasmi backend from sc-executor (paritytech#13800)
* refactor: use builder api for all executors * improve a lot * remove unused args * cleanup deps * fix inconsistency about heap alloc * add `heap_pages` back to try-runtime * fix * chore: reduce duplicated code for sc-service-test * cleanup code * fmt * improve test executor * improve * use #[deprecated] * set runtime_cache_size: 4 * wip * fix and improve * remove sc-executor-wasmi deps * clean up bench and tests * delete "client/executor/wasmi" * cleanup * refactor builder * fix * fix bench * fix tests * fix warnings * fix warnings * fix * fix * remove wasmi and fix tests * unused imports * improve by suggestions * Update client/cli/src/arg_enums.rs --------- Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: parity-processbot <>
1 parent 4760ed8 commit 0e90dec

File tree

18 files changed

+36
-795
lines changed

18 files changed

+36
-795
lines changed

Cargo.lock

Lines changed: 3 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ members = [
3838
"client/executor",
3939
"client/executor/common",
4040
"client/executor/runtime-test",
41-
"client/executor/wasmi",
4241
"client/executor/wasmtime",
4342
"client/informant",
4443
"client/keystore",

bin/node-template/node/src/service.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ pub fn new_partial(
6969
.transpose()?;
7070

7171
let executor = sc_service::new_native_or_wasm_executor(&config);
72-
7372
let (client, backend, keystore_container, task_manager) =
7473
sc_service::new_full_parts::<Block, RuntimeApi, _>(
7574
config,

bin/node/executor/benches/bench.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ fn bench_execute_block(c: &mut Criterion) {
182182
let mut group = c.benchmark_group("execute blocks");
183183
let execution_methods = vec![
184184
ExecutionMethod::Native,
185-
ExecutionMethod::Wasm(WasmExecutionMethod::Interpreted),
186185
ExecutionMethod::Wasm(WasmExecutionMethod::Compiled {
187186
instantiation_strategy: WasmtimeInstantiationStrategy::PoolingCopyOnWrite,
188187
}),

client/cli/src/arg_enums.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub const DEFAULT_WASMTIME_INSTANTIATION_STRATEGY: WasmtimeInstantiationStrategy
5454
#[derive(Debug, Clone, Copy, ValueEnum)]
5555
#[value(rename_all = "kebab-case")]
5656
pub enum WasmExecutionMethod {
57-
/// Uses an interpreter.
57+
/// Uses an interpreter which now is deprecated.
5858
#[clap(name = "interpreted-i-know-what-i-do")]
5959
Interpreted,
6060
/// Uses a compiled runtime.
@@ -76,21 +76,24 @@ pub fn execution_method_from_cli(
7676
execution_method: WasmExecutionMethod,
7777
instantiation_strategy: WasmtimeInstantiationStrategy,
7878
) -> sc_service::config::WasmExecutionMethod {
79-
match execution_method {
80-
WasmExecutionMethod::Interpreted => sc_service::config::WasmExecutionMethod::Interpreted,
81-
WasmExecutionMethod::Compiled => sc_service::config::WasmExecutionMethod::Compiled {
82-
instantiation_strategy: match instantiation_strategy {
83-
WasmtimeInstantiationStrategy::PoolingCopyOnWrite =>
84-
sc_service::config::WasmtimeInstantiationStrategy::PoolingCopyOnWrite,
85-
WasmtimeInstantiationStrategy::RecreateInstanceCopyOnWrite =>
86-
sc_service::config::WasmtimeInstantiationStrategy::RecreateInstanceCopyOnWrite,
87-
WasmtimeInstantiationStrategy::Pooling =>
88-
sc_service::config::WasmtimeInstantiationStrategy::Pooling,
89-
WasmtimeInstantiationStrategy::RecreateInstance =>
90-
sc_service::config::WasmtimeInstantiationStrategy::RecreateInstance,
91-
WasmtimeInstantiationStrategy::LegacyInstanceReuse =>
92-
sc_service::config::WasmtimeInstantiationStrategy::LegacyInstanceReuse,
93-
},
79+
if let WasmExecutionMethod::Interpreted = execution_method {
80+
log::warn!(
81+
"`interpreted-i-know-what-i-do` is deprecated and will be removed in the future. Defaults to `compiled` execution mode."
82+
);
83+
}
84+
85+
sc_service::config::WasmExecutionMethod::Compiled {
86+
instantiation_strategy: match instantiation_strategy {
87+
WasmtimeInstantiationStrategy::PoolingCopyOnWrite =>
88+
sc_service::config::WasmtimeInstantiationStrategy::PoolingCopyOnWrite,
89+
WasmtimeInstantiationStrategy::RecreateInstanceCopyOnWrite =>
90+
sc_service::config::WasmtimeInstantiationStrategy::RecreateInstanceCopyOnWrite,
91+
WasmtimeInstantiationStrategy::Pooling =>
92+
sc_service::config::WasmtimeInstantiationStrategy::Pooling,
93+
WasmtimeInstantiationStrategy::RecreateInstance =>
94+
sc_service::config::WasmtimeInstantiationStrategy::RecreateInstance,
95+
WasmtimeInstantiationStrategy::LegacyInstanceReuse =>
96+
sc_service::config::WasmtimeInstantiationStrategy::LegacyInstanceReuse,
9497
},
9598
}
9699
}

client/executor/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ targets = ["x86_64-unknown-linux-gnu"]
1717
lru = "0.8.1"
1818
parking_lot = "0.12.1"
1919
tracing = "0.1.29"
20-
wasmi = "0.13.2"
2120

2221
codec = { package = "parity-scale-codec", version = "3.2.2" }
2322
sc-executor-common = { version = "0.10.0-dev", path = "common" }
24-
sc-executor-wasmi = { version = "0.10.0-dev", path = "wasmi" }
2523
sc-executor-wasmtime = { version = "0.10.0-dev", path = "wasmtime" }
2624
sp-api = { version = "4.0.0-dev", path = "../../primitives/api" }
2725
sp-core = { version = "7.0.0", path = "../../primitives/core" }

client/executor/benches/bench.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ use std::sync::{
3333

3434
#[derive(Clone)]
3535
enum Method {
36-
Interpreted,
3736
Compiled { instantiation_strategy: InstantiationStrategy, precompile: bool },
3837
}
3938

@@ -50,17 +49,10 @@ fn initialize(
5049
method: Method,
5150
) -> Box<dyn WasmModule> {
5251
let blob = RuntimeBlob::uncompress_if_needed(runtime).unwrap();
53-
let host_functions = sp_io::SubstrateHostFunctions::host_functions();
52+
5453
let allow_missing_func_imports = true;
5554

5655
match method {
57-
Method::Interpreted => sc_executor_wasmi::create_runtime(
58-
blob,
59-
DEFAULT_HEAP_ALLOC_STRATEGY,
60-
host_functions,
61-
allow_missing_func_imports,
62-
)
63-
.map(|runtime| -> Box<dyn WasmModule> { Box::new(runtime) }),
6456
Method::Compiled { instantiation_strategy, precompile } => {
6557
let config = sc_executor_wasmtime::Config {
6658
allow_missing_func_imports,
@@ -215,7 +207,6 @@ fn bench_call_instance(c: &mut Criterion) {
215207
precompile: true,
216208
},
217209
),
218-
("interpreted", Method::Interpreted),
219210
];
220211

221212
let runtimes = [("kusama_runtime", kusama_runtime()), ("test_runtime", test_runtime())];

client/executor/common/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ targets = ["x86_64-unknown-linux-gnu"]
1616
[dependencies]
1717
thiserror = "1.0.30"
1818
wasm-instrument = "0.3"
19-
wasmi = "0.13.2"
2019
sc-allocator = { version = "4.1.0-dev", path = "../../allocator" }
2120
sp-maybe-compressed-blob = { version = "4.1.0-dev", path = "../../../primitives/maybe-compressed-blob" }
2221
sp-wasm-interface = { version = "7.0.0", path = "../../../primitives/wasm-interface" }

client/executor/common/src/error.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,13 @@
1818

1919
//! Rust executor possible errors.
2020
21-
use wasmi;
22-
2321
/// Result type alias.
2422
pub type Result<T> = std::result::Result<T, Error>;
2523

2624
/// Error type.
2725
#[derive(Debug, thiserror::Error)]
2826
#[allow(missing_docs)]
2927
pub enum Error {
30-
#[error(transparent)]
31-
Wasmi(#[from] wasmi::Error),
32-
3328
#[error("Error calling api function: {0}")]
3429
ApiError(Box<dyn std::error::Error + Send + Sync>),
3530

@@ -48,9 +43,6 @@ pub enum Error {
4843
#[error("Invalid type returned (should be u64)")]
4944
InvalidReturn,
5045

51-
#[error("Runtime error")]
52-
Runtime,
53-
5446
#[error("Runtime panicked: {0}")]
5547
RuntimePanicked(String),
5648

@@ -109,8 +101,6 @@ pub enum Error {
109101
OutputExceedsBounds,
110102
}
111103

112-
impl wasmi::HostError for Error {}
113-
114104
impl From<&'static str> for Error {
115105
fn from(err: &'static str) -> Error {
116106
Error::Other(err.into())

client/executor/common/src/runtime_blob/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
//!
2727
//! To give you some examples:
2828
//!
29-
//! - wasmi allows reaching to non-exported mutable globals so that we could reset them. Wasmtime
30-
//! doesn’t support that.
31-
//!
3229
//! We need to reset the globals because when we
3330
//! execute the Substrate Runtime, we do not drop and create the instance anew, instead
3431
//! we restore some selected parts of the state.

0 commit comments

Comments
 (0)