From 9ecc630d637318c9db5c39e94a50d3ad813e1cbd Mon Sep 17 00:00:00 2001 From: dr-frmr Date: Sun, 24 Mar 2024 20:45:32 -0600 Subject: [PATCH 1/3] fix: use personal rpc for register, if set with flag --- kinode/src/main.rs | 21 ++++++++++++--------- kinode/src/register.rs | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/kinode/src/main.rs b/kinode/src/main.rs index 72b1d3d3..797e75d9 100644 --- a/kinode/src/main.rs +++ b/kinode/src/main.rs @@ -47,6 +47,7 @@ async fn serve_register_fe( ws_networking: (tokio::net::TcpListener, bool), http_server_port: u16, testnet: bool, + maybe_rpc: Option, ) -> (Identity, Vec, Keyfile) { // check if we have keys saved on disk, encrypted // if so, prompt user for "password" to decrypt with @@ -67,7 +68,15 @@ async fn serve_register_fe( let (tx, mut rx) = mpsc::channel::<(Identity, Keyfile, Vec)>(1); let (our, decoded_keyfile, encoded_keyfile) = tokio::select! { - _ = register::register(tx, kill_rx, our_ip, ws_networking, http_server_port, disk_keyfile, testnet) => { + _ = register::register( + tx, + kill_rx, + our_ip, + ws_networking, + http_server_port, + disk_keyfile, + testnet, + maybe_rpc) => { panic!("registration failed") } Some((our, decoded_keyfile, encoded_keyfile)) = rx.recv() => { @@ -323,6 +332,7 @@ async fn main() { (ws_tcp_handle, flag_used), http_server_port, on_testnet, // true if testnet mode + matches.get_one::("rpc").cloned(), ) .await; @@ -331,14 +341,7 @@ async fn main() { None => { match password { None => { - serve_register_fe( - &home_directory_path, - our_ip.to_string(), - (ws_tcp_handle, flag_used), - http_server_port, - on_testnet, // true if testnet mode - ) - .await + panic!("Fake node must be booted with either a --fake-node-name, --password, or both."); } Some(password) => { match fs::read(format!("{}/.keys", home_directory_path)).await { diff --git a/kinode/src/register.rs b/kinode/src/register.rs index a47afdf4..0c0f498e 100644 --- a/kinode/src/register.rs +++ b/kinode/src/register.rs @@ -121,6 +121,7 @@ pub async fn register( http_port: u16, keyfile: Option>, testnet: bool, + maybe_rpc: Option, ) { // Networking info is generated and passed to the UI, but not used until confirmed let (public_key, serialized_networking_keypair) = keygen::generate_networking_key(); @@ -153,13 +154,22 @@ pub async fn register( }; // This ETH provider uses public rpc endpoints to verify registration signatures. - let url = if testnet { + let url = if let Some(rpc_url) = maybe_rpc { + rpc_url + } else if testnet { "wss://ethereum-sepolia-rpc.publicnode.com".to_string() } else { "wss://optimism-rpc.publicnode.com".to_string() }; let connector = WsConnect { url, auth: None }; - let client = ClientBuilder::default().ws(connector).await.unwrap(); + let Ok(client) = ClientBuilder::default().ws(connector).await else { + panic!( + "Error: runtime could not connect to ETH RPC.\n\ + This is necessary in order to verify node identity onchain.\n\ + Please make sure you are using a valid WebSockets URL if using \ + the --rpc flag, and you are connected to the internet." + ); + }; let provider = Arc::new(Provider::new_with_client(client)); From d26b72dff87f679211fc592b40f25dc584a5b53d Mon Sep 17 00:00:00 2001 From: dr-frmr Date: Sun, 24 Mar 2024 21:14:39 -0600 Subject: [PATCH 2/3] fix: remove old comment --- kinode/src/timer.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kinode/src/timer.rs b/kinode/src/timer.rs index 9b93a1c2..0451520b 100644 --- a/kinode/src/timer.rs +++ b/kinode/src/timer.rs @@ -36,8 +36,7 @@ pub async fn timer_service( Some(km) = timer_message_receiver.recv() => { // ignore Requests sent from other nodes if km.source.node != our { continue }; - // we only handle Requests which contain a little-endian u64 as IPC, - // except for a special "debug" message, which prints the current state + // we only handle Requests let Message::Request(req) = km.message else { continue }; let Ok(timer_action) = serde_json::from_slice::(&req.body) else { let _ = print_tx.send(Printout { From 7aadf346317a0d38e42bb4743d38aa8f3ed811c7 Mon Sep 17 00:00:00 2001 From: dr-frmr Date: Mon, 25 Mar 2024 13:01:32 -0600 Subject: [PATCH 3/3] fix: sim-mode doesn't bind ws-port --- kinode/src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/kinode/src/main.rs b/kinode/src/main.rs index 797e75d9..a5edbe3f 100644 --- a/kinode/src/main.rs +++ b/kinode/src/main.rs @@ -304,6 +304,7 @@ async fn main() { // booting will fail if the flag was used to select a different port. // if the flag was not used, the bound port will be dropped in favor of the onchain port. + #[cfg(not(feature = "simulation-mode"))] let (ws_tcp_handle, flag_used) = if let Some(port) = ws_networking_port { ( http::utils::find_open_port(*port, port + 1)