diff --git a/Cargo.lock b/Cargo.lock index 1090901895440..af0a52fb1d8a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4848,12 +4848,6 @@ dependencies = [ "hash-db", ] -[[package]] -name = "memory_units" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" - [[package]] name = "merlin" version = "2.0.1" @@ -6206,7 +6200,7 @@ dependencies = [ "sp-runtime", "sp-std", "wasm-instrument 0.4.0", - "wasmi 0.28.0", + "wasmi", "wasmparser-nostd", "wat", ] @@ -11432,7 +11426,6 @@ dependencies = [ "log", "parity-scale-codec", "sp-std", - "wasmi 0.13.2", "wasmtime", ] @@ -13019,17 +13012,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "wasmi" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06c326c93fbf86419608361a2c925a31754cf109da1b8b55737070b4d6669422" -dependencies = [ - "parity-wasm", - "wasmi-validation", - "wasmi_core 0.2.1", -] - [[package]] name = "wasmi" version = "0.28.0" @@ -13038,38 +13020,16 @@ checksum = "8e61a7006b0fdf24f6bbe8dcfdad5ca1b350de80061fb2827f31c82fbbb9565a" dependencies = [ "spin 0.9.8", "wasmi_arena", - "wasmi_core 0.12.0", + "wasmi_core", "wasmparser-nostd", ] -[[package]] -name = "wasmi-validation" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ff416ad1ff0c42e5a926ed5d5fab74c0f098749aa0ad8b2a34b982ce0e867b" -dependencies = [ - "parity-wasm", -] - [[package]] name = "wasmi_arena" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "401c1f35e413fac1846d4843745589d9ec678977ab35a384db8ae7830525d468" -[[package]] -name = "wasmi_core" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d20cb3c59b788653d99541c646c561c9dd26506f25c0cebfe810659c54c6d7" -dependencies = [ - "downcast-rs", - "libm 0.2.6", - "memory_units", - "num-rational", - "num-traits", -] - [[package]] name = "wasmi_core" version = "0.12.0" diff --git a/primitives/wasm-interface/Cargo.toml b/primitives/wasm-interface/Cargo.toml index 11804d705c20b..9a5229229138a 100644 --- a/primitives/wasm-interface/Cargo.toml +++ b/primitives/wasm-interface/Cargo.toml @@ -17,12 +17,11 @@ targets = ["x86_64-unknown-linux-gnu"] codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } impl-trait-for-tuples = "0.2.2" log = { version = "0.4.17", optional = true } -wasmi = { version = "0.13.2", optional = true } wasmtime = { version = "8.0.1", default-features = false, optional = true } anyhow = { version = "1.0.68", optional = true } sp-std = { version = "5.0.0", default-features = false, path = "../std" } [features] -default = [ "std" ] -std = [ "codec/std", "log", "sp-std/std", "wasmi", "wasmtime" ] -wasmtime = [ "dep:wasmtime", "anyhow" ] +default = ["std"] +std = ["codec/std", "log", "sp-std/std", "wasmtime"] +wasmtime = ["dep:wasmtime", "anyhow"] diff --git a/primitives/wasm-interface/src/lib.rs b/primitives/wasm-interface/src/lib.rs index b096d236c01eb..9d5d2bb358d57 100644 --- a/primitives/wasm-interface/src/lib.rs +++ b/primitives/wasm-interface/src/lib.rs @@ -21,9 +21,6 @@ use sp_std::{borrow::Cow, iter::Iterator, marker::PhantomData, mem, result, vec, vec::Vec}; -#[cfg(feature = "wasmi")] -mod wasmi_impl; - #[cfg(not(all(feature = "std", feature = "wasmtime")))] #[macro_export] macro_rules! if_wasmtime_is_enabled { diff --git a/primitives/wasm-interface/src/wasmi_impl.rs b/primitives/wasm-interface/src/wasmi_impl.rs deleted file mode 100644 index 7394e34551305..0000000000000 --- a/primitives/wasm-interface/src/wasmi_impl.rs +++ /dev/null @@ -1,80 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Implementation of conversions between Substrate and wasmi types. -use crate::{Signature, Value, ValueType}; -use sp_std::vec::Vec; - -impl From for wasmi::RuntimeValue { - fn from(value: Value) -> Self { - match value { - Value::I32(val) => Self::I32(val), - Value::I64(val) => Self::I64(val), - Value::F32(val) => Self::F32(val.into()), - Value::F64(val) => Self::F64(val.into()), - } - } -} - -impl From for Value { - fn from(value: wasmi::RuntimeValue) -> Self { - match value { - wasmi::RuntimeValue::I32(val) => Self::I32(val), - wasmi::RuntimeValue::I64(val) => Self::I64(val), - wasmi::RuntimeValue::F32(val) => Self::F32(val.into()), - wasmi::RuntimeValue::F64(val) => Self::F64(val.into()), - } - } -} - -impl From for wasmi::ValueType { - fn from(value: ValueType) -> Self { - match value { - ValueType::I32 => Self::I32, - ValueType::I64 => Self::I64, - ValueType::F32 => Self::F32, - ValueType::F64 => Self::F64, - } - } -} - -impl From for ValueType { - fn from(value: wasmi::ValueType) -> Self { - match value { - wasmi::ValueType::I32 => Self::I32, - wasmi::ValueType::I64 => Self::I64, - wasmi::ValueType::F32 => Self::F32, - wasmi::ValueType::F64 => Self::F64, - } - } -} - -impl From for wasmi::Signature { - fn from(sig: Signature) -> Self { - let args = sig.args.iter().map(|a| (*a).into()).collect::>(); - wasmi::Signature::new(args, sig.return_value.map(Into::into)) - } -} - -impl From<&wasmi::Signature> for Signature { - fn from(sig: &wasmi::Signature) -> Self { - Signature::new( - sig.params().iter().copied().map(Into::into).collect::>(), - sig.return_type().map(Into::into), - ) - } -}