Update FeatureSet::active to include slot-activated (#13256)
* Update FeatureSet::active to include slot-activated * Clippy suggestion
This commit is contained in:
parent
a74f0f90e4
commit
c2dbf53d76
|
@ -3950,7 +3950,7 @@ impl Bank {
|
|||
let slot = self.slot();
|
||||
|
||||
for feature_id in &self.feature_set.inactive {
|
||||
let mut activated = false;
|
||||
let mut activated = None;
|
||||
if let Some(mut account) = self.get_account(feature_id) {
|
||||
if let Some(mut feature) = Feature::from_account(&account) {
|
||||
match feature.activated_at {
|
||||
|
@ -3962,21 +3962,21 @@ impl Bank {
|
|||
self.store_account(feature_id, &account);
|
||||
}
|
||||
newly_activated.insert(*feature_id);
|
||||
activated = true;
|
||||
activated = Some(slot);
|
||||
info!("Feature {} activated at slot {}", feature_id, slot);
|
||||
}
|
||||
}
|
||||
Some(activation_slot) => {
|
||||
if slot >= activation_slot {
|
||||
// Feature is already active
|
||||
activated = true;
|
||||
activated = Some(activation_slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if activated {
|
||||
active.insert(*feature_id);
|
||||
if let Some(slot) = activated {
|
||||
active.insert(*feature_id, slot);
|
||||
} else {
|
||||
inactive.insert(*feature_id);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use lazy_static::lazy_static;
|
||||
use solana_sdk::{
|
||||
clock::Slot,
|
||||
hash::{Hash, Hasher},
|
||||
pubkey::Pubkey,
|
||||
};
|
||||
|
@ -114,21 +115,25 @@ lazy_static! {
|
|||
/// `FeatureSet` holds the set of currently active/inactive runtime features
|
||||
#[derive(AbiExample, Debug, Clone)]
|
||||
pub struct FeatureSet {
|
||||
pub active: HashSet<Pubkey>,
|
||||
pub active: HashMap<Pubkey, Slot>,
|
||||
pub inactive: HashSet<Pubkey>,
|
||||
}
|
||||
impl Default for FeatureSet {
|
||||
fn default() -> Self {
|
||||
// All features disabled
|
||||
Self {
|
||||
active: HashSet::new(),
|
||||
active: HashMap::new(),
|
||||
inactive: FEATURE_NAMES.keys().cloned().collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl FeatureSet {
|
||||
pub fn is_active(&self, feature_id: &Pubkey) -> bool {
|
||||
self.active.contains(feature_id)
|
||||
self.active.contains_key(feature_id)
|
||||
}
|
||||
|
||||
pub fn activated_slot(&self, feature_id: &Pubkey) -> Option<Slot> {
|
||||
self.active.get(feature_id).copied()
|
||||
}
|
||||
|
||||
pub fn cumulative_rent_related_fixes_enabled(&self) -> bool {
|
||||
|
@ -138,7 +143,7 @@ impl FeatureSet {
|
|||
/// All features enabled, useful for testing
|
||||
pub fn all_enabled() -> Self {
|
||||
Self {
|
||||
active: FEATURE_NAMES.keys().cloned().collect(),
|
||||
active: FEATURE_NAMES.keys().cloned().map(|key| (key, 0)).collect(),
|
||||
inactive: HashSet::new(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue