From da44bee024f292181dd883e1ad3e8633811be2f2 Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Tue, 10 Nov 2026 14:34:01 -0300 Subject: [PATCH 1/7] chore(node): name the config file in its warnings, and log a missing default at debug With no config file at the default `{datadir}/config.toml`, every start printed `WARN Could not read config file, ignoring it`. That's the normal case, so log it at debug. A missing explicit `--config-file`, or a file that can't be parsed, stays a warning, now with the path and the error (the TOML error used to be at debug only). --- crates/floresta-node/src/florestad.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/crates/floresta-node/src/florestad.rs b/crates/floresta-node/src/florestad.rs index 99139dbd1..b8946e1d7 100644 --- a/crates/floresta-node/src/florestad.rs +++ b/crates/floresta-node/src/florestad.rs @@ -694,13 +694,24 @@ impl Florestad { } else { match data.unwrap_err() { FlorestadError::TomlParsing(e) => { - warn!("Could not parse config file, ignoring it"); - debug!("{e}"); + warn!( + "Could not parse config file {}, ignoring it: {e}", + path.display() + ); + ConfigFile::default() + } + // No file at the default path is the common case, not a problem + FlorestadError::Io(e) + if config_file.is_none() && e.kind() == std::io::ErrorKind::NotFound => + { + debug!("No config file at {}, using defaults", path.display()); ConfigFile::default() } FlorestadError::Io(e) => { - warn!("Could not read config file, ignoring it"); - debug!("{e}"); + warn!( + "Could not read config file {}, ignoring it: {e}", + path.display() + ); ConfigFile::default() } // Shouldn't be any other error From 6578b839166104cf486ad04927146e9ea3fee333 Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Tue, 10 Nov 2026 14:34:01 -0300 Subject: [PATCH 2/7] refactor(node): read the config file once during wallet setup `get_config_file()` was called once each for descriptors, xpubs and addresses, so every config warning was printed three times. Read it once in `setup_wallet` and pass it to the three getters. --- crates/floresta-node/src/florestad.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/crates/floresta-node/src/florestad.rs b/crates/floresta-node/src/florestad.rs index b8946e1d7..80738c5d6 100644 --- a/crates/floresta-node/src/florestad.rs +++ b/crates/floresta-node/src/florestad.rs @@ -750,13 +750,14 @@ impl Florestad { fn setup_wallet(&self) -> Result, FlorestadError> { let wallet = AddressCache::::new_default(&self.config.datadir, ConsensusMerkle)?; + let config_file = self.get_config_file(); wallet .setup() .map_err(FlorestadError::CouldNotInitializeWallet)?; // Add the configured descriptors and addresses to the wallet - for descriptor in self.get_descriptors() { + for descriptor in self.get_descriptors(&config_file) { match wallet.push_descriptor(&descriptor) { Ok(_) => info!("Added descriptor to wallet: {descriptor}"), Err(WatchOnlyError::DuplicateDescriptor { descriptor: _ }) => { @@ -768,7 +769,7 @@ impl Florestad { } } - for xpub in self.get_xpubs() { + for xpub in self.get_xpubs(&config_file) { match wallet.push_xpub(&xpub, self.config.network) { Ok(()) => info!("Added xpubs to wallet: {xpub}"), Err(WatchOnlyError::DuplicateDescriptor { descriptor: _ }) => warn!( @@ -778,7 +779,7 @@ impl Florestad { } } - for address in self.get_addresses()? { + for address in self.get_addresses(&config_file)? { wallet.cache_address(address)?; } @@ -787,31 +788,31 @@ impl Florestad { } /// Get the wallet descriptors from the config file - fn get_descriptors(&self) -> Vec { + fn get_descriptors(&self, config_file: &ConfigFile) -> Vec { self.config .wallet_descriptor .iter() .flatten() - .chain(self.get_config_file().wallet.descriptors.iter().flatten()) + .chain(config_file.wallet.descriptors.iter().flatten()) .cloned() .collect() } /// Get the wallet xpubs from the config file and the environment - fn get_xpubs(&self) -> Vec { + fn get_xpubs(&self, config_file: &ConfigFile) -> Vec { self.config .wallet_xpub .iter() .flatten() - .chain(self.get_config_file().wallet.xpubs.iter().flatten()) + .chain(config_file.wallet.xpubs.iter().flatten()) .chain(Self::get_key_from_env().iter()) .cloned() .collect() } /// Get the wallet addresses from the config file - fn get_addresses(&self) -> Result, FlorestadError> { - self.get_config_file() + fn get_addresses(&self, config_file: &ConfigFile) -> Result, FlorestadError> { + config_file .wallet .addresses .as_deref() From efae8068db05cf2d8c284317931a0ed491098b0a Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Tue, 10 Nov 2026 14:34:01 -0300 Subject: [PATCH 3/7] chore(wire): log a missing anchors.json at debug anchors.json only exists after a utreexo peer was saved, so a fresh start always printed `Failed to init Utreexo peers: anchors.json does not exist yet, or is invalid`. Log a missing file at debug, and keep the warning for a file that can't be read or parsed, now with the error. --- crates/floresta-wire/src/p2p_wire/address_man.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/floresta-wire/src/p2p_wire/address_man.rs b/crates/floresta-wire/src/p2p_wire/address_man.rs index 614f6ba7e..81736a6d2 100644 --- a/crates/floresta-wire/src/p2p_wire/address_man.rs +++ b/crates/floresta-wire/src/p2p_wire/address_man.rs @@ -883,11 +883,18 @@ impl AddressMan { .collect::>()) }); - if anchors.is_err() { - warn!("Failed to init Utreexo peers: anchors.json does not exist yet, or is invalid"); + match anchors { + Ok(anchors) => anchors, + // No utreexo peer was saved yet, e.g. on a fresh start + Err(e) if e.kind() == std::io::ErrorKind::NotFound => { + debug!("No anchors.json yet, no Utreexo peers to reconnect to"); + Vec::new() + } + Err(e) => { + warn!("Failed to init Utreexo peers from anchors.json: {e}"); + Vec::new() + } } - - anchors.unwrap_or_default() } /// This function moves addresses between buckets, like if the ban time of a peer expired, From 15de9db539da7b907e67b3ec49f423b775e8815a Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Tue, 10 Nov 2026 14:34:01 -0300 Subject: [PATCH 4/7] chore(wire): log a failed DNS seed lookup as one warning naming the host A dead seed printed `ERROR DNS lookup failed: `, without the host, then `WARN No peer addresses read from DNS host: `. One dead seed out of several isn't an error: log a single warning with the host and the error. A lookup that succeeds with no addresses still logs the existing warning. --- .../floresta-wire/src/p2p_wire/address_man.rs | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/crates/floresta-wire/src/p2p_wire/address_man.rs b/crates/floresta-wire/src/p2p_wire/address_man.rs index 81736a6d2..b91ffcf73 100644 --- a/crates/floresta-wire/src/p2p_wire/address_man.rs +++ b/crates/floresta-wire/src/p2p_wire/address_man.rs @@ -28,7 +28,6 @@ use rand::seq::IteratorRandom; use serde::Deserialize; use serde::Serialize; use tracing::debug; -use tracing::error; use tracing::info; use tracing::warn; @@ -649,26 +648,29 @@ impl AddressMan { Some(proxy) => { debug!("Performing DNS lookup for host: {host}, using SOCKS5 proxy: {proxy}"); // SOCKS5 proxy lookup (proxied DNS-over-HTTPS). - dns_proxy::lookup_host_via_proxy(host, proxy).unwrap_or_else(|e| { - error!("DNS lookup via SOCKS5 proxy failed: {e}"); - Vec::new() - }) + dns_proxy::lookup_host_via_proxy(host, proxy).map_err(|e| e.to_string()) } None => { debug!("Performing DNS lookup for host: {host}, using the system resolver"); // System lookup (usually unencrypted, resolver sees both query and our IP). - dns_lookup::lookup_host(host).unwrap_or_else(|e| { - error!("DNS lookup failed: {e}"); - Vec::new() - }) + dns_lookup::lookup_host(host).map_err(|e| e.to_string()) } }; - if ips.is_empty() { - warn!("No peer addresses read from DNS host: {host}"); - } else { - info!("Fetched {} peer addresses from DNS host: {host}", ips.len()); - } + let ips = match ips { + Ok(ips) if ips.is_empty() => { + warn!("No peer addresses read from DNS host: {host}"); + ips + } + Ok(ips) => { + info!("Fetched {} peer addresses from DNS host: {host}", ips.len()); + ips + } + Err(e) => { + warn!("DNS lookup failed for host {host}: {e}"); + Vec::new() + } + }; let mut addresses = Vec::new(); for ip in ips { From dcdd36d78df3152b201119a23db65ceea907f7a4 Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Tue, 10 Nov 2026 14:34:01 -0300 Subject: [PATCH 5/7] chore(wire): log unexpected handshake messages at debug, by command name This is a remote peer's behaviour (e.g. `sendtemplate` before `verack`), and the warning Debug-printed the whole message. Log the command name at debug instead. The peer is still disconnected as before. --- crates/floresta-wire/src/p2p_wire/peer.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/floresta-wire/src/p2p_wire/peer.rs b/crates/floresta-wire/src/p2p_wire/peer.rs index 5bb96c2d4..fe40815eb 100644 --- a/crates/floresta-wire/src/p2p_wire/peer.rs +++ b/crates/floresta-wire/src/p2p_wire/peer.rs @@ -690,7 +690,11 @@ impl Peer { self.handle_version(version).await?; } _ => { - warn!("unexpected message: {:?} from peer {}", message, self.id); + debug!( + "unexpected message: {} from peer {}", + message.command(), + self.id + ); return Err(PeerError::UnexpectedMessage); } }, @@ -720,7 +724,11 @@ impl Peer { } bitcoin::p2p::message::NetworkMessage::WtxidRelay => {} _ => { - warn!("unexpected message: {:?} from peer {}", message, self.id); + debug!( + "unexpected message: {} from peer {}", + message.command(), + self.id + ); return Err(PeerError::UnexpectedMessage); } }, From 8b4ea5d99d552a34843d4cef1f2dd601ba5dfccc Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Tue, 10 Nov 2026 14:34:01 -0300 Subject: [PATCH 6/7] chore(wire): log NoPeersAvailable from block requests at debug Right after the assume-utreexo jump, the sync node logged `ERROR 90: crates/floresta-wire/src/p2p_wire/node/sync_ctx.rs - NoPeersAvailable` several times while it had no peer to ask for blocks yet. That's a transient state, so log it at debug. Other errors at these two sites still go through `try_and_log!`. --- crates/floresta-wire/src/p2p_wire/node/sync_ctx.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/floresta-wire/src/p2p_wire/node/sync_ctx.rs b/crates/floresta-wire/src/p2p_wire/node/sync_ctx.rs index 3e7230ddc..b45bb13ab 100644 --- a/crates/floresta-wire/src/p2p_wire/node/sync_ctx.rs +++ b/crates/floresta-wire/src/p2p_wire/node/sync_ctx.rs @@ -87,7 +87,11 @@ where self.last_block_request += 1; } - try_and_log!(self.request_blocks(blocks)); + match self.request_blocks(blocks) { + // Transient, e.g. right after startup or the assume-utreexo jump + Err(WireError::NoPeersAvailable) => debug!("No peer to request blocks from yet"), + result => try_and_log!(result), + } } fn ask_for_missed_blocks(&mut self) -> Result<(), WireError> { @@ -252,7 +256,10 @@ where } // Ask for missed blocks or proofs if they are no longer inflight or pending - try_and_log!(self.ask_for_missed_blocks()); + match self.ask_for_missed_blocks() { + Err(WireError::NoPeersAvailable) => debug!("No peer to request missed blocks from yet"), + result => try_and_log!(result), + } try_and_log!(self.ask_for_missed_proofs()); self.get_blocks_to_download(); From c5364724dde9bafcdfd294c2974b6e409e309e26 Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Tue, 10 Nov 2026 14:34:01 -0300 Subject: [PATCH 7/7] chore(wire): stop logging routine shutdown cases as errors Every Ctrl-C printed `ERROR 484: .../node/mod.rs - ChannelSend(SendError { .. })` for peers that were already gone, and `WARN No connected Utreexo peers to save to disk` when no utreexo peer was connected. Neither is a problem during shutdown, so log both at debug. --- crates/floresta-wire/src/p2p_wire/node/mod.rs | 6 +++++- crates/floresta-wire/src/p2p_wire/node/peer_man.rs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/floresta-wire/src/p2p_wire/node/mod.rs b/crates/floresta-wire/src/p2p_wire/node/mod.rs index 62a8a7479..83c87d8b0 100644 --- a/crates/floresta-wire/src/p2p_wire/node/mod.rs +++ b/crates/floresta-wire/src/p2p_wire/node/mod.rs @@ -46,6 +46,7 @@ use tokio::sync::mpsc::UnboundedReceiver; use tokio::sync::mpsc::UnboundedSender; use tokio::sync::mpsc::unbounded_channel; use tokio::sync::oneshot; +use tracing::debug; use tracing::info; use super::UtreexoNodeConfig; @@ -481,7 +482,10 @@ where info!("Shutting down node..."); try_and_warn!(self.save_utreexo_peers()); for peer in self.peer_ids.iter() { - try_and_log!(self.send_to_peer(*peer, NodeRequest::Shutdown)); + // The peer may already be gone, which is fine since we're shutting down anyway + if let Err(e) = self.send_to_peer(*peer, NodeRequest::Shutdown) { + debug!("Could not send shutdown to peer {peer}: {e:?}"); + } } try_and_log!(self.save_peers()); try_and_log!(self.chain.flush()); diff --git a/crates/floresta-wire/src/p2p_wire/node/peer_man.rs b/crates/floresta-wire/src/p2p_wire/node/peer_man.rs index d7cbf9c5c..c366107f9 100644 --- a/crates/floresta-wire/src/p2p_wire/node/peer_man.rs +++ b/crates/floresta-wire/src/p2p_wire/node/peer_man.rs @@ -904,7 +904,7 @@ where .map(|peer| peer.address.clone()) .collect(); if utreexo_peers.is_empty() { - warn!("No connected Utreexo peers to save to disk"); + debug!("No connected Utreexo peers to save to disk"); return Ok(()); } info!("Saving utreexo peers to disk...");