Skip to content

Commit

Permalink
revert programify feature gate (#33897)
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec authored Oct 27, 2023
1 parent 01603fd commit ecd674b
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 613 deletions.
56 changes: 36 additions & 20 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ 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 @@ -218,7 +217,6 @@ pub mod bank_hash_details;
mod builtin_programs;
pub mod epoch_accounts_hash_utils;
mod metrics;
mod replace_account;
mod serde_snapshot;
mod sysvar_cache;
#[cfg(test)]
Expand Down Expand Up @@ -8085,24 +8083,6 @@ 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::programify_feature_gate_program::id()) {
let datapoint_name = "bank-progamify_feature_gate_program";
if let Err(e) = replace_account::replace_empty_account_with_upgradeable_program(
self,
&feature::id(),
&inline_feature_gate_program::noop_program::id(),
datapoint_name,
) {
warn!(
"{}: Failed to replace empty account {} with upgradeable program: {}",
datapoint_name,
feature::id(),
e
);
datapoint_warn!(datapoint_name, ("slot", self.slot(), i64),);
}
}
}

fn apply_updated_hashes_per_tick(&mut self, hashes_per_tick: u64) {
Expand Down Expand Up @@ -8244,6 +8224,42 @@ impl Bank {
}
}

/// Use to replace programs by feature activation
#[allow(dead_code)]
fn replace_program_account(
&mut self,
old_address: &Pubkey,
new_address: &Pubkey,
datapoint_name: &'static str,
) {
if let Some(old_account) = self.get_account_with_fixed_root(old_address) {
if let Some(new_account) = self.get_account_with_fixed_root(new_address) {
datapoint_info!(datapoint_name, ("slot", self.slot, i64));

// Burn lamports in the old account
self.capitalization
.fetch_sub(old_account.lamports(), Relaxed);

// Transfer new account to old account
self.store_account(old_address, &new_account);

// Clear new account
self.store_account(new_address, &AccountSharedData::default());

// Unload a program from the bank's cache
self.loaded_programs_cache
.write()
.unwrap()
.remove_programs([*old_address].into_iter());

self.calculate_and_update_accounts_data_size_delta_off_chain(
old_account.data().len(),
new_account.data().len(),
);
}
}
}

/// Get all the accounts for this bank and calculate stats
pub fn get_total_accounts_stats(&self) -> ScanResult<TotalAccountsStats> {
let accounts = self.get_all_accounts()?;
Expand Down
191 changes: 0 additions & 191 deletions runtime/src/bank/replace_account.rs

This file was deleted.

Loading

0 comments on commit ecd674b

Please sign in to comment.