Add --minimum-validator-identity-balance

This commit is contained in:
Michael Vines 2021-01-17 16:52:57 -08:00 committed by mergify[bot]
parent 391a1ea760
commit a12ede8e7d
1 changed files with 18 additions and 4 deletions

View File

@ -5,7 +5,7 @@ use {
log::*, log::*,
solana_clap_utils::{ solana_clap_utils::{
input_parsers::pubkeys_of, 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_cli_output::display::format_labeled_address,
solana_client::{client_error, rpc_client::RpcClient, rpc_response::RpcVoteAccountStatus}, solana_client::{client_error, rpc_client::RpcClient, rpc_response::RpcVoteAccountStatus},
@ -29,6 +29,7 @@ struct Config {
ignore_http_bad_gateway: bool, ignore_http_bad_gateway: bool,
interval: Duration, interval: Duration,
json_rpc_url: String, json_rpc_url: String,
minimum_validator_identity_balance: u64,
monitor_active_stake: bool, monitor_active_stake: bool,
unhealthy_threshold: usize, unhealthy_threshold: usize,
validator_identity_pubkeys: Vec<Pubkey>, validator_identity_pubkeys: Vec<Pubkey>,
@ -102,6 +103,15 @@ fn get_config() -> Config {
.multiple(true) .multiple(true)
.help("Validator identities to monitor for delinquency") .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::<f64>)
.help("Alert when the validator identity balance is less than this amount of SOL")
)
.arg( .arg(
// Deprecated parameter, now always enabled // Deprecated parameter, now always enabled
Arg::with_name("no_duplicate_notifications") 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 interval = Duration::from_secs(value_t_or_exit!(matches, "interval", u64));
let unhealthy_threshold = value_t_or_exit!(matches, "unhealthy_threshold", usize); 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 = let json_rpc_url =
value_t!(matches, "json_rpc_url", String).unwrap_or_else(|_| config.json_rpc_url.clone()); 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") let validator_identity_pubkeys: Vec<_> = pubkeys_of(&matches, "validator_identities")
@ -148,6 +163,7 @@ fn get_config() -> Config {
ignore_http_bad_gateway, ignore_http_bad_gateway,
interval, interval,
json_rpc_url, json_rpc_url,
minimum_validator_identity_balance,
monitor_active_stake, monitor_active_stake,
unhealthy_threshold, unhealthy_threshold,
validator_identity_pubkeys, validator_identity_pubkeys,
@ -283,9 +299,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
} }
if let Some(balance) = validator_balances.get(&validator_identity) { if let Some(balance) = validator_balances.get(&validator_identity) {
if *balance < sol_to_lamports(10.) { if *balance < config.minimum_validator_identity_balance {
// At 1 SOL/day for validator voting fees, this gives over a week to
// find some more SOL
failures.push(( failures.push((
"balance", "balance",
format!("{} has {}", formatted_validator_identity, Sol(*balance)), format!("{} has {}", formatted_validator_identity, Sol(*balance)),