bench-tps add 1_000 as multiplier to compute-unit-price (#32132)

add 1_000 as multiplier to compute-unit-price
This commit is contained in:
Tao Zhu 2023-06-14 14:50:18 -05:00 committed by GitHub
parent 088ac5ec01
commit 4b30454193
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 4 deletions

View File

@ -41,10 +41,13 @@ use {
const MAX_TX_QUEUE_AGE: u64 = (MAX_PROCESSING_AGE as f64 * DEFAULT_S_PER_SLOT) as u64;
// Add prioritization fee to transfer transactions, when `--use-randomized-compute-unit-price`
// is used, compute-unit-price is randomly generated in range of (0..MAX_COMPUTE_UNIT_PRICE).
// is used, compute-unit-price is randomly generated in range of (0..MAX_COMPUTE_UNIT_PRICE)
// multiplies by COMPUTE_UNIT_PRICE_MULTIPLIER;
// 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`
// max additional cost is:
// `TRANSFER_TRANSACTION_COMPUTE_UNIT * MAX_COMPUTE_UNIT_PRICE * COMPUTE_UNIT_PRICE_MULTIPLIER / 1_000_000`
const MAX_COMPUTE_UNIT_PRICE: u64 = 50;
const COMPUTE_UNIT_PRICE_MULTIPLIER: u64 = 1_000;
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.
@ -52,6 +55,7 @@ pub fn max_lamports_for_prioritization(use_randomized_compute_unit_price: bool)
if use_randomized_compute_unit_price {
const MICRO_LAMPORTS_PER_LAMPORT: u64 = 1_000_000;
let micro_lamport_fee: u128 = (MAX_COMPUTE_UNIT_PRICE as u128)
.saturating_mul(COMPUTE_UNIT_PRICE_MULTIPLIER as u128)
.saturating_mul(TRANSFER_TRANSACTION_COMPUTE_UNIT as u128);
let fee = micro_lamport_fee
.saturating_add(MICRO_LAMPORTS_PER_LAMPORT.saturating_sub(1) as u128)
@ -527,8 +531,13 @@ fn generate_system_txs(
if use_randomized_compute_unit_price {
let mut rng = rand::thread_rng();
let range = Uniform::from(0..MAX_COMPUTE_UNIT_PRICE);
let compute_unit_prices: Vec<_> =
(0..pairs.len()).map(|_| range.sample(&mut rng)).collect();
let compute_unit_prices: Vec<_> = (0..pairs.len())
.map(|_| {
range
.sample(&mut rng)
.saturating_mul(COMPUTE_UNIT_PRICE_MULTIPLIER)
})
.collect();
let pairs_with_compute_unit_prices: Vec<_> =
pairs.iter().zip(compute_unit_prices.iter()).collect();