diff --git a/Cargo.lock b/Cargo.lock index 91feecdb8c..475d473b5d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1770,9 +1770,9 @@ dependencies = [ [[package]] name = "decider-distro" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fc977928aedc97953c9bd41627dd498c7cfd06e63b55b62464be45f6299287e" +checksum = "03a8de76f4a45b6c3199a96f81ea6e6cb84fa814b2dd3dbed2cdf5583b3f53ab" dependencies = [ "built 0.7.1", "fluence-spell-dtos", @@ -2186,16 +2186,16 @@ dependencies = [ [[package]] name = "fluence-app-service" -version = "0.33.0" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec5358cd011d91885b81539bc36f8f67075cd6bb1bf260c7ab35a7ff31b5870d" +checksum = "53f1b1edfa366551382890ecf2b18d8b9675b3a105bf2d90c444446cc081115d" dependencies = [ "log", "maplit", "marine-min-it-version", - "marine-runtime 0.34.0", - "marine-wasm-backend-traits", - "marine-wasmtime-backend", + "marine-runtime 0.36.0", + "marine-wasm-backend-traits 0.6.0", + "marine-wasmtime-backend 0.6.0", "serde", "serde_derive", "serde_json", @@ -2260,9 +2260,9 @@ dependencies = [ [[package]] name = "fluence-spell-distro" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d2a6f192674b298a5f49265be8b5d69479170bf4146297b28e3324b2b91f1a8" +checksum = "b4f7a6eb40ae202258affc0cde4ec51e4b49dfb01e44b2b01fe97352beaa46a1" dependencies = [ "built 0.7.1", "maplit", @@ -2270,12 +2270,12 @@ dependencies = [ [[package]] name = "fluence-spell-dtos" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db23727f355efdfa8f2d2c54822666ba83647d04aa614e20ae158074ee6edab0" +checksum = "13c65a23ae0bd9c838c3dba0ed167222e36026d7ce0f29f89faf5a47eff28148" dependencies = [ "eyre", - "marine-rs-sdk 0.12.0", + "marine-rs-sdk 0.14.0", "marine-sqlite-connector", "serde", "thiserror", @@ -4308,6 +4308,17 @@ dependencies = [ "serde", ] +[[package]] +name = "marine-call-parameters" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05495180730abae04abe209386ce367309a82110edb65fcdb1f3080f819bc1a0" +dependencies = [ + "marine-macro 0.14.0", + "marine-rs-sdk-main 0.14.0", + "serde", +] + [[package]] name = "marine-core" version = "0.26.1" @@ -4321,13 +4332,13 @@ dependencies = [ "log", "marine-it-generator 0.13.1", "marine-it-interfaces", - "marine-it-parser", + "marine-it-parser 0.15.1", "marine-min-it-version", "marine-module-info-parser 0.11.1", "marine-module-interface", "marine-utils", - "marine-wasm-backend-traits", - "marine-wasmtime-backend", + "marine-wasm-backend-traits 0.5.1", + "marine-wasmtime-backend 0.5.1", "multimap 0.8.3", "once_cell", "paste", @@ -4339,24 +4350,24 @@ dependencies = [ [[package]] name = "marine-core" -version = "0.28.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b9a08bd99ea96356abdac57700a58496dc4034d1f48000fb54e532fc5021c8d" +checksum = "2989c1670a82d69724804c7af5d8e4c35231083338806c49485d983f27dd440f" dependencies = [ "anyhow", "bytesize", "it-lilo", "it-memory-traits", "log", - "marine-it-generator 0.15.0", + "marine-it-generator 0.17.0", "marine-it-interfaces", - "marine-it-parser", + "marine-it-parser 0.16.0", "marine-min-it-version", - "marine-module-info-parser 0.13.0", + "marine-module-info-parser 0.15.0", "marine-module-interface", "marine-utils", - "marine-wasm-backend-traits", - "marine-wasmtime-backend", + "marine-wasm-backend-traits 0.6.0", + "marine-wasmtime-backend 0.6.0", "multimap 0.8.3", "once_cell", "paste", @@ -4373,7 +4384,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d03328e174951faf739e7e12be3d9ffb044cfc308508dc89260d63a1a43a0df" dependencies = [ "it-lilo", - "marine-it-parser", + "marine-it-parser 0.15.1", "marine-macro-impl 0.7.1", "once_cell", "serde", @@ -4385,13 +4396,13 @@ dependencies = [ [[package]] name = "marine-it-generator" -version = "0.15.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64902f7fee0488f2b1e27e8f595772f1a7a386d07f74e55a07def1ad967a64fd" +checksum = "993c33c6df3ae978022058dfd63a33b52de1307adec59e0c3f3367dd06bdf342" dependencies = [ "it-lilo", - "marine-it-parser", - "marine-macro-impl 0.13.0", + "marine-it-parser 0.16.0", + "marine-macro-impl 0.14.0", "once_cell", "serde", "serde_json", @@ -4420,7 +4431,26 @@ dependencies = [ "itertools 0.10.5", "marine-it-interfaces", "marine-module-interface", - "marine-wasm-backend-traits", + "marine-wasm-backend-traits 0.5.1", + "nom", + "semver 1.0.20", + "serde", + "thiserror", + "walrus", + "wasmer-interface-types-fl", +] + +[[package]] +name = "marine-it-parser" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fa9ba677486e1f1bf2bfd3e34b259255df277887fa90d5c22acb258bdedc34e" +dependencies = [ + "anyhow", + "itertools 0.10.5", + "marine-it-interfaces", + "marine-module-interface", + "marine-wasm-backend-traits 0.6.0", "nom", "semver 1.0.20", "serde", @@ -4459,6 +4489,16 @@ dependencies = [ "marine-rs-sdk-main 0.13.0", ] +[[package]] +name = "marine-macro" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f502185316f584a9373cceb6ff24a11d260dfd39505c817056bc127cd1a96a08" +dependencies = [ + "marine-macro-impl 0.14.0", + "marine-rs-sdk-main 0.14.0", +] + [[package]] name = "marine-macro-impl" version = "0.7.1" @@ -4511,6 +4551,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "marine-macro-impl" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e50fbc0e70ee4cde7802f0748acfb197d7770c7feffb980ce8c29bddd007519e" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn 1.0.109", +] + [[package]] name = "marine-min-it-version" version = "0.3.2" @@ -4531,7 +4584,7 @@ dependencies = [ "chrono", "derivative", "marine-rs-sdk-main 0.10.3", - "marine-wasm-backend-traits", + "marine-wasm-backend-traits 0.5.1", "semver 1.0.20", "serde", "thiserror", @@ -4540,15 +4593,15 @@ dependencies = [ [[package]] name = "marine-module-info-parser" -version = "0.13.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e39ef4b727e6e895b0b53682dc35463e00004aa0089d49797b4f289227ea3b5d" +checksum = "1db5fe45b6f0f397ecce757c23a3d0c4a08c2e9ffa6e7f642cb89e1ec777b16d" dependencies = [ "anyhow", "chrono", "derivative", - "marine-rs-sdk-main 0.13.0", - "marine-wasm-backend-traits", + "marine-rs-sdk-main 0.14.0", + "marine-wasm-backend-traits 0.6.0", "semver 1.0.20", "serde", "thiserror", @@ -4587,27 +4640,14 @@ dependencies = [ [[package]] name = "marine-rs-sdk" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7662e4c6c08f7cd1b63cd6ff8e473e3239a9d3dd10fb46bec357cb8331423268" -dependencies = [ - "marine-call-parameters 0.12.0", - "marine-macro 0.12.0", - "marine-rs-sdk-main 0.12.0", - "marine-timestamp-macro 0.12.0", - "serde", -] - -[[package]] -name = "marine-rs-sdk" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f33834365d1e6dd041e821a758000f32bed5b960edb09f9d8c61e340dd82e29" +checksum = "f93d2bd852fea1fea8097c195044430347eda98fd6a3752119b549192d5ac4ba" dependencies = [ - "marine-call-parameters 0.13.0", - "marine-macro 0.13.0", - "marine-rs-sdk-main 0.13.0", - "marine-timestamp-macro 0.13.0", + "marine-call-parameters 0.14.0", + "marine-macro 0.14.0", + "marine-rs-sdk-main 0.14.0", + "marine-timestamp-macro 0.14.0", "serde", ] @@ -4641,6 +4681,16 @@ dependencies = [ "serde", ] +[[package]] +name = "marine-rs-sdk-main" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b79c165fc21438b069babeec5ae36ba0eade5e08fb1d92dabbe6b41014ce841" +dependencies = [ + "log", + "serde", +] + [[package]] name = "marine-runtime" version = "0.32.1" @@ -4657,8 +4707,8 @@ dependencies = [ "marine-rs-sdk 0.10.3", "marine-rs-sdk-main 0.10.3", "marine-utils", - "marine-wasm-backend-traits", - "marine-wasmtime-backend", + "marine-wasm-backend-traits 0.5.1", + "marine-wasmtime-backend 0.5.1", "parking_lot", "safe-transmute", "serde", @@ -4672,9 +4722,9 @@ dependencies = [ [[package]] name = "marine-runtime" -version = "0.34.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e26c68703d0dc853790adf27813734a696dc75182a93c2a7b3d24a86eed56254" +checksum = "00e428f8066ed3cbd6def39a818ffe949d7ab15559666927b25401068ce2655d" dependencies = [ "bytesize", "it-json-serde", @@ -4683,13 +4733,14 @@ dependencies = [ "log", "marine-call-parameters 0.10.3", "marine-call-parameters 0.12.0", - "marine-core 0.28.0", + "marine-call-parameters 0.13.0", + "marine-core 0.30.0", "marine-module-interface", - "marine-rs-sdk 0.13.0", - "marine-rs-sdk-main 0.13.0", + "marine-rs-sdk 0.14.0", + "marine-rs-sdk-main 0.14.0", "marine-utils", - "marine-wasm-backend-traits", - "marine-wasmtime-backend", + "marine-wasm-backend-traits 0.6.0", + "marine-wasmtime-backend 0.6.0", "parking_lot", "safe-transmute", "serde", @@ -4703,12 +4754,12 @@ dependencies = [ [[package]] name = "marine-sqlite-connector" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb21d5419382307d97677d92c267f714a77549658270ada5d84496bfd74314e9" +checksum = "1c4d82c7e8c07f59aa526271b810c97ec7f79d14a77725025618a79b0b1d9051" dependencies = [ "bytesize", - "marine-rs-sdk 0.12.0", + "marine-rs-sdk 0.14.0", ] [[package]] @@ -4723,19 +4774,9 @@ dependencies = [ [[package]] name = "marine-timestamp-macro" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47ec0d664570661ecba1feba2dda610ab63f23733edf189dcde7b5ed23966144" -dependencies = [ - "chrono", - "quote", -] - -[[package]] -name = "marine-timestamp-macro" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a5086357724dc2a65e7abe39c85d58b9971198f8678ebc642a69aae1bbc7ae0" +checksum = "d03f267ac0a29f543ef12a1a519ff8d98e74ac66e1c580f2930d41ce2c50507d" dependencies = [ "chrono", "quote", @@ -4762,6 +4803,21 @@ dependencies = [ "wasmparser 0.101.1", ] +[[package]] +name = "marine-wasm-backend-traits" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50ba17135a13735abfc8fbbb221cd27fb8c607482ec72d7cd8f37315c9fdf6c5" +dependencies = [ + "anyhow", + "it-memory-traits", + "multimap 0.8.3", + "paste", + "thiserror", + "wasmer-interface-types-fl", + "wasmparser 0.101.1", +] + [[package]] name = "marine-wasmtime-backend" version = "0.5.1" @@ -4771,7 +4827,24 @@ dependencies = [ "anyhow", "it-memory-traits", "log", - "marine-wasm-backend-traits", + "marine-wasm-backend-traits 0.5.1", + "multimap 0.8.3", + "paste", + "wasmer-interface-types-fl", + "wasmtime", + "wasmtime-wasi", +] + +[[package]] +name = "marine-wasmtime-backend" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db7a74c532073142ced94fdeaf7a3e84f92ec5ebef5751fbd5516185ae3cf211" +dependencies = [ + "anyhow", + "it-memory-traits", + "log", + "marine-wasm-backend-traits 0.6.0", "multimap 0.8.3", "paste", "wasmer-interface-types-fl", @@ -5644,6 +5717,7 @@ version = "0.1.0" dependencies = [ "async-trait", "bs58", + "eyre", "fluence-app-service", "fluence-libp2p", "fs-utils", @@ -5674,7 +5748,7 @@ dependencies = [ "json-utils", "libipld", "log", - "marine-it-parser", + "marine-it-parser 0.16.0", "parking_lot", "particle-args", "particle-execution", diff --git a/Cargo.toml b/Cargo.toml index 74523fd3d7..8dc067b34c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -101,13 +101,13 @@ types = { path = "crates/types" } core-manager = { path = "crates/core-manager" } # spell -fluence-spell-dtos = "=0.7.3" -fluence-spell-distro = "=0.7.3" +fluence-spell-dtos = "=0.7.4" +fluence-spell-distro = "=0.7.4" # marine -fluence-app-service = { version = "0.33.0" } +fluence-app-service = "0.35.0" marine-utils = "0.5.1" -marine-it-parser = "0.15.1" +marine-it-parser = "0.16.0" # avm avm-server = "=0.35.0" diff --git a/crates/core-manager/src/manager.rs b/crates/core-manager/src/manager.rs index 54def08f0b..d0ba09d79a 100644 --- a/crates/core-manager/src/manager.rs +++ b/crates/core-manager/src/manager.rs @@ -429,12 +429,8 @@ impl CoreManagerFunctions for PersistentCoreManager { drop(lock); let toml = toml::to_string_pretty(&persistent_state) .map_err(|err| PersistError::SerializationError { err })?; - let exists = self.file_path.exists(); - let mut file = if exists { - File::open(self.file_path.clone()).map_err(|err| PersistError::IoError { err })? - } else { - File::create(self.file_path.clone()).map_err(|err| PersistError::IoError { err })? - }; + let mut file = + File::create(self.file_path.clone()).map_err(|err| PersistError::IoError { err })?; file.write(toml.as_bytes()) .map_err(|err| PersistError::IoError { err })?; Ok(()) diff --git a/crates/created-swarm/src/swarm.rs b/crates/created-swarm/src/swarm.rs index dad449f852..4654b7aa54 100644 --- a/crates/created-swarm/src/swarm.rs +++ b/crates/created-swarm/src/swarm.rs @@ -40,7 +40,8 @@ use futures::stream::iter; use nox::{Connectivity, Node}; use particle_protocol::ProtocolConfig; use server_config::{ - system_services_config, BootstrapConfig, ChainListenerConfig, UnresolvedConfig, + persistent_dir, system_services_config, BootstrapConfig, ChainListenerConfig, ResolvedConfig, + UnresolvedConfig, }; use tempfile::TempDir; use test_constants::{EXECUTION_TIMEOUT, TRANSPORT_TIMEOUT}; @@ -52,12 +53,14 @@ const HEALTH_CHECK_POLLING_INTERVAL: Duration = Duration::from_millis(100); // default bound on the number of computations it can perform simultaneously const DEFAULT_PARALLELISM: usize = 2; + #[allow(clippy::upper_case_acronyms)] type AVM = aquamarine::AVMRunner; #[derive(Derivative)] #[derivative(Debug)] pub struct CreatedSwarm { + pub config: ResolvedConfig, pub peer_id: PeerId, pub multiaddr: Multiaddr, // tmp dir, must be cleaned @@ -157,7 +160,17 @@ where F: (FnMut( Vec, Multiaddr, - ) -> BoxFuture<'static, (PeerId, Box>, KeyPair, SwarmConfig, Span)>) + ) -> BoxFuture< + 'static, + ( + PeerId, + Box>, + KeyPair, + SwarmConfig, + ResolvedConfig, + Span, + ), + >) + 'static + Send, M: (FnMut() -> Multiaddr) + 'static + Send, @@ -175,7 +188,8 @@ where let bootstraps = bootstraps(addrs); let create_node_future = create_node(bootstraps, addr.clone()); async move { - let (peer_id, node, management_keypair, config, span) = create_node_future.await; + let (peer_id, node, management_keypair, input_config, resolved_config, span) = + create_node_future.await; let connectivity = node.connectivity.clone(); let aquamarine_api = node.aquamarine_api.clone(); let started_node = node @@ -187,9 +201,10 @@ where .http_listen_addr .expect("could not take http listen addr"); CreatedSwarm { + config: resolved_config, peer_id, - multiaddr: config.listen_on, - tmp_dir: config.tmp_dir.clone(), + multiaddr: input_config.listen_on, + tmp_dir: input_config.tmp_dir.clone(), management_keypair, exit_outlet: started_node.exit_outlet, connectivity, @@ -306,7 +321,8 @@ pub fn aqua_vm_config( peer_id, tmp_dir, .. } = vm_config; - let air_interpreter = air_interpreter_path(&tmp_dir); + let persistent_dir = persistent_dir(&tmp_dir); + let air_interpreter = air_interpreter_path(&persistent_dir); write_default_air_interpreter(&air_interpreter).expect("write air interpreter"); VmConfig::new(peer_id, air_interpreter, None) @@ -315,7 +331,14 @@ pub fn aqua_vm_config( pub async fn create_swarm_with_runtime( config: SwarmConfig, vm_config: impl Fn(BaseVmConfig) -> RT::Config, -) -> (PeerId, Box>, KeyPair, SwarmConfig, Span) { +) -> ( + PeerId, + Box>, + KeyPair, + SwarmConfig, + ResolvedConfig, + Span, +) { use serde_json::json; let format = match &config.keypair { @@ -332,7 +355,7 @@ pub async fn create_swarm_with_runtime( let node_listen_span = tracing::info_span!(parent: &parent_span, "config"); let node_creation_span = tracing::info_span!(parent: &parent_span, "config"); - let (node, management_kp) = config_apply_span.in_scope(||{ + let (node, management_kp, resolved_config) = config_apply_span.in_scope(|| { let tmp_dir = config.tmp_dir.path().to_path_buf(); let node_config = json!({ @@ -419,7 +442,7 @@ pub async fn create_swarm_with_runtime( .extend(config.extend_system_services.clone()); let core_manager = Arc::new(DummyCoreManager::default().into()); let node = Node::new( - resolved, + resolved.clone(), core_manager, vm_config, data_store_config, @@ -427,7 +450,7 @@ pub async fn create_swarm_with_runtime( "some version", system_service_distros, ); - (node, management_kp) + (node, management_kp, resolved) }); let mut node = node @@ -442,6 +465,7 @@ pub async fn create_swarm_with_runtime( node, management_kp, config, + resolved_config, parent_span.clone(), ) }) @@ -449,6 +473,13 @@ pub async fn create_swarm_with_runtime( pub async fn create_swarm( config: SwarmConfig, -) -> (PeerId, Box>, KeyPair, SwarmConfig, Span) { +) -> ( + PeerId, + Box>, + KeyPair, + SwarmConfig, + ResolvedConfig, + Span, +) { create_swarm_with_runtime(config, aqua_vm_config).await } diff --git a/crates/nox-tests/tests/file_share/Cargo.lock b/crates/nox-tests/tests/file_share/Cargo.lock index e5554e26df..1efb764a73 100644 --- a/crates/nox-tests/tests/file_share/Cargo.lock +++ b/crates/nox-tests/tests/file_share/Cargo.lock @@ -2,6 +2,12 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -43,17 +49,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" dependencies = [ + "android-tzdata", "iana-time-zone", "js-sys", - "num-integer", "num-traits", - "time", "wasm-bindgen", - "winapi", + "windows-targets", ] [[package]] @@ -96,7 +101,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 1.0.109", ] [[package]] @@ -113,7 +118,7 @@ checksum = "39e61fda7e62115119469c7b3591fd913ecca96fb766cfd3f2e2502ab7bc87a5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -133,7 +138,7 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -192,18 +197,26 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "marine-call-parameters" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05495180730abae04abe209386ce367309a82110edb65fcdb1f3080f819bc1a0" dependencies = [ - "cfg-if", + "marine-macro", + "marine-rs-sdk-main", + "serde", ] [[package]] name = "marine-macro" -version = "0.7.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e03da22f641984aad5229f780d190502196d1c0bf908d3d17f5d6bcba73e525" +checksum = "f502185316f584a9373cceb6ff24a11d260dfd39505c817056bc127cd1a96a08" dependencies = [ "marine-macro-impl", "marine-rs-sdk-main", @@ -211,35 +224,35 @@ dependencies = [ [[package]] name = "marine-macro-impl" -version = "0.7.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca474b63cabaf8d7d9b38de87d630023cbc91ddc77e92f9c7bb745462a131b44" +checksum = "e50fbc0e70ee4cde7802f0748acfb197d7770c7feffb980ce8c29bddd007519e" dependencies = [ "proc-macro2", "quote", "serde", "serde_json", - "syn", + "syn 1.0.109", ] [[package]] name = "marine-rs-sdk" -version = "0.7.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfeeb7b8cd98e32276fabfe6ab095a6aae793f3f080e7eb1c3d36b1b762397c" +checksum = "f93d2bd852fea1fea8097c195044430347eda98fd6a3752119b549192d5ac4ba" dependencies = [ + "marine-call-parameters", "marine-macro", "marine-rs-sdk-main", "marine-timestamp-macro", - "polyplets", "serde", ] [[package]] name = "marine-rs-sdk-main" -version = "0.7.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43e6eac611bc5b96e80a3f3e2621eeded69fb56389aa83b6ea76ec0f243ef23" +checksum = "0b79c165fc21438b069babeec5ae36ba0eade5e08fb1d92dabbe6b41014ce841" dependencies = [ "log", "serde", @@ -247,24 +260,14 @@ dependencies = [ [[package]] name = "marine-timestamp-macro" -version = "0.7.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ea4557a757e9f4d04a0b6afb047431a246963268a4cab56c62cb5355457cb2f" +checksum = "d03f267ac0a29f543ef12a1a519ff8d98e74ac66e1c580f2930d41ce2c50507d" dependencies = [ "chrono", "quote", ] -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.15" @@ -280,17 +283,6 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" -[[package]] -name = "polyplets" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c051f220264e391afae06b6dceda199d523ee1dc7ae8e8cba4119a378dd411f" -dependencies = [ - "marine-macro", - "marine-rs-sdk-main", - "serde", -] - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -299,18 +291,18 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.50" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.23" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -359,29 +351,29 @@ checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" [[package]] name = "serde" -version = "1.0.152" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.50", ] [[package]] name = "serde_json" -version = "1.0.91" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", @@ -390,9 +382,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.107" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -400,23 +392,23 @@ dependencies = [ ] [[package]] -name = "termcolor" -version = "1.2.0" +name = "syn" +version = "2.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb" dependencies = [ - "winapi-util", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "time" -version = "0.1.45" +name = "termcolor" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", + "winapi-util", ] [[package]] @@ -431,12 +423,6 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -464,7 +450,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] @@ -486,7 +472,7 @@ checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -527,3 +513,60 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-targets" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d380ba1dc7187569a8a9e91ed34b8ccfc33123bbacb8c0aed2d1ad7f3ef2dc5f" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68e5dcfb9413f53afd9c8f86e56a7b4d86d9a2fa26090ea2dc9e40fba56c6ec6" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dab469ebbc45798319e69eebf92308e541ce46760b49b18c6b3fe5e8965b30f" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a4e9b6a7cac734a8b4138a4e1044eac3404d8326b6c0f939276560687a033fb" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28b0ec9c422ca95ff34a78755cfa6ad4a51371da2a5ace67500cf7ca5f232c58" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "704131571ba93e89d7cd43482277d6632589b18ecf4468f591fbae0a8b101614" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42079295511643151e98d61c38c0acc444e52dd42ab456f7ccfd5152e8ecf21c" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0770833d60a970638e989b3fa9fd2bb1aaadcf88963d1659fd7d9990196ed2d6" diff --git a/crates/nox-tests/tests/file_share/Cargo.toml b/crates/nox-tests/tests/file_share/Cargo.toml index 14ca790751..049d3fba82 100644 --- a/crates/nox-tests/tests/file_share/Cargo.toml +++ b/crates/nox-tests/tests/file_share/Cargo.toml @@ -1,3 +1,5 @@ +[workspace] + [package] name = "file_share" version = "0.1.0" @@ -8,9 +10,7 @@ edition = "2021" name = "file_share" path = "src/main.rs" -[workspace] - [dependencies] -marine-rs-sdk = "0.13.0" +marine-rs-sdk = "0.14.0" rand = "0.8.5" base64 = "0.21.0" diff --git a/crates/nox-tests/tests/file_share/artifacts/file_share.wasm b/crates/nox-tests/tests/file_share/artifacts/file_share.wasm index 9c0a16d55d..363949b6e3 100755 Binary files a/crates/nox-tests/tests/file_share/artifacts/file_share.wasm and b/crates/nox-tests/tests/file_share/artifacts/file_share.wasm differ diff --git a/crates/nox-tests/tests/modules.rs b/crates/nox-tests/tests/modules.rs index 15c46575fa..5b138d9e5a 100644 --- a/crates/nox-tests/tests/modules.rs +++ b/crates/nox-tests/tests/modules.rs @@ -88,7 +88,6 @@ async fn test_add_module_mounted_binaries_forbidden() { "logger_enabled": true, "wasi": { "envs": json!({}), - "preopened_files": vec!["/tmp"], "mapped_dirs": json!({}), }, "mounted_binaries": json!({"cmd": "/usr/bin/behbehbeh"}) diff --git a/crates/nox-tests/tests/tetraplets.rs b/crates/nox-tests/tests/tetraplets.rs index 172fa4207c..80e578e9b2 100644 --- a/crates/nox-tests/tests/tetraplets.rs +++ b/crates/nox-tests/tests/tetraplets.rs @@ -95,7 +95,7 @@ async fn test_tetraplets() { let tetraplet = &ap_literal_tetraplets[0][0]; assert_eq!(tetraplet.function_name, ""); assert_eq!(tetraplet.peer_pk, client.peer_id.to_base58()); - assert_eq!(tetraplet.lambda, ""); + assert_eq!(tetraplet.lens, ""); assert_eq!(tetraplet.service_id, ""); let first_tetraplets = args.next().unwrap(); @@ -108,7 +108,7 @@ async fn test_tetraplets() { let tetraplet = &first_tetraplets[0][0]; assert_eq!(tetraplet.function_name, "identity"); assert_eq!(tetraplet.peer_pk, client.node.to_base58()); - assert_eq!(tetraplet.lambda, ""); + assert_eq!(tetraplet.lens, ""); assert_eq!(tetraplet.service_id, "op"); let ap_first_tetraplets = args.next().unwrap(); @@ -127,6 +127,6 @@ async fn test_tetraplets() { let tetraplet = &second_tetraplets[0][0]; assert_eq!(tetraplet.function_name, "get_tetraplets"); assert_eq!(tetraplet.peer_pk, client.node.to_base58()); - assert_eq!(tetraplet.lambda, ".$.[0].[0].peer_pk"); + assert_eq!(tetraplet.lens, ".$.[0].[0].peer_pk"); assert_eq!(tetraplet.service_id, tetraplets_service.id.as_str()); } diff --git a/crates/nox-tests/tests/tetraplets/Cargo.lock b/crates/nox-tests/tests/tetraplets/Cargo.lock index 2b7e1963df..00c3dd1b43 100644 --- a/crates/nox-tests/tests/tetraplets/Cargo.lock +++ b/crates/nox-tests/tests/tetraplets/Cargo.lock @@ -2,12 +2,39 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "bumpalo" +version = "3.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b" + +[[package]] +name = "cc" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9fa1897e4325be0d68d48df6aa1a71ac2ed4d27723887e7754192705350730" + [[package]] name = "cfg-if" version = "1.0.0" @@ -16,54 +43,90 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.19" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" dependencies = [ - "libc", - "num-integer", + "android-tzdata", + "iana-time-zone", + "js-sys", "num-traits", - "time", - "winapi", + "wasm-bindgen", + "windows-targets", ] [[package]] -name = "getrandom" -version = "0.2.7" +name = "core-foundation-sys" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ - "cfg-if", - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", ] [[package]] name = "itoa" -version = "1.0.2" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" + +[[package]] +name = "js-sys" +version = "0.3.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" +dependencies = [ + "wasm-bindgen", +] [[package]] name = "libc" -version = "0.2.126" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "log" -version = "0.4.17" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "marine-call-parameters" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05495180730abae04abe209386ce367309a82110edb65fcdb1f3080f819bc1a0" dependencies = [ - "cfg-if", + "marine-macro", + "marine-rs-sdk-main", + "serde", ] [[package]] name = "marine-macro" -version = "0.7.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f21b40612e9da310a6df1e394cc30b4962bb4ddc13ee50faec6d2704861b7b" +checksum = "f502185316f584a9373cceb6ff24a11d260dfd39505c817056bc127cd1a96a08" dependencies = [ "marine-macro-impl", "marine-rs-sdk-main", @@ -71,36 +134,35 @@ dependencies = [ [[package]] name = "marine-macro-impl" -version = "0.7.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43b2b1e5bc5aebdaac7029cfd84a038cd11b23a023e724548f863618716f44e" +checksum = "e50fbc0e70ee4cde7802f0748acfb197d7770c7feffb980ce8c29bddd007519e" dependencies = [ "proc-macro2", "quote", "serde", "serde_json", - "syn", - "uuid", + "syn 1.0.109", ] [[package]] name = "marine-rs-sdk" -version = "0.7.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4208762a010c41a6352a651061fcd1a7bb077c6a3548be8ccd84fe79c3e1ddbd" +checksum = "f93d2bd852fea1fea8097c195044430347eda98fd6a3752119b549192d5ac4ba" dependencies = [ + "marine-call-parameters", "marine-macro", "marine-rs-sdk-main", "marine-timestamp-macro", - "polyplets", "serde", ] [[package]] name = "marine-rs-sdk-main" -version = "0.7.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0751f4093511b4d8942bed9402dba70ff927cb4df9b18632443294d1cbc51e1a" +checksum = "0b79c165fc21438b069babeec5ae36ba0eade5e08fb1d92dabbe6b41014ce841" dependencies = [ "log", "serde", @@ -108,99 +170,78 @@ dependencies = [ [[package]] name = "marine-timestamp-macro" -version = "0.7.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5297d57cecd75d71feb0c94da9027891e3c31215e23425b0e5dea9a5a7e60230" +checksum = "d03f267ac0a29f543ef12a1a519ff8d98e74ac66e1c580f2930d41ce2c50507d" dependencies = [ "chrono", "quote", ] -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] [[package]] name = "once_cell" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" - -[[package]] -name = "polyplets" -version = "0.3.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "407811d09f3e0fb2086060afdfbad2e6bb5b63c300edeec93358bb5b8a8e4257" -dependencies = [ - "marine-macro", - "marine-rs-sdk-main", - "serde", -] +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "proc-macro2" -version = "1.0.42" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c278e965f1d8cf32d6e0e96de3d3e79712178ae67986d9cf9151f51e95aac89b" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.20" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] [[package]] name = "ryu" -version = "1.0.10" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "serde" -version = "1.0.141" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7af873f2c95b99fcb0bd0fe622a43e29514658873c8ceba88c4cb88833a22500" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.141" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75743a150d003dd863b51dc809bcad0d73f2102c53632f1e954e738192a3413f" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.50", ] [[package]] name = "serde_json" -version = "1.0.82" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", @@ -209,9 +250,20 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.98" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" +checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb" dependencies = [ "proc-macro2", "quote", @@ -227,61 +279,127 @@ dependencies = [ ] [[package]] -name = "time" -version = "0.1.44" +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", + "cfg-if", + "wasm-bindgen-macro", ] [[package]] -name = "unicode-ident" -version = "1.0.2" +name = "wasm-bindgen-backend" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.50", + "wasm-bindgen-shared", +] [[package]] -name = "uuid" -version = "0.8.2" +name = "wasm-bindgen-macro" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" dependencies = [ - "getrandom", + "quote", + "wasm-bindgen-macro-support", ] [[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +name = "wasm-bindgen-macro-support" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.50", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] [[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +name = "wasm-bindgen-shared" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] -name = "winapi" -version = "0.3.9" +name = "windows-core" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "windows-targets", ] [[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" +name = "windows-targets" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d380ba1dc7187569a8a9e91ed34b8ccfc33123bbacb8c0aed2d1ad7f3ef2dc5f" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68e5dcfb9413f53afd9c8f86e56a7b4d86d9a2fa26090ea2dc9e40fba56c6ec6" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dab469ebbc45798319e69eebf92308e541ce46760b49b18c6b3fe5e8965b30f" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a4e9b6a7cac734a8b4138a4e1044eac3404d8326b6c0f939276560687a033fb" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28b0ec9c422ca95ff34a78755cfa6ad4a51371da2a5ace67500cf7ca5f232c58" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "704131571ba93e89d7cd43482277d6632589b18ecf4468f591fbae0a8b101614" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +checksum = "42079295511643151e98d61c38c0acc444e52dd42ab456f7ccfd5152e8ecf21c" [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "windows_x86_64_msvc" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "0770833d60a970638e989b3fa9fd2bb1aaadcf88963d1659fd7d9990196ed2d6" diff --git a/crates/nox-tests/tests/tetraplets/Cargo.toml b/crates/nox-tests/tests/tetraplets/Cargo.toml index 82bf46fa24..bc2df72b8b 100644 --- a/crates/nox-tests/tests/tetraplets/Cargo.toml +++ b/crates/nox-tests/tests/tetraplets/Cargo.toml @@ -1,3 +1,5 @@ +[workspace] + [package] name = "tetraplets" version = "0.2.0" @@ -5,7 +7,7 @@ authors = ["Fluence Labs"] edition = "2021" [dependencies] -marine-rs-sdk = "0.13.0" +marine-rs-sdk = "0.14.0" once_cell = "1.19.0" [[bin]] diff --git a/crates/nox-tests/tests/tetraplets/artifacts/tetraplets.wasm b/crates/nox-tests/tests/tetraplets/artifacts/tetraplets.wasm index cb9a26d558..10e43e26ec 100755 Binary files a/crates/nox-tests/tests/tetraplets/artifacts/tetraplets.wasm and b/crates/nox-tests/tests/tetraplets/artifacts/tetraplets.wasm differ diff --git a/crates/server-config/src/defaults.rs b/crates/server-config/src/defaults.rs index 1c784012e8..f37a5072f6 100644 --- a/crates/server-config/src/defaults.rs +++ b/crates/server-config/src/defaults.rs @@ -99,12 +99,19 @@ pub fn default_base_dir() -> PathBuf { format!(".fluence/v{CONFIG_VERSION}").into() } -pub fn services_base_dir(base_dir: &Path) -> PathBuf { +pub fn persistent_dir(base_dir: &Path) -> PathBuf { + base_dir.join("persistent") +} +pub fn ephemeral_dir(base_dir: &Path) -> PathBuf { + base_dir.join("ephemeral") +} + +pub fn services_dir(base_dir: &Path) -> PathBuf { base_dir.join("services") } pub fn avm_base_dir(base_dir: &Path) -> PathBuf { - base_dir.join("stepper") + base_dir.join("avm") } pub fn default_keypair_path(base_dir: &Path) -> PathOrValue { @@ -113,9 +120,9 @@ pub fn default_keypair_path(base_dir: &Path) -> PathOrValue { } } -pub fn default_builtins_keypair_path(base_dir: &Path) -> PathOrValue { +pub fn default_builtins_keypair_path(persistent_base_dir: &Path) -> PathOrValue { PathOrValue::Path { - path: base_dir.join("builtins_secret_key.ed25519"), + path: persistent_base_dir.join("builtins_secret_key.ed25519"), } } diff --git a/crates/server-config/src/dir_config.rs b/crates/server-config/src/dir_config.rs index d3487fda47..806d9fdb44 100644 --- a/crates/server-config/src/dir_config.rs +++ b/crates/server-config/src/dir_config.rs @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -use crate::defaults::{avm_base_dir, default_base_dir, services_base_dir}; +use crate::defaults::{avm_base_dir, default_base_dir, services_dir}; use air_interpreter_fs::air_interpreter_path; use fs_utils::{canonicalize, create_dirs, to_abs_path}; +use crate::{ephemeral_dir, persistent_dir}; use eyre::WrapErr; use serde::{Deserialize, Serialize}; use std::path::PathBuf; @@ -28,8 +29,17 @@ pub struct UnresolvedDirConfig { #[serde(default = "default_base_dir")] pub base_dir: PathBuf, - /// Base directory for resources needed by application services - pub services_base_dir: Option, + /// Base directory for persistent resources + pub persistent_base_dir: Option, + + /// Base directory for ephemeral resources + pub ephemeral_base_dir: Option, + + /// Base directory for persistent resources needed by application services + pub services_persistent_dir: Option, + + /// Base directory for ephemeral resources needed by application services + pub services_ephemeral_dir: Option, /// Base directory for resources needed by application services pub avm_base_dir: Option, @@ -57,43 +67,79 @@ impl UnresolvedDirConfig { pub fn resolve(self) -> eyre::Result { let base = to_abs_path(self.base_dir); - let services_base_dir = self.services_base_dir.unwrap_or(services_base_dir(&base)); - let avm_base_dir = self.avm_base_dir.unwrap_or(avm_base_dir(&base)); + let ephemeral_base_dir = self.ephemeral_base_dir.unwrap_or(ephemeral_dir(&base)); + let persistent_base_dir = self.persistent_base_dir.unwrap_or(persistent_dir(&base)); + + // ephemeral dirs + let services_ephemeral_dir = self + .services_ephemeral_dir + .unwrap_or(services_dir(&ephemeral_base_dir)); + let avm_base_dir = self + .avm_base_dir + .unwrap_or(avm_base_dir(&ephemeral_base_dir)); + + // persistent dirs + let services_persistent_dir = self + .services_persistent_dir + .unwrap_or(services_dir(&persistent_base_dir)); let air_interpreter_path = self .air_interpreter_path - .unwrap_or(air_interpreter_path(&base)); - let spell_base_dir = self.spell_base_dir.unwrap_or(base.join("spell")); - let keypairs_base_dir = self.keypairs_base_dir.unwrap_or(base.join("keypairs")); - let workers_base_dir = self.workers_base_dir.unwrap_or(base.join("workers")); - let cc_events_dir = self.cc_events_dir.unwrap_or(base.join("cc_events")); + .unwrap_or(air_interpreter_path(&persistent_base_dir)); + let spell_base_dir = self + .spell_base_dir + .unwrap_or(persistent_base_dir.join("spell")); + let keypairs_base_dir = self + .keypairs_base_dir + .unwrap_or(persistent_base_dir.join("keypairs")); + let workers_base_dir = self + .workers_base_dir + .unwrap_or(persistent_base_dir.join("workers")); + + let cc_events_dir = self + .cc_events_dir + .unwrap_or(persistent_base_dir.join("cc_events")); let core_state_path = self .core_state_path .clone() - .unwrap_or(base.join("cores_state.toml")); + .unwrap_or(persistent_base_dir.join("cores_state.toml")); create_dirs(&[ &base, - &services_base_dir, + // ephemeral dirs + &ephemeral_base_dir, + &services_ephemeral_dir, &avm_base_dir, + // persistent dirs + &persistent_base_dir, + &services_persistent_dir, &spell_base_dir, &keypairs_base_dir, &workers_base_dir, + // other &cc_events_dir, ]) .context("creating configured directories")?; - let base = canonicalize(base)?; - let services_base_dir = canonicalize(services_base_dir)?; + let base_dir = canonicalize(base)?; + // ephemeral dirs let avm_base_dir = canonicalize(avm_base_dir)?; + let services_ephemeral_dir = canonicalize(services_ephemeral_dir)?; + + // persistent dirs + let services_persistent_dir = canonicalize(services_persistent_dir)?; let spell_base_dir = canonicalize(spell_base_dir)?; let keypairs_base_dir = canonicalize(keypairs_base_dir)?; let workers_base_dir = canonicalize(workers_base_dir)?; + let cc_events_dir = canonicalize(cc_events_dir)?; Ok(ResolvedDirConfig { - base_dir: base, - services_base_dir, + base_dir, + ephemeral_base_dir, + persistent_base_dir, avm_base_dir, + services_ephemeral_dir, + services_persistent_dir, air_interpreter_path, spell_base_dir, keypairs_base_dir, @@ -107,9 +153,12 @@ impl UnresolvedDirConfig { #[derive(Clone, Debug, Serialize, Deserialize)] pub struct ResolvedDirConfig { pub base_dir: PathBuf, - pub services_base_dir: PathBuf, + pub ephemeral_base_dir: PathBuf, + pub persistent_base_dir: PathBuf, /// Directory where particle's prev_data is stored pub avm_base_dir: PathBuf, + pub services_ephemeral_dir: PathBuf, + pub services_persistent_dir: PathBuf, /// Directory where interpreter's WASM module is stored pub air_interpreter_path: PathBuf, pub spell_base_dir: PathBuf, diff --git a/crates/server-config/src/node_config.rs b/crates/server-config/src/node_config.rs index 2a5a129396..3ed180fa0b 100644 --- a/crates/server-config/src/node_config.rs +++ b/crates/server-config/src/node_config.rs @@ -82,7 +82,7 @@ pub struct UnresolvedNodeConfig { #[serde(default)] pub protocol_config: ProtocolConfig, - /// Number of stepper VMs to create. By default, `num_cpus::get() * 2` is used + /// Number of AVMs to create. By default, `num_cpus::get() * 2` is used #[serde(default = "default_aquavm_pool_size")] pub aquavm_pool_size: usize, @@ -140,7 +140,7 @@ pub struct UnresolvedNodeConfig { } impl UnresolvedNodeConfig { - pub fn resolve(mut self, base_dir: &Path) -> eyre::Result { + pub fn resolve(mut self, persistent_base_dir: &Path) -> eyre::Result { self.load_system_services_envs(); let bootstrap_nodes = match self.local { @@ -151,12 +151,12 @@ impl UnresolvedNodeConfig { let root_key_pair = self .root_key_pair .unwrap_or_default() - .get_keypair(default_keypair_path(base_dir))?; + .get_keypair(default_keypair_path(persistent_base_dir))?; let builtins_key_pair = self .builtins_key_pair .unwrap_or_default() - .get_keypair(default_builtins_keypair_path(base_dir))?; + .get_keypair(default_builtins_keypair_path(persistent_base_dir))?; let mut allowed_binaries = self.allowed_binaries; allowed_binaries.push(self.system_services.aqua_ipfs.ipfs_binary_path.clone()); @@ -333,7 +333,7 @@ pub struct NodeConfig { pub protocol_config: ProtocolConfig, - /// Number of stepper VMs to create. By default, `num_cpus::get() * 2` is used + /// Number of AVMs to create. By default, `num_cpus::get() * 2` is used pub aquavm_pool_size: usize, /// Maximum heap size in bytes available for an interpreter instance. diff --git a/crates/server-config/src/resolved_config.rs b/crates/server-config/src/resolved_config.rs index a2ac112d39..18e8c7dce5 100644 --- a/crates/server-config/src/resolved_config.rs +++ b/crates/server-config/src/resolved_config.rs @@ -46,8 +46,8 @@ pub struct UnresolvedConfig { impl UnresolvedConfig { pub fn resolve(self) -> eyre::Result { - let node_config = self.node_config.resolve(&self.dir_config.base_dir)?; let dir_config = self.dir_config.resolve()?; + let node_config = self.node_config.resolve(&dir_config.persistent_base_dir)?; Ok(ResolvedConfig { dir_config, diff --git a/crates/server-config/src/services_config.rs b/crates/server-config/src/services_config.rs index 697813c919..77c685f9d4 100644 --- a/crates/server-config/src/services_config.rs +++ b/crates/server-config/src/services_config.rs @@ -30,8 +30,10 @@ pub struct ServicesConfig { /// Opaque environment variables to be passed on each service creation /// TODO: isolate envs of different modules (i.e., module A shouldn't access envs of module B) pub envs: HashMap, - /// Working dir for services - pub workdir: PathBuf, + /// Persistent working dir for services + pub persistent_work_dir: PathBuf, + /// Ephemeral working dir for services + pub ephemeral_work_dir: PathBuf, /// Dir to store .wasm modules and their configs pub modules_dir: PathBuf, /// Dir to persist info about running services @@ -53,7 +55,8 @@ impl ServicesConfig { #[allow(clippy::too_many_arguments)] pub fn new( local_peer_id: PeerId, - base_dir: PathBuf, + persistent_dir: PathBuf, + ephemeral_dir: PathBuf, particles_vault_dir: PathBuf, envs: HashMap, management_peer_id: PeerId, @@ -61,7 +64,8 @@ impl ServicesConfig { default_service_memory_limit: Option, allowed_binaries: Vec, ) -> Result { - let base_dir = to_abs_path(base_dir); + let persistent_dir = to_abs_path(persistent_dir); + let ephemeral_dir = to_abs_path(ephemeral_dir); let allowed_binaries = allowed_binaries .into_iter() @@ -78,10 +82,11 @@ impl ServicesConfig { let this = Self { local_peer_id, - blueprint_dir: config_utils::blueprint_dir(&base_dir), - workdir: config_utils::workdir(&base_dir), - modules_dir: config_utils::modules_dir(&base_dir), - services_dir: config_utils::services_dir(&base_dir), + blueprint_dir: config_utils::blueprint_dir(&persistent_dir), + persistent_work_dir: config_utils::workdir(&persistent_dir), + ephemeral_work_dir: config_utils::workdir(&ephemeral_dir), + modules_dir: config_utils::modules_dir(&persistent_dir), + services_dir: config_utils::services_dir(&persistent_dir), particles_vault_dir, envs, management_peer_id, @@ -92,7 +97,8 @@ impl ServicesConfig { create_dirs(&[ &this.blueprint_dir, - &this.workdir, + &this.persistent_work_dir, + &this.ephemeral_work_dir, &this.modules_dir, &this.services_dir, &this.particles_vault_dir, diff --git a/crates/service-modules/src/modules/fixture.rs b/crates/service-modules/src/modules/fixture.rs index cdc664f9b5..51d9e73976 100644 --- a/crates/service-modules/src/modules/fixture.rs +++ b/crates/service-modules/src/modules/fixture.rs @@ -32,9 +32,9 @@ pub fn module_config(import_name: &str) -> JValue { "name": import_name, "mem_pages_count": 100, "logger_enabled": true, + "preopened_files": vec!["/tmp"], "wasi": { "envs": json!({}), - "preopened_files": vec!["/tmp"], "mapped_dirs": json!({}), } }) diff --git a/crates/spell-service-api/src/lib.rs b/crates/spell-service-api/src/lib.rs index 95e7ce1f9c..1c754c9400 100644 --- a/crates/spell-service-api/src/lib.rs +++ b/crates/spell-service-api/src/lib.rs @@ -302,10 +302,12 @@ mod tests { management_pid: PeerId, base_dir: PathBuf, ) -> (ParticleAppServices, ModuleRepository, PeerId) { + let persistent_dir = base_dir.join("persistent"); + let ephemeral_dir = base_dir.join("ephemeral"); let root_key_pair = Keypair::generate_ed25519(); - let vault_dir = base_dir.join("..").join("vault"); - let keypairs_dir = base_dir.join("..").join("keypairs"); - let workers_dir = base_dir.join("..").join("workers"); + let vault_dir = ephemeral_dir.join("..").join("vault"); + let keypairs_dir = persistent_dir.join("..").join("keypairs"); + let workers_dir = persistent_dir.join("..").join("workers"); let root_key_pair: KeyPair = root_key_pair.clone().into(); @@ -333,7 +335,8 @@ mod tests { let service_memory_limit = server_config::default_service_memory_limit(); let config = ServicesConfig::new( root_key_pair.get_peer_id(), - base_dir, + persistent_dir, + ephemeral_dir, vault_dir, HashMap::new(), management_pid, diff --git a/crates/system-services/Cargo.toml b/crates/system-services/Cargo.toml index d873355a8a..1312238a26 100644 --- a/crates/system-services/Cargo.toml +++ b/crates/system-services/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] aqua-ipfs-distro = "=0.6.0" -decider-distro = "=0.6.6" +decider-distro = "=0.6.7" registry-distro = "=0.9.4" trust-graph-distro = "=0.4.11" diff --git a/crates/workers/src/workers.rs b/crates/workers/src/workers.rs index 15cb64e467..b2f6a30ef3 100644 --- a/crates/workers/src/workers.rs +++ b/crates/workers/src/workers.rs @@ -283,12 +283,21 @@ impl Workers { let removed_worker_info = worker_infos.remove(&worker_id); let removed_runtime = runtimes.remove(&worker_id); + drop(worker_ids); + drop(worker_infos); + drop(runtimes); + debug_assert!(removed_worker_id.is_some(), "worker_id does not exist"); debug_assert!(removed_worker_info.is_some(), "worker info does not exist"); debug_assert!(removed_runtime.is_some(), "worker info does not exist"); if let Some(runtime) = removed_runtime { - runtime.shutdown_background(); + // we can't shutdown the runtime in the async context, shift it to the blocking pool + // also we don't wait the result + tokio::task::Builder::new() + .name(&format!("runtime-shutdown-{}", worker_id)) + .spawn_blocking(move || runtime.shutdown_background()) + .expect("Could not spawn task"); } Ok(()) @@ -497,6 +506,26 @@ impl Workers { } } } + + pub fn shutdown(&self) { + let mut runtimes = self.runtimes.write(); + let mut deleted_runtimes = Vec::with_capacity(runtimes.len()); + let worker_ids: Vec = runtimes.keys().cloned().collect(); + for worker_id in worker_ids { + if let Some(runtime) = runtimes.remove(&worker_id) { + deleted_runtimes.push(runtime); + } + } + + tokio::task::Builder::new() + .name("workers-shutdown") + .spawn_blocking(move || { + for runtime in deleted_runtimes { + runtime.shutdown_background(); + } + }) + .expect("Could not spawn a task"); + } } #[cfg(test)] diff --git a/docker/Config.default.toml b/docker/Config.default.toml index 6c50fb3eda..8da2c83966 100644 --- a/docker/Config.default.toml +++ b/docker/Config.default.toml @@ -1,7 +1,7 @@ # # directories for nox persistent storage # base_dir = "/.fluence" # services_base_dir = "/services" -# avm_base_dir = "/stepper" +# avm_base_dir = "/avm" # spell_base_dir = "/spell" # keypairs_base_dir = "/keypairs" # workers_base_dir = "/workers" diff --git a/nox/src/node.rs b/nox/src/node.rs index 039164c623..6ef0bd7abf 100644 --- a/nox/src/node.rs +++ b/nox/src/node.rs @@ -100,6 +100,8 @@ pub struct Node { versions: Versions, pub chain_listener: Option, + + workers: Arc, } impl Node { @@ -147,7 +149,8 @@ impl Node { let services_config = ServicesConfig::new( scopes.get_host_peer_id(), - config.dir_config.services_base_dir.clone(), + config.dir_config.services_persistent_dir.clone(), + config.dir_config.services_ephemeral_dir.clone(), config_utils::particles_vault_dir(&config.dir_config.avm_base_dir), config.services_envs.clone(), config.management_peer_id, @@ -389,6 +392,7 @@ impl Node { allow_local_addresses, versions, chain_listener, + workers.clone(), )) } @@ -484,6 +488,7 @@ impl Node { allow_local_addresses: bool, versions: Versions, chain_listener: Option, + workers: Arc, ) -> Box { let node_service = Self { particle_stream, @@ -510,6 +515,7 @@ impl Node { allow_local_addresses, versions, chain_listener, + workers, }; Box::new(node_service) @@ -538,6 +544,7 @@ impl Node { let libp2p_metrics = self.libp2p_metrics; let allow_local_addresses = self.allow_local_addresses; let versions = self.versions; + let workers = self.workers.clone(); let chain_listener = self.chain_listener; task::Builder::new().name(&task_name.clone()).spawn(async move { @@ -588,6 +595,7 @@ impl Node { dispatcher.cancel().await; connectivity.cancel().await; aquamarine_backend.abort(); + workers.shutdown(); }.in_current_span()).expect("Could not spawn task"); // Note: need to be after the start of the node to be able to subscribe spells @@ -648,7 +656,7 @@ mod tests { use connected_client::ConnectedClient; use core_manager::manager::DummyCoreManager; use fs_utils::to_abs_path; - use server_config::{default_base_dir, load_config_with_args}; + use server_config::{default_base_dir, load_config_with_args, persistent_dir}; use system_services::SystemServiceDistros; use crate::Node; @@ -657,8 +665,10 @@ mod tests { async fn run_node() { log_utils::enable_logs(); let base_dir = default_base_dir(); + let persistent_dir = persistent_dir(&base_dir); fs_utils::create_dir(&base_dir).unwrap(); - write_default_air_interpreter(&air_interpreter_path(&base_dir)).unwrap(); + fs_utils::create_dir(&persistent_dir).unwrap(); + write_default_air_interpreter(&air_interpreter_path(&persistent_dir)).unwrap(); let mut config = load_config_with_args(vec![], None) .expect("Could not load config") diff --git a/particle-builtins/src/builtins.rs b/particle-builtins/src/builtins.rs index bb1bfd655e..735b3141f4 100644 --- a/particle-builtins/src/builtins.rs +++ b/particle-builtins/src/builtins.rs @@ -1028,7 +1028,8 @@ fn make_module_config(args: Args) -> Result { let _max_heap_size: Option = Args::next_opt("max_heap_size", &mut args)?; let logger_enabled = Args::next_opt("logger_enabled", &mut args)?; - let preopened_files = Args::next_opt("preopened_files", &mut args)?; + // These are not used anymore, keep them for backward compatibility, because args are positional + let _preopened_files: Option> = Args::next_opt("preopened_files", &mut args)?; let envs = Args::next_opt("envs", &mut args)?.map(table); let mapped_dirs = Args::next_opt("mapped_dirs", &mut args)?.map(table); let mounted_binaries = Args::next_opt("mounted_binaries", &mut args)?.map(table); @@ -1040,11 +1041,7 @@ fn make_module_config(args: Args) -> Result { file_name: None, config: ModuleConfig { logger_enabled, - wasi: Some(WASIConfig { - preopened_files, - envs, - mapped_dirs, - }), + wasi: Some(WASIConfig { envs, mapped_dirs }), mounted_binaries, logging_mask, }, diff --git a/particle-execution/Cargo.toml b/particle-execution/Cargo.toml index 420012f5a9..40d896bd8f 100644 --- a/particle-execution/Cargo.toml +++ b/particle-execution/Cargo.toml @@ -21,3 +21,4 @@ bs58 = { workspace = true } tokio = { workspace = true, features = ["fs"] } parking_lot = { workspace = true } async-trait = { workspace = true } +eyre = { workspace = true } diff --git a/particle-execution/src/particle_vault.rs b/particle-execution/src/particle_vault.rs index d0d87d8a21..5e133c8d1c 100644 --- a/particle-execution/src/particle_vault.rs +++ b/particle-execution/src/particle_vault.rs @@ -14,7 +14,8 @@ * limitations under the License. */ -use fluence_app_service::{MarineWASIConfig, ModuleDescriptor}; +use eyre::eyre; +use fluence_app_service::ModuleDescriptor; use std::io::ErrorKind; use std::path; use std::path::{Path, PathBuf}; @@ -209,19 +210,23 @@ impl ParticleVault { /// Map `vault_dir/$current-peer-id` to `/tmp/vault` inside the service. /// Particle File Vaults will be available as `/tmp/vault/$particle_id` - pub fn inject_vault(&self, current_peer_id: PeerId, module: &mut ModuleDescriptor) { - let wasi = &mut module.config.wasi; - if wasi.is_none() { - *wasi = Some(MarineWASIConfig::default()); - } - // SAFETY: set wasi to Some in the code above - let wasi = wasi.as_mut().unwrap(); + pub fn inject_vault( + &self, + current_peer_id: PeerId, + module: &mut ModuleDescriptor, + ) -> eyre::Result<()> { + let wasi = module + .config + .wasi + .as_mut() + .ok_or(eyre!("Could not inject vault into empty WASI config"))?; let vault_dir = self.real_worker_particle_vault(current_peer_id); - wasi.preopened_files.insert(vault_dir.clone()); wasi.mapped_dirs .insert(VIRTUAL_PARTICLE_VAULT_PREFIX.into(), vault_dir); + + Ok(()) } } diff --git a/particle-services/src/app_services.rs b/particle-services/src/app_services.rs index 2fbf879495..25e903b806 100644 --- a/particle-services/src/app_services.rs +++ b/particle-services/src/app_services.rs @@ -14,13 +14,14 @@ * limitations under the License. */ use std::ops::Deref; +use std::path::Path; use std::time::{Duration, Instant}; use std::{collections::HashMap, sync::Arc}; use derivative::Derivative; use fluence_app_service::{ AppService, AppServiceConfig, AppServiceError, CallParameters, MarineConfig, MarineError, - SecurityTetraplet, ServiceInterface, + MarineWASIConfig, ModuleDescriptor, SecurityTetraplet, ServiceInterface, }; use humantime_serde::re::humantime::format_duration as pretty; use parking_lot::{Mutex, RwLock, RwLockUpgradableReadGuard}; @@ -49,7 +50,8 @@ use crate::error::ServiceError::{AliasAsServiceId, Forbidden, NoSuchAlias}; use crate::health::PersistedServiceHealth; use crate::persistence::{load_persisted_services, remove_persisted_service, PersistedService}; use crate::ServiceError::{ - ForbiddenAlias, ForbiddenAliasRoot, ForbiddenAliasWorker, InternalError, NoSuchService, + FailedToCreateDirectory, ForbiddenAlias, ForbiddenAliasRoot, ForbiddenAliasWorker, + InternalError, NoSuchService, }; type ServiceId = String; @@ -455,7 +457,7 @@ impl ParticleAppServices { peer_pk: st.peer_pk, service_id: st.service_id, function_name: st.function_name, - lambda: st.json_path, + lens: st.json_path, }) .collect() }) @@ -942,6 +944,7 @@ impl ParticleAppServices { blueprint_id.clone(), service_id.clone(), ) + .await .inspect_err(|_| { if let Some(metrics) = self.metrics.as_ref() { metrics.observe_created_failed(); @@ -999,22 +1002,97 @@ impl ParticleAppServices { } } - fn create_app_service( + fn inject_default_wasi(&self, module: &mut ModuleDescriptor) { + let wasi = &mut module.config.wasi; + if wasi.is_none() { + *wasi = Some(MarineWASIConfig::default()); + } + } + + async fn inject_persistent_dirs( + &self, + module: &mut ModuleDescriptor, + persistent_dir: &Path, + ) -> Result<(), ServiceError> { + let module_dir = persistent_dir.join(&module.import_name); + tokio::fs::create_dir_all(&module_dir) + .await + .map_err(|err| FailedToCreateDirectory { + path: module_dir.clone(), + err, + })?; + + let wasi = module.config.wasi.as_mut().ok_or(InternalError( + "Could not inject persistent dirs into empty WASI config".to_string(), + ))?; + wasi.mapped_dirs + .insert("/storage".into(), persistent_dir.to_path_buf()); + wasi.mapped_dirs + .insert("/storage/module".into(), module_dir); + Ok(()) + } + + async fn inject_ephemeral_dirs( + &self, + module: &mut ModuleDescriptor, + ephemeral_dir: &Path, + ) -> Result<(), ServiceError> { + let module_dir = ephemeral_dir.join(&module.import_name); + tokio::fs::create_dir_all(&module_dir) + .await + .map_err(|err| FailedToCreateDirectory { + path: module_dir.clone(), + err, + })?; + + let wasi = module.config.wasi.as_mut().ok_or(InternalError( + "Could not inject ephemeral dirs into empty WASI config".to_string(), + ))?; + wasi.mapped_dirs + .insert("/tmp".into(), ephemeral_dir.to_path_buf()); + wasi.mapped_dirs.insert("/tmp/module".into(), module_dir); + Ok(()) + } + + async fn create_app_service( &self, current_peer_id: PeerId, blueprint_id: String, service_id: String, ) -> Result { - // TODO: Better to create once, when the worker is created but I don't have mental capacity to do it rn - self.vault.initialize_worker(current_peer_id)?; + let persistent_dir = self.config.persistent_work_dir.join(&service_id); + let ephemeral_dir = self.config.ephemeral_work_dir.join(&service_id); + + // TODO: introduce separate errors + tokio::fs::create_dir_all(&persistent_dir) + .await + .map_err(|err| FailedToCreateDirectory { + path: persistent_dir.clone(), + err, + })?; + tokio::fs::create_dir_all(&ephemeral_dir) + .await + .map_err(|err| FailedToCreateDirectory { + path: ephemeral_dir.clone(), + err, + })?; + let mut modules_config = self.modules.resolve_blueprint(&blueprint_id)?; - modules_config - .iter_mut() - .for_each(|module| self.vault.inject_vault(current_peer_id, module)); + + self.vault.initialize_worker(current_peer_id)?; + + for module in modules_config.iter_mut() { + self.inject_default_wasi(module); + // SAFETY: set wasi to Some in the code before calling inject_vault + self.vault.inject_vault(current_peer_id, module).unwrap(); + self.inject_persistent_dirs(module, persistent_dir.as_path()) + .await?; + self.inject_ephemeral_dirs(module, ephemeral_dir.as_path()) + .await?; + } let app_config = AppServiceConfig { - service_working_dir: self.config.workdir.join(&service_id), - service_base_dir: self.config.workdir.clone(), + service_working_dir: persistent_dir, marine_config: MarineConfig { // TODO: add an option to set individual per-service limit total_memory_limit: self @@ -1106,9 +1184,11 @@ mod tests { management_pid: PeerId, base_dir: PathBuf, ) -> ParticleAppServices { - let vault_dir = base_dir.join("..").join("vault"); - let keypairs_dir = base_dir.join("..").join("keypairs"); - let workers_dir = base_dir.join("..").join("workers"); + let persistent_dir = base_dir.join("persistent"); + let ephemeral_dir = base_dir.join("ephemeral"); + let vault_dir = ephemeral_dir.join("vault"); + let keypairs_dir = persistent_dir.join("keypairs"); + let workers_dir = persistent_dir.join("workers"); let service_memory_limit = server_config::default_service_memory_limit(); let key_storage = KeyStorage::from_path(keypairs_dir.clone(), root_keypair.clone().into()) .await @@ -1135,7 +1215,8 @@ mod tests { let config = ServicesConfig::new( PeerId::from(root_keypair.public()), - base_dir, + persistent_dir, + ephemeral_dir, vault_dir, HashMap::new(), management_pid, @@ -1258,7 +1339,7 @@ mod tests { let inter1 = pas.get_interface(PeerScope::Host, service_id1, "").unwrap(); // delete module and check that interfaces will be returned anyway - let dir = modules_dir(base_dir.path()); + let dir = modules_dir(&base_dir.path().to_path_buf().join("persistent")); let module_file = dir.join(format!("{m_hash}.wasm")); tokio::fs::remove_file(module_file.clone()).await.unwrap(); diff --git a/particle-services/src/error.rs b/particle-services/src/error.rs index dcaa2fb777..f55902b708 100644 --- a/particle-services/src/error.rs +++ b/particle-services/src/error.rs @@ -106,6 +106,12 @@ pub enum ServiceError { InternalError(String), #[error("Worker {worker_id} not found")] WorkerNotFound { worker_id: WorkerId }, + #[error("Failed to create directory {path}: {err}")] + FailedToCreateDirectory { + path: PathBuf, + #[source] + err: std::io::Error, + }, } impl From for ServiceError {