Skip to content

Commit e9052f0

Browse files
authored
Removes Bank::replace_program_account() (#9396)
1 parent 84920ca commit e9052f0

File tree

2 files changed

+0
-75
lines changed

2 files changed

+0
-75
lines changed

runtime/src/bank.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5696,43 +5696,6 @@ impl Bank {
56965696
}
56975697
}
56985698

5699-
/// Use to replace programs by feature activation
5700-
#[allow(dead_code)]
5701-
fn replace_program_account(
5702-
&mut self,
5703-
old_address: &Pubkey,
5704-
new_address: &Pubkey,
5705-
datapoint_name: &'static str,
5706-
) {
5707-
if let Some(old_account) = self.get_account_with_fixed_root(old_address) {
5708-
if let Some(new_account) = self.get_account_with_fixed_root(new_address) {
5709-
datapoint_info!(datapoint_name, ("slot", self.slot, i64));
5710-
5711-
// Burn lamports in the old account
5712-
self.capitalization
5713-
.fetch_sub(old_account.lamports(), Relaxed);
5714-
5715-
// Transfer new account to old account
5716-
self.store_account(old_address, &new_account);
5717-
5718-
// Clear new account
5719-
self.store_account(new_address, &AccountSharedData::default());
5720-
5721-
// Unload a program from the bank's cache
5722-
self.transaction_processor
5723-
.global_program_cache
5724-
.write()
5725-
.unwrap()
5726-
.remove_programs([*old_address].into_iter());
5727-
5728-
self.calculate_and_update_accounts_data_size_delta_off_chain(
5729-
old_account.data().len(),
5730-
new_account.data().len(),
5731-
);
5732-
}
5733-
}
5734-
}
5735-
57365699
/// Calculates the accounts data size of all accounts
57375700
///
57385701
/// Panics if total overflows a u64.

runtime/src/bank/tests.rs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7031,44 +7031,6 @@ fn test_block_limits() {
70317031
);
70327032
}
70337033

7034-
#[test]
7035-
fn test_program_replacement() {
7036-
let mut bank = create_simple_test_bank(0);
7037-
7038-
// Setup original program account
7039-
let old_address = Pubkey::new_unique();
7040-
let new_address = Pubkey::new_unique();
7041-
bank.store_account_and_update_capitalization(
7042-
&old_address,
7043-
&AccountSharedData::from(Account {
7044-
lamports: 100,
7045-
..Account::default()
7046-
}),
7047-
);
7048-
assert_eq!(bank.get_balance(&old_address), 100);
7049-
7050-
// Setup new program account
7051-
let new_program_account = AccountSharedData::from(Account {
7052-
lamports: 123,
7053-
..Account::default()
7054-
});
7055-
bank.store_account_and_update_capitalization(&new_address, &new_program_account);
7056-
assert_eq!(bank.get_balance(&new_address), 123);
7057-
7058-
let original_capitalization = bank.capitalization();
7059-
7060-
bank.replace_program_account(&old_address, &new_address, "bank-apply_program_replacement");
7061-
7062-
// New program account is now empty
7063-
assert_eq!(bank.get_balance(&new_address), 0);
7064-
7065-
// Old program account holds the new program account
7066-
assert_eq!(bank.get_account(&old_address), Some(new_program_account));
7067-
7068-
// Lamports in the old token account were burnt
7069-
assert_eq!(bank.capitalization(), original_capitalization - 100);
7070-
}
7071-
70727034
fn min_rent_exempt_balance_for_sysvars(bank: &Bank, sysvar_ids: &[Pubkey]) -> u64 {
70737035
sysvar_ids
70747036
.iter()

0 commit comments

Comments
 (0)