Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/1207513338125664 delayed staking rewards #280

Merged
merged 32 commits into from
Nov 22, 2024

Conversation

talhadaar
Copy link
Member

@talhadaar talhadaar commented Aug 28, 2024

WIP - Opened for discussion

  • CollatorBlock: now a double map, stores numbers of blocks authored by a collator in each session.
  • AtStake StorageDoubleMap: here we snapshot collator staking state at the start of the round.
  • DelayedPayoutInfo: Stores the info we need to calculate payouts for collators/delegators for blocks generated in previous session.
  • payout_collator(end_session_flag) - Takes a block author from previous session from CollatorBlock, takes their staking state of previous session from AtStake, calculates and pays out their rewards based DelayedPayoutInfo.
    • end_session_flag indicates if this round is ending(probably by force_new_roud), if so, then execute all remaining delayed payouts for the previous round.
    • if this flag is true, then snapshot of previous round is also cleared from storage.

@talhadaar talhadaar requested a review from sfffaaa August 28, 2024 15:06
@talhadaar talhadaar self-assigned this Aug 28, 2024
@talhadaar talhadaar marked this pull request as draft August 28, 2024 15:06
@talhadaar talhadaar changed the title Feat/1207513338125664 delated staking rewards Feat/1207513338125664 delayed staking rewards Aug 28, 2024
pallets/parachain-staking/src/lib.rs Outdated Show resolved Hide resolved
pallets/parachain-staking/src/lib.rs Outdated Show resolved Hide resolved
pallets/parachain-staking/src/lib.rs Outdated Show resolved Hide resolved
pallets/parachain-staking/src/lib.rs Outdated Show resolved Hide resolved
pallets/parachain-staking/src/lib.rs Show resolved Hide resolved
pallets/parachain-staking/src/lib.rs Outdated Show resolved Hide resolved
pallets/parachain-staking/src/lib.rs Outdated Show resolved Hide resolved
pallets/parachain-staking/src/migrations.rs Outdated Show resolved Hide resolved
@talhadaar talhadaar force-pushed the feat/1207513338125664_delated-staking-rewards branch from ac18836 to 1f580f3 Compare October 10, 2024 12:10
@talhadaar talhadaar marked this pull request as ready for review November 21, 2024 12:54
let issue_number = if ed == T::CurrencyBalance::from(0_u32) {
T::Currency::reducible_balance(&pot, Preservation::Preserve, Fortitude::Polite)
// Avoid the pot complaint no balance there
.checked_sub(&T::CurrencyBalance::from(10_u32))
Copy link
Contributor

Choose a reason for hiding this comment

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

Please keep this logic. Otherwise, every time after we distribute the reward, one event will be emitted because we'll drain all the tokens in the pot

Copy link
Member Author

Choose a reason for hiding this comment

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

Incorporated this back in🤝

@talhadaar talhadaar merged commit 756f984 into dev Nov 22, 2024
1 check passed
@talhadaar talhadaar deleted the feat/1207513338125664_delated-staking-rewards branch November 22, 2024 10:48
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.

2 participants