Skip to content

Commit

Permalink
gossip optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
ebatsell committed Apr 16, 2024
1 parent 5d9537e commit 324ef3e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
5 changes: 5 additions & 0 deletions keepers/keeper-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use solana_sdk::{
};
use thiserror::Error as ThisError;
use tokio::task::{self, JoinError};
use tokio::time::sleep;

#[derive(Debug, Default, Clone)]
pub struct SubmitStats {
Expand Down Expand Up @@ -300,6 +301,10 @@ pub async fn parallel_execute_transactions(
if results[idx].is_ok() {
continue;
}
if idx % 50 == 0 {
// Need to avoid spamming the rpc or lots of transactions will get dropped
sleep(Duration::from_secs(3)).await;
}

// Future optimization: submit these in parallel batches and refresh blockhash for every batch
match client.send_transaction(tx).await {
Expand Down
21 changes: 13 additions & 8 deletions keepers/validator-keeper/src/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use solana_gossip::{
};
use solana_metrics::datapoint_info;
use solana_sdk::{
compute_budget::ComputeBudgetInstruction,
instruction::Instruction,
pubkey::Pubkey,
signature::{Keypair, Signable, Signature},
Expand All @@ -35,7 +36,7 @@ use validator_history::{
Config, ValidatorHistory, ValidatorHistoryEntry,
};

use crate::{get_validator_history_accounts_with_retry, start_spy_server};
use crate::{get_validator_history_accounts_with_retry, start_spy_server, PRIORITY_FEE};

#[derive(Clone, Debug)]
pub struct GossipEntry {
Expand Down Expand Up @@ -116,12 +117,16 @@ impl CreateTransaction for GossipEntry {
}

impl GossipEntry {
pub fn build_update_tx(&self) -> Vec<Instruction> {
let mut ixs = vec![build_verify_signature_ix(
self.signature.as_ref(),
self.identity.to_bytes(),
&self.message,
)];
pub fn build_update_tx(&self, priority_fee: u64) -> Vec<Instruction> {
let mut ixs = vec![
ComputeBudgetInstruction::set_compute_unit_limit(100_000),
ComputeBudgetInstruction::set_compute_unit_price(priority_fee),
build_verify_signature_ix(
self.signature.as_ref(),
self.identity.to_bytes(),
&self.message,
),
];

ixs.push(Instruction {
program_id: self.program_id,
Expand Down Expand Up @@ -362,7 +367,7 @@ pub async fn upload_gossip_values(

let update_transactions = gossip_entries
.iter()
.map(|entry| entry.build_update_tx())
.map(|entry| entry.build_update_tx(PRIORITY_FEE))
.collect::<Vec<_>>();

Ok(CreateUpdateStats {
Expand Down

0 comments on commit 324ef3e

Please sign in to comment.