Skip to content

Commit

Permalink
add lut metrics (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
vovkman authored Jul 17, 2024
1 parent 5a502b8 commit fe95448
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/rpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ use std::{
env, fmt,
str::FromStr,
sync::Arc,
time::Instant,
};

use crate::{
errors::invalid_request,
priority_fee::{MicroLamportPriorityFeeEstimates, PriorityFeeTracker, PriorityLevel},
solana::solana_rpc::decode_and_deserialize,
};
use cadence_macros::{statsd_count, statsd_time};
use jsonrpsee::{
core::{async_trait, RpcResult},
proc_macros::rpc,
Expand Down Expand Up @@ -131,6 +133,7 @@ fn get_from_address_lookup_tables(
let address_table_lookups: Option<&[solana_sdk::message::v0::MessageAddressTableLookup]> =
transaction.message.address_table_lookups();
if let Some(address_table_lookups) = address_table_lookups {
let start = Instant::now();
let mut lookup_table_indices = HashMap::new();
let address_table_lookup_accounts: Vec<Pubkey> = address_table_lookups
.iter()
Expand All @@ -142,6 +145,10 @@ fn get_from_address_lookup_tables(
a.account_key
})
.collect();
statsd_count!(
"get_from_address_lookup_tables_num_accounts",
address_table_lookup_accounts.len() as i64
);
let accounts = rpc_client.get_multiple_accounts(address_table_lookup_accounts.as_slice());
match accounts {
Ok(accounts) => {
Expand Down Expand Up @@ -185,6 +192,7 @@ fn get_from_address_lookup_tables(
info!("error getting accounts: {:?}", e);
}
}
statsd_time!("get_from_address_lookup_tables", start.elapsed());
}
account_keys
}
Expand Down Expand Up @@ -279,7 +287,9 @@ impl AtlasPriorityFeeEstimatorRpcServer for AtlasPriorityFeeEstimator {
});
}
}
let recommended = options.map_or(false, |o: GetPriorityFeeEstimateOptions| o.recommended.unwrap_or(false));
let recommended = options.map_or(false, |o: GetPriorityFeeEstimateOptions| {
o.recommended.unwrap_or(false)
});
let priority_fee = if recommended {
get_recommended_fee(priority_fee_levels)
} else {
Expand Down Expand Up @@ -317,7 +327,7 @@ fn should_include_vote(options: &Option<GetPriorityFeeEstimateOptions>) -> bool

const MIN_RECOMMENDED_PRIORITY_FEE: f64 = 10_000.0;

// Safety buffer on the recommended fee to cover cases where the priority fee is increasing over each block.
// Safety buffer on the recommended fee to cover cases where the priority fee is increasing over each block.
const RECOMMENDED_FEE_SAFETY_BUFFER: f64 = 0.05;

pub fn get_recommended_fee(priority_fee_levels: MicroLamportPriorityFeeEstimates) -> f64 {
Expand Down

0 comments on commit fe95448

Please sign in to comment.