From 33d9320d47373bdc79a4503be5d73cbdbf95fccc Mon Sep 17 00:00:00 2001 From: vms Date: Sat, 18 Jul 2020 18:05:07 +0300 Subject: [PATCH] add ability to use IT in host imports --- .../foreign_mod_instructions.rs | 7 ++++++ .../artifacts/wasm_modules/ipfs_node.wasm | Bin 177184 -> 177308 bytes examples/ipfs_node/wasm/ipfs_node/src/main.rs | 23 ++++-------------- fluence-faas/src/misc/imports.rs | 2 +- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/crates/wit-generator/src/instructions_generator/foreign_mod_instructions.rs b/crates/wit-generator/src/instructions_generator/foreign_mod_instructions.rs index c532c3a3..010f5aee 100644 --- a/crates/wit-generator/src/instructions_generator/foreign_mod_instructions.rs +++ b/crates/wit-generator/src/instructions_generator/foreign_mod_instructions.rs @@ -26,8 +26,15 @@ use fluence_sdk_wit::ParsedType; use wasmer_wit::interpreter::Instruction; use crate::instructions_generator::utils::wtype_to_itype; +const HOST_NAMESPACE_NAME: &str = "host"; + impl WITGenerator for AstExternModItem { fn generate_wit<'a>(&'a self, interfaces: &mut Interfaces<'a>) { + // host imports should be left as is + if self.namespace == HOST_NAMESPACE_NAME { + return; + } + for import in &self.imports { generate_wit_for_import(import, &self.namespace, interfaces); } diff --git a/examples/ipfs_node/wasm/artifacts/wasm_modules/ipfs_node.wasm b/examples/ipfs_node/wasm/artifacts/wasm_modules/ipfs_node.wasm index 5866c1814b35176d35e360dbd53e644e9e8b905a..8821a79b2f182703c00a0153aa119458db1a0010 100644 GIT binary patch delta 12227 zcma)C30zgh{y)Dt_ritCazPXk&~p(LMQ}q-VqIRF9n^tD&qdjeDr=7Q?`MYSlWjA}y z@;=+c-lwhFFl#T`tQA^g{B;`2*`V|CMY)pRrqf!5HHK=mZ>?=;k>=--NY&a>zO zwz%fN0YM(|I61|~#~`KVg7&N}3v_>HdrZ(Z-RotBG3Nae6}eva4kb)&vS$cdgM1D5i)zbuNSxE*ufId059|nPu*OXGRQ>ORtN43>GjV~U=?-1>t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^-e zo$B(LS12fK2&PmF1>zHp&k%Fr6`JnUPPS64wAKe>@%Yrhndl3GPMT?dkST}lZ)a2V z6Iy|~l3ynl(ew&HL6|Gq9~4K8>L;ghCMxElk*r zcEf?E3M9w)q2qFBjp+X7KmnUIZRnKISraEu7@n2$=;%CZmNnq+j>E_xQSozH&a;-eaYoC)>Ym_oow>@^kjj2d>T&uiWj7@hw+S3p2kMV zTc`*ByfusA!#c3$xDh|!fxUtvKc*ua6ttaOKx)P49sJpjY&PxWA?fUO`D<)CpN>si z(y?h5Kby`v%imCMKB*h4%g-jU2;RRFi^j{s)K09Eya(4UoDt1;cVZ3bTYjn&n@4;3 z)XwYyTvvB?W*r0flOIZ*obgk?0+oK@7a}w$%jF} zha)jl(3Qo|_k2-T_6DwCf84<``15yQ!4b;h=i9SpJT#E`^Bs4vc6j&2^e{TghkDrE zsDf8{*dRK_Lv%>tN4kS&6awEO9Tfh=VRv0o-TtDpj=1===?3TopU{otXM7qGY2-v7 z=7W2&Crn3g)-#tc_=sKS39H!)oO@a4?h?Uu@u5K97nA)^8pH`_Y(jn{6N?pJL@s|6 r?l-`|+Eu*%8aApCH01BbR~E|G$vIP|1jrK~$#Xkof4=~iJMjMiIkH0{ diff --git a/examples/ipfs_node/wasm/ipfs_node/src/main.rs b/examples/ipfs_node/wasm/ipfs_node/src/main.rs index b4bc71bc..ad0c1a60 100644 --- a/examples/ipfs_node/wasm/ipfs_node/src/main.rs +++ b/examples/ipfs_node/wasm/ipfs_node/src/main.rs @@ -39,7 +39,7 @@ pub fn put(file_path: String) -> String { let timeout = std::env::var(TIMEOUT_ENV_NAME).unwrap_or_else(|_| "1s".to_string()); let cmd = format!("add --timeout {} -Q {}", timeout, file_path); - call_ipfs(cmd) + ipfs(cmd) } /// Get file by provided hash from IPFS, saves it to a temporary file and returns a path to it. @@ -55,7 +55,7 @@ pub fn get(hash: String) -> String { timeout, result_file_path, hash ); - call_ipfs(cmd); + ipfs(cmd); RESULT_FILE_PATH.to_string() } @@ -71,22 +71,9 @@ pub fn get_address() -> String { } } -fn call_ipfs(cmd: String) -> String { - unsafe { - // TODO: better error handling - match ipfs(cmd.as_ptr() as _, cmd.len() as _) { - 0 => String::from_raw_parts( - fluence::internal::get_result_ptr() as _, - fluence::internal::get_result_size(), - fluence::internal::get_result_size(), - ), - _ => "host ipfs call failed".to_string(), - } - } -} - +#[fce] #[link(wasm_import_module = "host")] extern "C" { - /// Put a file to ipfs, returns ipfs hash of the file. - fn ipfs(ptr: i32, size: i32) -> i32; + /// Execute provided cmd as a parameters of ipfs cli, return result. + pub fn ipfs(cmd: String) -> String; } diff --git a/fluence-faas/src/misc/imports.rs b/fluence-faas/src/misc/imports.rs index 2e0c94bd..c5813cca 100644 --- a/fluence-faas/src/misc/imports.rs +++ b/fluence-faas/src/misc/imports.rs @@ -93,7 +93,7 @@ where }; DynamicFunc::new( - std::sync::Arc::new(FuncSig::new(vec![Type::I32, Type::I32], vec![Type::I32])), + std::sync::Arc::new(FuncSig::new(vec![Type::I32, Type::I32], vec![])), func, ) }