From e073e91633a91b4da0834a82bd14087dff687fdc Mon Sep 17 00:00:00 2001 From: Karlo <88337245+Rqnsom@users.noreply.github.com> Date: Mon, 10 Jul 2023 13:58:39 +0200 Subject: [PATCH 1/2] chore(synth_node_bin): rt_collector improvements - broadcast a list of tainters every 60 seconds and do it only if the number of connected peers has changed. - increase the number of max connected peers for both rt_collector and rt_s1_tainter --- .../src/action/constantly_ask_for_random_blocks.rs | 1 - synth_node_bin/src/action/rt_s1_collector.rs | 11 ++++++++++- synth_node_bin/src/action/rt_s1_tainter.rs | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/synth_node_bin/src/action/constantly_ask_for_random_blocks.rs b/synth_node_bin/src/action/constantly_ask_for_random_blocks.rs index 1c7e1105..e4912b32 100644 --- a/synth_node_bin/src/action/constantly_ask_for_random_blocks.rs +++ b/synth_node_bin/src/action/constantly_ask_for_random_blocks.rs @@ -6,7 +6,6 @@ use rand::{ rngs::StdRng, SeedableRng, }; -use tokio::time::{sleep, Duration}; use ziggurat_zcash::{ protocol::{ message::Message, diff --git a/synth_node_bin/src/action/rt_s1_collector.rs b/synth_node_bin/src/action/rt_s1_collector.rs index da8116b2..fd3887b2 100644 --- a/synth_node_bin/src/action/rt_s1_collector.rs +++ b/synth_node_bin/src/action/rt_s1_collector.rs @@ -15,7 +15,7 @@ use ziggurat_zcash::{ use super::{ActionCfg, SynthNodeAction}; // Configurable status printout interval. -const BROADCAST_INTERVAL_SEC: Duration = Duration::from_secs(3); +const BROADCAST_INTERVAL_SEC: Duration = Duration::from_secs(60); const DBG_INFO_LOG_INTERVAL_SEC: Duration = Duration::from_secs(10); const MAX_PEER_LIST_LEN: usize = 1000; @@ -38,6 +38,7 @@ impl SynthNodeAction for Action { network_cfg: NodeConfig { listener_ip: Some(IpAddr::V4(Ipv4Addr::UNSPECIFIED)), desired_listening_port: Some(18233), + max_connections: 3000, ..Default::default() }, allow_proper_shutdown: true, @@ -48,6 +49,7 @@ impl SynthNodeAction for Action { async fn run(&self, synth_node: &mut SyntheticNode, addr: Option) -> Result<()> { let mut broadcast_msgs_interval = interval(BROADCAST_INTERVAL_SEC); let mut dbg_info_interval = interval(DBG_INFO_LOG_INTERVAL_SEC); + let mut num_connected = synth_node.num_connected(); loop { tokio::select! { @@ -57,6 +59,13 @@ impl SynthNodeAction for Action { }, // Broadcast an Addr message to all peers. _ = broadcast_msgs_interval.tick() => { + let num_connected_new = synth_node.num_connected(); + + if num_connected == num_connected_new { + continue; + } + + num_connected = num_connected_new; let _ = broadcast_addr_msg(synth_node); }, // Clear inbound queue. diff --git a/synth_node_bin/src/action/rt_s1_tainter.rs b/synth_node_bin/src/action/rt_s1_tainter.rs index 9fdf2f6d..5a64960a 100644 --- a/synth_node_bin/src/action/rt_s1_tainter.rs +++ b/synth_node_bin/src/action/rt_s1_tainter.rs @@ -38,6 +38,7 @@ impl SynthNodeAction for Action { network_cfg: NodeConfig { listener_ip: Some(IpAddr::V4(Ipv4Addr::UNSPECIFIED)), desired_listening_port: Some(8233), + max_connections: 1000, ..Default::default() }, allow_proper_shutdown: true, From 932d6be0efd8bbe9b205f9e2ba321a86c010afb8 Mon Sep 17 00:00:00 2001 From: Karlo <88337245+Rqnsom@users.noreply.github.com> Date: Mon, 10 Jul 2023 14:04:30 +0200 Subject: [PATCH 2/2] chore: latest clippy fixes --- synth_node_bin/src/action/constantly_ask_for_random_blocks.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synth_node_bin/src/action/constantly_ask_for_random_blocks.rs b/synth_node_bin/src/action/constantly_ask_for_random_blocks.rs index e4912b32..12468d48 100644 --- a/synth_node_bin/src/action/constantly_ask_for_random_blocks.rs +++ b/synth_node_bin/src/action/constantly_ask_for_random_blocks.rs @@ -81,7 +81,7 @@ impl SynthNodeAction for Action { min = elapsed; } - avg = avg + elapsed; + avg += elapsed; count += 1;