Add Preview operating mode, rename SoftLaunch operating mode to Stable (#8331)

automerge
This commit is contained in:
Michael Vines 2020-02-19 17:48:58 -07:00 committed by GitHub
parent 8ae26867c5
commit 8c19b6268c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 26 deletions

View File

@ -32,7 +32,7 @@ pub fn get_inflation(operating_mode: OperatingMode, epoch: Epoch) -> Option<Infl
None
}
}
OperatingMode::SoftLaunch => {
OperatingMode::Stable | OperatingMode::Preview => {
if epoch == 0 {
// No inflation at epoch 0
Some(Inflation::new_disabled())
@ -54,7 +54,7 @@ pub fn get_programs(operating_mode: OperatingMode, epoch: Epoch) -> Option<Vec<(
OperatingMode::Development => {
if epoch == 0 {
Some(vec![
// Enable all SoftLaunch programs
// Enable all Stable programs
solana_bpf_loader_program!(),
solana_config_program!(),
solana_stake_program!(),
@ -71,7 +71,7 @@ pub fn get_programs(operating_mode: OperatingMode, epoch: Epoch) -> Option<Vec<(
None
}
}
OperatingMode::SoftLaunch => {
OperatingMode::Stable => {
if epoch == 0 {
Some(vec![
solana_config_program!(),
@ -82,11 +82,28 @@ pub fn get_programs(operating_mode: OperatingMode, epoch: Epoch) -> Option<Vec<(
} else if epoch == std::u64::MAX - 1 {
// The epoch of std::u64::MAX - 1 is a placeholder and is expected to be reduced in
// a future hard fork.
Some(vec![solana_storage_program!(), solana_vest_program!()])
Some(vec![solana_bpf_loader_program!()])
} else if epoch == std::u64::MAX {
// The epoch of std::u64::MAX is a placeholder and is expected to be reduced in a
// future hard fork.
Some(vec![solana_bpf_loader_program!()])
Some(vec![solana_storage_program!(), solana_vest_program!()])
} else {
None
}
}
OperatingMode::Preview => {
if epoch == 0 {
Some(vec![
solana_config_program!(),
solana_stake_program!(),
solana_system_program(),
solana_vote_program!(),
solana_bpf_loader_program!(),
])
} else if epoch == std::u64::MAX {
// The epoch of std::u64::MAX is a placeholder and is expected to be reduced in a
// future hard fork.
Some(vec![solana_storage_program!(), solana_vest_program!()])
} else {
None
}
@ -146,12 +163,12 @@ mod tests {
#[test]
fn test_softlaunch_inflation() {
assert_eq!(
get_inflation(OperatingMode::SoftLaunch, 0).unwrap(),
get_inflation(OperatingMode::Stable, 0).unwrap(),
Inflation::new_disabled()
);
assert_eq!(get_inflation(OperatingMode::SoftLaunch, 1), None);
assert_eq!(get_inflation(OperatingMode::Stable, 1), None);
assert_eq!(
get_inflation(OperatingMode::SoftLaunch, std::u64::MAX).unwrap(),
get_inflation(OperatingMode::Stable, std::u64::MAX).unwrap(),
Inflation::default()
);
}
@ -159,7 +176,7 @@ mod tests {
#[test]
fn test_softlaunch_programs() {
assert_eq!(
get_programs(OperatingMode::SoftLaunch, 0),
get_programs(OperatingMode::Stable, 0),
Some(vec![
solana_config_program!(),
solana_stake_program!(),
@ -167,8 +184,8 @@ mod tests {
solana_vote_program!(),
])
);
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).is_some());
assert_eq!(get_programs(OperatingMode::Stable, 1), None);
assert!(get_programs(OperatingMode::Stable, std::u64::MAX - 1).is_some());
assert!(get_programs(OperatingMode::Stable, std::u64::MAX).is_some());
}
}

View File

@ -142,7 +142,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
let default_target_tick_duration =
timing::duration_as_us(&PohConfig::default().target_tick_duration);
let default_ticks_per_slot = &clock::DEFAULT_TICKS_PER_SLOT.to_string();
let default_operating_mode = "softlaunch";
let default_operating_mode = "stable";
let matches = App::new(crate_name!())
.about(crate_description!())
@ -350,12 +350,12 @@ fn main() -> Result<(), Box<dyn error::Error>> {
Arg::with_name("operating_mode")
.long("operating-mode")
.possible_value("development")
.possible_value("softlaunch")
.possible_value("preview")
.possible_value("stable")
.takes_value(true)
.default_value(default_operating_mode)
.help(
"Configure the cluster for \"development\" mode where all features are available at epoch 0, \
or \"softlaunch\" mode where some features are disabled at epoch 0"
"Selects the features that will be enabled for the cluster"
),
)
.get_matches();
@ -456,10 +456,11 @@ fn main() -> Result<(), Box<dyn error::Error>> {
Duration::from_micros(default_target_tick_duration)
};
let operating_mode = if matches.value_of("operating_mode").unwrap() == "development" {
OperatingMode::Development
} else {
OperatingMode::SoftLaunch
let operating_mode = match matches.value_of("operating_mode").unwrap() {
"development" => OperatingMode::Development,
"stable" => OperatingMode::Stable,
"preview" => OperatingMode::Preview,
_ => unreachable!(),
};
match matches.value_of("hashes_per_tick").unwrap() {
@ -469,7 +470,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
compute_hashes_per_tick(poh_config.target_tick_duration, 1_000_000);
poh_config.hashes_per_tick = Some(hashes_per_tick);
}
OperatingMode::SoftLaunch => {
OperatingMode::Stable | OperatingMode::Preview => {
poh_config.hashes_per_tick =
Some(clock::DEFAULT_HASHES_PER_SECOND / clock::DEFAULT_TICKS_PER_SECOND);
}
@ -487,7 +488,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
} else {
match operating_mode {
OperatingMode::Development => clock::DEFAULT_DEV_SLOTS_PER_EPOCH,
OperatingMode::SoftLaunch => clock::DEFAULT_SLOTS_PER_EPOCH,
OperatingMode::Stable | OperatingMode::Preview => clock::DEFAULT_SLOTS_PER_EPOCH,
}
};
let epoch_schedule = EpochSchedule::new(slots_per_epoch);

View File

@ -163,7 +163,7 @@ impl LocalCluster {
genesis_config.poh_config = config.poh_config.clone();
match genesis_config.operating_mode {
OperatingMode::SoftLaunch => {
OperatingMode::Stable | OperatingMode::Preview => {
genesis_config.native_instruction_processors =
solana_genesis_programs::get_programs(genesis_config.operating_mode, 0)
.unwrap()

View File

@ -552,7 +552,7 @@ fn test_softlaunch_operating_mode() {
solana_logger::setup();
let config = ClusterConfig {
operating_mode: OperatingMode::SoftLaunch,
operating_mode: OperatingMode::Stable,
node_stakes: vec![100; 1],
cluster_lamports: 1_000,
validator_configs: vec![ValidatorConfig::default(); 1],

View File

@ -25,8 +25,9 @@ use std::{
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq)]
pub enum OperatingMode {
SoftLaunch, // Cluster features incrementally enabled over time
Development, // All features (including experimental features) available immediately from genesis
Stable, // Stable cluster features
Preview, // Next set of cluster features to be promoted to Stable
Development, // All features (including experimental features)
}
#[derive(Serialize, Deserialize, Debug, Clone)]