Skip to content

vote-program: deserialize, check initialized, then convert#8524

Merged
buffalojoec merged 7 commits intoanza-xyz:masterfrom
buffalojoec:vote-state-v4-deserialize-check-convert
Oct 17, 2025
Merged

vote-program: deserialize, check initialized, then convert#8524
buffalojoec merged 7 commits intoanza-xyz:masterfrom
buffalojoec:vote-state-v4-deserialize-check-convert

Conversation

@buffalojoec
Copy link
Copy Markdown

@buffalojoec buffalojoec commented Oct 17, 2025

Problem

As per the amendment to SIMD-0185 in solana-foundation/solana-improvement-documents#369, when the vote state v4 feature gate is active, the Vote program must adjust the way it handles its "deserialize and convert" workflow.

With the vote state v4 feature disabled, a handful of program instructions call VoteStateV3::deserialize, which coerces the underlying vote state to v3, before checking its initialization status. These instructions are:

  • Authorize*
  • UpdateValidatorIdentity
  • UpdateCommission
  • Withdraw

Only when the vote state v4 feature is enabled should the behavior change to "deserialize -> check initialized -> convert", as per solana-foundation/solana-improvement-documents#369.

Summary of Changes

First, refactors the verify_and_get_vote_state_handler helper to deserialize as VoteStateVersions first, then check for initialization, then convert to v3 or v4.

Then, configures instructions that did not previously call this helper (Authorize*, UpdateValidatorIdentity, UpdateCommission, Withdraw) to conditionally call it based on the feature status.

@buffalojoec buffalojoec requested a review from jstarry October 17, 2025 03:32
@mergify
Copy link
Copy Markdown

mergify Bot commented Oct 17, 2025

The Firedancer team maintains a line-for-line reimplementation of the
native programs, and until native programs are moved to BPF, those
implementations must exactly match their Agave counterparts.
If this PR represents a change to a native program implementation (not
tests), please include a reviewer from the Firedancer team. And please
keep refactors to a minimum.

@buffalojoec buffalojoec marked this pull request as ready for review October 17, 2025 04:02
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 17, 2025

Codecov Report

❌ Patch coverage is 90.96774% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.1%. Comparing base (a87fd3e) to head (3806b2d).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##           master    #8524     +/-   ##
=========================================
- Coverage    83.1%    83.1%   -0.1%     
=========================================
  Files         849      849             
  Lines      368587   368644     +57     
=========================================
+ Hits       306604   306649     +45     
- Misses      61983    61995     +12     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@buffalojoec buffalojoec enabled auto-merge October 17, 2025 05:42
@buffalojoec buffalojoec added this pull request to the merge queue Oct 17, 2025
Merged via the queue into anza-xyz:master with commit 4a5aa1e Oct 17, 2025
54 checks passed
@buffalojoec buffalojoec deleted the vote-state-v4-deserialize-check-convert branch October 17, 2025 06:16
rustopian pushed a commit to rustopian/agave that referenced this pull request Nov 20, 2025
…8524)

* vote-program: refactor: move `verify_and_get_vote_state_handler`

* vote-program: move voter authorized check out of helper

* vote-program: rename helper to `get_vote_state_handler_checked`

* vote-program: handler helper: deserialize as `VoteStateVersions`

* vote-program: use the helper in all instructions except `InitializeAccount`

* wrap new helper callsites to preserve old behavior

* take 2 on helper preserve behavior
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants