Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
eeeacd5
adds tests to ensure that AG votes are paid
akhi3030 Apr 7, 2026
5f6a5f2
implements logic to pay AG rewards during PER
akhi3030 Apr 7, 2026
bdfae60
various improvements
akhi3030 Apr 7, 2026
ab72e79
collect rewards for multiple slots
akhi3030 Apr 8, 2026
9ef69a1
pay to multiple delegators
akhi3030 Apr 8, 2026
80e31b3
different commissions
akhi3030 Apr 8, 2026
ff72b40
s/alpenglow_feature/is_alpenglow_active
akhi3030 Apr 9, 2026
5d8f880
debugging
akhi3030 Apr 9, 2026
50e56aa
a new test
akhi3030 Apr 10, 2026
035c0e4
fix staking bug
akhi3030 Apr 10, 2026
0a959ba
more debugging
akhi3030 Apr 13, 2026
4b63dd5
Merge branch 'master' into do-add-vote-rewards-tests
akhi3030 Apr 13, 2026
a5d6cc0
look up total-stake
akhi3030 Apr 13, 2026
caa1599
cleanup debugging
akhi3030 Apr 14, 2026
219a938
fix test
akhi3030 Apr 14, 2026
493e0e9
more fixes to tests
akhi3030 Apr 14, 2026
36db2e1
removing unwrap and related cleanup
akhi3030 Apr 14, 2026
04af938
pay multiple slots
akhi3030 Apr 14, 2026
165caa1
pr feedback
akhi3030 Apr 15, 2026
a3a0605
creating second validator
akhi3030 Apr 15, 2026
7901242
add logging and tracing
akhi3030 Apr 15, 2026
346ca18
check status of reward epoch
akhi3030 Apr 16, 2026
37eb128
Merge branch 'master' into do-add-vote-rewards-tests
akhi3030 Apr 16, 2026
cd2ce1f
simplify increment_credits
akhi3030 Apr 16, 2026
578f74d
introduce marker element
akhi3030 Apr 16, 2026
188e010
add marker
akhi3030 Apr 16, 2026
cfb5aed
update payout part to look at the marker
akhi3030 Apr 16, 2026
ee20f40
cleanup
akhi3030 Apr 16, 2026
bf3c81d
more cleanup
akhi3030 Apr 16, 2026
6a3effb
handling migrating phase partially
akhi3030 Apr 16, 2026
a5dde09
factor out iteration
akhi3030 Apr 17, 2026
f15f51f
remove epoch_inflation_rewards
akhi3030 Apr 17, 2026
431a417
use tower and ag points
akhi3030 Apr 17, 2026
2dd06bc
removing status
akhi3030 Apr 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,17 @@ impl AddAssign for SquashTiming {
}
}

/// Returned from `Bank::is_alpenglow_active_in_epoch()`.
#[derive(Debug)]
pub(crate) enum AlpenglowEpochStatus {
/// This is a full tower epoch
Tower,
/// The epoch started in tower and then switched to alpenglow
MigrationEpoch,
/// This is a full alpenglow epoch
FullAlpenglow,
}

#[derive(Clone, Debug, Default, PartialEq)]
pub struct CollectorFeeDetails {
transaction_fee: u64,
Expand Down
42 changes: 39 additions & 3 deletions runtime/src/bank/partitioned_epoch_rewards/calculation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ use {
},
crate::{
bank::{
RewardCalcTracer, RewardCalculationEvent, RewardCommission, RewardCommissions,
RewardsMetrics, null_tracer,
AlpenglowEpochStatus, RewardCalcTracer, RewardCalculationEvent, RewardCommission,
RewardCommissions, RewardsMetrics, null_tracer,
},
inflation_rewards::{
points::{CalculationEnvironment, DelegatedVoteState, PointValue, calculate_points},
points::{
AlpenglowStakeState, CalculationEnvironment, DelegatedVoteState, PointValue,
calculate_points,
},
redeem_rewards,
},
stake_account::StakeAccount,
Expand Down Expand Up @@ -432,6 +435,7 @@ impl Bank {
new_rate_activation_epoch: Option<Epoch>,
delay_commission_updates: bool,
commission_rate_in_basis_points: bool,
ag_epoch_status: &AlpenglowEpochStatus,
) -> Option<DelegationRewards> {
// curry closure to add the contextual stake_pubkey
let reward_calc_tracer = reward_calc_tracer.as_ref().map(|outer| {
Expand Down Expand Up @@ -479,6 +483,18 @@ impl Bank {
vote_state.commission() as u16 * 100
};

let ag_stake_state = match ag_epoch_status {
AlpenglowEpochStatus::Tower => AlpenglowStakeState::Tower,
AlpenglowEpochStatus::FullAlpenglow => AlpenglowStakeState::Alpenglow {
vote_pubkey,
epoch_stakes: &self.epoch_stakes,
},
AlpenglowEpochStatus::MigrationEpoch => AlpenglowStakeState::Migrating {
vote_pubkey,
epoch_stakes: &self.epoch_stakes,
},
};

match redeem_rewards(
stake_state,
commission_bps,
Expand All @@ -492,6 +508,7 @@ impl Bank {
},
reward_calc_tracer,
stake_account.lamports(),
ag_stake_state,
) {
Ok((stake_reward, commission_lamports, stake)) => {
let stake_reward = PartitionedStakeReward {
Expand Down Expand Up @@ -519,6 +536,22 @@ impl Bank {
}
}

/// Returns the status of alpenglow activation in `epoch`.
pub(crate) fn is_alpenglow_active_in_epoch(&self, epoch: Epoch) -> AlpenglowEpochStatus {
let Some(genesis_cert) = self.get_alpenglow_genesis_certificate() else {
return AlpenglowEpochStatus::Tower;
};
let cert_slot = genesis_cert.cert_type.slot();
match (
cert_slot <= self.epoch_schedule.get_first_slot_in_epoch(epoch),
cert_slot <= self.epoch_schedule.get_last_slot_in_epoch(epoch),
) {
(true, _) => AlpenglowEpochStatus::FullAlpenglow,
(false, true) => AlpenglowEpochStatus::MigrationEpoch,
(false, false) => AlpenglowEpochStatus::Tower,
}
}

/// Calculates epoch rewards for stake/commission accounts
/// Returns commission accounts, stake rewards, and the sum of all stake rewards in lamports
fn calculate_stake_rewards_and_commissions<'a>(
Expand All @@ -537,6 +570,8 @@ impl Bank {
let delay_commission_updates = feature_snapshot.delay_commission_updates;
let commission_rate_in_basis_points = feature_snapshot.commission_rate_in_basis_points;

let ag_epoch_status = self.is_alpenglow_active_in_epoch(rewarded_epoch);

let mut measure_redeem_rewards = Measure::start("redeem-rewards");
// For N stake delegations, where N is >1,000,000, we produce:
// * N stake rewards,
Expand Down Expand Up @@ -567,6 +602,7 @@ impl Bank {
new_warmup_cooldown_rate_epoch,
delay_commission_updates,
commission_rate_in_basis_points,
&ag_epoch_status,
)
});
let (stake_reward, maybe_reward_record) = match maybe_reward_record {
Expand Down
Loading
Loading