diff --git a/program-runtime/src/compute_budget.rs b/program-runtime/src/compute_budget.rs index 0fcd81c30d173a..9045229f5b8c7f 100644 --- a/program-runtime/src/compute_budget.rs +++ b/program-runtime/src/compute_budget.rs @@ -182,7 +182,7 @@ impl ComputeBudget { enable_request_heap_frame_ix: bool, support_set_loaded_accounts_data_size_limit_ix: bool, ) -> Result { - let mut num_non_compute_budget_instructions: usize = 0; + let mut num_non_compute_budget_instructions: u32 = 0; let mut updated_compute_unit_limit = None; let mut requested_heap_size = None; let mut prioritization_fee = None; @@ -261,10 +261,10 @@ impl ComputeBudget { self.heap_size = Some(bytes as usize); } - self.compute_unit_limit = if default_units_per_instruction { + let compute_unit_limit = if default_units_per_instruction { updated_compute_unit_limit.or_else(|| { Some( - (num_non_compute_budget_instructions as u32) + num_non_compute_budget_instructions .saturating_mul(DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT), ) }) @@ -272,7 +272,8 @@ impl ComputeBudget { updated_compute_unit_limit } .unwrap_or(MAX_COMPUTE_UNIT_LIMIT) - .min(MAX_COMPUTE_UNIT_LIMIT) as u64; + .min(MAX_COMPUTE_UNIT_LIMIT); + self.compute_unit_limit = u64::from(compute_unit_limit); self.loaded_accounts_data_size_limit = updated_loaded_accounts_data_size_limit .unwrap_or(MAX_LOADED_ACCOUNTS_DATA_SIZE_BYTES)