Skip to content

Commit

Permalink
Make get_prioritization_fee private
Browse files Browse the repository at this point in the history
  • Loading branch information
ksolana committed Nov 2, 2024
1 parent 25d6058 commit a835a96
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions compute-budget/src/compute_budget_limits.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use {
solana_program_entrypoint::HEAP_LENGTH, solana_fee_structure::FeeBudgetLimits,
solana_fee_structure::FeeBudgetLimits, solana_program_entrypoint::HEAP_LENGTH,
std::num::NonZeroU32,
};

Expand Down Expand Up @@ -40,7 +40,7 @@ impl Default for ComputeBudgetLimits {
}
}

pub fn get_prioritization_fee(compute_unit_price: u64, compute_unit_limit: u64) -> u64 {
fn get_prioritization_fee(compute_unit_price: u64, compute_unit_limit: u64) -> u64 {
let micro_lamport_fee: MicroLamports =
(compute_unit_price as u128).saturating_mul(compute_unit_limit as u128);
micro_lamport_fee
Expand Down
18 changes: 13 additions & 5 deletions runtime/src/bank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use {
},
solana_compute_budget::{
compute_budget::ComputeBudget,
compute_budget_limits::{self, get_prioritization_fee, MAX_COMPUTE_UNIT_LIMIT},
compute_budget_limits::{self, ComputeBudgetLimits, MAX_COMPUTE_UNIT_LIMIT},
},
solana_feature_set::{self as feature_set, FeatureSet},
solana_inline_spl::token,
Expand Down Expand Up @@ -10311,10 +10311,14 @@ fn test_calculate_fee_compute_units() {
Some(&Pubkey::new_unique()),
));
let fee = calculate_test_fee(&message, 1, &fee_structure);
let fee_budget_limits = FeeBudgetLimits::from(ComputeBudgetLimits {
compute_unit_price: PRIORITIZATION_FEE_RATE,
compute_unit_limit: requested_compute_units,
..ComputeBudgetLimits::default()
});
assert_eq!(
fee,
lamports_per_signature
+ get_prioritization_fee(PRIORITIZATION_FEE_RATE, requested_compute_units as u64)
lamports_per_signature + fee_budget_limits.prioritization_fee
);
}
}
Expand All @@ -10328,7 +10332,11 @@ fn test_calculate_prioritization_fee() {

let request_units = 1_000_000_u32;
let request_unit_price = 2_000_000_000_u64;
let prioritization_fee = get_prioritization_fee(request_unit_price, request_units as u64);
let fee_budget_limits = FeeBudgetLimits::from(ComputeBudgetLimits {
compute_unit_price: request_unit_price,
compute_unit_limit: request_units,
..ComputeBudgetLimits::default()
});

let message = new_sanitized_message(Message::new(
&[
Expand All @@ -10345,7 +10353,7 @@ fn test_calculate_prioritization_fee() {
);
assert_eq!(
fee,
fee_structure.lamports_per_signature + prioritization_fee
fee_structure.lamports_per_signature + fee_budget_limits.prioritization_fee
);
}

Expand Down

0 comments on commit a835a96

Please sign in to comment.