mirror of
https://github.com/fluencelabs/marine.git
synced 2025-06-23 03:31:37 +00:00
rename IPFSNode to FluenceFaaS; dir rearranges
This commit is contained in:
31
Cargo.lock
generated
31
Cargo.lock
generated
@ -370,7 +370,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fce"
|
name = "fce"
|
||||||
version = "0.2.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fce_wit_interfaces",
|
"fce_wit_interfaces",
|
||||||
"multimap",
|
"multimap",
|
||||||
@ -391,6 +391,21 @@ dependencies = [
|
|||||||
"wasmer-interface-types",
|
"wasmer-interface-types",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fluence-faas"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"cmd_lib",
|
||||||
|
"fce",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
|
"serde_json",
|
||||||
|
"toml",
|
||||||
|
"wasmer-runtime",
|
||||||
|
"wasmer-runtime-core",
|
||||||
|
"wasmer-wasi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gcc"
|
name = "gcc"
|
||||||
version = "0.3.55"
|
version = "0.3.55"
|
||||||
@ -517,18 +532,10 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ipfs_node_service"
|
name = "ipfs_node"
|
||||||
version = "0.2.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cmd_lib",
|
"fluence-faas",
|
||||||
"fce",
|
|
||||||
"serde",
|
|
||||||
"serde_derive",
|
|
||||||
"serde_json",
|
|
||||||
"toml",
|
|
||||||
"wasmer-runtime",
|
|
||||||
"wasmer-runtime-core",
|
|
||||||
"wasmer-wasi",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2,11 +2,12 @@
|
|||||||
members = [
|
members = [
|
||||||
"crates/fce_wit_interfaces",
|
"crates/fce_wit_interfaces",
|
||||||
"crates/wit_parser",
|
"crates/wit_parser",
|
||||||
|
"engine",
|
||||||
"examples/ipfs_node",
|
"examples/ipfs_node",
|
||||||
"examples/ipfs_node/wasm/ipfs_node",
|
"examples/ipfs_node/wasm/ipfs_node",
|
||||||
"examples/ipfs_node/wasm/ipfs_rpc",
|
"examples/ipfs_node/wasm/ipfs_rpc",
|
||||||
"examples/simple_greeting",
|
"examples/simple_greeting",
|
||||||
"fce",
|
"fluence-faas",
|
||||||
"tools/wit_embedder",
|
"tools/wit_embedder",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "fce"
|
name = "fce"
|
||||||
version = "0.2.0"
|
version = "0.1.0"
|
||||||
authors = ["Fluence Labs"]
|
authors = ["Fluence Labs"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
3
engine/README.md
Normal file
3
engine/README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Fluence Compute Engine
|
||||||
|
|
||||||
|
FCE is intended to run various Wasm binaries. At now, it is in the heavily developing phase.
|
@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
use super::module::FCEModule;
|
use super::module::FCEModule;
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::WasmProcess;
|
|
||||||
use crate::NodeFunction;
|
|
||||||
|
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
@ -28,22 +26,23 @@ pub struct FCE {
|
|||||||
modules: HashMap<String, FCEModule>,
|
modules: HashMap<String, FCEModule>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Represent a function type inside FCE.
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct FCEFunction<'a> {
|
||||||
|
pub name: &'a str,
|
||||||
|
pub inputs: &'a Vec<IType>,
|
||||||
|
pub outputs: &'a Vec<IType>,
|
||||||
|
}
|
||||||
|
|
||||||
impl FCE {
|
impl FCE {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
modules: HashMap::new(),
|
modules: HashMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for FCE {
|
/// Invoke a function of a module inside FCE by given function name with given arguments.
|
||||||
fn default() -> Self {
|
pub fn call(
|
||||||
Self::new()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WasmProcess for FCE {
|
|
||||||
fn call(
|
|
||||||
&mut self,
|
&mut self,
|
||||||
module_name: &str,
|
module_name: &str,
|
||||||
func_name: &str,
|
func_name: &str,
|
||||||
@ -56,7 +55,8 @@ impl WasmProcess for FCE {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_module<S>(
|
/// Load a new module inside FCE.
|
||||||
|
pub fn load_module<S>(
|
||||||
&mut self,
|
&mut self,
|
||||||
module_name: S,
|
module_name: S,
|
||||||
wasm_bytes: &[u8],
|
wasm_bytes: &[u8],
|
||||||
@ -65,8 +65,7 @@ impl WasmProcess for FCE {
|
|||||||
where
|
where
|
||||||
S: Into<String>,
|
S: Into<String>,
|
||||||
{
|
{
|
||||||
let _prepared_wasm_bytes =
|
let _prepared_wasm_bytes = crate::misc::prepare_module(wasm_bytes, config.mem_pages_count)?;
|
||||||
super::prepare::prepare_module(wasm_bytes, config.mem_pages_count)?;
|
|
||||||
|
|
||||||
let module = FCEModule::new(&wasm_bytes, config, &self.modules)?;
|
let module = FCEModule::new(&wasm_bytes, config, &self.modules)?;
|
||||||
|
|
||||||
@ -79,7 +78,8 @@ impl WasmProcess for FCE {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unload_module(&mut self, module_name: &str) -> Result<(), FCEError> {
|
/// Unload previously loaded module.
|
||||||
|
pub fn unload_module(&mut self, module_name: &str) -> Result<(), FCEError> {
|
||||||
match self.modules.entry(module_name.to_string()) {
|
match self.modules.entry(module_name.to_string()) {
|
||||||
Entry::Vacant(_) => Err(FCEError::NoSuchModule),
|
Entry::Vacant(_) => Err(FCEError::NoSuchModule),
|
||||||
|
|
||||||
@ -90,12 +90,13 @@ impl WasmProcess for FCE {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_interface(&self, module_name: &str) -> Result<Vec<NodeFunction<'_>>, FCEError> {
|
/// Return signatures of all exported by this module functions.
|
||||||
|
pub fn get_interface(&self, module_name: &str) -> Result<Vec<FCEFunction<'_>>, FCEError> {
|
||||||
match self.modules.get(module_name) {
|
match self.modules.get(module_name) {
|
||||||
Some(module) => {
|
Some(module) => {
|
||||||
let signatures = module
|
let signatures = module
|
||||||
.get_exports_signatures()
|
.get_exports_signatures()
|
||||||
.map(|(name, inputs, outputs)| NodeFunction {
|
.map(|(name, inputs, outputs)| FCEFunction {
|
||||||
name,
|
name,
|
||||||
inputs,
|
inputs,
|
||||||
outputs,
|
outputs,
|
||||||
@ -107,3 +108,9 @@ impl WasmProcess for FCE {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for FCE {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
@ -27,14 +27,15 @@
|
|||||||
unreachable_patterns
|
unreachable_patterns
|
||||||
)]
|
)]
|
||||||
|
|
||||||
mod vm;
|
mod config;
|
||||||
|
mod engine;
|
||||||
|
mod errors;
|
||||||
|
mod module;
|
||||||
mod misc;
|
mod misc;
|
||||||
mod wasm_process;
|
|
||||||
|
|
||||||
pub use vm::FCE;
|
pub use config::FCEModuleConfig;
|
||||||
pub use vm::FCEError;
|
pub use engine::FCE;
|
||||||
pub use vm::FCEModuleConfig;
|
pub use engine::FCEFunction;
|
||||||
pub use vm::IValue;
|
pub use errors::FCEError;
|
||||||
pub use vm::IType;
|
pub use module::IValue;
|
||||||
pub use wasm_process::WasmProcess;
|
pub use module::IType;
|
||||||
pub use wasm_process::NodeFunction;
|
|
@ -14,6 +14,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mod slice_pretty_printer;
|
mod prepare;
|
||||||
|
|
||||||
pub use slice_pretty_printer::SlicePrettyPrinter;
|
pub(crate) use prepare::prepare_module;
|
@ -18,7 +18,7 @@
|
|||||||
// https://github.com/paritytech/substrate/blob/master/srml/contracts/src/wasm/prepare.rs
|
// https://github.com/paritytech/substrate/blob/master/srml/contracts/src/wasm/prepare.rs
|
||||||
// https://github.com/nearprotocol/nearcore/blob/master/runtime/near-vm-runner/src/prepare.rs
|
// https://github.com/nearprotocol/nearcore/blob/master/runtime/near-vm-runner/src/prepare.rs
|
||||||
|
|
||||||
use super::errors::FCEError;
|
use crate::FCEError;
|
||||||
|
|
||||||
use parity_wasm::{
|
use parity_wasm::{
|
||||||
builder, elements,
|
builder, elements,
|
||||||
@ -73,7 +73,7 @@ impl<'a> ModuleBootstrapper {
|
|||||||
|
|
||||||
/// Prepares a Wasm module:
|
/// Prepares a Wasm module:
|
||||||
/// - set memory page count
|
/// - set memory page count
|
||||||
pub fn prepare_module(module: &[u8], mem_pages_count: u32) -> Result<Vec<u8>, FCEError> {
|
pub(crate) fn prepare_module(module: &[u8], mem_pages_count: u32) -> Result<Vec<u8>, FCEError> {
|
||||||
ModuleBootstrapper::init(module)?
|
ModuleBootstrapper::init(module)?
|
||||||
.set_mem_pages_count(mem_pages_count)
|
.set_mem_pages_count(mem_pages_count)
|
||||||
.into_wasm()
|
.into_wasm()
|
@ -61,7 +61,7 @@ impl Callable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct FCEModule {
|
pub(crate) struct FCEModule {
|
||||||
// wasmer_instance is needed because WITInstance contains dynamic functions
|
// wasmer_instance is needed because WITInstance contains dynamic functions
|
||||||
// that internally keep pointer to Wasmer instance.
|
// that internally keep pointer to Wasmer instance.
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
@ -82,7 +82,7 @@ pub struct FCEModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FCEModule {
|
impl FCEModule {
|
||||||
pub fn new(
|
pub(crate) fn new(
|
||||||
wasm_bytes: &[u8],
|
wasm_bytes: &[u8],
|
||||||
fce_module_config: FCEModuleConfig,
|
fce_module_config: FCEModuleConfig,
|
||||||
modules: &HashMap<String, FCEModule>,
|
modules: &HashMap<String, FCEModule>,
|
||||||
@ -130,7 +130,11 @@ impl FCEModule {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn call(&mut self, function_name: &str, args: &[IValue]) -> Result<Vec<IValue>, FCEError> {
|
pub(crate) fn call(
|
||||||
|
&mut self,
|
||||||
|
function_name: &str,
|
||||||
|
args: &[IValue],
|
||||||
|
) -> Result<Vec<IValue>, FCEError> {
|
||||||
match self.exports_funcs.get_mut(function_name) {
|
match self.exports_funcs.get_mut(function_name) {
|
||||||
Some(func) => Arc::make_mut(func).call(args),
|
Some(func) => Arc::make_mut(func).call(args),
|
||||||
None => Err(FCEError::NoSuchFunction(format!(
|
None => Err(FCEError::NoSuchFunction(format!(
|
||||||
@ -140,7 +144,7 @@ impl FCEModule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_exports_signatures(
|
pub(crate) fn get_exports_signatures(
|
||||||
&self,
|
&self,
|
||||||
) -> impl Iterator<Item = (&String, &Vec<IType>, &Vec<IType>)> {
|
) -> impl Iterator<Item = (&String, &Vec<IType>, &Vec<IType>)> {
|
||||||
self.exports_funcs.iter().map(|(func_name, func)| {
|
self.exports_funcs.iter().map(|(func_name, func)| {
|
@ -32,7 +32,7 @@ pub(self) use wasmer_core::types::Value as WValue;
|
|||||||
pub(self) mod wit_prelude {
|
pub(self) mod wit_prelude {
|
||||||
pub(super) use super::wit_instance::WITInstance;
|
pub(super) use super::wit_instance::WITInstance;
|
||||||
pub(super) use super::exports::WITExport;
|
pub(super) use super::exports::WITExport;
|
||||||
pub(super) use crate::vm::FCEError;
|
pub(super) use crate::FCEError;
|
||||||
pub(super) use super::wit_function::WITFunction;
|
pub(super) use super::wit_function::WITFunction;
|
||||||
pub(super) use super::memory::WITMemoryView;
|
pub(super) use super::memory::WITMemoryView;
|
||||||
pub(super) use super::memory::WITMemory;
|
pub(super) use super::memory::WITMemory;
|
@ -17,7 +17,7 @@
|
|||||||
use super::wit_prelude::FCEError;
|
use super::wit_prelude::FCEError;
|
||||||
use super::fce_module::FCEModule;
|
use super::fce_module::FCEModule;
|
||||||
use super::{IType, IValue, WValue};
|
use super::{IType, IValue, WValue};
|
||||||
use crate::vm::module::fce_module::Callable;
|
use super::fce_module::Callable;
|
||||||
|
|
||||||
use wasmer_wit::interpreter::wasm;
|
use wasmer_wit::interpreter::wasm;
|
||||||
use wasmer_core::instance::DynFunc;
|
use wasmer_core::instance::DynFunc;
|
@ -1,18 +1,8 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ipfs_node_service"
|
name = "ipfs_node"
|
||||||
version = "0.2.0"
|
version = "0.1.0"
|
||||||
authors = ["Fluence Labs"]
|
authors = ["Fluence Labs"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
fce = { path = "../../fce" }
|
fluence-faas = { path = "../../fluence-faas" }
|
||||||
|
|
||||||
wasmer-core = { package = "wasmer-runtime-core", version = "0.17.0", features = ["dynamicfunc-fat-closures"] }
|
|
||||||
wasmer-runtime = "0.17.0"
|
|
||||||
wasmer-wasi = "0.17.0"
|
|
||||||
|
|
||||||
toml = "0.5.6"
|
|
||||||
serde = { version = "1.0.111", features = ["derive"] }
|
|
||||||
serde_json = "1.0.53"
|
|
||||||
serde_derive = "1.0.111"
|
|
||||||
cmd_lib = "0.7.8"
|
|
||||||
|
@ -14,16 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mod node;
|
use fluence_faas::FluenceFaaS;
|
||||||
mod node_wasm_service;
|
use fluence_faas::IValue;
|
||||||
|
|
||||||
pub use node::IpfsNode;
|
|
||||||
pub use node::NodeError;
|
|
||||||
pub use node::NodePublicInterface;
|
|
||||||
pub use node::NodeModulePublicInterface;
|
|
||||||
pub use node_wasm_service::NodeWasmService;
|
|
||||||
|
|
||||||
use fce::IValue;
|
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
@ -37,7 +29,7 @@ const IPFS_RPC: &str = "/Users/mike/dev/work/fluence/wasm/fce/bin/wasm_ipfs_rpc_
|
|||||||
fn main() {
|
fn main() {
|
||||||
let ipfs_rpc = std::fs::read(IPFS_RPC).unwrap();
|
let ipfs_rpc = std::fs::read(IPFS_RPC).unwrap();
|
||||||
|
|
||||||
let mut ipfs_node = IpfsNode::new(
|
let mut ipfs_node = FluenceFaaS::new(
|
||||||
PathBuf::from(IPFS_MODULES_DIR),
|
PathBuf::from(IPFS_MODULES_DIR),
|
||||||
PathBuf::from(IPFS_MODULES_CONFIG_PATH),
|
PathBuf::from(IPFS_MODULES_CONFIG_PATH),
|
||||||
)
|
)
|
||||||
@ -46,13 +38,13 @@ fn main() {
|
|||||||
println!("ipfs node interface is\n{}", ipfs_node.get_interface());
|
println!("ipfs node interface is\n{}", ipfs_node.get_interface());
|
||||||
|
|
||||||
let node_addresses = ipfs_node
|
let node_addresses = ipfs_node
|
||||||
.core_call("ipfs_node.wasm", "get_addresses", &[])
|
.call_module("ipfs_node.wasm", "get_addresses", &[])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
println!("ipfs node addresses are:\n{:?}", node_addresses);
|
println!("ipfs node addresses are:\n{:?}", node_addresses);
|
||||||
|
|
||||||
let result = ipfs_node
|
let result = ipfs_node
|
||||||
.rpc_call(&ipfs_rpc, "put", &[IValue::String("asdasdasd".to_string())])
|
.call_code(&ipfs_rpc, "put", &[IValue::String("asdasdasd".to_string())])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
println!("execution result {:?}", result);
|
println!("execution result {:?}", result);
|
||||||
|
@ -1,27 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
mod config;
|
|
||||||
mod errors;
|
|
||||||
mod imports;
|
|
||||||
mod ipfs_node;
|
|
||||||
mod node_public_interface;
|
|
||||||
mod utils;
|
|
||||||
|
|
||||||
pub use ipfs_node::IpfsNode;
|
|
||||||
pub use errors::NodeError;
|
|
||||||
pub use node_public_interface::NodePublicInterface;
|
|
||||||
pub use node_public_interface::NodeModulePublicInterface;
|
|
@ -1,38 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use crate::NodeError;
|
|
||||||
use crate::NodePublicInterface;
|
|
||||||
|
|
||||||
use fce::IValue;
|
|
||||||
|
|
||||||
pub trait NodeWasmService {
|
|
||||||
fn rpc_call(
|
|
||||||
&mut self,
|
|
||||||
wasm_rpc: &[u8],
|
|
||||||
func_name: &str,
|
|
||||||
args: &[IValue],
|
|
||||||
) -> Result<Vec<IValue>, NodeError>;
|
|
||||||
|
|
||||||
fn core_call(
|
|
||||||
&mut self,
|
|
||||||
module_name: &str,
|
|
||||||
func_name: &str,
|
|
||||||
args: &[IValue],
|
|
||||||
) -> Result<Vec<IValue>, NodeError>;
|
|
||||||
|
|
||||||
fn get_interface(&self) -> NodePublicInterface;
|
|
||||||
}
|
|
@ -1,37 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
pub struct SlicePrettyPrinter<'a>(pub &'a [u8]);
|
|
||||||
|
|
||||||
impl<'a> std::fmt::LowerHex for SlicePrettyPrinter<'a> {
|
|
||||||
fn fmt(&self, fmtr: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
|
||||||
fmtr.write_fmt(format_args!("0x"))?;
|
|
||||||
for byte in self.0 {
|
|
||||||
fmtr.write_fmt(format_args!("{:02x}", byte))?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> std::fmt::UpperHex for SlicePrettyPrinter<'a> {
|
|
||||||
fn fmt(&self, fmtr: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
|
||||||
fmtr.write_fmt(format_args!("0x"))?;
|
|
||||||
for byte in self.0 {
|
|
||||||
fmtr.write_fmt(format_args!("{:02X}", byte))?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
mod fce;
|
|
||||||
mod module;
|
|
||||||
mod config;
|
|
||||||
mod prepare;
|
|
||||||
mod errors;
|
|
||||||
|
|
||||||
pub use fce::FCE;
|
|
||||||
pub use config::FCEModuleConfig;
|
|
||||||
pub use errors::FCEError;
|
|
||||||
pub use module::{IType, IValue};
|
|
@ -1,55 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use super::FCEModuleConfig;
|
|
||||||
use super::FCEError;
|
|
||||||
use super::IValue;
|
|
||||||
use super::IType;
|
|
||||||
|
|
||||||
/// Represent a function type inside wasm process.
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct NodeFunction<'a> {
|
|
||||||
pub name: &'a str,
|
|
||||||
pub inputs: &'a Vec<IType>,
|
|
||||||
pub outputs: &'a Vec<IType>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Describe a computation node behaviour in the Fluence network.
|
|
||||||
pub trait WasmProcess {
|
|
||||||
/// Invoke a function by given function name with given arguments of a module inside wasm process.
|
|
||||||
fn call(
|
|
||||||
&mut self,
|
|
||||||
module_name: &str,
|
|
||||||
function_name: &str,
|
|
||||||
arguments: &[IValue],
|
|
||||||
) -> Result<Vec<IValue>, FCEError>;
|
|
||||||
|
|
||||||
/// Load a new module inside wasm process.
|
|
||||||
fn load_module<S>(
|
|
||||||
&mut self,
|
|
||||||
module_name: S,
|
|
||||||
wasm_bytes: &[u8],
|
|
||||||
config: FCEModuleConfig,
|
|
||||||
) -> Result<(), FCEError>
|
|
||||||
where
|
|
||||||
S: Into<String>;
|
|
||||||
|
|
||||||
/// Unload previously loaded module.
|
|
||||||
fn unload_module(&mut self, module_name: &str) -> Result<(), FCEError>;
|
|
||||||
|
|
||||||
/// Return signatures of all exported by this module functions.
|
|
||||||
fn get_interface(&self, module_name: &str) -> Result<Vec<NodeFunction<'_>>, FCEError>;
|
|
||||||
}
|
|
18
fluence-faas/Cargo.toml
Normal file
18
fluence-faas/Cargo.toml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
[package]
|
||||||
|
name = "fluence-faas"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Fluence Labs"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
fce = { path = "../engine" }
|
||||||
|
|
||||||
|
wasmer-core = { package = "wasmer-runtime-core", version = "0.17.0", features = ["dynamicfunc-fat-closures"] }
|
||||||
|
wasmer-runtime = "0.17.0"
|
||||||
|
wasmer-wasi = "0.17.0"
|
||||||
|
|
||||||
|
toml = "0.5.6"
|
||||||
|
serde = { version = "1.0.111", features = ["derive"] }
|
||||||
|
serde_json = "1.0.53"
|
||||||
|
serde_derive = "1.0.111"
|
||||||
|
cmd_lib = "0.7.8"
|
3
fluence-faas/README.md
Normal file
3
fluence-faas/README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Fluence FaaS
|
||||||
|
|
||||||
|
Fluence FaaS is intended to run various Wasm binaries. At now, it is in the heavily developing phase.
|
@ -20,7 +20,7 @@ use std::io::Error as IOError;
|
|||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum NodeError {
|
pub enum FaaSError {
|
||||||
/// An error related to config parsing.
|
/// An error related to config parsing.
|
||||||
ConfigParseError(String),
|
ConfigParseError(String),
|
||||||
|
|
||||||
@ -28,29 +28,29 @@ pub enum NodeError {
|
|||||||
IOError(String),
|
IOError(String),
|
||||||
|
|
||||||
/// WIT doesn't contain such type.
|
/// WIT doesn't contain such type.
|
||||||
WasmProcessError(FCEError),
|
EngineError(FCEError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error for NodeError {}
|
impl Error for FaaSError {}
|
||||||
|
|
||||||
impl std::fmt::Display for NodeError {
|
impl std::fmt::Display for FaaSError {
|
||||||
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 {
|
||||||
NodeError::ConfigParseError(err_msg) => write!(f, "{}", err_msg),
|
FaaSError::ConfigParseError(err_msg) => write!(f, "{}", err_msg),
|
||||||
NodeError::IOError(err_msg) => write!(f, "{}", err_msg),
|
FaaSError::IOError(err_msg) => write!(f, "{}", err_msg),
|
||||||
NodeError::WasmProcessError(err) => write!(f, "{}", err),
|
FaaSError::EngineError(err) => write!(f, "{}", err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<IOError> for NodeError {
|
impl From<IOError> for FaaSError {
|
||||||
fn from(err: IOError) -> Self {
|
fn from(err: IOError) -> Self {
|
||||||
NodeError::IOError(format!("{}", err))
|
FaaSError::IOError(format!("{}", err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<FCEError> for NodeError {
|
impl From<FCEError> for FaaSError {
|
||||||
fn from(err: FCEError) -> Self {
|
fn from(err: FCEError) -> Self {
|
||||||
NodeError::WasmProcessError(err)
|
FaaSError::EngineError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,34 +14,32 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use super::errors::NodeError;
|
use super::FaaSError;
|
||||||
use super::node_public_interface::NodePublicInterface;
|
use super::faas_interface::FaaSInterface;
|
||||||
use super::node_public_interface::NodeModulePublicInterface;
|
use super::faas_interface::FaaSModuleInterface;
|
||||||
|
|
||||||
use fce::FCE;
|
use fce::FCE;
|
||||||
use fce::WasmProcess;
|
use super::IValue;
|
||||||
use fce::IValue;
|
|
||||||
use fce::FCEModuleConfig;
|
use fce::FCEModuleConfig;
|
||||||
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub struct IpfsNode {
|
pub struct FluenceFaaS {
|
||||||
process: FCE,
|
process: FCE,
|
||||||
// names of core modules that is loaded to FCE
|
// names of core modules loaded to FCE
|
||||||
module_names: Vec<String>,
|
module_names: Vec<String>,
|
||||||
rpc_module_config: FCEModuleConfig,
|
faas_code_config: FCEModuleConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IpfsNode {
|
impl FluenceFaaS {
|
||||||
pub fn new<P: Into<PathBuf>>(
|
pub fn new<P: Into<PathBuf>>(
|
||||||
core_modules_dir: P,
|
core_modules_dir: P,
|
||||||
config_file_path: P,
|
config_file_path: P,
|
||||||
) -> Result<Self, NodeError> {
|
) -> Result<Self, FaaSError> {
|
||||||
let mut wasm_process = FCE::new();
|
let mut wasm_process = FCE::new();
|
||||||
let mut module_names = Vec::new();
|
let mut module_names = Vec::new();
|
||||||
let mut core_modules_config =
|
let mut core_modules_config = crate::misc::parse_config_from_file(config_file_path.into())?;
|
||||||
super::config::parse_config_from_file(config_file_path.into())?;
|
|
||||||
|
|
||||||
for entry in fs::read_dir(core_modules_dir.into())? {
|
for entry in fs::read_dir(core_modules_dir.into())? {
|
||||||
let path = entry?.path();
|
let path = entry?.path();
|
||||||
@ -54,11 +52,11 @@ impl IpfsNode {
|
|||||||
let module_name = module_name
|
let module_name = module_name
|
||||||
.to_os_string()
|
.to_os_string()
|
||||||
.into_string()
|
.into_string()
|
||||||
.map_err(|e| NodeError::IOError(format!("failed to read from {:?} file", e)))?;
|
.map_err(|e| FaaSError::IOError(format!("failed to read from {:?} file", e)))?;
|
||||||
|
|
||||||
let module_bytes = fs::read(path.clone())?;
|
let module_bytes = fs::read(path.clone())?;
|
||||||
|
|
||||||
let core_module_config = super::utils::make_wasm_process_config(
|
let core_module_config = crate::misc::make_wasm_process_config(
|
||||||
core_modules_config.modules_config.remove(&module_name),
|
core_modules_config.modules_config.remove(&module_name),
|
||||||
)?;
|
)?;
|
||||||
wasm_process.load_module(module_name.clone(), &module_bytes, core_module_config)?;
|
wasm_process.load_module(module_name.clone(), &module_bytes, core_module_config)?;
|
||||||
@ -66,27 +64,25 @@ impl IpfsNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let rpc_module_config =
|
let rpc_module_config =
|
||||||
super::utils::make_wasm_process_config(core_modules_config.rpc_module_config)?;
|
crate::misc::make_wasm_process_config(core_modules_config.rpc_module_config)?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
process: wasm_process,
|
process: wasm_process,
|
||||||
module_names,
|
module_names,
|
||||||
rpc_module_config,
|
faas_code_config: rpc_module_config,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl crate::node_wasm_service::NodeWasmService for IpfsNode {
|
pub fn call_code(
|
||||||
fn rpc_call(
|
|
||||||
&mut self,
|
&mut self,
|
||||||
wasm_rpc: &[u8],
|
wasm_rpc: &[u8],
|
||||||
func_name: &str,
|
func_name: &str,
|
||||||
args: &[IValue],
|
args: &[IValue],
|
||||||
) -> Result<Vec<IValue>, NodeError> {
|
) -> Result<Vec<IValue>, FaaSError> {
|
||||||
let rpc_module_name = "ipfs_rpc";
|
let rpc_module_name = "ipfs_rpc";
|
||||||
|
|
||||||
self.process
|
self.process
|
||||||
.load_module(rpc_module_name, wasm_rpc, self.rpc_module_config.clone())?;
|
.load_module(rpc_module_name, wasm_rpc, self.faas_code_config.clone())?;
|
||||||
|
|
||||||
let call_result = self.process.call(rpc_module_name, func_name, args)?;
|
let call_result = self.process.call(rpc_module_name, func_name, args)?;
|
||||||
self.process.unload_module(rpc_module_name)?;
|
self.process.unload_module(rpc_module_name)?;
|
||||||
@ -94,28 +90,28 @@ impl crate::node_wasm_service::NodeWasmService for IpfsNode {
|
|||||||
Ok(call_result)
|
Ok(call_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn core_call(
|
pub fn call_module(
|
||||||
&mut self,
|
&mut self,
|
||||||
module_name: &str,
|
module_name: &str,
|
||||||
func_name: &str,
|
func_name: &str,
|
||||||
args: &[IValue],
|
args: &[IValue],
|
||||||
) -> Result<Vec<IValue>, NodeError> {
|
) -> Result<Vec<IValue>, FaaSError> {
|
||||||
self.process
|
self.process
|
||||||
.call(module_name, func_name, args)
|
.call(module_name, func_name, args)
|
||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_interface(&self) -> NodePublicInterface {
|
pub fn get_interface(&self) -> FaaSInterface {
|
||||||
let mut modules = Vec::with_capacity(self.module_names.len());
|
let mut modules = Vec::with_capacity(self.module_names.len());
|
||||||
|
|
||||||
for module_name in self.module_names.iter() {
|
for module_name in self.module_names.iter() {
|
||||||
let functions = self.process.get_interface(module_name).unwrap();
|
let functions = self.process.get_interface(module_name).unwrap();
|
||||||
modules.push(NodeModulePublicInterface {
|
modules.push(FaaSModuleInterface {
|
||||||
name: module_name,
|
name: module_name,
|
||||||
functions,
|
functions,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
NodePublicInterface { modules }
|
FaaSInterface { modules }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,17 +17,17 @@
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct NodePublicInterface<'a> {
|
pub struct FaaSInterface<'a> {
|
||||||
pub modules: Vec<NodeModulePublicInterface<'a>>,
|
pub modules: Vec<FaaSModuleInterface<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct NodeModulePublicInterface<'a> {
|
pub struct FaaSModuleInterface<'a> {
|
||||||
pub name: &'a str,
|
pub name: &'a str,
|
||||||
pub functions: Vec<fce::NodeFunction<'a>>,
|
pub functions: Vec<fce::FCEFunction<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> fmt::Display for NodePublicInterface<'a> {
|
impl<'a> fmt::Display for FaaSInterface<'a> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
for module in self.modules.iter() {
|
for module in self.modules.iter() {
|
||||||
write!(f, "{}", module)?;
|
write!(f, "{}", module)?;
|
||||||
@ -37,7 +37,7 @@ impl<'a> fmt::Display for NodePublicInterface<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> fmt::Display for NodeModulePublicInterface<'a> {
|
impl<'a> fmt::Display for FaaSModuleInterface<'a> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
writeln!(f, "{}", self.name)?;
|
writeln!(f, "{}", self.name)?;
|
||||||
|
|
@ -14,13 +14,15 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mod node;
|
mod errors;
|
||||||
mod node_wasm_service;
|
mod faas;
|
||||||
|
mod faas_interface;
|
||||||
|
mod misc;
|
||||||
|
|
||||||
pub use fce::IValue;
|
pub use fce::IValue;
|
||||||
|
pub use fce::IType;
|
||||||
|
|
||||||
pub use node::IpfsNode;
|
pub use errors::FaaSError;
|
||||||
pub use node::NodeError;
|
pub use faas::FluenceFaaS;
|
||||||
pub use node::NodePublicInterface;
|
pub use faas_interface::FaaSInterface;
|
||||||
pub use node::NodeModulePublicInterface;
|
pub use faas_interface::FaaSModuleInterface;
|
||||||
pub use node_wasm_service::NodeWasmService;
|
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use super::errors::NodeError;
|
use crate::FaaSError;
|
||||||
|
|
||||||
use serde_derive::Deserialize;
|
use serde_derive::Deserialize;
|
||||||
use toml::from_slice;
|
use toml::from_slice;
|
||||||
@ -22,20 +22,30 @@ use toml::from_slice;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
An example of a config:
|
An example of the config:
|
||||||
|
|
||||||
[ipfs_node]
|
[[core_module]]
|
||||||
mem_pages_count_count = 100
|
name = "ipfs_node.wasm"
|
||||||
|
mem_pages_count = 100
|
||||||
logger_enabled = true
|
logger_enabled = true
|
||||||
|
|
||||||
[imports]
|
[core_module.imports]
|
||||||
ipfs = "/usr/bin/ipfs"
|
|
||||||
mysql = "/usr/bin/mysql"
|
mysql = "/usr/bin/mysql"
|
||||||
|
ipfs = "/usr/local/bin/ipfs"
|
||||||
|
|
||||||
[wasi]
|
[core_module.wasi]
|
||||||
preopened_files = ["/tmp/file1"]
|
envs = []
|
||||||
[mapped_dirs]
|
preopened_files = ["/Users/user/tmp/"]
|
||||||
tmp = "/tmp"
|
mapped_dirs = { "tmp" = "/Users/user/tmp" }
|
||||||
|
|
||||||
|
[rpc_module]
|
||||||
|
mem_pages_count = 100
|
||||||
|
logger_enabled = true
|
||||||
|
|
||||||
|
[rpc_module.wasi]
|
||||||
|
envs = []
|
||||||
|
preopened_files = ["/Users/user/tmp"]
|
||||||
|
mapped_dirs = { "tmp" = "/Users/user/tmp" }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
@ -90,10 +100,10 @@ pub(crate) struct WASIConfig {
|
|||||||
|
|
||||||
pub(crate) fn parse_config_from_file(
|
pub(crate) fn parse_config_from_file(
|
||||||
config_file_path: std::path::PathBuf,
|
config_file_path: std::path::PathBuf,
|
||||||
) -> Result<NodeConfig, NodeError> {
|
) -> Result<NodeConfig, FaaSError> {
|
||||||
let file_content = std::fs::read(config_file_path)?;
|
let file_content = std::fs::read(config_file_path)?;
|
||||||
let config: RawCoreModulesConfig =
|
let config: RawCoreModulesConfig =
|
||||||
from_slice(&file_content).map_err(|err| NodeError::ConfigParseError(format!("{}", err)))?;
|
from_slice(&file_content).map_err(|err| FaaSError::ConfigParseError(format!("{}", err)))?;
|
||||||
|
|
||||||
let modules_config = config
|
let modules_config = config
|
||||||
.core_module
|
.core_module
|
@ -67,6 +67,8 @@ where
|
|||||||
let func = move |ctx: &mut Ctx, inputs: &[Value]| -> Vec<Value> {
|
let func = move |ctx: &mut Ctx, inputs: &[Value]| -> Vec<Value> {
|
||||||
use wasmer_core::memory::ptr::{Array, WasmPtr};
|
use wasmer_core::memory::ptr::{Array, WasmPtr};
|
||||||
|
|
||||||
|
// this closure is linked to import function that have (i32, i32) -> i32 type -
|
||||||
|
// it is safe to access input slice without its size checking
|
||||||
let array_ptr = inputs[0].to_u128() as i32;
|
let array_ptr = inputs[0].to_u128() as i32;
|
||||||
let array_size = inputs[1].to_u128() as i32;
|
let array_size = inputs[1].to_u128() as i32;
|
||||||
|
|
||||||
@ -77,9 +79,9 @@ where
|
|||||||
};
|
};
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
init_wasm_func_once!(allocate_func, ctx, i32, i32, ALLOCATE_FUNC_NAME, 4);
|
init_wasm_func_once!(allocate_func, ctx, i32, i32, ALLOCATE_FUNC_NAME, 2);
|
||||||
init_wasm_func_once!(set_result_ptr_func, ctx, i32, (), SET_PTR_FUNC_NAME, 5);
|
init_wasm_func_once!(set_result_ptr_func, ctx, i32, (), SET_PTR_FUNC_NAME, 3);
|
||||||
init_wasm_func_once!(set_result_size_func, ctx, i32, (), SET_SIZE_FUNC_NAME, 6);
|
init_wasm_func_once!(set_result_size_func, ctx, i32, (), SET_SIZE_FUNC_NAME, 4);
|
||||||
|
|
||||||
let mem_address = call_wasm_func!(allocate_func, result.len() as i32);
|
let mem_address = call_wasm_func!(allocate_func, result.len() as i32);
|
||||||
write_to_mem(ctx, mem_address as usize, result.as_bytes());
|
write_to_mem(ctx, mem_address as usize, result.as_bytes());
|
6
fluence-faas/src/misc/mod.rs
Normal file
6
fluence-faas/src/misc/mod.rs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
mod imports;
|
||||||
|
mod utils;
|
||||||
|
mod config;
|
||||||
|
|
||||||
|
pub(crate) use utils::make_wasm_process_config;
|
||||||
|
pub(crate) use config::parse_config_from_file;
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use wasmer_core::vm::Ctx;
|
use wasmer_core::vm::Ctx;
|
||||||
use super::errors::NodeError;
|
use crate::FaaSError;
|
||||||
use super::config::ModuleConfig;
|
use super::config::ModuleConfig;
|
||||||
|
|
||||||
use fce::FCEModuleConfig;
|
use fce::FCEModuleConfig;
|
||||||
@ -33,7 +33,7 @@ use std::path::PathBuf;
|
|||||||
|
|
||||||
// based on Wasmer: https://github.com/wasmerio/wasmer/blob/081f6250e69b98b9f95a8f62ad6d8386534f3279/lib/runtime-core/src/instance.rs#L863
|
// based on Wasmer: https://github.com/wasmerio/wasmer/blob/081f6250e69b98b9f95a8f62ad6d8386534f3279/lib/runtime-core/src/instance.rs#L863
|
||||||
/// Extract export function from Wasmer instance by name.
|
/// Extract export function from Wasmer instance by name.
|
||||||
pub(super) unsafe fn get_export_func_by_name<'a, Args, Rets>(
|
pub(crate) unsafe fn get_export_func_by_name<'a, Args, Rets>(
|
||||||
ctx: &'a mut Ctx,
|
ctx: &'a mut Ctx,
|
||||||
name: &str,
|
name: &str,
|
||||||
) -> Result<Func<'a, Args, Rets>, ResolveError>
|
) -> Result<Func<'a, Args, Rets>, ResolveError>
|
||||||
@ -103,9 +103,9 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Make FCE config based on parsed raw config.
|
/// Make FCE config based on parsed raw config.
|
||||||
pub(super) fn make_wasm_process_config(
|
pub(crate) fn make_wasm_process_config(
|
||||||
config: Option<ModuleConfig>,
|
config: Option<ModuleConfig>,
|
||||||
) -> Result<FCEModuleConfig, NodeError> {
|
) -> Result<FCEModuleConfig, FaaSError> {
|
||||||
use super::imports::create_host_import_func;
|
use super::imports::create_host_import_func;
|
||||||
use super::imports::log_utf8_string;
|
use super::imports::log_utf8_string;
|
||||||
use wasmer_core::import::Namespace;
|
use wasmer_core::import::Namespace;
|
Reference in New Issue
Block a user