From cc6ba1e13106525b8f1dd25aadeb0626d3786e1d Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Thu, 24 Sep 2020 00:22:49 -0700 Subject: [PATCH] Remove id field --- runtime/src/bank.rs | 6 +----- runtime/src/feature_set.rs | 16 +++++----------- version/src/lib.rs | 4 +--- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index d2d1cd8754..306114365a 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -3517,11 +3517,7 @@ impl Bank { inactive.insert(*feature_id); } - self.feature_set = Arc::new(FeatureSet { - id: self.feature_set.id, - active, - inactive, - }); + self.feature_set = Arc::new(FeatureSet { active, inactive }); newly_activated } diff --git a/runtime/src/feature_set.rs b/runtime/src/feature_set.rs index 790d352670..ad30459a5b 100644 --- a/runtime/src/feature_set.rs +++ b/runtime/src/feature_set.rs @@ -14,6 +14,7 @@ pub mod secp256k1_program_enabled { } lazy_static! { + /// Map of feature identifiers to user-visible description pub static ref FEATURE_NAMES: HashMap = [ (instructions_sysvar_enabled::id(), "instructions sysvar"), (secp256k1_program_enabled::id(), "secp256k1 program") @@ -23,7 +24,8 @@ lazy_static! { .cloned() .collect(); - static ref ID: Hash = { + /// Unique identifier of the current software's feature set + pub static ref ID: Hash = { let mut hasher = Hasher::default(); let mut feature_ids = FEATURE_NAMES.keys().collect::>(); feature_ids.sort(); @@ -34,16 +36,10 @@ lazy_static! { }; } -/// The `FeatureSet` struct tracks the set of available and currently active runtime features +/// `FeatureSet` holds the set of currently active/inactive runtime features #[derive(AbiExample)] pub struct FeatureSet { - /// Unique identifier of this feature set - pub id: Hash, - - /// Features that are currently active pub active: HashSet, - - /// Features that are currently inactive pub inactive: HashSet, } @@ -54,10 +50,9 @@ impl FeatureSet { } impl Default for FeatureSet { - // By default all features are disabled fn default() -> Self { + // All features disabled Self { - id: *ID, active: HashSet::new(), inactive: FEATURE_NAMES.keys().cloned().collect(), } @@ -67,7 +62,6 @@ impl Default for FeatureSet { impl FeatureSet { pub fn enabled() -> Self { Self { - id: *ID, active: FEATURE_NAMES.keys().cloned().collect(), inactive: HashSet::new(), } diff --git a/version/src/lib.rs b/version/src/lib.rs index 958b023ef5..42cb11fc13 100644 --- a/version/src/lib.rs +++ b/version/src/lib.rs @@ -51,9 +51,7 @@ fn compute_commit(sha1: Option<&'static str>) -> Option { impl Default for Version { fn default() -> Self { let feature_set = u32::from_le_bytes( - solana_runtime::feature_set::FeatureSet::default() - .id - .as_ref()[..4] + solana_runtime::feature_set::ID.as_ref()[..4] .try_into() .unwrap(), );