bench-tps: Transition to using spl-instruction-padding (#28496)
* bench-tps: Transition to using spl-instruction-padding * Use macros for conversions
This commit is contained in:
parent
340d3b5468
commit
9d7e999c1d
|
@ -4716,6 +4716,7 @@ dependencies = [
|
|||
"solana-thin-client",
|
||||
"solana-tpu-client",
|
||||
"solana-version",
|
||||
"spl-instruction-padding",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
|
@ -5184,9 +5185,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-frozen-abi"
|
||||
version = "1.11.5"
|
||||
version = "1.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28e4e35bc58c465f161bde764ebce41fdfcb503583cf3a77e0211274cc12b22d"
|
||||
checksum = "3f07a997db3dac7b9da06b007d4a8df6dbd8281182e6ebbbd8a56f935f540b0a"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"blake3",
|
||||
|
@ -5211,7 +5212,7 @@ dependencies = [
|
|||
"serde_derive",
|
||||
"serde_json",
|
||||
"sha2 0.10.5",
|
||||
"solana-frozen-abi-macro 1.11.5",
|
||||
"solana-frozen-abi-macro 1.14.5",
|
||||
"subtle",
|
||||
"thiserror",
|
||||
]
|
||||
|
@ -5251,9 +5252,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-frozen-abi-macro"
|
||||
version = "1.11.5"
|
||||
version = "1.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "708f837d748e574b1e53b250ab1f4a69ba330bbc10d041d02381165f0f36291a"
|
||||
checksum = "dcd7d529da0fa5b3b5ca71645122fc94c2aaf867744497969c109e1d4b8ad02d"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.41",
|
||||
"quote 1.0.18",
|
||||
|
@ -5577,9 +5578,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-logger"
|
||||
version = "1.11.5"
|
||||
version = "1.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7ea6fc68d63d33d862d919d4c8ad7f613ec243ccf6762d595c660020b289b57"
|
||||
checksum = "c690a6ae623bdd2d71229880a9f668ff714b5c6a9bc180a1abef4887da8b6f27"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"lazy_static",
|
||||
|
@ -5753,9 +5754,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-program"
|
||||
version = "1.11.5"
|
||||
version = "1.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bdd314d85b171bb20ccdcaf07346a9d52a012b10d84f4706f0628813d002fef8"
|
||||
checksum = "f835be7a20e172209538241cdf46451c08b38eaaca65cf16e65658700c447b17"
|
||||
dependencies = [
|
||||
"base64 0.13.0",
|
||||
"bincode",
|
||||
|
@ -5791,9 +5792,9 @@ dependencies = [
|
|||
"serde_json",
|
||||
"sha2 0.10.5",
|
||||
"sha3 0.10.4",
|
||||
"solana-frozen-abi 1.11.5",
|
||||
"solana-frozen-abi-macro 1.11.5",
|
||||
"solana-sdk-macro 1.11.5",
|
||||
"solana-frozen-abi 1.14.5",
|
||||
"solana-frozen-abi-macro 1.14.5",
|
||||
"solana-sdk-macro 1.14.5",
|
||||
"thiserror",
|
||||
"tiny-bip39",
|
||||
"wasm-bindgen",
|
||||
|
@ -6179,9 +6180,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-sdk"
|
||||
version = "1.11.5"
|
||||
version = "1.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad7d954df63b267857e26670e3aacfd8e2943ca703653b0418e5afc85046c2f3"
|
||||
checksum = "f74e8d699c3a441a5b0cd94c718e75b25c1a4295c2180a714b12fb1bcf66a51e"
|
||||
dependencies = [
|
||||
"assert_matches",
|
||||
"base64 0.13.0",
|
||||
|
@ -6218,11 +6219,11 @@ dependencies = [
|
|||
"serde_json",
|
||||
"sha2 0.10.5",
|
||||
"sha3 0.10.4",
|
||||
"solana-frozen-abi 1.11.5",
|
||||
"solana-frozen-abi-macro 1.11.5",
|
||||
"solana-logger 1.11.5",
|
||||
"solana-program 1.11.5",
|
||||
"solana-sdk-macro 1.11.5",
|
||||
"solana-frozen-abi 1.14.5",
|
||||
"solana-frozen-abi-macro 1.14.5",
|
||||
"solana-logger 1.14.5",
|
||||
"solana-program 1.14.5",
|
||||
"solana-sdk-macro 1.14.5",
|
||||
"thiserror",
|
||||
"uriparse",
|
||||
"wasm-bindgen",
|
||||
|
@ -6285,9 +6286,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-sdk-macro"
|
||||
version = "1.11.5"
|
||||
version = "1.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d0d9e81bc46edcc517b2df504856d57a5101c7586ec63f3143ae11fbe2eba613"
|
||||
checksum = "92ffde9b5b7313629780baca10eaffec7421d53be725c76031ca409a5298705c"
|
||||
dependencies = [
|
||||
"bs58",
|
||||
"proc-macro2 1.0.41",
|
||||
|
@ -6759,9 +6760,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "solana-zk-token-sdk"
|
||||
version = "1.11.5"
|
||||
version = "1.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62415c05a9ebfffaf8befaa61b24492ebf88269cf84cbeba714bac4125ec4ea3"
|
||||
checksum = "0a23a2c443027e8cc2981131a38928cb37e554970c497b5735e888049cc85d3f"
|
||||
dependencies = [
|
||||
"aes-gcm-siv",
|
||||
"arrayref",
|
||||
|
@ -6772,6 +6773,7 @@ dependencies = [
|
|||
"cipher 0.4.3",
|
||||
"curve25519-dalek",
|
||||
"getrandom 0.1.16",
|
||||
"itertools",
|
||||
"lazy_static",
|
||||
"merlin",
|
||||
"num-derive",
|
||||
|
@ -6780,8 +6782,8 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_json",
|
||||
"sha3 0.9.1",
|
||||
"solana-program 1.11.5",
|
||||
"solana-sdk 1.11.5",
|
||||
"solana-program 1.14.5",
|
||||
"solana-sdk 1.14.5",
|
||||
"subtle",
|
||||
"thiserror",
|
||||
"zeroize",
|
||||
|
@ -6866,19 +6868,29 @@ dependencies = [
|
|||
"borsh",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"solana-program 1.11.5",
|
||||
"solana-program 1.14.5",
|
||||
"spl-token",
|
||||
"spl-token-2022",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spl-instruction-padding"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c5557ec281a34f7f9053feb6e0d795162ba0c6a52898b21c3d1e899481191d5"
|
||||
dependencies = [
|
||||
"num_enum",
|
||||
"solana-program 1.14.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spl-memo"
|
||||
version = "3.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd0dc6f70db6bacea7ff25870b016a65ba1d1b6013536f08e4fd79a8f9005325"
|
||||
dependencies = [
|
||||
"solana-program 1.11.5",
|
||||
"solana-program 1.14.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -6892,7 +6904,7 @@ dependencies = [
|
|||
"num-derive",
|
||||
"num-traits",
|
||||
"num_enum",
|
||||
"solana-program 1.11.5",
|
||||
"solana-program 1.14.5",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
|
@ -6907,8 +6919,8 @@ dependencies = [
|
|||
"num-derive",
|
||||
"num-traits",
|
||||
"num_enum",
|
||||
"solana-program 1.11.5",
|
||||
"solana-zk-token-sdk 1.11.5",
|
||||
"solana-program 1.14.5",
|
||||
"solana-zk-token-sdk 1.14.5",
|
||||
"spl-memo",
|
||||
"spl-token",
|
||||
"thiserror",
|
||||
|
|
|
@ -37,6 +37,7 @@ solana-streamer = { path = "../streamer", version = "=1.15.0" }
|
|||
solana-thin-client = { path = "../thin-client", version = "=1.15.0" }
|
||||
solana-tpu-client = { path = "../tpu-client", version = "=1.15.0", default-features = false }
|
||||
solana-version = { path = "../version", version = "=1.15.0" }
|
||||
spl-instruction-padding = "0.1"
|
||||
thiserror = "1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use {
|
||||
crate::{
|
||||
bench_tps_client::*,
|
||||
cli::Config,
|
||||
inline_instruction_padding_program::{create_padded_instruction, InstructionPaddingConfig},
|
||||
cli::{Config, InstructionPaddingConfig},
|
||||
perf_utils::{sample_txs, SampleStats},
|
||||
send_batch::*,
|
||||
spl_convert::FromOtherSolana,
|
||||
},
|
||||
log::*,
|
||||
rand::distributions::{Distribution, Uniform},
|
||||
|
@ -25,6 +25,7 @@ use {
|
|||
timing::{duration_as_ms, duration_as_s, duration_as_us, timestamp},
|
||||
transaction::Transaction,
|
||||
},
|
||||
spl_instruction_padding::instruction::wrap_instruction,
|
||||
std::{
|
||||
collections::{HashSet, VecDeque},
|
||||
process::exit,
|
||||
|
@ -552,13 +553,15 @@ fn transfer_with_compute_unit_price_and_padding(
|
|||
let from_pubkey = from_keypair.pubkey();
|
||||
let transfer_instruction = system_instruction::transfer(&from_pubkey, to, lamports);
|
||||
let instruction = if let Some(instruction_padding_config) = instruction_padding_config {
|
||||
create_padded_instruction(
|
||||
instruction_padding_config.program_id,
|
||||
transfer_instruction,
|
||||
vec![],
|
||||
instruction_padding_config.data_size,
|
||||
FromOtherSolana::from(
|
||||
wrap_instruction(
|
||||
FromOtherSolana::from(instruction_padding_config.program_id),
|
||||
FromOtherSolana::from(transfer_instruction),
|
||||
vec![],
|
||||
instruction_padding_config.data_size,
|
||||
)
|
||||
.expect("Could not create padded instruction"),
|
||||
)
|
||||
.expect("Could not create padded instruction")
|
||||
} else {
|
||||
transfer_instruction
|
||||
};
|
||||
|
@ -645,13 +648,15 @@ fn nonced_transfer_with_padding(
|
|||
let from_pubkey = from_keypair.pubkey();
|
||||
let transfer_instruction = system_instruction::transfer(&from_pubkey, to, lamports);
|
||||
let instruction = if let Some(instruction_padding_config) = instruction_padding_config {
|
||||
create_padded_instruction(
|
||||
instruction_padding_config.program_id,
|
||||
transfer_instruction,
|
||||
vec![],
|
||||
instruction_padding_config.data_size,
|
||||
FromOtherSolana::from(
|
||||
wrap_instruction(
|
||||
FromOtherSolana::from(instruction_padding_config.program_id),
|
||||
FromOtherSolana::from(transfer_instruction),
|
||||
vec![],
|
||||
instruction_padding_config.data_size,
|
||||
)
|
||||
.expect("Could not create padded instruction"),
|
||||
)
|
||||
.expect("Could not create padded instruction")
|
||||
} else {
|
||||
transfer_instruction
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use {
|
||||
crate::inline_instruction_padding_program::{self, InstructionPaddingConfig},
|
||||
crate::spl_convert::FromOtherSolana,
|
||||
clap::{crate_description, crate_name, App, Arg, ArgMatches},
|
||||
solana_clap_utils::input_validators::{is_url, is_url_or_moniker},
|
||||
solana_cli_config::{ConfigInput, CONFIG_FILE},
|
||||
|
@ -31,6 +31,11 @@ impl Default for ExternalClientType {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct InstructionPaddingConfig {
|
||||
pub program_id: Pubkey,
|
||||
pub data_size: u32,
|
||||
}
|
||||
|
||||
/// Holds the configuration for a single run of the benchmark
|
||||
pub struct Config {
|
||||
pub entrypoint_addr: SocketAddr,
|
||||
|
@ -477,7 +482,7 @@ pub fn extract_args(matches: &ArgMatches) -> Config {
|
|||
let program_id = matches
|
||||
.value_of("instruction_padding_program_id")
|
||||
.map(|target_str| target_str.parse().unwrap())
|
||||
.unwrap_or(inline_instruction_padding_program::ID);
|
||||
.unwrap_or_else(|| FromOtherSolana::from(spl_instruction_padding::ID));
|
||||
args.instruction_padding_config = Some(InstructionPaddingConfig {
|
||||
program_id,
|
||||
data_size: data_size
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
use {
|
||||
solana_sdk::{
|
||||
declare_id,
|
||||
instruction::{AccountMeta, Instruction},
|
||||
program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
syscalls::{MAX_CPI_ACCOUNT_INFOS, MAX_CPI_INSTRUCTION_DATA_LEN},
|
||||
},
|
||||
std::{convert::TryInto, mem::size_of},
|
||||
};
|
||||
|
||||
pub struct InstructionPaddingConfig {
|
||||
pub program_id: Pubkey,
|
||||
pub data_size: u32,
|
||||
}
|
||||
|
||||
declare_id!("iXpADd6AW1k5FaaXum5qHbSqyd7TtoN6AD7suVa83MF");
|
||||
|
||||
pub fn create_padded_instruction(
|
||||
program_id: Pubkey,
|
||||
instruction: Instruction,
|
||||
padding_accounts: Vec<AccountMeta>,
|
||||
padding_data: u32,
|
||||
) -> Result<Instruction, ProgramError> {
|
||||
// The format for instruction data goes:
|
||||
// * 1 byte for the instruction type
|
||||
// * 4 bytes for the number of accounts required
|
||||
// * 4 bytes for the size of the data required
|
||||
// * the actual instruction data
|
||||
// * additional bytes are all padding
|
||||
let data_size = size_of::<u8>()
|
||||
+ size_of::<u32>()
|
||||
+ size_of::<u32>()
|
||||
+ instruction.data.len()
|
||||
+ padding_data as usize;
|
||||
// crude, but can find a potential issue right away
|
||||
if instruction.data.len() > MAX_CPI_INSTRUCTION_DATA_LEN as usize {
|
||||
return Err(ProgramError::InvalidInstructionData);
|
||||
}
|
||||
let mut data = Vec::with_capacity(data_size);
|
||||
data.push(1);
|
||||
let num_accounts: u32 = instruction
|
||||
.accounts
|
||||
.len()
|
||||
.try_into()
|
||||
.map_err(|_| ProgramError::InvalidInstructionData)?;
|
||||
data.extend(num_accounts.to_le_bytes().into_iter());
|
||||
|
||||
let data_size: u32 = instruction
|
||||
.data
|
||||
.len()
|
||||
.try_into()
|
||||
.map_err(|_| ProgramError::InvalidInstructionData)?;
|
||||
data.extend(data_size.to_le_bytes().into_iter());
|
||||
data.extend(instruction.data.into_iter());
|
||||
for i in 0..padding_data {
|
||||
data.push((i % u8::MAX as u32) as u8);
|
||||
}
|
||||
|
||||
// The format for account data goes:
|
||||
// * accounts required for the CPI
|
||||
// * program account to call into
|
||||
// * additional accounts may be included as padding or to test loading / locks
|
||||
let num_accounts = instruction.accounts.len() + 1 + padding_accounts.len();
|
||||
if num_accounts > MAX_CPI_ACCOUNT_INFOS {
|
||||
return Err(ProgramError::InvalidAccountData);
|
||||
}
|
||||
let mut accounts = Vec::with_capacity(num_accounts);
|
||||
accounts.extend(instruction.accounts.into_iter());
|
||||
accounts.push(AccountMeta::new_readonly(instruction.program_id, false));
|
||||
accounts.extend(padding_accounts.into_iter());
|
||||
|
||||
Ok(Instruction {
|
||||
program_id,
|
||||
accounts,
|
||||
data,
|
||||
})
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
pub mod bench;
|
||||
pub mod bench_tps_client;
|
||||
pub mod cli;
|
||||
pub mod inline_instruction_padding_program;
|
||||
pub mod keypairs;
|
||||
mod perf_utils;
|
||||
pub mod send_batch;
|
||||
pub mod spl_convert;
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
use {
|
||||
solana_sdk::{
|
||||
instruction::{AccountMeta, Instruction},
|
||||
pubkey::Pubkey,
|
||||
},
|
||||
spl_instruction_padding::solana_program::{
|
||||
instruction::{AccountMeta as SplAccountMeta, Instruction as SplInstruction},
|
||||
pubkey::Pubkey as SplPubkey,
|
||||
},
|
||||
};
|
||||
|
||||
pub trait FromOtherSolana<T> {
|
||||
fn from(_: T) -> Self;
|
||||
}
|
||||
|
||||
macro_rules! impl_pubkey_conversion {
|
||||
($S:ty, $L:ty) => {
|
||||
impl FromOtherSolana<$S> for $L {
|
||||
fn from(pubkey: $S) -> Self {
|
||||
Self::new_from_array(pubkey.to_bytes())
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
impl_pubkey_conversion!(SplPubkey, Pubkey);
|
||||
impl_pubkey_conversion!(Pubkey, SplPubkey);
|
||||
|
||||
macro_rules! impl_account_meta_conversion {
|
||||
($S:ty, $L:ty) => {
|
||||
impl FromOtherSolana<$S> for $L {
|
||||
fn from(meta: $S) -> Self {
|
||||
Self {
|
||||
pubkey: FromOtherSolana::from(meta.pubkey),
|
||||
is_signer: meta.is_signer,
|
||||
is_writable: meta.is_writable,
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
impl_account_meta_conversion!(SplAccountMeta, AccountMeta);
|
||||
impl_account_meta_conversion!(AccountMeta, SplAccountMeta);
|
||||
|
||||
macro_rules! impl_instruction_conversion {
|
||||
($S: ty, $L:ty) => {
|
||||
impl FromOtherSolana<$S> for $L {
|
||||
fn from(instruction: $S) -> Self {
|
||||
Self {
|
||||
program_id: FromOtherSolana::from(instruction.program_id),
|
||||
accounts: instruction
|
||||
.accounts
|
||||
.into_iter()
|
||||
.map(|meta| FromOtherSolana::from(meta))
|
||||
.collect(),
|
||||
data: instruction.data,
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
impl_instruction_conversion!(SplInstruction, Instruction);
|
||||
impl_instruction_conversion!(Instruction, SplInstruction);
|
|
@ -4,9 +4,9 @@ use {
|
|||
serial_test::serial,
|
||||
solana_bench_tps::{
|
||||
bench::{do_bench_tps, generate_and_fund_keypairs},
|
||||
cli::Config,
|
||||
inline_instruction_padding_program::{self, InstructionPaddingConfig},
|
||||
cli::{Config, InstructionPaddingConfig},
|
||||
send_batch::generate_durable_nonce_accounts,
|
||||
spl_convert::FromOtherSolana,
|
||||
},
|
||||
solana_core::validator::ValidatorConfig,
|
||||
solana_faucet::faucet::run_local_faucet,
|
||||
|
@ -46,7 +46,7 @@ fn program_account(program_data: &[u8]) -> AccountSharedData {
|
|||
fn test_bench_tps_local_cluster(config: Config) {
|
||||
let native_instruction_processors = vec![];
|
||||
let additional_accounts = vec![(
|
||||
inline_instruction_padding_program::id(),
|
||||
FromOtherSolana::from(spl_instruction_padding::ID),
|
||||
program_account(include_bytes!("fixtures/spl_instruction_padding.so")),
|
||||
)];
|
||||
|
||||
|
@ -121,7 +121,7 @@ fn test_bench_tps_test_validator(config: Config) {
|
|||
.faucet_addr(Some(faucet_addr))
|
||||
.add_program(
|
||||
"spl_instruction_padding",
|
||||
inline_instruction_padding_program::id(),
|
||||
FromOtherSolana::from(spl_instruction_padding::ID),
|
||||
)
|
||||
.start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified)
|
||||
.expect("validator start failed");
|
||||
|
@ -203,7 +203,7 @@ fn test_bench_tps_local_cluster_with_padding() {
|
|||
tx_count: 100,
|
||||
duration: Duration::from_secs(10),
|
||||
instruction_padding_config: Some(InstructionPaddingConfig {
|
||||
program_id: inline_instruction_padding_program::id(),
|
||||
program_id: FromOtherSolana::from(spl_instruction_padding::ID),
|
||||
data_size: 0,
|
||||
}),
|
||||
..Config::default()
|
||||
|
@ -217,7 +217,7 @@ fn test_bench_tps_tpu_client_with_padding() {
|
|||
tx_count: 100,
|
||||
duration: Duration::from_secs(10),
|
||||
instruction_padding_config: Some(InstructionPaddingConfig {
|
||||
program_id: inline_instruction_padding_program::id(),
|
||||
program_id: FromOtherSolana::from(spl_instruction_padding::ID),
|
||||
data_size: 0,
|
||||
}),
|
||||
..Config::default()
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue