Skip to content

Commit

Permalink
Temp compute budget fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Mar 11, 2024
1 parent fce0517 commit f0ee0c1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/helius_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub fn get_priority_fee_estimate_for_transaction(
priority_level: HeliusPriorityLevel,
transaction: &Transaction,
) -> Result<u64, String> {
println!("Invoking Helius RPC method: getPriorityFeeEstimate");
//println!("Invoking Helius RPC method: getPriorityFeeEstimate");

let request = serde_json::json!([HeliusGetPriorityFeeEstimateRequest {
options: Some(HeliusGetPriorityFeeEstimateOptions {
Expand Down Expand Up @@ -84,7 +84,7 @@ pub fn get_priority_fee_estimate_for_instructions(
priority_level: HeliusPriorityLevel,
instructions: &[Instruction],
) -> Result<u64, String> {
println!("Invoking Helius RPC method: getPriorityFeeEstimate");
//println!("Invoking Helius RPC method: getPriorityFeeEstimate");

let mut account_keys: Vec<_> = instructions
.iter()
Expand Down Expand Up @@ -113,7 +113,7 @@ pub fn get_priority_fee_estimate_for_instructions(
solana_client::rpc_request::RpcRequest::Custom {
method: "getPriorityFeeEstimate",
},
dbg!(request),
request,
)
.map(|response| {
response
Expand Down
22 changes: 16 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3174,16 +3174,26 @@ async fn process_account_sweep<T: Signers>(
)
};

apply_compute_budget(rpc_client, &mut instructions, compute_budget);

let (signature, maybe_transaction) = match existing_signature {
None => {
let mut message = Message::new(&instructions, Some(&from_authority_address));
message.recent_blockhash = recent_blockhash;
assert_eq!(
rpc_client.get_fee_for_message(&message)?,
num_transaction_signatures * fee_calculator.lamports_per_signature
);

let fee_for_message = rpc_client.get_fee_for_message(&message)?;

if compute_budget.compute_unit_price_micro_lamports.is_none() {
assert_eq!(
fee_for_message,
num_transaction_signatures * fee_calculator.lamports_per_signature
);
} else if from_account.owner == system_program::id() {
// Being lazy right now...
// The additional lamports used for priority fee were not accounted for
// when moving Lots around..
println!("TODO: account for priority fee in lot split...");
}

apply_compute_budget(rpc_client, &mut instructions, compute_budget);

let mut transaction = Transaction::new_unsigned(message);
let simulation_result = rpc_client.simulate_transaction(&transaction)?.value;
Expand Down

0 comments on commit f0ee0c1

Please sign in to comment.