Stake: Support merging fully-activated stake accounts#13712
Stake: Support merging fully-activated stake accounts#13712t-nelson merged 5 commits intosolana-labs:masterfrom
Conversation
|
WIP while I write tests. Works as expected on a local-cluster though! In the mean time, it'd be great to get a gut-check from @rwalker-com that this isn't utterly stupid for some obscure reason 🙏 |
|
|
||
| fn can_merge_with(&self, source: &Self) -> bool { | ||
| self.voter_pubkey == source.voter_pubkey | ||
| && (self.warmup_cooldown_rate - source.warmup_cooldown_rate).abs() < f64::EPSILON |
There was a problem hiding this comment.
you also want to verify that they were activated at the same time or are fully activated?
There was a problem hiding this comment.
Hey! Thanks for taking a peek! 🙂
I wasn't planning on handling the transient states. The fully-activated check is down here https://github.com/solana-labs/solana/pull/13712/files#diff-ab7997cf6770a6fae7b258e433b5dd8c33afa30431eab212552bc7f2b7b38db1R1164
1cf8fa7 to
2763b3c
Compare
2763b3c to
58862d3
Compare
|
I think this one's ready for final review now |
Codecov Report
@@ Coverage Diff @@
## master #13712 +/- ##
========================================
Coverage 82.1% 82.2%
========================================
Files 381 381
Lines 91992 92340 +348
========================================
+ Hits 75613 75951 +338
- Misses 16379 16389 +10 |
|
I'll try to rethink the organization of the helper functions in light of the rest of the comments 🤔 |
CriesofCarrots
left a comment
There was a problem hiding this comment.
Thanks for the extensive tests. I agree with @ryoqun that some expanded comments would help. Otherwise, looking good to me!
I'll take another pass when you make whatever helper fn changes you land on.
078513a to
bdabd0a
Compare
5754317 to
9c9f2b5
Compare
t-nelson
left a comment
There was a problem hiding this comment.
Ok, last round I think 😅
ryoqun
left a comment
There was a problem hiding this comment.
LGTM with nits.
Happily, I don't have anything anymore other than small renaming. What a solid work done from you. Also thank for enduring my persistent and long review window :)
CriesofCarrots
left a comment
There was a problem hiding this comment.
lgtm w/ a couple nits as well!
9c9f2b5 to
4b9413d
Compare
Pull request has been modified.
| #[error("stake account with activated stake cannot be merged")] | ||
| MergeActivatedStake, | ||
| #[error("stake account with transient stake cannot be merged")] | ||
| MergeTransientStake, |
There was a problem hiding this comment.
More accurate error name/message
| .0 | ||
| } | ||
|
|
||
| // returned tuple is (effective, activating, deactivating) stake |
There was a problem hiding this comment.
Commented stake_activating_and_deactivating() return tuple comment
| true, | ||
| ) { | ||
| /* | ||
| (e, a, d): e - effective, a - activating, d - deactivating */ |
There was a problem hiding this comment.
Heading comment for tuple patterns in get_if_mergeable() match.
Wonky use of multi-line comment to trick cargo fmt
| } | ||
| } | ||
|
|
||
| fn active_stake(&self) -> Option<&Stake> { |
There was a problem hiding this comment.
More descriptive name for active stake accessor
…3770) * stake: De-replicode mergable info extraction (cherry picked from commit dc7f897) * stake: Cosmetic - rename variable (cherry picked from commit bb2772d) * stake: Allow compatible, fully-active stake accounts to be merged (cherry picked from commit 8e73187) * stake: Remove disused test helper function (cherry picked from commit 6b9a019) * stake: Disallow stakes merging with themselves (cherry picked from commit 488ce98) Co-authored-by: Trent Nelson <trent@solana.com>

Problem
Only deactivated stake accounts can be merged. This poses a dilemma for automated staking tools in that they can only adjust a delegation downward without managing an ever-growing pool of accounts. It also exposes an unexpected asymmetry with
stake-split, which can be performed on delegated stake accountsSummary of Changes