bump wasmtime deps to 19.0.1

This commit is contained in:
hosted-fornet 2024-04-03 16:53:07 -07:00
parent 28638c2019
commit 98681db0e0
52 changed files with 598 additions and 572 deletions

618
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@ path = "src/main.rs"
[build-dependencies]
anyhow = "1.0.71"
kit = { git = "https://github.com/kinode-dao/kit", rev = "1bd7bec" }
kit = { git = "https://github.com/kinode-dao/kit", rev = "95cfc41" }
rayon = "1.8.1"
sha2 = "0.10"
tokio = "1.28"
@ -86,6 +86,7 @@ tokio-tungstenite = "0.20.1"
url = "2.4.1"
uuid = { version = "1.1.2", features = ["serde", "v4"] }
warp = "0.3.5"
wasmtime = "17.0.1"
wasmtime-wasi = "17.0.1"
wasi-common = "19.0.1"
wasmtime = "19.0.1"
wasmtime-wasi = "19.0.1"
zip = "0.6"

View File

@ -48,7 +48,9 @@ fn build_and_zip_package(
) -> anyhow::Result<(String, String, Vec<u8>)> {
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async {
kit::build::execute(&entry_path, true, false, true, features).await?;
kit::build::execute(&entry_path, true, false, true, features)
.await
.map_err(|e| anyhow::anyhow!("{:?}", e))?;
let mut writer = Cursor::new(Vec::new());
let options = FileOptions::default()

View File

@ -11,7 +11,7 @@ alloy-primitives = "0.6.2"
alloy-sol-types = "0.6.2"
anyhow = "1.0"
bincode = "1.3.3"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
@ -19,7 +19,7 @@ sha2 = "0.10.8"
sha3 = "0.10.8"
url = "2.4.1"
urlencoding = "2.1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
zip = { version = "0.6.6", default-features = false }
[lib]

View File

@ -9,9 +9,6 @@ use std::str::FromStr;
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
mod api;

View File

@ -8,10 +8,10 @@ simulation-mode = []
[dependencies]
anyhow = "1.0"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -1,5 +1,5 @@
use kinode_process_lib::{
await_next_request_body, call_init, println, Address, Message, NodeId, PackageId, Request,
await_next_message_body, call_init, println, Address, Message, NodeId, PackageId, Request,
};
mod api;
@ -8,15 +8,11 @@ use api::*;
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
call_init!(init);
fn init(our: Address) {
let Ok(body) = await_next_request_body() else {
let Ok(body) = await_next_message_body() else {
println!("download: failed to get args!");
return;
};

View File

@ -9,11 +9,11 @@ simulation-mode = []
[dependencies]
anyhow = "1.0"
bincode = "1.3.3"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -8,9 +8,6 @@ use ft_worker_lib::*;
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
/// internal worker protocol
@ -21,7 +18,6 @@ pub enum FTWorkerProtocol {
}
call_init!(init);
fn init(our: Address) {
let Ok(Message::Request {
source: parent_process,

View File

@ -8,10 +8,10 @@ simulation-mode = []
[dependencies]
anyhow = "1.0"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -1,5 +1,5 @@
use kinode_process_lib::{
await_next_request_body, call_init, println, Address, Message, PackageId, Request,
await_next_message_body, call_init, println, Address, Message, PackageId, Request,
};
mod api;
@ -8,15 +8,11 @@ use api::*;
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
call_init!(init);
fn init(our: Address) {
let Ok(body) = await_next_request_body() else {
let Ok(body) = await_next_message_body() else {
println!("install: failed to get args!");
return;
};

View File

@ -8,10 +8,10 @@ simulation-mode = []
[dependencies]
anyhow = "1.0"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -1,5 +1,5 @@
use kinode_process_lib::{
await_next_request_body, call_init, println, Address, Message, PackageId, Request,
await_next_message_body, call_init, println, Address, Message, PackageId, Request,
};
mod api;
@ -8,15 +8,11 @@ use api::*;
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
call_init!(init);
fn init(our: Address) {
let Ok(body) = await_next_request_body() else {
let Ok(body) = await_next_message_body() else {
println!("uninstall: failed to get args!");
return;
};

View File

@ -10,12 +10,12 @@ simulation-mode = []
anyhow = "1.0"
base64 = "0.13"
bincode = "1.3.3"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
pleco = "0.5"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
url = "*"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -100,14 +100,10 @@ fn send_ws_update(our: &Address, game: &Game, open_channels: &HashSet<u32>) -> a
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
// After generating bindings, use this macro to define the Component struct
// and its init() function, which the kernel will look for on startup.
call_init!(initialize);
fn initialize(our: Address) {
// A little printout to show in terminal that the process has started.
println!("started");

View File

@ -9,10 +9,10 @@ simulation-mode = []
[dependencies]
anyhow = "1.0"
bincode = "1.3.3"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -36,9 +36,6 @@ struct HomepageApp {
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
const HOME_PAGE: &str = include_str!("index.html");
@ -50,8 +47,6 @@ const APP_TEMPLATE: &str = r#"
<h6>${label}</h6>
</a>"#;
call_init!(init);
/// bind to root path on http_server (we have special dispensation to do so!)
fn bind_index(our: &str, apps: &HashMap<ProcessId, String>) {
bind_http_static_path(
@ -161,6 +156,7 @@ fn bind_index(our: &str, apps: &HashMap<ProcessId, String>) {
// Ok(())
// }
call_init!(init);
fn init(our: Address) {
let mut apps: HashMap<ProcessId, String> = HashMap::new();
let mut app_data: HashMap<ProcessId, HomepageApp> = HashMap::new();

View File

@ -7,10 +7,10 @@ edition = "2021"
simulation-mode = []
[dependencies]
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -1,17 +1,13 @@
use kinode_process_lib::{await_next_request_body, call_init, eth, println, Address};
use kinode_process_lib::{await_next_message_body, call_init, eth, println, Address};
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
call_init!(init);
fn init(_our: Address) {
let Ok(args) = await_next_request_body() else {
let Ok(args) = await_next_message_body() else {
println!("failed to get args");
return;
};

View File

@ -12,11 +12,11 @@ alloy-primitives = "0.6.2"
alloy-sol-types = "0.6.2"
bincode = "1.3.3"
hex = "0.4.3"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
rmp-serde = "1.1.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -1,6 +1,6 @@
use alloy_sol_types::{sol, SolEvent};
use kinode_process_lib::{
await_message, eth, get_typed_state, println, set_state, Address, Message, Request, Response,
await_message, call_init, eth, get_typed_state, println, set_state, Address, Message, Request, Response,
};
use serde::{Deserialize, Serialize};
use std::collections::{
@ -12,9 +12,6 @@ use std::string::FromUtf8Error;
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
#[derive(Clone, Debug, Serialize, Deserialize)]
@ -114,63 +111,59 @@ fn subscribe_to_logs(eth_provider: &eth::Provider, from_block: u64, filter: eth:
println!("subscribed to logs successfully");
}
struct Component;
impl Guest for Component {
fn init(our: String) {
let our: Address = our.parse().unwrap();
// first, await a message from the kernel which will contain the
// chain ID and contract address for the KNS version we want to track.
let chain_id: u64;
let contract_address: String;
loop {
let Ok(Message::Request { source, body, .. }) = await_message() else {
continue;
};
if source.process != "kernel:distro:sys" {
continue;
}
(chain_id, contract_address) = serde_json::from_slice(&body).unwrap();
break;
}
println!("indexing on contract address {}", contract_address);
// if we have state, load it in
let state: State = match get_typed_state(|bytes| Ok(bincode::deserialize::<State>(bytes)?))
{
Some(s) => {
// if chain id or contract address changed from a previous run, reset state
if s.chain_id != chain_id || s.contract_address != contract_address {
println!(
"resetting state because runtime contract address or chain ID changed"
);
State {
chain_id,
contract_address,
names: HashMap::new(),
nodes: HashMap::new(),
block: 1,
}
} else {
println!("loading in {} persisted PKI entries", s.nodes.len());
s
}
}
None => State {
chain_id,
contract_address: contract_address.clone(),
names: HashMap::new(),
nodes: HashMap::new(),
block: 1,
},
call_init!(init);
fn init(our: Address) {
// first, await a message from the kernel which will contain the
// chain ID and contract address for the KNS version we want to track.
let chain_id: u64;
let contract_address: String;
loop {
let Ok(Message::Request { source, body, .. }) = await_message() else {
continue;
};
if source.process != "kernel:distro:sys" {
continue;
}
(chain_id, contract_address) = serde_json::from_slice(&body).unwrap();
break;
}
println!("indexing on contract address {}", contract_address);
match main(our, state) {
Ok(_) => {}
Err(e) => {
println!("error: {:?}", e);
// if we have state, load it in
let state: State = match get_typed_state(|bytes| Ok(bincode::deserialize::<State>(bytes)?))
{
Some(s) => {
// if chain id or contract address changed from a previous run, reset state
if s.chain_id != chain_id || s.contract_address != contract_address {
println!(
"resetting state because runtime contract address or chain ID changed"
);
State {
chain_id,
contract_address,
names: HashMap::new(),
nodes: HashMap::new(),
block: 1,
}
} else {
println!("loading in {} persisted PKI entries", s.nodes.len());
s
}
}
None => State {
chain_id,
contract_address: contract_address.clone(),
names: HashMap::new(),
nodes: HashMap::new(),
block: 1,
},
};
match main(our, state) {
Ok(_) => {}
Err(e) => {
println!("error: {:?}", e);
}
}
}

View File

@ -7,10 +7,10 @@ edition = "2021"
simulation-mode = []
[dependencies]
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -5,9 +5,6 @@ use std::collections::HashMap;
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
/// From main kns_indexer process
@ -37,7 +34,6 @@ pub struct KnsUpdate {
}
call_init!(init);
fn init(_our: Address) {
let Ok(Message::Response { body, .. }) =
Request::to(("our", "kns_indexer", "kns_indexer", "sys"))

View File

@ -8,10 +8,10 @@ simulation-mode = []
[dependencies]
anyhow = "1.0"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -1,14 +1,11 @@
use kinode_process_lib::{
await_next_request_body, call_init, println, Address, ProcessId, Request,
await_next_message_body, call_init, println, Address, ProcessId, Request,
};
use serde::{Deserialize, Serialize};
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
#[derive(Debug, Serialize, Deserialize)]
@ -20,9 +17,8 @@ enum TerminalAction {
}
call_init!(init);
fn init(_our: Address) {
let Ok(args) = await_next_request_body() else {
let Ok(args) = await_next_message_body() else {
println!("failed to get args");
return;
};

View File

@ -8,10 +8,10 @@ simulation-mode = []
[dependencies]
anyhow = "1.0"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -1,19 +1,15 @@
use kinode_process_lib::{
await_next_request_body, call_init, get_blob, println, vfs, Address, Request,
await_next_message_body, call_init, get_blob, println, vfs, Address, Request,
};
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
call_init!(init);
fn init(_our: Address) {
let Ok(args) = await_next_request_body() else {
let Ok(args) = await_next_message_body() else {
println!("failed to get args");
return;
};

View File

@ -8,10 +8,10 @@ simulation-mode = []
[dependencies]
anyhow = "1.0"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -1,17 +1,13 @@
use kinode_process_lib::{await_next_request_body, call_init, println, Address};
use kinode_process_lib::{await_next_message_body, call_init, println, Address};
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
call_init!(init);
fn init(_our: Address) {
let Ok(args) = await_next_request_body() else {
let Ok(args) = await_next_message_body() else {
println!("failed to get args");
return;
};

View File

@ -7,10 +7,10 @@ edition = "2021"
simulation-mode = []
[dependencies]
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -1,19 +1,15 @@
use kinode_process_lib::{
await_next_request_body, call_init, println, Address, Request, SendError, SendErrorKind,
await_next_message_body, call_init, println, Address, Request, SendError, SendErrorKind,
};
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
call_init!(init);
fn init(our: Address) {
let Ok(args) = await_next_request_body() else {
let Ok(args) = await_next_message_body() else {
println!("failed to get args");
return;
};

View File

@ -9,11 +9,11 @@ simulation-mode = []
[dependencies]
anyhow = "1.0"
clap = "4.4.18"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
regex = "1.10.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -1,21 +1,17 @@
use clap::{Arg, Command};
use kinode_process_lib::{
await_next_request_body, call_init, println, Address, Request, SendErrorKind,
await_next_message_body, call_init, println, Address, Request, SendErrorKind,
};
use regex::Regex;
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
call_init!(init);
fn init(_our: Address) {
let Ok(body) = await_next_request_body() else {
let Ok(body) = await_next_message_body() else {
println!("failed to get args");
return;
};

View File

@ -7,10 +7,10 @@ edition = "2021"
simulation-mode = []
[dependencies]
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
rmp-serde = "1.1.2"
serde = { version = "1.0", features = ["derive"] }
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -1,14 +1,11 @@
use kinode_process_lib::{
await_next_request_body, call_init, println, Address, Message, NodeId, Request,
await_next_message_body, call_init, println, Address, Message, NodeId, Request,
};
use serde::{Deserialize, Serialize};
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
// types copied from runtime networking core
@ -52,9 +49,8 @@ pub enum NetResponse {
}
call_init!(init);
fn init(_our: Address) {
let Ok(args) = await_next_request_body() else {
let Ok(args) = await_next_message_body() else {
println!("failed to get args");
return;
};

View File

@ -7,10 +7,10 @@ edition = "2021"
simulation-mode = []
[dependencies]
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
rmp-serde = "1.1.2"
serde = { version = "1.0", features = ["derive"] }
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -4,9 +4,6 @@ use serde::{Deserialize, Serialize};
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
// types copied from runtime networking core
@ -50,7 +47,6 @@ pub enum NetResponse {
}
call_init!(init);
fn init(_our: Address) {
let Ok(Ok(Message::Response { body, .. })) = Request::to(("our", "net", "distro", "sys"))
.body(rmp_serde::to_vec(&NetAction::GetDiagnostics).unwrap())

View File

@ -7,10 +7,10 @@ edition = "2021"
simulation-mode = []
[dependencies]
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
rmp-serde = "1.1.2"
serde = { version = "1.0", features = ["derive"] }
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -1,14 +1,11 @@
use kinode_process_lib::{
await_next_request_body, call_init, println, Address, Message, NodeId, Request,
await_next_message_body, call_init, println, Address, Message, NodeId, Request,
};
use serde::{Deserialize, Serialize};
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
// types copied from runtime networking core
@ -52,9 +49,8 @@ pub enum NetResponse {
}
call_init!(init);
fn init(_our: Address) {
let Ok(args) = await_next_request_body() else {
let Ok(args) = await_next_message_body() else {
println!("failed to get args");
return;
};

View File

@ -7,10 +7,10 @@ edition = "2021"
simulation-mode = []
[dependencies]
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
rmp-serde = "1.1.2"
serde = { version = "1.0", features = ["derive"] }
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -4,9 +4,6 @@ use serde::{Deserialize, Serialize};
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
// types copied from runtime networking core
@ -50,7 +47,6 @@ pub enum NetResponse {
}
call_init!(init);
fn init(_our: Address) {
let Ok(Ok(Message::Response { body, .. })) = Request::to(("our", "net", "distro", "sys"))
.body(rmp_serde::to_vec(&NetAction::GetPeers).unwrap())

View File

@ -9,12 +9,12 @@ simulation-mode = []
[dependencies]
anyhow = "1.0"
bincode = "1.3.3"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
rand = "0.8"
regex = "1.10.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -2,7 +2,7 @@ use anyhow::anyhow;
use kinode_process_lib::kernel_types as kt;
use kinode_process_lib::kinode::process::standard as wit;
use kinode_process_lib::{
get_blob, get_typed_state, our_capabilities, print_to_terminal, println, set_state, vfs,
call_init, get_blob, get_typed_state, our_capabilities, print_to_terminal, println, set_state, vfs,
Address, Capability, ProcessId, Request,
};
use serde::{Deserialize, Serialize};
@ -11,9 +11,6 @@ use std::collections::{HashMap, HashSet};
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
#[derive(Debug, Serialize, Deserialize)]
@ -51,103 +48,101 @@ fn parse_command(state: &mut TerminalState, line: &str) -> anyhow::Result<()> {
}
}
struct Component;
impl Guest for Component {
fn init(our: String) {
let mut state: TerminalState =
match get_typed_state(|bytes| Ok(bincode::deserialize(bytes)?)) {
Some(s) => s,
None => TerminalState {
our: our.parse::<Address>().unwrap(),
aliases: HashMap::from([
(
"alias".to_string(),
ProcessId::new(Some("alias"), "terminal", "sys"),
),
(
"cat".to_string(),
ProcessId::new(Some("cat"), "terminal", "sys"),
),
(
"echo".to_string(),
ProcessId::new(Some("echo"), "terminal", "sys"),
),
(
"hi".to_string(),
ProcessId::new(Some("hi"), "terminal", "sys"),
),
(
"m".to_string(),
ProcessId::new(Some("m"), "terminal", "sys"),
),
(
"namehash_to_name".to_string(),
ProcessId::new(Some("namehash_to_name"), "terminal", "sys"),
),
(
"net_diagnostics".to_string(),
ProcessId::new(Some("net_diagnostics"), "terminal", "sys"),
),
(
"peer".to_string(),
ProcessId::new(Some("peer"), "terminal", "sys"),
),
(
"peers".to_string(),
ProcessId::new(Some("peers"), "terminal", "sys"),
),
(
"top".to_string(),
ProcessId::new(Some("top"), "terminal", "sys"),
),
]),
},
};
call_init!(init);
fn init(our: Address) {
let mut state: TerminalState =
match get_typed_state(|bytes| Ok(bincode::deserialize(bytes)?)) {
Some(s) => s,
None => TerminalState {
our,
aliases: HashMap::from([
(
"alias".to_string(),
ProcessId::new(Some("alias"), "terminal", "sys"),
),
(
"cat".to_string(),
ProcessId::new(Some("cat"), "terminal", "sys"),
),
(
"echo".to_string(),
ProcessId::new(Some("echo"), "terminal", "sys"),
),
(
"hi".to_string(),
ProcessId::new(Some("hi"), "terminal", "sys"),
),
(
"m".to_string(),
ProcessId::new(Some("m"), "terminal", "sys"),
),
(
"namehash_to_name".to_string(),
ProcessId::new(Some("namehash_to_name"), "terminal", "sys"),
),
(
"net_diagnostics".to_string(),
ProcessId::new(Some("net_diagnostics"), "terminal", "sys"),
),
(
"peer".to_string(),
ProcessId::new(Some("peer"), "terminal", "sys"),
),
(
"peers".to_string(),
ProcessId::new(Some("peers"), "terminal", "sys"),
),
(
"top".to_string(),
ProcessId::new(Some("top"), "terminal", "sys"),
),
]),
},
};
loop {
let (source, message) = match wit::receive() {
Ok((source, message)) => (source, message),
Err((error, _context)) => {
println!("net error: {:?}!", error.kind);
loop {
let (source, message) = match wit::receive() {
Ok((source, message)) => (source, message),
Err((error, _context)) => {
println!("net error: {:?}!", error.kind);
continue;
}
};
match message {
wit::Message::Request(wit::Request { body, .. }) => {
if state.our == source {
match parse_command(
&mut state,
std::str::from_utf8(&body).unwrap_or_default(),
) {
Ok(()) => continue,
Err(e) => println!("{e}"),
}
} else if state.our.node == source.node
&& state.our.package() == source.package()
{
let Ok(action) = serde_json::from_slice::<TerminalAction>(&body) else {
println!("failed to parse action from: {}", source);
continue;
};
match action {
TerminalAction::EditAlias { alias, process } => {
match handle_alias_change(&mut state, alias, process) {
Ok(()) => continue,
Err(e) => println!("{e}"),
};
}
}
} else {
println!("ignoring message from: {}", source);
continue;
}
};
match message {
wit::Message::Request(wit::Request { body, .. }) => {
if state.our == source {
match parse_command(
&mut state,
std::str::from_utf8(&body).unwrap_or_default(),
) {
Ok(()) => continue,
Err(e) => println!("{e}"),
}
} else if state.our.node == source.node
&& state.our.package() == source.package()
{
let Ok(action) = serde_json::from_slice::<TerminalAction>(&body) else {
println!("failed to parse action from: {}", source);
continue;
};
match action {
TerminalAction::EditAlias { alias, process } => {
match handle_alias_change(&mut state, alias, process) {
Ok(()) => continue,
Err(e) => println!("{e}"),
};
}
}
} else {
println!("ignoring message from: {}", source);
continue;
}
}
wit::Message::Response((wit::Response { body, .. }, _)) => {
if let Ok(txt) = std::str::from_utf8(&body) {
println!("{txt}");
} else {
println!("{body:?}");
}
}
wit::Message::Response((wit::Response { body, .. }, _)) => {
if let Ok(txt) = std::str::from_utf8(&body) {
println!("{txt}");
} else {
println!("{body:?}");
}
}
}

View File

@ -8,10 +8,10 @@ simulation-mode = []
[dependencies]
anyhow = "1.0"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -1,20 +1,16 @@
use kinode_process_lib::kernel_types::{KernelCommand, KernelPrint};
use kinode_process_lib::{
await_next_request_body, call_init, println, Address, ProcessId, Request,
await_next_message_body, call_init, println, Address, ProcessId, Request,
};
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
call_init!(init);
fn init(_our: Address) {
let Ok(args) = await_next_request_body() else {
let Ok(args) = await_next_message_body() else {
println!("failed to get args");
return;
};

View File

@ -9,11 +9,11 @@ simulation-mode = []
[dependencies]
anyhow = "1.0"
bincode = "1.3.3"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -12,9 +12,6 @@ use tester_types as tt;
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
fn make_vfs_address(our: &Address) -> anyhow::Result<Address> {

View File

@ -10,11 +10,11 @@ simulation-mode = []
anyhow = "1.0"
bincode = "1.3.3"
indexmap = "2.1"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "84b3d84" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
[lib]
crate-type = ["cdylib"]

View File

@ -12,9 +12,6 @@ use tester_types as tt;
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});
type Messages = IndexMap<kt::Message, tt::KernelMessage>;

View File

@ -12,10 +12,10 @@ use tokio::task::JoinHandle;
use wasmtime::component::ResourceTable as Table;
use wasmtime::component::*;
use wasmtime::{Engine, Store};
use wasmtime_wasi::preview2::{
use wasmtime_wasi::{
pipe::MemoryOutputPipe, DirPerms, FilePerms, WasiCtx, WasiCtxBuilder, WasiView,
};
use wasmtime_wasi::sync::Dir;
use wasi_common::sync::Dir;
const STACK_TRACE_SIZE: usize = 5000;
@ -63,16 +63,10 @@ pub struct ProcessWasi {
}
impl WasiView for ProcessWasi {
fn table(&self) -> &Table {
&self.table
}
fn table_mut(&mut self) -> &mut Table {
fn table(&mut self) -> &mut Table {
&mut self.table
}
fn ctx(&self) -> &WasiCtx {
&self.wasi
}
fn ctx_mut(&mut self) -> &mut WasiCtx {
fn ctx(&mut self) -> &mut WasiCtx {
&mut self.wasi
}
}
@ -558,7 +552,7 @@ pub async fn make_process_loop(
.await
{
if let Ok(wasi_tempdir) =
Dir::open_ambient_dir(tmp_path.clone(), wasmtime_wasi::sync::ambient_authority())
Dir::open_ambient_dir(tmp_path.clone(), wasi_common::sync::ambient_authority())
{
wasi.preopened_dir(
wasi_tempdir,
@ -572,7 +566,7 @@ pub async fn make_process_loop(
let wasi = wasi.stderr(wasi_stderr.clone()).build();
wasmtime_wasi::preview2::command::add_to_linker(&mut linker).unwrap();
wasmtime_wasi::command::add_to_linker(&mut linker).unwrap();
let mut store = Store::new(
&engine,

Binary file not shown.

View File

@ -23,4 +23,4 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"
tokio = { version = "1.28", features = ["sync"] }
wasmtime = { version = "17.0.1", features = ["component-model"] }
wasmtime = { version = "19.0.1", features = ["component-model"] }