(cherry picked from commit b178f3f2d3
)
Co-authored-by: sakridge <sakridge@gmail.com>
This commit is contained in:
@ -12,6 +12,13 @@ use std::process::exit;
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
|
fn get_repair_contact(nodes: &[ContactInfo]) -> ContactInfo {
|
||||||
|
let source = thread_rng().gen_range(0, nodes.len());
|
||||||
|
let mut contact = nodes[source].clone();
|
||||||
|
contact.id = solana_sdk::pubkey::new_rand();
|
||||||
|
contact
|
||||||
|
}
|
||||||
|
|
||||||
fn run_dos(
|
fn run_dos(
|
||||||
nodes: &[ContactInfo],
|
nodes: &[ContactInfo],
|
||||||
iterations: usize,
|
iterations: usize,
|
||||||
@ -56,24 +63,21 @@ fn run_dos(
|
|||||||
|
|
||||||
let mut data = Vec::new();
|
let mut data = Vec::new();
|
||||||
|
|
||||||
if !nodes.is_empty() {
|
|
||||||
let source = thread_rng().gen_range(0, nodes.len());
|
|
||||||
let mut contact = nodes[source].clone();
|
|
||||||
contact.id = solana_sdk::pubkey::new_rand();
|
|
||||||
match data_type.as_str() {
|
match data_type.as_str() {
|
||||||
"repair_highest" => {
|
"repair_highest" => {
|
||||||
let slot = 100;
|
let slot = 100;
|
||||||
let req = RepairProtocol::WindowIndexWithNonce(contact, slot, 0, 0);
|
let req = RepairProtocol::WindowIndexWithNonce(get_repair_contact(nodes), slot, 0, 0);
|
||||||
data = bincode::serialize(&req).unwrap();
|
data = bincode::serialize(&req).unwrap();
|
||||||
}
|
}
|
||||||
"repair_shred" => {
|
"repair_shred" => {
|
||||||
let slot = 100;
|
let slot = 100;
|
||||||
let req = RepairProtocol::HighestWindowIndexWithNonce(contact, slot, 0, 0);
|
let req =
|
||||||
|
RepairProtocol::HighestWindowIndexWithNonce(get_repair_contact(nodes), slot, 0, 0);
|
||||||
data = bincode::serialize(&req).unwrap();
|
data = bincode::serialize(&req).unwrap();
|
||||||
}
|
}
|
||||||
"repair_orphan" => {
|
"repair_orphan" => {
|
||||||
let slot = 100;
|
let slot = 100;
|
||||||
let req = RepairProtocol::OrphanWithNonce(contact, slot, 0);
|
let req = RepairProtocol::OrphanWithNonce(get_repair_contact(nodes), slot, 0);
|
||||||
data = bincode::serialize(&req).unwrap();
|
data = bincode::serialize(&req).unwrap();
|
||||||
}
|
}
|
||||||
"random" => {
|
"random" => {
|
||||||
@ -81,6 +85,7 @@ fn run_dos(
|
|||||||
}
|
}
|
||||||
"transaction" => {
|
"transaction" => {
|
||||||
let tx = solana_perf::test_tx::test_tx();
|
let tx = solana_perf::test_tx::test_tx();
|
||||||
|
info!("{:?}", tx);
|
||||||
data = bincode::serialize(&tx).unwrap();
|
data = bincode::serialize(&tx).unwrap();
|
||||||
}
|
}
|
||||||
"get_account_info" => {}
|
"get_account_info" => {}
|
||||||
@ -89,7 +94,6 @@ fn run_dos(
|
|||||||
panic!("unknown data type");
|
panic!("unknown data type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let mut last_log = Instant::now();
|
let mut last_log = Instant::now();
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
|
Reference in New Issue
Block a user