Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup feature: default units per instruction #26684

Merged
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion core/src/transaction_priority_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub trait GetTransactionPriorityDetails {
let prioritization_fee_details = compute_budget
.process_instructions(
instructions,
true, // use default units per instruction
true, // don't reject txs that use set compute unit price ix
)
.ok()?;
Expand Down
19 changes: 6 additions & 13 deletions program-runtime/src/compute_budget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ impl ComputeBudget {
pub fn process_instructions<'a>(
&mut self,
instructions: impl Iterator<Item = (&'a Pubkey, &'a CompiledInstruction)>,
default_units_per_instruction: bool,
support_set_compute_unit_price_ix: bool,
) -> Result<PrioritizationFeeDetails, TransactionError> {
let mut num_non_compute_budget_instructions: usize = 0;
Expand Down Expand Up @@ -221,18 +220,15 @@ impl ComputeBudget {
self.heap_size = Some(bytes as usize);
}

self.compute_unit_limit = if default_units_per_instruction {
updated_compute_unit_limit.or_else(|| {
self.compute_unit_limit = updated_compute_unit_limit
.or_else(|| {
Some(
(num_non_compute_budget_instructions as u32)
.saturating_mul(DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT),
)
})
} else {
updated_compute_unit_limit
}
.unwrap_or(MAX_COMPUTE_UNIT_LIMIT)
.min(MAX_COMPUTE_UNIT_LIMIT) as u64;
.unwrap_or(MAX_COMPUTE_UNIT_LIMIT)
.min(MAX_COMPUTE_UNIT_LIMIT) as u64;

Ok(prioritization_fee
.map(|fee_type| PrioritizationFeeDetails::new(fee_type, self.compute_unit_limit))
Expand Down Expand Up @@ -275,11 +271,8 @@ mod tests {
Hash::default(),
));
let mut compute_budget = ComputeBudget::default();
let result = compute_budget.process_instructions(
tx.message().program_instructions_iter(),
true,
$type_change,
);
let result = compute_budget
.process_instructions(tx.message().program_instructions_iter(), $type_change);
assert_eq!($expected_result, result);
assert_eq!(compute_budget, $expected_budget);
};
Expand Down
6 changes: 2 additions & 4 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ use {
epoch_schedule::EpochSchedule,
feature,
feature_set::{
self, add_set_compute_unit_price_ix, default_units_per_instruction,
disable_fee_calculator, enable_early_verification_of_account_modifications, FeatureSet,
self, add_set_compute_unit_price_ix, disable_fee_calculator,
enable_early_verification_of_account_modifications, FeatureSet,
},
fee::FeeStructure,
fee_calculator::{FeeCalculator, FeeRateGovernor},
Expand Down Expand Up @@ -4542,7 +4542,6 @@ impl Bank {
Measure::start("compute_budget_process_transaction_time");
let process_transaction_result = compute_budget.process_instructions(
tx.message().program_instructions_iter(),
feature_set.is_active(&default_units_per_instruction::id()),
feature_set.is_active(&add_set_compute_unit_price_ix::id()),
);
compute_budget_process_transaction_time.stop();
Expand Down Expand Up @@ -4837,7 +4836,6 @@ impl Bank {
let prioritization_fee_details = compute_budget
.process_instructions(
message.program_instructions_iter(),
false,
support_set_compute_unit_price_ix,
)
.unwrap_or_default();
Expand Down