From 4a104dd3d4df3c312c4458d1e2a38e506b7c3616 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Wed, 27 Mar 2024 13:20:49 -0300 Subject: [PATCH 01/15] fix: spam every target subnet --- crates/topos-certificate-spammer/src/lib.rs | 48 +++++++++++---------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/crates/topos-certificate-spammer/src/lib.rs b/crates/topos-certificate-spammer/src/lib.rs index 4e62dbaab..70b09039f 100644 --- a/crates/topos-certificate-spammer/src/lib.rs +++ b/crates/topos-certificate-spammer/src/lib.rs @@ -312,31 +312,33 @@ pub async fn run( let source_subnet = &mut source_subnets[rand::random::() % args.nb_subnets as usize]; // Randomize number of target subnets if target subnet list cli argument is provided - let target_subnets: Vec = if target_subnet_ids.is_empty() { - // Empty list of target subnets in certificate - Vec::new() - } else { - // Generate random list in size of 0..len(target_subnet_ids) as target subnets - let number_of_target_subnets = - rand::random::() % (target_subnet_ids.len() + 1); - let mut target_subnets = Vec::new(); - for _ in 0..number_of_target_subnets { - target_subnets.push( - target_subnet_ids - [rand::random::() % target_subnet_ids.len()], - ); + // let target_subnets: Vec = if target_subnet_ids.is_empty() { + // // Empty list of target subnets in certificate + // Vec::new() + // } else { + // // Generate random list in size of 0..len(target_subnet_ids) as target subnets + // let number_of_target_subnets = + // rand::random::() % (target_subnet_ids.len() + 1); + // let mut target_subnets = Vec::new(); + // for _ in 0..number_of_target_subnets { + // target_subnets.push( + // target_subnet_ids + // [rand::random::() % target_subnet_ids.len()], + // ); + // } + // target_subnets + // }; + + let new_cert = match generate_test_certificate( + source_subnet, + target_subnet_ids.as_slice(), + ) { + Ok(cert) => cert, + Err(e) => { + error!("Unable to generate certificate: {e}"); + continue; } - target_subnets }; - - let new_cert = - match generate_test_certificate(source_subnet, target_subnets.as_slice()) { - Ok(cert) => cert, - Err(e) => { - error!("Unable to generate certificate: {e}"); - continue; - } - }; debug!("New cert number {b} in batch {batch_number} generated"); batch.push(new_cert); } From eee18892fc2c8fde4edf5962324393e83451af3a Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Wed, 27 Mar 2024 13:44:23 -0300 Subject: [PATCH 02/15] fix: disable synchronizer --- crates/topos-tce/src/app_context.rs | 10 +++++----- crates/topos-tce/src/lib.rs | 26 +++++++++++++------------- crates/topos-test-sdk/src/tce/mod.rs | 4 ++-- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/crates/topos-tce/src/app_context.rs b/crates/topos-tce/src/app_context.rs index fedc50b66..95c1baa6d 100644 --- a/crates/topos-tce/src/app_context.rs +++ b/crates/topos-tce/src/app_context.rs @@ -21,7 +21,7 @@ use topos_tce_storage::store::ReadStore; use topos_tce_storage::types::CertificateDeliveredWithPositions; use topos_tce_storage::validator::ValidatorStore; use topos_tce_storage::StorageClient; -use topos_tce_synchronizer::SynchronizerEvent; +// use topos_tce_synchronizer::SynchronizerEvent; use tracing::{error, info, warn}; mod api; @@ -94,7 +94,7 @@ impl AppContext { mut network_stream: impl Stream + Unpin, mut tce_stream: impl Stream + Unpin, mut api_stream: impl Stream + Unpin, - mut synchronizer_stream: impl Stream + Unpin, + // mut synchronizer_stream: impl Stream + Unpin, mut broadcast_stream: impl Stream + Unpin, shutdown: (CancellationToken, mpsc::Sender<()>), ) { @@ -126,9 +126,9 @@ impl AppContext { self.on_api_event(event).await; } - // Synchronizer events - Some(_event) = synchronizer_stream.next() => { - } + // // Synchronizer events + // Some(_event) = synchronizer_stream.next() => { + // } // Shutdown signal _ = shutdown.0.cancelled() => { diff --git a/crates/topos-tce/src/lib.rs b/crates/topos-tce/src/lib.rs index 42f654dc7..fd3183d3e 100644 --- a/crates/topos-tce/src/lib.rs +++ b/crates/topos-tce/src/lib.rs @@ -151,17 +151,17 @@ pub async fn run( let _network_handle = network_runtime.bootstrap(&mut event_stream).await?; debug!("P2P layer bootstrapped"); - debug!("Creating the Synchronizer"); - - let (synchronizer_runtime, synchronizer_stream) = - topos_tce_synchronizer::Synchronizer::builder() - .with_config(config.synchronization.clone()) - .with_shutdown(shutdown.0.child_token()) - .with_store(validator_store.clone()) - .with_network_client(network_client.clone()) - .build()?; - - debug!("Synchronizer created"); + // debug!("Creating the Synchronizer"); + // + // let (synchronizer_runtime, synchronizer_stream) = + // topos_tce_synchronizer::Synchronizer::builder() + // .with_config(config.synchronization.clone()) + // .with_shutdown(shutdown.0.child_token()) + // .with_store(validator_store.clone()) + // .with_network_client(network_client.clone()) + // .build()?; + // + // debug!("Synchronizer created"); debug!("Starting gRPC api"); let (broadcast_sender, broadcast_receiver) = broadcast::channel(BROADCAST_CHANNEL_SIZE); @@ -203,7 +203,7 @@ pub async fn run( debug!("Reliable broadcast started"); - spawn(synchronizer_runtime.into_future()); + // spawn(synchronizer_runtime.into_future()); // setup transport-tce-storage-api connector let (app_context, _tce_stream) = AppContext::new( is_validator, @@ -220,7 +220,7 @@ pub async fn run( event_stream, tce_stream, api_stream, - synchronizer_stream, + // synchronizer_stream, BroadcastStream::new(broadcast_receiver).filter_map(|v| futures::future::ready(v.ok())), shutdown, )) diff --git a/crates/topos-test-sdk/src/tce/mod.rs b/crates/topos-test-sdk/src/tce/mod.rs index 2faaed193..3e9728b5f 100644 --- a/crates/topos-test-sdk/src/tce/mod.rs +++ b/crates/topos-test-sdk/src/tce/mod.rs @@ -273,7 +273,7 @@ pub async fn start_node( let (gatekeeper_client, gatekeeper_join_handle) = create_gatekeeper().await.unwrap(); - let (synchronizer_stream, synchronizer_join_handle) = create_synchronizer( + let (_synchronizer_stream, synchronizer_join_handle) = create_synchronizer( gatekeeper_client.clone(), network_client.clone(), validator_store.clone(), @@ -302,7 +302,7 @@ pub async fn start_node( network_stream, tce_stream, api_stream, - synchronizer_stream, + // synchronizer_stream, BroadcastStream::new(receiver).filter_map(|v| futures::future::ready(v.ok())), (shutdown_token, shutdown_sender), ) From d7e30cca7e656794fb5df6b4fb5a9bf29fc0f4b2 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Wed, 27 Mar 2024 16:11:04 -0300 Subject: [PATCH 03/15] fix: switch target_subnets to target_hosts --- crates/topos-certificate-spammer/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/topos-certificate-spammer/src/lib.rs b/crates/topos-certificate-spammer/src/lib.rs index 70b09039f..98d150714 100644 --- a/crates/topos-certificate-spammer/src/lib.rs +++ b/crates/topos-certificate-spammer/src/lib.rs @@ -230,9 +230,11 @@ pub async fn run( let mut source_subnets = generate_source_subnets(args.local_key_seed, args.nb_subnets)?; info!("Generated source subnets: {source_subnets:#?}"); + info!("Target hosts: {:?}", args.target_subnets); + // Target subnets (randomly assigned to every generated certificate) let target_subnet_ids: Vec = args - .target_subnets + .target_hosts .iter() .flat_map(|id| { id.iter().map(|id| { From 1eb445b78bb68f0e12ed2152c291978da74ed563 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Wed, 27 Mar 2024 16:11:44 -0300 Subject: [PATCH 04/15] fix: add logging to the spammer command --- crates/topos-certificate-spammer/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/topos-certificate-spammer/src/lib.rs b/crates/topos-certificate-spammer/src/lib.rs index 98d150714..db6569c1b 100644 --- a/crates/topos-certificate-spammer/src/lib.rs +++ b/crates/topos-certificate-spammer/src/lib.rs @@ -230,7 +230,8 @@ pub async fn run( let mut source_subnets = generate_source_subnets(args.local_key_seed, args.nb_subnets)?; info!("Generated source subnets: {source_subnets:#?}"); - info!("Target hosts: {:?}", args.target_subnets); + info!("Target hosts: {:?}", args.target_hosts); + info!("Target subnets: {:?}", args.target_subnets); // Target subnets (randomly assigned to every generated certificate) let target_subnet_ids: Vec = args From 674c2098f0dff5feb395d7ddf92786daeb1e37f6 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Wed, 27 Mar 2024 16:15:09 -0300 Subject: [PATCH 05/15] fix: hosts args for spammer cli --- crates/topos-certificate-spammer/src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/topos-certificate-spammer/src/config.rs b/crates/topos-certificate-spammer/src/config.rs index 0f5f38919..5c9a94739 100644 --- a/crates/topos-certificate-spammer/src/config.rs +++ b/crates/topos-certificate-spammer/src/config.rs @@ -9,6 +9,6 @@ pub struct CertificateSpammerConfig { pub batch_interval: u64, pub target_subnets: Option>, pub benchmark: bool, - pub target_hosts: Option, + pub target_hosts: Option>, pub number: Option, } From dd945f59408c806129d907f57ffb46992339f252 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Wed, 27 Mar 2024 16:38:08 -0300 Subject: [PATCH 06/15] fix: send certs in batch to each connection --- crates/topos-certificate-spammer/src/lib.rs | 50 ++++++++++++--------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/crates/topos-certificate-spammer/src/lib.rs b/crates/topos-certificate-spammer/src/lib.rs index db6569c1b..5c642578e 100644 --- a/crates/topos-certificate-spammer/src/lib.rs +++ b/crates/topos-certificate-spammer/src/lib.rs @@ -315,22 +315,22 @@ pub async fn run( let source_subnet = &mut source_subnets[rand::random::() % args.nb_subnets as usize]; // Randomize number of target subnets if target subnet list cli argument is provided - // let target_subnets: Vec = if target_subnet_ids.is_empty() { - // // Empty list of target subnets in certificate - // Vec::new() - // } else { - // // Generate random list in size of 0..len(target_subnet_ids) as target subnets - // let number_of_target_subnets = - // rand::random::() % (target_subnet_ids.len() + 1); - // let mut target_subnets = Vec::new(); - // for _ in 0..number_of_target_subnets { - // target_subnets.push( - // target_subnet_ids - // [rand::random::() % target_subnet_ids.len()], - // ); - // } - // target_subnets - // }; + let target_subnets: Vec = if target_subnet_ids.is_empty() { + // Empty list of target subnets in certificate + Vec::new() + } else { + // Generate random list in size of 0..len(target_subnet_ids) as target subnets + let number_of_target_subnets = + rand::random::() % (target_subnet_ids.len() + 1); + let mut target_subnets = Vec::new(); + for _ in 0..number_of_target_subnets { + target_subnets.push( + target_subnet_ids + [rand::random::() % target_subnet_ids.len()], + ); + } + target_subnets + }; let new_cert = match generate_test_certificate( source_subnet, @@ -346,15 +346,21 @@ pub async fn run( batch.push(new_cert); } + // Dispatch certs in this batch // Dispatch certs in this batch for cert in batch { // Randomly choose target tce node for every certificate from related source_subnet_id connection list - let target_node_connection = &target_node_connections[&cert.source_subnet_id] - [rand::random::() % target_nodes.len()]; - dispatch(cert, target_node_connection) - .instrument(Span::current()) - .with_current_context() - .await; + // let target_node_connection = &target_node_connections[&cert.source_subnet_id] + // [rand::random::() % target_nodes.len()]; + + for connection in &target_node_connections[&cert.source_subnet_id] { + if !connection.address.is_empty() { + dispatch(cert.clone(), connection) + .instrument(Span::current()) + .with_current_context() + .await; + } + } } } .instrument(span) From 4b0da133280f479c6076c3eb233a5c52cd1b49e0 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Wed, 27 Mar 2024 16:42:27 -0300 Subject: [PATCH 07/15] fix: hosts string --- crates/topos-certificate-spammer/src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/topos-certificate-spammer/src/config.rs b/crates/topos-certificate-spammer/src/config.rs index 5c9a94739..0f5f38919 100644 --- a/crates/topos-certificate-spammer/src/config.rs +++ b/crates/topos-certificate-spammer/src/config.rs @@ -9,6 +9,6 @@ pub struct CertificateSpammerConfig { pub batch_interval: u64, pub target_subnets: Option>, pub benchmark: bool, - pub target_hosts: Option>, + pub target_hosts: Option, pub number: Option, } From 3c20522395eea3dacf3eac290f4adf48a639bd12 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Wed, 27 Mar 2024 16:48:09 -0300 Subject: [PATCH 08/15] fix: typo --- crates/topos-certificate-spammer/src/lib.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/topos-certificate-spammer/src/lib.rs b/crates/topos-certificate-spammer/src/lib.rs index 5c642578e..7a395a44e 100644 --- a/crates/topos-certificate-spammer/src/lib.rs +++ b/crates/topos-certificate-spammer/src/lib.rs @@ -230,12 +230,9 @@ pub async fn run( let mut source_subnets = generate_source_subnets(args.local_key_seed, args.nb_subnets)?; info!("Generated source subnets: {source_subnets:#?}"); - info!("Target hosts: {:?}", args.target_hosts); - info!("Target subnets: {:?}", args.target_subnets); - // Target subnets (randomly assigned to every generated certificate) let target_subnet_ids: Vec = args - .target_hosts + .target_subnets .iter() .flat_map(|id| { id.iter().map(|id| { From 8386f21f7852f5a92881791e40967ae5cefe05fa Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Wed, 27 Mar 2024 16:51:08 -0300 Subject: [PATCH 09/15] fix: typo --- crates/topos-certificate-spammer/src/lib.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/crates/topos-certificate-spammer/src/lib.rs b/crates/topos-certificate-spammer/src/lib.rs index 7a395a44e..2cce2be78 100644 --- a/crates/topos-certificate-spammer/src/lib.rs +++ b/crates/topos-certificate-spammer/src/lib.rs @@ -329,16 +329,14 @@ pub async fn run( target_subnets }; - let new_cert = match generate_test_certificate( - source_subnet, - target_subnet_ids.as_slice(), - ) { - Ok(cert) => cert, - Err(e) => { - error!("Unable to generate certificate: {e}"); - continue; - } - }; + let new_cert = + match generate_test_certificate(source_subnet, target_subnets.as_slice()) { + Ok(cert) => cert, + Err(e) => { + error!("Unable to generate certificate: {e}"); + continue; + } + }; debug!("New cert number {b} in batch {batch_number} generated"); batch.push(new_cert); } From c6adf78ec3c66567531467dce65b819d8d832fa0 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Wed, 27 Mar 2024 17:02:27 -0300 Subject: [PATCH 10/15] fix: add logs --- crates/topos-certificate-spammer/src/lib.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/topos-certificate-spammer/src/lib.rs b/crates/topos-certificate-spammer/src/lib.rs index 2cce2be78..a1c88bfb0 100644 --- a/crates/topos-certificate-spammer/src/lib.rs +++ b/crates/topos-certificate-spammer/src/lib.rs @@ -341,6 +341,7 @@ pub async fn run( batch.push(new_cert); } + info!("Target Node Connections: {target_node_connections:#?}"); // Dispatch certs in this batch // Dispatch certs in this batch for cert in batch { @@ -349,12 +350,10 @@ pub async fn run( // [rand::random::() % target_nodes.len()]; for connection in &target_node_connections[&cert.source_subnet_id] { - if !connection.address.is_empty() { - dispatch(cert.clone(), connection) - .instrument(Span::current()) - .with_current_context() - .await; - } + dispatch(cert.clone(), connection) + .instrument(Span::current()) + .with_current_context() + .await; } } } From 29ac074bac890c2694faeae86c9ca51ef21dc2b5 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Thu, 28 Mar 2024 11:40:01 -0300 Subject: [PATCH 11/15] fix: clippy --- crates/topos-certificate-spammer/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/topos-certificate-spammer/src/lib.rs b/crates/topos-certificate-spammer/src/lib.rs index a1c88bfb0..7adce7014 100644 --- a/crates/topos-certificate-spammer/src/lib.rs +++ b/crates/topos-certificate-spammer/src/lib.rs @@ -340,8 +340,7 @@ pub async fn run( debug!("New cert number {b} in batch {batch_number} generated"); batch.push(new_cert); } - - info!("Target Node Connections: {target_node_connections:#?}"); + // Dispatch certs in this batch // Dispatch certs in this batch for cert in batch { From 71924b1a3a2301cc955a0a1e2dc243913d52d692 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Thu, 28 Mar 2024 15:13:15 -0300 Subject: [PATCH 12/15] fix: add debug log --- crates/topos-certificate-spammer/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/topos-certificate-spammer/src/lib.rs b/crates/topos-certificate-spammer/src/lib.rs index 7adce7014..4914a75af 100644 --- a/crates/topos-certificate-spammer/src/lib.rs +++ b/crates/topos-certificate-spammer/src/lib.rs @@ -340,7 +340,7 @@ pub async fn run( debug!("New cert number {b} in batch {batch_number} generated"); batch.push(new_cert); } - + // Dispatch certs in this batch // Dispatch certs in this batch for cert in batch { @@ -349,6 +349,10 @@ pub async fn run( // [rand::random::() % target_nodes.len()]; for connection in &target_node_connections[&cert.source_subnet_id] { + debug!( + "Sending certificate {cert:?} to target node {}", + connection.address + ); dispatch(cert.clone(), connection) .instrument(Span::current()) .with_current_context() From 942e25c72d156443d7dd65d13b040634de6a6749 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Thu, 28 Mar 2024 15:39:14 -0300 Subject: [PATCH 13/15] fix: changing log level --- crates/topos-certificate-spammer/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/topos-certificate-spammer/src/lib.rs b/crates/topos-certificate-spammer/src/lib.rs index 4914a75af..1d44fe82f 100644 --- a/crates/topos-certificate-spammer/src/lib.rs +++ b/crates/topos-certificate-spammer/src/lib.rs @@ -349,7 +349,7 @@ pub async fn run( // [rand::random::() % target_nodes.len()]; for connection in &target_node_connections[&cert.source_subnet_id] { - debug!( + info!( "Sending certificate {cert:?} to target node {}", connection.address ); From edc0cc4abaeafaff7f6a9d305957de0129a9bb01 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Thu, 28 Mar 2024 15:55:29 -0300 Subject: [PATCH 14/15] fix: typo --- crates/topos-certificate-spammer/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/topos-certificate-spammer/src/lib.rs b/crates/topos-certificate-spammer/src/lib.rs index 1d44fe82f..aa6244f2d 100644 --- a/crates/topos-certificate-spammer/src/lib.rs +++ b/crates/topos-certificate-spammer/src/lib.rs @@ -304,7 +304,7 @@ pub async fn run( number_of_peer_nodes ); async { - info!("Starting batch {batch_number}"); + info!("Start batch {batch_number}"); let mut batch: Vec = Vec::new(); // Certificates for this batch for b in 0..args.cert_per_batch { From 244e3c72abd175b3f3334edb7e2f783ef67ea111 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Thu, 11 Apr 2024 11:25:39 -0300 Subject: [PATCH 15/15] fix: add debug for spammer arguments --- crates/topos-certificate-spammer/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/topos-certificate-spammer/src/lib.rs b/crates/topos-certificate-spammer/src/lib.rs index aa6244f2d..00a237560 100644 --- a/crates/topos-certificate-spammer/src/lib.rs +++ b/crates/topos-certificate-spammer/src/lib.rs @@ -191,6 +191,7 @@ pub async fn run( ) -> Result<(), Error> { // Is list of nodes is specified in the command line use them otherwise use // config file provided nodes + debug!("{:#?}", args); let target_nodes = if args.benchmark { if let (Some(target_hosts), Some(number)) = (args.target_hosts, args.number) { let uri = target_hosts @@ -341,7 +342,6 @@ pub async fn run( batch.push(new_cert); } - // Dispatch certs in this batch // Dispatch certs in this batch for cert in batch { // Randomly choose target tce node for every certificate from related source_subnet_id connection list