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 files
|
||||||
*.repl_history
|
*.repl_history
|
||||||
|
|
||||||
# Temporary file of ipfs node example
|
|
||||||
/examples/ipfs_node/wasm/artifacts/ipfs_rpc_file
|
|
||||||
|
|
||||||
# Allowed Wasm files for examples
|
# Allowed Wasm files for examples
|
||||||
!/examples/greeting/artifacts/*.wasm
|
!/examples/greeting/artifacts/*.wasm
|
||||||
!/examples/ipfs_node/artifacts/wasm_modules/*.wasm
|
!/examples/ipfs_node/artifacts/*.wasm
|
||||||
!/examples/records/artifacts/wasm_modules/*.wasm
|
!/examples/records/artifacts/*.wasm
|
||||||
|
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -598,7 +598,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fce-wit-generator"
|
name = "fce-wit-generator"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fce-wit-parser",
|
"fce-wit-parser",
|
||||||
"fluence-sdk-wit 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"fluence-sdk-wit 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -630,7 +630,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fcli"
|
name = "fcli"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
@ -652,7 +652,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fluence-app-service"
|
name = "fluence-app-service"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fluence-faas",
|
"fluence-faas",
|
||||||
"log",
|
"log",
|
||||||
@ -663,7 +663,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fluence-faas"
|
name = "fluence-faas"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cmd_lib",
|
"cmd_lib",
|
||||||
"fce",
|
"fce",
|
||||||
@ -768,7 +768,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "frepl"
|
name = "frepl"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "fce-wit-generator"
|
name = "fce-wit-generator"
|
||||||
description = "Fluence FCE interface type helper crate"
|
description = "Fluence FCE interface type helper crate"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
authors = ["Fluence Labs"]
|
authors = ["Fluence Labs"]
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
@ -195,7 +195,7 @@ impl ForeignModInstructionGenerator for ParsedType {
|
|||||||
ParsedType::ByteVector => vec![
|
ParsedType::ByteVector => vec![
|
||||||
Instruction::ArgumentGet { index },
|
Instruction::ArgumentGet { index },
|
||||||
Instruction::ArgumentGet { index: index + 1 },
|
Instruction::ArgumentGet { index: index + 1 },
|
||||||
Instruction::StringLiftMemory,
|
Instruction::ByteArrayLiftMemory,
|
||||||
],
|
],
|
||||||
ParsedType::Record(record_name) => {
|
ParsedType::Record(record_name) => {
|
||||||
let type_index = wit_resolver.get_record_type_id(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]]
|
[[module]]
|
||||||
name = "effector"
|
name = "effector"
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "fluence-app-service"
|
name = "fluence-app-service"
|
||||||
description = "Fluence Application Service"
|
description = "Fluence Application Service"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
authors = ["Fluence Labs"]
|
authors = ["Fluence Labs"]
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
fluence-faas = { path = "../fluence-faas", version = "0.1.1" }
|
fluence-faas = { path = "../fluence-faas", version = "0.1.2" }
|
||||||
|
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
serde_json = "1.0.53"
|
serde_json = "1.0.53"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "fluence-faas"
|
name = "fluence-faas"
|
||||||
description = "Fluence FaaS"
|
description = "Fluence FaaS"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
authors = ["Fluence Labs"]
|
authors = ["Fluence Labs"]
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
@ -49,6 +49,7 @@ fn write_to_mem(context: &mut Ctx, address: usize, value: &[u8]) {
|
|||||||
.for_each(|(cell, byte)| cell.set(*byte));
|
.for_each(|(cell, byte)| cell.set(*byte));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
pub(super) fn create_host_import_func<S>(host_cmd: S) -> DynamicFunc<'static>
|
pub(super) fn create_host_import_func<S>(host_cmd: S) -> DynamicFunc<'static>
|
||||||
where
|
where
|
||||||
S: Into<String>,
|
S: Into<String>,
|
||||||
@ -56,10 +57,8 @@ where
|
|||||||
use wasmer_core::Func;
|
use wasmer_core::Func;
|
||||||
|
|
||||||
let allocate_func: Box<RefCell<Option<Func<'static, i32, i32>>>> = Box::new(RefCell::new(None));
|
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, ()>>>> =
|
let set_result_ptr_func: Box<RefCell<Option<Func<'static, i32, ()>>>> = Box::new(RefCell::new(None));
|
||||||
Box::new(RefCell::new(None));
|
let set_result_size_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();
|
let host_cmd = host_cmd.into();
|
||||||
|
|
||||||
@ -73,8 +72,18 @@ where
|
|||||||
|
|
||||||
let wasm_ptr = WasmPtr::<u8, Array>::new(array_ptr as _);
|
let wasm_ptr = WasmPtr::<u8, Array>::new(array_ptr as _);
|
||||||
let result = match wasm_ptr.get_utf8_string(ctx.memory(0), array_size 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(),
|
// TODO: prevent command injection
|
||||||
None => return vec![],
|
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 {
|
unsafe {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "fcli"
|
name = "fcli"
|
||||||
description = "Fluence FCE command line tool"
|
description = "Fluence FCE command line tool"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
authors = ["Fluence Labs"]
|
authors = ["Fluence Labs"]
|
||||||
repository = "https://github.com/fluencelabs/fce/tools/cli"
|
repository = "https://github.com/fluencelabs/fce/tools/cli"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
@ -12,7 +12,7 @@ name = "fce"
|
|||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[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" }
|
fce-wit-parser = { path = "../../crates/wit-parser", version = "0.1.3" }
|
||||||
|
|
||||||
anyhow = "1.0.31"
|
anyhow = "1.0.31"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "frepl"
|
name = "frepl"
|
||||||
description = "Fluence FCE REPL intended for testing purposes"
|
description = "Fluence FCE REPL intended for testing purposes"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
authors = ["Fluence Labs"]
|
authors = ["Fluence Labs"]
|
||||||
repository = "https://github.com/fluencelabs/fce/tools/repl"
|
repository = "https://github.com/fluencelabs/fce/tools/repl"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
@ -12,7 +12,7 @@ name = "fce-repl"
|
|||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[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"
|
anyhow = "1.0.31"
|
||||||
clap = "2.33.1"
|
clap = "2.33.1"
|
||||||
|
Loading…
Reference in New Issue
Block a user