add valid blockhash option to dos
This commit is contained in:
@ -33,13 +33,11 @@ fn get_repair_contact(nodes: &[ContactInfo]) -> ContactInfo {
|
|||||||
contact
|
contact
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_multisig_tx(nsign: usize) -> Transaction {
|
fn test_multisig_tx(nsign: usize, blockhash: Hash) -> Transaction {
|
||||||
let kpvals: Vec<Keypair> = (0..nsign).map( |_| Keypair::new() ).collect();
|
let kpvals: Vec<Keypair> = (0..nsign).map( |_| Keypair::new() ).collect();
|
||||||
let keypairs: Vec<&Keypair> = kpvals.iter().collect();
|
let keypairs: Vec<&Keypair> = kpvals.iter().collect();
|
||||||
|
|
||||||
let lamports = 5;
|
let lamports = 5;
|
||||||
let blockhash = Hash::default();
|
|
||||||
|
|
||||||
let transfer_instruction = SystemInstruction::Transfer { lamports };
|
let transfer_instruction = SystemInstruction::Transfer { lamports };
|
||||||
|
|
||||||
let program_ids = vec![system_program::id(), stake::program::id()];
|
let program_ids = vec![system_program::id(), stake::program::id()];
|
||||||
@ -75,6 +73,7 @@ fn run_dos(
|
|||||||
mode: String,
|
mode: String,
|
||||||
data_input: Option<String>,
|
data_input: Option<String>,
|
||||||
num_sign: usize, // makes sense only with transaction mode
|
num_sign: usize, // makes sense only with transaction mode
|
||||||
|
valid_block_hash: bool, // makes sense only with transaction mode
|
||||||
) {
|
) {
|
||||||
let mut target = None;
|
let mut target = None;
|
||||||
let mut rpc_client = None;
|
let mut rpc_client = None;
|
||||||
@ -90,7 +89,10 @@ fn run_dos(
|
|||||||
"gossip" => Some(node.gossip),
|
"gossip" => Some(node.gossip),
|
||||||
"tvu" => Some(node.tvu),
|
"tvu" => Some(node.tvu),
|
||||||
"tvu_forwards" => Some(node.tvu_forwards),
|
"tvu_forwards" => Some(node.tvu_forwards),
|
||||||
"tpu" => Some(node.tpu),
|
"tpu" => {
|
||||||
|
rpc_client = Some(RpcClient::new_socket(node.rpc));
|
||||||
|
Some(node.tpu)
|
||||||
|
},
|
||||||
"tpu_forwards" => Some(node.tpu_forwards),
|
"tpu_forwards" => Some(node.tpu_forwards),
|
||||||
"repair" => Some(node.repair),
|
"repair" => Some(node.repair),
|
||||||
"serve_repair" => Some(node.serve_repair),
|
"serve_repair" => Some(node.serve_repair),
|
||||||
@ -132,7 +134,12 @@ fn run_dos(
|
|||||||
data.resize(data_size, 0);
|
data.resize(data_size, 0);
|
||||||
}
|
}
|
||||||
"transaction" => {
|
"transaction" => {
|
||||||
let tx = test_multisig_tx(num_sign);
|
let blockhash = if valid_block_hash {
|
||||||
|
rpc_client.as_ref().unwrap().get_latest_blockhash().unwrap()
|
||||||
|
} else {
|
||||||
|
Hash::default()
|
||||||
|
};
|
||||||
|
let tx = test_multisig_tx(num_sign, blockhash);
|
||||||
info!("{:?}", tx);
|
info!("{:?}", tx);
|
||||||
data = bincode::serialize(&tx).unwrap();
|
data = bincode::serialize(&tx).unwrap();
|
||||||
}
|
}
|
||||||
@ -269,6 +276,13 @@ fn main() {
|
|||||||
.value_name("NSIGN")
|
.value_name("NSIGN")
|
||||||
.help("Number of signatures in transaction"),
|
.help("Number of signatures in transaction"),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("valid_blockhash")
|
||||||
|
.long("generate-valid-blockhash")
|
||||||
|
.takes_value(false)
|
||||||
|
.help("Generate a valid blockhash for transaction")
|
||||||
|
.hidden(true),
|
||||||
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
let mut entrypoint_addr = SocketAddr::from(([127, 0, 0, 1], 8001));
|
let mut entrypoint_addr = SocketAddr::from(([127, 0, 0, 1], 8001));
|
||||||
@ -285,6 +299,7 @@ fn main() {
|
|||||||
let data_type = value_t_or_exit!(matches, "data_type", String);
|
let data_type = value_t_or_exit!(matches, "data_type", String);
|
||||||
let data_input = value_t!(matches, "data_input", String).ok();
|
let data_input = value_t!(matches, "data_input", String).ok();
|
||||||
let num_sign = value_t!(matches, "num_sign", usize).unwrap_or(2);
|
let num_sign = value_t!(matches, "num_sign", usize).unwrap_or(2);
|
||||||
|
let valid_blockhash = matches.is_present("valid_blockhash");
|
||||||
|
|
||||||
let mut nodes = vec![];
|
let mut nodes = vec![];
|
||||||
if !skip_gossip {
|
if !skip_gossip {
|
||||||
@ -318,7 +333,8 @@ fn main() {
|
|||||||
data_size,
|
data_size,
|
||||||
mode,
|
mode,
|
||||||
data_input,
|
data_input,
|
||||||
num_sign
|
num_sign,
|
||||||
|
valid_blockhash,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,6 +362,7 @@ pub mod test {
|
|||||||
"tvu".to_string(),
|
"tvu".to_string(),
|
||||||
None,
|
None,
|
||||||
2,
|
2,
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
run_dos(
|
run_dos(
|
||||||
@ -357,6 +374,7 @@ pub mod test {
|
|||||||
"repair".to_string(),
|
"repair".to_string(),
|
||||||
None,
|
None,
|
||||||
2,
|
2,
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
run_dos(
|
run_dos(
|
||||||
@ -368,6 +386,7 @@ pub mod test {
|
|||||||
"serve_repair".to_string(),
|
"serve_repair".to_string(),
|
||||||
None,
|
None,
|
||||||
2,
|
2,
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,13 +404,14 @@ pub mod test {
|
|||||||
|
|
||||||
run_dos(
|
run_dos(
|
||||||
&[node],
|
&[node],
|
||||||
10, // was 10_000_000
|
1, // was 10_000_000
|
||||||
cluster.entry_point_info.gossip,
|
cluster.entry_point_info.gossip,
|
||||||
"transaction".to_string(),
|
"transaction".to_string(),
|
||||||
1000,
|
1000,
|
||||||
"tpu".to_string(),
|
"tpu".to_string(),
|
||||||
None,
|
None,
|
||||||
3,
|
3,
|
||||||
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user