vote-program: handler: init v4 support#8120
Conversation
|
The Firedancer team maintains a line-for-line reimplementation of the |
| VoteStateTargetVersion::V4 => { | ||
| VoteStateV4::default().set_vote_account_state(vote_account) | ||
| } |
There was a problem hiding this comment.
This should just zero the vote account data after we do the resize / rent check for prev vote state versions
There was a problem hiding this comment.
I believe this also belongs to follow-up now?
| instruction_context.try_borrow_instruction_account(vote_account_index)?; | ||
| let vote_state = | ||
| VoteStateHandler::deserialize_and_convert(&vote_account, VoteStateTargetVersion::V3)?; | ||
| let vote_state = VoteStateHandler::deserialize_and_convert(&vote_account, target_version)?; |
There was a problem hiding this comment.
Also need to update the target version below in deinitialize_vote_account_state. I guess it needs tests too?
There was a problem hiding this comment.
I think this comment belongs to the follow-up PR now.
| assert!(!vote_state_versions.is_uninitialized()); | ||
|
|
||
| // Verify fields. | ||
| if let VoteStateVersions::V4(v4) = vote_state_versions { |
There was a problem hiding this comment.
Please add checks for the other initialized v4 fields per simd-185 (collector accounts, etc)
| if result.is_ok() { | ||
| let vote_state_versions = vote_account.get_state::<VoteStateVersions>().unwrap(); | ||
| assert!(matches!(vote_state_versions, VoteStateVersions::V4(_))); | ||
| // v4 is always initialized |
There was a problem hiding this comment.
After de-init, we shouldn't be able to deserialize a v4 state anymore since it should be a v0 uninitalized account.
69ba407 to
ac69447
Compare
|
I repurposed this PR to be identical to #8108. |
|
@jstarry It's a little difficult to tell what comments were for Part 1 of this work or Part 2. I think I got everything for Part 1. Everything else mentioned should pertain to Part 2, where we add the |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #8120 +/- ##
========================================
Coverage 82.9% 83.0%
========================================
Files 823 823
Lines 361216 361498 +282
========================================
+ Hits 299758 300132 +374
+ Misses 61458 61366 -92 🚀 New features to boost your workflow:
|
Problem
Now that we have a "vote state handler" that can help us gate new vote state targets behind feature gates, it's time to implement
VoteStateV4within the handler.Summary of Changes
Implements the
VoteStateHandletrait forVoteStateV4in the program'shandlermodule and does some moderate refactoring to simplify the trait where possible and share functionality across free functions.This change does not add a
V4variant to the handler yet.