Skip to content
Merged
8 changes: 7 additions & 1 deletion tip-router-operator-cli/src/claim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use tokio::io::BufReader;
use tokio::sync::Mutex;

use crate::{
merkle_tree_collection_file_name, priority_fees,
epoch_percentage, merkle_tree_collection_file_name, priority_fees,
rpc_utils::{get_batched_accounts, send_until_blockhash_expires},
Cli,
};
Expand Down Expand Up @@ -120,10 +120,13 @@ pub async fn emit_claim_mev_tips_metrics(
.await?;

if validators_processed {
let epoch_percentage = epoch_percentage::get(&rpc_client).await.unwrap_or(0f64);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we'd want to not emit in the event of the unwrap failing so that we're not erroneously writing 0% in the event of a 429 or timeout. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm with that. Best to avoid erroneous alerts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


datapoint_info!(
"tip_router_cli.claim_mev_tips-send_summary",
("claim_transactions_left", claims_to_process.len(), i64),
("epoch", epoch, i64),
("epoch_percentage", epoch_percentage, f64),
"cluster" => &cli.cluster,
);
}
Expand Down Expand Up @@ -326,11 +329,14 @@ pub async fn claim_mev_tips(
.await?;

if validators_processed {
let epoch_percentage = epoch_percentage::get(&rpc_client).await.unwrap_or(0f64);

datapoint_info!(
"tip_router_cli.claim_mev_tips-send_summary",
("claim_transactions_left", claims_to_process.len(), i64),
("epoch", epoch, i64),
("operator", operator_address, String),
("epoch_percentage", epoch_percentage, f64),
"cluster" => cluster,
);
}
Expand Down
10 changes: 10 additions & 0 deletions tip-router-operator-cli/src/epoch_percentage.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use anyhow::Result;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: would prefer this as just a helper in lib.rs than adding another file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use solana_client::nonblocking::rpc_client::RpcClient;
use solana_sdk::clock::DEFAULT_SLOTS_PER_EPOCH;

pub async fn get(client: &RpcClient) -> Result<f64> {
let current_slot = client.get_slot().await? as f64;
let epoch_percentage =
(current_slot % DEFAULT_SLOTS_PER_EPOCH as f64) / DEFAULT_SLOTS_PER_EPOCH as f64;
Ok(epoch_percentage)
}
1 change: 1 addition & 0 deletions tip-router-operator-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub mod backup_snapshots;
pub mod claim;
pub mod cli;
pub mod distribution_meta;
mod epoch_percentage;
pub mod load_and_process_ledger;
pub mod priority_fees;
pub mod process_epoch;
Expand Down
4 changes: 3 additions & 1 deletion tip-router-operator-cli/src/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use solana_metrics::{datapoint_error, datapoint_info};
use solana_sdk::{pubkey::Pubkey, signature::Keypair};

use crate::tip_router::send_set_merkle_root_txs;
use crate::{meta_merkle_tree_file_name, Version};
use crate::{epoch_percentage, meta_merkle_tree_file_name, Version};
use crate::{
tip_router::{
cast_vote, get_ncn_config, set_merkle_root_instructions,
Expand Down Expand Up @@ -261,13 +261,15 @@ pub async fn submit_to_ncn(
Ok(res) => {
let num_success = res.iter().filter(|r| r.is_ok()).count();
let num_failed = res.iter().filter(|r| r.is_err()).count();
let epoch_percentage = epoch_percentage::get(client).await.unwrap_or(0f64);

datapoint_info!(
"tip_router_cli.set_merkle_root",
("operator_address", operator_address.to_string(), String),
("epoch", tip_router_target_epoch, i64),
("num_success", num_success, i64),
("num_failed", num_failed, i64),
("epoch_percentage", epoch_percentage, f64),
"cluster" => cluster,
);
info!(
Expand Down
Loading