set Transfer transaction loaded_accounts_data_size in bench-tps (#32105)

* set Transfer transaction loaded_accounts_data_size in bench-tps

* increase compute_unit_limit for additional ix
This commit is contained in:
Tao Zhu 2023-06-14 13:30:43 -05:00 committed by GitHub
parent 8b25052978
commit e83a06d85e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 2 deletions

View File

@ -45,7 +45,7 @@ const MAX_TX_QUEUE_AGE: u64 = (MAX_PROCESSING_AGE as f64 * DEFAULT_S_PER_SLOT) a
// It also sets transaction's compute-unit to TRANSFER_TRANSACTION_COMPUTE_UNIT. Therefore the
// max additional cost is `TRANSFER_TRANSACTION_COMPUTE_UNIT * MAX_COMPUTE_UNIT_PRICE / 1_000_000`
const MAX_COMPUTE_UNIT_PRICE: u64 = 50;
const TRANSFER_TRANSACTION_COMPUTE_UNIT: u32 = 450;
const TRANSFER_TRANSACTION_COMPUTE_UNIT: u32 = 600; // 1 transfer is plus 3 compute_budget ixs
/// calculate maximum possible prioritization fee, if `use-randomized-compute-unit-price` is
/// enabled, round to nearest lamports.
pub fn max_lamports_for_prioritization(use_randomized_compute_unit_price: bool) -> u64 {
@ -62,6 +62,10 @@ pub fn max_lamports_for_prioritization(use_randomized_compute_unit_price: bool)
}
}
// set transfer transaction's loaded account data size to 30K - large enough yet smaller than
// 32K page size, so it'd cost 0 extra CU.
const TRANSFER_TRANSACTION_LOADED_ACCOUNTS_DATA_SIZE: u32 = 30 * 1024;
pub type TimestampedTransaction = (Transaction, Option<u64>);
pub type SharedTransactions = Arc<RwLock<VecDeque<Vec<TimestampedTransaction>>>>;
@ -592,6 +596,11 @@ fn transfer_with_compute_unit_price_and_padding(
ComputeBudgetInstruction::set_compute_unit_price(compute_unit_price),
])
}
instructions.extend_from_slice(&[
ComputeBudgetInstruction::set_loaded_accounts_data_size_limit(
TRANSFER_TRANSACTION_LOADED_ACCOUNTS_DATA_SIZE,
),
]);
let message = Message::new(&instructions, Some(&from_pubkey));
Transaction::new(&[from_keypair], message, recent_blockhash)
}
@ -678,8 +687,14 @@ fn nonced_transfer_with_padding(
} else {
transfer_instruction
};
let mut instructions = vec![instruction];
instructions.extend_from_slice(&[
ComputeBudgetInstruction::set_loaded_accounts_data_size_limit(
TRANSFER_TRANSACTION_LOADED_ACCOUNTS_DATA_SIZE,
),
]);
let message = Message::new_with_nonce(
vec![instruction],
instructions,
Some(&from_pubkey),
nonce_account,
&nonce_authority.pubkey(),