Enable system program at SoftLaunch epoch 0 (#7313)

This commit is contained in:
Michael Vines 2019-12-06 23:16:28 -07:00 committed by GitHub
parent c00216e3be
commit 33f7103eae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 13 deletions

1
Cargo.lock generated
View File

@ -3610,6 +3610,7 @@ dependencies = [
name = "solana-local-cluster" name = "solana-local-cluster"
version = "0.22.0" version = "0.22.0"
dependencies = [ dependencies = [
"assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -73,17 +73,20 @@ pub fn get_programs(operating_mode: OperatingMode, epoch: Epoch) -> Option<Vec<(
} }
OperatingMode::SoftLaunch => { OperatingMode::SoftLaunch => {
if epoch == 0 { if epoch == 0 {
// Voting and Staking only at epoch 0 // Voting, Staking and System Program only at epoch 0
Some(vec![solana_stake_program!(), solana_vote_program!()]) Some(vec![
solana_stake_program!(),
solana_system_program(),
solana_vote_program!(),
])
} else if epoch == std::u64::MAX - 1 { } else if epoch == std::u64::MAX - 1 {
// System program and Archivers are activated next // Archivers are activated next
// //
// The epoch of std::u64::MAX - 1 is a placeholder and is expected to be reduced in // The epoch of std::u64::MAX - 1 is a placeholder and is expected to be reduced in
// a future hard fork. // a future hard fork.
Some(vec![ Some(vec![
solana_config_program!(), solana_config_program!(),
solana_storage_program!(), solana_storage_program!(),
solana_system_program(),
solana_vest_program!(), solana_vest_program!(),
]) ])
} else if epoch == std::u64::MAX { } else if epoch == std::u64::MAX {
@ -165,7 +168,11 @@ mod tests {
fn test_softlaunch_programs() { fn test_softlaunch_programs() {
assert_eq!( assert_eq!(
get_programs(OperatingMode::SoftLaunch, 0), get_programs(OperatingMode::SoftLaunch, 0),
Some(vec![solana_stake_program!(), solana_vote_program!(),]) Some(vec![
solana_stake_program!(),
solana_system_program(),
solana_vote_program!(),
])
); );
assert_eq!(get_programs(OperatingMode::SoftLaunch, 1), None); assert_eq!(get_programs(OperatingMode::SoftLaunch, 1), None);
assert!(get_programs(OperatingMode::SoftLaunch, std::u64::MAX - 1).is_some()); assert!(get_programs(OperatingMode::SoftLaunch, std::u64::MAX - 1).is_some());

View File

@ -31,5 +31,6 @@ tempfile = "3.1.0"
solana-rayon-threadlimit = { path = "../rayon-threadlimit", version = "0.22.0" } solana-rayon-threadlimit = { path = "../rayon-threadlimit", version = "0.22.0" }
[dev-dependencies] [dev-dependencies]
assert_matches = "1.3.0"
serial_test = "0.3.1" serial_test = "0.3.1"
serial_test_derive = "0.3.1" serial_test_derive = "0.3.1"

View File

@ -170,9 +170,11 @@ impl LocalCluster {
.into_iter() .into_iter()
.collect() .collect()
} }
// create_genesis_config_with_leader() assumes OperatingMode::Development so do OperatingMode::Development => {
// nothing... genesis_config
OperatingMode::Development => (), .native_instruction_processors
.push(solana_storage_program!());
}
} }
genesis_config.inflation = genesis_config.inflation =
@ -181,9 +183,6 @@ impl LocalCluster {
genesis_config genesis_config
.native_instruction_processors .native_instruction_processors
.extend_from_slice(&config.native_instruction_processors); .extend_from_slice(&config.native_instruction_processors);
genesis_config
.native_instruction_processors
.push(solana_storage_program!());
let storage_keypair = Keypair::new(); let storage_keypair = Keypair::new();
genesis_config.add_account( genesis_config.add_account(

View File

@ -1,3 +1,4 @@
use assert_matches::assert_matches;
use log::*; use log::*;
use serial_test_derive::serial; use serial_test_derive::serial;
use solana_client::thin_client::create_client; use solana_client::thin_client::create_client;
@ -565,11 +566,30 @@ fn test_softlaunch_operating_mode() {
solana_core::cluster_info::VALIDATOR_PORT_RANGE, solana_core::cluster_info::VALIDATOR_PORT_RANGE,
); );
// Programs that are not available at soft launch // Programs that are available at soft launch epoch 0
for program_id in [
&solana_sdk::system_program::id(),
&solana_vote_program::id(),
&solana_stake_program::id(),
]
.iter()
{
assert_matches!(
(
program_id,
client
.get_account_with_commitment(program_id, CommitmentConfig::recent())
.unwrap()
),
(_program_id, Some(_))
);
}
// Programs that are not available at soft launch epoch 0
for program_id in [ for program_id in [
&solana_config_program::id(), &solana_config_program::id(),
&solana_sdk::bpf_loader::id(), &solana_sdk::bpf_loader::id(),
&solana_sdk::system_program::id(), &solana_storage_program::id(),
&solana_vest_program::id(), &solana_vest_program::id(),
] ]
.iter() .iter()