2021-07-18 10:48:09 -07:00
|
|
|
//! Collection of all runtime features.
|
|
|
|
//!
|
|
|
|
//! Steps to add a new feature are outlined below. Note that these steps only cover
|
|
|
|
//! the process of getting a feature into the core Solana code.
|
|
|
|
//! - For features that are unambiguously good (ie bug fixes), these steps are sufficient.
|
|
|
|
//! - For features that should go up for community vote (ie fee structure changes), more
|
|
|
|
//! information on the additional steps to follow can be found at:
|
2021-07-23 11:48:37 -07:00
|
|
|
//! <https://spl.solana.com/feature-proposal#feature-proposal-life-cycle>
|
2021-07-18 10:48:09 -07:00
|
|
|
//!
|
|
|
|
//! 1. Generate a new keypair with `solana-keygen new --outfile feature.json --no-passphrase`
|
|
|
|
//! - Keypairs should be held by core contributors only. If you're a non-core contirbutor going
|
|
|
|
//! through these steps, the PR process will facilitate a keypair holder being picked. That
|
|
|
|
//! person will generate the keypair, provide pubkey for PR, and ultimately enable the feature.
|
|
|
|
//! 2. Add a public module for the feature, specifying keypair pubkey as the id with
|
|
|
|
//! `solana_sdk::declare_id!()` within the module.
|
|
|
|
//! Additionally, add an entry to `FEATURE_NAMES` map.
|
|
|
|
//! 3. Add desired logic to check for and switch on feature availability.
|
|
|
|
//!
|
|
|
|
//! For more information on how features are picked up, see comments for `Feature`.
|
|
|
|
|
2020-09-21 22:36:23 -07:00
|
|
|
use lazy_static::lazy_static;
|
2020-09-21 14:03:35 -07:00
|
|
|
use solana_sdk::{
|
2020-10-28 19:34:19 -07:00
|
|
|
clock::Slot,
|
2020-09-21 14:03:35 -07:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2020-11-24 09:22:31 -08:00
|
|
|
pub mod deprecate_rewards_sysvar {
|
|
|
|
solana_sdk::declare_id!("GaBtBJvmS4Arjj5W1NmFcyvPjsHN38UGYDq2MDwbs9Qu");
|
|
|
|
}
|
|
|
|
|
2020-09-25 16:19:03 -07:00
|
|
|
pub mod pico_inflation {
|
2020-11-20 08:54:41 -08:00
|
|
|
solana_sdk::declare_id!("4RWNif6C2WCNiKVW7otP4G7dkmkHGyKQWRpuZ1pxKU5m");
|
2020-09-25 16:19:03 -07:00
|
|
|
}
|
|
|
|
|
2020-11-20 08:54:41 -08:00
|
|
|
pub mod full_inflation {
|
2021-01-20 11:54:13 -08:00
|
|
|
pub mod devnet_and_testnet {
|
|
|
|
solana_sdk::declare_id!("DT4n6ABDqs6w4bnfwrXT9rsprcPf6cdDga1egctaPkLC");
|
|
|
|
}
|
|
|
|
|
2021-02-10 12:31:44 -08:00
|
|
|
pub mod mainnet {
|
|
|
|
pub mod certusone {
|
|
|
|
pub mod vote {
|
|
|
|
solana_sdk::declare_id!("BzBBveUDymEYoYzcMWNQCx3cd4jQs7puaVFHLtsbB6fm");
|
|
|
|
}
|
|
|
|
pub mod enable {
|
|
|
|
solana_sdk::declare_id!("7XRJcS5Ud5vxGB54JbK9N2vBZVwnwdBNeJW1ibRgD9gx");
|
|
|
|
}
|
2021-02-05 08:46:09 -08:00
|
|
|
}
|
|
|
|
}
|
2020-10-08 17:35:48 -07:00
|
|
|
}
|
|
|
|
|
2020-09-24 10:10:27 -07:00
|
|
|
pub mod spl_token_v2_multisig_fix {
|
|
|
|
solana_sdk::declare_id!("E5JiFDQCwyC6QfT9REFyMpfK2mHcmv1GUDySU1Ue7TYv");
|
|
|
|
}
|
|
|
|
|
2020-09-30 19:59:28 -07:00
|
|
|
pub mod no_overflow_rent_distribution {
|
|
|
|
solana_sdk::declare_id!("4kpdyrcj5jS47CZb2oJGfVxjYbsMm2Kx97gFyZrxxwXz");
|
|
|
|
}
|
|
|
|
|
2020-11-06 00:08:11 -08:00
|
|
|
pub mod stake_program_v2 {
|
|
|
|
solana_sdk::declare_id!("Gvd9gGJZDHGMNf1b3jkxrfBQSR5etrfTQSBNKCvLSFJN");
|
|
|
|
}
|
|
|
|
|
2020-11-19 12:15:06 -08:00
|
|
|
pub mod rewrite_stake {
|
|
|
|
solana_sdk::declare_id!("6ap2eGy7wx5JmsWUmQ5sHwEWrFSDUxSti2k5Hbfv5BZG");
|
|
|
|
}
|
|
|
|
|
2020-12-11 11:21:25 -08:00
|
|
|
pub mod filter_stake_delegation_accounts {
|
|
|
|
solana_sdk::declare_id!("GE7fRxmW46K6EmCD9AMZSbnaJ2e3LfqCZzdHi9hmYAgi");
|
|
|
|
}
|
|
|
|
|
2020-12-22 10:20:38 -08:00
|
|
|
pub mod stake_program_v3 {
|
|
|
|
solana_sdk::declare_id!("Ego6nTu7WsBcZBvVqJQKp6Yku2N3mrfG8oYCfaLZkAeK");
|
|
|
|
}
|
|
|
|
|
2021-02-05 22:40:07 -08:00
|
|
|
pub mod require_custodian_for_locked_stake_authorize {
|
|
|
|
solana_sdk::declare_id!("D4jsDcXaqdW8tDAWn8H4R25Cdns2YwLneujSL1zvjW6R");
|
|
|
|
}
|
|
|
|
|
2021-01-28 17:43:52 -08:00
|
|
|
pub mod spl_token_v2_self_transfer_fix {
|
|
|
|
solana_sdk::declare_id!("BL99GYhdjjcv6ys22C9wPgn2aTVERDbPHHo4NbS3hgp7");
|
|
|
|
}
|
|
|
|
|
2021-02-09 14:49:00 -08:00
|
|
|
pub mod warp_timestamp_again {
|
|
|
|
solana_sdk::declare_id!("GvDsGDkH5gyzwpDhxNixx8vtx1kwYHH13RiNAPw27zXb");
|
|
|
|
}
|
|
|
|
|
2021-02-24 09:00:48 -08:00
|
|
|
pub mod check_init_vote_data {
|
|
|
|
solana_sdk::declare_id!("3ccR6QpxGYsAbWyfevEtBNGfWV4xBffxRj2tD6A9i39F");
|
|
|
|
}
|
|
|
|
|
2021-02-26 14:21:34 -08:00
|
|
|
pub mod check_program_owner {
|
|
|
|
solana_sdk::declare_id!("5XnbR5Es9YXEARRuP6mdvoxiW3hx5atNNeBmwVd8P3QD");
|
|
|
|
}
|
|
|
|
|
2021-03-12 07:50:14 -08:00
|
|
|
pub mod require_stake_for_gossip {
|
|
|
|
solana_sdk::declare_id!("6oNzd5Z3M2L1xo4Q5hoox7CR2DuW7m1ETLWH5jHJthwa");
|
|
|
|
}
|
|
|
|
|
2021-04-20 11:07:30 -07:00
|
|
|
pub mod enforce_aligned_host_addrs {
|
|
|
|
solana_sdk::declare_id!("6Qob9Z4RwGdf599FDVCqsjuKjR8ZFR3oVs2ByRLWBsua");
|
|
|
|
}
|
2021-04-27 13:36:42 -07:00
|
|
|
|
2021-05-20 12:47:20 -07:00
|
|
|
pub mod stake_program_v4 {
|
|
|
|
solana_sdk::declare_id!("Dc7djyhP9aLfdq2zktpvskeAjpG56msCU1yexpxXiWZb");
|
|
|
|
}
|
|
|
|
|
2021-06-01 15:33:17 -07:00
|
|
|
pub mod memory_ops_syscalls {
|
|
|
|
solana_sdk::declare_id!("ENQi37wsVhTvFz2gUiZAAbqFEWGN2jwFsqdEDTE8A4MU");
|
|
|
|
}
|
|
|
|
|
2021-07-07 13:15:14 -07:00
|
|
|
pub mod secp256k1_recover_syscall_enabled {
|
|
|
|
solana_sdk::declare_id!("6RvdSWHh8oh72Dp7wMTS2DBkf3fRPtChfNrAo3cZZoXJ");
|
|
|
|
}
|
|
|
|
|
2021-06-03 14:59:04 -07:00
|
|
|
pub mod add_missing_program_error_mappings {
|
|
|
|
solana_sdk::declare_id!("3QEUpjhgPEt92nz3Mqf6pABkHPGCQwSvKtyGMq4SuQyL");
|
|
|
|
}
|
|
|
|
|
2021-06-05 16:45:45 -07:00
|
|
|
pub mod system_transfer_zero_check {
|
|
|
|
solana_sdk::declare_id!("BrTR9hzw4WBGFP65AJMbpAo64DcA3U6jdPSga9fMV5cS");
|
|
|
|
}
|
|
|
|
|
2021-06-08 11:04:10 -07:00
|
|
|
pub mod blake3_syscall_enabled {
|
|
|
|
solana_sdk::declare_id!("HTW2pSyErTj4BV6KBM9NZ9VBUJVxt7sacNWcf76wtzb3");
|
|
|
|
}
|
|
|
|
|
2021-06-03 10:36:39 -07:00
|
|
|
pub mod dedupe_config_program_signers {
|
|
|
|
solana_sdk::declare_id!("8kEuAshXLsgkUEdcFVLqrjCGGHVWFW99ZZpxvAzzMtBp");
|
|
|
|
}
|
|
|
|
|
2021-07-07 08:21:12 -07:00
|
|
|
pub mod deterministic_shred_seed_enabled {
|
|
|
|
solana_sdk::declare_id!("FjSRMpFe7mofQ3WrEMT7Smjk2sME1XdAoRxcv55V6M44");
|
|
|
|
}
|
|
|
|
|
2021-07-01 11:06:59 -07:00
|
|
|
pub mod verify_tx_signatures_len {
|
|
|
|
solana_sdk::declare_id!("EVW9B5xD9FFK7vw1SBARwMA4s5eRo5eKJdKpsBikzKBz");
|
|
|
|
}
|
|
|
|
|
2021-06-30 17:34:50 -07:00
|
|
|
pub mod vote_stake_checked_instructions {
|
|
|
|
solana_sdk::declare_id!("BcWknVcgvonN8sL4HE4XFuEVgfcee5MwxWPAgP6ZV89X");
|
|
|
|
}
|
|
|
|
|
2021-07-07 13:19:17 -07:00
|
|
|
pub mod updated_verify_policy {
|
|
|
|
solana_sdk::declare_id!("k15tVxtkgsmo7dy6iJ56N5hBCxuQAtqRgYwoTDuwbia");
|
|
|
|
}
|
|
|
|
|
2021-07-08 10:43:34 -07:00
|
|
|
pub mod neon_evm_compute_budget {
|
|
|
|
solana_sdk::declare_id!("GLrVvDPkQi5PMYUrsYWT9doZhSHr1BVZXqj5DbFps3rS");
|
|
|
|
}
|
|
|
|
|
2021-05-17 08:30:48 -07:00
|
|
|
pub mod rent_for_sysvars {
|
|
|
|
solana_sdk::declare_id!("BKCPBQQBZqggVnFso5nQ8rQ4RwwogYwjuUt9biBjxwNF");
|
|
|
|
}
|
|
|
|
|
2021-07-13 16:10:30 -07:00
|
|
|
pub mod libsecp256k1_0_5_upgrade_enabled {
|
|
|
|
solana_sdk::declare_id!("DhsYfRjxfnh2g7HKJYSzT79r74Afa1wbHkAgHndrA1oy");
|
|
|
|
}
|
|
|
|
|
2021-07-16 00:31:22 -07:00
|
|
|
pub mod tx_wide_compute_cap {
|
|
|
|
solana_sdk::declare_id!("5ekBxc8itEnPv4NzGJtr8BVVQLNMQuLMNQQj7pHoLNZ9");
|
|
|
|
}
|
|
|
|
|
2021-07-21 05:34:25 -07:00
|
|
|
pub mod spl_token_v2_set_authority_fix {
|
|
|
|
solana_sdk::declare_id!("FToKNBYyiF4ky9s8WsmLBXHCht17Ek7RXaLZGHzzQhJ1");
|
|
|
|
}
|
|
|
|
|
2021-08-04 00:50:28 -07:00
|
|
|
pub mod stop_verify_mul64_imm_nonzero {
|
|
|
|
solana_sdk::declare_id!("EHFwHg2vhwUb7ifm7BuY9RMbsyt1rS1rUii7yeDJtGnN");
|
|
|
|
}
|
|
|
|
|
2021-06-01 16:25:53 -07:00
|
|
|
pub mod merge_nonce_error_into_system_error {
|
|
|
|
solana_sdk::declare_id!("21AWDosvp3pBamFW91KB35pNoaoZVTM7ess8nr2nt53B");
|
|
|
|
}
|
|
|
|
|
2021-08-01 17:31:11 -07:00
|
|
|
pub mod disable_fees_sysvar {
|
|
|
|
solana_sdk::declare_id!("JAN1trEUEtZjgXYzNBYHU9DYd7GnThhXfFP7SzPXkPsG");
|
|
|
|
}
|
|
|
|
|
2021-08-04 07:43:34 -07:00
|
|
|
pub mod stake_merge_with_unmatched_credits_observed {
|
|
|
|
solana_sdk::declare_id!("meRgp4ArRPhD3KtCY9c5yAf2med7mBLsjKTPeVUHqBL");
|
|
|
|
}
|
|
|
|
|
2021-08-12 08:48:47 -07:00
|
|
|
pub mod gate_large_block {
|
|
|
|
solana_sdk::declare_id!("2ry7ygxiYURULZCrypHhveanvP5tzZ4toRwVp89oCNSj");
|
|
|
|
}
|
|
|
|
|
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-11-24 09:22:31 -08:00
|
|
|
(deprecate_rewards_sysvar::id(), "deprecate unused rewards sysvar"),
|
2021-01-20 11:54:13 -08:00
|
|
|
(pico_inflation::id(), "pico inflation"),
|
|
|
|
(full_inflation::devnet_and_testnet::id(), "full inflation on devnet and testnet"),
|
2020-09-24 10:10:27 -07:00
|
|
|
(spl_token_v2_multisig_fix::id(), "spl-token multisig fix"),
|
2020-09-30 19:59:28 -07:00
|
|
|
(no_overflow_rent_distribution::id(), "no overflow rent distribution"),
|
2020-11-06 00:08:11 -08:00
|
|
|
(stake_program_v2::id(), "solana_stake_program v2"),
|
2020-11-19 12:15:06 -08:00
|
|
|
(rewrite_stake::id(), "rewrite stake"),
|
2020-12-11 11:21:25 -08:00
|
|
|
(filter_stake_delegation_accounts::id(), "filter stake_delegation_accounts #14062"),
|
2020-12-22 10:20:38 -08:00
|
|
|
(stake_program_v3::id(), "solana_stake_program v3"),
|
2021-02-05 22:40:07 -08:00
|
|
|
(require_custodian_for_locked_stake_authorize::id(), "require custodian to authorize withdrawer change for locked stake"),
|
2021-01-28 17:43:52 -08:00
|
|
|
(spl_token_v2_self_transfer_fix::id(), "spl-token self-transfer fix"),
|
2021-04-20 11:07:30 -07:00
|
|
|
(full_inflation::mainnet::certusone::enable::id(), "full inflation enabled by Certus One"),
|
|
|
|
(full_inflation::mainnet::certusone::vote::id(), "community vote allowing Certus One to enable full inflation"),
|
2021-02-09 14:49:00 -08:00
|
|
|
(warp_timestamp_again::id(), "warp timestamp again, adjust bounding to 25% fast 80% slow #15204"),
|
2021-02-26 14:21:34 -08:00
|
|
|
(check_init_vote_data::id(), "check initialized Vote data"),
|
2021-03-10 23:04:00 -08:00
|
|
|
(check_program_owner::id(), "limit programs to operating on accounts owned by itself"),
|
2021-03-12 07:50:14 -08:00
|
|
|
(require_stake_for_gossip::id(), "require stakes for propagating crds values through gossip #15561"),
|
2021-04-20 11:07:30 -07:00
|
|
|
(enforce_aligned_host_addrs::id(), "enforce aligned host addresses"),
|
2021-05-20 12:47:20 -07:00
|
|
|
(stake_program_v4::id(), "solana_stake_program v4"),
|
2021-06-01 15:33:17 -07:00
|
|
|
(memory_ops_syscalls::id(), "add syscalls for memory operations"),
|
2021-07-07 13:15:14 -07:00
|
|
|
(secp256k1_recover_syscall_enabled::id(), "secp256k1_recover syscall"),
|
2021-06-03 14:59:04 -07:00
|
|
|
(add_missing_program_error_mappings::id(), "add missing program error mappings"),
|
2021-06-05 16:45:45 -07:00
|
|
|
(system_transfer_zero_check::id(), "perform all checks for transfers of 0 lamports"),
|
2021-06-08 11:04:10 -07:00
|
|
|
(blake3_syscall_enabled::id(), "blake3 syscall"),
|
2021-06-03 10:36:39 -07:00
|
|
|
(dedupe_config_program_signers::id(), "dedupe config program signers"),
|
2021-07-07 08:21:12 -07:00
|
|
|
(deterministic_shred_seed_enabled::id(), "deterministic shred seed"),
|
2021-06-30 17:34:50 -07:00
|
|
|
(vote_stake_checked_instructions::id(), "vote/state program checked instructions #18345"),
|
2021-07-07 13:19:17 -07:00
|
|
|
(updated_verify_policy::id(), "Update verify policy"),
|
2021-07-08 10:43:34 -07:00
|
|
|
(neon_evm_compute_budget::id(), "bump neon_evm's compute budget"),
|
2021-05-17 08:30:48 -07:00
|
|
|
(rent_for_sysvars::id(), "collect rent from accounts owned by sysvars"),
|
2021-07-13 16:10:30 -07:00
|
|
|
(libsecp256k1_0_5_upgrade_enabled::id(), "upgrade libsecp256k1 to v0.5.0"),
|
2021-07-16 00:31:22 -07:00
|
|
|
(tx_wide_compute_cap::id(), "Transaction wide compute cap"),
|
2021-07-21 05:34:25 -07:00
|
|
|
(spl_token_v2_set_authority_fix::id(), "spl-token set_authority fix"),
|
2021-08-04 00:50:28 -07:00
|
|
|
(stop_verify_mul64_imm_nonzero::id(), "Sets rbpf vm config verify_mul64_imm_nonzero to false"),
|
2021-06-01 16:25:53 -07:00
|
|
|
(merge_nonce_error_into_system_error::id(), "merge NonceError into SystemError"),
|
2021-08-01 17:31:11 -07:00
|
|
|
(disable_fees_sysvar::id(), "disable fees sysvar"),
|
2021-08-04 07:43:34 -07:00
|
|
|
(stake_merge_with_unmatched_credits_observed::id(), "allow merging active stakes with unmatched credits_observed #18985"),
|
2021-08-12 08:48:47 -07:00
|
|
|
(gate_large_block::id(), "validator checks block cost against max limit in realtime, reject if exceeds."),
|
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
|
|
|
|
2021-01-20 11:54:13 -08:00
|
|
|
#[derive(Clone, PartialEq, Eq, Hash)]
|
|
|
|
pub struct FullInflationFeaturePair {
|
|
|
|
pub vote_id: Pubkey, // Feature that grants the candidate the ability to enable full inflation
|
|
|
|
pub enable_id: Pubkey, // Feature to enable full inflation by the candidate
|
|
|
|
}
|
|
|
|
|
|
|
|
lazy_static! {
|
|
|
|
/// Set of feature pairs that once enabled will trigger full inflation
|
|
|
|
pub static ref FULL_INFLATION_FEATURE_PAIRS: HashSet<FullInflationFeaturePair> = [
|
|
|
|
FullInflationFeaturePair {
|
2021-02-10 12:31:44 -08:00
|
|
|
vote_id: full_inflation::mainnet::certusone::vote::id(),
|
|
|
|
enable_id: full_inflation::mainnet::certusone::enable::id(),
|
2021-02-05 08:46:09 -08:00
|
|
|
},
|
2021-01-20 11:54:13 -08:00
|
|
|
]
|
|
|
|
.iter()
|
|
|
|
.cloned()
|
|
|
|
.collect();
|
|
|
|
}
|
|
|
|
|
2020-09-24 00:22:49 -07:00
|
|
|
/// `FeatureSet` holds the set of currently active/inactive runtime features
|
2020-10-20 09:05:45 -07:00
|
|
|
#[derive(AbiExample, Debug, Clone)]
|
2020-09-21 14:03:35 -07:00
|
|
|
pub struct FeatureSet {
|
2020-10-28 19:34:19 -07:00
|
|
|
pub active: HashMap<Pubkey, Slot>,
|
2020-09-21 14:03:35 -07:00
|
|
|
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 {
|
2020-10-28 19:34:19 -07:00
|
|
|
active: HashMap::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 {
|
2020-10-28 19:34:19 -07:00
|
|
|
self.active.contains_key(feature_id)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn activated_slot(&self, feature_id: &Pubkey) -> Option<Slot> {
|
|
|
|
self.active.get(feature_id).copied()
|
2020-09-29 20:18:28 -07:00
|
|
|
}
|
2020-10-21 06:19:25 -07:00
|
|
|
|
2021-01-20 11:54:13 -08:00
|
|
|
/// List of enabled features that trigger full inflation
|
|
|
|
pub fn full_inflation_features_enabled(&self) -> HashSet<Pubkey> {
|
|
|
|
let mut hash_set = FULL_INFLATION_FEATURE_PAIRS
|
|
|
|
.iter()
|
|
|
|
.filter_map(|pair| {
|
|
|
|
if self.is_active(&pair.vote_id) && self.is_active(&pair.enable_id) {
|
|
|
|
Some(pair.enable_id)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.collect::<HashSet<_>>();
|
|
|
|
|
|
|
|
if self.is_active(&full_inflation::devnet_and_testnet::id()) {
|
|
|
|
hash_set.insert(full_inflation::devnet_and_testnet::id());
|
|
|
|
}
|
|
|
|
hash_set
|
|
|
|
}
|
|
|
|
|
2020-09-29 20:18:28 -07:00
|
|
|
/// All features enabled, useful for testing
|
|
|
|
pub fn all_enabled() -> Self {
|
|
|
|
Self {
|
2020-10-28 19:34:19 -07:00
|
|
|
active: FEATURE_NAMES.keys().cloned().map(|key| (key, 0)).collect(),
|
2020-09-29 20:18:28 -07:00
|
|
|
inactive: HashSet::new(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-20 11:54:13 -08:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod test {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_full_inflation_features_enabled_devnet_and_testnet() {
|
|
|
|
let mut feature_set = FeatureSet::default();
|
|
|
|
assert!(feature_set.full_inflation_features_enabled().is_empty());
|
|
|
|
feature_set
|
|
|
|
.active
|
|
|
|
.insert(full_inflation::devnet_and_testnet::id(), 42);
|
|
|
|
assert_eq!(
|
|
|
|
feature_set.full_inflation_features_enabled(),
|
|
|
|
[full_inflation::devnet_and_testnet::id()]
|
|
|
|
.iter()
|
|
|
|
.cloned()
|
|
|
|
.collect()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_full_inflation_features_enabled() {
|
|
|
|
// Normal sequence: vote_id then enable_id
|
|
|
|
let mut feature_set = FeatureSet::default();
|
|
|
|
assert!(feature_set.full_inflation_features_enabled().is_empty());
|
|
|
|
feature_set
|
|
|
|
.active
|
2021-02-10 12:31:44 -08:00
|
|
|
.insert(full_inflation::mainnet::certusone::vote::id(), 42);
|
2021-01-20 11:54:13 -08:00
|
|
|
assert!(feature_set.full_inflation_features_enabled().is_empty());
|
|
|
|
feature_set
|
|
|
|
.active
|
2021-02-10 12:31:44 -08:00
|
|
|
.insert(full_inflation::mainnet::certusone::enable::id(), 42);
|
2021-01-20 11:54:13 -08:00
|
|
|
assert_eq!(
|
|
|
|
feature_set.full_inflation_features_enabled(),
|
2021-02-10 12:31:44 -08:00
|
|
|
[full_inflation::mainnet::certusone::enable::id()]
|
2021-01-20 11:54:13 -08:00
|
|
|
.iter()
|
|
|
|
.cloned()
|
|
|
|
.collect()
|
|
|
|
);
|
|
|
|
|
|
|
|
// Backwards sequence: enable_id and then vote_id
|
|
|
|
let mut feature_set = FeatureSet::default();
|
|
|
|
assert!(feature_set.full_inflation_features_enabled().is_empty());
|
|
|
|
feature_set
|
|
|
|
.active
|
2021-02-10 12:31:44 -08:00
|
|
|
.insert(full_inflation::mainnet::certusone::enable::id(), 42);
|
2021-01-20 11:54:13 -08:00
|
|
|
assert!(feature_set.full_inflation_features_enabled().is_empty());
|
|
|
|
feature_set
|
|
|
|
.active
|
2021-02-10 12:31:44 -08:00
|
|
|
.insert(full_inflation::mainnet::certusone::vote::id(), 42);
|
2021-01-20 11:54:13 -08:00
|
|
|
assert_eq!(
|
|
|
|
feature_set.full_inflation_features_enabled(),
|
2021-02-10 12:31:44 -08:00
|
|
|
[full_inflation::mainnet::certusone::enable::id()]
|
2021-01-20 11:54:13 -08:00
|
|
|
.iter()
|
|
|
|
.cloned()
|
|
|
|
.collect()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|