Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
5e1a8bc
Fix app store ui dropdown & register checkmark
willbach Mar 21, 2024
4f4b79f
Merge branch 'develop' into wg/app-store-ui-dropdown-fix
nick1udwig Apr 2, 2024
bb44a74
Merge pull request #292 from kinode-dao/wg/app-store-ui-dropdown-fix
nick1udwig Apr 2, 2024
063155c
build.rs: rebuild packages if they have changed
nick1udwig Apr 2, 2024
19516a1
app_store: return a failure when start a package if it fails
nick1udwig Apr 2, 2024
eaf347f
Format Rust code using rustfmt
github-actions[bot] Apr 2, 2024
f93fac3
feat: add a sign/verify interface to `net:distro:sys` for networking key
dr-frmr Apr 2, 2024
026aba6
Format Rust code using rustfmt
github-actions[bot] Apr 2, 2024
e0a2b5d
Merge pull request #294 from kinode-dao/hf/app-store-and-build-fixes-2
nick1udwig Apr 2, 2024
42ee5b6
Merge branch 'main' into develop
dr-frmr Apr 2, 2024
51a6919
version bump
dr-frmr Apr 2, 2024
28638c2
Merge pull request #295 from kinode-dao/dr/signer-module
dr-frmr Apr 3, 2024
98681db
bump wasmtime deps to 19.0.1
nick1udwig Apr 3, 2024
809894e
Format Rust code using rustfmt
github-actions[bot] Apr 3, 2024
5e18f44
use latest `kit`
nick1udwig Apr 4, 2024
92d06dd
update kit dep & use kit for lib build
nick1udwig Apr 4, 2024
9773975
Format Rust code using rustfmt
github-actions[bot] Apr 4, 2024
e3d5aa4
Updated register UI (#300)
willbach Apr 5, 2024
78e0aaa
Merge pull request #298 from kinode-dao/hf/bump-wasmtime-deps
nick1udwig Apr 6, 2024
709e48f
appstore update: draft 0.1
0x70b1a5 Apr 5, 2024
2a08f14
appstore facelift
0x70b1a5 Apr 8, 2024
6ef6f4b
remove old css
0x70b1a5 Apr 8, 2024
15f832c
bundle
0x70b1a5 Apr 8, 2024
4f68ecf
modal
0x70b1a5 Apr 9, 2024
7c05d35
more modals
0x70b1a5 Apr 9, 2024
c4e8268
app_store: download_denied reasons
barraguda Apr 10, 2024
a497d88
Updated register UI (#300)
willbach Apr 5, 2024
787c525
rebuild
0x70b1a5 Apr 10, 2024
17e5d94
Merge branch 'develop' into tm/login
0x70b1a5 Apr 10, 2024
0fff1d7
Merge pull request #301 from kinode-dao/tm/login
barraguda Apr 10, 2024
06f8a2c
app_store: push errors over ws
barraguda Apr 10, 2024
53fbce8
Merge branch 'develop' into bp/appstore-fixes
barraguda Apr 10, 2024
ea9fa0d
app_store: move to optimism
barraguda Apr 10, 2024
4c15375
remove sepolia testnet
barraguda Apr 11, 2024
0c84f14
warn testnet nodes on boot
barraguda Apr 12, 2024
c90c61d
chore: update all packages to use process_lib v0.6.1 and remove redun…
dr-frmr Apr 12, 2024
3b390a1
Merge branch 'develop' into bp/appstore-fixes
dr-frmr Apr 12, 2024
8a92964
Merge pull request #302 from kinode-dao/bp/appstore-fixes
barraguda Apr 15, 2024
05b6606
Fixed vite config
willbach Apr 15, 2024
d0029a2
unpublish added
tadad Apr 15, 2024
5f35e5c
text fixed
tadad Apr 15, 2024
1e1bc15
css update
tadad Apr 15, 2024
4b7a4dc
fix: remove some sepolia detritus
dr-frmr Apr 16, 2024
656a860
Merge pull request #305 from kinode-dao/da/unpublish
tadad Apr 16, 2024
5abde2f
app_store: wait for wallet connected for abis
barraguda Apr 16, 2024
1757bdf
Merge pull request #308 from kinode-dao/bp/appstore-rpc
barraguda Apr 16, 2024
aed158b
fix #307
0x70b1a5 Apr 16, 2024
858eb1c
remove sepolia RPC that doesn't work, remove old comment
dr-frmr Apr 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
621 changes: 373 additions & 248 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "kinode_lib"
authors = ["KinodeDAO"]
version = "0.6.2"
version = "0.6.3"
edition = "2021"
description = "A general-purpose sovereign cloud computing platform"
homepage = "https://kinode.org"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ Make sure not to use the same home directory for two nodes at once! You can use
TODO: document feature flags in `--simulation-mode`
```bash
# OPTIONAL: --release flag
cargo +nightly run -p kinode -- home --testnet
cargo +nightly run -p kinode -- home
```

On boot you will be prompted to navigate to `localhost:8080`. Make sure your browser wallet matches the network that the node is being booted on. Follow the registration UI -- 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 browser wallet matches the network that the node is being booted on. Follow the registration UI -- if you want to register a new ID you will either need Optimism ETH or an invite code.

## Configuring the ETH RPC Provider

By default, a node will use the hardcoded providers for the network ([testnet](./kinode/default_providers_testnet.json)/[mainnet](./kinode/default_providers_mainnet.json)) it is booted on. A node can use a WebSockets RPC URL directly, or use another Kinode as a relay point. To adjust the providers a node uses, just create and modify the `.eth_providers` file in the node's home folder (set at boot). See the Kinode Book for more docs, and see the [default providers file here](./kinode/default_providers_testnet.json) for a template to create `.eth_providers`.
By default, a node will use the [hardcoded providers](./kinode/default_providers_mainnet.json) for the network it is booted on. A node can use a WebSockets RPC URL directly, or use another Kinode as a relay point. To adjust the providers a node uses, just create and modify the `.eth_providers` file in the node's home folder (set at boot). See the Kinode Book for more docs, and see the [default providers file here](./kinode/default_providers_mainnet.json) for a template to create `.eth_providers`.

You may also add a RPC provider or otherwise modify your configuration by sending messages from the terminal to the `eth:distro:sys` process. Use this message format to add a provider -- this will make your node's performance better when accessing a blockchain:
```
Expand Down
9 changes: 5 additions & 4 deletions kinode/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "kinode"
authors = ["KinodeDAO"]
version = "0.6.2"
version = "0.6.3"
edition = "2021"
description = "A general-purpose sovereign cloud computing platform"
homepage = "https://kinode.org"
Expand All @@ -14,7 +14,7 @@ path = "src/main.rs"

[build-dependencies]
anyhow = "1.0.71"
kit = { git = "https://github.com/kinode-dao/kit", rev = "1bd7bec" }
kit = { git = "https://github.com/kinode-dao/kit", rev = "659f59e" }
rayon = "1.8.1"
sha2 = "0.10"
tokio = "1.28"
Expand Down Expand Up @@ -86,6 +86,7 @@ tokio-tungstenite = "0.20.1"
url = "2.4.1"
uuid = { version = "1.1.2", features = ["serde", "v4"] }
warp = "0.3.5"
wasmtime = "17.0.1"
wasmtime-wasi = "17.0.1"
wasi-common = "19.0.1"
wasmtime = "19.0.1"
wasmtime-wasi = "19.0.1"
zip = "0.6"
30 changes: 29 additions & 1 deletion kinode/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rayon::prelude::*;
use std::{
collections::HashSet,
fs::{self, File},
io::{Cursor, Read, Write},
path::{Path, PathBuf},
Expand All @@ -22,14 +23,34 @@ fn get_features() -> String {
features
}

fn output_reruns(dir: &Path, rerun_files: &HashSet<String>) {
if let Ok(entries) = fs::read_dir(dir) {
for entry in entries.filter_map(|e| e.ok()) {
let path = entry.path();
if path.is_dir() {
// If the entry is a directory, recursively walk it
output_reruns(&path, rerun_files);
} else if let Some(filename) = path.file_name().and_then(|n| n.to_str()) {
// Check if the current file is in our list of interesting files
if rerun_files.contains(filename) {
// If so, print a `cargo:rerun-if-changed=PATH` line for it
println!("cargo:rerun-if-changed={}", path.display());
}
}
}
}
}

fn build_and_zip_package(
entry_path: PathBuf,
parent_pkg_path: &str,
features: &str,
) -> anyhow::Result<(String, String, Vec<u8>)> {
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async {
kit::build::execute(&entry_path, true, false, true, features).await?;
kit::build::execute(&entry_path, true, false, true, features)
.await
.map_err(|e| anyhow::anyhow!("{:?}", e))?;

let mut writer = Cursor::new(Vec::new());
let options = FileOptions::default()
Expand Down Expand Up @@ -76,6 +97,13 @@ fn main() -> anyhow::Result<()> {
.map(|entry| entry.unwrap().path())
.collect();

let rerun_files: HashSet<String> = HashSet::from([
"Cargo.lock".to_string(),
"Cargo.toml".to_string(),
"src/".to_string(),
]);
output_reruns(&parent_dir, &rerun_files);

let features = get_features();

let results: Vec<anyhow::Result<(String, String, Vec<u8>)>> = entries
Expand Down
4 changes: 2 additions & 2 deletions kinode/packages/app_store/app_store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ alloy-primitives = "0.6.2"
alloy-sol-types = "0.6.2"
anyhow = "1.0"
bincode = "1.3.3"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.1" }
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sha2 = "0.10.8"
sha3 = "0.10.8"
url = "2.4.1"
urlencoding = "2.1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"
zip = { version = "0.6.6", default-features = false }

[lib]
Expand Down
11 changes: 10 additions & 1 deletion kinode/packages/app_store/app_store/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,19 @@ pub enum RemoteRequest {
#[derive(Debug, Serialize, Deserialize)]
pub enum RemoteResponse {
DownloadApproved,
DownloadDenied, // TODO expand on why
DownloadDenied(ReasonDenied),
Metadata,
}

#[derive(Debug, Serialize, Deserialize)]
pub enum ReasonDenied {
NoPackage,
NotMirroring,
HashMismatch { requested: String, have: String },
FileNotFound,
WorkerSpawnFailed,
}

/// Local requests sent to the app store take this form.
#[derive(Debug, Serialize, Deserialize)]
pub enum LocalRequest {
Expand Down
118 changes: 82 additions & 36 deletions kinode/packages/app_store/app_store/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use kinode_process_lib::http::{bind_http_path, serve_ui, HttpServerRequest};
use kinode_process_lib::http::{
bind_http_path, bind_ws_path, send_ws_push, serve_ui, HttpServerRequest, WsMessageType,
};
use kinode_process_lib::kernel_types as kt;
use kinode_process_lib::*;
use kinode_process_lib::{call_init, println};
Expand All @@ -9,9 +11,6 @@ use std::str::FromStr;
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});

mod api;
Expand Down Expand Up @@ -40,8 +39,8 @@ use ft_worker_lib::{

const ICON: &str = include_str!("icon");

const CHAIN_ID: u64 = 11155111; // sepolia
const CONTRACT_ADDRESS: &str = "0x18c39eB547A0060C6034f8bEaFB947D1C16eADF1"; // sepolia
const CHAIN_ID: u64 = 10; // optimism
const CONTRACT_ADDRESS: &str = "0x52185B6a6017E6f079B994452F234f7C2533787B"; // optimism

const EVENTS: [&str; 3] = [
"AppRegistered(uint256,string,bytes,string,bytes32)",
Expand Down Expand Up @@ -82,7 +81,7 @@ fn fetch_logs(eth_provider: &eth::Provider, filter: &eth::Filter) -> Vec<eth::Lo
}
}
}
#[cfg(feature = "simulation-mode")]
#[cfg(feature = "simulation-mode")] // TODO use local testnet, provider_chainId: 31337
vec![]
}

Expand Down Expand Up @@ -127,6 +126,8 @@ fn init(our: Address) {
)
.expect("failed to serve static UI");

bind_ws_path("/", true, true).expect("failed to bind ws path");

// add ourselves to the homepage
Request::to(("our", "homepage", "homepage", "sys"))
.body(
Expand Down Expand Up @@ -175,6 +176,9 @@ fn init(our: Address) {
}
subscribe_to_logs(&eth_provider, filter);

// websocket channel to send errors/updates to UI
let channel_id: u32 = 154869;

loop {
match await_message() {
Err(send_error) => {
Expand All @@ -189,7 +193,21 @@ fn init(our: Address) {
&mut requested_packages,
&message,
) {
println!("error handling message: {:?}", e)
println!("error handling message: {:?}", e);
send_ws_push(
channel_id,
WsMessageType::Text,
LazyLoadBlob {
mime: Some("application/json".to_string()),
bytes: serde_json::json!({
"kind": "error",
"data": e.to_string(),
})
.to_string()
.as_bytes()
.to_vec(),
},
)
}
}
}
Expand Down Expand Up @@ -298,14 +316,23 @@ fn handle_remote_request(
desired_version_hash,
} => {
let Some(package_state) = state.get_downloaded_package(package_id) else {
return Resp::RemoteResponse(RemoteResponse::DownloadDenied);
return Resp::RemoteResponse(RemoteResponse::DownloadDenied(
ReasonDenied::NoPackage,
));
};
if !package_state.mirroring {
return Resp::RemoteResponse(RemoteResponse::DownloadDenied);
return Resp::RemoteResponse(RemoteResponse::DownloadDenied(
ReasonDenied::NotMirroring,
));
}
if let Some(hash) = desired_version_hash {
if &package_state.our_version != hash {
return Resp::RemoteResponse(RemoteResponse::DownloadDenied);
return Resp::RemoteResponse(RemoteResponse::DownloadDenied(
ReasonDenied::HashMismatch {
requested: hash.clone(),
have: package_state.our_version.clone(),
},
));
}
}
let file_name = format!("/{}.zip", package_id);
Expand All @@ -321,12 +348,16 @@ fn handle_remote_request(
)
.send_and_await_response(5)
else {
return Resp::RemoteResponse(RemoteResponse::DownloadDenied);
return Resp::RemoteResponse(RemoteResponse::DownloadDenied(
ReasonDenied::FileNotFound,
));
};
// transfer will *inherit* the blob bytes we receive from VFS
match spawn_transfer(&our, &file_name, None, 60, &source) {
Ok(()) => Resp::RemoteResponse(RemoteResponse::DownloadApproved),
Err(_e) => Resp::RemoteResponse(RemoteResponse::DownloadDenied),
Err(_e) => Resp::RemoteResponse(RemoteResponse::DownloadDenied(
ReasonDenied::WorkerSpawnFailed,
)),
}
}
}
Expand Down Expand Up @@ -686,25 +717,35 @@ pub fn handle_install(
))?)
.send()?;

let _bytes_response = Request::to(("our", "vfs", "distro", "sys"))
.body(serde_json::to_vec(&vfs::VfsRequest {
path: wasm_path.clone(),
action: vfs::VfsAction::Read,
})?)
.send_and_await_response(5)??;
if let Ok(vfs::VfsResponse::Err(_)) = serde_json::from_slice(
Request::to(("our", "vfs", "distro", "sys"))
.body(serde_json::to_vec(&vfs::VfsRequest {
path: wasm_path.clone(),
action: vfs::VfsAction::Read,
})?)
.send_and_await_response(5)??
.body(),
) {
return Err(anyhow::anyhow!("failed to read process file"));
};

Request::new()
.target(("our", "kernel", "distro", "sys"))
.body(serde_json::to_vec(&kt::KernelCommand::InitializeProcess {
id: parsed_new_process_id.clone(),
wasm_bytes_handle: wasm_path,
wit_version: None,
on_exit: entry.on_exit.clone(),
initial_capabilities: HashSet::new(),
public: entry.public,
})?)
.inherit(true)
.send_and_await_response(5)??;
let Ok(kt::KernelResponse::InitializedProcess) = serde_json::from_slice(
Request::new()
.target(("our", "kernel", "distro", "sys"))
.body(serde_json::to_vec(&kt::KernelCommand::InitializeProcess {
id: parsed_new_process_id.clone(),
wasm_bytes_handle: wasm_path,
wit_version: None,
on_exit: entry.on_exit.clone(),
initial_capabilities: HashSet::new(),
public: entry.public,
})?)
.inherit(true)
.send_and_await_response(5)??
.body(),
) else {
return Err(anyhow::anyhow!("failed to initialize process"));
};
// build initial caps
let mut requested_capabilities: Vec<kt::Capability> = vec![];
for value in &entry.request_capabilities {
Expand Down Expand Up @@ -829,11 +870,16 @@ pub fn handle_install(
}
}
}
Request::to(("our", "kernel", "distro", "sys"))
.body(serde_json::to_vec(&kt::KernelCommand::RunProcess(
parsed_new_process_id,
))?)
.send_and_await_response(5)??;
let Ok(kt::KernelResponse::StartedProcess) = serde_json::from_slice(
Request::to(("our", "kernel", "distro", "sys"))
.body(serde_json::to_vec(&kt::KernelCommand::RunProcess(
parsed_new_process_id,
))?)
.send_and_await_response(5)??
.body(),
) else {
return Err(anyhow::anyhow!("failed to start process"));
};
}
// finally set the package as installed
state.update_downloaded_package(package_id, |package_state| {
Expand Down
4 changes: 2 additions & 2 deletions kinode/packages/app_store/download/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ simulation-mode = []

[dependencies]
anyhow = "1.0"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.1" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" }
wit-bindgen = "0.24.0"

[lib]
crate-type = ["cdylib"]
Expand Down
8 changes: 2 additions & 6 deletions kinode/packages/app_store/download/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use kinode_process_lib::{
await_next_request_body, call_init, println, Address, Message, NodeId, PackageId, Request,
await_next_message_body, call_init, println, Address, Message, NodeId, PackageId, Request,
};

mod api;
Expand All @@ -8,15 +8,11 @@ use api::*;
wit_bindgen::generate!({
path: "wit",
world: "process",
exports: {
world: Component,
},
});

call_init!(init);

fn init(our: Address) {
let Ok(body) = await_next_request_body() else {
let Ok(body) = await_next_message_body() else {
println!("download: failed to get args!");
return;
};
Expand Down
Loading