diff --git a/.buildkite/prepare-protected-events.yml b/.buildkite/prepare-protected-events.yml index 763e52b0..5a1ac007 100644 --- a/.buildkite/prepare-protected-events.yml +++ b/.buildkite/prepare-protected-events.yml @@ -105,6 +105,7 @@ steps: - label: ":scales: Evaluate Marinade Protected Events" env: + RUST_LOG: info,protected_event_distribution=debug WHITELIST_STAKE_AUTHORITY: stWirqFCf2Uts1JBL1Jsd3r6VBWhgnpdPxCTe1MFjrq,4bZ6o3eUUNXhKuqjdCnCoPAoLgWiuLYixKaxoa8PpiKk,ex9CfkBZZd6Nv9XdnoDmmB45ymbu4arXVk7g5pWnt3N commands: - 'buildkite-agent artifact download --include-retried-jobs validators.json .' diff --git a/protected-event-distribution/src/protected_events.rs b/protected-event-distribution/src/protected_events.rs index d9403f80..5b8a682d 100644 --- a/protected-event-distribution/src/protected_events.rs +++ b/protected-event-distribution/src/protected_events.rs @@ -1,4 +1,6 @@ use crate::revenue_expectation_meta::{RevenueExpectationMeta, RevenueExpectationMetaCollection}; +use crate::utils::bps_f64; + use { crate::utils::{bps, bps_to_fraction}, log::{debug, info}, @@ -107,7 +109,7 @@ pub fn collect_commission_increase_events( if let Some(revenue_expectation) = revenue_expectation { if revenue_expectation.actual_non_bid_pmpe < revenue_expectation.expected_non_bid_pmpe { debug!( - "Validator {vote_account} commission increase. Expected non bid PMPE: {}, actual non bid PMPE: {}", + "Validator {vote_account} increased commission, expected non bid PMPE: {}, actual non bid PMPE: {}", revenue_expectation.expected_non_bid_pmpe, revenue_expectation.actual_non_bid_pmpe ); @@ -120,12 +122,12 @@ pub fn collect_commission_increase_events( expected_mev_commission: revenue_expectation.expected_mev_commission, actual_mev_commission: revenue_expectation.actual_mev_commission, // expected_non_bid_pmpe is what how many SOLs was expected to gain per 1000 of staked SOLs - // expected_epr is how many lamports per 1 staked lamport was expected to be paid by validator + // expected_epr is ratio of how many SOLS to pay for 1 staked SOL (it does not matter if in loampors or SOLs when ratio) expected_epr: revenue_expectation.expected_non_bid_pmpe / 1000.0, actual_epr: revenue_expectation.actual_non_bid_pmpe / 1000.0, - epr_loss_bps: bps( - (revenue_expectation.expected_non_bid_pmpe - revenue_expectation.actual_non_bid_pmpe).round() as u64, - revenue_expectation.expected_non_bid_pmpe.round() as u64 + epr_loss_bps: bps_f64( + revenue_expectation.expected_non_bid_pmpe - revenue_expectation.actual_non_bid_pmpe, + revenue_expectation.expected_non_bid_pmpe ), stake, }, diff --git a/protected-event-distribution/src/settlement_claims.rs b/protected-event-distribution/src/settlement_claims.rs index f4fc4655..d7ec92ec 100644 --- a/protected-event-distribution/src/settlement_claims.rs +++ b/protected-event-distribution/src/settlement_claims.rs @@ -4,7 +4,7 @@ use crate::{ settlement_config::{build_protected_event_matcher, SettlementConfig}, stake_meta_index::StakeMetaIndex, }; -use log::info; +use log::{debug, info}; use solana_sdk::pubkey::Pubkey; use { @@ -129,6 +129,13 @@ pub fn generate_settlements( claims_amount, claims, }); + } else { + debug!( + "Skipping protected-event Settlement for vote account {} as claim amount {} is less than min settlement lamports {}", + protected_event.vote_account(), + claims_amount, + settlement_config.min_settlement_lamports() + ); } } } diff --git a/protected-event-distribution/src/settlement_config.rs b/protected-event-distribution/src/settlement_config.rs index 6094f267..a4f616b5 100644 --- a/protected-event-distribution/src/settlement_config.rs +++ b/protected-event-distribution/src/settlement_config.rs @@ -1,4 +1,5 @@ use crate::{protected_events::ProtectedEvent, settlement_claims::SettlementMeta}; +use log::debug; use serde::{Deserialize, Serialize}; use solana_sdk::pubkey::Pubkey; use std::collections::HashSet; @@ -65,13 +66,37 @@ pub fn build_protected_event_matcher( grace_downtime_bps, .. }, ProtectedEvent::DowntimeRevenueImpact { epr_loss_bps, .. }, - ) => *epr_loss_bps > grace_downtime_bps.unwrap_or_default(), + ) => { + if *epr_loss_bps > grace_downtime_bps.unwrap_or_default() { + true + } else { + debug!( + "DowntimeRevenueImpact event vote account {} with epr_loss_bps: {} is under grace period: {}", + protected_event.vote_account(), + epr_loss_bps, + grace_downtime_bps.unwrap_or_default() + ); + false + } + } ( SettlementConfig::CommissionIncreaseSettlement { grace_increase_bps, .. }, ProtectedEvent::CommissionIncrease { epr_loss_bps, .. }, - ) => *epr_loss_bps > grace_increase_bps.unwrap_or_default(), + ) => { + if *epr_loss_bps > grace_increase_bps.unwrap_or_default() { + true + } else { + debug!( + "CommissionIncrease event vote account {} with epr_loss_bps: {} is under grace period: {}", + protected_event.vote_account(), + epr_loss_bps, + grace_increase_bps.unwrap_or_default() + ); + false + } + } _ => false, }, ) diff --git a/protected-event-distribution/src/utils.rs b/protected-event-distribution/src/utils.rs index fa4b5b50..7d2d86ce 100644 --- a/protected-event-distribution/src/utils.rs +++ b/protected-event-distribution/src/utils.rs @@ -49,6 +49,14 @@ pub fn bps(value: u64, max: u64) -> u64 { 10000 * value / max } +pub fn bps_f64(value: f64, max: f64) -> u64 { + assert!( + max > 0.0, + "Cannot calculute bps from values: {value}, {max}" + ); + (10000.0 * value / max).round() as u64 +} + pub fn bps_to_fraction(value: u64) -> f64 { value as f64 / 10000.0 }