From 8c19b6268c36b8b720f175b0a3b3e99e6a24929e Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 19 Feb 2020 17:48:58 -0700 Subject: [PATCH] Add Preview operating mode, rename SoftLaunch operating mode to Stable (#8331) automerge --- genesis-programs/src/lib.rs | 41 ++++++++++++++++++++-------- genesis/src/main.rs | 21 +++++++------- local-cluster/src/local_cluster.rs | 2 +- local-cluster/tests/local_cluster.rs | 2 +- sdk/src/genesis_config.rs | 5 ++-- 5 files changed, 45 insertions(+), 26 deletions(-) diff --git a/genesis-programs/src/lib.rs b/genesis-programs/src/lib.rs index 0d12db88f..543e870bd 100644 --- a/genesis-programs/src/lib.rs +++ b/genesis-programs/src/lib.rs @@ -32,7 +32,7 @@ pub fn get_inflation(operating_mode: OperatingMode, epoch: Epoch) -> Option { + 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 { 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 { + OperatingMode::Stable => { if epoch == 0 { Some(vec![ solana_config_program!(), @@ -82,11 +82,28 @@ pub fn get_programs(operating_mode: OperatingMode, epoch: Epoch) -> Option { + 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()); } } diff --git a/genesis/src/main.rs b/genesis/src/main.rs index 3382e3b1f..a9241cf15 100644 --- a/genesis/src/main.rs +++ b/genesis/src/main.rs @@ -142,7 +142,7 @@ fn main() -> Result<(), Box> { 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> { 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> { 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> { 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> { } 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); diff --git a/local-cluster/src/local_cluster.rs b/local-cluster/src/local_cluster.rs index 9eb7f0fbf..1e11d7871 100644 --- a/local-cluster/src/local_cluster.rs +++ b/local-cluster/src/local_cluster.rs @@ -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() diff --git a/local-cluster/tests/local_cluster.rs b/local-cluster/tests/local_cluster.rs index f782108f6..54df4cdbe 100644 --- a/local-cluster/tests/local_cluster.rs +++ b/local-cluster/tests/local_cluster.rs @@ -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], diff --git a/sdk/src/genesis_config.rs b/sdk/src/genesis_config.rs index 8510fcc11..434fc365c 100644 --- a/sdk/src/genesis_config.rs +++ b/sdk/src/genesis_config.rs @@ -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)]