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`
2022-07-27 09:06:29 -07:00
//! - Keypairs should be held by core contributors only. If you're a non-core contributor going
2021-07-18 10:48:09 -07:00
//! 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`.
2021-12-03 09:00:31 -08:00
use {
lazy_static ::lazy_static ,
solana_sdk ::{
clock ::Slot ,
hash ::{ Hash , Hasher } ,
pubkey ::Pubkey ,
} ,
std ::collections ::{ HashMap , HashSet } ,
2020-09-21 14:03:35 -07:00
} ;
2020-09-21 22:36:23 -07:00
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
}
2022-02-22 04:54:08 -08:00
pub mod secp256k1_program_enabled {
solana_sdk ::declare_id! ( " E3PHP7w8kB7np3CTQ1qQ2tW3KCtjRSXBQgW9vM2mWv2Y " ) ;
}
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-12-11 11:21:25 -08:00
pub mod filter_stake_delegation_accounts {
solana_sdk ::declare_id! ( " GE7fRxmW46K6EmCD9AMZSbnaJ2e3LfqCZzdHi9hmYAgi " ) ;
}
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-07-07 13:15:14 -07:00
pub mod secp256k1_recover_syscall_enabled {
solana_sdk ::declare_id! ( " 6RvdSWHh8oh72Dp7wMTS2DBkf3fRPtChfNrAo3cZZoXJ " ) ;
}
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-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-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-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 " ) ;
}
2022-01-04 22:55:26 -08:00
pub mod zk_token_sdk_enabled {
solana_sdk ::declare_id! ( " zk1snxsc6Fh3wsGNbbHAJNHiJoYgF29mMnTSusGx5EJ " ) ;
}
2022-05-07 00:20:53 -07:00
pub mod curve25519_syscall_enabled {
2022-05-07 19:28:07 -07:00
solana_sdk ::declare_id! ( " 7rcw5UtqgDTBBv2EcynNfYckgdAaH1MAsCjKgXMkN7Ri " ) ;
2022-05-07 00:20:53 -07:00
}
2021-08-17 15:17:56 -07:00
pub mod versioned_tx_message_enabled {
solana_sdk ::declare_id! ( " 3KZZ6Ks1885aGBQ45fwRcPXVBCtzUvxhUTkwKMR41Tca " ) ;
}
2021-08-19 13:13:54 -07:00
pub mod libsecp256k1_fail_on_bad_count {
solana_sdk ::declare_id! ( " 8aXvSuopd1PUj7UhehfXJRg6619RHp8ZvwTyyJHdUYsj " ) ;
}
2022-07-05 13:36:37 -07:00
pub mod libsecp256k1_fail_on_bad_count2 {
solana_sdk ::declare_id! ( " 54KAoNiUERNoWWUhTWWwXgym94gzoXFVnHyQwPA18V9A " ) ;
}
2021-08-25 13:57:27 -07:00
pub mod instructions_sysvar_owned_by_sysvar {
solana_sdk ::declare_id! ( " H3kBSaKdeiUsyHmeHqjJYNc27jesXZ6zWj3zWkowQbkV " ) ;
}
2021-09-03 14:20:56 -07:00
pub mod stake_program_advance_activating_credits_observed {
solana_sdk ::declare_id! ( " SAdVFw3RZvzbo6DvySbSdBnHN4gkzSTH9dSxesyKKPj " ) ;
}
2022-04-26 14:49:35 -07:00
pub mod credits_auto_rewind {
solana_sdk ::declare_id! ( " BUS12ciZ5gCoFafUHWW8qaFMMtwFQGVxjsDheWLdqBE2 " ) ;
}
2021-09-03 20:05:30 -07:00
pub mod demote_program_write_locks {
solana_sdk ::declare_id! ( " 3E3jV7v9VcdJL8iYZUMax9DiDno8j7EWUVbhm9RtShj2 " ) ;
}
2021-09-03 14:35:38 -07:00
pub mod ed25519_program_enabled {
2021-12-07 10:58:59 -08:00
solana_sdk ::declare_id! ( " 6ppMXNYLhVd7GcsZ5uV11wQEW7spppiMVfqQv5SXhDpX " ) ;
2021-09-03 14:35:38 -07:00
}
2021-09-01 02:14:01 -07:00
pub mod return_data_syscall_enabled {
2021-12-07 10:58:59 -08:00
solana_sdk ::declare_id! ( " DwScAzPUjuv65TMbDnFY7AgwmotzWy3xpEJMXM3hZFaB " ) ;
2021-09-01 02:14:01 -07:00
}
2021-09-19 12:50:41 -07:00
pub mod reduce_required_deploy_balance {
solana_sdk ::declare_id! ( " EBeznQDjcPG8491sFsKZYBi5S5jTVXMpAKNDJMQPS2kq " ) ;
}
2021-09-17 01:14:49 -07:00
pub mod sol_log_data_syscall_enabled {
2021-12-07 10:58:59 -08:00
solana_sdk ::declare_id! ( " 6uaHcKPGUy4J7emLBgUTeufhJdiwhngW6a1R9B7c2ob9 " ) ;
2021-09-17 01:14:49 -07:00
}
2021-09-16 23:41:53 -07:00
pub mod stakes_remove_delegation_if_inactive {
solana_sdk ::declare_id! ( " HFpdDDNQjvcXnXKec697HDDsyk6tFoWS2o8fkxuhQZpL " ) ;
}
2021-09-28 01:13:03 -07:00
pub mod do_support_realloc {
solana_sdk ::declare_id! ( " 75m6ysz33AfLA5DDEzWM1obBrnPQRSsdVQ2nRmc8Vuu1 " ) ;
}
2021-09-28 23:25:08 -07:00
// Note: when this feature is cleaned up, also remove the secp256k1 program from
// the list of builtins and remove its files from /programs
pub mod prevent_calling_precompiles_as_programs {
solana_sdk ::declare_id! ( " 4ApgRX3ud6p7LNMJmsuaAcZY5HWctGPr5obAsjB3A54d " ) ;
}
2021-10-05 21:53:26 -07:00
pub mod optimize_epoch_boundary_updates {
solana_sdk ::declare_id! ( " 265hPS8k8xJ37ot82KEgjRunsUp5w4n4Q4VwwiN9i9ps " ) ;
}
2022-04-19 08:10:35 -07:00
pub mod remove_native_loader {
solana_sdk ::declare_id! ( " HTTgmruMYRZEntyL3EdCDdnS6e4D5wRq1FA7kQsb66qq " ) ;
}
2021-10-07 02:38:23 -07:00
pub mod send_to_tpu_vote_port {
solana_sdk ::declare_id! ( " C5fh68nJ7uyKAuYZg2x9sEQ5YrVf3dkW6oojNBSc3Jvo " ) ;
}
2021-10-19 21:01:39 -07:00
pub mod requestable_heap_size {
solana_sdk ::declare_id! ( " CCu4boMmfLuqcmfTLPHQiUo22ZdUsXjgzPAURYaWt1Bw " ) ;
}
2021-10-22 14:32:40 -07:00
pub mod disable_fee_calculator {
solana_sdk ::declare_id! ( " 2jXx2yDmGysmBKfKYNgLj2DQyAQv6mMk2BPh4eSbyB4H " ) ;
}
2021-10-26 20:08:59 -07:00
pub mod add_compute_budget_program {
solana_sdk ::declare_id! ( " 4d5AKtxoh93Dwm1vHXUU3iRATuMndx1c431KgT2td52r " ) ;
}
2021-11-16 15:01:00 -08:00
pub mod nonce_must_be_writable {
solana_sdk ::declare_id! ( " BiCU7M5w8ZCMykVSyhZ7Q3m2SWoR2qrEQ86ERcDX77ME " ) ;
}
2021-11-21 05:27:03 -08:00
pub mod spl_token_v3_3_0_release {
solana_sdk ::declare_id! ( " Ftok2jhqAqxUWEiCVRrfRs9DPppWP8cgTB7NQNKL88mS " ) ;
}
2021-12-02 09:57:05 -08:00
pub mod leave_nonce_on_success {
solana_sdk ::declare_id! ( " E8MkiWZNNPGU6n55jkGzyj8ghUmjCHRmDFdYYFYHxWhQ " ) ;
}
2021-12-03 06:47:18 -08:00
pub mod reject_empty_instruction_without_program {
solana_sdk ::declare_id! ( " 9kdtFSrXHQg3hKkbXkQ6trJ3Ja1xpJ22CTFSNAciEwmL " ) ;
}
2021-12-06 09:26:46 -08:00
pub mod fixed_memcpy_nonoverlapping_check {
solana_sdk ::declare_id! ( " 36PRUK2Dz6HWYdG9SpjeAsF5F3KxnFCakA2BZMbtMhSb " ) ;
}
2021-12-06 14:01:20 -08:00
pub mod reject_non_rent_exempt_vote_withdraws {
solana_sdk ::declare_id! ( " 7txXZZD6Um59YoLMF7XUNimbMjsqsWhc7g2EniiTrmp1 " ) ;
}
2021-12-09 11:12:11 -08:00
pub mod evict_invalid_stakes_cache_entries {
solana_sdk ::declare_id! ( " EMX9Q7TVFAmQ9V1CggAkhMzhXSg8ECp7fHrWQX2G1chf " ) ;
}
2021-12-13 07:52:22 -08:00
pub mod allow_votes_to_directly_update_vote_state {
solana_sdk ::declare_id! ( " Ff8b1fBeB86q8cjq47ZhsQLgv5EkHu3G1C99zjUfAzrq " ) ;
}
2021-12-28 03:14:48 -08:00
pub mod cap_accounts_data_len {
solana_sdk ::declare_id! ( " capRxUrBjNkkCpjrJxPGfPaWijB7q3JoDfsWXAnt46r " ) ;
}
2022-01-03 22:25:23 -08:00
pub mod max_tx_account_locks {
solana_sdk ::declare_id! ( " CBkDroRDqm8HwHe6ak9cguPjUomrASEkfmxEaZ5CNNxz " ) ;
}
2022-01-11 10:32:25 -08:00
pub mod require_rent_exempt_accounts {
solana_sdk ::declare_id! ( " BkFDxiJQWZXGTZaJQxH7wVEHkAmwCgSEVkrvswFfRJPD " ) ;
}
2022-01-13 16:51:00 -08:00
pub mod filter_votes_outside_slot_hashes {
solana_sdk ::declare_id! ( " 3gtZPqvPpsbXZVCx6hceMfWxtsmrjMzmg8C7PLKSxS2d " ) ;
}
2021-12-15 14:19:47 -08:00
pub mod update_syscall_base_costs {
solana_sdk ::declare_id! ( " 2h63t332mGCCsWK2nqqqHhN4U9ayyqhLVFvczznHDoTZ " ) ;
}
2022-03-25 09:11:51 -07:00
pub mod stake_deactivate_delinquent_instruction {
solana_sdk ::declare_id! ( " 437r62HoAdUb63amq3D7ENnBLDhHT2xY8eFkLJYVKK4x " ) ;
}
2022-06-28 10:39:00 -07:00
pub mod stake_redelegate_instruction {
solana_sdk ::declare_id! ( " 3EPmAX94PvVJCjMeFfRFvj4avqCPL8vv3TGsZQg7ydMx " ) ;
}
2022-01-14 17:38:01 -08:00
pub mod vote_withdraw_authority_may_change_authorized_voter {
solana_sdk ::declare_id! ( " AVZS3ZsN4gi6Rkx2QUibYuSJG3S6QHib7xCYhG6vGJxU " ) ;
}
2022-01-24 13:54:41 -08:00
pub mod spl_associated_token_account_v1_0_4 {
solana_sdk ::declare_id! ( " FaTa4SpiaSNH44PGC4z8bnGVTkSRYaWvrBs3KTu8XQQq " ) ;
}
2022-02-02 12:16:24 -08:00
pub mod reject_vote_account_close_unless_zero_credit_epoch {
solana_sdk ::declare_id! ( " ALBk3EWdeAg2WAGf6GPDUf1nynyNqCdEVmgouG7rpuCj " ) ;
}
2022-02-02 16:45:57 -08:00
pub mod add_get_processed_sibling_instruction_syscall {
solana_sdk ::declare_id! ( " CFK1hRCNy8JJuAAY8Pb2GjLFNdCThS2qwZNe3izzBMgn " ) ;
}
2022-02-03 00:56:36 -08:00
pub mod bank_tranaction_count_fix {
solana_sdk ::declare_id! ( " Vo5siZ442SaZBKPXNocthiXysNviW4UYPwRFggmbgAp " ) ;
}
2022-02-04 12:17:49 -08:00
pub mod disable_bpf_deprecated_load_instructions {
solana_sdk ::declare_id! ( " 3XgNukcZWf9o3HdA3fpJbm94XFc4qpvTXc8h1wxYwiPi " ) ;
}
pub mod disable_bpf_unresolved_symbols_at_runtime {
solana_sdk ::declare_id! ( " 4yuaYAj2jGMGTh1sSmi4G2eFscsDq8qjugJXZoBN6YEa " ) ;
}
2022-02-09 11:04:49 -08:00
pub mod record_instruction_in_transaction_context_push {
solana_sdk ::declare_id! ( " 3aJdcZqxoLpSBxgeYGjPwaYS1zzcByxUDqJkbzWAH1Zb " ) ;
}
2022-03-08 11:48:22 -08:00
pub mod syscall_saturated_math {
solana_sdk ::declare_id! ( " HyrbKftCdJ5CrUfEti6x26Cj7rZLNe32weugk7tLcWb8 " ) ;
}
2022-03-10 11:48:09 -08:00
pub mod check_physical_overlapping {
solana_sdk ::declare_id! ( " nWBqjr3gpETbiaVj3CBJ3HFC5TMdnJDGt21hnvSTvVZ " ) ;
}
2022-03-14 09:34:43 -07:00
pub mod limit_secp256k1_recovery_id {
solana_sdk ::declare_id! ( " 7g9EUwj4j7CS21Yx1wvgWLjSZeh5aPq8x9kpoPwXM8n8 " ) ;
}
2022-03-18 14:29:49 -07:00
pub mod disable_deprecated_loader {
solana_sdk ::declare_id! ( " GTUMCZ8LTNxVfxdrw7ZsDFTxXb7TutYkzJnFwinpE6dg " ) ;
}
2022-03-22 15:20:39 -07:00
pub mod check_slice_translation_size {
solana_sdk ::declare_id! ( " GmC19j9qLn2RFk5NduX6QXaDhVpGncVVBzyM8e9WMz2F " ) ;
}
2022-03-31 01:46:35 -07:00
pub mod stake_split_uses_rent_sysvar {
solana_sdk ::declare_id! ( " FQnc7U4koHqWgRvFaBJjZnV8VPg6L6wWK33yJeDp4yvV " ) ;
}
2022-04-01 22:11:10 -07:00
pub mod add_get_minimum_delegation_instruction_to_stake_program {
solana_sdk ::declare_id! ( " St8k9dVXP97xT6faW24YmRSYConLbhsMJA4TJTBLmMT " ) ;
}
2022-04-12 17:52:32 -07:00
pub mod error_on_syscall_bpf_function_hash_collisions {
solana_sdk ::declare_id! ( " 8199Q2gMD2kwgfopK5qqVWuDbegLgpuFUFHCcUJQDN8b " ) ;
}
2022-04-13 11:09:33 -07:00
pub mod reject_callx_r10 {
solana_sdk ::declare_id! ( " 3NKRSwpySNwD3TvP5pHnRmkAQRsdkXWRr1WaQh8p4PWX " ) ;
}
2022-04-18 17:11:29 -07:00
pub mod drop_redundant_turbine_path {
solana_sdk ::declare_id! ( " 4Di3y24QFLt5QEUPZtbnjyfQKfm6ZMTfa6Dw1psfoMKU " ) ;
}
2022-04-19 19:31:11 -07:00
pub mod executables_incur_cpi_data_cost {
solana_sdk ::declare_id! ( " 7GUcYgq4tVtaqNCKT3dho9r4665Qp5TxCZ27Qgjx3829 " ) ;
}
2022-04-21 06:05:29 -07:00
pub mod fix_recent_blockhashes {
solana_sdk ::declare_id! ( " 6iyggb5MTcsvdcugX7bEKbHV8c6jdLbpHwkncrgLMhfo " ) ;
}
2022-04-08 06:45:55 -07:00
pub mod update_rewards_from_cached_accounts {
solana_sdk ::declare_id! ( " 28s7i3htzhahXQKqmS2ExzbEoUypg9krwvtK2M9UWXh9 " ) ;
}
2022-04-28 14:43:57 -07:00
pub mod spl_token_v3_4_0 {
solana_sdk ::declare_id! ( " Ftok4njE8b7tDffYkC5bAbCaQv5sL6jispYrprzatUwN " ) ;
}
pub mod spl_associated_token_account_v1_1_0 {
solana_sdk ::declare_id! ( " FaTa17gVKoqbh38HcfiQonPsAaQViyDCCSg71AubYZw8 " ) ;
}
2022-05-03 09:50:06 -07:00
pub mod default_units_per_instruction {
solana_sdk ::declare_id! ( " J2QdYx8crLbTVK8nur1jeLsmc3krDbfjoxoea2V1Uy5Q " ) ;
}
2022-05-04 03:17:29 -07:00
pub mod stake_allow_zero_undelegated_amount {
solana_sdk ::declare_id! ( " sTKz343FM8mqtyGvYWvbLpTThw3ixRM4Xk8QvZ985mw " ) ;
}
2022-05-06 12:19:50 -07:00
pub mod require_static_program_ids_in_transaction {
solana_sdk ::declare_id! ( " 8FdwgyHFEjhAdjWfV2vfqk7wA1g9X3fQpKH7SBpEv3kC " ) ;
}
2022-05-07 16:01:05 -07:00
pub mod stake_raise_minimum_delegation_to_1_sol {
// This is a feature-proposal *feature id*. The feature keypair address is `3YHAo6wWw5rDbQxb59BmJkQ3XwVhX3m8tdBVbtxnJmma`.
solana_sdk ::declare_id! ( " 4xmyBuR2VCXzy9H6qYpH9ckfgnTuMDQFPFBfTs4eBCY1 " ) ;
}
2022-05-15 21:06:33 -07:00
pub mod add_set_compute_unit_price_ix {
2022-05-12 11:07:36 -07:00
solana_sdk ::declare_id! ( " 98std1NSHqXi9WYvFShfVepRdCoq1qvsp8fsR2XZtG8g " ) ;
}
2022-05-15 21:06:33 -07:00
pub mod disable_deploy_of_alloc_free_syscall {
solana_sdk ::declare_id! ( " 79HWsX9rpnnJBPcdNURVqygpMAfxdrAirzAGAVmf92im " ) ;
}
2022-05-16 08:35:34 -07:00
pub mod include_account_index_in_rent_error {
solana_sdk ::declare_id! ( " 2R72wpcQ7qV7aTJWUumdn8u5wmmTyXbK7qzEy7YSAgyY " ) ;
}
2022-06-23 06:23:11 -07:00
pub mod add_shred_type_to_shred_seed {
solana_sdk ::declare_id! ( " Ds87KVeqhbv7Jw8W6avsS1mqz3Mw5J3pRTpPoDQ2QdiJ " ) ;
}
2022-05-31 15:53:06 -07:00
pub mod warp_timestamp_with_a_vengeance {
solana_sdk ::declare_id! ( " 3BX6SBeEBibHaVQXywdkcgyUk6evfYZkHdztXiDtEpFS " ) ;
}
2022-06-03 07:36:27 -07:00
pub mod separate_nonce_from_blockhash {
solana_sdk ::declare_id! ( " Gea3ZkK2N4pHuVZVxWcnAtS6UEDdyumdYt4pFcKjA3ar " ) ;
}
2022-06-03 10:05:55 -07:00
pub mod enable_durable_nonce {
solana_sdk ::declare_id! ( " 4EJQtF2pkRyawwcTVfQutzq4Sa5hRhibF6QAK1QXhtEX " ) ;
}
2022-06-06 16:37:03 -07:00
pub mod vote_state_update_credit_per_dequeue {
solana_sdk ::declare_id! ( " CveezY6FDLVBToHDcvJRmtMouqzsmj4UXYh5ths5G5Uv " ) ;
}
2022-06-07 06:45:45 -07:00
pub mod quick_bail_on_panic {
solana_sdk ::declare_id! ( " DpJREPyuMZ5nDfU6H3WTqSqUFSXAfw8u7xqmWtEwJDcP " ) ;
}
2022-06-08 12:43:09 -07:00
pub mod nonce_must_be_authorized {
solana_sdk ::declare_id! ( " HxrEu1gXuH7iD3Puua1ohd5n4iUKJyFNtNxk9DVJkvgr " ) ;
}
2022-06-08 14:34:57 -07:00
pub mod nonce_must_be_advanceable {
solana_sdk ::declare_id! ( " 3u3Er5Vc2jVcwz4xr2GJeSAXT3fAj6ADHZ4BJMZiScFd " ) ;
}
2022-06-13 20:36:44 -07:00
pub mod vote_authorize_with_seed {
solana_sdk ::declare_id! ( " 6tRxEYKuy2L5nnv5bgn7iT28MxUbYxp5h7F3Ncf1exrT " ) ;
}
2022-06-15 18:35:33 -07:00
pub mod cap_accounts_data_size_per_block {
solana_sdk ::declare_id! ( " qywiJyZmqTKspFg2LeuUHqcA5nNvBgobqb9UprywS9N " ) ;
}
2022-07-08 13:04:08 -07:00
pub mod preserve_rent_epoch_for_rent_exempt_accounts {
solana_sdk ::declare_id! ( " HH3MUYReL2BvqqA3oEcAa7txju5GY6G4nxJ51zvsEjEZ " ) ;
}
2022-07-11 14:46:32 -07:00
pub mod enable_bpf_loader_extend_program_data_ix {
solana_sdk ::declare_id! ( " 8Zs9W7D9MpSEtUWSQdGniZk2cNmV22y6FLJwCx53asme " ) ;
}
2022-07-15 00:31:34 -07:00
pub mod enable_early_verification_of_account_modifications {
solana_sdk ::declare_id! ( " 7Vced912WrRnfjaiKRiNBcbuFw7RrnLv3E3z95Y4GTNc " ) ;
}
2022-07-15 06:23:37 -07:00
pub mod prevent_crediting_accounts_that_end_rent_paying {
solana_sdk ::declare_id! ( " 812kqX67odAp5NFwM8D2N24cku7WTm9CHUTFUXaDkWPn " ) ;
}
2022-07-20 05:12:43 -07:00
pub mod cap_bpf_program_instruction_accounts {
solana_sdk ::declare_id! ( " 9k5ijzTbYPtjzu8wj2ErH9v45xecHzQ1x4PMYMMxFgdM " ) ;
}
2022-07-24 11:20:16 -07:00
pub mod loosen_cpi_size_restriction {
solana_sdk ::declare_id! ( " GDH5TVdbTPUpRnXaRyQqiKUa7uZAbZ28Q2N9bhbKoMLm " ) ;
}
2022-07-26 12:39:24 -07:00
pub mod use_default_units_in_fee_calculation {
solana_sdk ::declare_id! ( " 8sKQrMQoUHtQSUP83SPG4ta2JDjSAiWs7t5aJ9uEd6To " ) ;
}
2022-07-27 12:23:44 -07:00
pub mod compact_vote_state_updates {
solana_sdk ::declare_id! ( " 86HpNqzutEZwLcPxS6EHDcMNYWk6ikhteg9un7Y2PBKE " ) ;
}
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 > = [
2022-02-22 04:54:08 -08:00
( secp256k1_program_enabled ::id ( ) , " secp256k1 program " ) ,
2021-09-07 14:44:52 -07: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-12-11 11:21:25 -08:00
( filter_stake_delegation_accounts ::id ( ) , " filter stake_delegation_accounts #14062 " ) ,
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-07-07 13:15:14 -07:00
( secp256k1_recover_syscall_enabled ::id ( ) , " secp256k1_recover syscall " ) ,
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-08-25 13:57:27 -07:00
( verify_tx_signatures_len ::id ( ) , " prohibit extra transaction signatures " ) ,
2021-06-30 17:34:50 -07:00
( vote_stake_checked_instructions ::id ( ) , " vote/state program checked instructions #18345 " ) ,
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-08-19 09:46:06 -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-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. " ) ,
2022-01-04 22:55:26 -08:00
( zk_token_sdk_enabled ::id ( ) , " enable Zk Token proof program and syscalls " ) ,
2022-06-11 18:18:51 -07:00
( curve25519_syscall_enabled ::id ( ) , " enable curve25519 syscalls " ) ,
2021-08-17 15:17:56 -07:00
( versioned_tx_message_enabled ::id ( ) , " enable versioned transaction message processing " ) ,
2021-09-03 14:35:38 -07:00
( libsecp256k1_fail_on_bad_count ::id ( ) , " fail libsec256k1_verify if count appears wrong " ) ,
2022-07-05 13:36:37 -07:00
( libsecp256k1_fail_on_bad_count2 ::id ( ) , " fail libsec256k1_verify if count appears wrong " ) ,
2021-08-25 13:57:27 -07:00
( instructions_sysvar_owned_by_sysvar ::id ( ) , " fix owner for instructions sysvar " ) ,
2021-09-03 14:20:56 -07:00
( stake_program_advance_activating_credits_observed ::id ( ) , " Enable advancing credits observed for activation epoch #19309 " ) ,
2022-04-26 14:49:35 -07:00
( credits_auto_rewind ::id ( ) , " Auto rewind stake's credits_observed if (accidental) vote recreation is detected #22546 " ) ,
2021-09-28 08:59:08 -07:00
( demote_program_write_locks ::id ( ) , " demote program write locks to readonly, except when upgradeable loader present #19593 #20265 " ) ,
2021-09-03 14:35:38 -07:00
( ed25519_program_enabled ::id ( ) , " enable builtin ed25519 signature verify program " ) ,
2021-09-13 22:57:37 -07:00
( return_data_syscall_enabled ::id ( ) , " enable sol_{set,get}_return_data syscall " ) ,
2021-09-19 12:50:41 -07:00
( reduce_required_deploy_balance ::id ( ) , " reduce required payer balance for program deploys " ) ,
2021-09-17 01:14:49 -07:00
( sol_log_data_syscall_enabled ::id ( ) , " enable sol_log_data syscall " ) ,
2021-09-16 23:41:53 -07:00
( stakes_remove_delegation_if_inactive ::id ( ) , " remove delegations from stakes cache when inactive " ) ,
2021-09-28 01:13:03 -07:00
( do_support_realloc ::id ( ) , " support account data reallocation " ) ,
2021-10-22 14:32:40 -07:00
( prevent_calling_precompiles_as_programs ::id ( ) , " prevent calling precompiles as programs " ) ,
( optimize_epoch_boundary_updates ::id ( ) , " optimize epoch boundary updates " ) ,
2022-04-19 08:10:35 -07:00
( remove_native_loader ::id ( ) , " remove support for the native loader " ) ,
2021-10-22 14:32:40 -07:00
( send_to_tpu_vote_port ::id ( ) , " send votes to the tpu vote port " ) ,
2021-10-19 21:01:39 -07:00
( requestable_heap_size ::id ( ) , " Requestable heap frame size " ) ,
2021-10-22 14:32:40 -07:00
( disable_fee_calculator ::id ( ) , " deprecate fee calculator " ) ,
2021-10-26 20:08:59 -07:00
( add_compute_budget_program ::id ( ) , " Add compute_budget_program " ) ,
2021-11-16 15:01:00 -08:00
( nonce_must_be_writable ::id ( ) , " nonce must be writable " ) ,
2021-11-21 05:27:03 -08:00
( spl_token_v3_3_0_release ::id ( ) , " spl-token v3.3.0 release " ) ,
2021-12-02 09:57:05 -08:00
( leave_nonce_on_success ::id ( ) , " leave nonce as is on success " ) ,
2021-12-03 06:47:18 -08:00
( reject_empty_instruction_without_program ::id ( ) , " fail instructions which have native_loader as program_id directly " ) ,
2021-12-06 09:26:46 -08:00
( fixed_memcpy_nonoverlapping_check ::id ( ) , " use correct check for nonoverlapping regions in memcpy syscall " ) ,
2021-12-06 14:01:20 -08:00
( reject_non_rent_exempt_vote_withdraws ::id ( ) , " fail vote withdraw instructions which leave the account non-rent-exempt " ) ,
2021-12-09 11:12:11 -08:00
( evict_invalid_stakes_cache_entries ::id ( ) , " evict invalid stakes cache entries on epoch boundaries " ) ,
2021-12-13 07:52:22 -08:00
( allow_votes_to_directly_update_vote_state ::id ( ) , " enable direct vote state update " ) ,
2021-12-28 03:14:48 -08:00
( cap_accounts_data_len ::id ( ) , " cap the accounts data len " ) ,
2022-01-03 22:25:23 -08:00
( max_tx_account_locks ::id ( ) , " enforce max number of locked accounts per transaction " ) ,
2022-01-11 10:32:25 -08:00
( require_rent_exempt_accounts ::id ( ) , " require all new transaction accounts with data to be rent-exempt " ) ,
2022-01-13 16:51:00 -08:00
( filter_votes_outside_slot_hashes ::id ( ) , " filter vote slots older than the slot hashes history " ) ,
2022-03-10 11:48:09 -08:00
( update_syscall_base_costs ::id ( ) , " update syscall base costs " ) ,
2022-03-25 09:11:51 -07:00
( stake_deactivate_delinquent_instruction ::id ( ) , " enable the deactivate delinquent stake instruction #23932 " ) ,
2022-01-14 17:38:01 -08:00
( vote_withdraw_authority_may_change_authorized_voter ::id ( ) , " vote account withdraw authority may change the authorized voter #22521 " ) ,
2022-01-24 13:54:41 -08:00
( spl_associated_token_account_v1_0_4 ::id ( ) , " SPL Associated Token Account Program release version 1.0.4, tied to token 3.3.0 #22648 " ) ,
2022-02-02 12:16:24 -08:00
( reject_vote_account_close_unless_zero_credit_epoch ::id ( ) , " fail vote account withdraw to 0 unless account earned 0 credits in last completed epoch " ) ,
2022-02-02 16:45:57 -08:00
( add_get_processed_sibling_instruction_syscall ::id ( ) , " add add_get_processed_sibling_instruction_syscall " ) ,
2022-03-08 11:48:22 -08:00
( bank_tranaction_count_fix ::id ( ) , " fixes Bank::transaction_count to include all committed transactions, not just successful ones " ) ,
( disable_bpf_deprecated_load_instructions ::id ( ) , " disable ldabs* and ldind* BPF instructions " ) ,
( disable_bpf_unresolved_symbols_at_runtime ::id ( ) , " disable reporting of unresolved BPF symbols at runtime " ) ,
( record_instruction_in_transaction_context_push ::id ( ) , " move the CPI stack overflow check to the end of push " ) ,
2022-03-10 11:48:09 -08:00
( syscall_saturated_math ::id ( ) , " syscalls use saturated math " ) ,
( check_physical_overlapping ::id ( ) , " check physical overlapping regions " ) ,
2022-03-14 09:34:43 -07:00
( limit_secp256k1_recovery_id ::id ( ) , " limit secp256k1 recovery id " ) ,
2022-03-18 14:29:49 -07:00
( disable_deprecated_loader ::id ( ) , " disable the deprecated BPF loader " ) ,
2022-03-31 01:46:35 -07:00
( check_slice_translation_size ::id ( ) , " check size when translating slices " ) ,
( stake_split_uses_rent_sysvar ::id ( ) , " stake split instruction uses rent sysvar " ) ,
2022-04-01 22:11:10 -07:00
( add_get_minimum_delegation_instruction_to_stake_program ::id ( ) , " add GetMinimumDelegation instruction to stake program " ) ,
2022-04-12 17:52:32 -07:00
( error_on_syscall_bpf_function_hash_collisions ::id ( ) , " error on bpf function hash collisions " ) ,
2022-04-13 11:09:33 -07:00
( reject_callx_r10 ::id ( ) , " Reject bpf callx r10 instructions " ) ,
2022-04-18 17:11:29 -07:00
( drop_redundant_turbine_path ::id ( ) , " drop redundant turbine path " ) ,
2022-06-30 10:32:10 -07:00
( executables_incur_cpi_data_cost ::id ( ) , " Executables incur CPI data costs " ) ,
2022-04-21 06:05:29 -07:00
( fix_recent_blockhashes ::id ( ) , " stop adding hashes for skipped slots to recent blockhashes " ) ,
2022-04-08 06:45:55 -07:00
( update_rewards_from_cached_accounts ::id ( ) , " update rewards from cached accounts " ) ,
2022-04-28 14:43:57 -07:00
( spl_token_v3_4_0 ::id ( ) , " SPL Token Program version 3.4.0 release #24740 " ) ,
( spl_associated_token_account_v1_1_0 ::id ( ) , " SPL Associated Token Account Program version 1.1.0 release #24741 " ) ,
2022-05-03 09:50:06 -07:00
( default_units_per_instruction ::id ( ) , " Default max tx-wide compute units calculated per instruction " ) ,
2022-05-06 12:19:50 -07:00
( stake_allow_zero_undelegated_amount ::id ( ) , " Allow zero-lamport undelegated amount for initialized stakes #24670 " ) ,
( require_static_program_ids_in_transaction ::id ( ) , " require static program ids in versioned transactions " ) ,
2022-05-07 16:01:05 -07:00
( stake_raise_minimum_delegation_to_1_sol ::id ( ) , " Raise minimum stake delegation to 1.0 SOL #24357 " ) ,
2022-05-15 21:06:33 -07:00
( add_set_compute_unit_price_ix ::id ( ) , " add compute budget ix for setting a compute unit price " ) ,
( disable_deploy_of_alloc_free_syscall ::id ( ) , " disable new deployments of deprecated sol_alloc_free_ syscall " ) ,
2022-05-16 08:35:34 -07:00
( include_account_index_in_rent_error ::id ( ) , " include account index in rent tx error #25190 " ) ,
2022-06-23 06:23:11 -07:00
( add_shred_type_to_shred_seed ::id ( ) , " add shred-type to shred seed #25556 " ) ,
2022-05-31 15:53:06 -07:00
( warp_timestamp_with_a_vengeance ::id ( ) , " warp timestamp again, adjust bounding to 150% slow #25666 " ) ,
2022-06-03 07:36:27 -07:00
( separate_nonce_from_blockhash ::id ( ) , " separate durable nonce and blockhash domains #25744 " ) ,
2022-06-03 10:05:55 -07:00
( enable_durable_nonce ::id ( ) , " enable durable nonce #25744 " ) ,
2022-06-06 16:37:03 -07:00
( vote_state_update_credit_per_dequeue ::id ( ) , " Calculate vote credits for VoteStateUpdate per vote dequeue to match credit awards for Vote instruction " ) ,
2022-06-07 06:45:45 -07:00
( quick_bail_on_panic ::id ( ) , " quick bail on panic " ) ,
2022-06-08 12:43:09 -07:00
( nonce_must_be_authorized ::id ( ) , " nonce must be authorized " ) ,
2022-06-08 14:34:57 -07:00
( nonce_must_be_advanceable ::id ( ) , " durable nonces must be advanceable " ) ,
2022-06-13 20:36:44 -07:00
( vote_authorize_with_seed ::id ( ) , " An instruction you can use to change a vote accounts authority when the current authority is a derived key #25860 " ) ,
2022-06-15 18:35:33 -07:00
( cap_accounts_data_size_per_block ::id ( ) , " cap the accounts data size per block #25517 " ) ,
2022-06-28 10:39:00 -07:00
( stake_redelegate_instruction ::id ( ) , " enable the redelegate stake instruction #26294 " ) ,
2022-07-08 13:04:08 -07:00
( preserve_rent_epoch_for_rent_exempt_accounts ::id ( ) , " preserve rent epoch for rent exempt accounts #26479 " ) ,
2022-07-11 14:46:32 -07:00
( enable_bpf_loader_extend_program_data_ix ::id ( ) , " enable bpf upgradeable loader ExtendProgramData instruction #25234 " ) ,
2022-07-15 00:31:34 -07:00
( enable_early_verification_of_account_modifications ::id ( ) , " enable early verification of account modifications #25899 " ) ,
2022-07-15 06:23:37 -07:00
( prevent_crediting_accounts_that_end_rent_paying ::id ( ) , " prevent crediting rent paying accounts #26606 " ) ,
2022-07-20 05:12:43 -07:00
( cap_bpf_program_instruction_accounts ::id ( ) , " enforce max number of accounts per bpf program instruction #26628 " ) ,
2022-07-24 11:20:16 -07:00
( loosen_cpi_size_restriction ::id ( ) , " loosen cpi size restrictions #26641 " ) ,
2022-07-26 12:39:24 -07:00
( use_default_units_in_fee_calculation ::id ( ) , " use default units per instruction in fee calculation #26785 " ) ,
2022-07-27 12:23:44 -07:00
( compact_vote_state_updates ::id ( ) , " Compact vote state updates to lower block size " ) ,
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-11-11 14:09:28 -08:00
/// Activate a feature
pub fn activate ( & mut self , feature_id : & Pubkey , slot : u64 ) {
self . inactive . remove ( feature_id ) ;
self . active . insert ( * feature_id , slot ) ;
}
/// Deactivate a feature
pub fn deactivate ( & mut self , feature_id : & Pubkey ) {
self . active . remove ( feature_id ) ;
self . inactive . insert ( * feature_id ) ;
}
2020-09-29 20:18:28 -07:00
}
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 ( )
) ;
}
2021-11-11 14:09:28 -08:00
#[ test ]
fn test_feature_set_activate_deactivate ( ) {
let mut feature_set = FeatureSet ::default ( ) ;
let feature = Pubkey ::new_unique ( ) ;
assert! ( ! feature_set . is_active ( & feature ) ) ;
feature_set . activate ( & feature , 0 ) ;
assert! ( feature_set . is_active ( & feature ) ) ;
feature_set . deactivate ( & feature ) ;
assert! ( ! feature_set . is_active ( & feature ) ) ;
}
2021-01-20 11:54:13 -08:00
}