Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions vote-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ license = { workspace = true }
edition = { workspace = true }

[dependencies]
arbitrary = { workspace = true, features = ["derive"], optional = true }
bincode = { workspace = true, optional = true }
num-derive = { workspace = true }
num-traits = { workspace = true }
Expand Down Expand Up @@ -37,7 +38,6 @@ solana-system-interface = { workspace = true, features = ["bincode"], optional =
solana-serialize-utils = { workspace = true }

[dev-dependencies]
arbitrary = { workspace = true, features = ["derive"] }
itertools = { workspace = true }
rand = { workspace = true }
solana-epoch-schedule = { workspace = true }
Expand All @@ -52,7 +52,11 @@ bincode = [
"dep:solana-system-interface",
"serde"
]
dev-context-only-utils = ["bincode"]
dev-context-only-utils = [
"bincode",
"dep:arbitrary",
"solana-pubkey/dev-context-only-utils",
]
frozen-abi = [
"dep:solana-frozen-abi",
"dep:solana-frozen-abi-macro",
Expand Down
4 changes: 2 additions & 2 deletions vote-interface/src/authorized_voters.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(test)]
#[cfg(feature = "dev-context-only-utils")]
use arbitrary::Arbitrary;
#[cfg(feature = "serde")]
use serde_derive::{Deserialize, Serialize};
Expand All @@ -7,7 +7,7 @@ use {solana_clock::Epoch, solana_pubkey::Pubkey, std::collections::BTreeMap};
#[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[derive(Debug, Default, PartialEq, Eq, Clone)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(feature = "dev-context-only-utils", derive(Arbitrary))]
pub struct AuthorizedVoters {
authorized_voters: BTreeMap<Epoch, Pubkey>,
}
Expand Down
17 changes: 8 additions & 9 deletions vote-interface/src/state/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Vote state

#[cfg(feature = "dev-context-only-utils")]
use arbitrary::Arbitrary;
#[cfg(all(not(target_os = "solana"), feature = "bincode"))]
use bincode::deserialize;
#[cfg(feature = "bincode")]
Expand All @@ -18,10 +20,7 @@ use {
std::{collections::VecDeque, fmt::Debug},
};
#[cfg(test)]
use {
arbitrary::{Arbitrary, Unstructured},
solana_epoch_schedule::MAX_LEADER_SCHEDULE_EPOCH_OFFSET,
};
use {arbitrary::Unstructured, solana_epoch_schedule::MAX_LEADER_SCHEDULE_EPOCH_OFFSET};

mod vote_state_0_23_5;
pub mod vote_state_1_14_11;
Expand Down Expand Up @@ -82,7 +81,7 @@ impl Vote {
#[cfg_attr(feature = "frozen-abi", derive(AbiExample))]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[derive(Default, Debug, PartialEq, Eq, Copy, Clone)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(feature = "dev-context-only-utils", derive(Arbitrary))]
pub struct Lockout {
slot: Slot,
confirmation_count: u32,
Expand Down Expand Up @@ -132,7 +131,7 @@ impl Lockout {
#[cfg_attr(feature = "frozen-abi", derive(AbiExample))]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[derive(Default, Debug, PartialEq, Eq, Copy, Clone)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(feature = "dev-context-only-utils", derive(Arbitrary))]
pub struct LandedVote {
// Latency is the difference in slot number between the slot that was voted on (lockout.slot) and the slot in
// which the vote that added this Lockout landed. For votes which were cast before versions of the validator
Expand Down Expand Up @@ -354,7 +353,7 @@ pub struct VoteAuthorizeCheckedWithSeedArgs {
#[cfg_attr(feature = "frozen-abi", derive(AbiExample))]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[derive(Debug, Default, PartialEq, Eq, Clone)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(feature = "dev-context-only-utils", derive(Arbitrary))]
pub struct BlockTimestamp {
pub slot: Slot,
pub timestamp: UnixTimestamp,
Expand All @@ -366,7 +365,7 @@ const MAX_ITEMS: usize = 32;
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "frozen-abi", derive(AbiExample))]
#[derive(Debug, PartialEq, Eq, Clone)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(feature = "dev-context-only-utils", derive(Arbitrary))]
pub struct CircBuf<I> {
buf: [I; MAX_ITEMS],
/// next pointer
Expand Down Expand Up @@ -419,7 +418,7 @@ impl<I> CircBuf<I> {
)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[derive(Debug, Default, PartialEq, Eq, Clone)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(feature = "dev-context-only-utils", derive(Arbitrary))]
pub struct VoteState {
/// the node that votes in this account
pub node_pubkey: Pubkey,
Expand Down
4 changes: 2 additions & 2 deletions vote-interface/src/state/vote_state_1_14_11.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
#[cfg(test)]
#[cfg(feature = "dev-context-only-utils")]
use arbitrary::Arbitrary;

// Offset used for VoteState version 1_14_11
Expand All @@ -12,7 +12,7 @@ const DEFAULT_PRIOR_VOTERS_OFFSET: usize = 82;
)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[derive(Debug, Default, PartialEq, Eq, Clone)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(feature = "dev-context-only-utils", derive(Arbitrary))]
pub struct VoteState1_14_11 {
/// the node that votes in this account
pub node_pubkey: Pubkey,
Expand Down