Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
DoS tool: generate transactions using several threads (#26286)
Browse files Browse the repository at this point in the history
* add cli arg num_gen_threads

* introduce many generating threads

* add sender thread

* add time measurments

* cleanup

* sort dependencies

* revisit threads termination

* make send_batch_size to be configurable

* update Cargo.lock
  • Loading branch information
kirill lykov authored Aug 1, 2022
1 parent ac91577 commit e74ad90
Show file tree
Hide file tree
Showing 4 changed files with 272 additions and 84 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ description = "Tool to send various requests to cluster in order to evaluate the
[dependencies]
bincode = "1.3.3"
clap = { version = "3.1.5", features = ["derive", "cargo"] }
crossbeam-channel = "0.5.4"
itertools = "0.10.3"
log = "0.4.17"
rand = "0.7.0"
Expand All @@ -22,6 +23,7 @@ solana-core = { path = "../core", version = "=1.11.5" }
solana-faucet = { path = "../faucet", version = "=1.11.5" }
solana-gossip = { path = "../gossip", version = "=1.11.5" }
solana-logger = { path = "../logger", version = "=1.11.5" }
solana-measure = { path = "../measure", version = "=1.11.5" }
solana-net-utils = { path = "../net-utils", version = "=1.11.5" }
solana-perf = { path = "../perf", version = "=1.11.5" }
solana-rpc = { path = "../rpc", version = "=1.11.5" }
Expand Down
30 changes: 29 additions & 1 deletion dos/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ pub struct DosClientParameters {
#[clap(long, help = "Allow contacting private ip addresses")]
pub allow_private_addr: bool,

#[clap(
long,
default_value = "1",
help = "Number of threads generating transactions"
)]
pub num_gen_threads: usize,

#[clap(flatten)]
pub transaction_params: TransactionParams,

Expand All @@ -57,9 +64,12 @@ pub struct DosClientParameters {
help = "Submit transactions via QUIC"
)]
pub tpu_use_quic: bool,

#[clap(long, default_value = "16384", help = "Size of the transactions batch")]
pub send_batch_size: usize,
}

#[derive(Args, Serialize, Deserialize, Debug, Default, PartialEq, Eq)]
#[derive(Args, Clone, Serialize, Deserialize, Debug, Default, PartialEq, Eq)]
#[clap(rename_all = "kebab-case")]
pub struct TransactionParams {
#[clap(
Expand Down Expand Up @@ -219,6 +229,8 @@ mod tests {
allow_private_addr: false,
transaction_params: TransactionParams::default(),
tpu_use_quic: false,
num_gen_threads: 1,
send_batch_size: 16384,
},
);
}
Expand All @@ -237,6 +249,8 @@ mod tests {
"--num-signatures",
"8",
"--tpu-use-quic",
"--send-batch-size",
"1",
])
.unwrap();
assert_eq!(
Expand All @@ -249,6 +263,7 @@ mod tests {
data_input: None,
skip_gossip: false,
allow_private_addr: false,
num_gen_threads: 1,
transaction_params: TransactionParams {
num_signatures: Some(8),
valid_blockhash: false,
Expand All @@ -258,6 +273,7 @@ mod tests {
num_instructions: None,
},
tpu_use_quic: true,
send_batch_size: 1,
},
);
}
Expand All @@ -277,6 +293,8 @@ mod tests {
"transfer",
"--num-instructions",
"1",
"--send-batch-size",
"1",
])
.unwrap();
assert_eq!(
Expand All @@ -289,6 +307,7 @@ mod tests {
data_input: None,
skip_gossip: false,
allow_private_addr: false,
num_gen_threads: 1,
transaction_params: TransactionParams {
num_signatures: None,
valid_blockhash: true,
Expand All @@ -298,6 +317,7 @@ mod tests {
num_instructions: Some(1),
},
tpu_use_quic: false,
send_batch_size: 1,
},
);

Expand Down Expand Up @@ -332,6 +352,8 @@ mod tests {
"transfer",
"--num-instructions",
"8",
"--send-batch-size",
"1",
])
.unwrap();
assert_eq!(
Expand All @@ -344,6 +366,7 @@ mod tests {
data_input: None,
skip_gossip: false,
allow_private_addr: false,
num_gen_threads: 1,
transaction_params: TransactionParams {
num_signatures: None,
valid_blockhash: true,
Expand All @@ -353,6 +376,7 @@ mod tests {
num_instructions: Some(8),
},
tpu_use_quic: false,
send_batch_size: 1,
},
);
}
Expand All @@ -370,6 +394,8 @@ mod tests {
"--valid-blockhash",
"--transaction-type",
"account-creation",
"--send-batch-size",
"1",
])
.unwrap();
assert_eq!(
Expand All @@ -382,6 +408,7 @@ mod tests {
data_input: None,
skip_gossip: false,
allow_private_addr: false,
num_gen_threads: 1,
transaction_params: TransactionParams {
num_signatures: None,
valid_blockhash: true,
Expand All @@ -391,6 +418,7 @@ mod tests {
num_instructions: None,
},
tpu_use_quic: false,
send_batch_size: 1,
},
);
}
Expand Down
Loading

0 comments on commit e74ad90

Please sign in to comment.