2018-12-12 11:27:21 -08:00
|
|
|
mod bench;
|
|
|
|
mod cli;
|
2018-11-16 08:45:59 -08:00
|
|
|
|
2019-05-01 13:21:45 -07:00
|
|
|
use crate::bench::{do_bench_tps, generate_and_fund_keypairs, Config, NUM_LAMPORTS_PER_ACCOUNT};
|
2019-05-16 07:14:58 -07:00
|
|
|
use solana::gossip_service::{discover_cluster, get_clients};
|
2019-04-19 14:04:36 -07:00
|
|
|
use std::process::exit;
|
2018-03-04 00:21:40 -08:00
|
|
|
|
2018-02-28 09:07:54 -08:00
|
|
|
fn main() {
|
2018-12-14 12:36:50 -08:00
|
|
|
solana_logger::setup();
|
2018-11-16 08:45:59 -08:00
|
|
|
solana_metrics::set_panic_hook("bench-tps");
|
2018-03-03 20:15:42 -08:00
|
|
|
|
2018-12-12 11:27:21 -08:00
|
|
|
let matches = cli::build_args().get_matches();
|
2019-04-19 14:04:36 -07:00
|
|
|
let cli_config = cli::extract_args(&matches);
|
2018-12-12 11:27:21 -08:00
|
|
|
|
2019-04-19 14:04:36 -07:00
|
|
|
let cli::Config {
|
2019-05-03 15:00:19 -07:00
|
|
|
entrypoint_addr,
|
2019-04-19 14:04:36 -07:00
|
|
|
drone_addr,
|
|
|
|
id,
|
|
|
|
threads,
|
|
|
|
num_nodes,
|
|
|
|
duration,
|
|
|
|
tx_count,
|
|
|
|
thread_batch_sleep_ms,
|
|
|
|
sustained,
|
|
|
|
} = cli_config;
|
2018-12-12 11:27:21 -08:00
|
|
|
|
2019-04-19 14:04:36 -07:00
|
|
|
println!("Connecting to the cluster");
|
2019-05-16 07:14:58 -07:00
|
|
|
let (nodes, _replicators) =
|
|
|
|
discover_cluster(&entrypoint_addr, num_nodes).unwrap_or_else(|err| {
|
|
|
|
eprintln!("Failed to discover {} nodes: {:?}", num_nodes, err);
|
|
|
|
exit(1);
|
|
|
|
});
|
2019-04-19 14:04:36 -07:00
|
|
|
if nodes.len() < num_nodes {
|
|
|
|
eprintln!(
|
|
|
|
"Error: Insufficient nodes discovered. Expecting {} or more",
|
|
|
|
num_nodes
|
|
|
|
);
|
|
|
|
exit(1);
|
|
|
|
}
|
2019-05-01 17:14:01 -07:00
|
|
|
|
|
|
|
let clients = get_clients(&nodes);
|
2019-04-19 14:04:36 -07:00
|
|
|
|
2019-05-01 13:21:45 -07:00
|
|
|
let (keypairs, keypair_balance) = generate_and_fund_keypairs(
|
|
|
|
&clients[0],
|
|
|
|
Some(drone_addr),
|
|
|
|
&id,
|
|
|
|
tx_count,
|
|
|
|
NUM_LAMPORTS_PER_ACCOUNT,
|
|
|
|
);
|
2019-04-19 14:04:36 -07:00
|
|
|
|
|
|
|
let config = Config {
|
|
|
|
id,
|
|
|
|
threads,
|
|
|
|
thread_batch_sleep_ms,
|
|
|
|
duration,
|
|
|
|
tx_count,
|
|
|
|
sustained,
|
|
|
|
};
|
|
|
|
|
2019-05-01 13:21:45 -07:00
|
|
|
do_bench_tps(clients, config, keypairs, keypair_balance);
|
2018-09-06 14:20:01 -07:00
|
|
|
}
|