pub struct ValidatorInfo {Show 15 fields
pub node_identity: Pubkey,
pub authorized_withdrawer: Pubkey,
pub stake: u64,
pub address: Vec<u8>,
pub hostname: String,
pub authority_key: Vec<u8>,
pub protocol_key: Pubkey,
pub network_key: Pubkey,
pub registration_time: i64,
pub last_update: i64,
pub unbonding_periods: BTreeMap<u64, u64>,
pub lockup_period: u64,
pub commission_rate: u16,
pub new_commission_rate: Option<u16>,
pub earliest_shutdown: Option<u64>,
}Expand description
Data structure for the validator information account. This data structure is meant to hold
all information about a validator, such that we can leverage it in Epoch negotiation
and create a proper Authority object on Epoch change.
Fields§
§node_identity: Pubkey§stake: u64§address: Vec<u8>§hostname: String§protocol_key: Pubkey§network_key: Pubkey§registration_time: i64§last_update: i64§unbonding_periods: BTreeMap<u64, u64>Historical unbonding periods: effective_from_timestamp → unbonding_period_ms.
The duration in milliseconds that deactivating StakeInfo accounts wait before becoming inactive. Set by the runtime (via SetUnbondingPeriod) to punish misbehaving validators.
The first entry (key = registration_time) contains the default unbonding period. Subsequent entries are added by SetUnbondingPeriod to extend or reduce the period. Entries are in ascending order by timestamp (guaranteed by BTreeMap).
Note: A deactivated stake cannot be withdrawn until the unbonding period that was
effective at deactivation time has elapsed — see end_of_unbonding().
lockup_period: u64The minimum duration in milliseconds that StakeInfo accounts must commit to delegate for.
Can be set by the validator to earn increased rewards (bonus).
Note: An activated stake cannot be deactivated until
current_timestamp >= activation_requested + lockup_period.
This is fixed at registration and cannot be changed.
commission_rate: u16The validator’s commission from the inflation rewards in basis points, e.g. 835 corresponds to 8.35%
new_commission_rate: Option<u16>New commission_rate to be applied from the next epoch
earliest_shutdown: Option<u64>Optional timestamp (ms) after which the validator does not intend to participate in committees. Must be >= current_timestamp + lockup_period when set. Passing None resets the field (validator decides to continue).
Implementations§
Source§impl ValidatorInfo
impl ValidatorInfo
Sourcepub const MAX_UNBONDING_PERIOD_ENTRIES: usize = 100
pub const MAX_UNBONDING_PERIOD_ENTRIES: usize = 100
Maximum number of historical unbonding period entries allowed in the unbonding_periods map.
100 entries × 16 bytes (8-byte key + 8-byte value) = 1600 bytes of map data.
Enforced by the SetUnbondingPeriod handler to prevent unbounded account growth.
Sourcepub const fn account_size(
address_len: usize,
hostname_len: usize,
authority_key_len: usize,
) -> usize
pub const fn account_size( address_len: usize, hostname_len: usize, authority_key_len: usize, ) -> usize
Calculate the account data size needed to store a ValidatorInfo with the given
variable-length field sizes.
Uses the in-memory struct size as a safe upper bound, plus the actual lengths of the variable-length fields (address, hostname, authority_key).
Sourcepub fn end_of_unbonding(&self, deactivation_requested: u64) -> u64
pub fn end_of_unbonding(&self, deactivation_requested: u64) -> u64
Calculate when unbonding ends for a stake that requested deactivation at the given timestamp.
This handles three cases correctly:
- Active stake: Deactivated after punishment → uses punished period
- Unbonding stake: Was unbonding when punishment hit → gets extended
- Fully unbonded: Completed unbonding before punishment → exempt
§Algorithm (Dual-Tracking)
Uses two variables to achieve fairness (reductions apply to still-unbonding accounts) while preventing flash attacks (brief 0-period can’t free accounts):
-
max_end: monotonically increasing, tracks the longest unbonding window ever applicable. Used ONLY for the exemption check (“was this account genuinely done before this entry?”). Prevents flash reductions from creating false exemption gaps. -
effective_end: tracks the latest applicable period. This is the ACTUAL result. Can decrease when governance reduces a punishment.
§Complexity
O(log n + k) where n = total entries, k = entries after deactivation (typically 0-2)
§Arguments
deactivation_requested- When DeactivateStake was called (in milliseconds)
§Returns
The timestamp when unbonding completes
Trait Implementations§
Source§impl Clone for ValidatorInfo
impl Clone for ValidatorInfo
Source§fn clone(&self) -> ValidatorInfo
fn clone(&self) -> ValidatorInfo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ValidatorInfo
impl Debug for ValidatorInfo
Source§impl<'de> Deserialize<'de> for ValidatorInfo
impl<'de> Deserialize<'de> for ValidatorInfo
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ValidatorInfo, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ValidatorInfo, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ValidatorInfo
impl PartialEq for ValidatorInfo
Source§impl Serialize for ValidatorInfo
impl Serialize for ValidatorInfo
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for ValidatorInfo
impl StructuralPartialEq for ValidatorInfo
Auto Trait Implementations§
impl Freeze for ValidatorInfo
impl RefUnwindSafe for ValidatorInfo
impl Send for ValidatorInfo
impl Sync for ValidatorInfo
impl Unpin for ValidatorInfo
impl UnsafeUnpin for ValidatorInfo
impl UnwindSafe for ValidatorInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more