Bump wasmtime to 5.0.0 (and a few other deps) (#13160)

* Bump `wasmtime` to 4.0.0 (and a few other deps)

* Use `Error::msg` instead of `anyhow!`

* Bump `wasmtime` to 5.0.0

* Update `Cargo.lock`

* Add `wasmtime` feature to `sp-wasm-interface` dependency
This commit is contained in:
Koute
2023-02-07 00:40:50 +09:00
committed by GitHub
parent 8851bbb0f0
commit 44cbf303c4
10 changed files with 154 additions and 140 deletions
@@ -371,14 +371,14 @@ fn generate_host_function_implementation(
registry.register_static(
#crate_::sp_wasm_interface::Function::name(&#struct_name),
|mut caller: #crate_::sp_wasm_interface::wasmtime::Caller<T::State>, #(#ffi_args_prototype),*|
-> std::result::Result<#ffi_return_ty, #crate_::sp_wasm_interface::wasmtime::Trap>
-> std::result::Result<#ffi_return_ty, #crate_::sp_wasm_interface::anyhow::Error>
{
T::with_function_context(caller, move |__function_context__| {
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
#struct_name::call(
__function_context__,
#(#ffi_names,)*
).map_err(#crate_::sp_wasm_interface::wasmtime::Trap::new)
).map_err(#crate_::sp_wasm_interface::anyhow::Error::msg)
}));
match result {
Ok(result) => result,
@@ -391,7 +391,7 @@ fn generate_host_function_implementation(
} else {
"host code panicked while being called by the runtime".to_owned()
};
return Err(#crate_::sp_wasm_interface::wasmtime::Trap::new(message));
return Err(#crate_::sp_wasm_interface::anyhow::Error::msg(message));
}
}
})
@@ -18,9 +18,11 @@ codec = { package = "parity-scale-codec", version = "3.2.2", default-features =
impl-trait-for-tuples = "0.2.2"
log = { version = "0.4.17", optional = true }
wasmi = { version = "0.13", optional = true }
wasmtime = { version = "1.0.0", default-features = false, optional = true }
wasmtime = { version = "5.0.0", 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" ]
@@ -41,6 +41,9 @@ macro_rules! if_wasmtime_is_enabled {
if_wasmtime_is_enabled! {
// Reexport wasmtime so that its types are accessible from the procedural macro.
pub use wasmtime;
// Wasmtime uses anyhow types but doesn't reexport them.
pub use anyhow;
}
/// Result type used by traits in this crate.