Skip to content

Implement VoteStateV4#206

Closed
buffalojoec wants to merge 16 commits intoanza-xyz:masterfrom
buffalojoec:wip-vote-state-v4-hk
Closed

Implement VoteStateV4#206
buffalojoec wants to merge 16 commits intoanza-xyz:masterfrom
buffalojoec:wip-vote-state-v4-hk

Conversation

@buffalojoec
Copy link
Copy Markdown
Contributor

Includes the new interface, full serialization support, and the flipping of "current" to be v4.

@buffalojoec buffalojoec requested a review from jstarry June 27, 2025 03:56
@buffalojoec buffalojoec force-pushed the wip-vote-state-v4-hk branch from 1292249 to c0a662f Compare June 27, 2025 05:06
Comment thread vote-interface/src/state/vote_state_v3.rs Outdated
Comment thread vote-interface/src/state/vote_state_versions.rs Outdated
Comment thread vote-interface/src/state/vote_state_versions.rs Outdated
Comment thread vote-interface/src/state/vote_state_versions.rs Outdated
Comment thread vote-interface/src/state/vote_state_versions.rs Outdated
Comment thread vote-interface/src/state/vote_state_v4.rs Outdated
Comment thread vote-interface/src/state/mod.rs
Comment thread vote-interface/src/state/vote_state_v3.rs Outdated
Comment thread vote-interface/src/state/vote_state_versions.rs Outdated
Comment thread vote-interface/src/state/vote_state_versions.rs
@buffalojoec
Copy link
Copy Markdown
Contributor Author

@jstarry addressed all your feedback and also added updates based on SIMD changes.

In order to pull this out of draft, I'll have to do a rebase, where I'll resolve the conflicts and probably also rebase on top of #221.

@buffalojoec buffalojoec force-pushed the wip-vote-state-v4-hk branch from 9d4a1c2 to f98a67a Compare July 11, 2025 03:21
@buffalojoec buffalojoec changed the title [WIP]: Draft implementation of VoteStateV4 Implement VoteStateV4 Jul 12, 2025
@buffalojoec buffalojoec marked this pull request as ready for review July 12, 2025 03:18
@buffalojoec buffalojoec requested a review from jstarry July 12, 2025 03:18
Comment thread vote-interface/src/instruction.rs Outdated
Comment thread vote-interface/src/state/vote_state_v4.rs Outdated
Comment thread vote-interface/src/state/vote_state_v4.rs Outdated
Comment thread vote-interface/src/state/mod.rs Outdated
Comment thread vote-interface/src/state/mod.rs
Comment thread vote-interface/src/state/mod.rs Outdated
Comment thread vote-interface/src/state/mod.rs Outdated
Comment thread vote-interface/src/state/mod.rs
Comment thread vote-interface/src/state/vote_state_v3.rs Outdated
@buffalojoec buffalojoec requested a review from HaoranYi July 22, 2025 17:08
pub authorized_withdrawer: Pubkey,

/// The collector account for inflation rewards.
pub inflation_rewards_collector: Pubkey,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so, the intention is that we will update vote rewards payment to this account for votestatev4?
will this be defaulted to vote-pubkey?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

pub inflation_rewards_commission_bps: u16,
/// Basis points (0-10,000) that represent how much of the block revenue
/// should be given to this vote account.
pub block_revenue_commission_bps: u16,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

pub block_revenue_commission_bps: u16,

/// Reward amount pending distribution to stake delegators.
pub pending_delegator_rewards: u64,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@jstarry
Copy link
Copy Markdown
Contributor

jstarry commented Jul 23, 2025

Do you mind doing the deserialization code move (into new module) in a separate PR to reduce the diff size of this one and made it easier to review?

@buffalojoec
Copy link
Copy Markdown
Contributor Author

Do you mind doing the deserialization code move (into new module) in a separate PR to reduce the diff size of this one and made it easier to review?

Yeah sure, can do. I also am going to consider refactoring or replacing VoteStateVersions. I'll move this into draft for now.

@buffalojoec buffalojoec marked this pull request as draft July 23, 2025 15:40
Comment on lines +51 to +56
/// Compressed BLS pubkey for Alpenglow.
#[cfg_attr(
feature = "serde",
serde_as(as = "Option<[_; BLS_PUBKEY_COMPRESSED_BYTES]>")
)]
pub bls_pubkey_compressed: Option<[u8; BLS_PUBKEY_COMPRESSED_BYTES]>,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For Alpenglow, we'll want to have a bls_pubkey_compressed associated with each authorized voter. This way, an authorized voter change results in an appropriate change to the corresponding BLS pubkey.

Accordingly, we'll probably either want to:

(1) rewrite bls_pubkey_compressed as bls_pubkeys: Option<BTreeMap<Epoch, [u8; BLS_PUBKEY_COMPRESSED_BYTES]>>

(2) modify AuthorizedVoters to have the value of the BTreeMap include Option<[u8; BLS_PUBKEY_COMPRESSED_BYTES]>.

Slightly partial to option (1), as it seems a bit cleaner / more space-efficient.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not suggesting that we change within this SIMD, though - why do we need to keep around a BTreeMap<Epoch, _> rather than "current epoch" and "next epoch?"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh this is news to me. Sounds like we will want to amend SIMD-0185 with this change. And I'm not opposed to removing the btreemap. In SIMD-0185, I also added an entry for the "previous epoch" authorized voter as well so that when transitioning into a new epoch we can still process votes from the previous authorized voter because votes for slots near the end of the epoch signed by the previous authorized voter might land in the next epoch. But I'm thinking this isn't necessary for alpenglow?

Copy link
Copy Markdown
Contributor

@0x0ece 0x0ece Jul 28, 2025

Choose a reason for hiding this comment

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

@samkim-crypto I think we also need a proof of ownership for the BLS pubkey (a BLS signature):

pub const BLS_SIGNATURE_COMPRESSED_BYTES: usize = 96;

Two options are:

  1. we add it to the vote account
  2. we verify it in the tx that adds/updates the bls pubkey

(1 doesn't exclude 2)
I think it's cleaner to do it in 2), but it won't be possible in BPF without a syscall, so the vote program needs to remain native (until at least we add the syscall).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@0x0ece fyi we are discussing some of this in the #consensus discord channel

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, we do need to verify BLS pubkeys. @0x0ece can you expand on adding the verification to the vote account? Option 2 is essentially required, no?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes I agree option 2 is better. (I was thinking vote program in bpf, no syscall to do bls sigverify, then we could store the proof in the vote account and do the verification when we boot / load the keys. Unnecessary complication.)

@buffalojoec
Copy link
Copy Markdown
Contributor Author

I'll be breaking this PR up and handling the evolving state changes in other PRs.

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.

6 participants