mirror of
https://github.com/fluencelabs/marine.git
synced 2024-12-12 14:55:32 +00:00
Switch to stepper-inteface (#50)
This commit is contained in:
parent
2dc09858a8
commit
163036e409
115
Cargo.lock
generated
115
Cargo.lock
generated
@ -47,6 +47,7 @@ dependencies = [
|
|||||||
"maplit",
|
"maplit",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"stepper-interface",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -248,21 +249,11 @@ version = "0.7.8"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "475bd7aa7680b4ed8f6bb59745e882bcbaeb39326532bb79ffb1716480d9a274"
|
checksum = "475bd7aa7680b4ed8f6bb59745e882bcbaeb39326532bb79ffb1716480d9a274"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "console_error_panic_hook"
|
|
||||||
version = "0.1.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if 0.1.10",
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "const_fn"
|
name = "const_fn"
|
||||||
version = "0.4.3"
|
version = "0.4.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab"
|
checksum = "cd51eab21ab4fd6a3bf889e2d0958c0a6e3a61ad04260325e919e652a2a62826"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "constant_time_eq"
|
name = "constant_time_eq"
|
||||||
@ -744,7 +735,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "fluence"
|
name = "fluence"
|
||||||
version = "0.2.11"
|
version = "0.2.11"
|
||||||
source = "git+https://github.com/fluencelabs/rust-sdk#3aab224c9778f6eb8f9750779982f33976bee630"
|
source = "git+https://github.com/fluencelabs/rust-sdk#8a2570bbc630b2a519aee146ac6c5a52d5afe6cd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fluence-sdk-macro 0.2.11 (git+https://github.com/fluencelabs/rust-sdk)",
|
"fluence-sdk-macro 0.2.11 (git+https://github.com/fluencelabs/rust-sdk)",
|
||||||
"fluence-sdk-main 0.2.11 (git+https://github.com/fluencelabs/rust-sdk)",
|
"fluence-sdk-main 0.2.11 (git+https://github.com/fluencelabs/rust-sdk)",
|
||||||
@ -800,7 +791,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "fluence-sdk-macro"
|
name = "fluence-sdk-macro"
|
||||||
version = "0.2.11"
|
version = "0.2.11"
|
||||||
source = "git+https://github.com/fluencelabs/rust-sdk#3aab224c9778f6eb8f9750779982f33976bee630"
|
source = "git+https://github.com/fluencelabs/rust-sdk#8a2570bbc630b2a519aee146ac6c5a52d5afe6cd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fluence-sdk-wit 0.2.11 (git+https://github.com/fluencelabs/rust-sdk)",
|
"fluence-sdk-wit 0.2.11 (git+https://github.com/fluencelabs/rust-sdk)",
|
||||||
]
|
]
|
||||||
@ -819,7 +810,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "fluence-sdk-main"
|
name = "fluence-sdk-main"
|
||||||
version = "0.2.11"
|
version = "0.2.11"
|
||||||
source = "git+https://github.com/fluencelabs/rust-sdk#3aab224c9778f6eb8f9750779982f33976bee630"
|
source = "git+https://github.com/fluencelabs/rust-sdk#8a2570bbc630b2a519aee146ac6c5a52d5afe6cd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fluence-sdk-macro 0.2.11 (git+https://github.com/fluencelabs/rust-sdk)",
|
"fluence-sdk-macro 0.2.11 (git+https://github.com/fluencelabs/rust-sdk)",
|
||||||
"log",
|
"log",
|
||||||
@ -843,7 +834,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "fluence-sdk-wit"
|
name = "fluence-sdk-wit"
|
||||||
version = "0.2.11"
|
version = "0.2.11"
|
||||||
source = "git+https://github.com/fluencelabs/rust-sdk#3aab224c9778f6eb8f9750779982f33976bee630"
|
source = "git+https://github.com/fluencelabs/rust-sdk#8a2570bbc630b2a519aee146ac6c5a52d5afe6cd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -1092,9 +1083,9 @@ checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "http"
|
name = "http"
|
||||||
version = "0.2.1"
|
version = "0.2.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9"
|
checksum = "84129d298a6d57d246960ff8eb831ca4af3f96d29e2e28848dae275408658e26"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"fnv",
|
"fnv",
|
||||||
@ -1194,9 +1185,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "1.6.0"
|
version = "1.6.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2"
|
checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
@ -1213,9 +1204,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "inventory"
|
name = "inventory"
|
||||||
version = "0.1.9"
|
version = "0.1.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fedd49de24d8c263613701406611410687148ae8c37cd6452650b250f753a0dd"
|
checksum = "0f0f7efb804ec95e33db9ad49e4252f049e37e8b0a4652e3cd61f7999f2eff7f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ctor",
|
"ctor",
|
||||||
"ghost",
|
"ghost",
|
||||||
@ -1224,9 +1215,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "inventory-impl"
|
name = "inventory-impl"
|
||||||
version = "0.1.9"
|
version = "0.1.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ddead8880bc50f57fcd3b5869a7f6ff92570bb4e8f6870c22e2483272f2256da"
|
checksum = "75c094e94816723ab936484666968f5b58060492e880f3c8d00489a1e244fa51"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -1484,9 +1475,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "net2"
|
name = "net2"
|
||||||
version = "0.2.36"
|
version = "0.2.37"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d7cf75f38f16cb05ea017784dc6dbfd354f76c223dba37701734c4f5a9337d02"
|
checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
"libc",
|
"libc",
|
||||||
@ -1585,12 +1576,12 @@ checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl"
|
name = "openssl"
|
||||||
version = "0.10.30"
|
version = "0.10.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8d575eff3665419f9b83678ff2815858ad9d11567e082f5ac1814baba4e2bcb4"
|
checksum = "8d008f51b1acffa0d3450a68606e6a51c123012edaacb0f4e1426bd978869187"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cfg-if 0.1.10",
|
"cfg-if 1.0.0",
|
||||||
"foreign-types",
|
"foreign-types",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
"libc",
|
||||||
@ -1605,9 +1596,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl-sys"
|
name = "openssl-sys"
|
||||||
version = "0.9.58"
|
version = "0.9.59"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de"
|
checksum = "de52d8eabd217311538a39bba130d7dea1f1e118010fee7a033d966845e7d5fe"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"cc",
|
"cc",
|
||||||
@ -1927,9 +1918,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "reqwest"
|
name = "reqwest"
|
||||||
version = "0.10.9"
|
version = "0.10.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fb15d6255c792356a0f578d8a645c677904dc02e862bebe2ecc18e0c01b9a0ce"
|
checksum = "0718f81a8e14c4dbb3b34cf23dc6aaf9ab8a0dfec160c534b3dbca1aaa21f47c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"bytes",
|
"bytes",
|
||||||
@ -1956,7 +1947,6 @@ dependencies = [
|
|||||||
"url",
|
"url",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"wasm-bindgen-futures",
|
"wasm-bindgen-futures",
|
||||||
"wasm-bindgen-test",
|
|
||||||
"web-sys",
|
"web-sys",
|
||||||
"winreg",
|
"winreg",
|
||||||
]
|
]
|
||||||
@ -2046,12 +2036,6 @@ dependencies = [
|
|||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "scoped-tls"
|
|
||||||
version = "1.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scopeguard"
|
name = "scopeguard"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
@ -2203,13 +2187,12 @@ checksum = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "socket2"
|
name = "socket2"
|
||||||
version = "0.3.17"
|
version = "0.3.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2c29947abdee2a218277abeca306f25789c938e500ea5a9d4b12a5a504466902"
|
checksum = "97e0e9fd577458a4f61fb91fcb559ea2afecc54c934119421f9f5d3d5b1a1057"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"libc",
|
"libc",
|
||||||
"redox_syscall",
|
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -2219,6 +2202,16 @@ version = "1.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "stepper-interface"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/fluencelabs/aquamarine?branch=new_stepper_outcome#7b70f015be7297f1d53336d64d2119148b1d44cc"
|
||||||
|
dependencies = [
|
||||||
|
"fluence 0.2.11 (git+https://github.com/fluencelabs/rust-sdk)",
|
||||||
|
"serde",
|
||||||
|
"wasmer-interface-types-fl",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strsim"
|
name = "strsim"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
@ -2233,9 +2226,9 @@ checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "subtle"
|
name = "subtle"
|
||||||
version = "2.3.0"
|
version = "2.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd"
|
checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
@ -2382,9 +2375,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "0.2.23"
|
version = "0.2.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a6d7ad61edd59bfcc7e80dababf0f4aed2e6d5e0ba1659356ae889752dfc12ff"
|
checksum = "099837d3464c16a808060bb3f02263b412f6fafcb5d01c533d309985fbeebe48"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"fnv",
|
"fnv",
|
||||||
@ -2609,9 +2602,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vcpkg"
|
name = "vcpkg"
|
||||||
version = "0.2.10"
|
version = "0.2.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c"
|
checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vec_map"
|
name = "vec_map"
|
||||||
@ -2756,30 +2749,6 @@ version = "0.2.69"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158"
|
checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen-test"
|
|
||||||
version = "0.3.19"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0355fa0c1f9b792a09b6dcb6a8be24d51e71e6d74972f9eb4a44c4c004d24a25"
|
|
||||||
dependencies = [
|
|
||||||
"console_error_panic_hook",
|
|
||||||
"js-sys",
|
|
||||||
"scoped-tls",
|
|
||||||
"wasm-bindgen",
|
|
||||||
"wasm-bindgen-futures",
|
|
||||||
"wasm-bindgen-test-macro",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasm-bindgen-test-macro"
|
|
||||||
version = "0.3.19"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "27e07b46b98024c2ba2f9e83a10c2ef0515f057f2da299c1762a2017de80438b"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-greeting"
|
name = "wasm-greeting"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -12,6 +12,7 @@ path = "src/lib.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
fluence-faas = { path = "../fluence-faas", version = "0.1.11" }
|
fluence-faas = { path = "../fluence-faas", version = "0.1.11" }
|
||||||
|
stepper-interface = { git = "https://github.com/fluencelabs/aquamarine", branch = "new_stepper_outcome" }
|
||||||
|
|
||||||
maplit = "1.0.2"
|
maplit = "1.0.2"
|
||||||
serde_json = "1.0.57"
|
serde_json = "1.0.57"
|
||||||
|
@ -17,15 +17,13 @@
|
|||||||
use crate::Result;
|
use crate::Result;
|
||||||
use crate::AquamarineVMError;
|
use crate::AquamarineVMError;
|
||||||
use crate::config::AquamarineVMConfig;
|
use crate::config::AquamarineVMConfig;
|
||||||
use crate::stepper_outcome::StepperOutcome;
|
|
||||||
use crate::stepper_outcome::RawStepperOutcome;
|
|
||||||
|
|
||||||
use fluence_faas::FaaSConfig;
|
use fluence_faas::FaaSConfig;
|
||||||
use fluence_faas::FluenceFaaS;
|
use fluence_faas::FluenceFaaS;
|
||||||
use fluence_faas::HostImportDescriptor;
|
use fluence_faas::HostImportDescriptor;
|
||||||
use fluence_faas::IValue;
|
use fluence_faas::IValue;
|
||||||
|
use stepper_interface::StepperOutcome;
|
||||||
|
|
||||||
use std::convert::TryInto;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use crate::errors::AquamarineVMError::InvalidAquamarinePath;
|
use crate::errors::AquamarineVMError::InvalidAquamarinePath;
|
||||||
@ -80,7 +78,7 @@ impl AquamarineVM {
|
|||||||
|
|
||||||
let prev_data_path = self.particle_data_store.join(particle_id);
|
let prev_data_path = self.particle_data_store.join(particle_id);
|
||||||
// TODO: check for errors related to invalid file content (such as invalid UTF8 string)
|
// TODO: check for errors related to invalid file content (such as invalid UTF8 string)
|
||||||
let prev_data = std::fs::read_to_string(&prev_data_path).unwrap_or(String::from("[]"));
|
let prev_data = std::fs::read_to_string(&prev_data_path).unwrap_or_default();
|
||||||
let args = vec![
|
let args = vec![
|
||||||
IValue::String(init_user_id.into()),
|
IValue::String(init_user_id.into()),
|
||||||
IValue::String(aqua.into()),
|
IValue::String(aqua.into()),
|
||||||
@ -92,11 +90,14 @@ impl AquamarineVM {
|
|||||||
self.faas
|
self.faas
|
||||||
.call_with_ivalues(&self.wasm_filename, "invoke", &args, <_>::default())?;
|
.call_with_ivalues(&self.wasm_filename, "invoke", &args, <_>::default())?;
|
||||||
|
|
||||||
let raw_outcome = make_raw_outcome(result)?;
|
let outcome = StepperOutcome::from_ivalues(result)
|
||||||
std::fs::write(&prev_data_path, &raw_outcome.data)
|
.map_err(AquamarineVMError::StepperResultDeError)?;
|
||||||
|
|
||||||
|
// persist resulted data
|
||||||
|
std::fs::write(&prev_data_path, &outcome.data)
|
||||||
.map_err(|e| PersistDataError(e, prev_data_path))?;
|
.map_err(|e| PersistDataError(e, prev_data_path))?;
|
||||||
|
|
||||||
raw_outcome.try_into()
|
Ok(outcome)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,26 +139,21 @@ fn make_faas_config(
|
|||||||
current_peer_id: String,
|
current_peer_id: String,
|
||||||
logging_mask: i64,
|
logging_mask: i64,
|
||||||
) -> FaaSConfig {
|
) -> FaaSConfig {
|
||||||
use maplit::hashmap;
|
|
||||||
|
|
||||||
let make_faas_module_config = |call_service: HostImportDescriptor| {
|
|
||||||
use fluence_faas::FaaSModuleConfig;
|
use fluence_faas::FaaSModuleConfig;
|
||||||
|
use maplit::hashmap;
|
||||||
|
|
||||||
let host_imports = hashmap! {
|
let host_imports = hashmap! {
|
||||||
String::from(CALL_SERVICE_NAME) => call_service
|
String::from(CALL_SERVICE_NAME) => call_service
|
||||||
};
|
};
|
||||||
|
|
||||||
FaaSModuleConfig {
|
let mut aquamarine_module_config = FaaSModuleConfig {
|
||||||
mem_pages_count: None,
|
mem_pages_count: None,
|
||||||
logger_enabled: true,
|
logger_enabled: true,
|
||||||
host_imports,
|
host_imports,
|
||||||
wasi: None,
|
wasi: None,
|
||||||
logging_mask,
|
logging_mask,
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut aquamarine_module_config = make_faas_module_config(call_service);
|
|
||||||
|
|
||||||
let envs = hashmap! {
|
let envs = hashmap! {
|
||||||
CURRENT_PEER_ID_ENV_NAME.as_bytes().to_vec() => current_peer_id.into_bytes(),
|
CURRENT_PEER_ID_ENV_NAME.as_bytes().to_vec() => current_peer_id.into_bytes(),
|
||||||
};
|
};
|
||||||
@ -170,75 +166,6 @@ fn make_faas_config(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_raw_outcome(mut result: Vec<IValue>) -> Result<RawStepperOutcome> {
|
|
||||||
use AquamarineVMError::AquamarineResultError as ResultError;
|
|
||||||
|
|
||||||
match result.remove(0) {
|
|
||||||
IValue::Record(record_values) => {
|
|
||||||
let mut record_values = record_values.into_vec();
|
|
||||||
if record_values.len() != 3 {
|
|
||||||
return Err(ResultError(format!(
|
|
||||||
"expected StepperOutcome struct with 3 fields, got {:?}",
|
|
||||||
record_values
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
let ret_code = match record_values.remove(0) {
|
|
||||||
IValue::S32(ret_code) => ret_code,
|
|
||||||
v => {
|
|
||||||
return Err(ResultError(format!(
|
|
||||||
"expected i32 for ret_code, got {:?}",
|
|
||||||
v
|
|
||||||
)))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let data = match record_values.remove(0) {
|
|
||||||
IValue::String(str) => str,
|
|
||||||
v => {
|
|
||||||
return Err(ResultError(format!(
|
|
||||||
"expected string for data, got {:?}",
|
|
||||||
v
|
|
||||||
)))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let next_peer_pks = match record_values.remove(0) {
|
|
||||||
IValue::Array(ar_values) => {
|
|
||||||
let array = ar_values
|
|
||||||
.into_iter()
|
|
||||||
.map(|v| match v {
|
|
||||||
IValue::String(str) => Ok(str),
|
|
||||||
v => Err(ResultError(format!(
|
|
||||||
"expected string for next_peer_pks, got {:?}",
|
|
||||||
v
|
|
||||||
))),
|
|
||||||
})
|
|
||||||
.collect::<Result<Vec<String>>>()?;
|
|
||||||
|
|
||||||
Ok(array)
|
|
||||||
}
|
|
||||||
v => Err(ResultError(format!(
|
|
||||||
"expected array for next_peer_pks, got {:?}",
|
|
||||||
v
|
|
||||||
))),
|
|
||||||
}?;
|
|
||||||
|
|
||||||
Ok(RawStepperOutcome {
|
|
||||||
ret_code,
|
|
||||||
data,
|
|
||||||
next_peer_pks,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
v => {
|
|
||||||
return Err(ResultError(format!(
|
|
||||||
"expected record for StepperOutcome, got {:?}",
|
|
||||||
v
|
|
||||||
)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This API is intended for testing purposes
|
// This API is intended for testing purposes
|
||||||
#[cfg(feature = "raw-aquamarine-vm-api")]
|
#[cfg(feature = "raw-aquamarine-vm-api")]
|
||||||
impl AquamarineVM {
|
impl AquamarineVM {
|
||||||
@ -260,7 +187,9 @@ impl AquamarineVM {
|
|||||||
self.faas
|
self.faas
|
||||||
.call_with_ivalues(&self.wasm_filename, "invoke", &args, <_>::default())?;
|
.call_with_ivalues(&self.wasm_filename, "invoke", &args, <_>::default())?;
|
||||||
|
|
||||||
let raw_outcome = make_raw_outcome(result)?;
|
let outcome = StepperOutcome::from_ivalues(result)
|
||||||
raw_outcome.try_into()
|
.map_err(AquamarineVMError::StepperResultDeError)?;
|
||||||
|
|
||||||
|
Ok(outcome)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use crate::stepper_outcome::StepperError;
|
|
||||||
use fluence_faas::FaaSError;
|
use fluence_faas::FaaSError;
|
||||||
|
|
||||||
use std::io::Error as IOError;
|
use std::io::Error as IOError;
|
||||||
@ -26,11 +25,8 @@ pub enum AquamarineVMError {
|
|||||||
/// FaaS errors.
|
/// FaaS errors.
|
||||||
FaaSError(FaaSError),
|
FaaSError(FaaSError),
|
||||||
|
|
||||||
/// Aquamarine result deserialization errors.
|
/// Aquamarine stepper result deserialization errors.
|
||||||
AquamarineResultError(String),
|
StepperResultDeError(String),
|
||||||
|
|
||||||
/// Errors related to stepper execution.
|
|
||||||
StepperError(StepperError),
|
|
||||||
|
|
||||||
/// I/O errors while persisting resulted data.
|
/// I/O errors while persisting resulted data.
|
||||||
PersistDataError(IOError, PathBuf),
|
PersistDataError(IOError, PathBuf),
|
||||||
@ -52,8 +48,7 @@ impl std::fmt::Display for AquamarineVMError {
|
|||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
||||||
match self {
|
match self {
|
||||||
AquamarineVMError::FaaSError(err) => write!(f, "{}", err),
|
AquamarineVMError::FaaSError(err) => write!(f, "{}", err),
|
||||||
AquamarineVMError::AquamarineResultError(err_msg) => write!(f, "{}", err_msg),
|
AquamarineVMError::StepperResultDeError(err_msg) => write!(f, "{}", err_msg),
|
||||||
AquamarineVMError::StepperError(err) => write!(f, "{}", err),
|
|
||||||
AquamarineVMError::PersistDataError(err, path) => write!(
|
AquamarineVMError::PersistDataError(err, path) => write!(
|
||||||
f,
|
f,
|
||||||
"an error occurred while saving prev data {:?} by {:?} path",
|
"an error occurred while saving prev data {:?} by {:?} path",
|
||||||
@ -69,13 +64,11 @@ impl std::fmt::Display for AquamarineVMError {
|
|||||||
invalid_path,
|
invalid_path,
|
||||||
io_error,
|
io_error,
|
||||||
reason,
|
reason,
|
||||||
} => {
|
} => write!(
|
||||||
write!(
|
|
||||||
f,
|
f,
|
||||||
"path to AIR interpreter .wasm ({:?}) is invalid: {}; IO Error: {:?}",
|
"path to AIR interpreter .wasm ({:?}) is invalid: {}; IO Error: {:?}",
|
||||||
invalid_path, reason, io_error
|
invalid_path, reason, io_error
|
||||||
)
|
),
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,12 +79,6 @@ impl From<FaaSError> for AquamarineVMError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<StepperError> for AquamarineVMError {
|
|
||||||
fn from(err: StepperError) -> Self {
|
|
||||||
AquamarineVMError::StepperError(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<std::convert::Infallible> for AquamarineVMError {
|
impl From<std::convert::Infallible> for AquamarineVMError {
|
||||||
fn from(_: std::convert::Infallible) -> Self {
|
fn from(_: std::convert::Infallible) -> Self {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
|
@ -27,13 +27,10 @@
|
|||||||
mod aquamarine_stepper_vm;
|
mod aquamarine_stepper_vm;
|
||||||
mod config;
|
mod config;
|
||||||
mod errors;
|
mod errors;
|
||||||
mod stepper_outcome;
|
|
||||||
|
|
||||||
pub use aquamarine_stepper_vm::AquamarineVM;
|
pub use aquamarine_stepper_vm::AquamarineVM;
|
||||||
pub use config::AquamarineVMConfig;
|
pub use config::AquamarineVMConfig;
|
||||||
pub use errors::AquamarineVMError;
|
pub use errors::AquamarineVMError;
|
||||||
pub use stepper_outcome::StepperOutcome;
|
|
||||||
pub use stepper_outcome::StepperError;
|
|
||||||
|
|
||||||
// Re-exports
|
// Re-exports
|
||||||
pub use fluence_faas::HostExportedFunc;
|
pub use fluence_faas::HostExportedFunc;
|
||||||
|
@ -1,176 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020 Fluence Labs Limited
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// This file is an adapted copy of the StepperOutcome structure and stepper errors.
|
|
||||||
// Maybe it is better to depend on aquamarine when it become public.
|
|
||||||
|
|
||||||
use crate::AquamarineVMError;
|
|
||||||
|
|
||||||
use std::convert::TryFrom;
|
|
||||||
use std::error::Error;
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
|
||||||
pub(crate) struct RawStepperOutcome {
|
|
||||||
pub ret_code: i32,
|
|
||||||
pub data: String,
|
|
||||||
pub next_peer_pks: Vec<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
|
||||||
pub struct StepperOutcome {
|
|
||||||
pub data: String,
|
|
||||||
pub next_peer_pks: Vec<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
||||||
pub enum StepperError {
|
|
||||||
/// Errors occurred while parsing aqua script in the form of S expressions.
|
|
||||||
SExprParseError(String),
|
|
||||||
|
|
||||||
/// Errors occurred while parsing function arguments of an expression.
|
|
||||||
FuncArgsSerializationError(String),
|
|
||||||
|
|
||||||
/// Errors occurred while parsing returned by call_service value.
|
|
||||||
CallServiceResultDeserializationError(String),
|
|
||||||
|
|
||||||
/// Indicates that environment variable with name CURRENT_PEER_ID isn't set.
|
|
||||||
CurrentPeerIdEnvError(String),
|
|
||||||
|
|
||||||
/// Semantic errors in instructions.
|
|
||||||
InstructionError(String),
|
|
||||||
|
|
||||||
/// An error is occurred while calling local service via call_service.
|
|
||||||
LocalServiceError(String),
|
|
||||||
|
|
||||||
/// Value for such name isn't presence in data.
|
|
||||||
VariableNotFound(String),
|
|
||||||
|
|
||||||
/// Multiple values for such name found.
|
|
||||||
MultipleVariablesFound(String),
|
|
||||||
|
|
||||||
/// Value with such path wasn't found in data with such error.
|
|
||||||
VariableNotInJsonPath(String),
|
|
||||||
|
|
||||||
/// Provided JValue has incompatible with target type.
|
|
||||||
IncompatibleJValueType(String),
|
|
||||||
|
|
||||||
/// Provided AValue has incompatible with target type.
|
|
||||||
IncompatibleAValueType(String),
|
|
||||||
|
|
||||||
/// Multiple values found for such json path.
|
|
||||||
MultipleValuesInJsonPath(String),
|
|
||||||
|
|
||||||
/// Fold state wasn't found for such iterator name.
|
|
||||||
FoldStateNotFound(String),
|
|
||||||
|
|
||||||
/// Multiple fold states found for such iterator name.
|
|
||||||
MultipleFoldStates(String),
|
|
||||||
|
|
||||||
/// Expected evidence state of different type.
|
|
||||||
InvalidEvidenceState(String),
|
|
||||||
|
|
||||||
/// Errors occurred on call evidence deserialization.
|
|
||||||
CallEvidenceDeserializationError(String),
|
|
||||||
|
|
||||||
/// Errors occurred on call evidence serialization.
|
|
||||||
CallEvidenceSerializationError(String),
|
|
||||||
|
|
||||||
/// Errors occurred when previous and current evidence states are incompatible.
|
|
||||||
IncompatibleEvidenceStates(String),
|
|
||||||
|
|
||||||
/// Errors occurred when previous and current call results are incompatible.
|
|
||||||
IncompatibleCallResults(String),
|
|
||||||
|
|
||||||
/// Errors occurred when evidence path contains less elements then corresponding Par has.
|
|
||||||
EvidencePathTooSmall(String),
|
|
||||||
|
|
||||||
/// Related to such ret_code that doesn't have match with current StepperError.
|
|
||||||
UnknownError(String),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Error for StepperError {}
|
|
||||||
|
|
||||||
impl std::fmt::Display for StepperError {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
|
||||||
match self {
|
|
||||||
StepperError::SExprParseError(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::FuncArgsSerializationError(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::CallServiceResultDeserializationError(err_msg) => {
|
|
||||||
writeln!(f, "{}", err_msg)
|
|
||||||
}
|
|
||||||
StepperError::CurrentPeerIdEnvError(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::InstructionError(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::LocalServiceError(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::VariableNotFound(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::MultipleVariablesFound(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::VariableNotInJsonPath(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::IncompatibleJValueType(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::IncompatibleAValueType(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::MultipleValuesInJsonPath(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::FoldStateNotFound(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::MultipleFoldStates(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::InvalidEvidenceState(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::CallEvidenceDeserializationError(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::CallEvidenceSerializationError(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::IncompatibleEvidenceStates(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::IncompatibleCallResults(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::EvidencePathTooSmall(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
StepperError::UnknownError(err_msg) => writeln!(f, "{}", err_msg),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TryFrom<RawStepperOutcome> for StepperOutcome {
|
|
||||||
type Error = AquamarineVMError;
|
|
||||||
|
|
||||||
fn try_from(raw_outcome: RawStepperOutcome) -> Result<Self, Self::Error> {
|
|
||||||
macro_rules! to_vm_error {
|
|
||||||
($error_variant:ident) => {
|
|
||||||
Err(AquamarineVMError::StepperError(
|
|
||||||
StepperError::$error_variant(raw_outcome.data),
|
|
||||||
))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
match raw_outcome.ret_code {
|
|
||||||
0 => Ok(StepperOutcome {
|
|
||||||
data: raw_outcome.data,
|
|
||||||
next_peer_pks: raw_outcome.next_peer_pks,
|
|
||||||
}),
|
|
||||||
1 => to_vm_error!(SExprParseError),
|
|
||||||
2 => to_vm_error!(FuncArgsSerializationError),
|
|
||||||
3 => to_vm_error!(CallServiceResultDeserializationError),
|
|
||||||
4 => to_vm_error!(CurrentPeerIdEnvError),
|
|
||||||
5 => to_vm_error!(InstructionError),
|
|
||||||
6 => to_vm_error!(LocalServiceError),
|
|
||||||
7 => to_vm_error!(VariableNotFound),
|
|
||||||
8 => to_vm_error!(MultipleVariablesFound),
|
|
||||||
9 => to_vm_error!(VariableNotInJsonPath),
|
|
||||||
10 => to_vm_error!(IncompatibleJValueType),
|
|
||||||
11 => to_vm_error!(IncompatibleAValueType),
|
|
||||||
12 => to_vm_error!(MultipleValuesInJsonPath),
|
|
||||||
13 => to_vm_error!(FoldStateNotFound),
|
|
||||||
14 => to_vm_error!(MultipleFoldStates),
|
|
||||||
15 => to_vm_error!(InvalidEvidenceState),
|
|
||||||
16 => to_vm_error!(CallEvidenceDeserializationError),
|
|
||||||
17 => to_vm_error!(CallEvidenceSerializationError),
|
|
||||||
18 => to_vm_error!(IncompatibleEvidenceStates),
|
|
||||||
19 => to_vm_error!(IncompatibleCallResults),
|
|
||||||
20 => to_vm_error!(EvidencePathTooSmall),
|
|
||||||
_ => to_vm_error!(UnknownError),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user