-
Notifications
You must be signed in to change notification settings - Fork 209
Add VoteInitV2 and new variant in VoteAuthorize to add BLS Pubkey to vote program. #424
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
Changes from all commits
c58a057
058e39e
34945ff
4568356
7b86969
8e67cc5
d91a7b6
34d2074
a908ffe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,19 @@ | ||
| #[cfg(feature = "serde")] | ||
| use serde_derive::{Deserialize, Serialize}; | ||
| #[cfg(feature = "frozen-abi")] | ||
| use solana_frozen_abi_macro::{frozen_abi, AbiExample}; | ||
| use { | ||
| crate::state::{Lockout, MAX_LOCKOUT_HISTORY}, | ||
| crate::state::{ | ||
| Lockout, BLS_PUBLIC_KEY_COMPRESSED_SIZE, BLS_SIGNATURE_COMPRESSED_SIZE, MAX_LOCKOUT_HISTORY, | ||
| }, | ||
| solana_clock::{Slot, UnixTimestamp}, | ||
| solana_hash::Hash, | ||
| solana_pubkey::Pubkey, | ||
| std::{collections::VecDeque, fmt::Debug}, | ||
| }; | ||
| #[cfg(feature = "serde")] | ||
| use { | ||
| serde_derive::{Deserialize, Serialize}, | ||
| serde_with::serde_as, | ||
| }; | ||
|
|
||
| #[cfg_attr( | ||
| feature = "frozen-abi", | ||
|
|
@@ -201,11 +206,70 @@ pub struct VoteInit { | |
| pub commission: u8, | ||
| } | ||
|
|
||
| #[cfg_attr(feature = "serde", cfg_eval::cfg_eval, serde_as)] | ||
| #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
| #[derive(Debug, PartialEq, Eq, Clone, Copy)] | ||
| pub struct VoteInitV2 { | ||
| pub node_pubkey: Pubkey, | ||
| pub authorized_voter: Pubkey, | ||
| #[cfg_attr( | ||
| feature = "serde", | ||
| serde_as(as = "[_; BLS_PUBLIC_KEY_COMPRESSED_SIZE]") | ||
| )] | ||
| pub authorized_voter_bls_pubkey: [u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE], | ||
| #[cfg_attr(feature = "serde", serde_as(as = "[_; BLS_SIGNATURE_COMPRESSED_SIZE]"))] | ||
| pub authorized_voter_bls_proof_of_possession: [u8; BLS_SIGNATURE_COMPRESSED_SIZE], | ||
| pub authorized_withdrawer: Pubkey, | ||
| pub inflation_rewards_commission_bps: u16, | ||
| pub inflation_rewards_collector: Pubkey, | ||
| pub block_revenue_commission_bps: u16, | ||
| pub block_revenue_collector: Pubkey, | ||
| } | ||
|
|
||
| impl Default for VoteInitV2 { | ||
| fn default() -> Self { | ||
| Self { | ||
| node_pubkey: Pubkey::default(), | ||
| authorized_voter: Pubkey::default(), | ||
| authorized_voter_bls_pubkey: [0u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE], | ||
| authorized_voter_bls_proof_of_possession: [0u8; BLS_SIGNATURE_COMPRESSED_SIZE], | ||
| authorized_withdrawer: Pubkey::default(), | ||
| inflation_rewards_commission_bps: 0, | ||
| inflation_rewards_collector: Pubkey::default(), | ||
| block_revenue_commission_bps: 0, | ||
| block_revenue_collector: Pubkey::default(), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[cfg_attr(feature = "serde", cfg_eval::cfg_eval, serde_as)] | ||
| #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
| #[derive(Debug, PartialEq, Eq, Clone, Copy)] | ||
| pub struct VoterWithBLSArgs { | ||
| #[cfg_attr( | ||
| feature = "serde", | ||
| serde_as(as = "[_; BLS_PUBLIC_KEY_COMPRESSED_SIZE]") | ||
| )] | ||
| pub bls_pub_key: [u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE], | ||
| #[cfg_attr(feature = "serde", serde_as(as = "[_; BLS_SIGNATURE_COMPRESSED_SIZE]"))] | ||
| pub bls_proof_of_possession: [u8; BLS_SIGNATURE_COMPRESSED_SIZE], | ||
| } | ||
|
|
||
| impl Default for VoterWithBLSArgs { | ||
| fn default() -> Self { | ||
| Self { | ||
| bls_pub_key: [0u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE], | ||
| bls_proof_of_possession: [0u8; BLS_SIGNATURE_COMPRESSED_SIZE], | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+258
to
+265
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this could also get similar
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean I should use a wrapper here?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that's what I was getting at, but it looks like the final decision was to not use wrapper structs, so no need to do anything here |
||
|
|
||
| #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
| #[derive(Debug, PartialEq, Eq, Clone, Copy)] | ||
| pub enum VoteAuthorize { | ||
| Voter, | ||
| Withdrawer, | ||
| VoterWithBLS(VoterWithBLSArgs), | ||
| } | ||
|
|
||
| #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ use solana_frozen_abi_macro::{frozen_abi, AbiExample}; | |
| #[cfg(any(target_os = "solana", feature = "bincode"))] | ||
| use solana_instruction::error::InstructionError; | ||
| use { | ||
| super::{BlockTimestamp, LandedVote, VoteInit, BLS_PUBLIC_KEY_COMPRESSED_SIZE}, | ||
| super::{BlockTimestamp, LandedVote, VoteInit, VoteInitV2, BLS_PUBLIC_KEY_COMPRESSED_SIZE}, | ||
| crate::authorized_voters::AuthorizedVoters, | ||
| solana_clock::{Clock, Epoch, Slot}, | ||
| solana_pubkey::Pubkey, | ||
|
|
@@ -77,7 +77,7 @@ impl VoteStateV4 { | |
| 3762 // Same size as V3 to avoid account resizing | ||
| } | ||
|
|
||
| pub fn new(vote_pubkey: &Pubkey, vote_init: &VoteInit, clock: &Clock) -> Self { | ||
| pub fn new_with_defaults(vote_pubkey: &Pubkey, vote_init: &VoteInit, clock: &Clock) -> Self { | ||
| Self { | ||
| node_pubkey: vote_init.node_pubkey, | ||
| authorized_voters: AuthorizedVoters::new(clock.epoch, vote_init.authorized_voter), | ||
|
|
@@ -92,6 +92,20 @@ impl VoteStateV4 { | |
| } | ||
| } | ||
|
|
||
| pub fn new(vote_init: &VoteInitV2, clock: &Clock) -> Self { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how this is being used downstream already or how the transition is being planned, but was this breaking change intended?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok great, thanks! Sorry for the noise then |
||
| Self { | ||
| node_pubkey: vote_init.node_pubkey, | ||
| authorized_voters: AuthorizedVoters::new(clock.epoch, vote_init.authorized_voter), | ||
| bls_pubkey_compressed: Some(vote_init.authorized_voter_bls_pubkey), | ||
| authorized_withdrawer: vote_init.authorized_withdrawer, | ||
| inflation_rewards_commission_bps: vote_init.inflation_rewards_commission_bps, | ||
| inflation_rewards_collector: vote_init.inflation_rewards_collector, | ||
| block_revenue_commission_bps: vote_init.block_revenue_commission_bps, | ||
| block_revenue_collector: vote_init.block_revenue_collector, | ||
| ..Self::default() | ||
| } | ||
| } | ||
|
|
||
| #[cfg(any(target_os = "solana", feature = "bincode"))] | ||
| pub fn deserialize(input: &[u8], vote_pubkey: &Pubkey) -> Result<Self, InstructionError> { | ||
| let mut vote_state = Self::default(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.