Move Vote program out of the SDK
This commit is contained in:
committed by
Michael Vines
parent
b99e3eafdd
commit
1edf6c361e
@ -25,6 +25,7 @@ solana-metrics = { path = "../metrics", version = "0.12.0" }
|
||||
solana-sdk = { path = "../sdk", version = "0.12.0" }
|
||||
solana-native-loader = { path = "../programs/native/native_loader", version = "0.12.0" }
|
||||
solana-system-program = { path = "../programs/native/system", version = "0.12.0" }
|
||||
solana-vote-api = { path = "../programs/native/vote_api", version = "0.12.0" }
|
||||
|
||||
[lib]
|
||||
name = "solana_runtime"
|
||||
|
@ -11,7 +11,7 @@ use solana_sdk::native_loader;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use solana_sdk::transaction::Transaction;
|
||||
use solana_sdk::vote_program;
|
||||
use solana_vote_api;
|
||||
use std::collections::BTreeMap;
|
||||
use std::env;
|
||||
use std::fs::{create_dir_all, remove_dir_all};
|
||||
@ -427,7 +427,7 @@ impl AccountsDB {
|
||||
index: &HashMap<Pubkey, AccountMap>,
|
||||
pubkey: &Pubkey,
|
||||
) {
|
||||
if vote_program::check_id(&account.owner) {
|
||||
if solana_vote_api::check_id(&account.owner) {
|
||||
if Self::account_map_is_empty(pubkey, index) {
|
||||
self.index_info.vote_index.write().unwrap().remove(pubkey);
|
||||
} else {
|
||||
@ -1454,7 +1454,7 @@ mod tests {
|
||||
let pubkey = Keypair::new().pubkey();
|
||||
let mut default_account = Account::default();
|
||||
pubkeys.push(pubkey.clone());
|
||||
default_account.owner = vote_program::id();
|
||||
default_account.owner = solana_vote_api::id();
|
||||
default_account.tokens = (num + t + 1) as u64;
|
||||
assert!(accounts.load(0, &pubkey, true).is_none());
|
||||
accounts.store(0, &pubkey, &default_account);
|
||||
@ -1593,7 +1593,7 @@ mod tests {
|
||||
fn test_accounts_vote_filter() {
|
||||
solana_logger::setup();
|
||||
let accounts = Accounts::new(0, None);
|
||||
let mut vote_account = Account::new(1, 0, vote_program::id());
|
||||
let mut vote_account = Account::new(1, 0, solana_vote_api::id());
|
||||
let key = Keypair::new().pubkey();
|
||||
accounts.store_slow(0, &key, &vote_account);
|
||||
|
||||
@ -1608,7 +1608,7 @@ mod tests {
|
||||
vote_accounts = accounts.get_vote_accounts(1).collect();
|
||||
assert_eq!(vote_accounts.len(), 0);
|
||||
|
||||
let mut vote_account1 = Account::new(2, 0, vote_program::id());
|
||||
let mut vote_account1 = Account::new(2, 0, solana_vote_api::id());
|
||||
let key1 = Keypair::new().pubkey();
|
||||
accounts.store_slow(1, &key1, &vote_account1);
|
||||
|
||||
@ -1636,10 +1636,10 @@ mod tests {
|
||||
let accounts = accounts_db.get_vote_accounts(0);
|
||||
assert_eq!(accounts.len(), 1);
|
||||
accounts.iter().for_each(|(_, account)| {
|
||||
assert_eq!(account.owner, vote_program::id());
|
||||
assert_eq!(account.owner, solana_vote_api::id());
|
||||
});
|
||||
let lastkey = Keypair::new().pubkey();
|
||||
let mut lastaccount = Account::new(1, 0, vote_program::id());
|
||||
let mut lastaccount = Account::new(1, 0, solana_vote_api::id());
|
||||
accounts_db.store(0, &lastkey, &lastaccount);
|
||||
assert_eq!(accounts_db.get_vote_accounts(0).len(), 2);
|
||||
|
||||
|
@ -26,7 +26,9 @@ use solana_sdk::system_transaction::SystemTransaction;
|
||||
use solana_sdk::timing::{duration_as_us, MAX_RECENT_BLOCKHASHES, NUM_TICKS_PER_SECOND};
|
||||
use solana_sdk::token_program;
|
||||
use solana_sdk::transaction::Transaction;
|
||||
use solana_sdk::vote_program::{self, VoteState};
|
||||
use solana_vote_api;
|
||||
use solana_vote_api::vote_instruction::Vote;
|
||||
use solana_vote_api::vote_state::{Lockout, VoteState};
|
||||
use std::result;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::{Arc, RwLock};
|
||||
@ -255,15 +257,13 @@ impl Bank {
|
||||
// will be forced to select it as the leader for height 0
|
||||
let mut bootstrap_leader_staking_account = Account {
|
||||
tokens: bootstrap_leader_stake,
|
||||
userdata: vec![0; vote_program::get_max_size() as usize],
|
||||
owner: vote_program::id(),
|
||||
userdata: vec![0; VoteState::max_size() as usize],
|
||||
owner: solana_vote_api::id(),
|
||||
executable: false,
|
||||
};
|
||||
|
||||
let mut vote_state = VoteState::new(genesis_block.bootstrap_leader_id);
|
||||
vote_state
|
||||
.votes
|
||||
.push_back(vote_program::Lockout::new(&vote_program::Vote::new(0)));
|
||||
vote_state.votes.push_back(Lockout::new(&Vote::new(0)));
|
||||
vote_state
|
||||
.serialize(&mut bootstrap_leader_staking_account.userdata)
|
||||
.unwrap();
|
||||
@ -292,7 +292,7 @@ impl Bank {
|
||||
|
||||
fn add_builtin_programs(&self) {
|
||||
self.add_native_program("solana_system_program", &system_program::id());
|
||||
self.add_native_program("solana_vote_program", &vote_program::id());
|
||||
self.add_native_program("solana_vote_program", &solana_vote_api::id());
|
||||
self.add_native_program("solana_storage_program", &storage_program::id());
|
||||
self.add_native_program("solana_bpf_loader", &bpf_loader::id());
|
||||
self.add_native_program("solana_budget_program", &solana_budget_api::id());
|
||||
@ -1289,7 +1289,7 @@ mod tests {
|
||||
assert_eq!(solana_budget_api::id(), budget);
|
||||
assert_eq!(storage_program::id(), storage);
|
||||
assert_eq!(token_program::id(), token);
|
||||
assert_eq!(vote_program::id(), vote);
|
||||
assert_eq!(solana_vote_api::id(), vote);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1302,7 +1302,7 @@ mod tests {
|
||||
solana_budget_api::id(),
|
||||
storage_program::id(),
|
||||
token_program::id(),
|
||||
vote_program::id(),
|
||||
solana_vote_api::id(),
|
||||
];
|
||||
assert!(ids.into_iter().all(move |id| unique.insert(id)));
|
||||
}
|
||||
|
Reference in New Issue
Block a user