diff --git a/tip-distributor/src/bin/claim-mev-tips.rs b/tip-distributor/src/bin/claim-mev-tips.rs index e517377c7d..833a5da27c 100644 --- a/tip-distributor/src/bin/claim-mev-tips.rs +++ b/tip-distributor/src/bin/claim-mev-tips.rs @@ -60,6 +60,10 @@ struct Args { /// Specifies whether to reclaim rent on behalf of validators from respective TDAs. #[arg(long, env)] should_reclaim_tdas: bool, + + /// The price to pay per compute unit aka "Priority Fee". + #[arg(long, env, default_value_t = 1)] + micro_lamports_per_compute_unit: u64, } #[tokio::main] @@ -90,6 +94,7 @@ async fn main() -> Result<(), ClaimMevError> { keypair.clone(), args.max_loop_retries, max_loop_duration, + args.micro_lamports_per_compute_unit, ) .await { @@ -133,6 +138,7 @@ async fn main() -> Result<(), ClaimMevError> { args.max_loop_retries, max_loop_duration, args.should_reclaim_tdas, + args.micro_lamports_per_compute_unit, ) .await { diff --git a/tip-distributor/src/claim_mev_workflow.rs b/tip-distributor/src/claim_mev_workflow.rs index 82cdba3827..22d2cebeaa 100644 --- a/tip-distributor/src/claim_mev_workflow.rs +++ b/tip-distributor/src/claim_mev_workflow.rs @@ -17,6 +17,7 @@ use { solana_sdk::{ account::Account, commitment_config::CommitmentConfig, + compute_budget::ComputeBudgetInstruction, instruction::Instruction, pubkey::Pubkey, signature::{Keypair, Signer}, @@ -78,6 +79,7 @@ pub async fn claim_mev_tips( keypair: Arc, max_loop_retries: u64, max_loop_duration: Duration, + micro_lamports_per_compute_unit: u64, ) -> Result<(), ClaimMevError> { let payer_pubkey = keypair.pubkey(); let blockhash_rpc_client = Arc::new(RpcClient::new_with_commitment( @@ -204,6 +206,7 @@ pub async fn claim_mev_tips( &tdas, &claimants, &claim_statuses, + micro_lamports_per_compute_unit, )?; datapoint_info!( "claim_mev_workflow-prepare_transactions", @@ -308,6 +311,7 @@ fn build_transactions( tdas: &HashMap, claimants: &HashMap, claim_statuses: &HashMap>, + micro_lamports_per_compute_unit: u64, ) -> Result< ( usize, /* skipped_merkle_root_count */ @@ -397,7 +401,11 @@ fn build_transactions( let transactions = instructions .into_iter() - .map(|ix| Transaction::new_with_payer(&[ix], Some(payer_pubkey))) + .map(|claim_ix| { + let priority_fee_ix = + ComputeBudgetInstruction::set_compute_unit_price(micro_lamports_per_compute_unit); + Transaction::new_with_payer(&[priority_fee_ix, claim_ix], Some(payer_pubkey)) + }) .collect::>(); Ok(( skipped_merkle_root_count, diff --git a/tip-distributor/src/reclaim_rent_workflow.rs b/tip-distributor/src/reclaim_rent_workflow.rs index 8d923e3980..6775a02041 100644 --- a/tip-distributor/src/reclaim_rent_workflow.rs +++ b/tip-distributor/src/reclaim_rent_workflow.rs @@ -23,6 +23,7 @@ use { solana_program::pubkey::Pubkey, solana_sdk::{ commitment_config::CommitmentConfig, + compute_budget::ComputeBudgetInstruction, signature::{Keypair, Signer}, transaction::Transaction, }, @@ -42,6 +43,7 @@ pub async fn reclaim_rent( max_loop_duration: Duration, // Optionally reclaim TipDistributionAccount rents on behalf of validators. should_reclaim_tdas: bool, + micro_lamports_per_compute_unit: u64, ) -> Result<(), ClaimMevError> { let blockhash_rpc_client = Arc::new(RpcClient::new_with_timeout_and_commitment( rpc_url.clone(), @@ -67,6 +69,7 @@ pub async fn reclaim_rent( &tip_distribution_program_id, &signer_pubkey, should_reclaim_tdas, + micro_lamports_per_compute_unit, ) .await?; datapoint_info!( @@ -138,6 +141,7 @@ async fn build_transactions( tip_distribution_program_id: &Pubkey, signer_pubkey: &Pubkey, should_reclaim_tdas: bool, + micro_lamports_per_compute_unit: u64, ) -> Result<(Vec, Duration, Duration), ClaimMevError> { info!("Fetching program accounts"); let (accounts, get_pa_elapsed) = measure!( @@ -197,7 +201,13 @@ async fn build_transactions( }) .collect::>() .chunks(4) - .map(|instructions| Transaction::new_with_payer(instructions, Some(signer_pubkey))) + .map(|close_claim_status_instructions| { + let mut instructions = vec![ComputeBudgetInstruction::set_compute_unit_price( + micro_lamports_per_compute_unit, + )]; + instructions.extend(close_claim_status_instructions.to_vec()); + Transaction::new_with_payer(&instructions, Some(signer_pubkey)) + }) .collect::>(); info!(