Merge branch 'develop' into da/pipe-fix

This commit is contained in:
doria 2024-02-29 16:42:45 -03:00 committed by GitHub
commit 90bd2d9a88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 482 additions and 306 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -0,0 +1,12 @@
<svg width="779" height="514" viewBox="0 0 779 514" fill="none" xmlns="http://www.w3.org/2000/svg">
<style>
@media (prefers-color-scheme: dark) {
svg { fill: white; }
}
@media (prefers-color-scheme: light) {
svg { fill: black; }
}
</style>
<path d="M753.092 5.91932C756.557 5.09976 755.962 -0.00012207 752.401 -0.00012207H426.001C424.755 -0.00012207 423.639 0.77027 423.197 1.93535L236.968 492.6C235.729 495.865 240.123 498.255 242.191 495.441L569.357 50.1132C569.778 49.5392 570.391 49.1339 571.084 48.97L753.092 5.91932Z"/>
<path d="M11.9665 40.2288C9.10949 38.777 10.2135 34.4583 13.4167 34.5557L404.273 46.4367C406.334 46.4993 407.719 48.5749 406.986 50.5023L347.438 206.981C346.804 208.647 344.865 209.396 343.275 208.588L11.9665 40.2288Z"/>
</svg>

After

Width:  |  Height:  |  Size: 826 B

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -5,14 +5,17 @@
"on_exit": "Restart",
"request_networking": true,
"request_capabilities": [
"net:distro:sys",
"kernel:distro:sys",
"kv:distro:sys",
"http_server:distro:sys",
"sqlite:distro:sys",
"vfs:distro:sys"
],
"grant_capabilities": [
"kv:distro:sys",
"sqlite:distro:sys",
"vfs:distro:sys"
],
"public": true
}
]
]

View File

