Skip to content

(Alpenglow) Allow creating v4 account in genesis, upstream Consensus Pool.#8122

Merged
wen-coding merged 13 commits intoanza-xyz:masterfrom
wen-coding:upstream_consensus_pool
Sep 25, 2025
Merged

(Alpenglow) Allow creating v4 account in genesis, upstream Consensus Pool.#8122
wen-coding merged 13 commits intoanza-xyz:masterfrom
wen-coding:upstream_consensus_pool

Conversation

@wen-coding
Copy link
Copy Markdown

@wen-coding wen-coding commented Sep 21, 2025

  • Upstream consensus pool
  • To allow testing consensus pool, add create_genesis_config_with_alpenglow_vote_accounts to create Alpenglow vote accounts (VoteStateV4 account with bls_pubkey specified)
  • Add is_alpenglow option to the following:
    • create_genesis_config_with_vote_accounts_and_cluster_type
    • create_genesis_config_with_leader_ex
    • create_genesis_config_with_leader_ex_no_features
  • Added stake_state::create_alpenglow_account so when creating stake accounts for genesis config when is_alpenglow is true, it reads VoteStateV4 vote account data for credits. In all other cases it still reads VoteStateV3 vote account data

@wen-coding wen-coding marked this pull request as draft September 21, 2025 21:41
@mergify
Copy link
Copy Markdown

mergify Bot commented Sep 21, 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.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 21, 2025

Codecov Report

❌ Patch coverage is 98.59367% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.1%. Comparing base (84c5f28) to head (5904506).

Additional details and impacted files
@@            Coverage Diff            @@
##           master    #8122     +/-   ##
=========================================
+ Coverage    83.0%    83.1%   +0.1%     
=========================================
  Files         827      828      +1     
  Lines      362713   364668   +1955     
