From 94c934f67c074a4bdba6d52f65af191903c586f4 Mon Sep 17 00:00:00 2001 From: dr-frmr Date: Tue, 5 Dec 2023 13:37:33 -0500 Subject: [PATCH] little cleanup --- README.md | 8 +++++--- modules/tester/tester/Cargo.lock | 1 + modules/tester/tester/Cargo.toml | 3 +-- src/main.rs | 6 +++--- src/register.rs | 18 +++++++++--------- src/types.rs | 1 - 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 8e9e6de4..0c63b4a9 100644 --- a/README.md +++ b/README.md @@ -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/ ``` @@ -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": "", "publisher_node": ""}, "install_from": ""}} -!message our main:app_store:uqbar {"Install": {"package_name": "", "publisher_node": ""}} +!m our@main:app_store:uqbar {"Download": {"package": {"package_name": "", "publisher_node": ""}, "install_from": ""}} +!m our@main:app_store:uqbar {"Install": {"package_name": "", "publisher_node": ""}} ``` diff --git a/modules/tester/tester/Cargo.lock b/modules/tester/tester/Cargo.lock index 23099615..f83a4609 100644 --- a/modules/tester/tester/Cargo.lock +++ b/modules/tester/tester/Cargo.lock @@ -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", diff --git a/modules/tester/tester/Cargo.toml b/modules/tester/tester/Cargo.toml index 0f325448..4c4e48fb 100644 --- a/modules/tester/tester/Cargo.toml +++ b/modules/tester/tester/Cargo.toml @@ -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] diff --git a/src/main.rs b/src/main.rs index 774e6ca2..8a9c90f6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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; diff --git a/src/register.rs b/src/register.rs index a6ebbd42..8adc6194 100644 --- a/src/register.rs +++ b/src/register.rs @@ -32,9 +32,9 @@ abigen!( type RegistrationSender = mpsc::Sender<(Identity, Keyfile, Vec)>; -pub const QNS_SEPOLIA_ADDRESS: &str = "0x9e5ed0e7873E0d7f10eEb6dE72E87fE087A12776"; +pub const _QNS_SEPOLIA_ADDRESS: &str = "0x9e5ed0e7873E0d7f10eEb6dE72E87fE087A12776"; -pub fn ip_to_number(ip: &str) -> Result { +pub fn _ip_to_number(ip: &str) -> Result { let octets: Vec<&str> = ip.split('.').collect(); if octets.len() != 4 { @@ -58,7 +58,7 @@ pub fn ip_to_number(ip: &str) -> Result { 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 { // 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, ) -> Result { @@ -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::::connect(rpc_url.clone()).await else { println!("1"); return false; }; - let Ok(qns_address): Result = QNS_SEPOLIA_ADDRESS.parse() else { + let Ok(qns_address): Result = _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; }; diff --git a/src/types.rs b/src/types.rs index 0876e575..aed13560 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,5 +1,4 @@ use crate::kernel::process::wit; -use clap::Parser; use ring::signature; use serde::{Deserialize, Serialize}; use std::collections::{HashMap, HashSet};