diff --git a/Cargo.lock b/Cargo.lock index 9744bd7d076e..c096d3c84e8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8980,8 +8980,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", @@ -9011,8 +9010,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", @@ -9038,8 +9036,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", @@ -9057,8 +9054,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", @@ -9076,8 +9072,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", @@ -9088,8 +9083,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", @@ -9104,8 +9098,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 ec2ef8eaca53..35715c5929cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -215,3 +215,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 0538fe390832..aa0f43c8bc35 100644 --- a/examples/Cargo.lock +++ b/examples/Cargo.lock @@ -4952,8 +4952,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", @@ -4982,8 +4981,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", @@ -5009,8 +5007,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", @@ -5028,8 +5025,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", @@ -5047,8 +5043,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", @@ -5059,8 +5054,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", @@ -5075,8 +5069,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 4dfeb6beb6eb..9293c8e50dac 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -52,3 +52,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 4f2b0cbf12ad..072ec7c6a5ef 100644 --- a/linera-execution/Cargo.toml +++ b/linera-execution/Cargo.toml @@ -88,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/src/lib.rs b/linera-execution/src/lib.rs index fd76fedc931d..c9f8a37b74f6 100644 --- a/linera-execution/src/lib.rs +++ b/linera-execution/src/lib.rs @@ -69,10 +69,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 8d8ee4345e66..353fa4ec2db0 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 56e1e6a381e6..3a178ad79193 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 { @@ -354,7 +354,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 { @@ -503,7 +503,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 fc72c2ab585d..15324f1283ee 100644 --- a/linera-execution/src/wasm/wasmer.rs +++ b/linera-execution/src/wasm/wasmer.rs @@ -26,13 +26,6 @@ use crate::{ QueryContext, ServiceRuntime, }; -#[cfg(not(web))] -use { - wasmer::sys::EngineBuilder, - wasmer::Cranelift, - wasmer::Singlepass, -}; - /// An [`Engine`] instance configured to run application services. static SERVICE_ENGINE: Lazy = Lazy::new(|| { #[cfg(web)] @@ -79,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( @@ -114,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 { @@ -132,7 +125,7 @@ where impl crate::UserContract for WasmerContractInstance where - Runtime: ContractRuntime + Send + Unpin + 'static, + Runtime: ContractRuntime + Unpin + 'static, { fn instantiate( &mut self, @@ -174,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, diff --git a/linera-witty/src/runtime/wasmer/export_function.rs b/linera-witty/src/runtime/wasmer/export_function.rs index e0a50129fbf6..854fe77113f3 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 42f26a057a62..22ae608dbafb 100644 --- a/linera-witty/src/runtime/wasmer/function.rs +++ b/linera-witty/src/runtime/wasmer/function.rs @@ -32,7 +32,7 @@ macro_rules! impl_instance_with_function_for { where $( $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 840a10282739..f1df6f475ac3 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 08b6e4ef8e47..cfb572592481 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>