mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-18 22:21:50 +03:00
Merge pull request #105 from uqbar-dao/hf/fix-spawn-and-vfs-caps
fix spawn and vfs messaging caps
This commit is contained in:
commit
a7e39aaa50
@ -42,7 +42,7 @@ fn handle_message(our: &Address) -> anyhow::Result<()> {
|
|||||||
let response = Request::new()
|
let response = Request::new()
|
||||||
.target(make_vfs_address(&our)?)
|
.target(make_vfs_address(&our)?)
|
||||||
.ipc(serde_json::to_vec(&kt::VfsRequest {
|
.ipc(serde_json::to_vec(&kt::VfsRequest {
|
||||||
path: "/tester:uqbar/pkg".into(),
|
path: "/tester:uqbar/tests".into(),
|
||||||
action: kt::VfsAction::ReadDir,
|
action: kt::VfsAction::ReadDir,
|
||||||
})?)
|
})?)
|
||||||
.send_and_await_response(test_timeout)?
|
.send_and_await_response(test_timeout)?
|
||||||
@ -54,18 +54,18 @@ fn handle_message(our: &Address) -> anyhow::Result<()> {
|
|||||||
let kt::VfsResponse::ReadDir(children) =
|
let kt::VfsResponse::ReadDir(children) =
|
||||||
serde_json::from_slice(&vfs_ipc)?
|
serde_json::from_slice(&vfs_ipc)?
|
||||||
else {
|
else {
|
||||||
|
wit::print_to_terminal(
|
||||||
|
0,
|
||||||
|
&format!(
|
||||||
|
"{:?}",
|
||||||
|
serde_json::from_slice::<serde_json::Value>(&vfs_ipc)?,
|
||||||
|
),
|
||||||
|
);
|
||||||
panic!("")
|
panic!("")
|
||||||
};
|
};
|
||||||
let mut children: HashSet<_> = children.into_iter().collect();
|
|
||||||
children.remove("/manifest.json");
|
|
||||||
children.remove("/metadata.json");
|
|
||||||
children.remove("/tester.wasm");
|
|
||||||
children.remove("/test_runner.wasm");
|
|
||||||
|
|
||||||
wit::print_to_terminal(0, &format!("test_runner: running {:?}...", children));
|
wit::print_to_terminal(0, &format!("test_runner: running {:?}...", children));
|
||||||
|
|
||||||
// todo: are children returned as absolute paths.
|
|
||||||
|
|
||||||
for child in &children {
|
for child in &children {
|
||||||
let child_process_id = match spawn(
|
let child_process_id = match spawn(
|
||||||
None,
|
None,
|
||||||
|
@ -31,7 +31,6 @@ fn handle_message(
|
|||||||
_messages: &mut Messages,
|
_messages: &mut Messages,
|
||||||
node_names: &mut Vec<String>,
|
node_names: &mut Vec<String>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
println!("handle_message");
|
|
||||||
let Ok(message) = await_message() else {
|
let Ok(message) = await_message() else {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
@ -113,11 +112,20 @@ fn init(our: Address) {
|
|||||||
|
|
||||||
// orchestrate tests using external scripts
|
// orchestrate tests using external scripts
|
||||||
// -> must give drive cap to rpc
|
// -> must give drive cap to rpc
|
||||||
|
let _ = Request::new()
|
||||||
|
.target(make_vfs_address(&our).unwrap())
|
||||||
|
.ipc(serde_json::to_vec(&kt::VfsRequest {
|
||||||
|
path: "/tester:uqbar/tests".into(),
|
||||||
|
action: kt::VfsAction::CreateDrive,
|
||||||
|
}).unwrap())
|
||||||
|
.send_and_await_response(5)
|
||||||
|
.unwrap()
|
||||||
|
.unwrap();
|
||||||
let drive_cap = get_capability(
|
let drive_cap = get_capability(
|
||||||
&make_vfs_address(&our).unwrap(),
|
&make_vfs_address(&our).unwrap(),
|
||||||
&serde_json::to_string(&serde_json::json!({
|
&serde_json::to_string(&serde_json::json!({
|
||||||
"kind": "write",
|
"kind": "write",
|
||||||
"drive": "/tester:uqbar/pkg",
|
"drive": "/tester:uqbar/tests",
|
||||||
}))
|
}))
|
||||||
.expect("couldn't serialize"),
|
.expect("couldn't serialize"),
|
||||||
)
|
)
|
||||||
|
@ -886,6 +886,7 @@ pub async fn kernel(
|
|||||||
// kernel and filesystem can ALWAYS message any local process
|
// kernel and filesystem can ALWAYS message any local process
|
||||||
if kernel_message.source.process != *KERNEL_PROCESS_ID
|
if kernel_message.source.process != *KERNEL_PROCESS_ID
|
||||||
&& kernel_message.source.process != *STATE_PROCESS_ID
|
&& kernel_message.source.process != *STATE_PROCESS_ID
|
||||||
|
&& kernel_message.source.process != *VFS_PROCESS_ID
|
||||||
{
|
{
|
||||||
let Some(persisted_source) = process_map.get(&kernel_message.source.process) else {
|
let Some(persisted_source) = process_map.get(&kernel_message.source.process) else {
|
||||||
continue
|
continue
|
||||||
|
@ -185,18 +185,6 @@ impl StandardHost for process::ProcessWasi {
|
|||||||
node: self.process.metadata.our.node.clone(),
|
node: self.process.metadata.our.node.clone(),
|
||||||
process: VFS_PROCESS_ID.en_wit(),
|
process: VFS_PROCESS_ID.en_wit(),
|
||||||
};
|
};
|
||||||
// TODO: note, drive could just be your basic process maybe.
|
|
||||||
let path = format!(
|
|
||||||
"/{}/{}/{}",
|
|
||||||
self.process.metadata.our.process.to_string(),
|
|
||||||
self.process.metadata.our.process.package(),
|
|
||||||
wasm_path
|
|
||||||
);
|
|
||||||
// let our_drive_name = [
|
|
||||||
// self.process.metadata.our.process.package(),
|
|
||||||
// self.process.metadata.our.process.publisher(),
|
|
||||||
// ]
|
|
||||||
// .join(":");
|
|
||||||
let Ok(Ok((_, hash_response))) = process::send_and_await_response(
|
let Ok(Ok((_, hash_response))) = process::send_and_await_response(
|
||||||
self,
|
self,
|
||||||
None,
|
None,
|
||||||
@ -205,7 +193,7 @@ impl StandardHost for process::ProcessWasi {
|
|||||||
inherit: false,
|
inherit: false,
|
||||||
expects_response: Some(5),
|
expects_response: Some(5),
|
||||||
ipc: serde_json::to_vec(&t::VfsRequest {
|
ipc: serde_json::to_vec(&t::VfsRequest {
|
||||||
path: path.clone(),
|
path: wasm_path.clone(),
|
||||||
action: t::VfsAction::Read,
|
action: t::VfsAction::Read,
|
||||||
})
|
})
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
@ -260,7 +248,7 @@ impl StandardHost for process::ProcessWasi {
|
|||||||
expects_response: Some(5), // TODO evaluate
|
expects_response: Some(5), // TODO evaluate
|
||||||
ipc: serde_json::to_vec(&t::KernelCommand::InitializeProcess {
|
ipc: serde_json::to_vec(&t::KernelCommand::InitializeProcess {
|
||||||
id: new_process_id.clone(),
|
id: new_process_id.clone(),
|
||||||
wasm_bytes_handle: path,
|
wasm_bytes_handle: wasm_path,
|
||||||
on_exit: t::OnExit::de_wit(on_exit),
|
on_exit: t::OnExit::de_wit(on_exit),
|
||||||
initial_capabilities: match capabilities {
|
initial_capabilities: match capabilities {
|
||||||
wit::Capabilities::None => HashSet::new(),
|
wit::Capabilities::None => HashSet::new(),
|
||||||
|
Loading…
Reference in New Issue
Block a user