Skip to content

Commit

Permalink
Feature Gate: add the missing native mint account
Browse files Browse the repository at this point in the history
Adds the missing native token account as a feature gate
So11111111111111111111111111111111111111112
  • Loading branch information
nibty committed Dec 11, 2024
1 parent e3f7e2b commit bea0faf
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
14 changes: 13 additions & 1 deletion genesis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {
base64::{prelude::BASE64_STANDARD, Engine},
clap::{crate_description, crate_name, value_t, value_t_or_exit, App, Arg, ArgMatches},
itertools::Itertools,
solana_accounts_db::hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
solana_accounts_db::{hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE, inline_spl_token},
solana_clap_utils::{
input_parsers::{
cluster_type_of, pubkey_of, pubkeys_of, unix_timestamp_from_rfc3339_datetime,
Expand Down Expand Up @@ -580,6 +580,18 @@ fn main() -> Result<(), Box<dyn error::Error>> {
solana_stake_program::add_genesis_accounts(&mut genesis_config);
if genesis_config.cluster_type == ClusterType::Development {
solana_runtime::genesis_utils::activate_all_features(&mut genesis_config);

// Add the native mint account which was activated as a feature gate.
genesis_config.add_account(
inline_spl_token::native_mint::id(),
solana_sdk::account::AccountSharedData::from(Account {
owner: inline_spl_token::id(),
data: inline_spl_token::native_mint::ACCOUNT_DATA.to_vec(),
lamports: sol_to_lamports(1.0),
executable: false,
rent_epoch: 1,
}),
);
}

if let Some(files) = matches.values_of("primordial_accounts_file") {
Expand Down
16 changes: 15 additions & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ use {
ancestors::{Ancestors, AncestorsForSerialization},
blockhash_queue::BlockhashQueue,
epoch_accounts_hash::EpochAccountsHash,
inline_spl_token,
nonce_info::{NonceInfo, NoncePartial},
partitioned_rewards::PartitionedEpochRewardsConfig,
rent_collector::{CollectedInfo, RentCollector, RENT_EXEMPT_RENT_EPOCH},
Expand Down Expand Up @@ -154,7 +155,7 @@ use {
loader_v4::{self, LoaderV4State, LoaderV4Status},
message::{AccountKeys, SanitizedMessage},
native_loader,
native_token::LAMPORTS_PER_SOL,
native_token::{sol_to_lamports, LAMPORTS_PER_SOL},
nonce::{self, state::DurableNonce, NONCED_TX_MARKER_IX_INDEX},
nonce_account,
packet::PACKET_DATA_SIZE,
Expand Down Expand Up @@ -7900,6 +7901,19 @@ impl Bank {
if new_feature_activations.contains(&feature_set::update_hashes_per_tick6::id()) {
self.apply_updated_hashes_per_tick(UPDATED_HASHES_PER_TICK6);
}

if new_feature_activations.contains(&feature_set::enable_native_mint_wrap_account::id()) {
self.store_account_and_update_capitalization(
&inline_spl_token::native_mint::id(),
&solana_sdk::account::AccountSharedData::from(Account {
owner: inline_spl_token::id(),
data: inline_spl_token::native_mint::ACCOUNT_DATA.to_vec(),
lamports: sol_to_lamports(1.0),
executable: false,
rent_epoch: 1,
}),
);
}
}

fn apply_updated_hashes_per_tick(&mut self, hashes_per_tick: u64) {
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 @@ -793,6 +793,10 @@ pub mod enable_turbine_extended_fanout_experiments {
solana_sdk::declare_id!("BZn14Liea52wtBwrXUxTv6vojuTTmfc7XGEDTXrvMD7b");
}

pub mod enable_native_mint_wrap_account {
solana_sdk::declare_id!("BeCY6VL4CKQR2QUwe9w3iRtNMN91FMW1sXbRzwfc3WYc");
}

lazy_static! {
/// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
Expand Down Expand Up @@ -986,6 +990,7 @@ lazy_static! {
(deprecate_unused_legacy_vote_plumbing::id(), "Deprecate unused legacy vote tx plumbing"),
(chained_merkle_conflict_duplicate_proofs::id(), "generate duplicate proofs for chained merkle root conflicts"),
(enable_turbine_extended_fanout_experiments::id(), "enable turbine extended fanout experiments #2373"),
(enable_native_mint_wrap_account::id(), "enable the native mint wrap account"),
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()
Expand Down

0 comments on commit bea0faf

Please sign in to comment.