diff --git a/program-runtime/src/compute_budget.rs b/program-runtime/src/compute_budget.rs index 77a37c9f86a05b..f8a864a44e03da 100644 --- a/program-runtime/src/compute_budget.rs +++ b/program-runtime/src/compute_budget.rs @@ -176,7 +176,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; @@ -255,10 +255,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), ) }) @@ -266,7 +266,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)