Merge branch 'develop' into da/tempfile

This commit is contained in:
tadad 2024-02-24 10:11:16 -06:00 committed by GitHub
commit b2986c0860
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 262 additions and 233 deletions

33
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,33 @@
---
name: Bug report
about: Create a report to help us improve
title: 'bug: '
labels: 'bug'
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Kinode version [e.g. v1.0.0]
- process_lib version [e.g. v1.0.0]
**Additional context**
Add any other context about the problem here.

View File

@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: 'feature: '
labels: 'enhancement'
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

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

View File

@ -18,8 +18,8 @@
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1.00001, viewport-fit=cover"
/>
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet'>
<script type="module" crossorigin src="/main:app_store:sys/assets/index-Wv-dWa0C.js"></script>
<link rel="stylesheet" crossorigin href="/main:app_store:sys/assets/index-aUqPNadJ.css">
<script type="module" crossorigin src="/main:app_store:sys/assets/index-5QTuaL_D.js"></script>
<link rel="stylesheet" crossorigin href="/main:app_store:sys/assets/index-SoWN8KT-.css">
</head>
<body>
<div id="root"></div>

View File

@ -148,7 +148,7 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> {
);
// if contract address changed from a previous run, reset state
if state.contract_address != contract_address {
println!("resetting state for some reason.");
println!("kns_indexer: contract address changed, re-indexing");
state = State {
contract_address: contract_address.clone(),
names: HashMap::new(),

View File

@ -1,5 +1,7 @@
use clap::{Arg, Command};
use kinode_process_lib::{await_next_request_body, call_init, println, Address, Request, Response};
use kinode_process_lib::{
await_next_request_body, call_init, println, Address, Request, Response, SendErrorKind,
};
use regex::Regex;
wit_bindgen::generate!({
@ -78,10 +80,24 @@ fn init(_our: Address) {
println!("m: awaiting response for {}s", s);
match req.send_and_await_response(*s).unwrap() {
Ok(res) => {
let _ = Response::new().body(res.body()).send();
// TODO piping is broken. Patching it by just printing the response
// let _ = Response::new().body(res.body()).send();
if let Ok(txt) = std::str::from_utf8(&res.body()) {
println!("{txt}");
} else {
println!("{:?}", res.body());
}
}
Err(e) => {
println!("m: SendError: {:?}", e.kind);
println!(
"m: {}",
match e.kind {
SendErrorKind::Timeout =>
"target did not send Response in time, try increasing the await time",
SendErrorKind::Offline =>
"failed to send message because the target is offline",
}
);
}
}
}

View File

@ -5,12 +5,15 @@
"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

@ -922,8 +922,12 @@ pub async fn kernel(
.send(t::Printout {
verbosity: 0,
content: format!(
"event loop: don't have {} amongst registered processes (got net error for it)",
"event loop: {} failed to deliver a message {}; sender has already terminated",
wrapped_network_error.source.process,
match wrapped_network_error.error.kind {
t::SendErrorKind::Timeout => "due to timeout",
t::SendErrorKind::Offline => "because the receiver is offline",
},
)
})
.await;
@ -982,8 +986,17 @@ pub async fn kernel(
.send(t::Printout {
verbosity: 0,
content: format!(
"event loop: don't have {} amongst registered processes (got message for it from network)",
"event loop: got {} from network for {}, but process does not exist{}",
match kernel_message.message {
t::Message::Request(_) => "Request",
t::Message::Response(_) => "Response",
},
kernel_message.target.process,
match kernel_message.message {
t::Message::Request(_) => "",
t::Message::Response(_) =>
"\nhint: if you are using `m`, try awaiting the Response: `m --await 5 ...`",
}
)
})
.await;
@ -1099,7 +1112,12 @@ pub async fn kernel(
.send(t::Printout {
verbosity: 0,
content: format!(
"event loop: don't have {:?} amongst registered processes, got message for it: {}",
"event loop: got {} from {:?} for {:?}, but target doesn't exist (perhaps it terminated): {}",
match kernel_message.message {
t::Message::Request(_) => "Request",
t::Message::Response(_) => "Response",
},
kernel_message.source.process,
kernel_message.target.process,
kernel_message,
)

View File

@ -117,7 +117,15 @@ 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(not(feature = "simulation-mode"))]
let app = app.arg(arg!(--rpc <WS_URL> "Ethereum RPC endpoint (must be wss://)").required(true));
#[cfg(feature = "simulation-mode")]
let app = app
@ -163,6 +171,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 +627,7 @@ async fn main() {
print_sender.clone(),
print_receiver,
is_detached,
verbose_mode,
) => {
match quit {
Ok(_) => "graceful exit".into(),

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;

15
pull_request_template.md Normal file
View File

@ -0,0 +1,15 @@
## Problem
{A brief description of the problem, along with necessary context.}
## Solution
{A brief description of how you solved the problem.}
## Docs Update
[Corresponding docs PR](https://github.com/kinode-dao/kinode-book/pull/my-pr-number)
## Notes
{Any other information useful for reviewers.}