nectar/README.md

162 lines
8.3 KiB
Markdown
Raw Normal View History

<p align="center">
<img width="551" alt="Screenshot 2024-05-08 at 2 38 11PM" src="https://github.com/kinode-dao/kinode/assets/93405247/24c7982b-9d76-419a-96dc-ec4a25dda562">
<br />
<img src="https://img.shields.io/twitter/follow/kinodeOS">
</p>
2024-07-19 18:32:37 +03:00
Kinode is a general-purpose sovereign cloud computer, built for crypto.
This repo contains the core runtime and processes.
Most developers need not build the runtime.
Instead, check out the [Kinode book](https://book.kinode.org/), and in particular the ["My First App" tutorial](https://book.kinode.org/my_first_app/chapter_1.html).
2024-01-30 07:42:28 +03:00
If you want to get on the network, you can download a binary, rather than building it yourself, from [the releases page](https://github.com/kinode-dao/kinode/tags).
Then follow the instructions to [install it](https://book.kinode.org/install.html) and [join the network](https://book.kinode.org/login.html).
2024-06-01 03:35:30 +03:00
If you have questions, join the [Kinode discord](https://discord.gg/TCgdca5Bjt) and drop us a line in `#dev-support`.
2024-07-19 18:32:37 +03:00
2023-10-02 23:02:53 +03:00
## Setup
On certain operating systems, you may need to install these dependencies if they are not already present:
- openssl-sys: https://docs.rs/crate/openssl-sys/0.9.19
- libclang 5.0: https://rust-lang.github.io/rust-bindgen/requirements.html
2023-10-02 23:02:53 +03:00
```bash
# Clone the repo.
2024-02-08 01:16:35 +03:00
git clone git@github.com:kinode-dao/kinode.git
2023-10-02 23:02:53 +03:00
2024-01-08 23:02:14 +03:00
# Get some stuff so we can build Wasm.
2023-10-02 23:02:53 +03:00
2024-01-16 01:51:07 +03:00
cd kinode
2023-10-02 23:02:53 +03:00
cargo install wasm-tools
rustup install nightly
rustup target add wasm32-wasi
rustup target add wasm32-wasi --toolchain nightly
cargo install cargo-wasi
2024-06-03 20:55:49 +03:00
# Build the runtime, along with a number of "distro" WASM modules.
# The compiled binary will be at `kinode/target/debug/kinode`
# OPTIONAL: --release flag (slower build; faster runtime; binary at `kinode/target/release/kinode`)
cargo +nightly build -p kinode
2023-10-02 23:02:53 +03:00
```
2024-03-11 03:45:30 +03:00
## Security Status
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
2023-10-02 23:02:53 +03:00
2023-12-05 21:37:33 +03:00
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.
TODO: document feature flags in `--simulation-mode`
2023-10-02 23:02:53 +03:00
```bash
# OPTIONAL: --release flag
2024-04-16 18:08:36 +03:00
cargo +nightly run -p kinode -- home
2023-10-02 23:02:53 +03:00
```
2024-05-08 23:20:29 +03:00
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.
2024-03-11 03:45:30 +03:00
## Configuring the ETH RPC Provider
2024-05-08 23:20:29 +03:00
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`.
2023-10-02 23:02:53 +03:00
2024-05-08 23:20:29 +03:00
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:
2024-03-11 03:25:44 +03:00
```
m our@eth:distro:sys '{"AddProvider": {"chain_id": <SOME_CHAIN_ID>, "trusted": true, "provider": {"RpcUrl": "<WS_RPC_URL>"}}}'
```
2024-06-01 03:35:30 +03:00
You can also do the same thing by using the `--rpc` boot flag with an Optimism WebSockets RPC URL, or going to the Settings app once booted into a node.
2024-05-08 23:20:29 +03:00
2024-03-11 03:45:30 +03:00
## Distro and Runtime processes
2023-10-02 23:02:53 +03:00
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.
2024-01-17 09:18:33 +03:00
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 `kns_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`
2024-05-08 23:20:29 +03:00
- `kino_updates:sys`
2024-01-17 09:18:33 +03:00
- `kns_indexer:sys`
2024-05-08 23:20:29 +03:00
- `settings:sys`
- `terminal:sys`
2024-05-08 23:20:29 +03:00
- `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.
2024-03-11 03:45:30 +03:00
## Terminal syntax
2023-10-02 23:02:53 +03:00
- CTRL+C or CTRL+D to gracefully shutdown node
- CTRL+V to toggle through verbose modes (0-3, 0 is default and lowest verbosity)
2023-10-02 23:02:53 +03:00
- CTRL+J to toggle debug mode
- CTRL+S to step through events in debug mode
- CTRL+L to toggle logging mode, which writes all terminal output to the `.terminal_log` file. Off by default, this will write all events and verbose prints with timestamps.
2023-10-02 23:02:53 +03:00
- CTRL+A to jump to beginning of input
- CTRL+E to jump to end of input
- 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
2024-05-08 23:20:29 +03:00
- `m <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>. JSON containing spaces must be wrapped in single-quotes (`''`).
2024-07-19 18:32:37 +03:00
- 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
2024-01-22 20:53:32 +03:00
- `hi <name> <string>`: send a text message to another node's command line.
2024-07-19 18:32:37 +03:00
- Example: `hi ben.os hello world`
2024-01-22 20:53:32 +03:00
- `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.
2024-07-19 18:32:37 +03:00
- Example: `top net:distro:sys`
- Example: `top`
2024-01-22 20:53:32 +03:00
- `cat <vfs-file-path>`: print the contents of a file in the terminal
2024-07-19 18:32:37 +03:00
- Example: `cat /terminal:sys/pkg/scripts.json`
2024-01-22 20:53:32 +03:00
- `echo <text>`: print `text` to the terminal
2024-07-19 18:32:37 +03:00
- Example: `echo foo`
2024-03-05 23:31:43 +03:00
- `net_diagnostics`: print some useful networking diagnostic data
- `peers`: print the peers the node currently hold connections with
- `peer <name>`: print the peer's PKI info, if it exists
2023-10-02 23:02:53 +03:00
## Running as a Docker container
2024-04-05 00:04:55 +03:00
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.
The image includes EXPOSE directives for TCP port `8080` and TCP port `9000`. Port `8080` is used for serving the Kinode web dashboard over HTTP, and it may be mapped to a different port on the host. Port `9000` is optional and is only required for a direct node.
If you are running a direct node, you must map port `9000` to the same port on the host and on your router. Otherwise, your Kinode will not be able to connect to the rest of the network as connection info is written to the chain, and this information is based on the view from inside the Docker container.
To build a local Docker image, run the following command in this project root.
2024-07-19 18:29:45 +03:00
```bash
# The `VERSION` may be replaced with the tag of a GitHub release
docker build -t 0xlynett/kinode . --build-arg VERSION=v0.8.6
```
For example:
2024-07-19 18:29:45 +03:00
```bash
docker volume create kinode-volume
docker run -d -p 8080:8080 -it --name my-kinode \
2024-04-05 00:04:55 +03:00
--mount type=volume,source=kinode-volume,destination=/kinode-home \
0xlynett/kinode
2024-07-19 18:32:37 +03:00
```