add number of signatures to dos
This commit is contained in:
@ -14,6 +14,16 @@ use {
|
|||||||
str::FromStr,
|
str::FromStr,
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
},
|
},
|
||||||
|
// TODO(klykov): maybe later will move to test_tx.rs
|
||||||
|
solana_sdk::{
|
||||||
|
transaction::Transaction,
|
||||||
|
signature::Keypair,
|
||||||
|
hash::Hash,
|
||||||
|
stake,
|
||||||
|
system_program,
|
||||||
|
instruction::CompiledInstruction,
|
||||||
|
system_instruction::SystemInstruction,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fn get_repair_contact(nodes: &[ContactInfo]) -> ContactInfo {
|
fn get_repair_contact(nodes: &[ContactInfo]) -> ContactInfo {
|
||||||
@ -23,6 +33,39 @@ fn get_repair_contact(nodes: &[ContactInfo]) -> ContactInfo {
|
|||||||
contact
|
contact
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_multisig_tx(nsign: usize) -> Transaction {
|
||||||
|
let kpvals: Vec<Keypair> = (0..nsign).map( |_| Keypair::new() ).collect();
|
||||||
|
let keypairs: Vec<&Keypair> = kpvals.iter().collect();
|
||||||
|
|
||||||
|
let lamports = 5;
|
||||||
|
let blockhash = Hash::default();
|
||||||
|
|
||||||
|
let transfer_instruction = SystemInstruction::Transfer { lamports };
|
||||||
|
|
||||||
|
let program_ids = vec![system_program::id(), stake::program::id()];
|
||||||
|
|
||||||
|
let instructions = vec![CompiledInstruction::new(
|
||||||
|
0,
|
||||||
|
&transfer_instruction,
|
||||||
|
vec![0, 1],
|
||||||
|
)];
|
||||||
|
|
||||||
|
let tx = Transaction::new_with_compiled_instructions(
|
||||||
|
&keypairs,
|
||||||
|
&[],
|
||||||
|
blockhash,
|
||||||
|
program_ids,
|
||||||
|
instructions,
|
||||||
|
);
|
||||||
|
tx
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_invalid_multisig_tx(nsign: usize, blockhash: Hash) -> Transaction {
|
||||||
|
let mut tx = test_multisig_tx(nsign, blockhash);
|
||||||
|
tx.signatures = vec![Transaction::get_invalid_signature(); nsign];
|
||||||
|
tx
|
||||||
|
}
|
||||||
|
|
||||||
fn run_dos(
|
fn run_dos(
|
||||||
nodes: &[ContactInfo],
|
nodes: &[ContactInfo],
|
||||||
iterations: usize,
|
iterations: usize,
|
||||||
@ -31,6 +74,7 @@ fn run_dos(
|
|||||||
data_size: usize,
|
data_size: usize,
|
||||||
mode: String,
|
mode: String,
|
||||||
data_input: Option<String>,
|
data_input: Option<String>,
|
||||||
|
num_sign: usize, // makes sense only with transaction mode
|
||||||
) {
|
) {
|
||||||
let mut target = None;
|
let mut target = None;
|
||||||
let mut rpc_client = None;
|
let mut rpc_client = None;
|
||||||
@ -88,7 +132,7 @@ fn run_dos(
|
|||||||
data.resize(data_size, 0);
|
data.resize(data_size, 0);
|
||||||
}
|
}
|
||||||
"transaction" => {
|
"transaction" => {
|
||||||
let tx = solana_perf::test_tx::test_tx();
|
let tx = test_multisig_tx(num_sign);
|
||||||
info!("{:?}", tx);
|
info!("{:?}", tx);
|
||||||
data = bincode::serialize(&tx).unwrap();
|
data = bincode::serialize(&tx).unwrap();
|
||||||
}
|
}
|
||||||
@ -218,6 +262,13 @@ fn main() {
|
|||||||
.help("Allow contacting private ip addresses")
|
.help("Allow contacting private ip addresses")
|
||||||
.hidden(true),
|
.hidden(true),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("num_sign")
|
||||||
|
.long("number-of-signatures")
|
||||||
|
.takes_value(true)
|
||||||
|
.value_name("NSIGN")
|
||||||
|
.help("Number of signatures in transaction"),
|
||||||
|
)
|
||||||
.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));
|
||||||
@ -233,6 +284,7 @@ fn main() {
|
|||||||
let mode = value_t_or_exit!(matches, "mode", String);
|
let mode = value_t_or_exit!(matches, "mode", String);
|
||||||
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 mut nodes = vec![];
|
let mut nodes = vec![];
|
||||||
if !skip_gossip {
|
if !skip_gossip {
|
||||||
@ -266,6 +318,7 @@ fn main() {
|
|||||||
data_size,
|
data_size,
|
||||||
mode,
|
mode,
|
||||||
data_input,
|
data_input,
|
||||||
|
num_sign
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,6 +345,7 @@ pub mod test {
|
|||||||
10,
|
10,
|
||||||
"tvu".to_string(),
|
"tvu".to_string(),
|
||||||
None,
|
None,
|
||||||
|
2,
|
||||||
);
|
);
|
||||||
|
|
||||||
run_dos(
|
run_dos(
|
||||||
@ -302,6 +356,7 @@ pub mod test {
|
|||||||
10,
|
10,
|
||||||
"repair".to_string(),
|
"repair".to_string(),
|
||||||
None,
|
None,
|
||||||
|
2,
|
||||||
);
|
);
|
||||||
|
|
||||||
run_dos(
|
run_dos(
|
||||||
@ -312,6 +367,7 @@ pub mod test {
|
|||||||
10,
|
10,
|
||||||
"serve_repair".to_string(),
|
"serve_repair".to_string(),
|
||||||
None,
|
None,
|
||||||
|
2,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,12 +385,13 @@ pub mod test {
|
|||||||
|
|
||||||
run_dos(
|
run_dos(
|
||||||
&[node],
|
&[node],
|
||||||
10_000_000,
|
10, // 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,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user