Skip to content

Commit d91a7b6

Browse files
committed
Address pr comments.
1 parent 8e67cc5 commit d91a7b6

File tree

4 files changed

+54
-40
lines changed

4 files changed

+54
-40
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vote-interface/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ frozen-abi = [
3838
serde = [
3939
"dep:cfg_eval",
4040
"dep:serde",
41-
"dep:serde_bytes",
4241
"dep:serde_derive",
4342
"dep:serde_with",
4443
"dep:solana-serde-varint",
@@ -55,7 +54,6 @@ cfg_eval = { workspace = true, optional = true }
5554
num-derive = { workspace = true }
5655
num-traits = { workspace = true }
5756
serde = { workspace = true, optional = true }
58-
serde_bytes = { workspace = true, optional = true }
5957
serde_derive = { workspace = true, optional = true }
6058
serde_with = { workspace = true, features = ["macros"], optional = true }
6159
solana-clock = { workspace = true }

vote-interface/src/instruction.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ pub enum VoteInstruction {
4040
/// 0. `[WRITE]` Vote account to be updated with the Pubkey for authorization
4141
/// 1. `[]` Clock sysvar
4242
/// 2. `[SIGNER]` Vote or withdraw authority
43+
///
44+
/// When SIMD-0387 is enabled, the `VoteAuthorize::Voter` variant is
45+
/// disallowed for any vote accounts whose BLS pubkey is set to `Some`.
4346
Authorize(Pubkey, VoteAuthorize),
4447

4548
/// A Vote instruction with recent votes
@@ -93,6 +96,9 @@ pub enum VoteInstruction {
9396
/// 1. `[]` Clock sysvar
9497
/// 2. `[SIGNER]` Vote or withdraw authority
9598
/// 3. `[SIGNER]` New vote or withdraw authority
99+
///
100+
/// When SIMD-0387 is enabled, the `VoteAuthorize::Voter` variant is
101+
/// disallowed for any vote accounts whose BLS pubkey is set to `Some`.
96102
AuthorizeChecked(VoteAuthorize),
97103

98104
/// Update the onchain vote state for the signer.
@@ -117,6 +123,10 @@ pub enum VoteInstruction {
117123
/// 0. `[Write]` Vote account to be updated
118124
/// 1. `[]` Clock sysvar
119125
/// 2. `[SIGNER]` Base key of current Voter or Withdrawer authority's derived key
126+
///
127+
/// When SIMD-0387 is enabled, the `VoteAuthorize::Voter` variant in
128+
/// `authorization_type` is disallowed for any vote accounts whose BLS
129+
/// pubkey is set to `Some`.
120130
AuthorizeWithSeed(VoteAuthorizeWithSeedArgs),
121131

122132
/// Given that the current Voter or Withdrawer authority is a derived key,
@@ -131,6 +141,10 @@ pub enum VoteInstruction {
131141
/// 1. `[]` Clock sysvar
132142
/// 2. `[SIGNER]` Base key of current Voter or Withdrawer authority's derived key
133143
/// 3. `[SIGNER]` New vote or withdraw authority
144+
///
145+
/// When SIMD-0387 is enabled, the `VoteAuthorize::Voter` variant in
146+
/// `authorization_type` is disallowed for any vote accounts whose BLS
147+
/// pubkey is set to `Some`.
134148
AuthorizeCheckedWithSeed(VoteAuthorizeCheckedWithSeedArgs),
135149

136150
/// Update the onchain vote state for the signer.

vote-interface/src/state/vote_instruction_data.rs

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#[cfg(feature = "serde")]
2-
use serde_derive::{Deserialize, Serialize};
2+
use {
3+
serde_derive::{Deserialize, Serialize},
4+
serde_with::serde_as,
5+
};
36
#[cfg(feature = "frozen-abi")]
47
use solana_frozen_abi_macro::{frozen_abi, AbiExample};
58
use {
@@ -203,56 +206,56 @@ pub struct VoteInit {
203206
pub commission: u8,
204207
}
205208

209+
#[cfg_attr(feature = "serde", cfg_eval::cfg_eval, serde_as)]
206210
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
207211
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
208-
pub struct BLSPubkeyCompressed(
209-
#[cfg_attr(feature = "serde", serde(with = "serde_bytes"))]
210-
[u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE],
211-
);
212-
213-
impl Default for BLSPubkeyCompressed {
214-
fn default() -> Self {
215-
Self([0u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE])
216-
}
217-
}
218-
219-
impl From<BLSPubkeyCompressed> for [u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE] {
220-
fn from(wrapper: BLSPubkeyCompressed) -> Self {
221-
wrapper.0
222-
}
223-
}
224-
225-
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
226-
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
227-
pub struct BLSSignatureCompressed(
228-
#[cfg_attr(feature = "serde", serde(with = "serde_bytes"))] [u8; BLS_SIGNATURE_COMPRESSED_SIZE],
229-
);
230-
231-
impl Default for BLSSignatureCompressed {
232-
fn default() -> Self {
233-
Self([0u8; BLS_SIGNATURE_COMPRESSED_SIZE])
234-
}
235-
}
236-
237-
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
238-
#[derive(Debug, Default, PartialEq, Eq, Clone, Copy)]
239212
pub struct VoteInitV2 {
240213
pub node_pubkey: Pubkey,
241214
pub authorized_voter: Pubkey,
242-
pub authorized_voter_bls_pubkey: BLSPubkeyCompressed,
243-
pub authorized_voter_bls_proof_of_possession: BLSSignatureCompressed,
215+
#[cfg_attr(feature = "serde", serde_as(as = "[_; BLS_PUBLIC_KEY_COMPRESSED_SIZE]"))]
216+
pub authorized_voter_bls_pubkey: [u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE],
217+
#[cfg_attr(feature = "serde", serde_as(as = "[_; BLS_SIGNATURE_COMPRESSED_SIZE]"))]
218+
pub authorized_voter_bls_proof_of_possession: [u8; BLS_SIGNATURE_COMPRESSED_SIZE],
244219
pub authorized_withdrawer: Pubkey,
245220
pub inflation_rewards_commission_bps: u16,
246221
pub inflation_rewards_collector: Pubkey,
247222
pub block_revenue_commission_bps: u16,
248223
pub block_revenue_collector: Pubkey,
249224
}
250225

226+
impl Default for VoteInitV2 {
227+
fn default() -> Self {
228+
Self {
229+
node_pubkey: Pubkey::default(),
230+
authorized_voter: Pubkey::default(),
231+
authorized_voter_bls_pubkey: [0u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE],
232+
authorized_voter_bls_proof_of_possession: [0u8; BLS_SIGNATURE_COMPRESSED_SIZE],
233+
authorized_withdrawer: Pubkey::default(),
234+
inflation_rewards_commission_bps: 0,
235+
inflation_rewards_collector: Pubkey::default(),
236+
block_revenue_commission_bps: 0,
237+
block_revenue_collector: Pubkey::default(),
238+
}
239+
}
240+
}
241+
242+
#[cfg_attr(feature = "serde", cfg_eval::cfg_eval, serde_as)]
251243
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
252-
#[derive(Debug, Default, PartialEq, Eq, Clone, Copy)]
244+
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
253245
pub struct VoterWithBLSArgs {
254-
bls_pub_key: BLSPubkeyCompressed,
255-
bls_proof_of_possession: BLSSignatureCompressed,
246+
#[cfg_attr(feature = "serde", serde_as(as = "[_; BLS_PUBLIC_KEY_COMPRESSED_SIZE]"))]
247+
pub bls_pub_key: [u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE],
248+
#[cfg_attr(feature = "serde", serde_as(as = "[_; BLS_SIGNATURE_COMPRESSED_SIZE]"))]
249+
pub bls_proof_of_possession: [u8; BLS_SIGNATURE_COMPRESSED_SIZE],
250+
}
251+
252+
impl Default for VoterWithBLSArgs {
253+
fn default() -> Self {
254+
Self {
255+
bls_pub_key: [0u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE],
256+
bls_proof_of_possession: [0u8; BLS_SIGNATURE_COMPRESSED_SIZE],
257+
}
258+
}
256259
}
257260

258261
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]

0 commit comments

Comments
 (0)