Skip to content

Conversation

@grod220
Copy link
Member

@grod220 grod220 commented Oct 31, 2025

This pull request implements SIMD-0391, replacing all floating-point (f64) arithmetic in the Stake Program's warmup and cooldown logic with a fixed-point implementation using integer arithmetic. See SIMD for background rationale.

What's new?

  • The warmup/cooldown rate calculation now uses BPS values and u128 integer arithmetic.
  • All logic related to this now in isolated warmup_cooldown_allowance module
  • Delegation struct has been updated to maintain backward compatibility with on-chain data. The warmup_cooldown_rate: f64 field is replaced with _reserved: [u8; 8] (preserves memory layout)

Comment on lines -102 to -106
#[test]
fn assert_warmup_cooldown_rate() {
assert_eq!(warmup_cooldown_rate(0, Some(0)), NEW_WARMUP_COOLDOWN_RATE);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage in interface/src/warmup_cooldown_allowance.rs

Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall! Mostly nits and a few suggestions

///
/// This function allocates a share of the cluster's per-epoch deactivation allowance
/// proportional to the account's share of the previous epoch's total deactivating stake.
pub fn calculate_cooldown_allowance(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: just from a naming convention, this should be called calculate_deactivation_allowance to go with calculate_activation_allowance, ie let's be consistent with activation / deactivation or warmup / cooldown

@grod220 grod220 force-pushed the float-to-fixed-point branch from 009dc87 to 9c0ba5c Compare November 18, 2025 12:47
Comment on lines +701 to +702

pub fn stake_activating_and_deactivating<T: StakeHistoryGetEntry>(
Copy link
Member Author

@grod220 grod220 Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions below are copy/pasting of the legacy versions with changes related to:

  • Usage of new calculate_*_allowance()helpers
  • Additional code comments for context
  • Variable name changes for clarity

@grod220 grod220 requested a review from joncinque November 18, 2025 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants