Skip to main content

Module sysvar

Module sysvar 

Source
Expand description

Sysvar access via direct syscalls.

Provides zero-alloc, zero-deserialization access to Solana sysvars by reading them directly into stack buffers via syscalls, including the epoch schedule sysvar.

Re-exports§

pub use crate::arith::saturating_mul_u64;

Structs§

Clock
Clock sysvar data, read directly from the runtime.
EpochRewards
EpochRewards sysvar data (SIMD-0118).
EpochSchedule
Epoch schedule sysvar data.
Rent
Rent sysvar data.
SlotHash
One (slot, hash) entry from the SlotHashes sysvar.
StakeHistoryEntry
One epoch’s stake-history entry.

Constants§

ACCOUNT_STORAGE_OVERHEAD
Fixed per-account storage overhead charged by the cluster.
CLOCK_ID
Clock sysvar address.
EPOCH_REWARDS_ID
EpochRewards sysvar address (SIMD-0118).
EPOCH_SCHEDULE_ID
Epoch schedule sysvar address.
EPOCH_SCHEDULE_IMAGE_LEN
Length of the EpochSchedule sysvar’s account image.
EXEMPTION_THRESHOLD_YEARS
Years of rent an account must prepay to be rent-exempt.
INSTRUCTIONS_ID
Instructions sysvar address (for instruction introspection).
LAMPORTS_PER_BYTE_YEAR
Lamports charged per byte of account storage per year.
LAST_RESTART_SLOT_ID
LastRestartSlot sysvar address.
RENT_ID
Rent sysvar address.
RENT_IMAGE_LEN
Length of the Rent sysvar’s account image: u64 + f64 + u8.
SLOT_HASHES_ID
SlotHashes sysvar address.
STAKE_HISTORY_ID
StakeHistory sysvar address.

Functions§

decode_epoch_schedule
Decode the EpochSchedule account image (epoch_schedule_decodes_canonical_image pins the offsets).
get_clock
Read the Clock sysvar.
get_epoch_rewards
Read the EpochRewards sysvar (SIMD-0118).
get_epoch_schedule
Read the EpochSchedule sysvar.
get_epoch_stake
Get the current-epoch activated stake of the vote account at vote.
get_last_restart_slot
Read the slot of the last cluster restart (hard fork), or 0 if the cluster has never been restarted.
get_rent
Read the Rent sysvar.
get_sysvar_into
Copy dst.len() bytes starting at offset from the sysvar identified by sysvar_id into dst.
get_sysvar_prefix_at
get_sysvar_into that reports a read past the sysvar’s end as Ok(false) instead of an error, so a caller can read an optimistic prefix (a length word plus the first entry) in one syscall and fall back only when the sysvar is shorter than that.
get_total_epoch_stake
Get the cluster-wide total activated stake for the current epoch.
rent_exempt_minimum
Minimum balance for rent exemption assuming the launch-era rent constants (LAMPORTS_PER_BYTE_YEAR, EXEMPTION_THRESHOLD_YEARS, ACCOUNT_STORAGE_OVERHEAD).
scale_by_exemption_threshold
Apply the rent exemption_threshold (given as its IEEE-754 bit pattern) to an integer lamport amount without any floating-point instruction.
slot_hashes_latest
Read the most recent (slot, hash) from the SlotHashes sysvar.
stake_history_latest
Read the most recent stake-history entry.