little cleanup

This commit is contained in:
dr-frmr 2023-12-05 13:37:33 -05:00
parent 989645c419
commit 94c934f67c
No known key found for this signature in database
6 changed files with 19 additions and 18 deletions

View File

@ -29,7 +29,9 @@ cargo +nightly build --release
### 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`.
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 here, `--llm` and `--simulation-mode`
```bash
cargo +nightly run --release -- home --rpc wss://eth-sepolia.g.alchemy.com/v2/<your-api-key>
```
@ -71,6 +73,6 @@ On boot you will be prompted to navigate to `localhost:8080`. Make sure your ETH
Download and install an app:
```
!message our main:app_store:uqbar {"Download": {"package": {"package_name": "<pkg>", "publisher_node": "<node>"}, "install_from": "<node>"}}
!message our main:app_store:uqbar {"Install": {"package_name": "<pkg>", "publisher_node": "<node>"}}
!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>"}}
```

View File

@ -280,6 +280,7 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
[[package]]
name = "uqbar_process_lib"
version = "0.2.0"
source = "git+ssh://git@github.com/uqbar-dao/process_lib.git?rev=9684d33#9684d338967c871e1611c608a4b2fa362598e194"
dependencies = [
"anyhow",
"bincode",

View File

@ -17,8 +17,7 @@ indexmap = "2.1"
serde = {version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"
uqbar_process_lib = { path = "../../../../process_lib" }
# uqbar_process_lib = { git = "https://github.com/uqbar-dao/process_lib", rev = "9684d33" }
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "9684d33" }
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "5390bab780733f1660d14c254ec985df2816bf1d" }
[lib]

View File

@ -3,14 +3,14 @@
use crate::types::*;
use anyhow::Result;
use clap::{arg, value_parser, Command};
use ring::rand::SystemRandom;
use ring::signature;
use ring::signature::KeyPair;
use std::env;
use std::sync::Arc;
use tokio::sync::{mpsc, oneshot};
use tokio::{fs, time::timeout};
#[cfg(feature = "simulation-mode")]
use ring::{rand::SystemRandom, signature, signature::KeyPair};
mod eth_rpc;
mod filesystem;
mod http;

View File

@ -32,9 +32,9 @@ abigen!(
type RegistrationSender = mpsc::Sender<(Identity, Keyfile, Vec<u8>)>;
pub const QNS_SEPOLIA_ADDRESS: &str = "0x9e5ed0e7873E0d7f10eEb6dE72E87fE087A12776";
pub const _QNS_SEPOLIA_ADDRESS: &str = "0x9e5ed0e7873E0d7f10eEb6dE72E87fE087A12776";
pub fn ip_to_number(ip: &str) -> Result<u32, &'static str> {
pub fn _ip_to_number(ip: &str) -> Result<u32, &'static str> {
let octets: Vec<&str> = ip.split('.').collect();
if octets.len() != 4 {
@ -58,7 +58,7 @@ pub fn ip_to_number(ip: &str) -> Result<u32, &'static str> {
Ok(ip_num)
}
fn hex_string_to_u8_array(hex_str: &str) -> Result<[u8; 32], &'static str> {
fn _hex_string_to_u8_array(hex_str: &str) -> Result<[u8; 32], &'static str> {
if !hex_str.starts_with("0x") || hex_str.len() != 66 {
// "0x" + 64 hex chars
return Err("Invalid hex format or length");
@ -346,7 +346,7 @@ async fn handle_boot(
async fn handle_import_keyfile(
info: ImportKeyfileInfo,
ip: String,
rpc_url: String,
_rpc_url: String,
sender: RegistrationSender,
) -> Result<impl Reply, Rejection> {
// if keyfile was not present in node and is present from user upload
@ -420,7 +420,7 @@ async fn handle_import_keyfile(
async fn handle_login(
info: LoginInfo,
ip: String,
rpc_url: String,
_rpc_url: String,
sender: RegistrationSender,
encoded_keyfile: Vec<u8>,
) -> Result<impl Reply, Rejection> {
@ -614,14 +614,14 @@ async fn success_response(
Ok(response)
}
async fn networking_info_valid(rpc_url: String, ip: String, ws_port: u16, our: &Identity) -> bool {
async fn _networking_info_valid(rpc_url: String, ip: String, ws_port: u16, our: &Identity) -> bool {
// check if Identity for this username has correct networking keys,
// if not, prompt user to reset them.
let Ok(ws_rpc) = Provider::<Ws>::connect(rpc_url.clone()).await else {
println!("1");
return false;
};
let Ok(qns_address): Result<EthAddress, _> = QNS_SEPOLIA_ADDRESS.parse() else {
let Ok(qns_address): Result<EthAddress, _> = _QNS_SEPOLIA_ADDRESS.parse() else {
println!("2");
return false;
};
@ -646,7 +646,7 @@ async fn networking_info_valid(rpc_url: String, ip: String, ws_port: u16, our: &
})
.collect();
let current_ip = match ip_to_number(&ip) {
let current_ip = match _ip_to_number(&ip) {
Ok(ip_num) => ip_num,
Err(_) => {
println!("5");
@ -654,7 +654,7 @@ async fn networking_info_valid(rpc_url: String, ip: String, ws_port: u16, our: &
}
};
let Ok(networking_key_bytes) = hex_string_to_u8_array(&our.networking_key) else {
let Ok(networking_key_bytes) = _hex_string_to_u8_array(&our.networking_key) else {
println!("6");
return false;
};

View File

@ -1,5 +1,4 @@
use crate::kernel::process::wit;
use clap::Parser;
use ring::signature;
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};