Merge native programs parts into one unit (#7047)
This commit is contained in:
@ -30,11 +30,9 @@ solana-metrics = { path = "../metrics", version = "0.21.0" }
|
||||
solana-bpf-loader-api = { path = "../programs/bpf_loader_api", version = "0.21.0" }
|
||||
solana-bpf-loader-program = { path = "../programs/bpf_loader_program", version = "0.21.0" }
|
||||
solana-sdk = { path = "../sdk", version = "0.21.0" }
|
||||
solana-stake-api = { path = "../programs/stake_api", version = "0.21.0" }
|
||||
solana-stake-program = { path = "../programs/stake_program", version = "0.21.0" }
|
||||
solana-stake-program = { path = "../programs/stake", version = "0.21.0" }
|
||||
solana-storage-api = { path = "../programs/storage_api", version = "0.21.0" }
|
||||
solana-vote-api = { path = "../programs/vote_api", version = "0.21.0" }
|
||||
solana-vote-program = { path = "../programs/vote_program", version = "0.21.0" }
|
||||
solana-vote-program = { path = "../programs/vote", version = "0.21.0" }
|
||||
sys-info = "0.5.8"
|
||||
tempfile = "3.1.0"
|
||||
solana-rayon-threadlimit = { path = "../rayon-threadlimit", version = "0.21.0" }
|
||||
|
@ -1306,7 +1306,7 @@ pub mod tests {
|
||||
}
|
||||
for t in 0..num_vote {
|
||||
let pubkey = Pubkey::new_rand();
|
||||
let account = Account::new((num + t + 1) as u64, space, &solana_vote_api::id());
|
||||
let account = Account::new((num + t + 1) as u64, space, &solana_vote_program::id());
|
||||
pubkeys.push(pubkey.clone());
|
||||
let ancestors = vec![(slot, 0)].into_iter().collect();
|
||||
assert!(accounts.load_slow(&ancestors, &pubkey).is_none());
|
||||
|
@ -1637,8 +1637,8 @@ mod tests {
|
||||
system_instruction,
|
||||
sysvar::{fees::Fees, rewards::Rewards},
|
||||
};
|
||||
use solana_stake_api::stake_state::Stake;
|
||||
use solana_vote_api::{
|
||||
use solana_stake_program::stake_state::Stake;
|
||||
use solana_vote_program::{
|
||||
vote_instruction,
|
||||
vote_state::{self, Vote, VoteInit, VoteState, MAX_LOCKOUT_HISTORY},
|
||||
};
|
||||
@ -3281,9 +3281,9 @@ mod tests {
|
||||
Err(InstructionError::CustomError(42))
|
||||
}
|
||||
|
||||
assert!(bank.get_account(&solana_vote_api::id()).is_none());
|
||||
bank.add_instruction_processor(solana_vote_api::id(), mock_vote_processor);
|
||||
assert!(bank.get_account(&solana_vote_api::id()).is_some());
|
||||
assert!(bank.get_account(&solana_vote_program::id()).is_none());
|
||||
bank.add_instruction_processor(solana_vote_program::id(), mock_vote_processor);
|
||||
assert!(bank.get_account(&solana_vote_program::id()).is_some());
|
||||
|
||||
let mock_account = Keypair::new();
|
||||
let instructions = vote_instruction::create_account(
|
||||
@ -3340,9 +3340,9 @@ mod tests {
|
||||
bank.last_blockhash(),
|
||||
);
|
||||
|
||||
let vote_loader_account = bank.get_account(&solana_vote_api::id()).unwrap();
|
||||
bank.add_instruction_processor(solana_vote_api::id(), mock_vote_processor);
|
||||
let new_vote_loader_account = bank.get_account(&solana_vote_api::id()).unwrap();
|
||||
let vote_loader_account = bank.get_account(&solana_vote_program::id()).unwrap();
|
||||
bank.add_instruction_processor(solana_vote_program::id(), mock_vote_processor);
|
||||
let new_vote_loader_account = bank.get_account(&solana_vote_program::id()).unwrap();
|
||||
// Vote loader account should not be updated since it was included in the genesis config.
|
||||
assert_eq!(vote_loader_account.data, new_vote_loader_account.data);
|
||||
assert_eq!(
|
||||
|
@ -7,8 +7,8 @@ use solana_sdk::{
|
||||
signature::{Keypair, KeypairUtil},
|
||||
system_program::{self, solana_system_program},
|
||||
};
|
||||
use solana_stake_api::stake_state;
|
||||
use solana_vote_api::vote_state;
|
||||
use solana_stake_program::stake_state;
|
||||
use solana_vote_program::vote_state;
|
||||
|
||||
// The default stake placed with the bootstrap leader
|
||||
pub const BOOTSTRAP_LEADER_LAMPORTS: u64 = 42;
|
||||
@ -85,7 +85,7 @@ pub fn create_genesis_config_with_leader(
|
||||
..GenesisConfig::default()
|
||||
};
|
||||
|
||||
solana_stake_api::add_genesis_accounts(&mut genesis_config);
|
||||
solana_stake_program::add_genesis_accounts(&mut genesis_config);
|
||||
solana_storage_api::rewards_pools::add_genesis_accounts(&mut genesis_config);
|
||||
|
||||
GenesisConfigInfo {
|
||||
|
@ -89,8 +89,11 @@ pub fn invoke_entrypoint(
|
||||
let path = create_path(&name);
|
||||
match library_open(&path) {
|
||||
Ok(library) => unsafe {
|
||||
let entrypoint: Symbol<instruction_processor_utils::Entrypoint> =
|
||||
match library.get(instruction_processor_utils::ENTRYPOINT.as_bytes()) {
|
||||
let entrypoint: Symbol<instruction_processor_utils::Entrypoint> = match library
|
||||
.get(name.as_bytes())
|
||||
{
|
||||
Ok(s) => s,
|
||||
Err(_) => match library.get(instruction_processor_utils::ENTRYPOINT.as_bytes()) {
|
||||
Ok(s) => s,
|
||||
Err(e) => {
|
||||
warn!(
|
||||
@ -100,7 +103,8 @@ pub fn invoke_entrypoint(
|
||||
);
|
||||
return Err(InstructionError::GenericError);
|
||||
}
|
||||
};
|
||||
},
|
||||
};
|
||||
let ret = entrypoint(program_id, params, ix_data);
|
||||
symbol_cache
|
||||
.write()
|
||||
|
@ -4,8 +4,8 @@ use solana_sdk::account::Account;
|
||||
use solana_sdk::clock::Epoch;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::sysvar::stake_history::StakeHistory;
|
||||
use solana_stake_api::stake_state::{new_stake_history_entry, StakeState};
|
||||
use solana_vote_api::vote_state::VoteState;
|
||||
use solana_stake_program::stake_state::{new_stake_history_entry, StakeState};
|
||||
use solana_vote_program::vote_state::VoteState;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Default, Clone, PartialEq, Debug, Deserialize, Serialize)]
|
||||
@ -96,13 +96,13 @@ impl Stakes {
|
||||
}
|
||||
|
||||
pub fn is_stake(account: &Account) -> bool {
|
||||
solana_vote_api::check_id(&account.owner)
|
||||
|| solana_stake_api::check_id(&account.owner)
|
||||
solana_vote_program::check_id(&account.owner)
|
||||
|| solana_stake_program::check_id(&account.owner)
|
||||
&& account.data.len() >= std::mem::size_of::<StakeState>()
|
||||
}
|
||||
|
||||
pub fn store(&mut self, pubkey: &Pubkey, account: &Account) {
|
||||
if solana_vote_api::check_id(&account.owner) {
|
||||
if solana_vote_program::check_id(&account.owner) {
|
||||
if account.lamports == 0 {
|
||||
self.vote_accounts.remove(pubkey);
|
||||
} else {
|
||||
@ -124,7 +124,7 @@ impl Stakes {
|
||||
|
||||
self.vote_accounts.insert(*pubkey, (stake, account.clone()));
|
||||
}
|
||||
} else if solana_stake_api::check_id(&account.owner) {
|
||||
} else if solana_stake_program::check_id(&account.owner) {
|
||||
// old_stake is stake lamports and voter_pubkey from the pre-store() version
|
||||
let old_stake = self.stake_accounts.get(pubkey).and_then(|old_account| {
|
||||
StakeState::stake_from(old_account).map(|stake| {
|
||||
@ -210,8 +210,8 @@ impl Stakes {
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use solana_sdk::{pubkey::Pubkey, rent::Rent};
|
||||
use solana_stake_api::stake_state;
|
||||
use solana_vote_api::vote_state::{self, VoteState, MAX_LOCKOUT_HISTORY};
|
||||
use solana_stake_program::stake_state;
|
||||
use solana_vote_program::vote_state::{self, VoteState, MAX_LOCKOUT_HISTORY};
|
||||
|
||||
// set up some dummies for a staked node (( vote ) ( stake ))
|
||||
pub fn create_staked_node_accounts(stake: u64) -> ((Pubkey, Account), (Pubkey, Account)) {
|
||||
@ -508,7 +508,10 @@ pub mod tests {
|
||||
}
|
||||
|
||||
// not a stake account, and whacks above entry
|
||||
stakes.store(&stake_pubkey, &Account::new(1, 0, &solana_stake_api::id()));
|
||||
stakes.store(
|
||||
&stake_pubkey,
|
||||
&Account::new(1, 0, &solana_stake_program::id()),
|
||||
);
|
||||
{
|
||||
let vote_accounts = stakes.vote_accounts();
|
||||
assert!(vote_accounts.get(&vote_pubkey).is_some());
|
||||
|
Reference in New Issue
Block a user