|
|
@@ -61,10 +61,7 @@ pub fn poll_slot_height(client: &RpcClient) -> Slot {
|
|
|
return slot;
|
|
|
} else {
|
|
|
num_retries -= 1;
|
|
|
- warn!(
|
|
|
- "get_slot_height failure: {:?}. remaining retries {}",
|
|
|
- response, num_retries
|
|
|
- );
|
|
|
+ warn!("get_slot_height failure: {response:?}. remaining retries {num_retries}");
|
|
|
}
|
|
|
if num_retries == 0 {
|
|
|
panic!("failed to get_slot_height(), rpc node down?")
|
|
|
@@ -81,10 +78,7 @@ pub fn poll_get_latest_blockhash(client: &RpcClient) -> Option<Hash> {
|
|
|
return Some(blockhash);
|
|
|
} else {
|
|
|
num_retries -= 1;
|
|
|
- warn!(
|
|
|
- "get_latest_blockhash failure: {:?}. remaining retries {}",
|
|
|
- response, num_retries
|
|
|
- );
|
|
|
+ warn!("get_latest_blockhash failure: {response:?}. remaining retries {num_retries}");
|
|
|
}
|
|
|
if num_retries == 0 {
|
|
|
panic!("failed to get_latest_blockhash(), rpc node down?")
|
|
|
@@ -102,10 +96,7 @@ pub fn poll_get_fee_for_message(client: &RpcClient, message: &mut Message) -> (O
|
|
|
return (Some(fee), message.recent_blockhash);
|
|
|
} else {
|
|
|
num_retries -= 1;
|
|
|
- warn!(
|
|
|
- "get_fee_for_message failure: {:?}. remaining retries {}",
|
|
|
- response, num_retries
|
|
|
- );
|
|
|
+ warn!("get_fee_for_message failure: {response:?}. remaining retries {num_retries}");
|
|
|
|
|
|
let blockhash = poll_get_latest_blockhash(client).expect("blockhash");
|
|
|
message.recent_blockhash = blockhash;
|
|
|
@@ -119,7 +110,7 @@ pub fn poll_get_fee_for_message(client: &RpcClient, message: &mut Message) -> (O
|
|
|
|
|
|
fn airdrop_lamports(client: &RpcClient, id: &Keypair, desired_balance: u64) -> bool {
|
|
|
let starting_balance = client.get_balance(&id.pubkey()).unwrap_or(0);
|
|
|
- info!("starting balance {}", starting_balance);
|
|
|
+ info!("starting balance {starting_balance}");
|
|
|
|
|
|
if starting_balance < desired_balance {
|
|
|
let airdrop_amount = desired_balance - starting_balance;
|
|
|
@@ -143,7 +134,7 @@ fn airdrop_lamports(client: &RpcClient, id: &Keypair, desired_balance: u64) -> b
|
|
|
let current_balance = client.get_balance(&id.pubkey()).unwrap_or_else(|e| {
|
|
|
panic!("airdrop error {e}");
|
|
|
});
|
|
|
- info!("current balance {}...", current_balance);
|
|
|
+ info!("current balance {current_balance}...");
|
|
|
|
|
|
if current_balance - starting_balance != airdrop_amount {
|
|
|
info!(
|
|
|
@@ -396,10 +387,10 @@ fn process_get_multiple_accounts(
|
|
|
stats.total_errors_time_us += rpc_time.as_us();
|
|
|
stats.errors += 1;
|
|
|
if last_error.elapsed().as_secs() > 2 {
|
|
|
- info!("error: {:?}", e);
|
|
|
+ info!("error: {e:?}");
|
|
|
*last_error = Instant::now();
|
|
|
}
|
|
|
- debug!("error: {:?}", e);
|
|
|
+ debug!("error: {e:?}");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -519,7 +510,7 @@ fn run_rpc_bench_loop(
|
|
|
stats.total_errors_time_us += rpc_time.as_us();
|
|
|
stats.errors += 1;
|
|
|
if last_error.elapsed().as_secs() > 2 {
|
|
|
- info!("get_account_info error: {:?}", e);
|
|
|
+ info!("get_account_info error: {e:?}");
|
|
|
last_error = Instant::now();
|
|
|
}
|
|
|
}
|
|
|
@@ -545,7 +536,7 @@ fn run_rpc_bench_loop(
|
|
|
stats.total_errors_time_us += rpc_time.as_us();
|
|
|
stats.errors += 1;
|
|
|
if last_error.elapsed().as_secs() > 2 {
|
|
|
- info!("get_block error: {:?}", e);
|
|
|
+ info!("get_block error: {e:?}");
|
|
|
last_error = Instant::now();
|
|
|
}
|
|
|
}
|
|
|
@@ -569,7 +560,7 @@ fn run_rpc_bench_loop(
|
|
|
stats.total_errors_time_us += rpc_time.as_us();
|
|
|
stats.errors += 1;
|
|
|
if last_error.elapsed().as_secs() > 2 {
|
|
|
- info!("get_blocks error: {:?}", e);
|
|
|
+ info!("get_blocks error: {e:?}");
|
|
|
last_error = Instant::now();
|
|
|
}
|
|
|
}
|
|
|
@@ -588,7 +579,7 @@ fn run_rpc_bench_loop(
|
|
|
stats.total_errors_time_us += rpc_time.as_us();
|
|
|
stats.errors += 1;
|
|
|
if last_error.elapsed().as_secs() > 2 {
|
|
|
- info!("get_first_available_block error: {:?}", e);
|
|
|
+ info!("get_first_available_block error: {e:?}");
|
|
|
last_error = Instant::now();
|
|
|
}
|
|
|
}
|
|
|
@@ -607,7 +598,7 @@ fn run_rpc_bench_loop(
|
|
|
stats.total_errors_time_us += rpc_time.as_us();
|
|
|
stats.errors += 1;
|
|
|
if last_error.elapsed().as_secs() > 2 {
|
|
|
- info!("get_slot error: {:?}", e);
|
|
|
+ info!("get_slot error: {e:?}");
|
|
|
last_error = Instant::now();
|
|
|
}
|
|
|
}
|
|
|
@@ -626,7 +617,7 @@ fn run_rpc_bench_loop(
|
|
|
stats.total_errors_time_us += rpc_time.as_us();
|
|
|
stats.errors += 1;
|
|
|
if last_error.elapsed().as_secs() > 2 {
|
|
|
- info!("get_token_supply error: {:?}", e);
|
|
|
+ info!("get_token_supply error: {e:?}");
|
|
|
last_error = Instant::now();
|
|
|
}
|
|
|
}
|
|
|
@@ -659,7 +650,7 @@ fn run_rpc_bench_loop(
|
|
|
stats.errors += 1;
|
|
|
stats.total_errors_time_us += rpc_time.as_us();
|
|
|
if last_error.elapsed().as_secs() > 2 {
|
|
|
- info!("get-program-accounts error: {:?}", e);
|
|
|
+ info!("get-program-accounts error: {e:?}");
|
|
|
last_error = Instant::now();
|
|
|
}
|
|
|
}
|
|
|
@@ -679,7 +670,7 @@ fn run_rpc_bench_loop(
|
|
|
stats.errors += 1;
|
|
|
stats.total_errors_time_us += rpc_time.as_us();
|
|
|
if last_error.elapsed().as_secs() > 2 {
|
|
|
- info!("get-token-accounts-by-delegate error: {:?}", e);
|
|
|
+ info!("get-token-accounts-by-delegate error: {e:?}");
|
|
|
last_error = Instant::now();
|
|
|
}
|
|
|
}
|
|
|
@@ -699,7 +690,7 @@ fn run_rpc_bench_loop(
|
|
|
stats.errors += 1;
|
|
|
stats.total_errors_time_us += rpc_time.as_us();
|
|
|
if last_error.elapsed().as_secs() > 2 {
|
|
|
- info!("get-token-accounts-by-owner error: {:?}", e);
|
|
|
+ info!("get-token-accounts-by-owner error: {e:?}");
|
|
|
last_error = Instant::now();
|
|
|
}
|
|
|
}
|
|
|
@@ -781,7 +772,7 @@ fn make_rpc_bench_threads(
|
|
|
let transaction_signature_tracker = transaction_signature_tracker.clone();
|
|
|
let mint = *mint;
|
|
|
Builder::new()
|
|
|
- .name(format!("rpc-bench-{}", thread))
|
|
|
+ .name(format!("rpc-bench-{thread}"))
|
|
|
.spawn(move || {
|
|
|
start_bench.wait();
|
|
|
run_rpc_bench_loop(
|
|
|
@@ -853,7 +844,7 @@ fn run_accounts_bench(
|
|
|
let transaction_signature_tracker =
|
|
|
TransactionSignatureTracker(Arc::new(RwLock::new(VecDeque::with_capacity(5000))));
|
|
|
|
|
|
- info!("Starting balance(s): {:?}", balances);
|
|
|
+ info!("Starting balance(s): {balances:?}");
|
|
|
|
|
|
let executor = TransactionExecutor::new_with_rpc_client(client.clone());
|
|
|
|
|
|
@@ -917,10 +908,7 @@ fn run_accounts_bench(
|
|
|
}
|
|
|
last_balance = Instant::now();
|
|
|
if *balance < lamports * 2 {
|
|
|
- info!(
|
|
|
- "Balance {} is less than needed: {}, doing airdrop...",
|
|
|
- balance, lamports
|
|
|
- );
|
|
|
+ info!("Balance {balance} is less than needed: {lamports}, doing airdrop...");
|
|
|
if !airdrop_lamports(&client, payer_keypairs[i], lamports * 100_000) {
|
|
|
warn!("failed airdrop, exiting");
|
|
|
return;
|
|
|
@@ -934,7 +922,7 @@ fn run_accounts_bench(
|
|
|
if sigs_len < batch_size {
|
|
|
let num_to_create = batch_size - sigs_len;
|
|
|
if num_to_create >= payer_keypairs.len() {
|
|
|
- info!("creating {} new", num_to_create);
|
|
|
+ info!("creating {num_to_create} new");
|
|
|
let chunk_size = num_to_create / payer_keypairs.len();
|
|
|
if chunk_size > 0 {
|
|
|
for (i, keypair) in payer_keypairs.iter().enumerate() {
|
|
|
@@ -1018,8 +1006,9 @@ fn run_accounts_bench(
|
|
|
|| max_accounts_met
|
|
|
{
|
|
|
info!(
|
|
|
- "total_accounts_created: {} total_accounts_closed: {} tx_sent_count: {} loop_count: {} balance(s): {:?}",
|
|
|
- total_accounts_created, total_accounts_closed, tx_sent_count, count, balances
|
|
|
+ "total_accounts_created: {total_accounts_created} total_accounts_closed: \
|
|
|
+ {total_accounts_closed} tx_sent_count: {tx_sent_count} loop_count: {count} \
|
|
|
+ balance(s): {balances:?}"
|
|
|
);
|
|
|
last_log = Instant::now();
|
|
|
}
|
|
|
@@ -1061,9 +1050,9 @@ fn run_accounts_bench(
|
|
|
(max_created_seed - max_closed_seed) as usize,
|
|
|
);
|
|
|
if num_to_close >= payer_keypairs.len() {
|
|
|
- info!("closing {} accounts", num_to_close);
|
|
|
+ info!("closing {num_to_close} accounts");
|
|
|
let chunk_size = num_to_close / payer_keypairs.len();
|
|
|
- info!("{:?} chunk_size", chunk_size);
|
|
|
+ info!("{chunk_size:?} chunk_size");
|
|
|
if chunk_size > 0 {
|
|
|
for (i, keypair) in payer_keypairs.iter().enumerate() {
|
|
|
let txs: Vec<_> = (0..chunk_size)
|
|
|
@@ -1101,8 +1090,8 @@ fn run_accounts_bench(
|
|
|
count += 1;
|
|
|
if last_log.elapsed().as_millis() > 3000 || max_closed_seed >= max_created_seed {
|
|
|
info!(
|
|
|
- "total_accounts_closed: {} tx_sent_count: {} loop_count: {} balance(s): {:?}",
|
|
|
- total_accounts_closed, tx_sent_count, count, balances
|
|
|
+ "total_accounts_closed: {total_accounts_closed} tx_sent_count: \
|
|
|
+ {tx_sent_count} loop_count: {count} balance(s): {balances:?}"
|
|
|
);
|
|
|
last_log = Instant::now();
|
|
|
}
|
|
|
@@ -1150,8 +1139,8 @@ fn main() {
|
|
|
.validator(is_url_or_moniker)
|
|
|
.conflicts_with("entrypoint")
|
|
|
.help(
|
|
|
- "URL for Solana's JSON RPC or moniker (or their first letter): \
|
|
|
- [mainnet-beta, testnet, devnet, localhost]",
|
|
|
+ "URL for Solana's JSON RPC or moniker (or their first letter): [mainnet-beta, \
|
|
|
+ testnet, devnet, localhost]",
|
|
|
),
|
|
|
)
|
|
|
.arg(
|
|
|
@@ -1206,10 +1195,9 @@ fn main() {
|
|
|
.takes_value(true)
|
|
|
.value_name("BYTES")
|
|
|
.help(
|
|
|
- "Every `n` batches, create a batch of close transactions for \
|
|
|
- the earliest remaining batch of accounts created. \
|
|
|
- Note: Should be > 1 to avoid situations where the close \
|
|
|
- transactions will be submitted before the corresponding \
|
|
|
+ "Every `n` batches, create a batch of close transactions for the earliest \
|
|
|
+ remaining batch of accounts created. Note: Should be > 1 to avoid situations \
|
|
|
+ where the close transactions will be submitted before the corresponding \
|
|
|
create transactions have been confirmed",
|
|
|
),
|
|
|
)
|
|
|
@@ -1232,7 +1220,10 @@ fn main() {
|
|
|
.long("max-accounts")
|
|
|
.takes_value(true)
|
|
|
.value_name("NUM_ACCOUNTS")
|
|
|
- .help("Halt after client has created this number of accounts. Does not count closed accounts."),
|
|
|
+ .help(
|
|
|
+ "Halt after client has created this number of accounts. Does not count closed \
|
|
|
+ accounts.",
|
|
|
+ ),
|
|
|
)
|
|
|
.arg(
|
|
|
Arg::with_name("check_gossip")
|
|
|
@@ -1273,10 +1264,7 @@ fn main() {
|
|
|
.takes_value(true)
|
|
|
.value_name("RPC_BENCH_TYPE(S)")
|
|
|
.multiple(true)
|
|
|
- .requires_ifs(&[
|
|
|
- ("supply", "mint"),
|
|
|
- ("token-accounts-by-owner", "mint"),
|
|
|
- ])
|
|
|
+ .requires_ifs(&[("supply", "mint"), ("token-accounts-by-owner", "mint")])
|
|
|
.help("Spawn a thread which calls a specific RPC method in a loop to benchmark it"),
|
|
|
)
|
|
|
.get_matches();
|
|
|
@@ -1333,7 +1321,7 @@ fn main() {
|
|
|
Some(
|
|
|
solana_net_utils::get_cluster_shred_version(&entrypoint_addr).unwrap_or_else(
|
|
|
|err| {
|
|
|
- eprintln!("Failed to get shred version: {}", err);
|
|
|
+ eprintln!("Failed to get shred version: {err}");
|
|
|
exit(1);
|
|
|
},
|
|
|
),
|
|
|
@@ -1344,7 +1332,7 @@ fn main() {
|
|
|
};
|
|
|
|
|
|
let rpc_addr = if !skip_gossip {
|
|
|
- info!("Finding cluster entry: {:?}", entrypoint_addr);
|
|
|
+ info!("Finding cluster entry: {entrypoint_addr:?}");
|
|
|
let (gossip_nodes, _validators) = discover(
|
|
|
None, // keypair
|
|
|
Some(&entrypoint_addr),
|
|
|
@@ -1364,7 +1352,7 @@ fn main() {
|
|
|
info!("done found {} nodes", gossip_nodes.len());
|
|
|
gossip_nodes[0].rpc().unwrap()
|
|
|
} else {
|
|
|
- info!("Using {:?} as the RPC address", entrypoint_addr);
|
|
|
+ info!("Using {entrypoint_addr:?} as the RPC address");
|
|
|
entrypoint_addr
|
|
|
};
|
|
|
|
|
|
@@ -1498,7 +1486,7 @@ pub mod test {
|
|
|
);
|
|
|
let post_txs = client.get_transaction_count().unwrap();
|
|
|
start.stop();
|
|
|
- info!("{} pre {} post {}", start, pre_txs, post_txs);
|
|
|
+ info!("{start} pre {pre_txs} post {post_txs}");
|
|
|
}
|
|
|
|
|
|
#[test]
|
|
|
@@ -1548,7 +1536,7 @@ pub mod test {
|
|
|
);
|
|
|
let post_txs = client.get_transaction_count().unwrap();
|
|
|
start.stop();
|
|
|
- info!("{} pre {} post {}", start, pre_txs, post_txs);
|
|
|
+ info!("{start} pre {pre_txs} post {post_txs}");
|
|
|
}
|
|
|
|
|
|
#[test]
|
|
|
@@ -1643,6 +1631,6 @@ pub mod test {
|
|
|
0,
|
|
|
);
|
|
|
start.stop();
|
|
|
- info!("{}", start);
|
|
|
+ info!("{start}");
|
|
|
}
|
|
|
}
|