Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syscall: GetEpochStake #1152

Merged
merged 8 commits into from
Jun 11, 2024

Conversation

buffalojoec
Copy link

@buffalojoec buffalojoec commented May 2, 2024

Problem

Currently, on-chain programs have no knowledge of the current epoch's stake and
how much active stake is delegated to a certain vote account.

If this data was 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 to tally vote account stake in
support for a pending feature gate.

Summary of Changes

  • Introduce a new callback function to the SVM to retrieve the total epoch stake.
  • Introduce another new callback function to the SVM to retrieve the list of cached
    vote accounts.
  • Optionally require the cached total stake and list of vote accounts in the invoke
    context's EnvironmentConfig.
  • Introduce a new syscall - SyscallGetEpochStake - that will use these fields on the
    invoke context to retrieve total epoch stake or a given vote account's epoch stake.

SIMD 0133

Feature Gate Tracking Issue: #884

@buffalojoec buffalojoec force-pushed the syscall-get-epoch-stake-2 branch from cebf52d to 15e8474 Compare May 2, 2024 18:09
@buffalojoec buffalojoec force-pushed the syscall-get-epoch-stake-2 branch 3 times, most recently from 02dc2f6 to 52f6e22 Compare May 4, 2024 19:49
@codecov-commenter
Copy link

codecov-commenter commented May 4, 2024

Codecov Report

Attention: Patch coverage is 68.54839% with 78 lines in your changes are missing coverage. Please review.

Project coverage is 82.7%. Comparing base (ef8d362) to head (f8fc17c).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##           master    #1152     +/-   ##
=========================================
- Coverage    82.7%    82.7%   -0.1%     
=========================================
  Files         871      872      +1     
  Lines      370249   370496    +247     
=========================================
+ Hits       306391   306571    +180     
- Misses      63858    63925     +67     

@buffalojoec buffalojoec force-pushed the syscall-get-epoch-stake-2 branch from 52f6e22 to c92350e Compare May 6, 2024 23:51
@buffalojoec

This comment was marked as resolved.

@buffalojoec buffalojoec marked this pull request as ready for review May 7, 2024 00:15
runtime/src/bank.rs Outdated Show resolved Hide resolved
Copy link

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay on this. Mostly nits. However, I think we need to find a way to avoid importing unneeded dependencies into low-level crates with solana-vote

sdk/src/feature_set.rs Outdated Show resolved Hide resolved
runtime/src/bank.rs Outdated Show resolved Hide resolved
Cargo.lock Show resolved Hide resolved
Cargo.lock Show resolved Hide resolved
sdk/src/feature_set.rs Outdated Show resolved Hide resolved
programs/bpf_loader/src/syscalls/mod.rs Outdated Show resolved Hide resolved
sdk/program/src/program_stubs.rs Outdated Show resolved Hide resolved
sdk/program/src/syscalls/definitions.rs Outdated Show resolved Hide resolved
program-runtime/src/invoke_context.rs Outdated Show resolved Hide resolved
programs/bpf_loader/src/syscalls/mod.rs Outdated Show resolved Hide resolved
@buffalojoec buffalojoec force-pushed the syscall-get-epoch-stake-2 branch from fcf3908 to f8fc17c Compare May 17, 2024 23:18
@buffalojoec

This comment was marked as resolved.

@buffalojoec buffalojoec force-pushed the syscall-get-epoch-stake-2 branch from f8fc17c to 86b7981 Compare June 6, 2024 20:10
@buffalojoec buffalojoec force-pushed the syscall-get-epoch-stake-2 branch from 3bf712a to c8f3381 Compare June 6, 2024 21:24
Copy link

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All from me

@buffalojoec buffalojoec merged commit b150801 into anza-xyz:master Jun 11, 2024
54 checks passed
samkim-crypto pushed a commit to samkim-crypto/agave that referenced this pull request Jul 31, 2024
* SVM: add `get_vote_accounts` callback

* program-runtime: invoke context: add `vote_accounts`

* sdk: add feature gate for sol-get-epoch-stake

* syscall: get-epoch-stake

* syscall: get-epoch-stake: tests

* drop `get_compute_meter`

* refactor for total stake

* refactor API for total stake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants