From 935aa1ab8781577350548b0db3d471d01f7d31aa Mon Sep 17 00:00:00 2001 From: Joe Date: Fri, 18 Aug 2023 11:40:30 -0600 Subject: [PATCH] added feature --- runtime/src/bank.rs | 9 +++++++++ runtime/src/inline_feature_gate_program.rs | 5 +++++ runtime/src/lib.rs | 1 + sdk/src/feature_set.rs | 5 +++++ 4 files changed, 20 insertions(+) create mode 100644 runtime/src/inline_feature_gate_program.rs diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index fff14533661d74..27d583081018f1 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -42,6 +42,7 @@ use { builtins::{BuiltinPrototype, BUILTINS}, epoch_rewards_hasher::hash_rewards_into_partitions, epoch_stakes::{EpochStakes, NodeVoteAccounts}, + inline_feature_gate_program, runtime_config::RuntimeConfig, serde_snapshot::BankIncrementalSnapshotPersistence, snapshot_hash::SnapshotHash, @@ -7972,6 +7973,14 @@ impl Bank { if new_feature_activations.contains(&feature_set::update_hashes_per_tick::id()) { self.apply_updated_hashes_per_tick(DEFAULT_HASHES_PER_TICK); } + + if new_feature_activations.contains(&feature_set::feature_gate_program::id()) { + self.replace_empty_account_with_upgradeable_program( + &feature::id(), + &inline_feature_gate_program::noop_program::id(), + "bank-apply_feature_gate_program", + ); + } } fn apply_updated_hashes_per_tick(&mut self, hashes_per_tick: u64) { diff --git a/runtime/src/inline_feature_gate_program.rs b/runtime/src/inline_feature_gate_program.rs new file mode 100644 index 00000000000000..84391b3054d0be --- /dev/null +++ b/runtime/src/inline_feature_gate_program.rs @@ -0,0 +1,5 @@ +solana_sdk::declare_id!("Feature111111111111111111111111111111111111"); + +pub(crate) mod noop_program { + solana_sdk::declare_id!("5Re2FUHmvSdem1KV2bU5GFvqZpP2MXj76yVhMKKbP45o"); +} diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 7978048c8540a8..54b3df07f8253e 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -14,6 +14,7 @@ pub mod commitment; mod epoch_rewards_hasher; pub mod epoch_stakes; pub mod genesis_utils; +pub mod inline_feature_gate_program; pub mod inline_spl_associated_token_account; pub mod loader_utils; pub mod non_circulating_supply; diff --git a/sdk/src/feature_set.rs b/sdk/src/feature_set.rs index cd768991c71807..af7aebf71d7096 100644 --- a/sdk/src/feature_set.rs +++ b/sdk/src/feature_set.rs @@ -687,6 +687,10 @@ pub mod reduce_stake_warmup_cooldown { } } +pub mod feature_gate_program { + solana_sdk::declare_id!("8GdovDzVwWU5edz2G697bbB7GZjrUc6aQZLWyNNAtHdg"); +} + lazy_static! { /// Map of feature identifiers to user-visible description pub static ref FEATURE_NAMES: HashMap = [ @@ -851,6 +855,7 @@ lazy_static! { (bpf_account_data_direct_mapping::id(), "use memory regions to map account data into the rbpf vm instead of copying the data"), (last_restart_slot_sysvar::id(), "enable new sysvar last_restart_slot"), (reduce_stake_warmup_cooldown::id(), "reduce stake warmup cooldown from 25% to 9%"), + (feature_gate_program::id(), "control feature activations with an on-chain program"), /*************** ADD NEW FEATURES HERE ***************/ ] .iter()