Skip to content

Commit

Permalink
Improve notifications even more
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Apr 29, 2021
1 parent 4264a94 commit 67db42a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/legacy_stake_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ impl GenericStakePool for LegacyStakePool {
return Err("Failed to initialize stake pool. Unable to continue".into());
}

let mut notifications = vec![];
let mut notifications = vec![
format!("Baseline stake amount: {}", Sol(self.baseline_stake_amount)),
format!("Bonus stake amount: {}", Sol(self.bonus_stake_amount)),
];
let ok = send_and_confirm_transactions(
rpc_client,
dry_run,
Expand Down
24 changes: 18 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ fn classify_producers(
fn classify_poor_voters(
config: &Config,
vote_account_info: &[VoteAccountInfo],
) -> (HashSet<Pubkey>, u64, bool) {
) -> (HashSet<Pubkey>, u64, u64, bool) {
let avg_epoch_credits = vote_account_info
.iter()
.map(|vai| vai.epoch_credits)
Expand Down Expand Up @@ -782,7 +782,12 @@ fn classify_poor_voters(
);
trace!("poor_voters: {:?}", poor_voters);

(poor_voters, min_epoch_credits, too_many_poor_voters)
(
poor_voters,
min_epoch_credits,
avg_epoch_credits,
too_many_poor_voters,
)
}

fn get_confirmed_blocks(
Expand Down Expand Up @@ -940,19 +945,23 @@ fn main() -> BoxResult<()> {
.flat_map(|(v, sp)| v.into_iter().map(move |v| (v, sp)))
.collect::<HashMap<_, _>>();

let (poor_voters, min_epoch_credits, too_many_poor_voters) =
let (poor_voters, min_epoch_credits, avg_epoch_credits, too_many_poor_voters) =
classify_poor_voters(&config, &vote_account_info);

let mut notifications = vec![
format!(
"Minimum vote credits required for epoch {}: {}",
last_epoch, min_epoch_credits,
"Minimum vote credits required for epoch {}: {} (cluster average: {}, grace: {}%)",
last_epoch,
min_epoch_credits,
avg_epoch_credits,
config.min_epoch_credit_percentage_of_average,
),
format!(
"Maximum allowed skip rate for epoch {}: {:.2}% (cluster average is {:.2}%)",
"Maximum allowed skip rate for epoch {}: {:.2}% (cluster average: {:.2}%, grace: {}%)",
last_epoch,
cluster_average_skip_rate + config.quality_block_producer_percentage,
cluster_average_skip_rate,
config.quality_block_producer_percentage,
),
format!("Solana release {} or greater required", min_release_version),
format!("Maximum commission: {}%", config.max_commission),
Expand Down Expand Up @@ -985,6 +994,7 @@ fn main() -> BoxResult<()> {
}

let mut desired_validator_stake = vec![];
let mut validators_processed = 0;
for VoteAccountInfo {
identity,
vote_address,
Expand All @@ -995,6 +1005,7 @@ fn main() -> BoxResult<()> {
if !stake_pool.is_enrolled(&identity) {
continue;
}
validators_processed += 1;

let block_producer_classification_reason_msg = block_producer_classification_reason
.get(&identity)
Expand Down Expand Up @@ -1097,6 +1108,7 @@ fn main() -> BoxResult<()> {
&config.authorized_staker,
&desired_validator_stake,
)?);
notifications.push(format!("{} validators processed", validators_processed));

for notification in notifications {
info!("notification: {}", notification);
Expand Down
8 changes: 6 additions & 2 deletions src/stake_pool_v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ impl GenericStakePool for StakePool {

info!("Bonus stake amount: {}", Sol(bonus_stake_amount));

let notifications = distribute_validator_stake(
let mut notifications = vec![
format!("Baseline stake amount: {}", Sol(self.baseline_stake_amount)),
format!("Bonus stake amount: {}", Sol(bonus_stake_amount)),
];
notifications.extend(distribute_validator_stake(
rpc_client,
authorized_staker,
desired_validator_stake
Expand All @@ -198,7 +202,7 @@ impl GenericStakePool for StakePool {
self.reserve_stake_address,
self.baseline_stake_amount,
bonus_stake_amount,
)?;
)?);
Ok(notifications)
}
}
Expand Down

0 comments on commit 67db42a

Please sign in to comment.