Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

stake: Don't pay out rewards for epochs where inflation was not enabled#13680

Merged
mergify[bot] merged 1 commit intosolana-labs:masterfrom
t-nelson:no-preinflation-stake-rewards
Nov 21, 2020
Merged

stake: Don't pay out rewards for epochs where inflation was not enabled#13680
mergify[bot] merged 1 commit intosolana-labs:masterfrom
t-nelson:no-preinflation-stake-rewards

Conversation

@t-nelson
Copy link
Copy Markdown
Contributor

Problem

The stake program will redeem rewards for all unpaid epochs in the delegate's vote history up to the current one, including those for which inflation was disabled

Summary of Changes

An alternative approach to #13233

Always update the stake state's observed_credits stamp, when inflation is disabled.

closes #13233

@t-nelson t-nelson force-pushed the no-preinflation-stake-rewards branch from 07448b2 to e0b3db4 Compare November 19, 2020 03:25
Comment thread programs/stake/src/stake_state.rs Outdated
CriesofCarrots
CriesofCarrots previously approved these changes Nov 19, 2020
Copy link
Copy Markdown
Contributor

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

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

lgtm!

Comment thread programs/stake/src/stake_state.rs Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 19, 2020

Codecov Report

Merging #13680 (c695366) into master (0ec8069) will increase coverage by 0.0%.
The diff coverage is 100.0%.

@@           Coverage Diff           @@
##           master   #13680   +/-   ##
=======================================
  Coverage    82.1%    82.1%           
=======================================
  Files         381      381           
  Lines       91948    91955    +7     
=======================================
+ Hits        75561    75574   +13     
+ Misses      16387    16381    -6     

@ryoqun
Copy link
Copy Markdown
Contributor

ryoqun commented Nov 19, 2020

Thanks for coming up with this.

@t-nelson I like this approach. Here's a bit of context and my reasoning for that.

When I originally wrote #13233, the situation was rather limited, not needing a gating for stake program. What a good old peaceful day. I was only aware of small inflation skew.....

Also, I was completely new to the relevant code. So, I originally approached to the solution of not going outside inflation code (thereby not modifying accounts so that we can deploy changes without gating) and opted for not rewriting stake accounts.

But, the situation changed significantly.... now that we have whole switch for the stake native program and we'll change staking calculation for stuck deactivating ones, fixing spoof bugs, and even more we'll rewrite bunch of stake accounts. And now I've been really deep into the code.

So, why not updating like this pr in aggressive implementation change way? ;) Especially, this is a blocker for the SoM and stake merges at the same time.

@t-nelson t-nelson force-pushed the no-preinflation-stake-rewards branch from e0b3db4 to c695366 Compare November 21, 2020 03:01
@mergify mergify Bot dismissed CriesofCarrots’s stale review November 21, 2020 03:01

Pull request has been modified.

@t-nelson
Copy link
Copy Markdown
Contributor Author

Updated with a much simpler change set after some great discussions with @ryoqun and @CriesofCarrots. Many thanks to both!

Copy link
Copy Markdown
Contributor

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

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

😍 how small this fix ended up!

Copy link
Copy Markdown
Contributor

@ryoqun ryoqun left a comment

Choose a reason for hiding this comment

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

LGTM! Also, I checked this like before by running ledger-tool with mainnet-beta snapshot; I confirmed this pr actually updates all stake delegations' credits_observed only when inflation is disabled.

@t-nelson t-nelson added the automerge Merge this Pull Request automatically once CI passes label Nov 21, 2020
@mergify mergify Bot merged commit 13aa38d into solana-labs:master Nov 21, 2020
@t-nelson t-nelson deleted the no-preinflation-stake-rewards branch November 21, 2020 04:25
@ryoqun
Copy link
Copy Markdown
Contributor

ryoqun commented Nov 27, 2020

LGTM! Also, I checked this like before by running ledger-tool with mainnet-beta snapshot; I confirmed this pr actually updates all stake delegations' credits_observed only when inflation is disabled.

seems like my check was wrong in some way..: #13836.

@ryoqun
Copy link
Copy Markdown
Contributor

ryoqun commented Nov 27, 2020

LGTM! Also, I checked this like before by running ledger-tool with mainnet-beta snapshot; I confirmed this pr actually updates all stake delegations' credits_observed only when inflation is disabled.

seems like my check was wrong in some way..: #13836.

well, it turns out mainnet-beta ledger didn't have those problematic stake accounts in fact. So, my testing with mb was rather correct by itself.

the testnet had those problematic stake accounts.... I really wish I had tested with testnet as well at the time.........

Well, I thought we really care about mainnet-beta and mainnet-beta has been used by real customers and I tended to think it has most exhaustive set of various accounts state, regarding testing only it is enough to stamp LGTM (this laziness was combined with time-pressures as well).

I learnt an important lesson here....

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

automerge Merge this Pull Request automatically once CI passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants