uqbar->nectar

This commit is contained in:
dr-frmr 2024-01-08 17:02:14 -03:00
parent 3638f9a0bd
commit 4c7ca4d35e
No known key found for this signature in database
56 changed files with 687 additions and 589 deletions

View File

@ -16,5 +16,5 @@
# S3_ACCESS_KEY=minioadmin
# S3_SECRET__KEY=minioadmin
# S3_REGION=eu-north-1
# S3_BUCKET=uqbar
# S3_BUCKET=nectar
# S3_ENDPOINT=http://localhost:9000

1
.gitignore vendored
View File

@ -1,6 +1,5 @@
target/
wit/
uqbar
.vscode
.app-signing
.DS_Store

122
Cargo.lock generated
View File

@ -2978,6 +2978,67 @@ dependencies = [
"tempfile",
]
[[package]]
name = "nectar"
version = "0.5.0"
dependencies = [
"aes-gcm 0.10.2",
"anyhow",
"async-trait",
"base64 0.13.1",
"bincode",
"blake3",
"bytes",
"cap-std",
"chacha20poly1305 0.10.1",
"chrono",
"clap",
"crossterm",
"dashmap",
"digest",
"elliptic-curve",
"ethers",
"ethers-providers",
"flate2",
"futures",
"generic-array",
"getrandom",
"hex",
"hkdf",
"hmac",
"http",
"jwt",
"lazy_static",
"log",
"nohash-hasher",
"num-traits",
"open",
"public-ip",
"rand",
"reqwest",
"ring",
"rmp-serde",
"rocksdb",
"route-recognizer",
"rusqlite",
"serde",
"serde_json",
"serde_urlencoded",
"sha2",
"snow",
"static_dir",
"thiserror",
"tokio",
"tokio-tungstenite 0.20.1",
"url",
"uuid 1.4.1",
"walkdir",
"warp",
"wasmtime",
"wasmtime-wasi",
"zip",
]
[[package]]
name = "new_debug_unreachable"
version = "1.0.4"
@ -5057,67 +5118,6 @@ version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
[[package]]
name = "uqbar"
version = "0.5.0"
dependencies = [
"aes-gcm 0.10.2",
"anyhow",
"async-trait",
"base64 0.13.1",
"bincode",
"blake3",
"bytes",
"cap-std",
"chacha20poly1305 0.10.1",
"chrono",
"clap",
"crossterm",
"dashmap",
"digest",
"elliptic-curve",
"ethers",
"ethers-providers",
"flate2",
"futures",
"generic-array",
"getrandom",
"hex",
"hkdf",
"hmac",
"http",
"jwt",
"lazy_static",
"log",
"nohash-hasher",
"num-traits",
"open",
"public-ip",
"rand",
"reqwest",
"ring",
"rmp-serde",
"rocksdb",
"route-recognizer",
"rusqlite",
"serde",
"serde_json",
"serde_urlencoded",
"sha2",
"snow",
"static_dir",
"thiserror",
"tokio",
"tokio-tungstenite 0.20.1",
"url",
"uuid 1.4.1",
"walkdir",
"warp",
"wasmtime",
"wasmtime-wasi",
"zip",
]
[[package]]
name = "url"
version = "2.4.1"

View File

@ -1,5 +1,5 @@
[package]
name = "uqbar"
name = "nectar"
authors = ["UqbarDAO"]
version = "0.5.0"
edition = "2021"

View File

@ -5,15 +5,15 @@
```bash
# Clone the repo.
git clone git@github.com:uqbar-dao/uqbar.git
git clone git@github.com:uqbar-dao/nectar.git
# Configure dependency retrieval from GitHub
mkdir .cargo
echo "net.git-fetch-with-cli = true" > .cargo/config
# Get some stuff so we can build wasm.
# Get some stuff so we can build Wasm.
cd uqbar
cd nectar
cargo install wasm-tools
rustup install nightly
rustup target add wasm32-wasi
@ -55,14 +55,14 @@ 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
- `/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:uqbar diagnostics`
- Example: `/message our@net:sys:nectar diagnostics`
- `our` will always be interpolated by the system as your node's name
- Can also use `/m` for same command: `/m our@net:sys:uqbar diagnostics`
- Can also use `/m` for same command: `/m our@net:sys:nectar 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.
- Example: `/app our@net:sys:uqbar`, then `/m diagnostics`
- Can also use `/a` for same command: `/a our@net:sys:uqbar`
- Example: `/app our@net:sys:nectar`, then `/m diagnostics`
- Can also use `/a` for same command: `/a our@net:sys:nectar`
- Example of sending many messages:
- `/a ben.uq@net:sys:uqbar`
- `/a ben.uq@net:sys:nectar`
- `/m hey there`
- `/m how are you?`
- `/a` (to exit app mode)
@ -73,6 +73,6 @@ On boot you will be prompted to navigate to `localhost:8080`. Make sure your ETH
Download and install an app:
```
/m our@main:app_store:uqbar {"Download": {"package": {"package_name": "<pkg>", "publisher_node": "<node>"}, "install_from": "<node>"}}
/m our@main:app_store:uqbar {"Install": {"package_name": "<pkg>", "publisher_node": "<node>"}}
/m our@main:app_store:nectar {"Download": {"package": {"package_name": "<pkg>", "publisher_node": "<node>"}, "install_from": "<node>"}}
/m our@main:app_store:nectar {"Install": {"package_name": "<pkg>", "publisher_node": "<node>"}}
```

View File

@ -11,13 +11,13 @@ def build_and_move(feature, tmp_dir):
if feature:
subprocess.run(["cargo", "+nightly", "build", "--release", "--features", feature], check=True)
binary_name = f"uqbar-{feature}"
binary_name = f"nectar-{feature}"
else:
subprocess.run(["cargo", "+nightly", "build", "--release"], check=True)
binary_name = "uqbar"
binary_name = "nectar"
# Move and rename the binary
source_path = "target/release/uqbar"
source_path = "target/release/nectar"
dest_path = os.path.join(tmp_dir, binary_name)
shutil.move(source_path, dest_path)
@ -26,7 +26,7 @@ def main():
features = ["", "simulation-mode"] # Add more features as needed
# Ensure the tmp directory is clean
tmp_dir = "/tmp/uqbar-release"
tmp_dir = "/tmp/nectar-release"
if os.path.exists(tmp_dir):
shutil.rmtree(tmp_dir)
os.makedirs(tmp_dir)

View File

@ -138,11 +138,11 @@ fn main() {
// Pull wit from git repo
let wit_dir = pwd.join("wit");
fs::create_dir_all(&wit_dir).unwrap();
let wit_file = wit_dir.join("uqbar.wit");
let wit_file = wit_dir.join("nectar.wit");
//if !wit_file.exists() { // TODO: cache in better way
let mut wit_file = std::fs::File::create(&wit_file).unwrap();
let uqbar_wit_url = "https://raw.githubusercontent.com/uqbar-dao/uqwit/master/uqbar.wit";
let mut response = reqwest::blocking::get(uqbar_wit_url).unwrap();
let nectar_wit_url = "https://raw.githubusercontent.com/uqbar-dao/uqwit/master/nectar.wit";
let mut response = reqwest::blocking::get(nectar_wit_url).unwrap();
io::copy(&mut response, &mut wit_file).unwrap();
// Create target.wasm (compiled .wit) & world

View File

@ -15,11 +15,11 @@ rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sha2 = "0.10.8"
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "e72a791" }
nectar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "6520b95" }
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
[lib]
crate-type = ["cdylib"]
[package.metadata.component]
package = "uqbar:process"
package = "nectar:process"

View File

