From 11f9838ca7bd037490a84d905c8909c109f01895 Mon Sep 17 00:00:00 2001 From: James Kay Date: Wed, 5 Jun 2024 15:34:07 +0100 Subject: [PATCH] Wasm on the Web (#1990) * `linera-execution::wasm::wasmer`: set up dependencies for the Web * `linera-{execution,witty}`: allow non-`Send` types in `UserData` * `.github/workflows`: enable testing the `wasmer` feature on the Web * `linera-execution`: don't use `wasmer/js-default` on native targets * `linera-execution`: make the `wasmtime` backend non-`Send` safe * `linera-witty`: turn on required `wasmer` features --- .github/workflows/rust.yml | 2 +- Cargo.lock | 22 ++++------ Cargo.toml | 7 +++- examples/Cargo.lock | 21 ++++------ examples/Cargo.toml | 5 +++ linera-execution/Cargo.toml | 8 +++- linera-execution/build.rs | 4 +- linera-execution/src/lib.rs | 4 +- .../src/test_utils/mock_application.rs | 4 +- linera-execution/src/wasm/system_api.rs | 6 +-- linera-execution/src/wasm/wasmer.rs | 40 +++++++++++-------- linera-execution/src/wasm/wasmtime.rs | 12 +++--- linera-witty/Cargo.toml | 10 +++++ .../src/runtime/wasmer/export_function.rs | 2 +- linera-witty/src/runtime/wasmer/function.rs | 6 +-- linera-witty/src/runtime/wasmer/memory.rs | 10 +---- linera-witty/src/runtime/wasmer/mod.rs | 10 +---- 17 files changed, 92 insertions(+), 81 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9a8e32946cb..51c800b48f4 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -80,7 +80,7 @@ jobs: --locked \ --target wasm32-unknown-unknown \ --no-default-features \ - --features web + --features web,wasmer - name: Compile the workspace with the default features (build) run: | cargo build --locked diff --git a/Cargo.lock b/Cargo.lock index 17baf7dafdf..43c96c8fef0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8030,8 +8030,7 @@ dependencies = [ [[package]] name = "wasmer" version = "4.3.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063315805273d66057de5e7145919e745134374ee9a2acfeb354814a2240649e" +source = "git+https://github.com/Twey/wasmer?branch=non-send-environments#2e48e6bc7b220558d854f3b512d62292e3e0c263" dependencies = [ "bytes", "cfg-if", @@ -8053,6 +8052,7 @@ dependencies = [ "wasmer-derive", "wasmer-types", "wasmer-vm", + "wasmparser 0.121.2", "wat", "winapi", ] @@ -8060,8 +8060,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "4.3.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f809637584d1ba52e43291703c255107f87858b7fc70d78b4bebc175f462f5d9" +source = "git+https://github.com/Twey/wasmer?branch=non-send-environments#2e48e6bc7b220558d854f3b512d62292e3e0c263" dependencies = [ "backtrace", "bytes", @@ -8087,8 +8086,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "4.3.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b092fd256db30f3ffe069173c7799bde50283a0969827e034004ae755d4fe8" +source = "git+https://github.com/Twey/wasmer?branch=non-send-environments#2e48e6bc7b220558d854f3b512d62292e3e0c263" dependencies = [ "cranelift-codegen 0.91.1", "cranelift-entity 0.91.1", @@ -8106,8 +8104,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "4.3.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6852aef78618c839d02874283cdc331beb91e01727789c29007920ff3803c915" +source = "git+https://github.com/Twey/wasmer?branch=non-send-environments#2e48e6bc7b220558d854f3b512d62292e3e0c263" dependencies = [ "byteorder", "dynasm", @@ -8125,8 +8122,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "4.3.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7f14f05a6665e0a4fcdfced554b1b9bc649b8a411414a2c99802c6daa3faed3" +source = "git+https://github.com/Twey/wasmer?branch=non-send-environments#2e48e6bc7b220558d854f3b512d62292e3e0c263" dependencies = [ "proc-macro-error 1.0.4", "proc-macro2", @@ -8137,8 +8133,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "4.3.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b718632586b3e2959435adabb1b449a8632ee50ff086058df2708878eb774b" +source = "git+https://github.com/Twey/wasmer?branch=non-send-environments#2e48e6bc7b220558d854f3b512d62292e3e0c263" dependencies = [ "bytecheck", "enum-iterator", @@ -8153,8 +8148,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "4.3.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6e3747c71e2dd938cdf90c735f37dc72cbb8538109b4a134d719a64826ae5c2" +source = "git+https://github.com/Twey/wasmer?branch=non-send-environments#2e48e6bc7b220558d854f3b512d62292e3e0c263" dependencies = [ "backtrace", "cc", diff --git a/Cargo.toml b/Cargo.toml index a088cdbe3ca..2bed6d6b7e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -148,7 +148,7 @@ wasm-bindgen = "0.2.92" wasm-bindgen-test = "0.3.42" wasm-encoder = "0.24.1" wasm-instrument = "0.4.0" -wasmer = { version = "4.3.0-alpha.1", features = ["singlepass"] } +wasmer = { version = "4.3.0-alpha.1", default-features = false } wasmer-compiler-singlepass = "4.3.0-alpha.1" wasmparser = "0.101.1" wasmtime = "1.0" @@ -217,3 +217,8 @@ opt-level = 3 version = "0.4.1" git = "https://github.com/Twey/rust-indexed-db" branch = "no-uuid-wasm-bindgen" + +[patch.crates-io.wasmer] +version = "4.3.0-alpha.1" +git = "https://github.com/Twey/wasmer" +branch = "non-send-environments" diff --git a/examples/Cargo.lock b/examples/Cargo.lock index eb05be2099d..336c98851b2 100644 --- a/examples/Cargo.lock +++ b/examples/Cargo.lock @@ -6205,8 +6205,7 @@ dependencies = [ [[package]] name = "wasmer" version = "4.3.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063315805273d66057de5e7145919e745134374ee9a2acfeb354814a2240649e" +source = "git+https://github.com/Twey/wasmer?branch=non-send-environments#22d085d25f1b1141d22b22938163541efe34cbe7" dependencies = [ "bytes", "cfg-if", @@ -6235,8 +6234,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "4.3.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f809637584d1ba52e43291703c255107f87858b7fc70d78b4bebc175f462f5d9" +source = "git+https://github.com/Twey/wasmer?branch=non-send-environments#22d085d25f1b1141d22b22938163541efe34cbe7" dependencies = [ "backtrace", "bytes", @@ -6262,8 +6260,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "4.3.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b092fd256db30f3ffe069173c7799bde50283a0969827e034004ae755d4fe8" +source = "git+https://github.com/Twey/wasmer?branch=non-send-environments#22d085d25f1b1141d22b22938163541efe34cbe7" dependencies = [ "cranelift-codegen 0.91.1", "cranelift-entity 0.91.1", @@ -6281,8 +6278,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "4.3.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6852aef78618c839d02874283cdc331beb91e01727789c29007920ff3803c915" +source = "git+https://github.com/Twey/wasmer?branch=non-send-environments#22d085d25f1b1141d22b22938163541efe34cbe7" dependencies = [ "byteorder", "dynasm", @@ -6300,8 +6296,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "4.3.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7f14f05a6665e0a4fcdfced554b1b9bc649b8a411414a2c99802c6daa3faed3" +source = "git+https://github.com/Twey/wasmer?branch=non-send-environments#22d085d25f1b1141d22b22938163541efe34cbe7" dependencies = [ "proc-macro-error 1.0.4", "proc-macro2", @@ -6312,8 +6307,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "4.3.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b718632586b3e2959435adabb1b449a8632ee50ff086058df2708878eb774b" +source = "git+https://github.com/Twey/wasmer?branch=non-send-environments#22d085d25f1b1141d22b22938163541efe34cbe7" dependencies = [ "bytecheck", "enum-iterator", @@ -6328,8 +6322,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "4.3.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6e3747c71e2dd938cdf90c735f37dc72cbb8538109b4a134d719a64826ae5c2" +source = "git+https://github.com/Twey/wasmer?branch=non-send-environments#22d085d25f1b1141d22b22938163541efe34cbe7" dependencies = [ "backtrace", "cc", diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 8a69dd06a7b..69f8bd74ea6 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -57,3 +57,8 @@ strip = 'debuginfo' [profile.bench] debug = true + +[patch.crates-io.wasmer] +version = "4.3.0-alpha.1" +git = "https://github.com/Twey/wasmer" +branch = "non-send-environments" diff --git a/linera-execution/Cargo.toml b/linera-execution/Cargo.toml index 1a9c66f759b..7164dcf39a4 100644 --- a/linera-execution/Cargo.toml +++ b/linera-execution/Cargo.toml @@ -59,15 +59,16 @@ thiserror.workspace = true tracing = { workspace = true, features = ["log"] } wasm-encoder = { workspace = true, optional = true } wasm-instrument = { workspace = true, optional = true, features = ["sign_ext"] } -wasmer = { workspace = true, optional = true } wasmparser = { workspace = true, optional = true } wasmtime = { workspace = true, optional = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] tokio = { workspace = true, features = ["rt-multi-thread"] } +wasmer = { workspace = true, optional = true, features = ["sys-default", "singlepass"] } [target.'cfg(target_arch = "wasm32")'.dependencies] tokio = { workspace = true, features = ["rt"] } +wasmer = { workspace = true, optional = true, features = ["js-default"] } [dev-dependencies] anyhow.workspace = true @@ -87,3 +88,8 @@ cfg_aliases.workspace = true [package.metadata.cargo-machete] ignored = ["serde_bytes"] + +[patch.crates-io.wasmer] +version = "4.3.0-alpha.1" +git = "https://github.com/Twey/wasmer" +branch = "non-send-environments" diff --git a/linera-execution/build.rs b/linera-execution/build.rs index 782466bef48..e474536e8f7 100644 --- a/linera-execution/build.rs +++ b/linera-execution/build.rs @@ -3,11 +3,13 @@ fn main() { cfg_aliases::cfg_aliases! { + web: { all(target_arch = "wasm32", feature = "web") }, + with_fs: { all(not(target_arch = "wasm32"), feature = "fs") }, with_metrics: { all(not(target_arch = "wasm32"), feature = "metrics") }, with_testing: { any(test, feature = "test") }, with_tokio_multi_thread: { not(target_arch = "wasm32") }, - with_wasmer: { all(not(target_arch = "wasm32"), feature = "wasmer") }, + with_wasmer: { feature = "wasmer" }, with_wasmtime: { all(not(target_arch = "wasm32"), feature = "wasmtime") }, // If you change this, don't forget to update `WasmRuntime` and diff --git a/linera-execution/src/lib.rs b/linera-execution/src/lib.rs index f2018ba70c4..2795c5e5601 100644 --- a/linera-execution/src/lib.rs +++ b/linera-execution/src/lib.rs @@ -72,10 +72,10 @@ pub type UserContractCode = Arc; pub type UserServiceCode = Arc; /// An implementation of [`UserContract`]. -pub type UserContractInstance = Box; +pub type UserContractInstance = Box; /// An implementation of [`UserService`]. -pub type UserServiceInstance = Box; +pub type UserServiceInstance = Box; /// A factory trait to obtain a [`UserContract`] from a [`UserContractModule`] pub trait UserContractModule { diff --git a/linera-execution/src/test_utils/mock_application.rs b/linera-execution/src/test_utils/mock_application.rs index 8d8ee4345e6..353fa4ec2db 100644 --- a/linera-execution/src/test_utils/mock_application.rs +++ b/linera-execution/src/test_utils/mock_application.rs @@ -195,7 +195,7 @@ impl UserContractModule for MockApplication { fn instantiate( &self, runtime: ContractSyncRuntime, - ) -> Result, ExecutionError> { + ) -> Result, ExecutionError> { Ok(Box::new(self.create_mock_instance(runtime))) } } @@ -204,7 +204,7 @@ impl UserServiceModule for MockApplication { fn instantiate( &self, runtime: ServiceSyncRuntime, - ) -> Result, ExecutionError> { + ) -> Result, ExecutionError> { Ok(Box::new(self.create_mock_instance(runtime))) } } diff --git a/linera-execution/src/wasm/system_api.rs b/linera-execution/src/wasm/system_api.rs index 0f9bdad0aee..4bbe2795492 100644 --- a/linera-execution/src/wasm/system_api.rs +++ b/linera-execution/src/wasm/system_api.rs @@ -79,7 +79,7 @@ pub struct ContractSystemApi(PhantomData); impl ContractSystemApi where Caller: Instance>, - Runtime: ContractRuntime + Send + 'static, + Runtime: ContractRuntime + 'static, { /// Returns the ID of the current chain. fn get_chain_id(caller: &mut Caller) -> Result { @@ -360,7 +360,7 @@ pub struct ServiceSystemApi(PhantomData); impl ServiceSystemApi where Caller: Instance>, - Runtime: ServiceRuntime + Send + 'static, + Runtime: ServiceRuntime + 'static, { /// Returns the ID of the current chain. fn get_chain_id(caller: &mut Caller) -> Result { @@ -514,7 +514,7 @@ pub struct ViewSystemApi(PhantomData); impl ViewSystemApi where Caller: Instance>, - Runtime: BaseRuntime + WriteBatch + Send + 'static, + Runtime: BaseRuntime + WriteBatch + 'static, { /// Creates a new promise to check if the `key` is in storage. fn contains_key_new(caller: &mut Caller, key: Vec) -> Result { diff --git a/linera-execution/src/wasm/wasmer.rs b/linera-execution/src/wasm/wasmer.rs index 4e5df0da3f2..15324f1283e 100644 --- a/linera-execution/src/wasm/wasmer.rs +++ b/linera-execution/src/wasm/wasmer.rs @@ -13,7 +13,7 @@ use linera_witty::{ }; use tokio::sync::Mutex; use wasm_instrument::{gas_metering, parity_wasm}; -use wasmer::{sys::EngineBuilder, Cranelift, Engine, Module, Singlepass, Store}; +use wasmer::{Engine, Module, Store}; use super::{ module_cache::ModuleCache, @@ -28,8 +28,15 @@ use crate::{ /// An [`Engine`] instance configured to run application services. static SERVICE_ENGINE: Lazy = Lazy::new(|| { - let compiler_config = Cranelift::new(); - EngineBuilder::new(compiler_config).into() + #[cfg(web)] + { + wasmer::Engine::default() + } + + #[cfg(not(web))] + { + wasmer::sys::EngineBuilder::new(wasmer::Cranelift::new()).into() + } }); /// A cache of compiled contract modules, with their respective [`Engine`] instances. @@ -65,7 +72,7 @@ impl WasmContractModule { impl WasmerContractInstance where - Runtime: ContractRuntime + WriteBatch + Clone + Send + Sync + Unpin + 'static, + Runtime: ContractRuntime + WriteBatch + Clone + Unpin + 'static, { /// Prepares a runtime instance to call into the Wasm contract. pub fn prepare( @@ -100,7 +107,7 @@ impl WasmServiceModule { impl WasmerServiceInstance where - Runtime: ServiceRuntime + WriteBatch + Clone + Send + Sync + Unpin + 'static, + Runtime: ServiceRuntime + WriteBatch + Clone + Unpin + 'static, { /// Prepares a runtime instance to call into the Wasm service. pub fn prepare(service_module: &Module, runtime: Runtime) -> Result { @@ -118,7 +125,7 @@ where impl crate::UserContract for WasmerContractInstance where - Runtime: ContractRuntime + Send + Unpin + 'static, + Runtime: ContractRuntime + Unpin + 'static, { fn instantiate( &mut self, @@ -160,10 +167,7 @@ where } } -impl crate::UserService for WasmerServiceInstance -where - Runtime: Send + 'static, -{ +impl crate::UserService for WasmerServiceInstance { fn handle_query( &mut self, _context: QueryContext, @@ -253,17 +257,21 @@ impl CachedContractModule { /// Creates a new [`Engine`] to compile a contract bytecode. fn create_compilation_engine() -> Engine { - let mut compiler_config = Singlepass::default(); - compiler_config.canonicalize_nans(true); + #[cfg(not(web))] + { + let mut compiler_config = wasmer::Singlepass::default(); + compiler_config.canonicalize_nans(true); + + wasmer::sys::EngineBuilder::new(compiler_config).into() + } - EngineBuilder::new(compiler_config).into() + #[cfg(web)] + wasmer::Engine::default() } /// Creates a [`Module`] from a compiled contract using a headless [`Engine`]. pub fn create_execution_instance(&self) -> Result<(Engine, Module), anyhow::Error> { - use wasmer::NativeEngineExt; - - let engine = Engine::headless(); + let engine = Engine::default(); let store = Store::new(engine.clone()); let module = unsafe { Module::deserialize(&store, &*self.compiled_bytecode) }?; Ok((engine, module)) diff --git a/linera-execution/src/wasm/wasmtime.rs b/linera-execution/src/wasm/wasmtime.rs index b1a939d0704..b55dd00401a 100644 --- a/linera-execution/src/wasm/wasmtime.rs +++ b/linera-execution/src/wasm/wasmtime.rs @@ -46,7 +46,7 @@ static SERVICE_CACHE: Lazy>> = Lazy::new(Mutex::defaul /// system API. pub(crate) struct WasmtimeContractInstance where - Runtime: ContractRuntime + Send + Sync + 'static, + Runtime: ContractRuntime + 'static, { /// The Wasm module instance. instance: EntrypointInstance>, @@ -59,7 +59,7 @@ where // dependency is updated impl WasmtimeContractInstance where - Runtime: ContractRuntime + Send + Sync, + Runtime: ContractRuntime, { fn configure_initial_fuel(&mut self) -> Result<(), ExecutionError> { let runtime = &mut self.instance.user_data_mut().runtime_mut(); @@ -124,7 +124,7 @@ impl WasmContractModule { impl WasmtimeContractInstance where - Runtime: ContractRuntime + WriteBatch + Send + Sync + 'static, + Runtime: ContractRuntime + WriteBatch + 'static, { /// Prepares a runtime instance to call into the Wasm contract. pub fn prepare(contract_module: &Module, runtime: Runtime) -> Result { @@ -161,7 +161,7 @@ impl WasmServiceModule { impl WasmtimeServiceInstance where - Runtime: ServiceRuntime + WriteBatch + Send + Sync + 'static, + Runtime: ServiceRuntime + WriteBatch + 'static, { /// Prepares a runtime instance to call into the Wasm service. pub fn prepare(service_module: &Module, runtime: Runtime) -> Result { @@ -184,7 +184,7 @@ where impl crate::UserContract for WasmtimeContractInstance where - Runtime: ContractRuntime + Send + Sync + 'static, + Runtime: ContractRuntime + 'static, { fn instantiate( &mut self, @@ -232,7 +232,7 @@ where impl crate::UserService for WasmtimeServiceInstance where - Runtime: ServiceRuntime + Send + Sync + 'static, + Runtime: ServiceRuntime + 'static, { fn handle_query( &mut self, diff --git a/linera-witty/Cargo.toml b/linera-witty/Cargo.toml index 2c0ac42f2af..dd8ed668a85 100644 --- a/linera-witty/Cargo.toml +++ b/linera-witty/Cargo.toml @@ -30,6 +30,16 @@ thiserror.workspace = true wasmer = { workspace = true, optional = true } wasmtime = { workspace = true, optional = true } +[target.wasm32-unknown-unknown.dependencies.wasmer] +workspace = true +optional = true +features = ["js-default"] + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies.wasmer] +workspace = true +optional = true +features = ["sys-default", "singlepass"] + [dev-dependencies] assert_matches.workspace = true insta.workspace = true diff --git a/linera-witty/src/runtime/wasmer/export_function.rs b/linera-witty/src/runtime/wasmer/export_function.rs index e0a50129fbf..854fe77113f 100644 --- a/linera-witty/src/runtime/wasmer/export_function.rs +++ b/linera-witty/src/runtime/wasmer/export_function.rs @@ -20,7 +20,7 @@ macro_rules! export_function { where $( $types: FromToNativeWasmType, )* FlatResult: MaybeFlatType + WasmTypeList, - UserData: Send + 'static, + UserData: 'static, HandlerError: Error + Send + Sync + 'static, Handler: Fn( diff --git a/linera-witty/src/runtime/wasmer/function.rs b/linera-witty/src/runtime/wasmer/function.rs index b2396721741..22ae608dbaf 100644 --- a/linera-witty/src/runtime/wasmer/function.rs +++ b/linera-witty/src/runtime/wasmer/function.rs @@ -4,7 +4,7 @@ //! Implementations of [`InstanceWithFunction`] for Wasmer instances. use frunk::{hlist_pat, HList}; -use wasmer::{AsStoreRef, Extern, FromToNativeWasmType, TypedFunction}; +use wasmer::{AsStoreRef, Extern, FromToNativeWasmType, NativeWasmTypeInto, TypedFunction}; use super::{ parameters::WasmerParameters, results::WasmerResults, EntrypointInstance, ReentrantInstance, @@ -30,9 +30,9 @@ macro_rules! impl_instance_with_function_for { impl<$( $types, )* Results, UserData> InstanceWithFunction for $instance where - $( $types: FlatType + FromToNativeWasmType, )* + $( $types: FlatType + FromToNativeWasmType + NativeWasmTypeInto, )* Results: FlatLayout + WasmerResults, - UserData: Send + 'static, + UserData: 'static, { type Function = TypedFunction< ::ImportParameters, diff --git a/linera-witty/src/runtime/wasmer/memory.rs b/linera-witty/src/runtime/wasmer/memory.rs index 840a1028273..f1df6f475ac 100644 --- a/linera-witty/src/runtime/wasmer/memory.rs +++ b/linera-witty/src/runtime/wasmer/memory.rs @@ -12,10 +12,7 @@ use crate::{GuestPointer, RuntimeError, RuntimeMemory}; macro_rules! impl_memory_traits { ($instance:ty) => { - impl InstanceWithMemory for $instance - where - UserData: Send + 'static, - { + impl InstanceWithMemory for $instance { fn memory_from_export(&self, export: Extern) -> Result, RuntimeError> { Ok(match export { Extern::Memory(memory) => Some(memory), @@ -24,10 +21,7 @@ macro_rules! impl_memory_traits { } } - impl RuntimeMemory<$instance> for Memory - where - UserData: Send + 'static, - { + impl RuntimeMemory<$instance> for Memory { fn read<'instance>( &self, instance: &'instance $instance, diff --git a/linera-witty/src/runtime/wasmer/mod.rs b/linera-witty/src/runtime/wasmer/mod.rs index 08b6e4ef8e4..cfb57259248 100644 --- a/linera-witty/src/runtime/wasmer/mod.rs +++ b/linera-witty/src/runtime/wasmer/mod.rs @@ -35,10 +35,7 @@ pub struct InstanceBuilder { environment: Environment, } -impl InstanceBuilder -where - UserData: Send + 'static, -{ +impl InstanceBuilder { /// Creates a new [`InstanceBuilder`]. pub fn new(engine: Engine, user_data: UserData) -> Self { InstanceBuilder { @@ -160,10 +157,7 @@ impl Instance for EntrypointInstance { /// guest. pub type ReentrantInstance<'a, UserData> = FunctionEnvMut<'a, Environment>; -impl Instance for ReentrantInstance<'_, UserData> -where - UserData: Send + 'static, -{ +impl Instance for ReentrantInstance<'_, UserData> { type Runtime = Wasmer; type UserData = UserData; type UserDataReference<'a> = MutexGuard<'a, UserData>