Remove non-essential programs from runtime/

This commit is contained in:
Michael Vines
2019-03-12 11:44:41 -07:00
parent 3d2b7dd1ef
commit 1ee43a7633
11 changed files with 119 additions and 77 deletions

View File

@ -70,7 +70,76 @@ fn main() -> Result<(), Box<dyn error::Error>> {
);
genesis_block.mint_id = mint_keypair.pubkey();
genesis_block.bootstrap_leader_vote_account_id = bootstrap_leader_vote_account_keypair.pubkey();
genesis_block.native_programs.extend_from_slice(&[
("solana_budget_program".to_string(), solana_budget_api::id()),
(
"solana_storage_program".to_string(),
solana_storage_api::id(),
),
("solana_token_program".to_string(), solana_token_api::id()),
]);
create_new_ledger(ledger_path, &genesis_block)?;
Ok(())
}
#[cfg(test)]
mod tests {
use hashbrown::HashSet;
use solana_sdk::pubkey::Pubkey;
#[test]
fn test_program_ids() {
let system = Pubkey::new(&[
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,
]);
let native = Pubkey::new(&[
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,
]);
let bpf = Pubkey::new(&[
128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
]);
let budget = Pubkey::new(&[
129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
]);
let storage = Pubkey::new(&[
130, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
]);
let token = Pubkey::new(&[
131, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
]);
let vote = Pubkey::new(&[
132, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
]);
assert_eq!(solana_sdk::system_program::id(), system);
assert_eq!(solana_sdk::native_loader::id(), native);
assert_eq!(solana_sdk::bpf_loader::id(), bpf);
assert_eq!(solana_budget_api::id(), budget);
assert_eq!(solana_storage_api::id(), storage);
assert_eq!(solana_token_api::id(), token);
assert_eq!(solana_vote_api::id(), vote);
}
#[test]
fn test_program_id_uniqueness() {
let mut unique = HashSet::new();
let ids = vec![
solana_sdk::system_program::id(),
solana_sdk::native_loader::id(),
solana_sdk::bpf_loader::id(),
solana_budget_api::id(),
solana_storage_api::id(),
solana_token_api::id(),
solana_vote_api::id(),
];
assert!(ids.into_iter().all(move |id| unique.insert(id)));
}
}