From da036ea6af81972732cc4aadc7a443f11b76a748 Mon Sep 17 00:00:00 2001 From: doria <93405247+dr-frmr@users.noreply.github.com> Date: Thu, 9 May 2024 05:20:29 +0900 Subject: [PATCH 1/2] fix: readme RPC info and other nits --- README.md | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 9283ed14..c639ffc2 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,6 @@ cargo +nightly build -p kinode No security audits of this crate have ever been performed. This software is under active development and should be **used at your own risk**. ## Boot -Get an eth-sepolia-rpc API key and pass that as an argument. You can get one for free at `alchemy.com`. Make sure not to use the same home directory for two nodes at once! You can use any name for the home directory: here we just use `home`. The `--` here separates cargo arguments from binary arguments. @@ -52,18 +51,20 @@ TODO: document feature flags in `--simulation-mode` 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 Optimism ETH or an invite code. +On boot you will be prompted to navigate to `localhost:8080` (or whatever HTTP port your node bound to: it will try 8080 and go up from there, or use the port passed with the `--http-port` boot flag. 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](./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`. +By default, a node will use the [hardcoded providers](./kinode/src/eth/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/src/eth/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: +You may also add a RPC provider or otherwise modify your configuration by sending messages from the terminal to the `eth:distro:sys` process. You can get one for free at `alchemy.com`. Use this message format to add a provider -- this will make your node's performance better when accessing a blockchain: ``` m our@eth:distro:sys '{"AddProvider": {"chain_id": , "trusted": true, "provider": {"RpcUrl": ""}}}' ``` We will soon add a settings GUI for this. +You can also do the same thing by using the `--rpc` boot flag with an Optimism WebSockets RPC URL. + ## Distro and Runtime processes 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. @@ -89,9 +90,11 @@ The distro userspace packages are: - `app_store:sys` - `chess:sys` - `homepage:sys` +- `kino_updates:sys` - `kns_indexer:sys` +- `settings:sys` - `terminal:sys` -- `tester:sys` (used with `kit` for running test suites) +- `tester:sys` (used with `kit` for running test suites, only installed in `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. @@ -110,7 +113,7 @@ The `sys` publisher is not a real node ID, but it's also not a special case valu - UpArrow/DownArrow or CTRL+P/CTRL+N to move up and down through command history - CTRL+R to search history, CTRL+R again to toggle through search results, CTRL+G to cancel search -- `m
`: send an inter-process message.
is formatted as @. is formatted as ::. JSON containing spaces must be wrapped in single-quotes (`''`). +- `m
''`: send an inter-process message.
is formatted as @. is formatted as ::. JSON containing spaces must be wrapped in single-quotes (`''`). - Example: `m our@eth:distro:sys "SetPublic" -a 5` - the '-a' flag is used to expect a response with a given timeout - `our` will always be interpolated by the system as your node's name @@ -127,14 +130,6 @@ The `sys` publisher is not a real node ID, but it's also not a special case valu - `peers`: print the peers the node currently hold connections with - `peer `: print the peer's PKI info, if it exists -### Terminal example usage - -Download and install an app: -``` -m our@main:app_store:sys '{"Download": {"package": {"package_name": "", "publisher_node": ""}, "install_from": ""}}' -m our@main:app_store:sys '{"Install": {"package_name": "", "publisher_node": ""}}' -``` - ## Running as a Docker container This image expects a volume mounted at `/kinode-home`. This volume may be empty or may contain another Kinode's data. It will be used as the home directory of your Kinode. @@ -155,4 +150,4 @@ docker volume create kinode-volume docker run -d -p 8080:8080 -it --name my-kinode \ --mount type=volume,source=kinode-volume,destination=/kinode-home \ 0xlynett/kinode -``` \ No newline at end of file +``` From 4637b1f50039cf6b56af5b8fa233fc0fb72569dd Mon Sep 17 00:00:00 2001 From: dr-frmr Date: Wed, 8 May 2024 15:35:38 -0600 Subject: [PATCH 2/2] hotfix: settings page work on secure connections --- kinode/packages/settings/pkg/ui/script.js | 16 ++++++---------- kinode/packages/settings/settings/src/lib.rs | 1 + 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/kinode/packages/settings/pkg/ui/script.js b/kinode/packages/settings/pkg/ui/script.js index c61d9f6d..967ff4e0 100644 --- a/kinode/packages/settings/pkg/ui/script.js +++ b/kinode/packages/settings/pkg/ui/script.js @@ -2,16 +2,11 @@ const APP_PATH = '/settings:settings:sys/ask'; // Fetch initial data and populate the UI function init() { - fetch('/our') - .then(response => response.text()) + fetch(APP_PATH) + .then(response => response.json()) .then(data => { - const our = data + '@settings:settings:sys'; - fetch(APP_PATH) - .then(response => response.json()) - .then(data => { - console.log(data); - populate(data); - }); + console.log(data); + populate(data); }); } @@ -158,7 +153,8 @@ document.getElementById('ping-peer').addEventListener('submit', (e) => { }) // Setup WebSocket connection -const ws = new WebSocket("ws://" + location.host + "/settings:settings:sys/"); +const wsProtocol = location.protocol === 'https:' ? 'wss://' : 'ws://'; +const ws = new WebSocket(wsProtocol + location.host + "/settings:settings:sys/"); ws.onmessage = event => { const data = JSON.parse(event.data); console.log(data); diff --git a/kinode/packages/settings/settings/src/lib.rs b/kinode/packages/settings/settings/src/lib.rs index 805d7a7d..f81661fe 100644 --- a/kinode/packages/settings/settings/src/lib.rs +++ b/kinode/packages/settings/settings/src/lib.rs @@ -249,6 +249,7 @@ fn handle_http_request( state: &mut SettingsState, http_request: &http::IncomingHttpRequest, ) -> anyhow::Result<()> { + state.fetch()?; match http_request.method()?.as_str() { "GET" => Ok(http::send_response( http::StatusCode::OK,