=========================================
+ Hits       301254   303313   +2059     
+ Misses      61459    61355    -104     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wen-coding wen-coding marked this pull request as ready for review September 21, 2025 23:16
@wen-coding wen-coding changed the title Allow creating v4 account in genesis, upstream Consensus Pool. (Alpenglow) Allow creating v4 account in genesis, upstream Consensus Pool. Sep 21, 2025
@wen-coding wen-coding moved this to In Progress in Alpenglow Sep 21, 2025
Comment thread programs/stake/src/stake_state.rs Outdated
let credits = if let Ok(vote_state_v3) = VoteStateV3::deserialize(vote_account.data()) {
vote_state_v3.credits()
} else {
match VoteStateV4::deserialize(vote_account.data(), voter_pubkey) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking - is it possible for someone to create a VoteStateV4 on chain and then this fn has divergent behavior depending on software version?
Does this need to be part of a feature flag?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point, I added stake_state::create_alpenglow_account which is only called from genesis when is_alpenglow is true. So when creating stake state on testnet/mainnet the stake program only recognizes VoteStateV3 accounts for now. We can remove it once we launched VoteStateV4 and converted all VoteStateV3 accounts.

@AshwinSekar
Copy link
Copy Markdown

Looks good from my end, please wait for approval from Jon/Joe for the program changes

@ksn6
Copy link
Copy Markdown

ksn6 commented Sep 24, 2025

LGTM

Comment on lines +124 to +130
let credits = if is_alpenglow {
let vote_state_v4 = VoteStateV4::deserialize(vote_account.data(), voter_pubkey).unwrap();
vote_state_v4.epoch_credits.last().map_or(0, |(_, c, _)| *c)
} else {
let vote_state = VoteStateV3::deserialize(vote_account.data()).expect("vote_state");
vote_state.credits()
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm currently adding the implementation of v4 to the Vote program, and I think this change will have to get captured in that PR, so that it coincides with the feature gate I'm adding. In fact, I believe I need to add this now to get it to pass CI.

Is it feasible to rebase this onto #8163?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make sure we are on the same page:
What we needed for Alpenglow upstreaming:

  1. Adding v4 account for tests: create_v4_account_with_authorized was added in Add create_v4_account_with_authorized and actually populate bls_pubkey_to_rank_map in EpochStakes. #8103 as a temp workardound, but after vote-program: handler: init v4 support #8120 we should convert it to create_new_vote_state_v4_for_tests
  2. We need to create v4 account only genesis config:
    2.1 We are adding genesis util functions here
    2.2 To make stake account creation work we are performing the operation here, you are saying once vote-program: outfit to fully support vote state v4 #8163 lands we should convert that to
    let mut vote_state = VoteStateHandler::deserialize_and_convert(vote_account, VoteStateTargetVersion::V4)?;

Of course we can do that. Do you know when #8163 will land?

Copy link
Copy Markdown
Author

@wen-coding wen-coding Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, create_v4_account_with_authorized uses create_new_vote_state_v4_for_tests, so I guess we are good there. Is the only difference on #8163 to change:
let vote_state_v4 = VoteStateV4::deserialize(vote_account.data(), voter_pubkey).unwrap();
to
let vote_state = VoteStateHandler::deserialize_and_convert(vote_account, VoteStateTargetVersion::V4)?;
?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly, and that should be covered by my PR once it's fully updated, since I'll need to update any callsites that don't yet know about the v4 state feature gate.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, so sounds like it works both ways, if you manage to submit #8163 first, then I'll sync and change to the above call. If we submit this PR first, then it's just one-line change, so shouldn't be a big deal either.

In that case, is it okay if we ship this first to unblock other Alpenglow upstreaming?

Does rest of this PR look roughly correct to you?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can really only attest to the program stuff. I can't offer much of a review on the consensus side. But if you need the change immediately, sure, you can ship.

@wen-coding wen-coding requested a review from a team as a code owner September 24, 2025 18:16
@wen-coding wen-coding requested a review from a team as a code owner September 24, 2025 18:16
@wen-coding wen-coding force-pushed the upstream_consensus_pool branch from 56a252b to e9eae6b Compare September 24, 2025 18:18
@wen-coding wen-coding merged commit 20852db into anza-xyz:master Sep 25, 2025
54 checks passed
@wen-coding wen-coding deleted the upstream_consensus_pool branch September 25, 2025 19:02
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Alpenglow Sep 25, 2025
@joncinque
Copy link
Copy Markdown

Agreed with @buffalojoec, all of the logic outside of votor should hinge around vote state v4 being enabled, and not alpenglow. So #8163 should have landed first to make this change cleaner. Now all of the alpenglow-specific code in the non-votor files should be removed in #8163. Why did we need to land this so soon?

@wen-coding
Copy link
Copy Markdown
Author

Agreed with @buffalojoec, all of the logic outside of votor should hinge around vote state v4 being enabled, and not alpenglow. So #8163 should have landed first to make this change cleaner. Now all of the alpenglow-specific code in the non-votor files should be removed in #8163. Why did we need to land this so soon?

@bw-solana Because we are now still developing in Alpenglow repo and syncing between Agave/Alpenglow is painful and we find breaking changes here and there, so pushing Alpenglow repo upstream even one week earlier helps the whole project a lot.

We could of course wait for #8163 if it lands in a few days, but I don't want to rush Joe's work either, #8163 needs to be properly and carefully written so it handles all edge cases in VoteStateV4 transition. While after chatting with Joe, I think we figured replacing alpenglow-specific code in non-votor files is really an one-line change, so landing #8122 seems like a nice compromise to:

  1. Let Joe land vote-program: outfit to fully support vote state v4 #8163 properly with enough time for coding and reviewing
  2. meanwhile unblock Alpenglow upstreaming to Agave master repo
    And the cost is an one-line change.

So it seems to be an okay compromise to me.

Did I misunderstand any of the comments above?

@wen-coding
Copy link
Copy Markdown
Author

Agreed with @buffalojoec, all of the logic outside of votor should hinge around vote state v4 being enabled, and not alpenglow. So #8163 should have landed first to make this change cleaner. Now all of the alpenglow-specific code in the non-votor files should be removed in #8163. Why did we need to land this so soon?

@bw-solana Because we are now still developing in Alpenglow repo and syncing between Agave/Alpenglow is painful and we find breaking changes here and there, so pushing Alpenglow repo upstream even one week earlier helps the whole project a lot.

We could of course wait for #8163 if it lands in a few days, but I don't want to rush Joe's work either, #8163 needs to be properly and carefully written so it handles all edge cases in VoteStateV4 transition. While after chatting with Joe, I think we figured replacing alpenglow-specific code in non-votor files is really an one-line change, so landing #8122 seems like a nice compromise to:

  1. Let Joe land vote-program: outfit to fully support vote state v4 #8163 properly with enough time for coding and reviewing
  2. meanwhile unblock Alpenglow upstreaming to Agave master repo
    And the cost is an one-line change.

So it seems to be an okay compromise to me.

Did I misunderstand any of the comments above?

And yes, we are totally okay with replacing any functions outside votor with VoteStateV4 names if possible, including all the genesis functions.

However, there is a difference between a VoteStateV4 account and an Alpenglow vote account, because an Alpenglow vote account needs to:

  1. be VoteStateV4 account
  2. has a properly specified BLS pubkey
    Given the timeline of the projects, I think VoteStateV4 will launch much much earlier than Alpenglow. So I don't want to tie VoteStateV4 account to the notion "if you are VoteStateV4, you must have a BLS pubkey", which is why I named all those helper functions Alpenglow. I don't want naive users calling them before our keygen/genesis tools support "put proper BLS pubkey" in the vote account. There will be a SIMD for that. Does that make sense?

That said, if you think there is any function we should rename, I can totally send PR to fix it.

@bw-solana
Copy link
Copy Markdown

The urgency is around getting out of sync/integration hell. We're trying to keep over 100k divergent LOC in sync between the repos.

We absolutely need to maintain a high Agave quality bar, but the options as I see them:

  1. Prioritize and land VoteStateV4 stuff ASAP
  2. Get temp workaround into high enough quality state that we decide we can live w/ it until VoteStateV4 stuff gets worked out

@buffalojoec
Copy link
Copy Markdown

VoteStateV4 is close. #8163 hasn't moved because I've been adding some more tests piecemeal like #8178 and #8191, and I also have to go through any other libs/tests that are going to break once the v4 feature is added. That's what I'm doing right now.

It's easier for me if I don't have to sort through Alpenglow stuff when I update the stake stuff to bind to the v4 feature gate, but I also don't want to hold anyone up if it's critical.

Regardless, I've earmarked this PR to evaluate against in #8163.

@wen-coding
Copy link
Copy Markdown
Author

VoteStateV4 is close. #8163 hasn't moved because I've been adding some more tests piecemeal like #8178 and #8191, and I also have to go through any other libs/tests that are going to break once the v4 feature is added. That's what I'm doing right now.

It's easier for me if I don't have to sort through Alpenglow stuff when I update the stake stuff to bind to the v4 feature gate, but I also don't want to hold anyone up if it's critical.

Regardless, I've earmarked this PR to evaluate against in #8163.

Totally understood. Sorry for the additional trouble and thank you so much for being so flexible! Greatly appreciate it!

@bw-solana
Copy link
Copy Markdown

@buffalojoec - you're a legend 🙏

Want to make sure everyone understands the urgency from our side, but also don't want you to feel pressured to take shortcuts, rush things, or feel bullied into any bad decisions.

Lmk if we can help in any way

@joncinque
Copy link
Copy Markdown

Gotcha, if this is super urgent, then no problem! I just want to make sure we're not creating too much future work for ourselves.

Every time we add is_alpenglow somewhere, future changes become more difficult to reason about until we remove all the tower code, so I'm hoping we don't need to do it too much.

@wen-coding
Copy link
Copy Markdown
Author

Totally agreed. Unfortunately genesis is where I think we need to special case for now, because we need to create genesis with Alpenglow accounts before it's ready, we will be super careful in all other places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

7 participants