Skip to content

Commit d5fc81e

Browse files
Reduce budget request instruction length (solana-labs#20636) (solana-labs#20644)
(cherry picked from commit c231cfe) Co-authored-by: Jack May <jack@solana.com>
1 parent 53f4bde commit d5fc81e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

sdk/src/compute_budget.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use solana_sdk::{
1212

1313
crate::declare_id!("ComputeBudget111111111111111111111111111111");
1414

15-
const MAX_UNITS: u64 = 1_000_000;
15+
const MAX_UNITS: u32 = 1_000_000;
1616

1717
/// Compute Budget Instructions
1818
#[derive(
@@ -30,11 +30,11 @@ const MAX_UNITS: u64 = 1_000_000;
3030
pub enum ComputeBudgetInstruction {
3131
/// Request a specific maximum number of compute units the transaction is
3232
/// allowed to consume.
33-
RequestUnits(u64),
33+
RequestUnits(u32),
3434
}
3535

3636
/// Create a `ComputeBudgetInstruction::RequestUnits` `Instruction`
37-
pub fn request_units(units: u64) -> Instruction {
37+
pub fn request_units(units: u32) -> Instruction {
3838
Instruction::new_with_borsh(id(), &ComputeBudgetInstruction::RequestUnits(units), vec![])
3939
}
4040

@@ -52,7 +52,7 @@ pub fn process_request(
5252
if units > MAX_UNITS {
5353
return Err(error);
5454
}
55-
compute_budget.max_units = units;
55+
compute_budget.max_units = units as u64;
5656
}
5757
}
5858
Ok(())
@@ -134,7 +134,7 @@ mod tests {
134134
assert_eq!(
135135
compute_budget,
136136
BpfComputeBudget {
137-
max_units: MAX_UNITS,
137+
max_units: MAX_UNITS as u64,
138138
..BpfComputeBudget::default()
139139
}
140140
);

0 commit comments

Comments
 (0)