From a12ede8e7d3c409d0786fe1d9d93686fc18ecb3d Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Sun, 17 Jan 2021 16:52:57 -0800 Subject: [PATCH] Add --minimum-validator-identity-balance --- watchtower/src/main.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/watchtower/src/main.rs b/watchtower/src/main.rs index 91c7ab8a2..802098d31 100644 --- a/watchtower/src/main.rs +++ b/watchtower/src/main.rs @@ -5,7 +5,7 @@ use { log::*, solana_clap_utils::{ input_parsers::pubkeys_of, - input_validators::{is_pubkey_or_keypair, is_url}, + input_validators::{is_parsable, is_pubkey_or_keypair, is_url}, }, solana_cli_output::display::format_labeled_address, solana_client::{client_error, rpc_client::RpcClient, rpc_response::RpcVoteAccountStatus}, @@ -29,6 +29,7 @@ struct Config { ignore_http_bad_gateway: bool, interval: Duration, json_rpc_url: String, + minimum_validator_identity_balance: u64, monitor_active_stake: bool, unhealthy_threshold: usize, validator_identity_pubkeys: Vec, @@ -102,6 +103,15 @@ fn get_config() -> Config { .multiple(true) .help("Validator identities to monitor for delinquency") ) + .arg( + Arg::with_name("minimum_validator_identity_balance") + .long("minimum-validator-identity-balance") + .value_name("SOL") + .takes_value(true) + .default_value("10") + .validator(is_parsable::) + .help("Alert when the validator identity balance is less than this amount of SOL") + ) .arg( // Deprecated parameter, now always enabled Arg::with_name("no_duplicate_notifications") @@ -133,6 +143,11 @@ fn get_config() -> Config { let interval = Duration::from_secs(value_t_or_exit!(matches, "interval", u64)); let unhealthy_threshold = value_t_or_exit!(matches, "unhealthy_threshold", usize); + let minimum_validator_identity_balance = sol_to_lamports(value_t_or_exit!( + matches, + "minimum_validator_identity_balance", + f64 + )); let json_rpc_url = value_t!(matches, "json_rpc_url", String).unwrap_or_else(|_| config.json_rpc_url.clone()); let validator_identity_pubkeys: Vec<_> = pubkeys_of(&matches, "validator_identities") @@ -148,6 +163,7 @@ fn get_config() -> Config { ignore_http_bad_gateway, interval, json_rpc_url, + minimum_validator_identity_balance, monitor_active_stake, unhealthy_threshold, validator_identity_pubkeys, @@ -283,9 +299,7 @@ fn main() -> Result<(), Box> { } if let Some(balance) = validator_balances.get(&validator_identity) { - if *balance < sol_to_lamports(10.) { - // At 1 SOL/day for validator voting fees, this gives over a week to - // find some more SOL + if *balance < config.minimum_validator_identity_balance { failures.push(( "balance", format!("{} has {}", formatted_validator_identity, Sol(*balance)),