-
Notifications
You must be signed in to change notification settings - Fork 259
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
Check EpochRewards::active within the Stake Program #617
Check EpochRewards::active within the Stake Program #617
Conversation
Oh also: I know we need some comprehensive tests of this logic in (edit) Test added |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #617 +/- ##
========================================
Coverage 81.8% 81.9%
========================================
Files 851 851
Lines 230238 230394 +156
========================================
+ Hits 188511 188729 +218
+ Misses 41727 41665 -62 |
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.
Do you mind splitting this into a change that removes the old logic and a change that introduces the new logic? As for tests, I would like to see at least one more that checks that get min delegation still works during epoch rewards
3ed9bca
to
caf1b0e
Compare
Removed the old-logic-removal commits from this PR. |
caf1b0e
to
2e21beb
Compare
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.
Looks great!
// The EpochRewards sysvar only exists after the | ||
// enable_partitioned_epoch_reward feature is activated. If it exists, check | ||
// the `active` field | ||
let epoch_rewards_active = invoke_context | ||
.get_sysvar_cache() | ||
.get_epoch_rewards() | ||
.map(|epoch_rewards| epoch_rewards.active) | ||
.unwrap_or(false); |
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.
cc @2501babe on this change, since the bpf version of the stake program will need to fetch the epoch rewards using the new syscall
Problem
As per SIMD-0118, credits to stake accounts should be allowed during the rewards interval. The current implementation Errors all transactions that load a stake account as writable, overly restrictive.
Summary of Changes
Note: this implements the specification in the SIMD, but I think this could be relaxed on a handful of instructions, like Authorize and SetLockup. It's possible that even Initialize, DelegateStake, and Deactivate could be supported during the rewards interval as well, depending on cache state for recalculation (boot from snapshot). At any rate, unless either of you feel strongly about doing that now, I'll make any of those changes in a separate PR.
Remove existingcheck_account_access()
call in SVMI did leave this method in the
TransactionProcessingCallback
trait, however. It's a generic-enough name that it could be used for something other than rewards-period restriction.Towards #426