@ -1,7 +1,7 @@
use std::str::FromStr;
use kinode_process_lib::{
await_message, our_capabilities, println, spawn, vfs,
await_message, call_init, our_capabilities, println, spawn, vfs,
vfs::{DirEntry, FileType},
Address, Message, OnExit, ProcessId, Request, Response,
};
@ -48,11 +48,10 @@ fn handle_message(our: &Address) -> anyhow::Result<()> {
path: dir_prefix.into(),
action: vfs::VfsAction::ReadDir,
})?)
.send_and_await_response(test_timeout)?
.unwrap();
.send_and_await_response(test_timeout)??;
let Message::Response { body: vfs_body, .. } = response else {
panic!("")
fail!("test_runner");
};
let vfs::VfsResponse::ReadDir(mut children) =
serde_json::from_slice(&vfs_body)?
@ -61,7 +60,7 @@ fn handle_message(our: &Address) -> anyhow::Result<()> {
"{:?}",
serde_json::from_slice::<serde_json::Value>(&vfs_body)?
);
panic!("")
fail!("test_runner");
};
for test_name in test_names {
@ -116,7 +115,7 @@ fn handle_message(our: &Address) -> anyhow::Result<()> {
Ok(child_process_id) => child_process_id,
Err(e) => {
println!("couldn't spawn {}: {}", test_path, e);
panic!("couldn't spawn"); // TODO
fail!("test_runner");
}
};
@ -126,11 +125,10 @@ fn handle_message(our: &Address) -> anyhow::Result<()> {
process: child_process_id,
})
.body(body.clone())
.send_and_await_response(test_timeout)?
.unwrap();
.send_and_await_response(test_timeout)??;
let Message::Response { body, .. } = response else {
panic!("")
fail!("test_runner");
};
match serde_json::from_slice(&body)? {
tt::TesterResponse::Pass => {}
@ -149,12 +147,11 @@ fn handle_message(our: &Address) -> anyhow::Result<()> {
println!("test_runner: done running {:?}", children);
Response::new()
.body(serde_json::to_vec(&tt::TesterResponse::Pass).unwrap())
.send()
.unwrap();
.body(serde_json::to_vec(&tt::TesterResponse::Pass)?)
.send()?;
}
tt::TesterRequest::KernelMessage(_) | tt::TesterRequest::GetFullMessage(_) => {
unimplemented!()
fail!("test_runner");
}
}
Ok(())
@ -162,21 +159,17 @@ fn handle_message(our: &Address) -> anyhow::Result<()> {
}
}
struct Component;
impl Guest for Component {
fn init(our: String) {
println!("{:?}@test_runner: begin", our);
call_init!(init);
fn init(our: Address) {
println!("{}: begin", our);
let our: Address = our.parse().unwrap();
loop {
match handle_message(&our) {
Ok(()) => {}
Err(e) => {
println!("test_runner: error: {:?}", e);
fail!("test_runner");
}
};
}
loop {
match handle_message(&our) {
Ok(()) => {}
Err(e) => {
println!("test_runner: error: {:?}", e);
fail!("test_runner");
}
};
}
}

View File

@ -47,7 +47,7 @@ fn handle_message(
Response::new().body(body).send().unwrap();
}
tt::TesterResponse::GetFullMessage(_) => {
unimplemented!()
fail!("tester");
}
}
Ok(())
@ -83,7 +83,7 @@ fn handle_message(
Ok(child_process_id) => child_process_id,
Err(e) => {
println!("couldn't spawn {}: {}", child, e);
panic!("couldn't spawn"); // TODO
fail!("tester");
}
};
Request::new()
@ -92,12 +92,12 @@ fn handle_message(
process: child_process_id,
})
.body(body)
.expects_response(test_timeout)
.expects_response(test_timeout * 2)
.send()?;
}
}
tt::TesterRequest::KernelMessage(_) | tt::TesterRequest::GetFullMessage(_) => {
unimplemented!()
fail!("tester");
}
}
Ok(())
@ -107,11 +107,11 @@ fn handle_message(
call_init!(init);
fn init(our: Address) {
println!("tester: begin");
println!("{}: begin", our);
let mut messages: Messages = IndexMap::new();
let mut node_names: Vec<String> = Vec::new();
let _ = Request::new()
match Request::new()
.target(make_vfs_address(&our).unwrap())
.body(
serde_json::to_vec(&vfs::VfsRequest {
@ -121,12 +121,20 @@ fn init(our: Address) {
.unwrap(),
)
.send_and_await_response(5)
.unwrap()
.unwrap();
{
Err(_) => {
fail!("tester");
}
Ok(r) => {
if r.is_err() {
fail!("tester");
}
}
}
// orchestrate tests using external scripts
// -> must give drive cap to rpc
let _ = Request::new()
let sent = Request::new()
.target(("our", "kernel", "distro", "sys"))
.body(
serde_json::to_vec(&kt::KernelCommand::GrantCapabilities {
@ -145,14 +153,17 @@ fn init(our: Address) {
})
.unwrap(),
)
.send()
.unwrap();
.send();
if sent.is_err() {
fail!("tester");
}
loop {
match handle_message(&our, &mut messages, &mut node_names) {
Ok(()) => {}
Err(e) => {
println!("tester: error: {:?}", e,);
fail!("tester");
}
};
}

View File

@ -89,6 +89,7 @@ async fn handle_kernel_request(
reverse_cap_index: &mut t::ReverseCapIndex,
caps_oracle: t::CapMessageSender,
engine: &Engine,
home_directory_path: &str,
) {
let t::Message::Request(request) = km.message else {
return;
@ -274,6 +275,7 @@ async fn handle_kernel_request(
},
reboot: false,
},
&home_directory_path,
)
.await
{
@ -580,6 +582,7 @@ async fn start_process(
engine: &Engine,
caps_oracle: t::CapMessageSender,
process_metadata: &StartProcessMetadata,
home_directory_path: &str,
) -> Result<()> {
let (send_to_process, recv_in_process) =
mpsc::channel::<Result<t::KernelMessage, t::WrappedSendError>>(PROCESS_CHANNEL_CAPACITY);
@ -622,6 +625,7 @@ async fn start_process(
km_blob_bytes,
caps_oracle,
engine.clone(),
home_directory_path.to_string(),
)),
);
@ -786,6 +790,7 @@ pub async fn kernel(
&engine,
caps_oracle_sender.clone(),
&metadata,
home_directory_path.as_str(),
)
.await
{
@ -1090,6 +1095,7 @@ pub async fn kernel(
&mut reverse_cap_index,
caps_oracle_sender.clone(),
&engine,
&home_directory_path,
).await;
} else {
// pass message to appropriate runtime module or process

View File

@ -8,11 +8,15 @@ pub use lib::Process;
use ring::signature::{self, KeyPair};
use std::collections::{HashMap, VecDeque};
use std::sync::Arc;
use tokio::fs;
use tokio::task::JoinHandle;
use wasmtime::component::ResourceTable as Table;
use wasmtime::component::*;
use wasmtime::{Engine, Store};
use wasmtime_wasi::preview2::{pipe::MemoryOutputPipe, WasiCtx, WasiCtxBuilder, WasiView};
use wasmtime_wasi::preview2::{
pipe::MemoryOutputPipe, DirPerms, FilePerms, WasiCtx, WasiCtxBuilder, WasiView,
};
use wasmtime_wasi::sync::Dir;
const STACK_TRACE_SIZE: usize = 5000;
@ -493,6 +497,7 @@ pub async fn make_process_loop(
wasm_bytes: Vec<u8>,
caps_oracle: t::CapMessageSender,
engine: Engine,
home_directory_path: String,
) -> Result<()> {
// before process can be instantiated, need to await 'run' message from kernel
let mut pre_boot_queue = Vec::<Result<t::KernelMessage, t::WrappedSendError>>::new();
@ -536,7 +541,31 @@ pub async fn make_process_loop(
let table = Table::new();
let wasi_stderr = MemoryOutputPipe::new(STACK_TRACE_SIZE);
let wasi = WasiCtxBuilder::new().stderr(wasi_stderr.clone()).build();
let tmp_path = format!(
"{}/vfs/{}:{}/tmp",
home_directory_path,
metadata.our.process.package(),
metadata.our.process.publisher()
);
if let Err(e) = fs::create_dir_all(&tmp_path).await {
panic!("failed creating tmp dir! {:?}", e);
}
let Ok(wasi_tempdir) =
Dir::open_ambient_dir(tmp_path.clone(), wasmtime_wasi::sync::ambient_authority())
else {
panic!("failed to open ambient tmp dir!");
};
let wasi = WasiCtxBuilder::new()
.preopened_dir(
wasi_tempdir,
DirPerms::all(),
FilePerms::all(),
tmp_path.clone(),
)
.env("TEMP_DIR", tmp_path)
.stderr(wasi_stderr.clone())
.build();
wasmtime_wasi::preview2::command::add_to_linker(&mut linker).unwrap();

View File

@ -117,7 +117,12 @@ async fn main() {
.value_parser(value_parser!(bool)),
)
.arg(arg!(--rpcnode <String> "RPC node provider must be a valid address").required(false))
.arg(arg!(--rpc <WS_URL> "Ethereum RPC endpoint (must be wss://)").required(false));
.arg(arg!(--rpc <WS_URL> "Ethereum RPC endpoint (must be wss://)").required(false))
.arg(
arg!(--verbosity <VERBOSITY> "Verbosity level: higher is more verbose")
.default_value("0")
.value_parser(value_parser!(u8)),
);
#[cfg(feature = "simulation-mode")]
let app = app
@ -163,6 +168,7 @@ async fn main() {
} else {
register::KNS_OPTIMISM_ADDRESS
};
let verbose_mode = *matches.get_one::<u8>("verbosity").unwrap();
// check .testnet file for true/false in order to enforce testnet mode on subsequent boots of this node
match fs::read(format!("{}/.testnet", home_directory_path)).await {
@ -618,6 +624,7 @@ async fn main() {
print_sender.clone(),
print_receiver,
is_detached,
verbose_mode,
) => {
match quit {
Ok(_) => "graceful exit".into(),

View File

@ -1,12 +1,15 @@
{
"files": {
"main.css": "/static/css/main.74f501c5.css",
"main.js": "/static/js/main.084b4a46.js",
"main.css": "/static/css/main.dce05a4d.css",
"main.js": "/static/js/main.726c0750.js",
"static/media/unknown.png": "/static/media/unknown.880d04d4611a45ab1001.png",
"index.html": "/index.html"
"static/media/background.jpg": "/static/media/background.01d2427cfc21fb685016.jpg",
"static/media/kinode.svg": "/static/media/kinode.86d0c1a6a4a3ca3be41616b5989d6925.svg",
"index.html": "/index.html",
"static/media/logo.svg": "/static/media/logo.45dcb752ac5b825f5e3b9299d2210f0a.svg"
},
"entrypoints": [
"static/css/main.74f501c5.css",
"static/js/main.084b4a46.js"
"static/css/main.dce05a4d.css",
"static/js/main.726c0750.js"
]
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -0,0 +1,18 @@
<svg width="580" height="72" viewBox="0 0 580 72" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_6_641)">
<path d="M0.824922 1.07031L0.794922 70.0703H14.7949L14.8049 1.07031H0.824922Z" fill="#FFF5D9"/>
<path d="M16.5947 36.8803L41.2547 1.07031H58.2447L33.1647 36.8803L61.2447 70.0703H42.9947L16.5947 36.8803Z" fill="#FFF5D9"/>
<path d="M119.885 1.07031H105.765V70.0703H119.885V1.07031Z" fill="#FFF5D9"/>
<path d="M173.185 1.07031V70.0703H186.775V26.8303L224.045 70.0703H234.825V1.07031H221.325V45.6803L183.445 1.07031H173.185Z" fill="#FFF5D9"/>
<path d="M342.465 8.86C333.025 0.15 321.645 0 318.535 0C315.475 0 303.575 0.22 294.005 9.52C283.845 19.4 283.805 32.24 283.795 35.66C283.785 39.3 283.895 49.03 290.805 57.99C300.855 71.02 316.695 71.31 318.535 71.32C321.375 71.32 334.185 71 343.965 60.66C353.065 51.04 353.265 39.4 353.275 35.66C353.275 32.49 353.305 18.86 342.455 8.86H342.465ZM318.435 58.01C307.095 58.01 297.895 47.95 297.895 35.54C297.895 23.13 307.085 13.07 318.435 13.07C329.785 13.07 338.975 23.13 338.975 35.54C338.975 47.95 329.785 58.01 318.435 58.01Z" fill="#FFF5D9"/>
<path d="M450.495 12.0802C444.975 5.46023 437.135 0.990234 427.955 0.990234C417.555 0.990234 405.295 1.07023 402.295 1.07023V69.9802C405.285 69.9802 417.555 70.0602 427.955 70.0602C445.525 70.0602 458.445 53.4102 459.065 36.8602C459.395 28.0102 456.185 18.9002 450.495 12.0802ZM440.085 49.9502C436.895 53.8702 432.705 56.6902 427.665 57.5602C424.025 58.1902 420.095 57.8302 416.405 57.8302C416.405 50.4002 416.405 42.9802 416.405 35.5502V13.2202C423.795 13.2202 430.525 12.7002 436.605 17.6002C440.275 20.5602 442.925 24.7102 444.165 29.2402C444.525 30.5402 444.765 31.8802 444.875 33.2302C445.395 39.3702 443.995 45.1402 440.085 49.9502Z" fill="#FFF5D9"/>
<path d="M508.135 0.990234V70.0602H552.715V57.9302H522.035V40.4202H547.125V28.0702H521.995V13.3202H552.715V0.990234H508.135Z" fill="#FFF5D9"/>
<path d="M574.835 66.0398H572.745L571.015 63.0698H569.845V66.0398H567.805V57.5498H571.765C572.845 57.5498 573.865 57.9298 574.425 58.9398C575.205 60.3698 574.665 62.3798 573.105 63.0298C573.725 64.1198 574.225 64.9498 574.845 66.0398H574.835ZM570.375 61.0798H570.845C571.335 61.0798 572.365 61.0798 572.365 60.2898C572.365 59.5598 571.335 59.5598 570.845 59.5598H570.375V61.0798Z" fill="#FFF5D9"/>
<path d="M570.964 69.0002C574.913 69.0002 578.114 65.799 578.114 61.8502C578.114 57.9014 574.913 54.7002 570.964 54.7002C567.016 54.7002 563.814 57.9014 563.814 61.8502C563.814 65.799 567.016 69.0002 570.964 69.0002Z" stroke="#FFF5D9" stroke-width="2.2" stroke-miterlimit="10"/>
</g>
<defs>
<clipPath id="clip0_6_641">
<rect width="578.41" height="71.32" fill="white" transform="translate(0.794922)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -0,0 +1,10 @@
<svg width="122" height="81" viewBox="0 0 122 81" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_6_651)">
<path d="M89.3665 8.06803L121.5 0.35155L66.5111 0.320312L63.7089 7.69502L0.5 5.7032L54.0253 32.9925L36.1529 80.3203L89.3665 8.06803Z" fill="#FFF5D9"/>
</g>
<defs>
<clipPath id="clip0_6_651">
<rect width="121" height="80" fill="white" transform="translate(0.5 0.320312)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 431 B

View File

@ -52,6 +52,7 @@ pub async fn terminal(
print_tx: PrintSender,
mut print_rx: PrintReceiver,
is_detached: bool,
mut verbose_mode: u8,
) -> Result<()> {
let mut stdout = stdout();
execute!(
@ -139,7 +140,6 @@ pub async fn terminal(
let mut cursor_col: u16 = prompt_len.try_into().unwrap();
let mut line_col: usize = cursor_col as usize;
let mut in_step_through: bool = false;
let mut verbose_mode: u8 = 0; // least verbose mode
let mut search_mode: bool = false;
let mut search_depth: usize = 0;
let mut logging_mode: bool = false;