From 03b6486f6eee8e0393ab443f02b6e712b350846a Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 10 Apr 2024 21:52:52 -0600 Subject: [PATCH 1/9] Add VoteState api --- sdk/program/src/vote/state/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sdk/program/src/vote/state/mod.rs b/sdk/program/src/vote/state/mod.rs index 25bd6efccf4887..92a9d34262c6ee 100644 --- a/sdk/program/src/vote/state/mod.rs +++ b/sdk/program/src/vote/state/mod.rs @@ -736,6 +736,18 @@ impl VoteState { } } + /// Number of "credits" owed to this account for a particular epoch. + /// Iterates VoteState::epoch_credits in reverse order, so will be most + /// performant for a recent epoch. Returns zero if epoch cannot be found. + pub fn credits_for_recent_epoch(&self, desired_epoch: Epoch) -> u64 { + for (epoch, credits, _prev_credits) in self.epoch_credits.iter().rev() { + if *epoch == desired_epoch { + return *credits; + } + } + return 0; + } + /// Number of "credits" owed to this account from the mining pool on a per-epoch basis, /// starting from credits observed. /// Each tuple of (Epoch, u64, u64) is read as (epoch, credits, prev_credits), where From efbd4e3497b3a83d55a392e97da1620f2c9bfad7 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 10 Apr 2024 22:22:12 -0600 Subject: [PATCH 2/9] Add and use compare_stake_vote_credits helper --- programs/stake/src/points.rs | 96 +++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 41 deletions(-) diff --git a/programs/stake/src/points.rs b/programs/stake/src/points.rs index d19bd3435a366d..bb7ebf66536ffe 100644 --- a/programs/stake/src/points.rs +++ b/programs/stake/src/points.rs @@ -116,47 +116,12 @@ pub(crate) fn calculate_stake_points_and_credits( let credits_in_stake = stake.credits_observed; let credits_in_vote = new_vote_state.credits(); // if there is no newer credits since observed, return no point - match credits_in_vote.cmp(&credits_in_stake) { - Ordering::Less => { - if let Some(inflation_point_calc_tracer) = inflation_point_calc_tracer.as_ref() { - inflation_point_calc_tracer(&SkippedReason::ZeroCreditsAndReturnRewinded.into()); - } - // Don't adjust stake.activation_epoch for simplicity: - // - generally fast-forwarding stake.activation_epoch forcibly (for - // artificial re-activation with re-warm-up) skews the stake - // history sysvar. And properly handling all the cases - // regarding deactivation epoch/warm-up/cool-down without - // introducing incentive skew is hard. - // - Conceptually, it should be acceptable for the staked SOLs at - // the recreated vote to receive rewards again immediately after - // rewind even if it looks like instant activation. That's - // because it must have passed the required warmed-up at least - // once in the past already - // - Also such a stake account remains to be a part of overall - // effective stake calculation even while the vote account is - // missing for (indefinite) time or remains to be pre-remove - // credits score. It should be treated equally to staking with - // delinquent validator with no differentiation. - - // hint with true to indicate some exceptional credits handling is needed - return CalculatedStakePoints { - points: 0, - new_credits_observed: credits_in_vote, - force_credits_update_with_skipped_reward: true, - }; - } - Ordering::Equal => { - if let Some(inflation_point_calc_tracer) = inflation_point_calc_tracer.as_ref() { - inflation_point_calc_tracer(&SkippedReason::ZeroCreditsAndReturnCurrent.into()); - } - // don't hint caller and return current value if credits remain unchanged (= delinquent) - return CalculatedStakePoints { - points: 0, - new_credits_observed: credits_in_stake, - force_credits_update_with_skipped_reward: false, - }; - } - Ordering::Greater => {} + if let Some(result) = compare_stake_vote_credits( + credits_in_vote, + credits_in_stake, + &inflation_point_calc_tracer, + ) { + return result; } let mut points = 0; @@ -210,6 +175,55 @@ pub(crate) fn calculate_stake_points_and_credits( } } +fn compare_stake_vote_credits( + credits_in_vote: u64, + credits_in_stake: u64, + inflation_point_calc_tracer: &Option, +) -> Option { + match credits_in_vote.cmp(&credits_in_stake) { + Ordering::Less => { + if let Some(inflation_point_calc_tracer) = inflation_point_calc_tracer.as_ref() { + inflation_point_calc_tracer(&SkippedReason::ZeroCreditsAndReturnRewinded.into()); + } + // Don't adjust stake.activation_epoch for simplicity: + // - generally fast-forwarding stake.activation_epoch forcibly (for + // artificial re-activation with re-warm-up) skews the stake + // history sysvar. And properly handling all the cases + // regarding deactivation epoch/warm-up/cool-down without + // introducing incentive skew is hard. + // - Conceptually, it should be acceptable for the staked SOLs at + // the recreated vote to receive rewards again immediately after + // rewind even if it looks like instant activation. That's + // because it must have passed the required warmed-up at least + // once in the past already + // - Also such a stake account remains to be a part of overall + // effective stake calculation even while the vote account is + // missing for (indefinite) time or remains to be pre-remove + // credits score. It should be treated equally to staking with + // delinquent validator with no differentiation. + + // hint with true to indicate some exceptional credits handling is needed + Some(CalculatedStakePoints { + points: 0, + new_credits_observed: credits_in_vote, + force_credits_update_with_skipped_reward: true, + }) + } + Ordering::Equal => { + if let Some(inflation_point_calc_tracer) = inflation_point_calc_tracer.as_ref() { + inflation_point_calc_tracer(&SkippedReason::ZeroCreditsAndReturnCurrent.into()); + } + // don't hint caller and return current value if credits remain unchanged (= delinquent) + Some(CalculatedStakePoints { + points: 0, + new_credits_observed: credits_in_stake, + force_credits_update_with_skipped_reward: false, + }) + } + Ordering::Greater => None, + } +} + #[cfg(test)] mod tests { use {super::*, crate::stake_state::new_stake, solana_sdk::native_token}; From f8c27b19a8a1d9b544d23138a0c7d62364dbc17e Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 10 Apr 2024 22:32:31 -0600 Subject: [PATCH 3/9] Add and use handle_epoch_credits helper --- programs/stake/src/points.rs | 102 ++++++++++++++++++++--------------- 1 file changed, 59 insertions(+), 43 deletions(-) diff --git a/programs/stake/src/points.rs b/programs/stake/src/points.rs index bb7ebf66536ffe..8657d10114615a 100644 --- a/programs/stake/src/points.rs +++ b/programs/stake/src/points.rs @@ -124,49 +124,13 @@ pub(crate) fn calculate_stake_points_and_credits( return result; } - let mut points = 0; - let mut new_credits_observed = credits_in_stake; - - for (epoch, final_epoch_credits, initial_epoch_credits) in - new_vote_state.epoch_credits().iter().copied() - { - let stake_amount = u128::from(stake.delegation.stake( - epoch, - stake_history, - new_rate_activation_epoch, - )); - - // figure out how much this stake has seen that - // for which the vote account has a record - let earned_credits = if credits_in_stake < initial_epoch_credits { - // the staker observed the entire epoch - final_epoch_credits - initial_epoch_credits - } else if credits_in_stake < final_epoch_credits { - // the staker registered sometime during the epoch, partial credit - final_epoch_credits - new_credits_observed - } else { - // the staker has already observed or been redeemed this epoch - // or was activated after this epoch - 0 - }; - let earned_credits = u128::from(earned_credits); - - // don't want to assume anything about order of the iterator... - new_credits_observed = new_credits_observed.max(final_epoch_credits); - - // finally calculate points for this epoch - let earned_points = stake_amount * earned_credits; - points += earned_points; - - if let Some(inflation_point_calc_tracer) = inflation_point_calc_tracer.as_ref() { - inflation_point_calc_tracer(&InflationPointCalculationEvent::CalculatedPoints( - epoch, - stake_amount, - earned_credits, - earned_points, - )); - } - } + let (points, new_credits_observed) = handle_epoch_credits( + new_vote_state.epoch_credits().iter().copied(), + stake, + stake_history, + new_rate_activation_epoch, + &inflation_point_calc_tracer, + ); CalculatedStakePoints { points, @@ -224,6 +188,58 @@ fn compare_stake_vote_credits( } } +fn handle_epoch_credits( + epoch_credits_iter: impl Iterator, + stake: &Stake, + stake_history: &StakeHistory, + new_rate_activation_epoch: Option, + inflation_point_calc_tracer: &Option, +) -> (u128, u64) { + let credits_in_stake = stake.credits_observed; + let mut points = 0; + let mut new_credits_observed = credits_in_stake; + + for (epoch, final_epoch_credits, initial_epoch_credits) in epoch_credits_iter { + let stake_amount = u128::from(stake.delegation.stake( + epoch, + stake_history, + new_rate_activation_epoch, + )); + + // figure out how much this stake has seen that + // for which the vote account has a record + let earned_credits = if credits_in_stake < initial_epoch_credits { + // the staker observed the entire epoch + final_epoch_credits - initial_epoch_credits + } else if credits_in_stake < final_epoch_credits { + // the staker registered sometime during the epoch, partial credit + final_epoch_credits - new_credits_observed + } else { + // the staker has already observed or been redeemed this epoch + // or was activated after this epoch + 0 + }; + let earned_credits = u128::from(earned_credits); + + // don't want to assume anything about order of the iterator... + new_credits_observed = new_credits_observed.max(final_epoch_credits); + + // finally calculate points for this epoch + let earned_points = stake_amount * earned_credits; + points += earned_points; + + if let Some(inflation_point_calc_tracer) = inflation_point_calc_tracer.as_ref() { + inflation_point_calc_tracer(&InflationPointCalculationEvent::CalculatedPoints( + epoch, + stake_amount, + earned_credits, + earned_points, + )); + } + } + (points, new_credits_observed) +} + #[cfg(test)] mod tests { use {super::*, crate::stake_state::new_stake, solana_sdk::native_token}; From a111d2107c2441de6bf1e2db5724b2b4c5971354 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 10 Apr 2024 22:43:26 -0600 Subject: [PATCH 4/9] Add and use calculate_stake_points_and_credits_through_epoch --- programs/stake/src/points.rs | 38 +++++++++++++++++++++++++++++++++++ programs/stake/src/rewards.rs | 12 +++++++---- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/programs/stake/src/points.rs b/programs/stake/src/points.rs index 8657d10114615a..5b2c6d81f5f755 100644 --- a/programs/stake/src/points.rs +++ b/programs/stake/src/points.rs @@ -139,6 +139,44 @@ pub(crate) fn calculate_stake_points_and_credits( } } +pub(crate) fn calculate_stake_points_and_credits_through_epoch( + max_epoch: Epoch, + stake: &Stake, + new_vote_state: &VoteState, + stake_history: &StakeHistory, + inflation_point_calc_tracer: Option, + new_rate_activation_epoch: Option, +) -> CalculatedStakePoints { + let credits_in_stake = stake.credits_observed; + let credits_in_vote = new_vote_state.credits_for_recent_epoch(max_epoch); + // if there is no newer credits since observed, return no point + if let Some(result) = compare_stake_vote_credits( + credits_in_vote, + credits_in_stake, + &inflation_point_calc_tracer, + ) { + return result; + } + + let (points, new_credits_observed) = handle_epoch_credits( + new_vote_state + .epoch_credits() + .iter() + .take_while(|(epoch, _, _)| *epoch <= max_epoch) + .copied(), + stake, + stake_history, + new_rate_activation_epoch, + &inflation_point_calc_tracer, + ); + + CalculatedStakePoints { + points, + new_credits_observed, + force_credits_update_with_skipped_reward: false, + } +} + fn compare_stake_vote_credits( credits_in_vote: u64, credits_in_stake: u64, diff --git a/programs/stake/src/rewards.rs b/programs/stake/src/rewards.rs index 08416996520289..902dd9e75bcadb 100644 --- a/programs/stake/src/rewards.rs +++ b/programs/stake/src/rewards.rs @@ -3,8 +3,8 @@ use { crate::points::{ - calculate_stake_points_and_credits, CalculatedStakePoints, InflationPointCalculationEvent, - PointValue, SkippedReason, + calculate_stake_points_and_credits_through_epoch, CalculatedStakePoints, + InflationPointCalculationEvent, PointValue, SkippedReason, }, solana_sdk::{ account::{AccountSharedData, WritableAccount}, @@ -138,7 +138,8 @@ fn calculate_stake_rewards( points, new_credits_observed, mut force_credits_update_with_skipped_reward, - } = calculate_stake_points_and_credits( + } = calculate_stake_points_and_credits_through_epoch( + rewarded_epoch, stake, vote_state, stake_history, @@ -228,7 +229,10 @@ fn calculate_stake_rewards( mod tests { use { super::*, - crate::{points::null_tracer, stake_state::new_stake}, + crate::{ + points::{calculate_stake_points_and_credits, null_tracer}, + stake_state::new_stake, + }, solana_sdk::{native_token, pubkey::Pubkey}, }; From 6e98df733726ee4d6db487ed157ccb58d7a99c7d Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 10 Apr 2024 23:03:56 -0600 Subject: [PATCH 5/9] wip: add recalculate_partitions method --- .../partitioned_epoch_rewards/calculation.rs | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/runtime/src/bank/partitioned_epoch_rewards/calculation.rs b/runtime/src/bank/partitioned_epoch_rewards/calculation.rs index 4b86acd922dfbe..4f3237874d18b0 100644 --- a/runtime/src/bank/partitioned_epoch_rewards/calculation.rs +++ b/runtime/src/bank/partitioned_epoch_rewards/calculation.rs @@ -3,7 +3,7 @@ use { epoch_rewards_hasher::hash_rewards_into_partitions, Bank, CalculateRewardsAndDistributeVoteRewardsResult, CalculateValidatorRewardsResult, EpochRewardCalculateParamInfo, PartitionedRewardsCalculation, StakeRewardCalculation, - StakeRewardCalculationPartitioned, VoteRewardsAccounts, + StakeRewardCalculationPartitioned, StakeRewards, VoteRewardsAccounts, }, crate::bank::{ PrevEpochInflationRewards, RewardCalcTracer, RewardCalculationEvent, RewardsMetrics, @@ -485,6 +485,48 @@ impl Bank { (points > 0).then_some(PointValue { rewards, points }) } + + fn recalculate_partitions( + &self, + rewarded_epoch: Epoch, + reward_calc_tracer: Option, + thread_pool: &ThreadPool, + metrics: &mut RewardsMetrics, + ) -> Vec { + let epoch_rewards_sysvar = self.get_epoch_rewards_sysvar(); + if !epoch_rewards_sysvar.active { + return vec![]; + } + + let point_value = PointValue { + rewards: epoch_rewards_sysvar.total_rewards, + points: epoch_rewards_sysvar.total_points, + }; + + // TODO: will these stakes be unmolested enough? + let stakes = self.stakes_cache.stakes(); + // TODO: update this? + let reward_calculate_param = self.get_epoch_reward_calculate_param_info(&stakes); + + let ( + _, + StakeRewardCalculation { + mut stake_rewards, .. + }, + ) = self.calculate_stake_vote_rewards( + &reward_calculate_param, + rewarded_epoch, + point_value, + thread_pool, + reward_calc_tracer, + metrics, + ); + hash_rewards_into_partitions( + std::mem::take(&mut stake_rewards), + &epoch_rewards_sysvar.parent_blockhash, + epoch_rewards_sysvar.num_partitions as usize, + ) + } } #[cfg(test)] From 06b755ea3ede5595f10f97b196a998280af72804 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Fri, 12 Jan 2024 13:24:25 -0700 Subject: [PATCH 6/9] wip: remove feature deactivation from TestValidator --- validator/src/bin/solana-test-validator.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/validator/src/bin/solana-test-validator.rs b/validator/src/bin/solana-test-validator.rs index 580a6a14027518..7f7865d8ac18e8 100644 --- a/validator/src/bin/solana-test-validator.rs +++ b/validator/src/bin/solana-test-validator.rs @@ -23,7 +23,6 @@ use { account::AccountSharedData, clock::Slot, epoch_schedule::EpochSchedule, - feature_set, native_token::sol_to_lamports, pubkey::Pubkey, rent::Rent, @@ -352,9 +351,7 @@ fn main() { exit(1); }); - let mut features_to_deactivate = pubkeys_of(&matches, "deactivate_feature").unwrap_or_default(); - // Remove this when client support is ready for the enable_partitioned_epoch_reward feature - features_to_deactivate.push(feature_set::enable_partitioned_epoch_reward::id()); + let features_to_deactivate = pubkeys_of(&matches, "deactivate_feature").unwrap_or_default(); if TestValidatorGenesis::ledger_exists(&ledger_path) { for (name, long) in &[ From 3904622002ac01e12b33c6e8bf30169efa8eb2e8 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Thu, 11 Apr 2024 14:50:15 -0600 Subject: [PATCH 7/9] wip: compare recalculated partitions --- runtime/src/bank.rs | 30 +++++++++++++++++++ .../partitioned_epoch_rewards/calculation.rs | 2 +- .../bank/partitioned_epoch_rewards/sysvar.rs | 4 +-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 33e4fa63bc0d19..1d5e4b4cc12f86 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -1663,6 +1663,36 @@ impl Bank { .fill_missing_sysvar_cache_entries(&bank); bank.rebuild_skipped_rewrites(); + let epoch_rewards_sysvar = bank.get_epoch_rewards_sysvar(); + if epoch_rewards_sysvar.active { + use crate::bank::partitioned_epoch_rewards::StartBlockHeightAndRewards; + let (thread_pool, _thread_pool_time) = measure!( + ThreadPoolBuilder::new() + .thread_name(|i| format!("solBnkNewFlds{i:02}")) + .build() + .expect("new rayon threadpool"), + "thread_pool_creation", + ); + let mut rewards_metrics = RewardsMetrics::default(); + let recalculated = bank.recalculate_partitions( + bank.epoch() - 1, + null_tracer(), + &thread_pool, + &mut rewards_metrics, + ); + let alternate_epoch_reward_status = + EpochRewardStatus::Active(StartBlockHeightAndRewards { + start_block_height: epoch_rewards_sysvar.distribution_starting_block_height, + stake_rewards_by_partition: Arc::new(recalculated), + }); + warn!( + "{:?}", + alternate_epoch_reward_status == bank.epoch_reward_status + ); + } else { + warn!("rewards period not active"); + } + // Sanity assertions between bank snapshot and genesis config // Consider removing from serializable bank state // (BankFieldsToSerialize/BankFieldsToDeserialize) and initializing diff --git a/runtime/src/bank/partitioned_epoch_rewards/calculation.rs b/runtime/src/bank/partitioned_epoch_rewards/calculation.rs index 4f3237874d18b0..f9f52b4d8999d8 100644 --- a/runtime/src/bank/partitioned_epoch_rewards/calculation.rs +++ b/runtime/src/bank/partitioned_epoch_rewards/calculation.rs @@ -486,7 +486,7 @@ impl Bank { (points > 0).then_some(PointValue { rewards, points }) } - fn recalculate_partitions( + pub(in crate::bank) fn recalculate_partitions( &self, rewarded_epoch: Epoch, reward_calc_tracer: Option, diff --git a/runtime/src/bank/partitioned_epoch_rewards/sysvar.rs b/runtime/src/bank/partitioned_epoch_rewards/sysvar.rs index feb1d93461e983..82203167252080 100644 --- a/runtime/src/bank/partitioned_epoch_rewards/sysvar.rs +++ b/runtime/src/bank/partitioned_epoch_rewards/sysvar.rs @@ -99,9 +99,7 @@ impl Bank { /// Get EpochRewards sysvar. Returns EpochRewards::default() if sysvar /// account cannot be found or cannot be deserialized. - pub(in crate::bank::partitioned_epoch_rewards) fn get_epoch_rewards_sysvar( - &self, - ) -> sysvar::epoch_rewards::EpochRewards { + pub(in crate::bank) fn get_epoch_rewards_sysvar(&self) -> sysvar::epoch_rewards::EpochRewards { from_account( &self .get_account(&sysvar::epoch_rewards::id()) From 5821fdfef3b5cb77e64a129743bda81aab50256a Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Fri, 12 Apr 2024 13:15:45 -0600 Subject: [PATCH 8/9] wip: testing stuff --- accounts-db/src/partitioned_rewards.rs | 2 +- runtime/src/bank.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/accounts-db/src/partitioned_rewards.rs b/accounts-db/src/partitioned_rewards.rs index 652a907d3a7bb6..14d636725a775c 100644 --- a/accounts-db/src/partitioned_rewards.rs +++ b/accounts-db/src/partitioned_rewards.rs @@ -33,7 +33,7 @@ impl Default for PartitionedEpochRewardsConfig { // Target to store 64 rewards per entry/tick in a block. A block has a minimum of 64 // entries/tick. This gives 4096 total rewards to store in one block. // This constant affects consensus. - stake_account_stores_per_block: 4096, + stake_account_stores_per_block: 40, test_enable_partitioned_rewards: false, test_compare_partitioned_epoch_rewards: false, } diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 1d5e4b4cc12f86..e010d2632be7fc 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -1664,6 +1664,7 @@ impl Bank { bank.rebuild_skipped_rewrites(); let epoch_rewards_sysvar = bank.get_epoch_rewards_sysvar(); + warn!("{:?}", epoch_rewards_sysvar); if epoch_rewards_sysvar.active { use crate::bank::partitioned_epoch_rewards::StartBlockHeightAndRewards; let (thread_pool, _thread_pool_time) = measure!( From 17ebb8684d309539de5d2d7cf7ca83530f2749a8 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Fri, 12 Apr 2024 16:40:53 -0600 Subject: [PATCH 9/9] wip: moar testing --- accounts-db/src/partitioned_rewards.rs | 2 +- runtime/src/bank.rs | 25 ++++++++++++++++++- .../partitioned_epoch_rewards/calculation.rs | 2 ++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/accounts-db/src/partitioned_rewards.rs b/accounts-db/src/partitioned_rewards.rs index 14d636725a775c..1012b0e8a476a2 100644 --- a/accounts-db/src/partitioned_rewards.rs +++ b/accounts-db/src/partitioned_rewards.rs @@ -33,7 +33,7 @@ impl Default for PartitionedEpochRewardsConfig { // Target to store 64 rewards per entry/tick in a block. A block has a minimum of 64 // entries/tick. This gives 4096 total rewards to store in one block. // This constant affects consensus. - stake_account_stores_per_block: 40, + stake_account_stores_per_block: 4, test_enable_partitioned_rewards: false, test_compare_partitioned_epoch_rewards: false, } diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index e010d2632be7fc..a45e023ab53094 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -1683,13 +1683,36 @@ impl Bank { ); let alternate_epoch_reward_status = EpochRewardStatus::Active(StartBlockHeightAndRewards { - start_block_height: epoch_rewards_sysvar.distribution_starting_block_height, + start_block_height: epoch_rewards_sysvar.distribution_starting_block_height - 1, stake_rewards_by_partition: Arc::new(recalculated), }); + warn!("SLOT {:?}", bank.slot()); + warn!("BLOCK HEIGHT {:?}", bank.block_height()); + warn!("rewards {:?}", bank.rewards); warn!( "{:?}", alternate_epoch_reward_status == bank.epoch_reward_status ); + if let EpochRewardStatus::Active(StartBlockHeightAndRewards { + stake_rewards_by_partition, + .. + }) = alternate_epoch_reward_status { + warn!("RECALC num_partitions {:?}", stake_rewards_by_partition.len()); + for parition in stake_rewards_by_partition.iter() { + warn!("RECALC {:?}", parition.len()); + } + } + // warn!("RECALC {:?}", alternate_epoch_reward_status); + if let EpochRewardStatus::Active(StartBlockHeightAndRewards { + stake_rewards_by_partition, + .. + }) = &bank.epoch_reward_status { + warn!("bank num_partitions {:?}", stake_rewards_by_partition.len()); + for parition in stake_rewards_by_partition.iter() { + warn!("bank {:?}", parition.len()); + } + } + // warn!("bank {:?}", bank.epoch_reward_status); } else { warn!("rewards period not active"); } diff --git a/runtime/src/bank/partitioned_epoch_rewards/calculation.rs b/runtime/src/bank/partitioned_epoch_rewards/calculation.rs index f9f52b4d8999d8..fc8c7fcae4341f 100644 --- a/runtime/src/bank/partitioned_epoch_rewards/calculation.rs +++ b/runtime/src/bank/partitioned_epoch_rewards/calculation.rs @@ -364,6 +364,7 @@ impl Bank { reward_calc_tracer.as_ref(), new_warmup_cooldown_rate_epoch, ); + log::warn!("redeemed {:?}", redeemed); let post_lamport = stake_account.lamports(); @@ -521,6 +522,7 @@ impl Bank { reward_calc_tracer, metrics, ); + log::warn!("recalc stake_rewards {:?}", stake_rewards.len()); hash_rewards_into_partitions( std::mem::take(&mut stake_rewards), &epoch_rewards_sysvar.parent_blockhash,