SIMD-0133
Syscall Get-Epoch-Stake
Feature Gate Status
FKe75t4LXxGaQnVHdUKM6DSFifVVraGZ8LyNo7oPwy1Z
TL;DR
A syscall to retrieve a vote account's delegated stake or the total cluster stake for the current epoch.
Summary
A syscall to retrieve a vote account's delegated stake or the total cluster stake for the current epoch.
Motivation
Currently, on-chain programs have no knowledge of the current epoch's stake and how much active stake is delegated to any vote account. If this data were available for querying by on-chain programs, it would unblock many use cases, such as validator governance and secondary consensus mechanisms, that were previously not possible on Solana. Additionally, this would enable the Feature Gate program defined in [SIMD 0089](./0089-programify-feature-gate-program.md) to tally vote account stake in support for a pending feature gate.
Key Changes
- Retrieves the total active stake delegated to a vote account, or for the
- entire cluster, for the current epoch.
- If a valid pointer for vote_addr is provided, returns the total active
- stake delegated to the vote account at the 32-byte address found at
- If a null pointer is provided, returns the total active stake for the
- @param vote_addr A pointer to 32 bytes representing the vote address.
- Can be a null pointer.
- @return A 64-bit unsigned integer representing the total
- active stake delegated to the vote account at the
- provided address.
- The syscall aborts the virtual machine if:
- Not all bytes in VM memory range [vote_addr, vote_addr + 32) are readable.
- Compute budget is exceeded.
- Otherwise, the syscall returns a u64 integer representing the total active stake delegated to the vote account at the provided address. If the provided vote address corresponds to an account that is not a vote account or does not exist, the syscall will return 0 for active stake.
- Otherwise, the syscall returns a u64 integer representing the total active stake on the cluster for the current epoch.
- PUBKEY_BYTES: 32 bytes for an Ed25519 public key.
- syscall_base: Base cost of a syscall.
- cpi_bytes_per_units: Number of account data bytes per CU charged during CPI.
- mem_op_base: Base cost of a memory operation syscall.
Impact
Dapp developers will be able to query vote account and cluster stake for the current epoch from within on-chain programs.
Security Considerations
This new syscall introduces the same security considerations as the rest of the syscalls in the existing interface, which manipulate raw pointers to VM memory and must be implemented with care.