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
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
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions program-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ solana-frozen-abi-macro = { workspace = true, optional = true }
solana-measure = { workspace = true }
solana-metrics = { workspace = true }
solana-sdk = { workspace = true }
solana-vote = { workspace = true }
solana_rbpf = { workspace = true }
thiserror = { workspace = true }

Expand Down
19 changes: 19 additions & 0 deletions program-runtime/src/invoke_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use {
IndexOfAccount, InstructionAccount, TransactionAccount, TransactionContext,
},
},
solana_vote::vote_account::VoteAccountsHashMap,
std::{
alloc::Layout,
cell::RefCell,
Expand Down Expand Up @@ -146,19 +147,25 @@ impl BpfAllocator {

pub struct EnvironmentConfig<'a> {
pub blockhash: Hash,
epoch_total_stake: Option<u64>,
epoch_vote_accounts: Option<&'a VoteAccountsHashMap>,
pub feature_set: Arc<FeatureSet>,
pub lamports_per_signature: u64,
sysvar_cache: &'a SysvarCache,
}
impl<'a> EnvironmentConfig<'a> {
pub fn new(
blockhash: Hash,
epoch_total_stake: Option<u64>,
epoch_vote_accounts: Option<&'a VoteAccountsHashMap>,
feature_set: Arc<FeatureSet>,
lamports_per_signature: u64,
sysvar_cache: &'a SysvarCache,
) -> Self {
Self {
blockhash,
epoch_total_stake,
epoch_vote_accounts,
feature_set,
lamports_per_signature,
sysvar_cache,
Expand Down Expand Up @@ -614,6 +621,16 @@ impl<'a> InvokeContext<'a> {
self.environment_config.sysvar_cache
}

/// Get cached epoch total stake.
pub fn get_epoch_total_stake(&self) -> Option<u64> {
self.environment_config.epoch_total_stake
}

/// Get cached epoch vote accounts.
pub fn get_epoch_vote_accounts(&self) -> Option<&VoteAccountsHashMap> {
self.environment_config.epoch_vote_accounts
}

// Should alignment be enforced during user pointer translation
pub fn get_check_aligned(&self) -> bool {
self.transaction_context
Expand Down Expand Up @@ -710,6 +727,8 @@ macro_rules! with_mock_invoke_context {
});
let environment_config = EnvironmentConfig::new(
Hash::default(),
None,
None,
Arc::new(FeatureSet::all_enabled()),
0,
&sysvar_cache,
Expand Down
1 change: 1 addition & 0 deletions programs/bpf_loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ assert_matches = { workspace = true }
memoffset = { workspace = true }
rand = { workspace = true }
solana-sdk = { workspace = true, features = ["dev-context-only-utils"] }
solana-vote = { workspace = true }
test-case = { workspace = true }

[lib]
Expand Down
Loading