Skip to content

Commit

Permalink
added feature
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Aug 18, 2023
1 parent 6f687e5 commit 935aa1a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions runtime/src/inline_feature_gate_program.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
solana_sdk::declare_id!("Feature111111111111111111111111111111111111");

pub(crate) mod noop_program {
solana_sdk::declare_id!("5Re2FUHmvSdem1KV2bU5GFvqZpP2MXj76yVhMKKbP45o");
}
1 change: 1 addition & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions sdk/src/feature_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Pubkey, &'static str> = [
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 935aa1a

Please sign in to comment.