From d5fc81e12a66b262b0c1c998fd61729c10c21e52 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 20 Oct 2021 12:17:29 -0700 Subject: [PATCH] Reduce budget request instruction length (#20636) (#20644) (cherry picked from commit c231cfe23553745f64dbe5fc2ee2ecde714e53c7) Co-authored-by: Jack May --- sdk/src/compute_budget.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/src/compute_budget.rs b/sdk/src/compute_budget.rs index 0fae0b8a81..e90ae3d7f8 100644 --- a/sdk/src/compute_budget.rs +++ b/sdk/src/compute_budget.rs @@ -12,7 +12,7 @@ use solana_sdk::{ crate::declare_id!("ComputeBudget111111111111111111111111111111"); -const MAX_UNITS: u64 = 1_000_000; +const MAX_UNITS: u32 = 1_000_000; /// Compute Budget Instructions #[derive( @@ -30,11 +30,11 @@ const MAX_UNITS: u64 = 1_000_000; pub enum ComputeBudgetInstruction { /// Request a specific maximum number of compute units the transaction is /// allowed to consume. - RequestUnits(u64), + RequestUnits(u32), } /// Create a `ComputeBudgetInstruction::RequestUnits` `Instruction` -pub fn request_units(units: u64) -> Instruction { +pub fn request_units(units: u32) -> Instruction { Instruction::new_with_borsh(id(), &ComputeBudgetInstruction::RequestUnits(units), vec![]) } @@ -52,7 +52,7 @@ pub fn process_request( if units > MAX_UNITS { return Err(error); } - compute_budget.max_units = units; + compute_budget.max_units = units as u64; } } Ok(()) @@ -134,7 +134,7 @@ mod tests { assert_eq!( compute_budget, BpfComputeBudget { - max_units: MAX_UNITS, + max_units: MAX_UNITS as u64, ..BpfComputeBudget::default() } );