Add feature for pending SPL Token self-transfer fix (#14917)
(cherry picked from commit 85b5dbead6
)
Co-authored-by: Trent Nelson <trent@solana.com>
This commit is contained in:
@ -4583,8 +4583,8 @@ impl Bank {
|
|||||||
self.rent_collector.rent.burn_percent = 50; // 50% rent burn
|
self.rent_collector.rent.burn_percent = 50; // 50% rent burn
|
||||||
}
|
}
|
||||||
|
|
||||||
if new_feature_activations.contains(&feature_set::spl_token_v2_multisig_fix::id()) {
|
if new_feature_activations.contains(&feature_set::spl_token_v2_self_transfer_fix::id()) {
|
||||||
self.apply_spl_token_v2_multisig_fix();
|
self.apply_spl_token_v2_self_transfer_fix();
|
||||||
}
|
}
|
||||||
// Remove me after a while around v1.6
|
// Remove me after a while around v1.6
|
||||||
if !self.no_stake_rewrite.load(Relaxed)
|
if !self.no_stake_rewrite.load(Relaxed)
|
||||||
@ -4676,7 +4676,7 @@ impl Bank {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_spl_token_v2_multisig_fix(&mut self) {
|
fn apply_spl_token_v2_self_transfer_fix(&mut self) {
|
||||||
if let Some(mut account) = self.get_account(&inline_spl_token_v2_0::id()) {
|
if let Some(mut account) = self.get_account(&inline_spl_token_v2_0::id()) {
|
||||||
self.capitalization.fetch_sub(account.lamports, Relaxed);
|
self.capitalization.fetch_sub(account.lamports, Relaxed);
|
||||||
account.lamports = 0;
|
account.lamports = 0;
|
||||||
@ -10840,7 +10840,7 @@ pub(crate) mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_spl_token_v2_multisig_fix() {
|
fn test_spl_token_v2_self_transfer_fix() {
|
||||||
let (genesis_config, _mint_keypair) = create_genesis_config(0);
|
let (genesis_config, _mint_keypair) = create_genesis_config(0);
|
||||||
let mut bank = Bank::new(&genesis_config);
|
let mut bank = Bank::new(&genesis_config);
|
||||||
|
|
||||||
@ -10855,7 +10855,7 @@ pub(crate) mod tests {
|
|||||||
assert_eq!(bank.get_balance(&inline_spl_token_v2_0::id()), 100);
|
assert_eq!(bank.get_balance(&inline_spl_token_v2_0::id()), 100);
|
||||||
let original_capitalization = bank.capitalization();
|
let original_capitalization = bank.capitalization();
|
||||||
|
|
||||||
bank.apply_spl_token_v2_multisig_fix();
|
bank.apply_spl_token_v2_self_transfer_fix();
|
||||||
|
|
||||||
// Account is now empty, and the account lamports were burnt
|
// Account is now empty, and the account lamports were burnt
|
||||||
assert_eq!(bank.get_balance(&inline_spl_token_v2_0::id()), 0);
|
assert_eq!(bank.get_balance(&inline_spl_token_v2_0::id()), 0);
|
||||||
|
@ -162,6 +162,10 @@ pub mod prevent_upgrade_and_invoke {
|
|||||||
solana_sdk::declare_id!("BiNjYd8jCYDgAwMqP91uwZs6skWpuHtKrZbckuKESs8N");
|
solana_sdk::declare_id!("BiNjYd8jCYDgAwMqP91uwZs6skWpuHtKrZbckuKESs8N");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod spl_token_v2_self_transfer_fix {
|
||||||
|
solana_sdk::declare_id!("BL99GYhdjjcv6ys22C9wPgn2aTVERDbPHHo4NbS3hgp7");
|
||||||
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Map of feature identifiers to user-visible description
|
/// Map of feature identifiers to user-visible description
|
||||||
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
|
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
|
||||||
@ -201,6 +205,7 @@ lazy_static! {
|
|||||||
(prevent_upgrade_and_invoke::id(), "Prevent upgrade and invoke in same tx batch"),
|
(prevent_upgrade_and_invoke::id(), "Prevent upgrade and invoke in same tx batch"),
|
||||||
(full_inflation::candidate_example::vote::id(), "Community vote allowing candidate_example to enable full inflation"),
|
(full_inflation::candidate_example::vote::id(), "Community vote allowing candidate_example to enable full inflation"),
|
||||||
(full_inflation::candidate_example::enable::id(), "Full inflation enabled by candidate_example"),
|
(full_inflation::candidate_example::enable::id(), "Full inflation enabled by candidate_example"),
|
||||||
|
(spl_token_v2_self_transfer_fix::id(), "spl-token self-transfer fix"),
|
||||||
/*************** ADD NEW FEATURES HERE ***************/
|
/*************** ADD NEW FEATURES HERE ***************/
|
||||||
]
|
]
|
||||||
.iter()
|
.iter()
|
||||||
|
Reference in New Issue
Block a user