From bb1c3dedc05bd36fae39b3ac8b2f14af841146e3 Mon Sep 17 00:00:00 2001 From: klykov Date: Fri, 18 Feb 2022 19:26:06 +0100 Subject: [PATCH 1/3] Fix small problems in transaction-dos tool --- transaction-dos/src/main.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/transaction-dos/src/main.rs b/transaction-dos/src/main.rs index b8693c97c66d5e..315613e38b2f9f 100644 --- a/transaction-dos/src/main.rs +++ b/transaction-dos/src/main.rs @@ -13,6 +13,7 @@ use { commitment_config::CommitmentConfig, instruction::{AccountMeta, Instruction}, message::Message, + packet::PACKET_DATA_SIZE, pubkey::Pubkey, rpc_port::DEFAULT_RPC_PORT, signature::{read_keypair_file, Keypair, Signer}, @@ -174,7 +175,8 @@ fn run_transactions_dos( let program_account = client.get_account(&program_id); - let message = Message::new( + let mut blockhash = client.get_latest_blockhash().expect("blockhash"); + let mut message = Message::new_with_blockhash( &[ Instruction::new_with_bytes( Pubkey::new_unique(), @@ -188,12 +190,12 @@ fn run_transactions_dos( ), ], None, + &blockhash, ); let mut latest_blockhash = Instant::now(); let mut last_log = Instant::now(); let mut count = 0; - let mut blockhash = client.get_latest_blockhash().expect("blockhash"); if just_calculate_fees { let fee = client @@ -267,6 +269,7 @@ fn run_transactions_dos( loop { if latest_blockhash.elapsed().as_secs() > 10 { blockhash = client.get_latest_blockhash().expect("blockhash"); + message.recent_blockhash = blockhash; latest_blockhash = Instant::now(); } @@ -378,7 +381,7 @@ fn run_transactions_dos( let tx = Transaction::new(&signers, message, blockhash); if !tested_size.load(Ordering::Relaxed) { let ser_size = bincode::serialized_size(&tx).unwrap(); - assert!(ser_size < 1200, "{}", ser_size); + assert!(ser_size < PACKET_DATA_SIZE as u64, "{}", ser_size); tested_size.store(true, Ordering::Relaxed); } tx @@ -657,7 +660,7 @@ pub mod test { let tx = Transaction::new(&signers, message, blockhash); let size = bincode::serialized_size(&tx).unwrap(); info!("size:{}", size); - assert!(size < 1200); + assert!(size < PACKET_DATA_SIZE as u64); } #[test] @@ -698,6 +701,7 @@ pub mod test { .collect(); let account_keypair_refs: Vec<_> = account_keypairs.iter().collect(); let mut start = Measure::start("total accounts run"); + run_transactions_dos( cluster.entry_point_info.rpc, faucet_addr, @@ -711,7 +715,11 @@ pub mod test { program_keypair.pubkey(), Some(( program_keypair, - String::from("../programs/bpf/c/out/tuner.so"), + format!( + "{}{}", + env!("CARGO_MANIFEST_DIR"), + "/../programs/bpf/c/out/tuner.so" + ), )), &account_keypair_refs, maybe_account_groups, From 974ff01ad5affe493e73ffcb88ad7bbcf759174d Mon Sep 17 00:00:00 2001 From: klykov Date: Sun, 20 Feb 2022 18:55:17 +0100 Subject: [PATCH 2/3] address pr comments --- transaction-dos/src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/transaction-dos/src/main.rs b/transaction-dos/src/main.rs index 315613e38b2f9f..932fe5a667e27c 100644 --- a/transaction-dos/src/main.rs +++ b/transaction-dos/src/main.rs @@ -132,6 +132,9 @@ fn make_dos_message( Message::new(&instructions, Some(&keypair.pubkey())) } +/// creates large transactions that all touch the same set of accounts, +/// so they can't be parallelized +/// #[allow(clippy::too_many_arguments)] fn run_transactions_dos( entrypoint_addr: SocketAddr, @@ -701,7 +704,6 @@ pub mod test { .collect(); let account_keypair_refs: Vec<_> = account_keypairs.iter().collect(); let mut start = Measure::start("total accounts run"); - run_transactions_dos( cluster.entry_point_info.rpc, faucet_addr, From b73f95d84405be63b367bf685a06ba565a121275 Mon Sep 17 00:00:00 2001 From: klykov Date: Mon, 21 Feb 2022 22:13:07 +0100 Subject: [PATCH 3/3] fmt comments --- transaction-dos/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transaction-dos/src/main.rs b/transaction-dos/src/main.rs index 932fe5a667e27c..393bf2f8d1729b 100644 --- a/transaction-dos/src/main.rs +++ b/transaction-dos/src/main.rs @@ -132,9 +132,9 @@ fn make_dos_message( Message::new(&instructions, Some(&keypair.pubkey())) } -/// creates large transactions that all touch the same set of accounts, +/// creates large transactions that all touch the same set of accounts, /// so they can't be parallelized -/// +/// #[allow(clippy::too_many_arguments)] fn run_transactions_dos( entrypoint_addr: SocketAddr,