mirror of
https://github.com/uqbar-dao/nectar.git
synced 2025-01-08 18:52:49 +03:00
WIP: sys:nectar -> distro:sys, userspace modules to sys for publisher
This commit is contained in:
parent
94bac2de4b
commit
693d75d9e2
50
README.md
50
README.md
@ -38,8 +38,38 @@ cargo +nightly run --release -- home --rpc wss://eth-sepolia.g.alchemy.com/v2/<y
|
|||||||
|
|
||||||
On boot you will be prompted to navigate to `localhost:8080`. Make sure your ETH wallet is connected to the Sepolia test network. Login should be straightforward, just submit the transactions and follow the flow. If you want to register a new ID you will either need [Sepolia testnet tokens](https://www.infura.io/faucet/sepolia) or an invite code.
|
On boot you will be prompted to navigate to `localhost:8080`. Make sure your ETH wallet is connected to the Sepolia test network. Login should be straightforward, just submit the transactions and follow the flow. If you want to register a new ID you will either need [Sepolia testnet tokens](https://www.infura.io/faucet/sepolia) or an invite code.
|
||||||
|
|
||||||
|
### Distro and Runtime processes
|
||||||
|
|
||||||
## Terminal syntax
|
The base OS install comes with certain runtime modules. These are interacted with in the same way as userspace processes, but are deeply ingrained to the system and the APIs they present at their Process IDs are assumed to be available by userspace processes. All of these are identified in the `distro:sys` package.
|
||||||
|
|
||||||
|
This distribution of the OS also comes with userspace packages pre-installed. Some of these packages are intimately tied to the runtime: `terminal`, `homepage`, and `ndns_indexer`. Modifying, removing or replacing the distro userspace packages should only be done in highly specialized use-cases.
|
||||||
|
|
||||||
|
The runtime distro processes are:
|
||||||
|
|
||||||
|
- `eth:distro:sys`
|
||||||
|
- `http_client:distro:sys`
|
||||||
|
- `http_server:distro:sys`
|
||||||
|
- `kernel:distro:sys`
|
||||||
|
- `kv:distro:sys`
|
||||||
|
- `net:distro:sys`
|
||||||
|
- `state:distro:sys`
|
||||||
|
- `terminal:distro:sys`
|
||||||
|
- `timer:distro:sys`
|
||||||
|
- `sqlite:distro:sys`
|
||||||
|
- `vfs:distro:sys`
|
||||||
|
|
||||||
|
The distro userspace packages are:
|
||||||
|
|
||||||
|
- `app_store:sys`
|
||||||
|
- `chess:sys`
|
||||||
|
- `homepage:sys`
|
||||||
|
- `ndns_indexer:sys`
|
||||||
|
- `terminal:sys`
|
||||||
|
- `tester:sys` (only installed in if compiled with feature flag `simulation-mode`)
|
||||||
|
|
||||||
|
The `sys` publisher is not a real node ID, but it's also not a special case value. Packages, whether runtime or userspace, installed from disk when a node bootstraps do not have their package ID or publisher node ID validated. Packages installed (not injected locally, as is done during development) after a node has booted will have their publisher field validated.
|
||||||
|
|
||||||
|
### Terminal syntax
|
||||||
|
|
||||||
- CTRL+C or CTRL+D to gracefully shutdown node
|
- CTRL+C or CTRL+D to gracefully shutdown node
|
||||||
- CTRL+V to toggle through verbose modes (0-3, 0 is default and lowest verbosity)
|
- CTRL+V to toggle through verbose modes (0-3, 0 is default and lowest verbosity)
|
||||||
@ -55,27 +85,27 @@ On boot you will be prompted to navigate to `localhost:8080`. Make sure your ETH
|
|||||||
- CTRL+R to search history, CTRL+R again to toggle through search results, CTRL+G to cancel search
|
- CTRL+R to search history, CTRL+R again to toggle through search results, CTRL+G to cancel search
|
||||||
|
|
||||||
- `/message <address> <json>`: send an inter-process message. <address> is formatted as <node>@<process_id>. <process_id> is formatted as <process_name>:<package_name>:<publisher_node>.
|
- `/message <address> <json>`: send an inter-process message. <address> is formatted as <node>@<process_id>. <process_id> is formatted as <process_name>:<package_name>:<publisher_node>.
|
||||||
- Example: `/message our@net:sys:nectar diagnostics`
|
- Example: `/message our@net:distro:sys diagnostics`
|
||||||
- `our` will always be interpolated by the system as your node's name
|
- `our` will always be interpolated by the system as your node's name
|
||||||
- Can also use `/m` for same command: `/m our@net:sys:nectar diagnostics`
|
- Can also use `/m` for same command: `/m our@net:distro:sys diagnostics`
|
||||||
- `/app <address>`: set the terminal to a mode where all messages go to a specific app. To clear this selection, use `/app clear` or simply `/app`. This is useful for apps that have a command line interface.
|
- `/app <address>`: set the terminal to a mode where all messages go to a specific app. To clear this selection, use `/app clear` or simply `/app`. This is useful for apps that have a command line interface.
|
||||||
- Example: `/app our@net:sys:nectar`, then `/m diagnostics`
|
- Example: `/app our@net:distro:sys`, then `/m diagnostics`
|
||||||
- Can also use `/a` for same command: `/a our@net:sys:nectar`
|
- Can also use `/a` for same command: `/a our@net:distro:sys`
|
||||||
- Example of sending many messages:
|
- Example of sending many messages:
|
||||||
- `/a ben.os@net:sys:nectar`
|
- `/a ben.os@net:distro:sys`
|
||||||
- `/m hey there`
|
- `/m hey there`
|
||||||
- `/m how are you?`
|
- `/m how are you?`
|
||||||
- `/a` (to exit app mode)
|
- `/a` (to exit app mode)
|
||||||
- `/hi <name> <string>`: send a text message to another node's command line.
|
- `/hi <name> <string>`: send a text message to another node's command line.
|
||||||
- Example: `/hi ben.os hello world`
|
- Example: `/hi ben.os hello world`
|
||||||
- `/top <process_id>`: display kernel debugging info about a process. Leave the process ID blank to display info about all processes and get the total number of running processes.
|
- `/top <process_id>`: display kernel debugging info about a process. Leave the process ID blank to display info about all processes and get the total number of running processes.
|
||||||
- Example: `/top net:sys:nectar`
|
- Example: `/top net:distro:sys`
|
||||||
- Example: `/top`
|
- Example: `/top`
|
||||||
|
|
||||||
## Example usage
|
### Terminal example usage
|
||||||
|
|
||||||
Download and install an app:
|
Download and install an app:
|
||||||
```
|
```
|
||||||
/m our@main:app_store:nectar {"Download": {"package": {"package_name": "<pkg>", "publisher_node": "<node>"}, "install_from": "<node>"}}
|
/m our@main:app_store:sys {"Download": {"package": {"package_name": "<pkg>", "publisher_node": "<node>"}, "install_from": "<node>"}}
|
||||||
/m our@main:app_store:nectar {"Install": {"package_name": "<pkg>", "publisher_node": "<node>"}}
|
/m our@main:app_store:sys {"Install": {"package_name": "<pkg>", "publisher_node": "<node>"}}
|
||||||
```
|
```
|
||||||
|
@ -178,7 +178,7 @@ struct ManifestCap {
|
|||||||
|
|
||||||
call_init!(init);
|
call_init!(init);
|
||||||
fn init(our: Address) {
|
fn init(our: Address) {
|
||||||
println!("{}: running", our.process);
|
println!("{}: started", our.package());
|
||||||
|
|
||||||
// load in our saved state or initalize a new one if none exists
|
// load in our saved state or initalize a new one if none exists
|
||||||
let mut state = get_typed_state(|bytes| Ok(bincode::deserialize(bytes)?)).unwrap_or(State {
|
let mut state = get_typed_state(|bytes| Ok(bincode::deserialize(bytes)?)).unwrap_or(State {
|
||||||
@ -346,7 +346,7 @@ fn handle_new_package(
|
|||||||
|
|
||||||
// create a new drive for this package in VFS
|
// create a new drive for this package in VFS
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "vfs", "sys", "nectar"))
|
.target(("our", "vfs", "distro", "sys"))
|
||||||
.body(serde_json::to_vec(&vfs::VfsRequest {
|
.body(serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: drive.clone(),
|
path: drive.clone(),
|
||||||
action: vfs::VfsAction::CreateDrive,
|
action: vfs::VfsAction::CreateDrive,
|
||||||
@ -361,7 +361,7 @@ fn handle_new_package(
|
|||||||
// add zip bytes
|
// add zip bytes
|
||||||
blob.mime = Some("application/zip".to_string());
|
blob.mime = Some("application/zip".to_string());
|
||||||
let response = Request::new()
|
let response = Request::new()
|
||||||
.target(("our", "vfs", "sys", "nectar"))
|
.target(("our", "vfs", "distro", "sys"))
|
||||||
.body(serde_json::to_vec(&vfs::VfsRequest {
|
.body(serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: drive.clone(),
|
path: drive.clone(),
|
||||||
action: vfs::VfsAction::AddZip,
|
action: vfs::VfsAction::AddZip,
|
||||||
@ -379,7 +379,7 @@ fn handle_new_package(
|
|||||||
// call it <package>.zip
|
// call it <package>.zip
|
||||||
let zip_path = format!("{}/{}.zip", drive.clone(), package);
|
let zip_path = format!("{}/{}.zip", drive.clone(), package);
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "vfs", "sys", "nectar"))
|
.target(("our", "vfs", "distro", "sys"))
|
||||||
.inherit(true)
|
.inherit(true)
|
||||||
.body(serde_json::to_vec(&vfs::VfsRequest {
|
.body(serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: zip_path,
|
path: zip_path,
|
||||||
@ -392,7 +392,7 @@ fn handle_new_package(
|
|||||||
// now, read the pkg contents to create our own listing and state,
|
// now, read the pkg contents to create our own listing and state,
|
||||||
// such that we can mirror this package to others.
|
// such that we can mirror this package to others.
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "vfs", "sys", "nectar"))
|
.target(("our", "vfs", "distro", "sys"))
|
||||||
.body(serde_json::to_vec(&vfs::VfsRequest {
|
.body(serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: metadata_path,
|
path: metadata_path,
|
||||||
action: vfs::VfsAction::Read,
|
action: vfs::VfsAction::Read,
|
||||||
@ -427,7 +427,7 @@ fn handle_new_package(
|
|||||||
fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
||||||
let drive_path = format!("/{}/pkg", package);
|
let drive_path = format!("/{}/pkg", package);
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "vfs", "sys", "nectar"))
|
.target(("our", "vfs", "distro", "sys"))
|
||||||
.body(serde_json::to_vec(&vfs::VfsRequest {
|
.body(serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: format!("{}/manifest.json", drive_path),
|
path: format!("{}/manifest.json", drive_path),
|
||||||
action: vfs::VfsAction::Read,
|
action: vfs::VfsAction::Read,
|
||||||
@ -440,7 +440,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
|||||||
let manifest = serde_json::from_str::<Vec<kt::PackageManifestEntry>>(&manifest)?;
|
let manifest = serde_json::from_str::<Vec<kt::PackageManifestEntry>>(&manifest)?;
|
||||||
// always grant read/write to their drive, which we created for them
|
// always grant read/write to their drive, which we created for them
|
||||||
let Some(read_cap) = get_capability(
|
let Some(read_cap) = get_capability(
|
||||||
&Address::new(&our.node, ("vfs", "sys", "nectar")),
|
&Address::new(&our.node, ("vfs", "distro", "sys")),
|
||||||
&serde_json::to_string(&serde_json::json!({
|
&serde_json::to_string(&serde_json::json!({
|
||||||
"kind": "read",
|
"kind": "read",
|
||||||
"drive": drive_path,
|
"drive": drive_path,
|
||||||
@ -449,7 +449,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
|||||||
return Err(anyhow::anyhow!("app store: no read cap"));
|
return Err(anyhow::anyhow!("app store: no read cap"));
|
||||||
};
|
};
|
||||||
let Some(write_cap) = get_capability(
|
let Some(write_cap) = get_capability(
|
||||||
&Address::new(&our.node, ("vfs", "sys", "nectar")),
|
&Address::new(&our.node, ("vfs", "distro", "sys")),
|
||||||
&serde_json::to_string(&serde_json::json!({
|
&serde_json::to_string(&serde_json::json!({
|
||||||
"kind": "write",
|
"kind": "write",
|
||||||
"drive": drive_path,
|
"drive": drive_path,
|
||||||
@ -458,7 +458,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
|||||||
return Err(anyhow::anyhow!("app store: no write cap"));
|
return Err(anyhow::anyhow!("app store: no write cap"));
|
||||||
};
|
};
|
||||||
let Some(networking_cap) = get_capability(
|
let Some(networking_cap) = get_capability(
|
||||||
&Address::new(&our.node, ("kernel", "sys", "nectar")),
|
&Address::new(&our.node, ("kernel", "distro", "sys")),
|
||||||
&"\"network\"".to_string(),
|
&"\"network\"".to_string(),
|
||||||
) else {
|
) else {
|
||||||
return Err(anyhow::anyhow!("app store: no net cap"));
|
return Err(anyhow::anyhow!("app store: no net cap"));
|
||||||
@ -486,14 +486,14 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
|||||||
};
|
};
|
||||||
// kill process if it already exists
|
// kill process if it already exists
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "kernel", "sys", "nectar"))
|
.target(("our", "kernel", "distro", "sys"))
|
||||||
.body(serde_json::to_vec(&kt::KernelCommand::KillProcess(
|
.body(serde_json::to_vec(&kt::KernelCommand::KillProcess(
|
||||||
parsed_new_process_id.clone(),
|
parsed_new_process_id.clone(),
|
||||||
))?)
|
))?)
|
||||||
.send()?;
|
.send()?;
|
||||||
|
|
||||||
let _bytes_response = Request::new()
|
let _bytes_response = Request::new()
|
||||||
.target(("our", "vfs", "sys", "nectar"))
|
.target(("our", "vfs", "distro", "sys"))
|
||||||
.body(serde_json::to_vec(&vfs::VfsRequest {
|
.body(serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: wasm_path.clone(),
|
path: wasm_path.clone(),
|
||||||
action: vfs::VfsAction::Read,
|
action: vfs::VfsAction::Read,
|
||||||
@ -556,7 +556,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "kernel", "sys", "nectar"))
|
.target(("our", "kernel", "distro", "sys"))
|
||||||
.body(serde_json::to_vec(&kt::KernelCommand::InitializeProcess {
|
.body(serde_json::to_vec(&kt::KernelCommand::InitializeProcess {
|
||||||
id: parsed_new_process_id.clone(),
|
id: parsed_new_process_id.clone(),
|
||||||
wasm_bytes_handle: wasm_path,
|
wasm_bytes_handle: wasm_path,
|
||||||
@ -573,7 +573,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
|||||||
serde_json::Value::String(process_name) => {
|
serde_json::Value::String(process_name) => {
|
||||||
if let Ok(parsed_process_id) = process_name.parse::<ProcessId>() {
|
if let Ok(parsed_process_id) = process_name.parse::<ProcessId>() {
|
||||||
let _ = Request::new()
|
let _ = Request::new()
|
||||||
.target(("our", "kernel", "sys", "nectar"))
|
.target(("our", "kernel", "distro", "sys"))
|
||||||
.body(
|
.body(
|
||||||
serde_json::to_vec(&kt::KernelCommand::GrantCapabilities {
|
serde_json::to_vec(&kt::KernelCommand::GrantCapabilities {
|
||||||
target: parsed_process_id,
|
target: parsed_process_id,
|
||||||
@ -599,7 +599,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
|||||||
{
|
{
|
||||||
if let Some(params) = map.get("params") {
|
if let Some(params) = map.get("params") {
|
||||||
let _ = Request::new()
|
let _ = Request::new()
|
||||||
.target(("our", "kernel", "sys", "nectar"))
|
.target(("our", "kernel", "distro", "sys"))
|
||||||
.body(
|
.body(
|
||||||
serde_json::to_vec(
|
serde_json::to_vec(
|
||||||
&kt::KernelCommand::GrantCapabilities {
|
&kt::KernelCommand::GrantCapabilities {
|
||||||
@ -627,7 +627,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "kernel", "sys", "nectar"))
|
.target(("our", "kernel", "distro", "sys"))
|
||||||
.body(serde_json::to_vec(&kt::KernelCommand::RunProcess(
|
.body(serde_json::to_vec(&kt::KernelCommand::RunProcess(
|
||||||
parsed_new_process_id,
|
parsed_new_process_id,
|
||||||
))?)
|
))?)
|
||||||
@ -639,7 +639,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
|||||||
fn handle_uninstall(package: &PackageId) -> anyhow::Result<()> {
|
fn handle_uninstall(package: &PackageId) -> anyhow::Result<()> {
|
||||||
let drive_path = format!("/{}/pkg", package);
|
let drive_path = format!("/{}/pkg", package);
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "vfs", "sys", "nectar"))
|
.target(("our", "vfs", "distro", "sys"))
|
||||||
.body(serde_json::to_vec(&vfs::VfsRequest {
|
.body(serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: format!("{}/manifest.json", drive_path),
|
path: format!("{}/manifest.json", drive_path),
|
||||||
action: vfs::VfsAction::Read,
|
action: vfs::VfsAction::Read,
|
||||||
@ -657,7 +657,7 @@ fn handle_uninstall(package: &PackageId) -> anyhow::Result<()> {
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "kernel", "sys", "nectar"))
|
.target(("our", "kernel", "distro", "sys"))
|
||||||
.body(serde_json::to_vec(&kt::KernelCommand::KillProcess(
|
.body(serde_json::to_vec(&kt::KernelCommand::KillProcess(
|
||||||
parsed_new_process_id,
|
parsed_new_process_id,
|
||||||
))?)
|
))?)
|
||||||
@ -665,7 +665,7 @@ fn handle_uninstall(package: &PackageId) -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
// then, delete the drive
|
// then, delete the drive
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "vfs", "sys", "nectar"))
|
.target(("our", "vfs", "distro", "sys"))
|
||||||
.body(serde_json::to_vec(&vfs::VfsRequest {
|
.body(serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: drive_path,
|
path: drive_path,
|
||||||
action: vfs::VfsAction::RemoveDirAll,
|
action: vfs::VfsAction::RemoveDirAll,
|
||||||
@ -691,7 +691,7 @@ fn handle_remote_request(
|
|||||||
// get the .zip from VFS and attach as blob to response
|
// get the .zip from VFS and attach as blob to response
|
||||||
let file_path = format!("/{}/pkg/{}.zip", package, package);
|
let file_path = format!("/{}/pkg/{}.zip", package, package);
|
||||||
let Ok(Ok(_)) = Request::new()
|
let Ok(Ok(_)) = Request::new()
|
||||||
.target(("our", "vfs", "sys", "nectar"))
|
.target(("our", "vfs", "distro", "sys"))
|
||||||
.body(
|
.body(
|
||||||
serde_json::to_vec(&vfs::VfsRequest {
|
serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: file_path,
|
path: file_path,
|
||||||
|
@ -5,25 +5,25 @@
|
|||||||
"on_exit": "Restart",
|
"on_exit": "Restart",
|
||||||
"request_networking": true,
|
"request_networking": true,
|
||||||
"request_capabilities": [
|
"request_capabilities": [
|
||||||
"terminal:terminal:nectar",
|
"terminal:terminal:sys",
|
||||||
"filesystem:sys:nectar",
|
"filesystem:distro:sys",
|
||||||
"http_server:sys:nectar",
|
"http_server:distro:sys",
|
||||||
"http_client:sys:nectar",
|
"http_client:distro:sys",
|
||||||
"net:sys:nectar",
|
"net:distro:sys",
|
||||||
"vfs:sys:nectar",
|
"vfs:distro:sys",
|
||||||
"kernel:sys:nectar",
|
"kernel:distro:sys",
|
||||||
"eth:sys:nectar",
|
"eth:distro:sys",
|
||||||
{
|
{
|
||||||
"process": "vfs:sys:nectar",
|
"process": "vfs:distro:sys",
|
||||||
"params": {
|
"params": {
|
||||||
"root": true
|
"root": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"grant_capabilities": [
|
"grant_capabilities": [
|
||||||
"http_server:sys:nectar",
|
"http_server:distro:sys",
|
||||||
"terminal:terminal:nectar",
|
"terminal:terminal:sys",
|
||||||
"vfs:sys:nectar"
|
"vfs:distro:sys"
|
||||||
],
|
],
|
||||||
"public": false
|
"public": false
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"package": "app_store",
|
"package": "app_store",
|
||||||
"publisher": "nectar",
|
"publisher": "sys",
|
||||||
"version": [
|
"version": [
|
||||||
0,
|
0,
|
||||||
2,
|
2,
|
||||||
|
@ -73,7 +73,7 @@ fn load_chess_state() -> ChessState {
|
|||||||
fn send_ws_update(our: &Address, game: &Game, open_channels: &HashSet<u32>) -> anyhow::Result<()> {
|
fn send_ws_update(our: &Address, game: &Game, open_channels: &HashSet<u32>) -> anyhow::Result<()> {
|
||||||
for channel in open_channels {
|
for channel in open_channels {
|
||||||
Request::new()
|
Request::new()
|
||||||
.target((&our.node, "http_server", "sys", "nectar"))
|
.target((&our.node, "http_server", "distro", "sys"))
|
||||||
.body(serde_json::to_vec(
|
.body(serde_json::to_vec(
|
||||||
&http::HttpServerAction::WebSocketPush {
|
&http::HttpServerAction::WebSocketPush {
|
||||||
channel_id: *channel,
|
channel_id: *channel,
|
||||||
@ -108,7 +108,7 @@ call_init!(initialize);
|
|||||||
|
|
||||||
fn initialize(our: Address) {
|
fn initialize(our: Address) {
|
||||||
// A little printout to show in terminal that the process has started.
|
// A little printout to show in terminal that the process has started.
|
||||||
println!("{} by {}: start", our.process(), our.publisher());
|
println!("{}: started", our.package());
|
||||||
|
|
||||||
// Serve the index.html and other UI files found in pkg/ui at the root path.
|
// Serve the index.html and other UI files found in pkg/ui at the root path.
|
||||||
http::serve_ui(&our, "ui").unwrap();
|
http::serve_ui(&our, "ui").unwrap();
|
||||||
@ -168,14 +168,14 @@ fn handle_request(our: &Address, message: &Message, state: &mut ChessState) -> a
|
|||||||
// Note that since this is a local request, we *can* trust the ProcessId.
|
// Note that since this is a local request, we *can* trust the ProcessId.
|
||||||
// Here, we'll accept messages from the local terminal so as to make this a "CLI" app.
|
// Here, we'll accept messages from the local terminal so as to make this a "CLI" app.
|
||||||
} else if message.source().node == our.node
|
} else if message.source().node == our.node
|
||||||
&& message.source().process == "terminal:terminal:nectar"
|
&& message.source().process == "terminal:terminal:sys"
|
||||||
{
|
{
|
||||||
let Ok(chess_request) = serde_json::from_slice::<ChessRequest>(message.body()) else {
|
let Ok(chess_request) = serde_json::from_slice::<ChessRequest>(message.body()) else {
|
||||||
return Err(anyhow::anyhow!("invalid chess request"));
|
return Err(anyhow::anyhow!("invalid chess request"));
|
||||||
};
|
};
|
||||||
handle_local_request(our, state, &chess_request)
|
handle_local_request(our, state, &chess_request)
|
||||||
} else if message.source().node == our.node
|
} else if message.source().node == our.node
|
||||||
&& message.source().process == "http_server:sys:nectar"
|
&& message.source().process == "http_server:distro:sys"
|
||||||
{
|
{
|
||||||
// receive HTTP requests and websocket connection messages from our server
|
// receive HTTP requests and websocket connection messages from our server
|
||||||
match serde_json::from_slice::<http::HttpServerRequest>(message.body())? {
|
match serde_json::from_slice::<http::HttpServerRequest>(message.body())? {
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
"on_exit": "Restart",
|
"on_exit": "Restart",
|
||||||
"request_networking": true,
|
"request_networking": true,
|
||||||
"request_capabilities": [
|
"request_capabilities": [
|
||||||
"http_server:sys:nectar",
|
"http_server:distro:sys",
|
||||||
"net:sys:nectar",
|
"net:distro:sys",
|
||||||
"vfs:sys:nectar"
|
"vfs:distro:sys"
|
||||||
],
|
],
|
||||||
"grant_capabilities": [
|
"grant_capabilities": [
|
||||||
"http_server:sys:nectar"
|
"http_server:distro:sys"
|
||||||
],
|
],
|
||||||
"public": true
|
"public": true
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"package": "chess",
|
"package": "chess",
|
||||||
"publisher": "nectar",
|
"publisher": "sys",
|
||||||
"version": [
|
"version": [
|
||||||
0,
|
0,
|
||||||
2,
|
2,
|
||||||
|
@ -65,7 +65,7 @@ fn main(our: Address) -> anyhow::Result<()> {
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
if let Message::Response { source, body, .. } = message
|
if let Message::Response { source, body, .. } = message
|
||||||
&& source.process == "http_server:sys:nectar"
|
&& source.process == "http_server:distro:sys"
|
||||||
{
|
{
|
||||||
match serde_json::from_slice::<Result<(), HttpServerError>>(&body) {
|
match serde_json::from_slice::<Result<(), HttpServerError>>(&body) {
|
||||||
Ok(Ok(())) => continue,
|
Ok(Ok(())) => continue,
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
"on_exit": "Restart",
|
"on_exit": "Restart",
|
||||||
"request_networking": false,
|
"request_networking": false,
|
||||||
"request_capabilities": [
|
"request_capabilities": [
|
||||||
"http_server:sys:nectar"
|
"http_server:distro:sys"
|
||||||
],
|
],
|
||||||
"grant_capabilities": [
|
"grant_capabilities": [
|
||||||
"http_server:sys:nectar"
|
"http_server:distro:sys"
|
||||||
],
|
],
|
||||||
"public": false
|
"public": false
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"package": "homepage",
|
"package": "homepage",
|
||||||
"publisher": "nectar",
|
"publisher": "sys",
|
||||||
"version": [
|
"version": [
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
|
@ -114,7 +114,7 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> {
|
|||||||
let Ok(Message::Request { source, body, .. }) = await_message() else {
|
let Ok(Message::Request { source, body, .. }) = await_message() else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
if source.process != "kernel:sys:nectar" {
|
if source.process != "kernel:distro:sys" {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
contract_address = Some(std::str::from_utf8(&body).unwrap().to_string());
|
contract_address = Some(std::str::from_utf8(&body).unwrap().to_string());
|
||||||
@ -135,7 +135,7 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
// shove all state into net::net
|
// shove all state into net::net
|
||||||
Request::new()
|
Request::new()
|
||||||
.target((&our.node, "net", "sys", "nectar"))
|
.target((&our.node, "net", "distro", "sys"))
|
||||||
.try_body(NetActions::NdnsBatchUpdate(
|
.try_body(NetActions::NdnsBatchUpdate(
|
||||||
state.nodes.values().cloned().collect::<Vec<_>>(),
|
state.nodes.values().cloned().collect::<Vec<_>>(),
|
||||||
))?
|
))?
|
||||||
@ -166,7 +166,7 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> {
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
if source.process == "http_server:sys:nectar" {
|
if source.process == "http_server:distro:sys" {
|
||||||
if let Ok(body_json) = serde_json::from_slice::<serde_json::Value>(&body) {
|
if let Ok(body_json) = serde_json::from_slice::<serde_json::Value>(&body) {
|
||||||
if body_json["path"].as_str().unwrap_or_default() == "/node/:name" {
|
if body_json["path"].as_str().unwrap_or_default() == "/node/:name" {
|
||||||
if let Some(name) = body_json["url_params"]["name"].as_str() {
|
if let Some(name) = body_json["url_params"]["name"].as_str() {
|
||||||
@ -279,7 +279,7 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
Request::new()
|
Request::new()
|
||||||
.target((&our.node, "net", "sys", "nectar"))
|
.target((&our.node, "net", "distro", "sys"))
|
||||||
.try_body(NetActions::NdnsUpdate(node.clone()))?
|
.try_body(NetActions::NdnsUpdate(node.clone()))?
|
||||||
.send()?;
|
.send()?;
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
"on_exit": "Restart",
|
"on_exit": "Restart",
|
||||||
"request_networking": false,
|
"request_networking": false,
|
||||||
"request_capabilities": [
|
"request_capabilities": [
|
||||||
"eth:sys:nectar",
|
"eth:distro:sys",
|
||||||
"http_server:sys:nectar",
|
"http_server:distro:sys",
|
||||||
"net:sys:nectar"
|
"net:distro:sys"
|
||||||
],
|
],
|
||||||
"grant_capabilities": [
|
"grant_capabilities": [
|
||||||
"eth:sys:nectar",
|
"eth:distro:sys",
|
||||||
"http_server:sys:nectar"
|
"http_server:distro:sys"
|
||||||
],
|
],
|
||||||
"public": false
|
"public": false
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"package": "ndns_indexer",
|
"package": "ndns_indexer",
|
||||||
"publisher": "nectar",
|
"publisher": "sys",
|
||||||
"version": [
|
"version": [
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
"on_exit": "Restart",
|
"on_exit": "Restart",
|
||||||
"request_networking": true,
|
"request_networking": true,
|
||||||
"request_capabilities": [
|
"request_capabilities": [
|
||||||
"net:sys:nectar",
|
"net:distro:sys",
|
||||||
"http_client:sys:nectar",
|
"http_client:distro:sys",
|
||||||
"kernel:sys:nectar"
|
"kernel:distro:sys"
|
||||||
],
|
],
|
||||||
"public": true
|
"public": true
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"package": "terminal",
|
"package": "terminal",
|
||||||
"publisher": "nectar",
|
"publisher": "sys",
|
||||||
"version": [
|
"version": [
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
|
@ -36,7 +36,7 @@ fn parse_command(state: &mut TerminalState, line: &str) -> anyhow::Result<()> {
|
|||||||
node_id
|
node_id
|
||||||
};
|
};
|
||||||
Request::new()
|
Request::new()
|
||||||
.target((node_id, "net", "sys", "nectar"))
|
.target((node_id, "net", "distro", "sys"))
|
||||||
.body(message)
|
.body(message)
|
||||||
.expects_response(5)
|
.expects_response(5)
|
||||||
.send()?;
|
.send()?;
|
||||||
@ -75,7 +75,7 @@ fn parse_command(state: &mut TerminalState, line: &str) -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
// send a message to kernel asking it to print debugging information
|
// send a message to kernel asking it to print debugging information
|
||||||
"/top" | "/kernel_debug" => {
|
"/top" | "/kernel_debug" => {
|
||||||
let kernel_addr = Address::new("our", ("kernel", "sys", "nectar"));
|
let kernel_addr = Address::new("our", ("kernel", "distro", "sys"));
|
||||||
match tail {
|
match tail {
|
||||||
"" => Request::new()
|
"" => Request::new()
|
||||||
.target(kernel_addr)
|
.target(kernel_addr)
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
"on_exit": "Restart",
|
"on_exit": "Restart",
|
||||||
"request_networking": true,
|
"request_networking": true,
|
||||||
"request_capabilities": [
|
"request_capabilities": [
|
||||||
"net:sys:nectar",
|
"net:distro:sys",
|
||||||
"kernel:sys:nectar",
|
"kernel:distro:sys",
|
||||||
"http_server:sys:nectar",
|
"http_server:distro:sys",
|
||||||
"vfs:sys:nectar"
|
"vfs:distro:sys"
|
||||||
],
|
],
|
||||||
"grant_capabilities": [
|
"grant_capabilities": [
|
||||||
"vfs:sys:nectar"
|
"vfs:distro:sys"
|
||||||
],
|
],
|
||||||
"public": true
|
"public": true
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"package": "tester",
|
"package": "tester",
|
||||||
"publisher": "nectar",
|
"publisher": "sys",
|
||||||
"version": [
|
"version": [
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use nectar_process_lib::{
|
use nectar_process_lib::{
|
||||||
await_message, our_capabilities, println, spawn, vfs, Address, Message, OnExit, ProcessId, Request, Response,
|
await_message, our_capabilities, println, spawn, vfs, Address, Message, OnExit, ProcessId,
|
||||||
|
Request, Response,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod tester_types;
|
mod tester_types;
|
||||||
@ -18,7 +19,7 @@ wit_bindgen::generate!({
|
|||||||
fn make_vfs_address(our: &Address) -> anyhow::Result<Address> {
|
fn make_vfs_address(our: &Address) -> anyhow::Result<Address> {
|
||||||
Ok(Address::new(
|
Ok(Address::new(
|
||||||
our.node.clone(),
|
our.node.clone(),
|
||||||
ProcessId::from_str("vfs:sys:nectar")?,
|
ProcessId::from_str("vfs:distro:sys")?,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +38,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)?)
|
||||||
.body(serde_json::to_vec(&vfs::VfsRequest {
|
.body(serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: "/tester:nectar/tests".into(),
|
path: "/tester:sys/tests".into(),
|
||||||
action: vfs::VfsAction::ReadDir,
|
action: vfs::VfsAction::ReadDir,
|
||||||
})?)
|
})?)
|
||||||
.send_and_await_response(test_timeout)?
|
.send_and_await_response(test_timeout)?
|
||||||
@ -46,7 +47,8 @@ fn handle_message(our: &Address) -> anyhow::Result<()> {
|
|||||||
let Message::Response { body: vfs_body, .. } = response else {
|
let Message::Response { body: vfs_body, .. } = response else {
|
||||||
panic!("")
|
panic!("")
|
||||||
};
|
};
|
||||||
let vfs::VfsResponse::ReadDir(mut children) = serde_json::from_slice(&vfs_body)?
|
let vfs::VfsResponse::ReadDir(mut children) =
|
||||||
|
serde_json::from_slice(&vfs_body)?
|
||||||
else {
|
else {
|
||||||
println!(
|
println!(
|
||||||
"{:?}",
|
"{:?}",
|
||||||
@ -55,9 +57,10 @@ fn handle_message(our: &Address) -> anyhow::Result<()> {
|
|||||||
panic!("")
|
panic!("")
|
||||||
};
|
};
|
||||||
|
|
||||||
let caps_file_path = "tester:nectar/tests/grant_capabilities.json";
|
let caps_file_path = "tester:sys/tests/grant_capabilities.json";
|
||||||
let caps_index = children.iter().position(|i| *i.path == *caps_file_path);
|
let caps_index = children.iter().position(|i| *i.path == *caps_file_path);
|
||||||
let caps_by_child: std::collections::HashMap<String, Vec<String>> = match caps_index {
|
let caps_by_child: std::collections::HashMap<String, Vec<String>> =
|
||||||
|
match caps_index {
|
||||||
None => std::collections::HashMap::new(),
|
None => std::collections::HashMap::new(),
|
||||||
Some(caps_index) => {
|
Some(caps_index) => {
|
||||||
children.remove(caps_index);
|
children.remove(caps_index);
|
||||||
@ -70,14 +73,19 @@ fn handle_message(our: &Address) -> anyhow::Result<()> {
|
|||||||
println!("test_runner: running {:?}...", children);
|
println!("test_runner: running {:?}...", children);
|
||||||
|
|
||||||
for child in &children {
|
for child in &children {
|
||||||
let grant_caps = child.path
|
let grant_caps = child
|
||||||
|
.path
|
||||||
.split("/")
|
.split("/")
|
||||||
.last()
|
.last()
|
||||||
.and_then(|child_file_name| child_file_name.strip_suffix(".wasm"))
|
.and_then(|child_file_name| child_file_name.strip_suffix(".wasm"))
|
||||||
.and_then(|child_file_name| {
|
.and_then(|child_file_name| {
|
||||||
caps_by_child
|
caps_by_child.get(child_file_name).and_then(|caps| {
|
||||||
.get(child_file_name)
|
Some(
|
||||||
.and_then(|caps| Some(caps.iter().map(|cap| ProcessId::from_str(cap).unwrap()).collect()))
|
caps.iter()
|
||||||
|
.map(|cap| ProcessId::from_str(cap).unwrap())
|
||||||
|
.collect(),
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.unwrap_or(vec![]);
|
.unwrap_or(vec![]);
|
||||||
let child_process_id = match spawn(
|
let child_process_id = match spawn(
|
||||||
|
@ -2,8 +2,8 @@ use indexmap::map::IndexMap;
|
|||||||
|
|
||||||
use nectar_process_lib::kernel_types as kt;
|
use nectar_process_lib::kernel_types as kt;
|
||||||
use nectar_process_lib::{
|
use nectar_process_lib::{
|
||||||
await_message, call_init, our_capabilities, println, spawn, vfs, Address, Message,
|
await_message, call_init, our_capabilities, println, spawn, vfs, Address, Message, OnExit,
|
||||||
OnExit, ProcessId, Request, Response,
|
ProcessId, Request, Response,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod tester_types;
|
mod tester_types;
|
||||||
@ -22,7 +22,7 @@ type Messages = IndexMap<kt::Message, tt::KernelMessage>;
|
|||||||
fn make_vfs_address(our: &Address) -> anyhow::Result<Address> {
|
fn make_vfs_address(our: &Address) -> anyhow::Result<Address> {
|
||||||
Ok(Address {
|
Ok(Address {
|
||||||
node: our.node.clone(),
|
node: our.node.clone(),
|
||||||
process: "vfs:sys:nectar".parse()?,
|
process: "vfs:distro:sys".parse()?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ fn handle_message(
|
|||||||
match serde_json::from_slice(&body)? {
|
match serde_json::from_slice(&body)? {
|
||||||
tt::TesterResponse::Pass | tt::TesterResponse::Fail { .. } => {
|
tt::TesterResponse::Pass | tt::TesterResponse::Fail { .. } => {
|
||||||
if (source.process.package_name != "tester")
|
if (source.process.package_name != "tester")
|
||||||
| (source.process.publisher_node != "nectar")
|
| (source.process.publisher_node != "sys")
|
||||||
{
|
{
|
||||||
return Err(tt::TesterError::UnexpectedResponse.into());
|
return Err(tt::TesterError::UnexpectedResponse.into());
|
||||||
}
|
}
|
||||||
@ -70,13 +70,13 @@ fn handle_message(
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
} else {
|
} else {
|
||||||
// we are master node
|
// we are master node
|
||||||
let child = "/tester:nectar/pkg/test_runner.wasm";
|
let child = "/tester:sys/pkg/test_runner.wasm";
|
||||||
let child_process_id = match spawn(
|
let child_process_id = match spawn(
|
||||||
None,
|
None,
|
||||||
child,
|
child,
|
||||||
OnExit::None, // TODO: notify us
|
OnExit::None, // TODO: notify us
|
||||||
our_capabilities(),
|
our_capabilities(),
|
||||||
vec!["vfs:sys:nectar".parse::<ProcessId>().unwrap()],
|
vec!["vfs:distro:sys".parse::<ProcessId>().unwrap()],
|
||||||
false, // not public
|
false, // not public
|
||||||
) {
|
) {
|
||||||
Ok(child_process_id) => child_process_id,
|
Ok(child_process_id) => child_process_id,
|
||||||
@ -114,7 +114,7 @@ fn init(our: Address) {
|
|||||||
.target(make_vfs_address(&our).unwrap())
|
.target(make_vfs_address(&our).unwrap())
|
||||||
.body(
|
.body(
|
||||||
serde_json::to_vec(&vfs::VfsRequest {
|
serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: "/tester:nectar/tests".into(),
|
path: "/tester:sys/tests".into(),
|
||||||
action: vfs::VfsAction::CreateDrive,
|
action: vfs::VfsAction::CreateDrive,
|
||||||
})
|
})
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
@ -126,18 +126,18 @@ 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()
|
let _ = Request::new()
|
||||||
.target(("our", "kernel", "sys", "nectar"))
|
.target(("our", "kernel", "distro", "sys"))
|
||||||
.body(
|
.body(
|
||||||
serde_json::to_vec(&kt::KernelCommand::GrantCapabilities {
|
serde_json::to_vec(&kt::KernelCommand::GrantCapabilities {
|
||||||
target: ProcessId::new(Some("http_server"), "sys", "nectar"),
|
target: ProcessId::new(Some("http_server"), "distro", "sys"),
|
||||||
capabilities: vec![kt::Capability {
|
capabilities: vec![kt::Capability {
|
||||||
issuer: Address::new(
|
issuer: Address::new(
|
||||||
our.node.clone(),
|
our.node.clone(),
|
||||||
ProcessId::new(Some("vfs"), "sys", "nectar"),
|
ProcessId::new(Some("vfs"), "distro", "sys"),
|
||||||
),
|
),
|
||||||
params: serde_json::json!({
|
params: serde_json::json!({
|
||||||
"kind": "write",
|
"kind": "write",
|
||||||
"drive": "/tester:nectar/tests",
|
"drive": "/tester:sys/tests",
|
||||||
})
|
})
|
||||||
.to_string(),
|
.to_string(),
|
||||||
}],
|
}],
|
||||||
|
@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use tokio::task::JoinHandle;
|
use tokio::task::JoinHandle;
|
||||||
|
|
||||||
/// The Request type that can be made to eth:sys:nectar. Currently primitive, this
|
/// The Request type that can be made to eth:distro:sys. Currently primitive, this
|
||||||
/// enum will expand to support more actions in the future.
|
/// enum will expand to support more actions in the future.
|
||||||
///
|
///
|
||||||
/// Will be serialized and deserialized using `serde_json::to_vec` and `serde_json::from_slice`.
|
/// Will be serialized and deserialized using `serde_json::to_vec` and `serde_json::from_slice`.
|
||||||
|
@ -142,7 +142,7 @@ pub async fn http_client(
|
|||||||
id,
|
id,
|
||||||
source: Address {
|
source: Address {
|
||||||
node: our_name.to_string(),
|
node: our_name.to_string(),
|
||||||
process: ProcessId::new(Some("http_client"), "sys", "nectar"),
|
process: ProcessId::new(Some("http_client"), "distro", "sys"),
|
||||||
},
|
},
|
||||||
target: target.clone(),
|
target: target.clone(),
|
||||||
rsvp: None,
|
rsvp: None,
|
||||||
@ -419,7 +419,7 @@ async fn handle_http_request(
|
|||||||
id,
|
id,
|
||||||
source: Address {
|
source: Address {
|
||||||
node: our.to_string(),
|
node: our.to_string(),
|
||||||
process: ProcessId::new(Some("http_client"), "sys", "nectar"),
|
process: ProcessId::new(Some("http_client"), "distro", "sys"),
|
||||||
},
|
},
|
||||||
target,
|
target,
|
||||||
rsvp: None,
|
rsvp: None,
|
||||||
@ -520,7 +520,7 @@ async fn http_error_message(
|
|||||||
id,
|
id,
|
||||||
source: Address {
|
source: Address {
|
||||||
node: our.to_string(),
|
node: our.to_string(),
|
||||||
process: ProcessId::new(Some("http_client"), "sys", "nectar"),
|
process: ProcessId::new(Some("http_client"), "distro", "sys"),
|
||||||
},
|
},
|
||||||
target,
|
target,
|
||||||
rsvp: None,
|
rsvp: None,
|
||||||
@ -617,7 +617,7 @@ async fn handle_ws_message(
|
|||||||
id,
|
id,
|
||||||
source: Address {
|
source: Address {
|
||||||
node: our.to_string(),
|
node: our.to_string(),
|
||||||
process: ProcessId::new(Some("http_client"), "sys", "nectar"),
|
process: ProcessId::new(Some("http_client"), "distro", "sys"),
|
||||||
},
|
},
|
||||||
target,
|
target,
|
||||||
rsvp: None,
|
rsvp: None,
|
||||||
|
@ -6,7 +6,7 @@ use thiserror::Error;
|
|||||||
// TODO: add documentation similar to server_types
|
// TODO: add documentation similar to server_types
|
||||||
|
|
||||||
/// Request type that can be shared over WASM boundary to apps.
|
/// Request type that can be shared over WASM boundary to apps.
|
||||||
/// This is the one you send to the `http_client:sys:nectar` service.
|
/// This is the one you send to the `http_client:distro:sys` service.
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub enum HttpClientAction {
|
pub enum HttpClientAction {
|
||||||
Http(OutgoingHttpRequest),
|
Http(OutgoingHttpRequest),
|
||||||
@ -25,7 +25,7 @@ pub enum HttpClientAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// HTTP Request type that can be shared over WASM boundary to apps.
|
/// HTTP Request type that can be shared over WASM boundary to apps.
|
||||||
/// This is the one you send to the `http_client:sys:nectar` service.
|
/// This is the one you send to the `http_client:distro:sys` service.
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct OutgoingHttpRequest {
|
pub struct OutgoingHttpRequest {
|
||||||
pub method: String, // must parse to http::Method
|
pub method: String, // must parse to http::Method
|
||||||
@ -37,7 +37,7 @@ pub struct OutgoingHttpRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// WebSocket Client Request type that can be shared over WASM boundary to apps.
|
/// WebSocket Client Request type that can be shared over WASM boundary to apps.
|
||||||
/// This comes from an open websocket client connection in the `http_client:sys:nectar` service.
|
/// This comes from an open websocket client connection in the `http_client:distro:sys` service.
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub enum HttpClientRequest {
|
pub enum HttpClientRequest {
|
||||||
WebSocketPush {
|
WebSocketPush {
|
||||||
@ -50,7 +50,7 @@ pub enum HttpClientRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// HTTP Client Response type that can be shared over WASM boundary to apps.
|
/// HTTP Client Response type that can be shared over WASM boundary to apps.
|
||||||
/// This is the one you receive from the `http_client:sys:nectar` service.
|
/// This is the one you receive from the `http_client:distro:sys` service.
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub enum HttpClientResponse {
|
pub enum HttpClientResponse {
|
||||||
Http(HttpResponse),
|
Http(HttpResponse),
|
||||||
|
@ -86,13 +86,13 @@ pub async fn http_server(
|
|||||||
// add RPC path
|
// add RPC path
|
||||||
let mut bindings_map: Router<BoundPath> = Router::new();
|
let mut bindings_map: Router<BoundPath> = Router::new();
|
||||||
let rpc_bound_path = BoundPath {
|
let rpc_bound_path = BoundPath {
|
||||||
app: ProcessId::new(Some("rpc"), "sys", "nectar"),
|
app: ProcessId::new(Some("rpc"), "distro", "sys"),
|
||||||
secure_subdomain: None, // TODO maybe RPC should have subdomain?
|
secure_subdomain: None, // TODO maybe RPC should have subdomain?
|
||||||
authenticated: false,
|
authenticated: false,
|
||||||
local_only: true,
|
local_only: true,
|
||||||
static_content: None,
|
static_content: None,
|
||||||
};
|
};
|
||||||
bindings_map.add("/rpc:sys:nectar/message", rpc_bound_path);
|
bindings_map.add("/rpc:distro:sys/message", rpc_bound_path);
|
||||||
let path_bindings: PathBindings = Arc::new(RwLock::new(bindings_map));
|
let path_bindings: PathBindings = Arc::new(RwLock::new(bindings_map));
|
||||||
|
|
||||||
// ws path bindings
|
// ws path bindings
|
||||||
@ -454,10 +454,10 @@ async fn http_handler(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RPC functionality: if path is /rpc:sys:nectar/message,
|
// RPC functionality: if path is /rpc:distro:sys/message,
|
||||||
// we extract message from base64 encoded bytes in data
|
// we extract message from base64 encoded bytes in data
|
||||||
// and send it to the correct app.
|
// and send it to the correct app.
|
||||||
let message = if bound_path.app == "rpc:sys:nectar" {
|
let message = if bound_path.app == "rpc:distro:sys" {
|
||||||
match handle_rpc_message(our, id, body, print_tx).await {
|
match handle_rpc_message(our, id, body, print_tx).await {
|
||||||
Ok(message) => message,
|
Ok(message) => message,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@ -794,7 +794,7 @@ async fn handle_app_message(
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
// if path is /rpc/message, return accordingly with base64 encoded blob
|
// if path is /rpc/message, return accordingly with base64 encoded blob
|
||||||
if path == "/rpc:sys:nectar/message" {
|
if path == "/rpc:distro:sys/message" {
|
||||||
let blob = km.lazy_load_blob.map(|p| LazyLoadBlob {
|
let blob = km.lazy_load_blob.map(|p| LazyLoadBlob {
|
||||||
mime: p.mime,
|
mime: p.mime,
|
||||||
bytes: base64::encode(p.bytes).into_bytes(),
|
bytes: base64::encode(p.bytes).into_bytes(),
|
||||||
@ -856,7 +856,7 @@ async fn handle_app_message(
|
|||||||
cache,
|
cache,
|
||||||
} => {
|
} => {
|
||||||
let mut path_bindings = path_bindings.write().await;
|
let mut path_bindings = path_bindings.write().await;
|
||||||
if km.source.process != "homepage:homepage:nectar" {
|
if km.source.process != "homepage:homepage:sys" {
|
||||||
path = if path.starts_with('/') {
|
path = if path.starts_with('/') {
|
||||||
format!("/{}{}", km.source.process, path)
|
format!("/{}{}", km.source.process, path)
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,7 +4,7 @@ use std::collections::HashMap;
|
|||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
/// HTTP Request type that can be shared over WASM boundary to apps.
|
/// HTTP Request type that can be shared over WASM boundary to apps.
|
||||||
/// This is the one you receive from the `http_server:sys:nectar` service.
|
/// This is the one you receive from the `http_server:distro:sys` service.
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub enum HttpServerRequest {
|
pub enum HttpServerRequest {
|
||||||
Http(IncomingHttpRequest),
|
Http(IncomingHttpRequest),
|
||||||
@ -52,7 +52,7 @@ pub struct RpcResponseBody {
|
|||||||
pub lazy_load_blob: Option<LazyLoadBlob>,
|
pub lazy_load_blob: Option<LazyLoadBlob>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Request type sent to `http_server:sys:nectar` in order to configure it.
|
/// Request type sent to `http_server:distro:sys` in order to configure it.
|
||||||
/// You can also send [`type@HttpServerAction::WebSocketPush`], which
|
/// You can also send [`type@HttpServerAction::WebSocketPush`], which
|
||||||
/// allows you to push messages across an existing open WebSocket connection.
|
/// allows you to push messages across an existing open WebSocket connection.
|
||||||
///
|
///
|
||||||
|
@ -191,7 +191,7 @@ async fn handle_kernel_request(
|
|||||||
let parent_caps: &HashMap<t::Capability, Vec<u8>> =
|
let parent_caps: &HashMap<t::Capability, Vec<u8>> =
|
||||||
&process_map.get(&km.source.process).unwrap().capabilities;
|
&process_map.get(&km.source.process).unwrap().capabilities;
|
||||||
let mut valid_capabilities: HashMap<t::Capability, Vec<u8>> = HashMap::new();
|
let mut valid_capabilities: HashMap<t::Capability, Vec<u8>> = HashMap::new();
|
||||||
if km.source.process == "kernel:sys:nectar" {
|
if km.source.process == "kernel:distro:sys" {
|
||||||
for cap in initial_capabilities {
|
for cap in initial_capabilities {
|
||||||
let sig = keypair.sign(&rmp_serde::to_vec(&cap).unwrap());
|
let sig = keypair.sign(&rmp_serde::to_vec(&cap).unwrap());
|
||||||
valid_capabilities.insert(cap, sig.as_ref().to_vec());
|
valid_capabilities.insert(cap, sig.as_ref().to_vec());
|
||||||
@ -619,7 +619,7 @@ async fn start_process(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// the nectar kernel. contains event loop which handles all message-passing between
|
/// the OS kernel. contains event loop which handles all message-passing between
|
||||||
/// all processes (WASM apps) and also runtime tasks.
|
/// all processes (WASM apps) and also runtime tasks.
|
||||||
pub async fn kernel(
|
pub async fn kernel(
|
||||||
our: t::Identity,
|
our: t::Identity,
|
||||||
@ -651,7 +651,7 @@ pub async fn kernel(
|
|||||||
|
|
||||||
let mut senders: Senders = HashMap::new();
|
let mut senders: Senders = HashMap::new();
|
||||||
senders.insert(
|
senders.insert(
|
||||||
t::ProcessId::new(Some("net"), "sys", "nectar"),
|
t::ProcessId::new(Some("net"), "distro", "sys"),
|
||||||
ProcessSender::Runtime(send_to_net.clone()),
|
ProcessSender::Runtime(send_to_net.clone()),
|
||||||
);
|
);
|
||||||
for (process_id, sender, _) in runtime_extensions {
|
for (process_id, sender, _) in runtime_extensions {
|
||||||
@ -803,7 +803,7 @@ pub async fn kernel(
|
|||||||
},
|
},
|
||||||
target: t::Address {
|
target: t::Address {
|
||||||
node: our.name.clone(),
|
node: our.name.clone(),
|
||||||
process: t::ProcessId::new(Some("ndns_indexer"), "ndns_indexer", "nectar"),
|
process: t::ProcessId::new(Some("ndns_indexer"), "ndns_indexer", "sys"),
|
||||||
},
|
},
|
||||||
rsvp: None,
|
rsvp: None,
|
||||||
message: t::Message::Request(t::Request {
|
message: t::Message::Request(t::Request {
|
||||||
@ -819,7 +819,7 @@ pub async fn kernel(
|
|||||||
.expect("fatal: kernel event loop died");
|
.expect("fatal: kernel event loop died");
|
||||||
|
|
||||||
#[cfg(feature = "simulation-mode")]
|
#[cfg(feature = "simulation-mode")]
|
||||||
let tester_process_id = t::ProcessId::new(Some("tester"), "tester", "nectar");
|
let tester_process_id = t::ProcessId::new(Some("tester"), "tester", "sys");
|
||||||
|
|
||||||
// main event loop
|
// main event loop
|
||||||
loop {
|
loop {
|
||||||
|
18
src/main.rs
18
src/main.rs
@ -329,42 +329,42 @@ async fn main() {
|
|||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
let mut runtime_extensions = vec![
|
let mut runtime_extensions = vec![
|
||||||
(
|
(
|
||||||
ProcessId::new(Some("http_server"), "sys", "nectar"),
|
ProcessId::new(Some("http_server"), "distro", "sys"),
|
||||||
http_server_sender,
|
http_server_sender,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ProcessId::new(Some("http_client"), "sys", "nectar"),
|
ProcessId::new(Some("http_client"), "distro", "sys"),
|
||||||
http_client_sender,
|
http_client_sender,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ProcessId::new(Some("timer"), "sys", "nectar"),
|
ProcessId::new(Some("timer"), "distro", "sys"),
|
||||||
timer_service_sender,
|
timer_service_sender,
|
||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ProcessId::new(Some("eth"), "sys", "nectar"),
|
ProcessId::new(Some("eth"), "distro", "sys"),
|
||||||
eth_provider_sender,
|
eth_provider_sender,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ProcessId::new(Some("vfs"), "sys", "nectar"),
|
ProcessId::new(Some("vfs"), "distro", "sys"),
|
||||||
vfs_message_sender,
|
vfs_message_sender,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ProcessId::new(Some("state"), "sys", "nectar"),
|
ProcessId::new(Some("state"), "distro", "sys"),
|
||||||
state_sender,
|
state_sender,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ProcessId::new(Some("kv"), "sys", "nectar"),
|
ProcessId::new(Some("kv"), "distro", "sys"),
|
||||||
kv_sender,
|
kv_sender,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ProcessId::new(Some("sqlite"), "sys", "nectar"),
|
ProcessId::new(Some("sqlite"), "distro", "sys"),
|
||||||
sqlite_sender,
|
sqlite_sender,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
@ -372,7 +372,7 @@ async fn main() {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* the kernel module will handle our userspace processes and receives
|
* the kernel module will handle our userspace processes and receives
|
||||||
* all "messages", the basic message format for nectar.
|
* the basic message format for this OS.
|
||||||
*
|
*
|
||||||
* if any of these modules fail, the program exits with an error.
|
* if any of these modules fail, the program exits with an error.
|
||||||
*/
|
*/
|
||||||
|
@ -930,7 +930,7 @@ async fn handle_local_message(
|
|||||||
id: km.id,
|
id: km.id,
|
||||||
source: Address {
|
source: Address {
|
||||||
node: our.name.clone(),
|
node: our.name.clone(),
|
||||||
process: ProcessId::new(Some("net"), "sys", "nectar"),
|
process: ProcessId::new(Some("net"), "distro", "sys"),
|
||||||
},
|
},
|
||||||
target: km.rsvp.unwrap_or(km.source),
|
target: km.rsvp.unwrap_or(km.source),
|
||||||
rsvp: None,
|
rsvp: None,
|
||||||
|
@ -209,17 +209,17 @@ pub async fn create_passthrough(
|
|||||||
if !target_peer.routing_for {
|
if !target_peer.routing_for {
|
||||||
return Err(anyhow!("we don't route for that indirect node"));
|
return Err(anyhow!("we don't route for that indirect node"));
|
||||||
}
|
}
|
||||||
// send their net:sys:nectar process a message, notifying it to create a *matching*
|
// send their net:distro:sys process a message, notifying it to create a *matching*
|
||||||
// passthrough request, which we can pair with this pending one.
|
// passthrough request, which we can pair with this pending one.
|
||||||
target_peer.sender.send(KernelMessage {
|
target_peer.sender.send(KernelMessage {
|
||||||
id: rand::random(),
|
id: rand::random(),
|
||||||
source: Address {
|
source: Address {
|
||||||
node: our.name.clone(),
|
node: our.name.clone(),
|
||||||
process: ProcessId::new(Some("net"), "sys", "nectar"),
|
process: ProcessId::new(Some("net"), "distro", "sys"),
|
||||||
},
|
},
|
||||||
target: Address {
|
target: Address {
|
||||||
node: to_name.clone(),
|
node: to_name.clone(),
|
||||||
process: ProcessId::new(Some("net"), "sys", "nectar"),
|
process: ProcessId::new(Some("net"), "distro", "sys"),
|
||||||
},
|
},
|
||||||
rsvp: None,
|
rsvp: None,
|
||||||
message: Message::Request(Request {
|
message: Message::Request(Request {
|
||||||
@ -326,7 +326,7 @@ pub async fn recv_protocol_message(conn: &mut PeerConnection) -> Result<KernelMe
|
|||||||
&mut conn.buf,
|
&mut conn.buf,
|
||||||
)?;
|
)?;
|
||||||
if outer_len < 4 {
|
if outer_len < 4 {
|
||||||
return Err(anyhow!("nectar message too small!"));
|
return Err(anyhow!("protocol message too small!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let length_bytes = [conn.buf[0], conn.buf[1], conn.buf[2], conn.buf[3]];
|
let length_bytes = [conn.buf[0], conn.buf[1], conn.buf[2], conn.buf[3]];
|
||||||
@ -485,7 +485,7 @@ pub async fn parse_hello_message(
|
|||||||
id: km.id,
|
id: km.id,
|
||||||
source: Address {
|
source: Address {
|
||||||
node: our.name.clone(),
|
node: our.name.clone(),
|
||||||
process: ProcessId::new(Some("net"), "sys", "nectar"),
|
process: ProcessId::new(Some("net"), "distro", "sys"),
|
||||||
},
|
},
|
||||||
target: km.rsvp.as_ref().unwrap_or(&km.source).clone(),
|
target: km.rsvp.as_ref().unwrap_or(&km.source).clone(),
|
||||||
rsvp: None,
|
rsvp: None,
|
||||||
|
@ -299,7 +299,7 @@ async fn bootstrap(
|
|||||||
let k_cap = Capability {
|
let k_cap = Capability {
|
||||||
issuer: Address {
|
issuer: Address {
|
||||||
node: our_name.to_string(),
|
node: our_name.to_string(),
|
||||||
process: ProcessId::new(Some("kernel"), "sys", "nectar"),
|
process: ProcessId::new(Some("kernel"), "distro", "sys"),
|
||||||
},
|
},
|
||||||
params: "\"messaging\"".into(),
|
params: "\"messaging\"".into(),
|
||||||
};
|
};
|
||||||
@ -308,7 +308,7 @@ async fn bootstrap(
|
|||||||
let n_cap = Capability {
|
let n_cap = Capability {
|
||||||
issuer: Address {
|
issuer: Address {
|
||||||
node: our_name.to_string(),
|
node: our_name.to_string(),
|
||||||
process: ProcessId::new(Some("net"), "sys", "nectar"),
|
process: ProcessId::new(Some("net"), "distro", "sys"),
|
||||||
},
|
},
|
||||||
params: "\"messaging\"".into(),
|
params: "\"messaging\"".into(),
|
||||||
};
|
};
|
||||||
@ -336,7 +336,7 @@ async fn bootstrap(
|
|||||||
// finally, save runtime modules in state map as well, somewhat fakely
|
// finally, save runtime modules in state map as well, somewhat fakely
|
||||||
// special cases for kernel and net
|
// special cases for kernel and net
|
||||||
process_map
|
process_map
|
||||||
.entry(ProcessId::new(Some("kernel"), "sys", "nectar"))
|
.entry(ProcessId::new(Some("kernel"), "distro", "sys"))
|
||||||
.or_insert(PersistedProcess {
|
.or_insert(PersistedProcess {
|
||||||
wasm_bytes_handle: "".into(),
|
wasm_bytes_handle: "".into(),
|
||||||
wit_version: None,
|
wit_version: None,
|
||||||
@ -345,7 +345,7 @@ async fn bootstrap(
|
|||||||
public: false,
|
public: false,
|
||||||
});
|
});
|
||||||
process_map
|
process_map
|
||||||
.entry(ProcessId::new(Some("net"), "sys", "nectar"))
|
.entry(ProcessId::new(Some("net"), "distro", "sys"))
|
||||||
.or_insert(PersistedProcess {
|
.or_insert(PersistedProcess {
|
||||||
wasm_bytes_handle: "".into(),
|
wasm_bytes_handle: "".into(),
|
||||||
wit_version: None,
|
wit_version: None,
|
||||||
|
20
src/types.rs
20
src/types.rs
@ -5,16 +5,16 @@ use std::collections::{HashMap, HashSet};
|
|||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
pub static ref ETH_PROCESS_ID: ProcessId = ProcessId::new(Some("eth"), "sys", "nectar");
|
pub static ref ETH_PROCESS_ID: ProcessId = ProcessId::new(Some("eth"), "distro", "sys");
|
||||||
pub static ref HTTP_CLIENT_PROCESS_ID: ProcessId = ProcessId::new(Some("http_client"), "sys", "nectar");
|
pub static ref HTTP_CLIENT_PROCESS_ID: ProcessId = ProcessId::new(Some("http_client"), "distro", "sys");
|
||||||
pub static ref HTTP_SERVER_PROCESS_ID: ProcessId = ProcessId::new(Some("http_server"), "sys", "nectar");
|
pub static ref HTTP_SERVER_PROCESS_ID: ProcessId = ProcessId::new(Some("http_server"), "distro", "sys");
|
||||||
pub static ref KERNEL_PROCESS_ID: ProcessId = ProcessId::new(Some("kernel"), "sys", "nectar");
|
pub static ref KERNEL_PROCESS_ID: ProcessId = ProcessId::new(Some("kernel"), "distro", "sys");
|
||||||
pub static ref TERMINAL_PROCESS_ID: ProcessId = ProcessId::new(Some("terminal"), "terminal", "nectar");
|
pub static ref TERMINAL_PROCESS_ID: ProcessId = ProcessId::new(Some("terminal"), "terminal", "sys");
|
||||||
pub static ref TIMER_PROCESS_ID: ProcessId = ProcessId::new(Some("timer"), "sys", "nectar");
|
pub static ref TIMER_PROCESS_ID: ProcessId = ProcessId::new(Some("timer"), "distro", "sys");
|
||||||
pub static ref VFS_PROCESS_ID: ProcessId = ProcessId::new(Some("vfs"), "sys", "nectar");
|
pub static ref VFS_PROCESS_ID: ProcessId = ProcessId::new(Some("vfs"), "distro", "sys");
|
||||||
pub static ref STATE_PROCESS_ID: ProcessId = ProcessId::new(Some("state"), "sys", "nectar");
|
pub static ref STATE_PROCESS_ID: ProcessId = ProcessId::new(Some("state"), "distro", "sys");
|
||||||
pub static ref KV_PROCESS_ID: ProcessId = ProcessId::new(Some("kv"), "sys", "nectar");
|
pub static ref KV_PROCESS_ID: ProcessId = ProcessId::new(Some("kv"), "distro", "sys");
|
||||||
pub static ref SQLITE_PROCESS_ID: ProcessId = ProcessId::new(Some("sqlite"), "sys", "nectar");
|
pub static ref SQLITE_PROCESS_ID: ProcessId = ProcessId::new(Some("sqlite"), "distro", "sys");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user