2020-09-21 22:36:23 -07:00
|
|
|
use lazy_static::lazy_static;
|
2020-09-21 14:03:35 -07:00
|
|
|
use solana_sdk::{
|
|
|
|
hash::{Hash, Hasher},
|
|
|
|
pubkey::Pubkey,
|
|
|
|
};
|
2020-09-21 22:36:23 -07:00
|
|
|
use std::collections::{HashMap, HashSet};
|
|
|
|
|
|
|
|
pub mod instructions_sysvar_enabled {
|
|
|
|
solana_sdk::declare_id!("EnvhHCLvg55P7PDtbvR1NwuTuAeodqpusV3MR5QEK8gs");
|
|
|
|
}
|
|
|
|
|
|
|
|
pub mod secp256k1_program_enabled {
|
|
|
|
solana_sdk::declare_id!("E3PHP7w8kB7np3CTQ1qQ2tW3KCtjRSXBQgW9vM2mWv2Y");
|
|
|
|
}
|
|
|
|
|
2020-09-23 22:34:00 -07:00
|
|
|
pub mod consistent_recent_blockhashes_sysvar {
|
|
|
|
solana_sdk::declare_id!("3h1BQWPDS5veRsq6mDBWruEpgPxRJkfwGexg5iiQ9mYg");
|
|
|
|
}
|
|
|
|
|
2020-09-25 16:19:03 -07:00
|
|
|
pub mod pico_inflation {
|
|
|
|
solana_sdk::declare_id!("GaBtBJvmS4Arjj5W1NmFcyvPjsHN38UGYDq2MDwbs9Qu");
|
|
|
|
}
|
|
|
|
|
2020-09-24 10:10:27 -07:00
|
|
|
pub mod spl_token_v2_multisig_fix {
|
|
|
|
solana_sdk::declare_id!("E5JiFDQCwyC6QfT9REFyMpfK2mHcmv1GUDySU1Ue7TYv");
|
|
|
|
}
|
|
|
|
|
2020-09-24 12:23:09 -07:00
|
|
|
pub mod bpf_loader2_program {
|
|
|
|
solana_sdk::declare_id!("DFBnrgThdzH4W6wZ12uGPoWcMnvfZj11EHnxHcVxLPhD");
|
|
|
|
}
|
|
|
|
|
2020-09-29 14:36:30 -07:00
|
|
|
pub mod compute_budget_config2 {
|
|
|
|
solana_sdk::declare_id!("HxvjqDSiF5sYdSYuCXsUnS8UeAoWsMT9iGoFP8pgV1mB");
|
|
|
|
}
|
|
|
|
|
2020-09-29 23:29:20 -07:00
|
|
|
pub mod sha256_syscall_enabled {
|
|
|
|
solana_sdk::declare_id!("D7KfP7bZxpkYtD4Pc38t9htgs1k5k47Yhxe4rp6WDVi8");
|
|
|
|
}
|
|
|
|
|
2020-10-01 11:59:28 +09:00
|
|
|
pub mod no_overflow_rent_distribution {
|
|
|
|
solana_sdk::declare_id!("4kpdyrcj5jS47CZb2oJGfVxjYbsMm2Kx97gFyZrxxwXz");
|
|
|
|
}
|
|
|
|
|
2020-10-06 23:52:13 -07:00
|
|
|
pub mod ristretto_mul_syscall_enabled {
|
|
|
|
solana_sdk::declare_id!("HRe7A6aoxgjKzdjbBv6HTy7tJ4YWqE6tVmYCGho6S9Aq");
|
|
|
|
}
|
|
|
|
|
2020-09-21 22:36:23 -07:00
|
|
|
lazy_static! {
|
2020-09-24 00:22:49 -07:00
|
|
|
/// Map of feature identifiers to user-visible description
|
2020-09-21 22:36:23 -07:00
|
|
|
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
|
|
|
|
(instructions_sysvar_enabled::id(), "instructions sysvar"),
|
2020-09-23 22:34:00 -07:00
|
|
|
(secp256k1_program_enabled::id(), "secp256k1 program"),
|
|
|
|
(consistent_recent_blockhashes_sysvar::id(), "consistent recentblockhashes sysvar"),
|
2020-09-25 16:19:03 -07:00
|
|
|
(pico_inflation::id(), "pico-inflation"),
|
2020-09-24 10:10:27 -07:00
|
|
|
(spl_token_v2_multisig_fix::id(), "spl-token multisig fix"),
|
2020-09-24 12:23:09 -07:00
|
|
|
(bpf_loader2_program::id(), "bpf_loader2 program"),
|
2020-09-29 14:36:30 -07:00
|
|
|
(compute_budget_config2::id(), "1ms compute budget"),
|
2020-10-01 11:59:28 +09:00
|
|
|
(sha256_syscall_enabled::id(), "sha256 syscall"),
|
|
|
|
(no_overflow_rent_distribution::id(), "no overflow rent distribution"),
|
2020-10-06 23:52:13 -07:00
|
|
|
(ristretto_mul_syscall_enabled::id(), "ristretto multiply syscall"),
|
2020-09-21 22:36:23 -07:00
|
|
|
/*************** ADD NEW FEATURES HERE ***************/
|
|
|
|
]
|
|
|
|
.iter()
|
|
|
|
.cloned()
|
|
|
|
.collect();
|
|
|
|
|
2020-09-24 00:22:49 -07:00
|
|
|
/// Unique identifier of the current software's feature set
|
|
|
|
pub static ref ID: Hash = {
|
2020-09-21 22:36:23 -07:00
|
|
|
let mut hasher = Hasher::default();
|
|
|
|
let mut feature_ids = FEATURE_NAMES.keys().collect::<Vec<_>>();
|
|
|
|
feature_ids.sort();
|
|
|
|
for feature in feature_ids {
|
|
|
|
hasher.hash(feature.as_ref());
|
|
|
|
}
|
|
|
|
hasher.result()
|
|
|
|
};
|
|
|
|
}
|
2020-09-21 14:03:35 -07:00
|
|
|
|
2020-09-24 00:22:49 -07:00
|
|
|
/// `FeatureSet` holds the set of currently active/inactive runtime features
|
2020-09-24 08:53:50 -07:00
|
|
|
#[derive(AbiExample, Clone)]
|
2020-09-21 14:03:35 -07:00
|
|
|
pub struct FeatureSet {
|
|
|
|
pub active: HashSet<Pubkey>,
|
|
|
|
pub inactive: HashSet<Pubkey>,
|
|
|
|
}
|
|
|
|
impl Default for FeatureSet {
|
|
|
|
fn default() -> Self {
|
2020-09-24 00:22:49 -07:00
|
|
|
// All features disabled
|
2020-09-21 14:03:35 -07:00
|
|
|
Self {
|
|
|
|
active: HashSet::new(),
|
2020-09-21 22:36:23 -07:00
|
|
|
inactive: FEATURE_NAMES.keys().cloned().collect(),
|
2020-09-21 14:03:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-09-29 20:18:28 -07:00
|
|
|
impl FeatureSet {
|
|
|
|
pub fn is_active(&self, feature_id: &Pubkey) -> bool {
|
|
|
|
self.active.contains(feature_id)
|
|
|
|
}
|
|
|
|
/// All features enabled, useful for testing
|
|
|
|
pub fn all_enabled() -> Self {
|
|
|
|
Self {
|
|
|
|
active: FEATURE_NAMES.keys().cloned().collect(),
|
|
|
|
inactive: HashSet::new(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|