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