From 1cab6b71ebab9d682102d8e72f9b85f6995c89b9 Mon Sep 17 00:00:00 2001 From: Steven Luscher Date: Sat, 7 Dec 2024 01:44:56 -0500 Subject: [PATCH] The accounts cluster benchmark can once again create token accounts to test `getTokenAccountsByOwner` (#3965) --- accounts-cluster-bench/src/main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/accounts-cluster-bench/src/main.rs b/accounts-cluster-bench/src/main.rs index ff8d4151b0206d..1fc3c0474ddbc4 100644 --- a/accounts-cluster-bench/src/main.rs +++ b/accounts-cluster-bench/src/main.rs @@ -19,12 +19,14 @@ use { hash::Hash, instruction::{AccountMeta, Instruction}, message::Message, + program_pack::Pack, pubkey::Pubkey, signature::{read_keypair_file, Keypair, Signer}, system_instruction, system_program, transaction::Transaction, }, solana_streamer::socket::SocketAddrSpace, + spl_token::state::Account, std::{ cmp::min, process::exit, @@ -139,7 +141,11 @@ fn make_create_message( maybe_space: Option, mint: Option, ) -> Message { - let space = maybe_space.unwrap_or_else(|| thread_rng().gen_range(0..1000)); + let space = if mint.is_some() { + Account::get_packed_len() as u64 + } else { + maybe_space.unwrap_or_else(|| thread_rng().gen_range(0..1000)) + }; let instructions: Vec<_> = (0..num_instructions) .flat_map(|_| { @@ -860,6 +866,7 @@ fn main() { .long("space") .takes_value(true) .value_name("BYTES") + .conflicts_with("mint") .help("Size of accounts to create"), ) .arg(