Skip to content

SIMD-0185: Vote Account v4 #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

jstarry
Copy link
Contributor

@jstarry jstarry commented Oct 17, 2024

No description provided.

@jstarry jstarry changed the title SIMD-XXXX: Vote Account v4 SIMD-0185: Vote Account v4 Oct 17, 2024
`authorized_voters` field that correspond to epochs less than the current epoch,
only purge entries less than the previous epoch (current epoch - 1). This will
mean that the `authorized_voters` field can now hold up to 4 entries for the
epochs in the range `[current_epoch - 1, current_epoch + 2]`. Keeping the
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a reason we need to store current_epoch + 2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's the current design and I think it kinda makes sense because otherwise you could set a new authorized voter at the end of an epoch and immediately start using it in the next block in the new epoch and leaders would need an up to date view on any new authorized voters for each fork crossing the epoch boundary

@diman-io
Copy link

I'm sorry, why is block_tips_collector here? Are tips somehow planned in the protocol level / voting program?

@jstarry
Copy link
Contributor Author

jstarry commented Oct 23, 2024

I'm sorry, why is block_tips_collector here? Are tips somehow planned in the protocol level / voting program?

Up for debate still, but I put it there for now since it's easier to update the vote account all in one go. If that field remains unused by the protocol it can be used for something else in the future.

@diman-io
Copy link

Is this about a new instruction to pay the leader who landed a successful transaction?

Copy link

@segfaultdoc segfaultdoc left a comment

Choose a reason for hiding this comment

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

Overall good proposal, trying to think longer term if the Tips commission piece makes sense or becomes obsolete

@jstarry
Copy link
Contributor Author

jstarry commented Nov 5, 2024

I updated the proposal to use basis points for commission values and to remove any special handling for block tips for now.

@jstarry
Copy link
Contributor Author

jstarry commented Jan 24, 2025

@AshwinSekar I've updated the SIMD to only remove the prior_voters field in a new version of vote state. This way the SIMD is much simpler and we can make progress towards adding other new fields to the vote state without needing to reallocations for existing vote accounts like we had to for TVC.

@jstarry jstarry marked this pull request as ready for review January 24, 2025 09:34
@AshwinSekar
Copy link
Contributor

@AshwinSekar I've updated the SIMD to only remove the prior_voters field in a new version of vote state. This way the SIMD is much simpler and we can make progress towards adding other new fields to the vote state without needing to reallocations for existing vote accounts like we had to for TVC.

Got it, happy to approve. I do think it would be a lot faster if we could get away with one migration to remove prior_voters and add the new fields. Are you facing any hurdles with that approach?

Copy link

@lidatong lidatong left a comment

Choose a reason for hiding this comment

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

approving for FD

@jstarry
Copy link
Contributor Author

jstarry commented Feb 17, 2025

Got it, happy to approve. I do think it would be a lot faster if we could get away with one migration to remove prior_voters and add the new fields. Are you facing any hurdles with that approach?

Yeah maybe that's still the best approach. There's just a lot of changes I want to make:

  1. Remove prior_voters to make room for other state without increasing vote state size
  2. Additionally store the authorized voter for the previous epoch now that prior voters is going away
  3. Store new fields for fee collector addresses, commissions, and pending delegator rewards
  4. New instructions for setting collector addresses and commission

Would we use a single feature gate for all of these changes? I think that could be fine. We will have a separate feature gate for SIMD-0123 anyways to actually make use of these new fields.

Copy link
Contributor

@AshwinSekar AshwinSekar left a comment

Choose a reason for hiding this comment

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

Would we use a single feature gate for all of these changes? I think that could be fine. We will have a separate feature gate for SIMD-0123 anyways to actually make use of these new fields.

This sounds like a good approach. lgtm

@michaelh-laine
Copy link

Can this be incorporated into this SIMD?

#254

@jstarry
Copy link
Contributor Author

jstarry commented Mar 5, 2025

Can this be incorporated into this SIMD?

#254

I already have a separate SIMD written up for this actually: #249

@jstarry
Copy link
Contributor Author

jstarry commented Apr 16, 2025

Just pushed another update to this SIMD to add more detail to the required changes section and some other minor cleanup and renaming. It'd be great to get another review pass from anza devs @AshwinSekar @buffalojoec @t-nelson and fd devs @lidatong @topointon-jump

Comment on lines +207 to +210
The existing withdraw instruction MUST be modified to completely zero vote
account data for fully withdrawn vote accounts. The old behavior partially
zeroed the account data following the vote state version discriminant and is
less intuitive.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I felt this was a nice to have change. This way we know that any vote account with the version discriminant bytes 03 00 00 00 is still initialized. Other vote state versions require checking fields for initialized values to be sure of initialization which is a footgun IMO.

Comment on lines +160 to +165
If a modified vote account's size is smaller than `3762` bytes, first resize the
account to `3762` bytes before updating the account data. The vote program does
not need to check if the resulting account is rent exempt, the runtime will
enforce that check. This differs from the prior vote program implementation which
falls back to store vote state as v2 if the account size cannot be resized while
keeping the account rent exempt.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I felt this was nice to have because it simplifies the vote program implementation and ensures that all v4 vote accounts have the same size. Here's the current code in question that this will clean up:

https://github.com/anza-xyz/agave/blame/0df4a2d963e06ced795247719ef1aa16c6d71d15/programs/vote/src/vote_state/mod.rs#L40-L54

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.

7 participants