@ -1,10 +1,10 @@
use nectar_process_lib::kernel_types as kt;
use nectar_process_lib::println;
use nectar_process_lib::*;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use sha2::Digest;
use std::collections::{HashMap, HashSet};
use uqbar_process_lib::kernel_types as kt;
use uqbar_process_lib::println;
use uqbar_process_lib::*;
wit_bindgen::generate!({
path: "../../../wit",
@ -19,7 +19,7 @@ use ft_worker_lib::{
spawn_receive_transfer, spawn_transfer, FTWorkerCommand, FTWorkerResult, FileTransferContext,
};
/// Uqbar App Store:
/// Nectar App Store:
/// acts as both a local package manager and a protocol to share packages across the network.
/// packages are apps; apps are packages. we use an onchain app listing contract to determine
/// what apps are available to download and what node(s) to download them from.
@ -346,7 +346,7 @@ fn handle_new_package(
// create a new drive for this package in VFS
Request::new()
.target(("our", "vfs", "sys", "uqbar"))
.target(("our", "vfs", "sys", "nectar"))
.ipc(serde_json::to_vec(&vfs::VfsRequest {
path: drive.clone(),
action: vfs::VfsAction::CreateDrive,
@ -361,7 +361,7 @@ fn handle_new_package(
// add zip bytes
payload.mime = Some("application/zip".to_string());
let response = Request::new()
.target(("our", "vfs", "sys", "uqbar"))
.target(("our", "vfs", "sys", "nectar"))
.ipc(serde_json::to_vec(&vfs::VfsRequest {
path: drive.clone(),
action: vfs::VfsAction::AddZip,
@ -379,7 +379,7 @@ fn handle_new_package(
// call it <package>.zip
let zip_path = format!("{}/{}.zip", drive.clone(), package);
Request::new()
.target(("our", "vfs", "sys", "uqbar"))
.target(("our", "vfs", "sys", "nectar"))
.inherit(true)
.ipc(serde_json::to_vec(&vfs::VfsRequest {
path: zip_path,
@ -392,7 +392,7 @@ fn handle_new_package(
// now, read the pkg contents to create our own listing and state,
// such that we can mirror this package to others.
Request::new()
.target(("our", "vfs", "sys", "uqbar"))
.target(("our", "vfs", "sys", "nectar"))
.ipc(serde_json::to_vec(&vfs::VfsRequest {
path: metadata_path,
action: vfs::VfsAction::Read,
@ -427,7 +427,7 @@ fn handle_new_package(
fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
let drive_path = format!("/{}/pkg", package);
Request::new()
.target(("our", "vfs", "sys", "uqbar"))
.target(("our", "vfs", "sys", "nectar"))
.ipc(serde_json::to_vec(&vfs::VfsRequest {
path: format!("{}/manifest.json", drive_path),
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)?;
// always grant read/write to their drive, which we created for them
let Some(read_cap) = get_capability(
&Address::new(&our.node, ("vfs", "sys", "uqbar")),
&Address::new(&our.node, ("vfs", "sys", "nectar")),
&serde_json::to_string(&serde_json::json!({
"kind": "read",
"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"));
};
let Some(write_cap) = get_capability(
&Address::new(&our.node, ("vfs", "sys", "uqbar")),
&Address::new(&our.node, ("vfs", "sys", "nectar")),
&serde_json::to_string(&serde_json::json!({
"kind": "write",
"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"));
};
let Some(networking_cap) = get_capability(
&Address::new(&our.node, ("kernel", "sys", "uqbar")),
&Address::new(&our.node, ("kernel", "sys", "nectar")),
&"\"network\"".to_string(),
) else {
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
Request::new()
.target(("our", "kernel", "sys", "uqbar"))
.target(("our", "kernel", "sys", "nectar"))
.ipc(serde_json::to_vec(&kt::KernelCommand::KillProcess(
parsed_new_process_id.clone(),
))?)
.send()?;
let _bytes_response = Request::new()
.target(("our", "vfs", "sys", "uqbar"))
.target(("our", "vfs", "sys", "nectar"))
.ipc(serde_json::to_vec(&vfs::VfsRequest {
path: wasm_path.clone(),
action: vfs::VfsAction::Read,
@ -554,7 +554,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
}
}
Request::new()
.target(("our", "kernel", "sys", "uqbar"))
.target(("our", "kernel", "sys", "nectar"))
.ipc(serde_json::to_vec(&kt::KernelCommand::InitializeProcess {
id: parsed_new_process_id.clone(),
wasm_bytes_handle: wasm_path,
@ -571,7 +571,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
serde_json::Value::String(process_name) => {
if let Ok(parsed_process_id) = ProcessId::from_str(&process_name) {
let _ = Request::new()
.target(("our", "kernel", "sys", "uqbar"))
.target(("our", "kernel", "sys", "nectar"))
.ipc(
serde_json::to_vec(&kt::KernelCommand::GrantCapabilities {
target: parsed_process_id,
@ -595,7 +595,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
{
if let Some(params) = map.get("params") {
let _ = Request::new()
.target(("our", "kernel", "sys", "uqbar"))
.target(("our", "kernel", "sys", "nectar"))
.ipc(
serde_json::to_vec(
&kt::KernelCommand::GrantCapabilities {
@ -623,7 +623,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
}
}
Request::new()
.target(("our", "kernel", "sys", "uqbar"))
.target(("our", "kernel", "sys", "nectar"))
.ipc(serde_json::to_vec(&kt::KernelCommand::RunProcess(
parsed_new_process_id,
))?)
@ -635,7 +635,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
fn handle_uninstall(package: &PackageId) -> anyhow::Result<()> {
let drive_path = format!("/{}/pkg", package);
Request::new()
.target(("our", "vfs", "sys", "uqbar"))
.target(("our", "vfs", "sys", "nectar"))
.ipc(serde_json::to_vec(&vfs::VfsRequest {
path: format!("{}/manifest.json", drive_path),
action: vfs::VfsAction::Read,
@ -653,7 +653,7 @@ fn handle_uninstall(package: &PackageId) -> anyhow::Result<()> {
continue;
};
Request::new()
.target(("our", "kernel", "sys", "uqbar"))
.target(("our", "kernel", "sys", "nectar"))
.ipc(serde_json::to_vec(&kt::KernelCommand::KillProcess(
parsed_new_process_id,
))?)
@ -661,7 +661,7 @@ fn handle_uninstall(package: &PackageId) -> anyhow::Result<()> {
}
// then, delete the drive
Request::new()
.target(("our", "vfs", "sys", "uqbar"))
.target(("our", "vfs", "sys", "nectar"))
.ipc(serde_json::to_vec(&vfs::VfsRequest {
path: drive_path,
action: vfs::VfsAction::RemoveDirAll,
@ -687,7 +687,7 @@ fn handle_remote_request(
// get the .zip from VFS and attach as payload to response
let file_path = format!("/{}/pkg/{}.zip", package, package);
let Ok(Ok(_)) = Request::new()
.target(("our", "vfs", "sys", "uqbar"))
.target(("our", "vfs", "sys", "nectar"))
.ipc(
serde_json::to_vec(&vfs::VfsRequest {
path: file_path,

View File

@ -16,11 +16,11 @@ bincode = "1.3.3"
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "e72a791" }
nectar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "6520b95" }
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
[lib]
crate-type = ["cdylib"]
[package.metadata.component]
package = "uqbar:process"
package = "nectar:process"

View File

@ -1,5 +1,5 @@
use nectar_process_lib::*;
use serde::{Deserialize, Serialize};
use uqbar_process_lib::*;
#[derive(Debug, Serialize, Deserialize)]
pub struct FileTransferContext {

View File

@ -1,6 +1,6 @@
use nectar_process_lib::println;
use nectar_process_lib::*;
use serde::{Deserialize, Serialize};
use uqbar_process_lib::*;
use uqbar_process_lib::println;
mod ft_worker_lib;
use ft_worker_lib::*;
@ -23,9 +23,14 @@ pub enum FTWorkerProtocol {
call_init!(init);
fn init(our: Address) {
let Ok(Message::Request { source: parent_process, ipc, .. }) = await_message() else {
panic!("ft_worker: got bad init message");
};
let Ok(Message::Request {
source: parent_process,
ipc,
..
}) = await_message()
else {
panic!("ft_worker: got bad init message");
};
let command = serde_json::from_slice::<FTWorkerCommand>(&ipc)
.expect("ft_worker: got unparseable init message");
@ -42,7 +47,9 @@ fn init(our: Address) {
timeout,
..
} => handle_receive(parent_process, &file_name, total_chunks, timeout),
}) else { return };
}) else {
return;
};
Response::new()
.ipc(serde_json::to_vec(&result).unwrap())
@ -56,7 +63,7 @@ fn handle_send(our: &Address, target: &Address, file_name: &str, timeout: u64) -
let transfer_id: u64 = our.process().parse().unwrap();
let Some(payload) = get_payload() else {
println!("ft_worker: wasn't given payload!");
return FTWorkerResult::Err(TransferError::SourceFailed)
return FTWorkerResult::Err(TransferError::SourceFailed);
};
let file_bytes = payload.bytes;
let mut file_size = file_bytes.len() as u64;
@ -69,19 +76,23 @@ fn handle_send(our: &Address, target: &Address, file_name: &str, timeout: u64) -
// send contents in chunks and wait for
// acknowledgement.
let Ok(Ok(response)) = Request::to(target.clone())
.ipc(serde_json::to_vec(&FTWorkerCommand::Receive {
transfer_id,
file_name: file_name.to_string(),
file_size,
total_chunks,
timeout,
}).unwrap())
.send_and_await_response(timeout) else {
return FTWorkerResult::Err(TransferError::TargetOffline)
};
.ipc(
serde_json::to_vec(&FTWorkerCommand::Receive {
transfer_id,
file_name: file_name.to_string(),
file_size,
total_chunks,
timeout,
})
.unwrap(),
)
.send_and_await_response(timeout)
else {
return FTWorkerResult::Err(TransferError::TargetOffline);
};
let opp_worker = response.source();
let Ok(FTWorkerProtocol::Ready) = serde_json::from_slice(&response.ipc()) else {
return FTWorkerResult::Err(TransferError::TargetRejected)
return FTWorkerResult::Err(TransferError::TargetRejected);
};
// send file in chunks
loop {
@ -110,10 +121,10 @@ fn handle_send(our: &Address, target: &Address, file_name: &str, timeout: u64) -
}
// now wait for Finished response
let Ok(Message::Response { ipc, .. }) = await_message() else {
return FTWorkerResult::Err(TransferError::TargetRejected)
return FTWorkerResult::Err(TransferError::TargetRejected);
};
let Ok(FTWorkerProtocol::Finished) = serde_json::from_slice(&ipc) else {
return FTWorkerResult::Err(TransferError::TargetRejected)
return FTWorkerResult::Err(TransferError::TargetRejected);
};
// return success to parent
return FTWorkerResult::SendSuccess;
@ -138,13 +149,13 @@ fn handle_receive(
let start_time = std::time::Instant::now();
loop {
let Ok(Message::Request { .. }) = await_message() else {
return Some(FTWorkerResult::Err(TransferError::SourceFailed))
return Some(FTWorkerResult::Err(TransferError::SourceFailed));
};
if start_time.elapsed().as_secs() > timeout {
return Some(FTWorkerResult::Err(TransferError::SourceFailed))
return Some(FTWorkerResult::Err(TransferError::SourceFailed));
}
let Some(payload) = get_payload() else {
return Some(FTWorkerResult::Err(TransferError::SourceFailed))
return Some(FTWorkerResult::Err(TransferError::SourceFailed));
};
chunks_received += 1;
file_bytes.extend(payload.bytes);

View File

@ -5,25 +5,25 @@
"on_exit": "Restart",
"request_networking": true,
"request_capabilities": [
"terminal:terminal:uqbar",
"filesystem:sys:uqbar",
"http_server:sys:uqbar",
"http_client:sys:uqbar",
"net:sys:uqbar",
"vfs:sys:uqbar",
"kernel:sys:uqbar",
"eth:sys:uqbar",
"terminal:terminal:nectar",
"filesystem:sys:nectar",
"http_server:sys:nectar",
"http_client:sys:nectar",
"net:sys:nectar",
"vfs:sys:nectar",
"kernel:sys:nectar",
"eth:sys:nectar",
{
"process": "vfs:sys:uqbar",
"process": "vfs:sys:nectar",
"params": {
"root": true
}
}
],
"grant_capabilities": [
"http_server:sys:uqbar",
"terminal:terminal:uqbar",
"vfs:sys:uqbar"
"http_server:sys:nectar",
"terminal:terminal:nectar",
"vfs:sys:nectar"
],
"public": false
}

View File

@ -1,6 +1,10 @@
{
"package": "app_store",
"publisher": "uqbar",
"version": [0, 2, 0],
"publisher": "nectar",
"version": [
0,
2,
0
],
"description": "A package manager + app store."
}
}

View File

@ -16,11 +16,11 @@ pleco = "0.5"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
url = "*"
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "e72a791" }
nectar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "6520b95" }
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
[lib]
crate-type = ["cdylib"]
[package.metadata.component]
package = "uqbar:process"
package = "nectar:process"

View File

@ -1,11 +1,11 @@
#![feature(let_chains)]
use pleco::Board;
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};
use uqbar_process_lib::{
use nectar_process_lib::{
await_message, call_init, get_payload, get_typed_state, http, println, set_state, Address,
Message, NodeId, Payload, Request, Response,
};
use pleco::Board;
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};
extern crate base64;
//
@ -73,7 +73,7 @@ fn load_chess_state() -> ChessState {
fn send_ws_update(our: &Address, game: &Game, open_channels: &HashSet<u32>) -> anyhow::Result<()> {
for channel in open_channels {
Request::new()
.target((&our.node, "http_server", "sys", "uqbar"))
.target((&our.node, "http_server", "sys", "nectar"))
.ipc(serde_json::to_vec(
&http::HttpServerAction::WebSocketPush {
channel_id: *channel,
@ -94,7 +94,7 @@ fn send_ws_update(our: &Address, game: &Game, open_channels: &HashSet<u32>) -> a
Ok(())
}
// Boilerplate: generate the wasm bindings for an Uqbar app
// Boilerplate: generate the wasm bindings for a Nectar app
wit_bindgen::generate!({
path: "../../../wit",
world: "process",
@ -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.
// Here, we'll accept messages from the local terminal so as to make this a "CLI" app.
} else if message.source().node == our.node
&& message.source().process == "terminal:terminal:uqbar"
&& message.source().process == "terminal:terminal:nectar"
{
let Ok(chess_request) = serde_json::from_slice::<ChessRequest>(message.ipc()) else {
return Err(anyhow::anyhow!("invalid chess request"));
};
handle_local_request(our, state, &chess_request)
} else if message.source().node == our.node
&& message.source().process == "http_server:sys:uqbar"
&& message.source().process == "http_server:sys:nectar"
{
// receive HTTP requests and websocket connection messages from our server
match serde_json::from_slice::<http::HttpServerRequest>(message.ipc())? {

View File

@ -5,10 +5,10 @@
"on_exit": "Restart",
"request_networking": true,
"request_capabilities": [
"net:sys:uqbar"
"net:sys:nectar"
],
"grant_capabilities": [
"http_server:sys:uqbar"
"http_server:sys:nectar"
],
"public": true
}

View File

@ -1,5 +1,9 @@
{
"package": "chess",
"publisher": "uqbar",
"version": [0, 2, 0]
}
"publisher": "nectar",
"version": [
0,
2,
0
]
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -15,11 +15,11 @@ anyhow = "1.0"
bincode = "1.3.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "e72a791" }
nectar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "6520b95" }
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
[lib]
crate-type = ["cdylib"]
[package.metadata.component]
package = "uqbar:process"
package = "nectar:process"

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
#![feature(let_chains)]
use uqbar_process_lib::{
await_message, http::bind_http_static_path, http::HttpServerError, println,
Address, Message, ProcessId,
use nectar_process_lib::{
await_message, http::bind_http_static_path, http::HttpServerError, println, Address, Message,
ProcessId,
};
wit_bindgen::generate!({
@ -66,7 +66,7 @@ fn main(our: Address) -> anyhow::Result<()> {
continue;
};
if let Message::Response { source, ipc, .. } = message
&& source.process == "http_server:sys:uqbar"
&& source.process == "http_server:sys:nectar"
{
match serde_json::from_slice::<Result<(), HttpServerError>>(&ipc) {
Ok(Ok(())) => continue,

View File

@ -5,10 +5,10 @@
"on_exit": "Restart",
"request_networking": false,
"request_capabilities": [
"http_server:sys:uqbar"
"http_server:sys:nectar"
],
"grant_capabilities": [
"http_server:sys:uqbar"
"http_server:sys:nectar"
],
"public": false
}

View File

@ -1,5 +1,9 @@
{
"package": "homepage",
"publisher": "uqbar",
"version": [0, 1, 0]
}
"publisher": "nectar",
"version": [
0,
1,
0
]
}

View File

@ -5,10 +5,10 @@
"on_exit": "Restart",
"request_networking": true,
"request_capabilities": [
"net:sys:uqbar",
"http_server:sys:uqbar",
"eth:sys:uqbar"
"net:sys:nectar",
"http_server:sys:nectar",
"eth:sys:nectar"
],
"public": true
}
]
]

View File

@ -1,5 +1,9 @@
{
"package": "qns_indexer",
"publisher": "uqbar",
"version": [0, 1, 0]
}
"publisher": "nectar",
"version": [
0,
1,
0
]
}

View File

@ -20,11 +20,11 @@ hex = "0.4.3"
rmp-serde = "1.1.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "6228e0f", features = ["eth"] }
nectar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "6228e0f", features = ["eth"] }
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
[lib]
crate-type = ["cdylib"]
[package.metadata.component]
package = "uqbar:process"
package = "nectar:process"

View File

@ -1,15 +1,15 @@
use alloy_primitives::B256;
use alloy_rpc_types::Log;
use alloy_sol_types::{sol, SolEvent};
use nectar_process_lib::eth::{EthAddress, SubscribeLogsRequest};
use nectar_process_lib::{
await_message, get_typed_state, http, print_to_terminal, println, set_state, Address, Message,
Payload, Request, Response,
};
use serde::{Deserialize, Serialize};
use std::collections::hash_map::{Entry, HashMap};
use std::str::FromStr;
use std::string::FromUtf8Error;
use uqbar_process_lib::eth::{EthAddress, SubscribeLogsRequest};
use uqbar_process_lib::{
await_message, get_typed_state, http, print_to_terminal, println, set_state, Address, Message,
Payload, Request, Response,
};
wit_bindgen::generate!({
path: "../../../wit",
@ -112,7 +112,7 @@ impl Guest for Component {
fn main(our: Address, mut state: State) -> anyhow::Result<()> {
// shove all state into net::net
Request::new()
.target((&our.node, "net", "sys", "uqbar"))
.target((&our.node, "net", "sys", "nectar"))
.try_ipc(NetActions::QnsBatchUpdate(
state.nodes.values().cloned().collect::<Vec<_>>(),
))?
@ -145,7 +145,7 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> {
continue;
};
if source.process == "http_server:sys:uqbar" {
if source.process == "http_server:sys:nectar" {
if let Ok(ipc_json) = serde_json::from_slice::<serde_json::Value>(&ipc) {
if ipc_json["path"].as_str().unwrap_or_default() == "/node/:name" {
if let Some(name) = ipc_json["url_params"]["name"].as_str() {
@ -239,7 +239,7 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> {
if send {
print_to_terminal(1, &format!("qns_indexer: sending ID to net: {:?}", node));
Request::new()
.target((&our.node, "net", "sys", "uqbar"))
.target((&our.node, "net", "sys", "nectar"))
.try_ipc(NetActions::QnsUpdate(node.clone()))?
.send()?;
}

View File

@ -5,10 +5,10 @@
"on_exit": "Restart",
"request_networking": true,
"request_capabilities": [
"net:sys:uqbar",
"http_client:sys:uqbar",
"kernel:sys:uqbar"
"net:sys:nectar",
"http_client:sys:nectar",
"kernel:sys:nectar"
],
"public": true
}
]
]

View File

@ -1,5 +1,9 @@
{
"package": "terminal",
"publisher": "uqbar",
"version": [0, 1, 0]
}
"publisher": "nectar",
"version": [
0,
1,
0
]
}

View File

@ -15,11 +15,11 @@ anyhow = "1.0"
bincode = "1.3.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "e72a791" }
nectar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "6520b95" }
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
[lib]
crate-type = ["cdylib"]
[package.metadata.component]
package = "uqbar:process"
package = "nectar:process"

View File

@ -1,6 +1,6 @@
use anyhow::anyhow;
use uqbar_process_lib::uqbar::process::standard as wit;
use uqbar_process_lib::{println, Address, Request};
use nectar_process_lib::nectar::process::standard as wit;
use nectar_process_lib::{println, Address, Request};
wit_bindgen::generate!({
path: "../../../wit",
@ -29,9 +29,13 @@ fn parse_command(state: &mut TerminalState, line: &str) -> anyhow::Result<()> {
Some((s, t)) => (s, t),
None => return Err(anyhow!("invalid command: \"{line}\"")),
};
let node_id = if node_id == "our" { &state.our.node } else { node_id };
let node_id = if node_id == "our" {
&state.our.node
} else {
node_id
};
Request::new()
.target((node_id, "net", "sys", "uqbar"))
.target((node_id, "net", "sys", "nectar"))
.ipc(message)
.expects_response(5)
.send()?;
@ -56,10 +60,7 @@ fn parse_command(state: &mut TerminalState, line: &str) -> anyhow::Result<()> {
// otherwise use the current_target
"/m" | "/message" => {
if let Some(target) = &state.current_target {
Request::new()
.target(target.clone())
.ipc(tail)
.send()
Request::new().target(target.clone()).ipc(tail).send()
} else {
let (target, ipc) = match tail.split_once(" ") {
Some((a, p)) => (a, p),
@ -68,10 +69,7 @@ fn parse_command(state: &mut TerminalState, line: &str) -> anyhow::Result<()> {
let Ok(target) = Address::from_str(target) else {
return Err(anyhow!("invalid address: \"{target}\""));
};
Request::new()
.target(target)
.ipc(ipc)
.send()
Request::new().target(target).ipc(ipc).send()
}
}
_ => return Err(anyhow!("invalid command: \"{line}\"")),
@ -94,10 +92,7 @@ impl Guest for Component {
}
};
match message {
wit::Message::Request(wit::Request {
ipc,
..
}) => {
wit::Message::Request(wit::Request { ipc, .. }) => {
if state.our.node != source.node || state.our.process != source.process {
continue;
}

View File

@ -5,11 +5,11 @@
"on_exit": "Restart",
"request_networking": true,
"request_capabilities": [
"net:sys:uqbar",
"kernel:sys:uqbar"
"net:sys:nectar",
"kernel:sys:nectar"
],
"grant_capabilities": [
"vfs:sys:uqbar"
"vfs:sys:nectar"
],
"public": true
}

View File

@ -1,5 +1,9 @@
{
"package": "tester",
"publisher": "uqbar",
"version": [0, 1, 0]
}
"publisher": "nectar",
"version": [
0,
1,
0
]
}

View File

@ -16,11 +16,11 @@ bincode = "1.3.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "e72a791" }
nectar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "6520b95" }
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
[lib]
crate-type = ["cdylib"]
[package.metadata.component]
package = "uqbar:process"
package = "nectar:process"

View File

@ -1,9 +1,9 @@
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};
use uqbar_process_lib::kernel_types as kt;
use uqbar_process_lib::uqbar::process::standard as wit;
use uqbar_process_lib::{
use nectar_process_lib::kernel_types as kt;
use nectar_process_lib::nectar::process::standard as wit;
use nectar_process_lib::{
our_capabilities, spawn, vfs, Address, Message, OnExit, ProcessId, Request, Response,
};
@ -21,7 +21,7 @@ wit_bindgen::generate!({
fn make_vfs_address(our: &wit::Address) -> anyhow::Result<Address> {
Ok(wit::Address {
node: our.node.clone(),
process: ProcessId::from_str("vfs:sys:uqbar")?,
process: ProcessId::from_str("vfs:sys:nectar")?,
})
}
@ -44,7 +44,7 @@ fn handle_message(our: &Address) -> anyhow::Result<()> {
let response = Request::new()
.target(make_vfs_address(&our)?)
.ipc(serde_json::to_vec(&vfs::VfsRequest {
path: "/tester:uqbar/tests".into(),
path: "/tester:nectar/tests".into(),
action: vfs::VfsAction::ReadDir,
})?)
.send_and_await_response(test_timeout)?

View File

@ -17,11 +17,11 @@ indexmap = "2.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "e72a791" }
nectar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "6520b95" }
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
[lib]
crate-type = ["cdylib"]
[package.metadata.component]
package = "uqbar:process"
package = "nectar:process"

View File

@ -1,7 +1,7 @@
use indexmap::map::IndexMap;
use uqbar_process_lib::kernel_types as kt;
use uqbar_process_lib::{
use nectar_process_lib::kernel_types as kt;
use nectar_process_lib::{
await_message, call_init, our_capabilities, println, spawn, vfs, Address, Capability, Message,
OnExit, ProcessId, Request, Response,
};
@ -22,7 +22,7 @@ type Messages = IndexMap<kt::Message, tt::KernelMessage>;
fn make_vfs_address(our: &Address) -> anyhow::Result<Address> {
Ok(Address {
node: our.node.clone(),
process: ProcessId::from_str("vfs:sys:uqbar")?,
process: ProcessId::from_str("vfs:sys:nectar")?,
})
}
@ -40,7 +40,7 @@ fn handle_message(
match serde_json::from_slice(&ipc)? {
tt::TesterResponse::Pass | tt::TesterResponse::Fail { .. } => {
if (source.process.package_name != "tester")
| (source.process.publisher_node != "uqbar")
| (source.process.publisher_node != "nectar")
{
return Err(tt::TesterError::UnexpectedResponse.into());
}
@ -70,13 +70,13 @@ fn handle_message(
.unwrap();
} else {
// we are master node
let child = "/tester:uqbar/pkg/test_runner.wasm";
let child = "/tester:nectar/pkg/test_runner.wasm";
let child_process_id = match spawn(
None,
child,
OnExit::None, // TODO: notify us
our_capabilities(),
vec![ProcessId::from_str("vfs:sys:uqbar").unwrap()],
vec![ProcessId::from_str("vfs:sys:nectar").unwrap()],
false, // not public
) {
Ok(child_process_id) => child_process_id,
@ -114,7 +114,7 @@ fn init(our: Address) {
.target(make_vfs_address(&our).unwrap())
.ipc(
serde_json::to_vec(&vfs::VfsRequest {
path: "/tester:uqbar/tests".into(),
path: "/tester:nectar/tests".into(),
action: vfs::VfsAction::CreateDrive,
})
.unwrap(),
@ -123,18 +123,18 @@ fn init(our: Address) {
.unwrap()
.unwrap();
let _ = Request::new()
.target(("our", "kernel", "sys", "uqbar"))
.target(("our", "kernel", "sys", "nectar"))
.ipc(
serde_json::to_vec(&kt::KernelCommand::GrantCapabilities {
target: ProcessId::new(Some("http_server"), "sys", "uqbar"),
target: ProcessId::new(Some("http_server"), "sys", "nectar"),
capabilities: vec![kt::Capability {
issuer: Address::new(
our.node.clone(),
ProcessId::new(Some("vfs"), "sys", "uqbar"),
ProcessId::new(Some("vfs"), "sys", "nectar"),
),
params: serde_json::json!({
"kind": "write",
"drive": "/tester:uqbar/tests",
"drive": "/tester:nectar/tests",
})
.to_string(),
}],
@ -150,7 +150,7 @@ fn init(our: Address) {
.target(make_vfs_address(&our).unwrap())
.ipc(
serde_json::to_vec(&vfs::VfsRequest {
path: "/tester:uqbar/tests".into(),
path: "/tester:nectar/tests".into(),
action: vfs::VfsAction::CreateDrive,
})
.unwrap(),

View File

@ -1,9 +1,9 @@
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use uqbar_process_lib::kernel_types as kt;
use uqbar_process_lib::{Address, Response};
// use uqbar_process_lib::uqbar::process::standard as wit;
use nectar_process_lib::kernel_types as kt;
use nectar_process_lib::{Address, Response};
// use nectar_process_lib::nectar::process::standard as wit;
type Rsvp = Option<Address>;

View File

@ -207,7 +207,7 @@ async fn connect_websocket(
id,
source: Address {
node: our.to_string(),
process: ProcessId::new(Some("http_client"), "sys", "uqbar"),
process: ProcessId::new(Some("http_client"), "sys", "nectar"),
},
target: target.clone(),
rsvp: None,
@ -449,7 +449,7 @@ async fn handle_http_request(
id,
source: Address {
node: our.to_string(),
process: ProcessId::new(Some("http_client"), "sys", "uqbar"),
process: ProcessId::new(Some("http_client"), "sys", "nectar"),
},
target,
rsvp: None,
@ -549,7 +549,7 @@ async fn http_error_message(
id,
source: Address {
node: our.to_string(),
process: ProcessId::new(Some("http_client"), "sys", "uqbar"),
process: ProcessId::new(Some("http_client"), "sys", "nectar"),
},
target,
rsvp: None,
@ -586,7 +586,7 @@ async fn websocket_error_message(
id,
source: Address {
node: our.to_string(),
process: ProcessId::new(Some("http_client"), "sys", "uqbar"),
process: ProcessId::new(Some("http_client"), "sys", "nectar"),
},
target,
rsvp: None,
@ -691,7 +691,7 @@ async fn handle_ws_message(
id,
source: Address {
node: our.to_string(),
process: ProcessId::new(Some("http_client"), "sys", "uqbar"),
process: ProcessId::new(Some("http_client"), "sys", "nectar"),
},
target,
rsvp: None,

File diff suppressed because one or more lines are too long

View File

@ -86,13 +86,13 @@ pub async fn http_server(
// add RPC path
let mut bindings_map: Router<BoundPath> = Router::new();
let rpc_bound_path = BoundPath {
app: ProcessId::from_str("rpc:sys:uqbar").unwrap(),
app: ProcessId::from_str("rpc:sys:nectar").unwrap(),
secure_subdomain: None, // TODO maybe RPC should have subdomain?
authenticated: false,
local_only: true,
static_content: None,
};
bindings_map.add("/rpc:sys:uqbar/message", rpc_bound_path);
bindings_map.add("/rpc:sys:nectar/message", rpc_bound_path);
let path_bindings: PathBindings = Arc::new(RwLock::new(bindings_map));
// ws path bindings
@ -241,7 +241,7 @@ async fn login_handler(
)
.into_response();
match HeaderValue::from_str(&format!("uqbar-auth_{}={};", our.as_ref(), &token)) {
match HeaderValue::from_str(&format!("nectar-auth_{}={};", our.as_ref(), &token)) {
Ok(v) => {
response.headers_mut().append(http::header::SET_COOKIE, v);
Ok(response)
@ -456,10 +456,10 @@ async fn http_handler(
}
}
// RPC functionality: if path is /rpc:sys:uqbar/message,
// RPC functionality: if path is /rpc:sys:nectar/message,
// we extract message from base64 encoded bytes in data
// and send it to the correct app.
let message = if bound_path.app == "rpc:sys:uqbar" {
let message = if bound_path.app == "rpc:sys:nectar" {
match handle_rpc_message(our, id, body, print_tx).await {
Ok(message) => message,
Err(e) => {
@ -797,7 +797,7 @@ async fn handle_app_message(
return;
};
// if path is /rpc/message, return accordingly with base64 encoded payload
if path == "/rpc:sys:uqbar/message" {
if path == "/rpc:sys:nectar/message" {
let payload = km.payload.map(|p| Payload {
mime: p.mime,
bytes: base64::encode(p.bytes).into_bytes(),
@ -859,7 +859,7 @@ async fn handle_app_message(
cache,
} => {
let mut path_bindings = path_bindings.write().await;
if km.source.process != "homepage:homepage:uqbar" {
if km.source.process != "homepage:homepage:nectar" {
path = if path.starts_with('/') {
format!("/{}{}", km.source.process, path)
} else {

View File

@ -4,7 +4,7 @@ use std::collections::HashMap;
use thiserror::Error;
/// HTTP Request type that can be shared over WASM boundary to apps.
/// This is the one you receive from the `http_server:sys:uqbar` service.
/// This is the one you receive from the `http_server:sys:nectar` service.
#[derive(Debug, Serialize, Deserialize)]
pub enum HttpServerRequest {
Http(IncomingHttpRequest),
@ -38,7 +38,7 @@ pub struct IncomingHttpRequest {
}
/// HTTP Request type that can be shared over WASM boundary to apps.
/// This is the one you send to the `http_client:sys:uqbar` service.
/// This is the one you send to the `http_client:sys:nectar` service.
#[derive(Debug, Serialize, Deserialize)]
pub struct OutgoingHttpRequest {
pub method: String, // must parse to http::Method
@ -59,7 +59,7 @@ pub struct HttpResponse {
}
/// WebSocket Client Request type that can be shared over WASM boundary to apps.
/// This is the one you send to the `http_client:sys:uqbar` service.
/// This is the one you send to the `http_client:sys:nectar` service.
#[derive(Debug, Serialize, Deserialize)]
pub enum WebSocketClientAction {
Open {
@ -114,7 +114,7 @@ pub enum WebSocketClientError {
CloseFailed { channel_id: u32 },
}
/// Request type sent to `http_server:sys:uqbar` in order to configure it.
/// Request type sent to `http_server:sys:nectar` in order to configure it.
/// You can also send [`type@HttpServerAction::WebSocketPush`], which
/// allows you to push messages across an existing open WebSocket connection.
///

View File

@ -43,7 +43,7 @@ pub fn auth_cookie_valid(our_node: &str, cookie: &str, jwt_secret: &[u8]) -> boo
for cookie_part in cookie_parts {
let cookie_part_parts: Vec<&str> = cookie_part.split('=').collect();
if cookie_part_parts.len() == 2
&& cookie_part_parts[0] == format!("uqbar-auth_{}", our_node)
&& cookie_part_parts[0] == format!("nectar-auth_{}", our_node)
{
auth_token = Some(cookie_part_parts[1].to_string());
break;

View File

@ -12,7 +12,7 @@ use wasmtime::{Config, Engine, WasmBacktraceDetails};
/// Manipulate a single process.
pub mod process;
/// Implement the functions served to processes by `uqbar.wit`.
/// Implement the functions served to processes by `nectar.wit`.
mod standard_host;
const PROCESS_CHANNEL_CAPACITY: usize = 100;
@ -604,7 +604,7 @@ async fn start_process(
Ok(())
}
/// the uqbar kernel. contains event loop which handles all message-passing between
/// the nectar kernel. contains event loop which handles all message-passing between
/// all processes (WASM apps) and also runtime tasks.
pub async fn kernel(
our: t::Identity,
@ -635,7 +635,7 @@ pub async fn kernel(
let mut senders: Senders = HashMap::new();
senders.insert(
t::ProcessId::new(Some("net"), "sys", "uqbar"),
t::ProcessId::new(Some("net"), "sys", "nectar"),
ProcessSender::Runtime(send_to_net.clone()),
);
for (process_id, sender, _) in runtime_extensions {
@ -777,7 +777,7 @@ pub async fn kernel(
.expect("fatal: kernel event loop died");
#[cfg(feature = "simulation-mode")]
let tester_process_id = t::ProcessId::new(Some("tester"), "tester", "uqbar");
let tester_process_id = t::ProcessId::new(Some("tester"), "tester", "nectar");
// main event loop
loop {

View File

@ -2,12 +2,12 @@ use crate::kernel::{ProcessMessageReceiver, ProcessMessageSender};
use crate::types as t;
use crate::KERNEL_PROCESS_ID;
use anyhow::Result;
pub use nectar::process::standard as wit;
pub use nectar::process::standard::Host as StandardHost;
use ring::signature::{self, KeyPair};
use std::collections::{HashMap, VecDeque};
use std::sync::Arc;
use tokio::task::JoinHandle;
pub use uqbar::process::standard as wit;
pub use uqbar::process::standard::Host as StandardHost;
use wasmtime::component::*;
use wasmtime::{Engine, Store};
use wasmtime_wasi::preview2::{Table, WasiCtx, WasiCtxBuilder, WasiView};

View File

@ -1,5 +1,5 @@
use crate::kernel::process;
use crate::kernel::process::uqbar::process::standard as wit;
use crate::kernel::process::nectar::process::standard as wit;
use crate::kernel::process::StandardHost;
use crate::types as t;
use crate::types::STATE_PROCESS_ID;

View File

@ -91,7 +91,7 @@ async fn serve_register_fe(
#[tokio::main]
async fn main() {
let app = Command::new("Uqbar")
let app = Command::new("nectar")
.version(VERSION)
.author("Uqbar DAO: https://github.com/uqbar-dao")
.about("A General Purpose Sovereign Cloud Computing Platform")
@ -197,7 +197,7 @@ async fn main() {
let http_server_port = http::utils::find_open_port(port).await.unwrap();
if http_server_port != port {
let error_message = format!(
"uqbar: couldn't bind {}; first available port found {}. Set an available port with `--port` and try again.",
"error: couldn't bind {}; first available port found {}. Set an available port with `--port` and try again.",
port,
http_server_port,
);
@ -315,38 +315,38 @@ async fn main() {
#[allow(unused_mut)]
let mut runtime_extensions = vec![
(
ProcessId::new(Some("http_server"), "sys", "uqbar"),
ProcessId::new(Some("http_server"), "sys", "nectar"),
http_server_sender,
true,
),
(
ProcessId::new(Some("http_client"), "sys", "uqbar"),
ProcessId::new(Some("http_client"), "sys", "nectar"),
http_client_sender,
false,
),
(
ProcessId::new(Some("timer"), "sys", "uqbar"),
ProcessId::new(Some("timer"), "sys", "nectar"),
timer_service_sender,
true,
),
(
ProcessId::new(Some("eth"), "sys", "uqbar"),
ProcessId::new(Some("eth"), "sys", "nectar"),
eth_provider_sender,
true,
),
(
ProcessId::new(Some("vfs"), "sys", "uqbar"),
ProcessId::new(Some("vfs"), "sys", "nectar"),
vfs_message_sender,
true,
),
(
ProcessId::new(Some("state"), "sys", "uqbar"),
ProcessId::new(Some("state"), "sys", "nectar"),
state_sender,
true,
),
(ProcessId::new(Some("kv"), "sys", "uqbar"), kv_sender, true),
(ProcessId::new(Some("kv"), "sys", "nectar"), kv_sender, true),
(
ProcessId::new(Some("sqlite"), "sys", "uqbar"),
ProcessId::new(Some("sqlite"), "sys", "nectar"),
sqlite_sender,
true,
),
@ -354,7 +354,7 @@ async fn main() {
/*
* the kernel module will handle our userspace processes and receives
* all "messages", the basic message format for uqbar.
* all "messages", the basic message format for nectar.
*
* if any of these modules fail, the program exits with an error.
*/

View File

@ -638,7 +638,7 @@ async fn recv_connection(
noise.read_message(first_message, &mut buf)?;
// -> e, ee, s, es
send_uqbar_handshake(
send_nectar_handshake(
our,
keypair,
&our_static_key,
@ -651,7 +651,7 @@ async fn recv_connection(
// <- s, se
let their_handshake =
recv_uqbar_handshake(&mut noise, &mut buf, &mut read_stream, &mut write_stream).await?;
recv_nectar_handshake(&mut noise, &mut buf, &mut read_stream, &mut write_stream).await?;
// now validate this handshake payload against the QNS PKI
let their_id = pki
@ -717,7 +717,7 @@ async fn recv_connection_via_router(
)?;
// -> e, ee, s, es
send_uqbar_handshake(
send_nectar_handshake(
our,
keypair,
&our_static_key,
@ -730,7 +730,7 @@ async fn recv_connection_via_router(
// <- s, se
let their_handshake =
recv_uqbar_handshake(&mut noise, &mut buf, &mut read_stream, &mut write_stream).await?;
recv_nectar_handshake(&mut noise, &mut buf, &mut read_stream, &mut write_stream).await?;
// now validate this handshake payload against the QNS PKI
let their_id = pki
@ -809,7 +809,7 @@ async fn init_connection(
// <- e, ee, s, es
let their_handshake =
recv_uqbar_handshake(&mut noise, &mut buf, &mut read_stream, &mut write_stream).await?;
recv_nectar_handshake(&mut noise, &mut buf, &mut read_stream, &mut write_stream).await?;
// now validate this handshake payload against the QNS PKI
validate_handshake(
@ -821,7 +821,7 @@ async fn init_connection(
)?;
// -> s, se
send_uqbar_handshake(
send_nectar_handshake(
our,
keypair,
&our_static_key,
@ -922,7 +922,7 @@ async fn handle_local_message(
id: km.id,
source: Address {
node: our.name.clone(),
process: ProcessId::from_str("net:sys:uqbar").unwrap(),
process: ProcessId::from_str("net:sys:nectar").unwrap(),
},
target: km.rsvp.unwrap_or(km.source),
rsvp: None,

View File

@ -59,7 +59,7 @@ pub async fn maintain_connection(
let mut last_message = std::time::Instant::now();
loop {
tokio::select! {
recv_result = recv_uqbar_message(&mut conn) => {
recv_result = recv_nectar_message(&mut conn) => {
match recv_result {
Ok(km) => {
if km.source.node != peer_name {
@ -81,7 +81,7 @@ pub async fn maintain_connection(
maybe_recv = peer_rx.recv() => {
match maybe_recv {
Some(km) => {
match send_uqbar_message(&km, &mut conn).await {
match send_nectar_message(&km, &mut conn).await {
Ok(()) => {
last_message = std::time::Instant::now();
continue
@ -209,17 +209,17 @@ pub async fn create_passthrough(
if !target_peer.routing_for {
return Err(anyhow!("we don't route for that indirect node"));
}
// send their net:sys:uqbar process a message, notifying it to create a *matching*
// send their net:sys:nectar process a message, notifying it to create a *matching*
// passthrough request, which we can pair with this pending one.
target_peer.sender.send(KernelMessage {
id: rand::random(),
source: Address {
node: our.name.clone(),
process: ProcessId::from_str("net:sys:uqbar").unwrap(),
process: ProcessId::from_str("net:sys:nectar").unwrap(),
},
target: Address {
node: to_name.clone(),
process: ProcessId::from_str("net:sys:uqbar").unwrap(),
process: ProcessId::from_str("net:sys:nectar").unwrap(),
},
rsvp: None,
message: Message::Request(Request {
@ -299,7 +299,7 @@ pub fn validate_handshake(
Ok(())
}
pub async fn send_uqbar_message(km: &KernelMessage, conn: &mut PeerConnection) -> Result<()> {
pub async fn send_nectar_message(km: &KernelMessage, conn: &mut PeerConnection) -> Result<()> {
let serialized = rmp_serde::to_vec(km)?;
if serialized.len() > MESSAGE_MAX_SIZE as usize {
return Err(anyhow!("message too large"));
@ -320,13 +320,13 @@ pub async fn send_uqbar_message(km: &KernelMessage, conn: &mut PeerConnection) -
}
/// any error in receiving a message will result in the connection being closed.
pub async fn recv_uqbar_message(conn: &mut PeerConnection) -> Result<KernelMessage> {
pub async fn recv_nectar_message(conn: &mut PeerConnection) -> Result<KernelMessage> {
let outer_len = conn.noise.read_message(
&ws_recv(&mut conn.read_stream, &mut conn.write_stream).await?,
&mut conn.buf,
)?;
if outer_len < 4 {
return Err(anyhow!("uqbar message too small!"));
return Err(anyhow!("nectar message too small!"));
}
let length_bytes = [conn.buf[0], conn.buf[1], conn.buf[2], conn.buf[3]];
@ -349,7 +349,7 @@ pub async fn recv_uqbar_message(conn: &mut PeerConnection) -> Result<KernelMessa
Ok(rmp_serde::from_slice(&msg)?)
}
pub async fn send_uqbar_handshake(
pub async fn send_nectar_handshake(
our: &Identity,
keypair: &Ed25519KeyPair,
noise_static_key: &[u8],
@ -373,7 +373,7 @@ pub async fn send_uqbar_handshake(
Ok(())
}
pub async fn recv_uqbar_handshake(
pub async fn recv_nectar_handshake(
noise: &mut snow::HandshakeState,
buf: &mut [u8],
read_stream: &mut SplitStream<WebSocketStream<MaybeTlsStream<TcpStream>>>,
@ -485,7 +485,7 @@ pub async fn parse_hello_message(
id: km.id,
source: Address {
node: our.name.clone(),
process: ProcessId::from_str("net:sys:uqbar").unwrap(),
process: ProcessId::from_str("net:sys:nectar").unwrap(),
},
target: km.rsvp.as_ref().unwrap_or(&km.source).clone(),
rsvp: None,

File diff suppressed because one or more lines are too long

View File

@ -117,9 +117,9 @@ pub async fn register(
ws_routing: Some((ip.clone(), ws_port)),
allowed_routers: vec![
"nectar-next-router.uq".into(),
// "uqbar-router-1.uq".into(),
// "uqbar-router-2.uq".into(),
// "uqbar-router-3.uq".into(),
// "nectar-router-1.uq".into(),
// "nectar-router-2.uq".into(),
// "nectar-router-3.uq".into(),
],
});
@ -535,7 +535,7 @@ async fn success_response(
let headers = response.headers_mut();
match HeaderValue::from_str(&format!("uqbar-auth_{}={};", &our.name, &token)) {
match HeaderValue::from_str(&format!("nectar-auth_{}={};", &our.name, &token)) {
Ok(v) => {
headers.append(SET_COOKIE, v);
}

View File

@ -299,7 +299,7 @@ async fn bootstrap(
let k_cap = Capability {
issuer: Address {
node: our_name.to_string(),
process: ProcessId::from_str("kernel:sys:uqbar").unwrap(),
process: ProcessId::from_str("kernel:sys:nectar").unwrap(),
},
params: "\"messaging\"".into(),
};
@ -308,7 +308,7 @@ async fn bootstrap(
let n_cap = Capability {
issuer: Address {
node: our_name.to_string(),
process: ProcessId::from_str("net:sys:uqbar").unwrap(),
process: ProcessId::from_str("net:sys:nectar").unwrap(),
},
params: "\"messaging\"".into(),
};
@ -336,7 +336,7 @@ async fn bootstrap(
// finally, save runtime modules in state map as well, somewhat fakely
// special cases for kernel and net
process_map
.entry(ProcessId::from_str("kernel:sys:uqbar").unwrap())
.entry(ProcessId::from_str("kernel:sys:nectar").unwrap())
.or_insert(PersistedProcess {
wasm_bytes_handle: "".into(),
wit_version: None,
@ -345,7 +345,7 @@ async fn bootstrap(
public: false,
});
process_map
.entry(ProcessId::from_str("net:sys:uqbar").unwrap())
.entry(ProcessId::from_str("net:sys:nectar").unwrap())
.or_insert(PersistedProcess {
wasm_bytes_handle: "".into(),
wit_version: None,

View File

@ -34,7 +34,7 @@ pub async fn terminal(
execute!(
stdout,
EnableBracketedPaste,
terminal::SetTitle(format!("{}@{}", our.name, "uqbar"))
terminal::SetTitle(format!("{}@{}", our.name, "nectar"))
)?;
let (mut win_cols, mut win_rows) = terminal::size().unwrap();
@ -131,18 +131,19 @@ pub async fn terminal(
let mut log_writer = BufWriter::new(log_handle);
// use to trigger cleanup if receive signal to kill process
let mut sigalrm = signal(SignalKind::alarm()).expect("uqbar: failed to set up SIGALRM handler");
let mut sighup = signal(SignalKind::hangup()).expect("uqbar: failed to set up SIGHUP handler");
let mut sigalrm =
signal(SignalKind::alarm()).expect("nectar: failed to set up SIGALRM handler");
let mut sighup = signal(SignalKind::hangup()).expect("nectar: failed to set up SIGHUP handler");
let mut sigint =
signal(SignalKind::interrupt()).expect("uqbar: failed to set up SIGINT handler");
let mut sigpipe = signal(SignalKind::pipe()).expect("uqbar: failed to set up SIGPIPE handler");
let mut sigquit = signal(SignalKind::quit()).expect("uqbar: failed to set up SIGQUIT handler");
signal(SignalKind::interrupt()).expect("nectar: failed to set up SIGINT handler");
let mut sigpipe = signal(SignalKind::pipe()).expect("nectar: failed to set up SIGPIPE handler");
let mut sigquit = signal(SignalKind::quit()).expect("nectar: failed to set up SIGQUIT handler");
let mut sigterm =
signal(SignalKind::terminate()).expect("uqbar: failed to set up SIGTERM handler");
signal(SignalKind::terminate()).expect("nectar: failed to set up SIGTERM handler");
let mut sigusr1 =
signal(SignalKind::user_defined1()).expect("uqbar: failed to set up SIGUSR1 handler");
signal(SignalKind::user_defined1()).expect("nectar: failed to set up SIGUSR1 handler");
let mut sigusr2 =
signal(SignalKind::user_defined2()).expect("uqbar: failed to set up SIGUSR2 handler");
signal(SignalKind::user_defined2()).expect("nectar: failed to set up SIGUSR2 handler");
loop {
let event = reader.next().fuse();

View File

@ -5,16 +5,16 @@ use std::collections::{HashMap, HashSet};
use thiserror::Error;
lazy_static::lazy_static! {
pub static ref ETH_PROCESS_ID: ProcessId = ProcessId::new(Some("eth"), "sys", "uqbar");
pub static ref HTTP_CLIENT_PROCESS_ID: ProcessId = ProcessId::new(Some("http_client"), "sys", "uqbar");
pub static ref HTTP_SERVER_PROCESS_ID: ProcessId = ProcessId::new(Some("http_server"), "sys", "uqbar");
pub static ref KERNEL_PROCESS_ID: ProcessId = ProcessId::new(Some("kernel"), "sys", "uqbar");
pub static ref TERMINAL_PROCESS_ID: ProcessId = ProcessId::new(Some("terminal"), "terminal", "uqbar");
pub static ref TIMER_PROCESS_ID: ProcessId = ProcessId::new(Some("timer"), "sys", "uqbar");
pub static ref VFS_PROCESS_ID: ProcessId = ProcessId::new(Some("vfs"), "sys", "uqbar");
pub static ref STATE_PROCESS_ID: ProcessId = ProcessId::new(Some("state"), "sys", "uqbar");
pub static ref KV_PROCESS_ID: ProcessId = ProcessId::new(Some("kv"), "sys", "uqbar");
pub static ref SQLITE_PROCESS_ID: ProcessId = ProcessId::new(Some("sqlite"), "sys", "uqbar");
pub static ref ETH_PROCESS_ID: ProcessId = ProcessId::new(Some("eth"), "sys", "nectar");
pub static ref HTTP_CLIENT_PROCESS_ID: ProcessId = ProcessId::new(Some("http_client"), "sys", "nectar");
pub static ref HTTP_SERVER_PROCESS_ID: ProcessId = ProcessId::new(Some("http_server"), "sys", "nectar");
pub static ref KERNEL_PROCESS_ID: ProcessId = ProcessId::new(Some("kernel"), "sys", "nectar");
pub static ref TERMINAL_PROCESS_ID: ProcessId = ProcessId::new(Some("terminal"), "terminal", "nectar");
pub static ref TIMER_PROCESS_ID: ProcessId = ProcessId::new(Some("timer"), "sys", "nectar");
pub static ref VFS_PROCESS_ID: ProcessId = ProcessId::new(Some("vfs"), "sys", "nectar");
pub static ref STATE_PROCESS_ID: ProcessId = ProcessId::new(Some("state"), "sys", "nectar");
pub static ref KV_PROCESS_ID: ProcessId = ProcessId::new(Some("kv"), "sys", "nectar");
pub static ref SQLITE_PROCESS_ID: ProcessId = ProcessId::new(Some("sqlite"), "sys", "nectar");
}
//
@ -697,7 +697,7 @@ pub type CapMessageSender = tokio::sync::mpsc::Sender<CapMessage>;
pub type CapMessageReceiver = tokio::sync::mpsc::Receiver<CapMessage>;
//
// types used for UQI: uqbar's identity system
// types used for Nectar's identity system
//
#[derive(Debug, Serialize, Deserialize)]