2019-04-17 11:28:26 -07:00
|
|
|
pub mod bench;
|
|
|
|
mod cli;
|
|
|
|
pub mod order_book;
|
|
|
|
|
|
|
|
use crate::bench::{airdrop_lamports, do_bench_exchange, Config};
|
|
|
|
use log::*;
|
|
|
|
use solana::cluster_info::FULLNODE_PORT_RANGE;
|
2019-04-18 22:31:25 -07:00
|
|
|
use solana::contact_info::ContactInfo;
|
2019-04-17 11:28:26 -07:00
|
|
|
use solana::gossip_service::discover_nodes;
|
|
|
|
use solana_client::thin_client::create_client;
|
|
|
|
use solana_sdk::signature::KeypairUtil;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
solana_logger::setup();
|
|
|
|
|
|
|
|
let matches = cli::build_args().get_matches();
|
|
|
|
let cli_config = cli::extract_args(&matches);
|
|
|
|
|
|
|
|
let cli::Config {
|
|
|
|
network_addr,
|
|
|
|
drone_addr,
|
|
|
|
identity,
|
|
|
|
threads,
|
|
|
|
num_nodes,
|
|
|
|
duration,
|
|
|
|
trade_delay,
|
|
|
|
fund_amount,
|
|
|
|
batch_size,
|
|
|
|
account_groups,
|
|
|
|
..
|
|
|
|
} = cli_config;
|
|
|
|
|
|
|
|
info!("Connecting to the cluster");
|
|
|
|
let nodes = discover_nodes(&network_addr, num_nodes).unwrap_or_else(|_| {
|
|
|
|
panic!("Failed to discover nodes");
|
|
|
|
});
|
2019-04-19 07:54:21 -07:00
|
|
|
|
|
|
|
let clients: Vec<_> = nodes
|
2019-04-17 11:28:26 -07:00
|
|
|
.iter()
|
2019-04-18 22:31:25 -07:00
|
|
|
.filter_map(|node| {
|
2019-04-17 11:28:26 -07:00
|
|
|
let cluster_entrypoint = node.clone();
|
|
|
|
let cluster_addrs = cluster_entrypoint.client_facing_addr();
|
2019-04-18 22:31:25 -07:00
|
|
|
if ContactInfo::is_valid_address(&cluster_addrs.0)
|
|
|
|
&& ContactInfo::is_valid_address(&cluster_addrs.1)
|
|
|
|
{
|
2019-04-19 07:54:21 -07:00
|
|
|
let client = create_client(cluster_addrs, FULLNODE_PORT_RANGE);
|
|
|
|
Some(client)
|
2019-04-18 22:31:25 -07:00
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
2019-04-17 11:28:26 -07:00
|
|
|
})
|
|
|
|
.collect();
|
|
|
|
|
2019-04-19 07:54:21 -07:00
|
|
|
info!("{} nodes found", clients.len());
|
|
|
|
if clients.len() < num_nodes {
|
2019-04-18 22:31:25 -07:00
|
|
|
panic!("Error: Insufficient nodes discovered");
|
|
|
|
}
|
|
|
|
|
2019-04-17 11:28:26 -07:00
|
|
|
info!("Funding keypair: {}", identity.pubkey());
|
|
|
|
|
|
|
|
let accounts_in_groups = batch_size * account_groups;
|
|
|
|
airdrop_lamports(
|
2019-04-19 07:54:21 -07:00
|
|
|
&clients[0],
|
2019-04-17 11:28:26 -07:00
|
|
|
&drone_addr,
|
|
|
|
&identity,
|
|
|
|
fund_amount * (accounts_in_groups + 1) as u64 * 2,
|
|
|
|
);
|
|
|
|
|
|
|
|
let config = Config {
|
|
|
|
identity,
|
|
|
|
threads,
|
|
|
|
duration,
|
|
|
|
trade_delay,
|
|
|
|
fund_amount,
|
|
|
|
batch_size,
|
|
|
|
account_groups,
|
|
|
|
};
|
|
|
|
|
2019-04-19 07:54:21 -07:00
|
|
|
do_bench_exchange(clients, config);
|
2019-04-17 11:28:26 -07:00
|
|
|
}
|