-
Notifications
You must be signed in to change notification settings - Fork 239
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
Simd 118: use vote state from EpochStakes in calculation #1138
Simd 118: use vote state from EpochStakes in calculation #1138
Conversation
c7f69d9
to
516a54b
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1138 +/- ##
=========================================
- Coverage 82.1% 82.1% -0.1%
=========================================
Files 880 880
Lines 235632 235653 +21
=========================================
+ Hits 193649 193654 +5
- Misses 41983 41999 +16 |
@joncinque , thanks for all your time on #1102 and sorry for this whiplash 😕 Justin and I talked some on that PR and a little bit in DM and think this is a better direction than using the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the lateness on this, but looks good to me
Problem
Stake-reward calculation methods assume that the caller is interested in existing VoteState (specifically, the last epoch in the VoteState::epoch_credits list). This is only true when rewards are calculated at the epoch-boundary block. To support recalculation in later blocks, calculation needs to have access to the VoteState such as it was at the epoch boundary.
The VoteState itself contains previous epoch-credit information, and #1102 was a way to expose this data to calculation methods. However, that approach requires that vote accounts never be destroyed during the period in which recalculation might occur, which would probably necessitate a change to the Vote Program.
Meanwhile,
EpochStakes
cached in the bank and snapshots already preserves vote account state from the previous epoch.Summary of Changes
Use the vote accounts from EpochStakes in partitioned epoch rewards calculation.
Note: this works for epoch-boundary calculation because EpochStakes is updated before calculation:
agave/runtime/src/bank.rs
Lines 1423 to 1435 in be80b92
Currently includes a check that the operative stakes (fromRemovedStakesCache
) are identical to those from the EpochStakes. This isn't important for the existing implementation, where calculation is still all in the epoch-boundary block and EpochStakes and StakesCache are therefore equivalent, but will be helpful for recalculation. If you'd like me to punt this bit to the next PR, which adds recalculation, let me know.Closes #1102