diff --git a/Cargo.lock b/Cargo.lock index 8c8b09f6..48ab455e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1952,9 +1952,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.24" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -2167,7 +2167,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.5", + "socket2 0.4.10", "tokio", "tower-service", "tracing", diff --git a/keepers/keeper-core/src/lib.rs b/keepers/keeper-core/src/lib.rs index 082aa18d..cd0f615b 100644 --- a/keepers/keeper-core/src/lib.rs +++ b/keepers/keeper-core/src/lib.rs @@ -9,6 +9,7 @@ use log::*; use solana_client::rpc_response::RpcVoteAccountInfo; use solana_client::{client_error::ClientError, nonblocking::rpc_client::RpcClient}; use solana_program::hash::Hash; +use solana_sdk::compute_budget::ComputeBudgetInstruction; use solana_sdk::packet::PACKET_DATA_SIZE; use solana_sdk::transaction::TransactionError; use solana_sdk::{ @@ -308,7 +309,6 @@ pub async fn parallel_execute_transactions( Err(e) => match e.get_transaction_error() { Some(TransactionError::BlockhashNotFound) => { is_blockhash_not_found = true; - break; } Some(TransactionError::AlreadyProcessed) => { submitted_signatures.insert(tx.signatures[0], idx); @@ -365,6 +365,7 @@ pub async fn parallel_execute_instructions( signer: &Arc, retry_count: u16, confirmation_time: u64, + microlamports: u64, ) -> Result>, TransactionExecutionError> { /* Note: Assumes all instructions are equivalent in compute, equivalent in size, and can be executed in any order @@ -383,8 +384,20 @@ pub async fn parallel_execute_instructions( let instructions_per_tx = calculate_instructions_per_tx(client, instructions, signer) .await - .map_err(|e| TransactionExecutionError::ClientError(e.to_string()))?; - let transactions: Vec<&[Instruction]> = instructions.chunks(instructions_per_tx).collect(); + .map_err(|e| TransactionExecutionError::ClientError(e.to_string()))? + - 1; + + let mut transactions: Vec> = instructions + .chunks(instructions_per_tx) + .map(|c| c.to_vec()) + .collect(); + for tx in transactions.iter_mut() { + tx.insert( + 0, + ComputeBudgetInstruction::set_compute_unit_price(microlamports), + ); + } + let transactions: Vec<&[Instruction]> = transactions.iter().map(|c| c.as_slice()).collect(); parallel_execute_transactions( client, @@ -441,7 +454,7 @@ pub async fn submit_transactions( .map(|t| t.as_slice()) .collect::>(); - match parallel_execute_transactions(client, &tx_slice, keypair, 10, 30).await { + match parallel_execute_transactions(client, &tx_slice, keypair, 100, 20).await { Ok(results) => { stats.successes = results.iter().filter(|&tx| tx.is_ok()).count() as u64; stats.errors = results.len() as u64 - stats.successes; @@ -456,9 +469,12 @@ pub async fn submit_instructions( client: &Arc, instructions: Vec, keypair: &Arc, + microlamports: u64, ) -> Result { let mut stats = SubmitStats::default(); - match parallel_execute_instructions(client, &instructions, keypair, 10, 30).await { + match parallel_execute_instructions(client, &instructions, keypair, 100, 20, microlamports) + .await + { Ok(results) => { stats.successes = results.iter().filter(|&tx| tx.is_ok()).count() as u64; stats.errors = results.len() as u64 - stats.successes; @@ -474,9 +490,10 @@ pub async fn submit_create_and_update( create_transactions: Vec>, update_instructions: Vec, keypair: &Arc, + microlamports: u64, ) -> Result { Ok(CreateUpdateStats { creates: submit_transactions(client, create_transactions, keypair).await?, - updates: submit_instructions(client, update_instructions, keypair).await?, + updates: submit_instructions(client, update_instructions, keypair, microlamports).await?, }) } diff --git a/keepers/validator-keeper/src/cluster_info.rs b/keepers/validator-keeper/src/cluster_info.rs index a6dd892a..b0a2b183 100644 --- a/keepers/validator-keeper/src/cluster_info.rs +++ b/keepers/validator-keeper/src/cluster_info.rs @@ -1,13 +1,15 @@ use std::sync::Arc; use anchor_lang::{InstructionData, ToAccountMetas}; -use keeper_core::{submit_instructions, SubmitStats, TransactionExecutionError}; +use keeper_core::{submit_transactions, SubmitStats, TransactionExecutionError}; use solana_client::nonblocking::rpc_client::RpcClient; use solana_sdk::{ compute_budget, instruction::Instruction, pubkey::Pubkey, signature::Keypair, signer::Signer, }; use validator_history::state::ClusterHistory; +use crate::PRIORITY_FEE; + pub async fn update_cluster_info( client: Arc, keypair: Arc, @@ -16,6 +18,8 @@ pub async fn update_cluster_info( let (cluster_history_account, _) = Pubkey::find_program_address(&[ClusterHistory::SEED], program_id); + let priority_fee_ix = + compute_budget::ComputeBudgetInstruction::set_compute_unit_price(PRIORITY_FEE); let heap_request_ix = compute_budget::ComputeBudgetInstruction::request_heap_frame(256 * 1024); let compute_budget_ix = compute_budget::ComputeBudgetInstruction::set_compute_unit_limit(1_400_000); @@ -30,9 +34,14 @@ pub async fn update_cluster_info( data: validator_history::instruction::CopyClusterInfo {}.data(), }; - submit_instructions( + submit_transactions( &client, - vec![heap_request_ix, compute_budget_ix, update_instruction], + vec![vec![ + priority_fee_ix, + heap_request_ix, + compute_budget_ix, + update_instruction, + ]], &keypair, ) .await diff --git a/keepers/validator-keeper/src/lib.rs b/keepers/validator-keeper/src/lib.rs index 286be460..1c2d8c43 100644 --- a/keepers/validator-keeper/src/lib.rs +++ b/keepers/validator-keeper/src/lib.rs @@ -42,6 +42,8 @@ pub mod vote_account; pub type Error = Box; +pub const PRIORITY_FEE: u64 = 500_000; + #[derive(ThisError, Debug)] pub enum KeeperError { #[error(transparent)] diff --git a/keepers/validator-keeper/src/mev_commission.rs b/keepers/validator-keeper/src/mev_commission.rs index f6286b63..83718084 100644 --- a/keepers/validator-keeper/src/mev_commission.rs +++ b/keepers/validator-keeper/src/mev_commission.rs @@ -16,7 +16,7 @@ use solana_sdk::{signature::Keypair, signer::Signer}; use validator_history::constants::MIN_VOTE_EPOCHS; use validator_history::{constants::MAX_ALLOC_BYTES, Config, ValidatorHistory}; -use crate::KeeperError; +use crate::{KeeperError, PRIORITY_FEE}; #[derive(Clone)] pub struct ValidatorMevCommissionEntry { @@ -160,8 +160,14 @@ pub async fn update_mev_commission( let (create_transactions, update_instructions) = build_create_and_update_instructions(&client, &entries_to_update).await?; - match submit_create_and_update(&client, create_transactions, update_instructions, &keypair) - .await + match submit_create_and_update( + &client, + create_transactions, + update_instructions, + &keypair, + PRIORITY_FEE, + ) + .await { Ok(submit_result) => { if submit_result.creates.errors == 0 && submit_result.updates.errors == 0 { @@ -222,8 +228,14 @@ pub async fn update_mev_earned( let (create_transactions, update_instructions) = build_create_and_update_instructions(client, &entries_to_update).await?; - let submit_result = - submit_create_and_update(client, create_transactions, update_instructions, keypair).await; + let submit_result = submit_create_and_update( + client, + create_transactions, + update_instructions, + keypair, + PRIORITY_FEE, + ) + .await; match submit_result { Ok(submit_result) => { if submit_result.creates.errors == 0 && submit_result.updates.errors == 0 { diff --git a/keepers/validator-keeper/src/stake.rs b/keepers/validator-keeper/src/stake.rs index 20c44da5..5296b642 100644 --- a/keepers/validator-keeper/src/stake.rs +++ b/keepers/validator-keeper/src/stake.rs @@ -22,7 +22,7 @@ use validator_history::{ state::{Config, ValidatorHistory}, }; -use crate::KeeperError; +use crate::{KeeperError, PRIORITY_FEE}; pub struct StakeHistoryEntry { pub stake: u64, @@ -218,9 +218,15 @@ pub async fn update_stake_history( let (create_transactions, update_instructions) = build_create_and_update_instructions(&client, &stake_history_entries).await?; - submit_create_and_update(&client, create_transactions, update_instructions, &keypair) - .await - .map_err(|e| e.into()) + submit_create_and_update( + &client, + create_transactions, + update_instructions, + &keypair, + PRIORITY_FEE, + ) + .await + .map_err(|e| e.into()) } /* @@ -311,7 +317,7 @@ pub async fn _recompute_superminority_and_rank( .map(|entry| entry.update_instruction()) .collect::>(); - match submit_instructions(&client, update_instructions, &keypair).await { + match submit_instructions(&client, update_instructions, &keypair, PRIORITY_FEE).await { Ok(_) => println!("completed epoch {}", epoch), Err(e) => return Err(e.into()), }; diff --git a/keepers/validator-keeper/src/vote_account.rs b/keepers/validator-keeper/src/vote_account.rs index f98268fa..5d06de41 100644 --- a/keepers/validator-keeper/src/vote_account.rs +++ b/keepers/validator-keeper/src/vote_account.rs @@ -18,7 +18,7 @@ use validator_history::constants::{MAX_ALLOC_BYTES, MIN_VOTE_EPOCHS}; use validator_history::state::ValidatorHistory; use validator_history::Config; -use crate::{get_validator_history_accounts_with_retry, KeeperError}; +use crate::{get_validator_history_accounts_with_retry, KeeperError, PRIORITY_FEE}; pub struct CopyVoteAccountEntry { pub vote_account: Pubkey, @@ -162,6 +162,7 @@ pub async fn update_vote_accounts( create_transactions, update_instructions, &keypair, + PRIORITY_FEE, ) .await;