Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Fix staking reward issue #4346

Closed
wants to merge 14 commits into from

Conversation

gui1117
Copy link
Contributor

@gui1117 gui1117 commented Dec 10, 2019

Fix #4121
Fix #4220
Fix #4331

TODO

  • maybe better naming
  • maybe improvement on storage structure
  • Kusama transition
  • Test storage upgrade transition with some real chain put_code upgrade

DONE

when implementing OnSessionEnding::on_session_ending, we must end era if the session ending is the last one of the era, this era end will reward validator and clear some storage. but we also potentially plan a new era in the future using the argument will_apply_at.
This new era planned must freeze the validators information for this future era: validator set, validators exposures, commissions and slot_stake.

This new era in planned with the storage EraStartSessionIndex which store the session index on which the era start from the current era to the futurest planned.
Era information is stored in ValidatorForEra and SlotStakeForEra.

@gui1117 gui1117 added the A3-in_progress Pull request is in progress. No review needed at this stage. label Dec 10, 2019
@gui1117 gui1117 force-pushed the gui-staking-fix-wrong-reward-attribution branch from d7009f9 to f2ae420 Compare December 11, 2019 12:39
@@ -443,8 +447,6 @@ pub fn advance_session() {
}

pub fn start_session(session_index: SessionIndex) {
// Compensate for session delay
let session_index = session_index + 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is one reason why tests with start_session has been modified, it makes them clearer IMHO, also most tests don't use this but start_era instead.

@gui1117 gui1117 added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Dec 11, 2019
@gavofyork gavofyork self-requested a review December 12, 2019 10:53
@gavofyork
Copy link
Member

The staking/reward/exposure dataset could be huge and complicated. Have you analysed the various complexity here?

@gavofyork gavofyork mentioned this pull request Dec 17, 2019
@gavofyork
Copy link
Member

I would prefer this be done in the way I outline in #4407

@gavofyork gavofyork added A1-onice and removed A0-please_review Pull request needs code review. labels Dec 17, 2019
@gui1117 gui1117 mentioned this pull request Jan 9, 2020
@gui1117 gui1117 closed this Jan 22, 2020
@gui1117 gui1117 deleted the gui-staking-fix-wrong-reward-attribution branch January 22, 2020 11:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants