Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 2 additions & 11 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,6 @@ solana-slot-hashes = "3.0.0"
solana-slot-history = "3.0.0"
solana-stable-layout = "3.0.0"
solana-stake-interface = { version = "2.0.1" }
solana-stake-program = { path = "programs/stake", version = "=3.1.0-beta.0", features = ["agave-unstable-api"] }
solana-storage-bigtable = { path = "storage-bigtable", version = "=3.1.0-beta.0", features = ["agave-unstable-api"] }
solana-storage-proto = { path = "storage-proto", version = "=3.1.0-beta.0", features = ["agave-unstable-api"] }
solana-streamer = { path = "streamer", version = "=3.1.0-beta.0", features = ["agave-unstable-api"] }
Expand Down
4 changes: 2 additions & 2 deletions accounts-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dev-context-only-utils = [
"dep:solana-keypair",
"dep:solana-rent",
"dep:solana-signer",
"dep:solana-stake-program",
"dep:solana-stake-interface",
"dep:solana-vote-program",
"solana-account/dev-context-only-utils",
"solana-transaction/dev-context-only-utils",
Expand Down Expand Up @@ -89,7 +89,7 @@ solana-reward-info = { workspace = true, features = ["serde"] }
solana-sha256-hasher = { workspace = true }
solana-signer = { workspace = true, optional = true }
solana-slot-hashes = { workspace = true }
solana-stake-program = { workspace = true, optional = true }
solana-stake-interface = { workspace = true, optional = true }
solana-svm-transaction = { workspace = true }
solana-system-interface = { workspace = true }
solana-sysvar = { workspace = true }
Expand Down
54 changes: 51 additions & 3 deletions accounts-db/src/stake_rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,18 @@ impl<'a> StorableAccounts<'a> for (Slot, &'a [StakeReward]) {

#[cfg(feature = "dev-context-only-utils")]
use {
rand::Rng, solana_account::WritableAccount, solana_keypair::Keypair, solana_rent::Rent,
solana_signer::Signer, solana_stake_program::stake_state, solana_vote_program::vote_state,
rand::Rng,
solana_account::{state_traits::StateMut, WritableAccount},
solana_clock::Epoch,
solana_keypair::Keypair,
solana_rent::Rent,
solana_signer::Signer,
solana_stake_interface::{
program as stake_program,
stake_flags::StakeFlags,
state::{Authorized, Delegation, Meta, Stake, StakeStateV2},
},
solana_vote_program::vote_state,
};

// These functions/fields are only usable from a dev context (i.e. tests and benches)
Expand All @@ -92,7 +102,7 @@ impl StakeReward {
);

let reward_lamports: i64 = rng.gen_range(1..200);
let validator_stake_account = stake_state::create_account(
let validator_stake_account = create_stake_account(
&validator_staking_keypair.pubkey(),
&validator_voting_keypair.pubkey(),
&validator_vote_account,
Expand All @@ -119,3 +129,41 @@ impl StakeReward {
self.stake_account.checked_add_lamports(amount).unwrap();
}
}

#[cfg(feature = "dev-context-only-utils")]
fn create_stake_account(
authorized: &Pubkey,
voter_pubkey: &Pubkey,
vote_account: &AccountSharedData,
rent: &Rent,
lamports: u64,
) -> AccountSharedData {
let mut stake_account =
AccountSharedData::new(lamports, StakeStateV2::size_of(), &stake_program::id());

let vote_state =
vote_state::VoteStateV4::deserialize(vote_account.data(), voter_pubkey).unwrap();
let credits_observed = vote_state.credits();

let rent_exempt_reserve = rent.minimum_balance(stake_account.data().len());
let stake_amount = lamports
.checked_sub(rent_exempt_reserve)
.expect("lamports >= rent_exempt_reserve");

let meta = Meta {
authorized: Authorized::auto(authorized),
rent_exempt_reserve,
..Meta::default()
};

let stake = Stake {
delegation: Delegation::new(voter_pubkey, stake_amount, Epoch::MAX),
credits_observed,
};

stake_account
.set_state(&StakeStateV2::Stake(meta, stake, StakeFlags::empty()))
.expect("set_state");

stake_account
}
1 change: 0 additions & 1 deletion builtins-default-costs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ solana-frozen-abi = { workspace = true, optional = true, features = [
solana-loader-v4-program = { workspace = true, features = ["agave-unstable-api"] }
solana-pubkey = { workspace = true }
solana-sdk-ids = { workspace = true }
solana-stake-program = { workspace = true }
solana-system-program = { workspace = true }
solana-vote-program = { workspace = true }

Expand Down
1 change: 0 additions & 1 deletion builtins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ solana-loader-v4-program = { workspace = true }
solana-program-runtime = { workspace = true }
solana-pubkey = { workspace = true }
solana-sdk-ids = { workspace = true }
solana-stake-program = { workspace = true }
solana-system-program = { workspace = true }
solana-vote-program = { workspace = true }
solana-zk-elgamal-proof-program = { workspace = true }
Expand Down
1 change: 0 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ solana-poh = { workspace = true, features = ["dev-context-only-utils"] }
solana-program-binaries = { workspace = true }
solana-program-runtime = { workspace = true, features = ["metrics"] }
solana-rpc = { workspace = true, features = ["dev-context-only-utils"] }
solana-stake-program = { workspace = true }
solana-system-program = { workspace = true }
solana-unified-scheduler-pool = { workspace = true, features = [
"dev-context-only-utils",
Expand Down
21 changes: 13 additions & 8 deletions core/src/commitment_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,11 @@ mod tests {
solana_account::{state_traits::StateMut, Account, ReadableAccount},
solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo},
solana_pubkey::Pubkey,
solana_runtime::genesis_utils::{
create_genesis_config_with_vote_accounts, ValidatorVoteKeypairs,
solana_runtime::{
genesis_utils::{create_genesis_config_with_vote_accounts, ValidatorVoteKeypairs},
stake_utils,
},
solana_signer::Signer,
solana_stake_program::stake_state,
solana_vote::vote_transaction,
solana_vote_program::vote_state::{
self, process_slot_vote_unchecked, TowerSync, VoteStateV4, VoteStateVersions,
Expand Down Expand Up @@ -409,8 +409,13 @@ mod tests {
0,
100,
);
let stake_account1 =
stake_state::create_account(&sk1, &pk1, &vote_account1, &genesis_config.rent, 100);
let stake_account1 = stake_utils::create_stake_account(
&sk1,
&pk1,
&vote_account1,
&genesis_config.rent,
100,
);
let sk2 = solana_pubkey::new_rand();
let pk2 = solana_pubkey::new_rand();
let mut vote_account2 = vote_state::create_v4_account_with_authorized(
Expand All @@ -422,7 +427,7 @@ mod tests {
50,
);
let stake_account2 =
stake_state::create_account(&sk2, &pk2, &vote_account2, &genesis_config.rent, 50);
stake_utils::create_stake_account(&sk2, &pk2, &vote_account2, &genesis_config.rent, 50);
let sk3 = solana_pubkey::new_rand();
let pk3 = solana_pubkey::new_rand();
let mut vote_account3 = vote_state::create_v4_account_with_authorized(
Expand All @@ -433,7 +438,7 @@ mod tests {
0,
1,
);
let stake_account3 = stake_state::create_account(
let stake_account3 = stake_utils::create_stake_account(
&sk3,
&pk3,
&vote_account3,
Expand All @@ -450,7 +455,7 @@ mod tests {
0,
1,
);
let stake_account4 = stake_state::create_account(
let stake_account4 = stake_utils::create_stake_account(
&sk4,
&pk4,
&vote_account4,
Expand Down
32 changes: 2 additions & 30 deletions dev-bins/Cargo.lock

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

1 change: 0 additions & 1 deletion dev-bins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ solana-shred-version = "3.0.0"
solana-signature = { version = "3.1.0", default-features = false }
solana-signer = "3.0.0"
solana-stake-interface = { version = "2.0.1" }
solana-stake-program = { path = "../programs/stake", version = "=3.1.0-beta.0", features = ["agave-unstable-api"] }
solana-storage-bigtable = { path = "../storage-bigtable", version = "=3.1.0-beta.0", features = ["agave-unstable-api"] }
solana-streamer = { path = "../streamer", version = "=3.1.0-beta.0", features = ["agave-unstable-api"] }
solana-svm-callback = { path = "../svm-callback", version = "=3.1.0-beta.0", features = ["agave-unstable-api"] }
Expand Down
Loading
Loading