Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions bench-tps/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,21 @@ 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.
pub fn max_lamports_for_prioritization(use_randomized_compute_unit_price: bool) -> u64 {
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)
Expand Down Expand Up @@ -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();

Expand Down