diff --git a/Cargo.lock b/Cargo.lock index 7e099ebb..809e480f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -213,12 +213,12 @@ version = "0.1.0" [[package]] name = "avm-server" -version = "0.11.1" +version = "0.12.0" dependencies = [ "air-interpreter-interface", "avm-data-store", "eyre", - "fluence-faas", + "fluence-faas 0.10.0", "log", "maplit", "parking_lot 0.11.2", @@ -303,6 +303,15 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytesize" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c58ec36aac5066d5ca17df51b3e70279f5670a72102f5752cb7e7c856adfc70" +dependencies = [ + "serde", +] + [[package]] name = "cargo_toml" version = "0.8.1" @@ -593,6 +602,41 @@ dependencies = [ "syn", ] +[[package]] +name = "darling" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" +dependencies = [ + "darling_core", + "quote", + "syn", +] + [[package]] name = "diff" version = "0.1.12" @@ -724,7 +768,7 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01c66660de99826038c5ec4ad0f5dccf10b1c8a15924aeaa5315ab49d718bfc9" dependencies = [ - "fluence-faas", + "fluence-faas 0.9.3", "log", "maplit", "serde", @@ -746,8 +790,8 @@ dependencies = [ "marine-module-interface", "marine-rs-sdk", "marine-rs-sdk-main", - "marine-runtime", - "marine-utils", + "marine-runtime 0.7.2", + "marine-utils 0.2.0", "safe-transmute", "serde", "serde_derive", @@ -760,6 +804,34 @@ dependencies = [ "wasmer-wasi-fl", ] +[[package]] +name = "fluence-faas" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bbb9c5b3178f6374e0b14f12fbfa661c7232b7567cdb65b3c718f1ff38ca597" +dependencies = [ + "bytesize", + "cmd_lib", + "itertools 0.9.0", + "log", + "marine-module-interface", + "marine-rs-sdk", + "marine-rs-sdk-main", + "marine-runtime 0.8.0", + "marine-utils 0.3.0", + "safe-transmute", + "serde", + "serde_derive", + "serde_json", + "serde_with", + "thiserror", + "toml", + "wasmer-interface-types-fl", + "wasmer-runtime-core-fl", + "wasmer-runtime-fl", + "wasmer-wasi-fl", +] + [[package]] name = "fluence-it-types" version = "0.3.1" @@ -773,6 +845,12 @@ dependencies = [ "wast", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "fstrings" version = "0.2.3" @@ -918,6 +996,12 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "indenter" version = "0.3.3" @@ -1256,12 +1340,42 @@ dependencies = [ "marine-it-parser", "marine-module-info-parser", "marine-module-interface", - "marine-utils", + "marine-utils 0.2.0", "multimap", "once_cell", - "parity-wasm", + "parity-wasm 0.41.0", "paste", - "pwasm-utils", + "pwasm-utils 0.12.0", + "semver 0.11.0", + "serde", + "thiserror", + "wasmer-interface-types-fl", + "wasmer-runtime-core-fl", + "wasmer-runtime-fl", + "wasmer-wasi-fl", +] + +[[package]] +name = "marine-runtime" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be19d5b67f04a8ad65f334a4382b15156a3e130e41c58ea44ba9f95f9966bbaa" +dependencies = [ + "anyhow", + "boolinator", + "it-lilo", + "log", + "marine-it-generator", + "marine-it-interfaces", + "marine-it-parser", + "marine-module-info-parser", + "marine-module-interface", + "marine-utils 0.3.0", + "multimap", + "once_cell", + "parity-wasm 0.42.2", + "paste", + "pwasm-utils 0.18.2", "semver 0.11.0", "serde", "thiserror", @@ -1287,6 +1401,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8dc5838acba84ce4d802d672afd0814fae0ae7098021ae5b06d975e70d09f812" +[[package]] +name = "marine-utils" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a227f549086e34de1d9d4d1f21823eacdce55839a85fc44a2dfb9f244f3fdcc" + [[package]] name = "memchr" version = "2.4.1" @@ -1426,6 +1546,12 @@ version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfc878dac00da22f8f61e7af3157988424567ab01d9920b962ef7dcbd7cd865" +[[package]] +name = "parity-wasm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" + [[package]] name = "parking_lot" version = "0.10.2" @@ -1593,7 +1719,18 @@ checksum = "4f7a12f176deee919f4ba55326ee17491c8b707d0987aed822682c821b660192" dependencies = [ "byteorder", "log", - "parity-wasm", + "parity-wasm 0.41.0", +] + +[[package]] +name = "pwasm-utils" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "880b3384fb00b8f6ecccd5d358b93bd2201900ae3daad213791d1864f6441f5c" +dependencies = [ + "byteorder", + "log", + "parity-wasm 0.42.2", ] [[package]] @@ -1848,6 +1985,29 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_with" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad6056b4cb69b6e43e3a0f055def223380baecc99da683884f205bf347f7c4b3" +dependencies = [ + "rustversion", + "serde", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12e47be9471c72889ebafb5e14d5ff930d89ae7a67bbdb5f8abb564f845a927e" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "siphasher" version = "0.3.7" @@ -1879,6 +2039,12 @@ dependencies = [ "precomputed-hash", ] +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "strum" version = "0.21.0" diff --git a/avm/server/Cargo.toml b/avm/server/Cargo.toml index fd1ff348..6a5aadbf 100644 --- a/avm/server/Cargo.toml +++ b/avm/server/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "avm-server" description = "Fluence AIR VM" -version = "0.11.1" +version = "0.12.0" authors = ["Fluence Labs"] edition = "2018" license = "Apache-2.0" @@ -18,7 +18,7 @@ path = "src/lib.rs" [dependencies] air-interpreter-interface = { version = "0.7.0", path = "../../crates/air-lib/interpreter-interface" } avm-data-store = { version = "0.1.0", path = "../../crates/data-store" } -fluence-faas = "0.9.3" +fluence-faas = "0.10.0" polyplets = { version = "0.2.0", path = "../../crates/air-lib/polyplets" } eyre = "0.6.5" diff --git a/avm/server/src/avm.rs b/avm/server/src/avm.rs index 7c3b6912..6f079f8b 100644 --- a/avm/server/src/avm.rs +++ b/avm/server/src/avm.rs @@ -55,13 +55,14 @@ impl AVM { let AVMConfig { air_wasm_path, current_peer_id, + max_heap_size, logging_mask, mut data_store, } = config; data_store.initialize()?; - let runner = AVMRunner::new(air_wasm_path, current_peer_id, logging_mask) + let runner = AVMRunner::new(air_wasm_path, current_peer_id, max_heap_size, logging_mask) .map_err(AVMError::RunnerError)?; let runner = SendSafeRunner(runner); let avm = Self { runner, data_store }; diff --git a/avm/server/src/config.rs b/avm/server/src/config.rs index ce7c3bcc..b74a03bd 100644 --- a/avm/server/src/config.rs +++ b/avm/server/src/config.rs @@ -25,6 +25,9 @@ pub struct AVMConfig { /// Current peer id. pub current_peer_id: String, + /// Maximum heap size in bytes available for the interpreter. + pub max_heap_size: Option, + /// Mask used to filter logs, for details see `log_utf8_string` in fluence-faas. pub logging_mask: i32, diff --git a/avm/server/src/runner.rs b/avm/server/src/runner.rs index 1d0172cc..e116e395 100644 --- a/avm/server/src/runner.rs +++ b/avm/server/src/runner.rs @@ -39,11 +39,12 @@ impl AVMRunner { pub fn new( air_wasm_path: PathBuf, current_peer_id: impl Into, + max_heap_size: Option, logging_mask: i32, ) -> RunnerResult { let (wasm_dir, wasm_filename) = split_dirname(air_wasm_path)?; - let faas_config = make_faas_config(wasm_dir, &wasm_filename, logging_mask); + let faas_config = make_faas_config(wasm_dir, &wasm_filename, max_heap_size, logging_mask); let faas = FluenceFaaS::with_raw_config(faas_config)?; let current_peer_id = current_peer_id.into(); @@ -149,9 +150,15 @@ fn split_dirname(path: PathBuf) -> RunnerResult<(PathBuf, String)> { Ok((path, file_name)) } -fn make_faas_config(air_wasm_dir: PathBuf, air_wasm_file: &str, logging_mask: i32) -> FaaSConfig { +fn make_faas_config( + air_wasm_dir: PathBuf, + air_wasm_file: &str, + max_heap_size: Option, + logging_mask: i32, +) -> FaaSConfig { let air_module_config = fluence_faas::FaaSModuleConfig { mem_pages_count: None, + max_heap_size, logger_enabled: true, host_imports: <_>::default(), wasi: None, diff --git a/crates/air-lib/test-utils/src/test_runner.rs b/crates/air-lib/test-utils/src/test_runner.rs index c18c1fd1..5877895b 100644 --- a/crates/air-lib/test-utils/src/test_runner.rs +++ b/crates/air-lib/test-utils/src/test_runner.rs @@ -21,6 +21,9 @@ use std::collections::HashMap; use std::collections::HashSet; use std::path::PathBuf; +// 10 Mb +const AVM_MAX_HEAP_SIZE: u64 = 10 * 1024 * 1024; + pub struct TestRunner { pub runner: AVMRunner, pub call_service: CallServiceClosure, @@ -84,8 +87,13 @@ pub fn create_avm( let current_peer_id = current_peer_id.into(); let logging_mask = i32::MAX; - let runner = - AVMRunner::new(air_wasm_path, current_peer_id, logging_mask).expect("vm should be created"); + let runner = AVMRunner::new( + air_wasm_path, + current_peer_id, + Some(AVM_MAX_HEAP_SIZE), + logging_mask, + ) + .expect("vm should be created"); TestRunner { runner, call_service,