Upgrade VoteState#8348
Conversation
a6d24df to
dcd425c
Compare
| self.lamports()?.saturating_sub(meta.rent_exempt_reserve), // can't stake the rent ;) | ||
| vote_account.unsigned_key(), | ||
| &vote_account.state()?, | ||
| &State::<VoteStateVersions>::state(vote_account)?.convert_to_current(), |
There was a problem hiding this comment.
@mvines, I dislike this state() function because it requires whoever modifies this code to know that vote accounts are special/need special handling, and can't directly be deserialized into a VoteState object like its other counterparts(stake, storage, nonce, etc.). Ideally the Account type carries the type of the object it's storing so we can avoid this footgun (even in this PR, hopefully I haven't missed any conversions directly to VoteState from account.data), but that's a more sweeping change I can add as a follow-up.
There was a problem hiding this comment.
solana/sdk/src/account_utils.rs
Lines 38 to 40 in b18e405
We could add a trait that requires an implementation of fn convert_to_current() then make it a bound on T for State<T> and StateMut<T> hide it in the fn state() implementations
7521422 to
e013d49
Compare
6bf0d2d to
15656c7
Compare
Codecov Report
@@ Coverage Diff @@
## master #8348 +/- ##
========================================
- Coverage 80.3% 80.3% -0.1%
========================================
Files 254 256 +2
Lines 56235 56341 +106
========================================
+ Hits 45173 45254 +81
- Misses 11062 11087 +25 |
f4ac0dc to
25ec429
Compare
automerge (cherry picked from commit d821fd2)
Problem
No way to upgrade to new VoteState without breaking ABI
Depends on and includes changes from #8303
Summary of Changes
Convert VoteState's between different releases using an enum to differentiate the types
TODO: convert snapshots to include new VoteStates
Fixes #