Skip to content

Commit

Permalink
working on emit
Browse files Browse the repository at this point in the history
  • Loading branch information
coachchucksol committed May 16, 2024
1 parent 28a4776 commit a1673c9
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"datapoint"
]
}
16 changes: 16 additions & 0 deletions keepers/validator-keeper/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,18 @@ struct Args {
#[arg(short, long, env, default_value = "60")]
metrics_interval: u64,

// Priority Fees (mLamports)
#[arg(short, long, env, default_value = "50_000")]
priority_fees: u64,

#[arg(short, long, env, default_value_t = Cluster::Mainnet)]
cluster: Cluster,
}

fn should_emit(tick: u64, intervals: &[u64]) -> bool {
intervals.iter().any(|interval| (tick + 1) % interval == 0)
}

fn should_update(tick: u64, intervals: &[u64]) -> bool {
intervals.iter().any(|interval| tick % interval == 0)
}
Expand All @@ -92,6 +100,7 @@ struct RunLoopConfig {
gossip_entrypoint: Option<SocketAddr>,
validator_history_interval: u64,
metrics_interval: u64,
priority_fees: u64,
}

async fn run_loop(config: RunLoopConfig) {
Expand All @@ -104,6 +113,7 @@ async fn run_loop(config: RunLoopConfig) {
gossip_entrypoint,
validator_history_interval,
metrics_interval,
priority_fees,
} = config;
let intervals = vec![validator_history_interval, metrics_interval];

Expand Down Expand Up @@ -256,6 +266,11 @@ async fn run_loop(config: RunLoopConfig) {
);
}

// ---------------------- EMIT ---------------------------------
if should_emit(tick, &intervals) {
KeeperOperations::emit(&keeper_state.runs_for_epoch, &keeper_state.errors_for_epoch)
}

// ---------- SLEEP ----------
sleep_and_tick(&mut tick).await;
}
Expand Down Expand Up @@ -299,6 +314,7 @@ async fn main() {
gossip_entrypoint,
validator_history_interval: args.validator_history_interval,
metrics_interval: args.metrics_interval,
priority_fees: args.priority_fees,
};

run_loop(config).await;
Expand Down
21 changes: 21 additions & 0 deletions keepers/validator-keeper/src/operations/keeper_operations.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use solana_metrics::datapoint_info;

#[derive(Clone)]
pub enum KeeperOperations {
PreCreateUpdate,
Expand All @@ -13,4 +15,23 @@ pub enum KeeperOperations {
}
impl KeeperOperations {
pub const LEN: usize = 10;

pub fn emit(
runs_for_epoch: &[u64; KeeperOperations::LEN],
errors_for_epoch: &[u64; KeeperOperations::LEN],
) {
datapoint_info!(
"keeper-operation-stats",
(
"num-pre-create-update-runs",
runs_for_epoch[KeeperOperations::PreCreateUpdate as usize],
i64
),
(
"num-pre-create-update-errors",
errors_for_epoch[KeeperOperations::PreCreateUpdate as usize],
i64
)
);
}
}
1 change: 1 addition & 0 deletions keepers/validator-keeper/src/state/keeper_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::{HashMap, HashSet};

use bytemuck::Zeroable;
use solana_client::rpc_response::RpcVoteAccountInfo;
use solana_metrics::datapoint_info;

Check failure on line 5 in keepers/validator-keeper/src/state/keeper_state.rs

View workflow job for this annotation

GitHub Actions / lint

unused import: `solana_metrics::datapoint_info`

Check failure on line 5 in keepers/validator-keeper/src/state/keeper_state.rs

View workflow job for this annotation

GitHub Actions / udeps

unused import: `solana_metrics::datapoint_info`

Check failure on line 5 in keepers/validator-keeper/src/state/keeper_state.rs

View workflow job for this annotation

GitHub Actions / test

unused import: `solana_metrics::datapoint_info`
use solana_sdk::{
account::Account, epoch_info::EpochInfo, pubkey::Pubkey,
vote::program::id as get_vote_program_id,
Expand Down

0 comments on commit a1673c9

Please sign in to comment.