From edfb01fe0c6273349013ffe66ae08ea030978afc Mon Sep 17 00:00:00 2001 From: segfaultdoctor <17258903+segfaultdoc@users.noreply.github.com> Date: Tue, 26 Dec 2023 17:46:54 -0500 Subject: [PATCH 1/2] wip --- tip-distributor/src/bin/claim-mev-tips.rs | 6 ++++++ tip-distributor/src/claim_mev_workflow.rs | 10 +++++++++- tip-distributor/src/reclaim_rent_workflow.rs | 12 +++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) 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!( From 63427ad5d49935146b1b311e53a9ceb8592f2577 Mon Sep 17 00:00:00 2001 From: segfaultdoctor <17258903+segfaultdoc@users.noreply.github.com> Date: Tue, 26 Dec 2023 18:02:35 -0500 Subject: [PATCH 2/2] wip --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 91687db7b6..7bb17daf4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9515,18 +9515,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.11" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c19fae0c8a9efc6a8281f2e623db8af1db9e57852e04cde3e754dd2dc29340f" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.11" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc56589e9ddd1f1c28d4b4b5c773ce232910a6bb67a70133d61c9e347585efe9" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2 1.0.69", "quote 1.0.33",