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

v1.16: Priority queue supports deprecated compute budget ix (backport of #32567) #32572

Merged
merged 1 commit into from
Jul 21, 2023
Merged
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
58 changes: 52 additions & 6 deletions runtime/src/transaction_priority_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ pub trait GetTransactionPriorityDetails {
let prioritization_fee_details = compute_budget
.process_instructions(
instructions,
true, // use default units per instruction
false, // stop supporting prioritization by request_units_deprecated instruction
true, // enable request heap frame instruction
true, // enable support set accounts data size instruction
// TODO: round_compute_unit_price_enabled: bool
true, // use default units per instruction
true, // supports prioritization by request_units_deprecated instruction
true, // enable request heap frame instruction
true, // enable support set accounts data size instruction
// TODO: round_compute_unit_price_enabled: bool
)
.ok()?;
Some(TransactionPriorityDetails {
Expand Down Expand Up @@ -70,7 +70,8 @@ mod tests {
use {
super::*,
solana_sdk::{
compute_budget::ComputeBudgetInstruction,
compute_budget::{self, ComputeBudgetInstruction},
instruction::Instruction,
message::Message,
pubkey::Pubkey,
signature::{Keypair, Signer},
Expand Down Expand Up @@ -193,4 +194,49 @@ mod tests {
})
);
}

#[test]
fn test_get_priority_with_deprecated_compute_unit_request() {
let priority = 1_000;
let units = 200_000;
let additional_fee = units * priority / 1_000_000;
let keypair = Keypair::new();
let transaction = Transaction::new_unsigned(Message::new(
&[
system_instruction::transfer(&keypair.pubkey(), &Pubkey::new_unique(), 1),
Instruction::new_with_borsh(
compute_budget::id(),
&ComputeBudgetInstruction::RequestUnitsDeprecated {
units,
additional_fee,
},
vec![],
),
],
Some(&keypair.pubkey()),
));

// assert for SanitizedVersionedTransaction
let versioned_transaction = VersionedTransaction::from(transaction.clone());
let sanitized_versioned_transaction =
SanitizedVersionedTransaction::try_new(versioned_transaction).unwrap();
assert_eq!(
sanitized_versioned_transaction.get_transaction_priority_details(false),
Some(TransactionPriorityDetails {
priority: priority as u64,
compute_unit_limit: units as u64
})
);

// assert for SanitizedTransaction
let sanitized_transaction =
SanitizedTransaction::try_from_legacy_transaction(transaction).unwrap();
assert_eq!(
sanitized_transaction.get_transaction_priority_details(false),
Some(TransactionPriorityDetails {
priority: priority as u64,
compute_unit_limit: units as u64
})
);
}
}