From 39d5e0435c975c8a6148680285c2986b6bec0f32 Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Mon, 1 Apr 2024 22:29:04 -0400 Subject: [PATCH] fix debug commands clean up dht capabilities add temporary fanout debugging logs --- veilid-core/src/rpc_processor/fanout_call.rs | 9 +++++++++ veilid-core/src/rpc_processor/fanout_queue.rs | 18 ++++++++++++++++++ veilid-core/src/rpc_processor/rpc_get_value.rs | 2 +- .../src/rpc_processor/rpc_inspect_value.rs | 2 +- .../src/rpc_processor/rpc_watch_value.rs | 2 +- veilid-core/src/storage_manager/get_value.rs | 2 +- veilid-core/src/storage_manager/set_value.rs | 2 +- veilid-core/src/storage_manager/watch_value.rs | 11 ++++++++++- veilid-core/src/veilid_api/debug.rs | 4 ++-- 9 files changed, 44 insertions(+), 8 deletions(-) diff --git a/veilid-core/src/rpc_processor/fanout_call.rs b/veilid-core/src/rpc_processor/fanout_call.rs index 7b7330ba..1d412ea5 100644 --- a/veilid-core/src/rpc_processor/fanout_call.rs +++ b/veilid-core/src/rpc_processor/fanout_call.rs @@ -145,6 +145,15 @@ where } fn add_to_fanout_queue(self: Arc, new_nodes: &[NodeRef]) { + info!( + "FanoutCall::add_to_fanout_queue:\n new_nodes={{\n{}}}\n", + new_nodes + .iter() + .map(|x| format!(" {}", x)) + .collect::>() + .join(",\n"), + ); + let ctx = &mut *self.context.lock(); let this = self.clone(); ctx.fanout_queue.add(new_nodes, |current_nodes| { diff --git a/veilid-core/src/rpc_processor/fanout_queue.rs b/veilid-core/src/rpc_processor/fanout_queue.rs index 2f624da7..06a49027 100644 --- a/veilid-core/src/rpc_processor/fanout_queue.rs +++ b/veilid-core/src/rpc_processor/fanout_queue.rs @@ -1,5 +1,6 @@ use super::*; +#[derive(Debug)] pub(in crate::rpc_processor) struct FanoutQueue { crypto_kind: CryptoKind, current_nodes: VecDeque, @@ -53,6 +54,20 @@ impl FanoutQueue { // Sort and trim the candidate set self.current_nodes = VecDeque::from_iter(cleanup(self.current_nodes.as_slices().0).iter().cloned()); + + info!( + "FanoutQueue::add:\n current_nodes={{\n{}}}\n returned_nodes={{\n{}}}\n", + self.current_nodes + .iter() + .map(|x| format!(" {}", x)) + .collect::>() + .join(",\n"), + self.returned_nodes + .iter() + .map(|x| format!(" {}", x)) + .collect::>() + .join(",\n") + ); } // Return next fanout candidate @@ -63,6 +78,9 @@ impl FanoutQueue { // Ensure we don't return this node again self.returned_nodes.insert(key); + + info!("FanoutQueue::next: => {}", cn); + Some(cn) } diff --git a/veilid-core/src/rpc_processor/rpc_get_value.rs b/veilid-core/src/rpc_processor/rpc_get_value.rs index 94d71306..5060d6e2 100644 --- a/veilid-core/src/rpc_processor/rpc_get_value.rs +++ b/veilid-core/src/rpc_processor/rpc_get_value.rs @@ -211,7 +211,7 @@ impl RPCProcessor { // Get the nodes that we know about that are closer to the the key than our own node let routing_table = self.routing_table(); - let closer_to_key_peers = network_result_try!(routing_table.find_preferred_peers_closer_to_key(key, vec![CAP_DHT, CAP_DHT_WATCH])); + let closer_to_key_peers = network_result_try!(routing_table.find_preferred_peers_closer_to_key(key, vec![CAP_DHT])); if debug_target_enabled!("dht") { let debug_string = format!( diff --git a/veilid-core/src/rpc_processor/rpc_inspect_value.rs b/veilid-core/src/rpc_processor/rpc_inspect_value.rs index d68f4585..64188109 100644 --- a/veilid-core/src/rpc_processor/rpc_inspect_value.rs +++ b/veilid-core/src/rpc_processor/rpc_inspect_value.rs @@ -200,7 +200,7 @@ impl RPCProcessor { // Get the nodes that we know about that are closer to the the key than our own node let routing_table = self.routing_table(); - let closer_to_key_peers = network_result_try!(routing_table.find_preferred_peers_closer_to_key(key, vec![CAP_DHT, CAP_DHT_WATCH])); + let closer_to_key_peers = network_result_try!(routing_table.find_preferred_peers_closer_to_key(key, vec![CAP_DHT])); if debug_target_enabled!("dht") { let debug_string = format!( diff --git a/veilid-core/src/rpc_processor/rpc_watch_value.rs b/veilid-core/src/rpc_processor/rpc_watch_value.rs index 4fff8dfc..2a28aca1 100644 --- a/veilid-core/src/rpc_processor/rpc_watch_value.rs +++ b/veilid-core/src/rpc_processor/rpc_watch_value.rs @@ -251,7 +251,7 @@ impl RPCProcessor { // Get the nodes that we know about that are closer to the the key than our own node let closer_to_key_peers = network_result_try!( - routing_table.find_preferred_peers_closer_to_key(key, vec![CAP_DHT, CAP_DHT_WATCH]) + routing_table.find_preferred_peers_closer_to_key(key, vec![CAP_DHT]) ); // See if we would have accepted this as a set, same set_value_count for watches diff --git a/veilid-core/src/storage_manager/get_value.rs b/veilid-core/src/storage_manager/get_value.rs index 111479f0..51d00213 100644 --- a/veilid-core/src/storage_manager/get_value.rs +++ b/veilid-core/src/storage_manager/get_value.rs @@ -174,7 +174,7 @@ impl StorageManager { key_count, fanout, timeout_us, - capability_fanout_node_info_filter(vec![CAP_DHT, CAP_DHT_WATCH]), + capability_fanout_node_info_filter(vec![CAP_DHT]), call_routine, check_done, ); diff --git a/veilid-core/src/storage_manager/set_value.rs b/veilid-core/src/storage_manager/set_value.rs index f21c6375..4d793174 100644 --- a/veilid-core/src/storage_manager/set_value.rs +++ b/veilid-core/src/storage_manager/set_value.rs @@ -159,7 +159,7 @@ impl StorageManager { key_count, fanout, timeout_us, - capability_fanout_node_info_filter(vec![CAP_DHT, CAP_DHT_WATCH]), + capability_fanout_node_info_filter(vec![CAP_DHT]), call_routine, check_done, ); diff --git a/veilid-core/src/storage_manager/watch_value.rs b/veilid-core/src/storage_manager/watch_value.rs index 86b3440d..35874fe0 100644 --- a/veilid-core/src/storage_manager/watch_value.rs +++ b/veilid-core/src/storage_manager/watch_value.rs @@ -50,7 +50,16 @@ impl StorageManager { vec![watch_node] } else { let inner = self.inner.lock().await; - inner.get_value_nodes(key)?.unwrap_or_default() + inner + .get_value_nodes(key)? + .unwrap_or_default() + .into_iter() + .filter(|x| { + x.node_info(RoutingDomain::PublicInternet) + .map(|ni| ni.has_capability(CAP_DHT_WATCH)) + .unwrap_or_default() + }) + .collect() }; // Get the appropriate watcher key, if anonymous use a static anonymous watch key diff --git a/veilid-core/src/veilid_api/debug.rs b/veilid-core/src/veilid_api/debug.rs index 48b3fcc2..2cbcb52d 100644 --- a/veilid-core/src/veilid_api/debug.rs +++ b/veilid-core/src/veilid_api/debug.rs @@ -1602,7 +1602,7 @@ impl VeilidAPI { "subkey", get_number::, )?; - let force_refresh = if args.len() >= 4 { + let force_refresh = if args.len() >= 3 + opt_arg_add { Some(get_debug_argument_at( &args, 2 + opt_arg_add, @@ -1735,7 +1735,7 @@ impl VeilidAPI { }) }; let count = if rest_defaults { - Default::default() + u32::MAX } else { get_debug_argument_at( &args,