Add --use_move mode to bench-tps (#5311)
* Add --use_move mode to bench-tps substitute for global flag. * Use cuda queue for coverage build.
This commit is contained in:
parent
a642168369
commit
4f1c881227
|
@ -37,8 +37,6 @@ pub enum BenchTpsError {
|
||||||
AirdropFailure,
|
AirdropFailure,
|
||||||
}
|
}
|
||||||
|
|
||||||
const USE_MOVE: bool = false;
|
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, BenchTpsError>;
|
pub type Result<T> = std::result::Result<T, BenchTpsError>;
|
||||||
|
|
||||||
pub type SharedTransactions = Arc<RwLock<VecDeque<Vec<(Transaction, u64)>>>>;
|
pub type SharedTransactions = Arc<RwLock<VecDeque<Vec<(Transaction, u64)>>>>;
|
||||||
|
@ -50,6 +48,7 @@ pub struct Config {
|
||||||
pub duration: Duration,
|
pub duration: Duration,
|
||||||
pub tx_count: usize,
|
pub tx_count: usize,
|
||||||
pub sustained: bool,
|
pub sustained: bool,
|
||||||
|
pub use_move: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
|
@ -61,6 +60,7 @@ impl Default for Config {
|
||||||
duration: Duration::new(std::u64::MAX, 0),
|
duration: Duration::new(std::u64::MAX, 0),
|
||||||
tx_count: 500_000,
|
tx_count: 500_000,
|
||||||
sustained: false,
|
sustained: false,
|
||||||
|
use_move: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,7 @@ where
|
||||||
thread_batch_sleep_ms,
|
thread_batch_sleep_ms,
|
||||||
duration,
|
duration,
|
||||||
tx_count,
|
tx_count,
|
||||||
|
use_move,
|
||||||
sustained,
|
sustained,
|
||||||
} = config;
|
} = config;
|
||||||
|
|
||||||
|
@ -174,6 +175,7 @@ where
|
||||||
&keypairs[len..],
|
&keypairs[len..],
|
||||||
threads,
|
threads,
|
||||||
reclaim_lamports_back_to_source_account,
|
reclaim_lamports_back_to_source_account,
|
||||||
|
use_move,
|
||||||
&program_id,
|
&program_id,
|
||||||
&libra_mint_id,
|
&libra_mint_id,
|
||||||
);
|
);
|
||||||
|
@ -239,7 +241,8 @@ fn generate_txs(
|
||||||
dest: &[Keypair],
|
dest: &[Keypair],
|
||||||
threads: usize,
|
threads: usize,
|
||||||
reclaim: bool,
|
reclaim: bool,
|
||||||
program_id: &Pubkey,
|
use_move: bool,
|
||||||
|
libra_pay_program_id: &Pubkey,
|
||||||
libra_mint_id: &Pubkey,
|
libra_mint_id: &Pubkey,
|
||||||
) {
|
) {
|
||||||
let tx_count = source.len();
|
let tx_count = source.len();
|
||||||
|
@ -254,10 +257,10 @@ fn generate_txs(
|
||||||
let transactions: Vec<_> = pairs
|
let transactions: Vec<_> = pairs
|
||||||
.par_iter()
|
.par_iter()
|
||||||
.map(|(id, keypair)| {
|
.map(|(id, keypair)| {
|
||||||
if USE_MOVE {
|
if use_move {
|
||||||
(
|
(
|
||||||
librapay_transaction::transfer(
|
librapay_transaction::transfer(
|
||||||
program_id,
|
libra_pay_program_id,
|
||||||
libra_mint_id,
|
libra_mint_id,
|
||||||
&id,
|
&id,
|
||||||
&id,
|
&id,
|
||||||
|
@ -611,7 +614,11 @@ fn should_switch_directions(num_lamports_per_account: u64, i: u64) -> bool {
|
||||||
i % (num_lamports_per_account / 4) == 0 && (i >= (3 * num_lamports_per_account) / 4)
|
i % (num_lamports_per_account / 4) == 0 && (i >= (3 * num_lamports_per_account) / 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn generate_keypairs(seed_keypair: &Keypair, count: u64) -> (Vec<Keypair>, u64) {
|
pub fn generate_keypairs(
|
||||||
|
seed_keypair: &Keypair,
|
||||||
|
count: u64,
|
||||||
|
use_move: bool,
|
||||||
|
) -> (Vec<Keypair>, u64) {
|
||||||
let mut seed = [0u8; 32];
|
let mut seed = [0u8; 32];
|
||||||
seed.copy_from_slice(&seed_keypair.to_bytes()[..32]);
|
seed.copy_from_slice(&seed_keypair.to_bytes()[..32]);
|
||||||
let mut rnd = GenKeys::new(seed);
|
let mut rnd = GenKeys::new(seed);
|
||||||
|
@ -624,7 +631,7 @@ pub fn generate_keypairs(seed_keypair: &Keypair, count: u64) -> (Vec<Keypair>, u
|
||||||
delta *= MAX_SPENDS_PER_TX;
|
delta *= MAX_SPENDS_PER_TX;
|
||||||
total_keys += delta;
|
total_keys += delta;
|
||||||
}
|
}
|
||||||
if USE_MOVE {
|
if use_move {
|
||||||
// Move funding is a naive loop that doesn't
|
// Move funding is a naive loop that doesn't
|
||||||
// need aligned number of keys.
|
// need aligned number of keys.
|
||||||
(rnd.gen_n_keypairs(count), extra)
|
(rnd.gen_n_keypairs(count), extra)
|
||||||
|
@ -762,10 +769,11 @@ pub fn generate_and_fund_keypairs<T: Client>(
|
||||||
funding_key: &Keypair,
|
funding_key: &Keypair,
|
||||||
tx_count: usize,
|
tx_count: usize,
|
||||||
lamports_per_account: u64,
|
lamports_per_account: u64,
|
||||||
libra_keys: Option<(&Pubkey, &Pubkey, &Keypair)>,
|
libra_keys: Option<(&Pubkey, &Pubkey, &Arc<Keypair>)>,
|
||||||
) -> Result<(Vec<Keypair>, u64)> {
|
) -> Result<(Vec<Keypair>, u64)> {
|
||||||
info!("Creating {} keypairs...", tx_count * 2);
|
info!("Creating {} keypairs...", tx_count * 2);
|
||||||
let (mut keypairs, extra) = generate_keypairs(funding_key, tx_count as u64 * 2);
|
let (mut keypairs, extra) =
|
||||||
|
generate_keypairs(funding_key, tx_count as u64 * 2, libra_keys.is_some());
|
||||||
info!("Get lamports...");
|
info!("Get lamports...");
|
||||||
|
|
||||||
// Sample the first keypair, see if it has lamports, if so then resume.
|
// Sample the first keypair, see if it has lamports, if so then resume.
|
||||||
|
@ -783,8 +791,7 @@ pub fn generate_and_fund_keypairs<T: Client>(
|
||||||
if client.get_balance(&funding_key.pubkey()).unwrap_or(0) < total {
|
if client.get_balance(&funding_key.pubkey()).unwrap_or(0) < total {
|
||||||
airdrop_lamports(client, &drone_addr.unwrap(), funding_key, total)?;
|
airdrop_lamports(client, &drone_addr.unwrap(), funding_key, total)?;
|
||||||
}
|
}
|
||||||
if USE_MOVE {
|
if let Some((libra_pay_program_id, libra_mint_program_id, libra_mint_key)) = libra_keys {
|
||||||
let (libra_pay_program_id, libra_mint_program_id, libra_mint_key) = libra_keys.unwrap();
|
|
||||||
fund_move_keys(
|
fund_move_keys(
|
||||||
client,
|
client,
|
||||||
funding_key,
|
funding_key,
|
||||||
|
@ -843,8 +850,7 @@ mod tests {
|
||||||
assert_eq!(should_switch_directions(20, 101), false);
|
assert_eq!(should_switch_directions(20, 101), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
fn test_bench_tps_local_cluster(config: Config) {
|
||||||
fn test_bench_tps_local_cluster() {
|
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
const NUM_NODES: usize = 1;
|
const NUM_NODES: usize = 1;
|
||||||
let cluster = LocalCluster::new(&ClusterConfig {
|
let cluster = LocalCluster::new(&ClusterConfig {
|
||||||
|
@ -866,7 +872,7 @@ mod tests {
|
||||||
FULLNODE_PORT_RANGE,
|
FULLNODE_PORT_RANGE,
|
||||||
);
|
);
|
||||||
|
|
||||||
let (libra_mint_id, libra_pay_program_id) = if USE_MOVE {
|
let (libra_mint_id, libra_pay_program_id) = if config.use_move {
|
||||||
let libra_mint_id = upload_mint_program(&drone_keypair, &client);
|
let libra_mint_id = upload_mint_program(&drone_keypair, &client);
|
||||||
let libra_pay_program_id = upload_payment_program(&drone_keypair, &client);
|
let libra_pay_program_id = upload_payment_program(&drone_keypair, &client);
|
||||||
(libra_mint_id, libra_pay_program_id)
|
(libra_mint_id, libra_pay_program_id)
|
||||||
|
@ -878,23 +884,25 @@ mod tests {
|
||||||
run_local_drone(drone_keypair, addr_sender, None);
|
run_local_drone(drone_keypair, addr_sender, None);
|
||||||
let drone_addr = addr_receiver.recv_timeout(Duration::from_secs(2)).unwrap();
|
let drone_addr = addr_receiver.recv_timeout(Duration::from_secs(2)).unwrap();
|
||||||
|
|
||||||
let mut config = Config::default();
|
|
||||||
config.tx_count = 100;
|
|
||||||
config.duration = Duration::from_secs(10);
|
|
||||||
|
|
||||||
let lamports_per_account = 100;
|
let lamports_per_account = 100;
|
||||||
|
|
||||||
|
let libra_keys = if config.use_move {
|
||||||
|
Some((
|
||||||
|
&libra_pay_program_id,
|
||||||
|
&libra_mint_id,
|
||||||
|
&cluster.libra_mint_keypair,
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
let (keypairs, _keypair_balance) = generate_and_fund_keypairs(
|
let (keypairs, _keypair_balance) = generate_and_fund_keypairs(
|
||||||
&client,
|
&client,
|
||||||
Some(drone_addr),
|
Some(drone_addr),
|
||||||
&config.id,
|
&config.id,
|
||||||
config.tx_count,
|
config.tx_count,
|
||||||
lamports_per_account,
|
lamports_per_account,
|
||||||
Some((
|
libra_keys,
|
||||||
&libra_pay_program_id,
|
|
||||||
&libra_mint_id,
|
|
||||||
&cluster.libra_mint_keypair,
|
|
||||||
)),
|
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -909,6 +917,26 @@ mod tests {
|
||||||
assert!(total > 100);
|
assert!(total > 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_bench_tps_local_cluster_solana() {
|
||||||
|
let mut config = Config::default();
|
||||||
|
config.tx_count = 100;
|
||||||
|
config.duration = Duration::from_secs(10);
|
||||||
|
|
||||||
|
test_bench_tps_local_cluster(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[ignore]
|
||||||
|
fn test_bench_tps_local_cluster_move() {
|
||||||
|
let mut config = Config::default();
|
||||||
|
config.tx_count = 100;
|
||||||
|
config.duration = Duration::from_secs(10);
|
||||||
|
config.use_move = true;
|
||||||
|
|
||||||
|
test_bench_tps_local_cluster(config);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_bench_tps_bank_client() {
|
fn test_bench_tps_bank_client() {
|
||||||
let (genesis_block, id) = create_genesis_block(10_000);
|
let (genesis_block, id) = create_genesis_block(10_000);
|
||||||
|
|
|
@ -22,6 +22,7 @@ pub struct Config {
|
||||||
pub write_to_client_file: bool,
|
pub write_to_client_file: bool,
|
||||||
pub read_from_client_file: bool,
|
pub read_from_client_file: bool,
|
||||||
pub target_lamports_per_signature: u64,
|
pub target_lamports_per_signature: u64,
|
||||||
|
pub use_move: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
|
@ -40,6 +41,7 @@ impl Default for Config {
|
||||||
write_to_client_file: false,
|
write_to_client_file: false,
|
||||||
read_from_client_file: false,
|
read_from_client_file: false,
|
||||||
target_lamports_per_signature: FeeCalculator::default().target_lamports_per_signature,
|
target_lamports_per_signature: FeeCalculator::default().target_lamports_per_signature,
|
||||||
|
use_move: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,6 +102,11 @@ pub fn build_args<'a, 'b>() -> App<'a, 'b> {
|
||||||
.long("sustained")
|
.long("sustained")
|
||||||
.help("Use sustained performance mode vs. peak mode. This overlaps the tx generation with transfers."),
|
.help("Use sustained performance mode vs. peak mode. This overlaps the tx generation with transfers."),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("use-move")
|
||||||
|
.long("use-move")
|
||||||
|
.help("Use Move language transactions to perform transfers."),
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("tx_count")
|
Arg::with_name("tx_count")
|
||||||
.long("tx_count")
|
.long("tx_count")
|
||||||
|
@ -211,5 +218,7 @@ pub fn extract_args<'a>(matches: &ArgMatches<'a>) -> Config {
|
||||||
args.target_lamports_per_signature = v.to_string().parse().expect("can't parse lamports");
|
args.target_lamports_per_signature = v.to_string().parse().expect("can't parse lamports");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
args.use_move = matches.is_present("use-move");
|
||||||
|
|
||||||
args
|
args
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,11 @@ fn main() {
|
||||||
write_to_client_file,
|
write_to_client_file,
|
||||||
read_from_client_file,
|
read_from_client_file,
|
||||||
target_lamports_per_signature,
|
target_lamports_per_signature,
|
||||||
|
use_move,
|
||||||
} = cli_config;
|
} = cli_config;
|
||||||
|
|
||||||
if write_to_client_file {
|
if write_to_client_file {
|
||||||
let (keypairs, _) = generate_keypairs(&id, tx_count as u64 * 2);
|
let (keypairs, _) = generate_keypairs(&id, tx_count as u64 * 2, use_move);
|
||||||
let num_accounts = keypairs.len() as u64;
|
let num_accounts = keypairs.len() as u64;
|
||||||
let max_fee = FeeCalculator::new(target_lamports_per_signature).max_lamports_per_signature;
|
let max_fee = FeeCalculator::new(target_lamports_per_signature).max_lamports_per_signature;
|
||||||
let num_lamports_per_account = (num_accounts - 1 + NUM_SIGNATURES_FOR_TXS * max_fee)
|
let num_lamports_per_account = (num_accounts - 1 + NUM_SIGNATURES_FOR_TXS * max_fee)
|
||||||
|
@ -119,6 +120,7 @@ fn main() {
|
||||||
duration,
|
duration,
|
||||||
tx_count,
|
tx_count,
|
||||||
sustained,
|
sustained,
|
||||||
|
use_move,
|
||||||
};
|
};
|
||||||
|
|
||||||
do_bench_tps(
|
do_bench_tps(
|
||||||
|
|
|
@ -22,6 +22,8 @@ steps:
|
||||||
- command: ". ci/rust-version.sh; ci/docker-run.sh $$rust_nightly_docker_image ci/test-coverage.sh"
|
- command: ". ci/rust-version.sh; ci/docker-run.sh $$rust_nightly_docker_image ci/test-coverage.sh"
|
||||||
name: "coverage"
|
name: "coverage"
|
||||||
timeout_in_minutes: 40
|
timeout_in_minutes: 40
|
||||||
|
agents:
|
||||||
|
- "queue=cuda"
|
||||||
# TODO: Fix and re-enable test-large-network.sh
|
# TODO: Fix and re-enable test-large-network.sh
|
||||||
# - command: "ci/test-large-network.sh || true"
|
# - command: "ci/test-large-network.sh || true"
|
||||||
# name: "large-network [ignored]"
|
# name: "large-network [ignored]"
|
||||||
|
|
Loading…
Reference in New Issue