-
Notifications
You must be signed in to change notification settings - Fork 890
Reorganize partitioned epoch rewards runtime code, 1 of 5 #511
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
Reorganize partitioned epoch rewards runtime code, 1 of 5 #511
Conversation
9b3e58a to
ff95329
Compare
|
frozen_abi change should be fine. Diff: |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #511 +/- ##
=======================================
Coverage 81.8% 81.8%
=======================================
Files 843 844 +1
Lines 228586 228589 +3
=======================================
+ Hits 187124 187138 +14
+ Misses 41462 41451 -11 |
43ed1a3 to
ff95329
Compare
|
Sorry, dumb accidental push. No changes since passed CI on Friday. |
ff95329 to
4d668bb
Compare
joncinque
left a comment
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!
|
|
||
| pub(crate) type StakeRewards = Vec<StakeReward>; | ||
|
|
||
| impl Bank { |
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.
I'll be honest, I don't love the impl Bank blocks in multiple files, because I'm used to just having one file open and jumping to function definitions within the same file. When possible, I prefer encapsulating the additional functionality in new types.
But in this case, where there's a lot of the Bank required, encapsulation would seriously complicate the scope of the refactor.
The only other options I came up with end up looking very similar (or worse) to multiple impl blocks:
- define functions that take the Bank and anything else required, but that ends up pretty much the same, and maybe worse because more fields might need to be exposed
- define a trait and have
Bankimplement it, but that's also worse since those functions become public
All that to say: it looks like the best option. And the fee distribution code has a separate impl Bank block, so there's some precedent. I'll just get better at navigating code 😅
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.
Thanks for your thoughts on this and sharing some alternative approaches! I definitely understand your perspective, but given how enormously sprawling Bank has become, I do think the benefits of this organizational approach outweigh the drawbacks (...and yeah, Justin and I have done some of this for other Bank functionality already 💦 )
Problem
Code for partitioned epoch rewards is peppered throughout bank.rs. It is very hard to trace the flows, and figure out which structs and methods are needed for calculation vs distribution, or for sysvar handling.
Summary of Changes
This is the first of 5 reorg/refactoring PRs.
There are no functional changes in this PR, although some
pubdeclarations may look different due to module nesting.This is best reviewed by commit.
Eventually, partitioned_epoch_rewards module will look like this:
The complete change is visible in a draft PR