mirror of
https://github.com/fluencelabs/marine.git
synced 2024-12-12 06:45:32 +00:00
misc improvements (#24)
- improve error handling in host functions - refactor examples - fix IT generation
This commit is contained in:
parent
aff726b5eb
commit
709dc36550
7
.gitignore
vendored
7
.gitignore
vendored
@ -12,10 +12,7 @@ target/
|
||||
# REPL history files
|
||||
*.repl_history
|
||||
|
||||
# Temporary file of ipfs node example
|
||||
/examples/ipfs_node/wasm/artifacts/ipfs_rpc_file
|
||||
|
||||
# Allowed Wasm files for examples
|
||||
!/examples/greeting/artifacts/*.wasm
|
||||
!/examples/ipfs_node/artifacts/wasm_modules/*.wasm
|
||||
!/examples/records/artifacts/wasm_modules/*.wasm
|
||||
!/examples/ipfs_node/artifacts/*.wasm
|
||||
!/examples/records/artifacts/*.wasm
|
||||
|
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -598,7 +598,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fce-wit-generator"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
dependencies = [
|
||||
"fce-wit-parser",
|
||||
"fluence-sdk-wit 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -630,7 +630,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fcli"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@ -652,7 +652,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fluence-app-service"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"fluence-faas",
|
||||
"log",
|
||||
@ -663,7 +663,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fluence-faas"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"cmd_lib",
|
||||
"fce",
|
||||
@ -768,7 +768,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
||||
|
||||
[[package]]
|
||||
name = "frepl"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "fce-wit-generator"
|
||||
description = "Fluence FCE interface type helper crate"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
authors = ["Fluence Labs"]
|
||||
license = "Apache-2.0"
|
||||
edition = "2018"
|
||||
|
@ -195,7 +195,7 @@ impl ForeignModInstructionGenerator for ParsedType {
|
||||
ParsedType::ByteVector => vec![
|
||||
Instruction::ArgumentGet { index },
|
||||
Instruction::ArgumentGet { index: index + 1 },
|
||||
Instruction::StringLiftMemory,
|
||||
Instruction::ByteArrayLiftMemory,
|
||||
],
|
||||
ParsedType::Record(record_name) => {
|
||||
let type_index = wit_resolver.get_record_type_id(record_name)?;
|
||||
|
@ -1,4 +1,4 @@
|
||||
modules_dir = "artifacts/wasm_modules"
|
||||
modules_dir = "artifacts/"
|
||||
|
||||
[[module]]
|
||||
name = "effector"
|
||||
|
@ -1,13 +1,13 @@
|
||||
[package]
|
||||
name = "fluence-app-service"
|
||||
description = "Fluence Application Service"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
authors = ["Fluence Labs"]
|
||||
license = "Apache-2.0"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
fluence-faas = { path = "../fluence-faas", version = "0.1.1" }
|
||||
fluence-faas = { path = "../fluence-faas", version = "0.1.2" }
|
||||
|
||||
log = "0.4.8"
|
||||
serde_json = "1.0.53"
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "fluence-faas"
|
||||
description = "Fluence FaaS"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
authors = ["Fluence Labs"]
|
||||
license = "Apache-2.0"
|
||||
edition = "2018"
|
||||
|
@ -49,6 +49,7 @@ fn write_to_mem(context: &mut Ctx, address: usize, value: &[u8]) {
|
||||
.for_each(|(cell, byte)| cell.set(*byte));
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub(super) fn create_host_import_func<S>(host_cmd: S) -> DynamicFunc<'static>
|
||||
where
|
||||
S: Into<String>,
|
||||
@ -56,10 +57,8 @@ where
|
||||
use wasmer_core::Func;
|
||||
|
||||
let allocate_func: Box<RefCell<Option<Func<'static, i32, i32>>>> = Box::new(RefCell::new(None));
|
||||
let set_result_ptr_func: Box<RefCell<Option<Func<'static, i32, ()>>>> =
|
||||
Box::new(RefCell::new(None));
|
||||
let set_result_size_func: Box<RefCell<Option<Func<'static, i32, ()>>>> =
|
||||
Box::new(RefCell::new(None));
|
||||
let set_result_ptr_func: Box<RefCell<Option<Func<'static, i32, ()>>>> = Box::new(RefCell::new(None));
|
||||
let set_result_size_func: Box<RefCell<Option<Func<'static, i32, ()>>>> = Box::new(RefCell::new(None));
|
||||
|
||||
let host_cmd = host_cmd.into();
|
||||
|
||||
@ -73,8 +72,18 @@ where
|
||||
|
||||
let wasm_ptr = WasmPtr::<u8, Array>::new(array_ptr as _);
|
||||
let result = match wasm_ptr.get_utf8_string(ctx.memory(0), array_size as _) {
|
||||
Some(arg_value) => cmd_lib::run_fun!("{} {}", host_cmd, arg_value).unwrap(),
|
||||
None => return vec![],
|
||||
// TODO: prevent command injection
|
||||
Some(arg_value) => match cmd_lib::run_fun!("{} {}", host_cmd, arg_value) {
|
||||
Ok(result) => result,
|
||||
Err(e) => {
|
||||
log::error!("error occurred while calling `{} {}`: {:?} ", host_cmd, arg_value, e);
|
||||
String::new()
|
||||
},
|
||||
}
|
||||
None => {
|
||||
log::error!("error getting utf8 string from {} offset of {} bytes", array_ptr, array_size);
|
||||
String::new()
|
||||
}
|
||||
};
|
||||
|
||||
unsafe {
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "fcli"
|
||||
description = "Fluence FCE command line tool"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
authors = ["Fluence Labs"]
|
||||
repository = "https://github.com/fluencelabs/fce/tools/cli"
|
||||
license = "Apache-2.0"
|
||||
@ -12,7 +12,7 @@ name = "fce"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
fce-wit-generator = { path = "../../crates/wit-generator", version = "0.1.2"}
|
||||
fce-wit-generator = { path = "../../crates/wit-generator", version = "0.1.3"}
|
||||
fce-wit-parser = { path = "../../crates/wit-parser", version = "0.1.3" }
|
||||
|
||||
anyhow = "1.0.31"
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "frepl"
|
||||
description = "Fluence FCE REPL intended for testing purposes"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
authors = ["Fluence Labs"]
|
||||
repository = "https://github.com/fluencelabs/fce/tools/repl"
|
||||
license = "Apache-2.0"
|
||||
@ -12,7 +12,7 @@ name = "fce-repl"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
fluence-app-service = { path = "../../fluence-app-service", version = "0.1.1", features = ["raw-module-api"] }
|
||||
fluence-app-service = { path = "../../fluence-app-service", version = "0.1.2", features = ["raw-module-api"] }
|
||||
|
||||
anyhow = "1.0.31"
|
||||
clap = "2.33.1"
|
||||
|
Loading…
Reference in New Issue
Block a user