Add feature to resolve spl-token v2 multisig bug
This commit is contained in:
parent
aa5c008fa8
commit
f9a74b51ef
|
@ -3567,6 +3567,10 @@ 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()) {
|
||||||
|
self.apply_spl_token_v2_multisig_fix();
|
||||||
|
}
|
||||||
|
|
||||||
self.ensure_builtins(init_finish_or_warp, &new_feature_activations);
|
self.ensure_builtins(init_finish_or_warp, &new_feature_activations);
|
||||||
self.reinvoke_entered_epoch_callback(initiate_callback);
|
self.reinvoke_entered_epoch_callback(initiate_callback);
|
||||||
self.recheck_cross_program_support();
|
self.recheck_cross_program_support();
|
||||||
|
@ -3674,6 +3678,15 @@ impl Bank {
|
||||||
self.set_compute_budget(compute_budget);
|
self.set_compute_budget(compute_budget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn apply_spl_token_v2_multisig_fix(&mut self) {
|
||||||
|
if let Some(mut account) = self.get_account(&inline_spl_token_v2_0::id()) {
|
||||||
|
self.capitalization.fetch_sub(account.lamports, Relaxed);
|
||||||
|
account.lamports = 0;
|
||||||
|
self.store_account(&inline_spl_token_v2_0::id(), &account);
|
||||||
|
self.remove_executor(&inline_spl_token_v2_0::id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn reconfigure_token2_native_mint(&mut self) {
|
fn reconfigure_token2_native_mint(&mut self) {
|
||||||
let reconfigure_token2_native_mint = match self.cluster_type() {
|
let reconfigure_token2_native_mint = match self.cluster_type() {
|
||||||
ClusterType::Development => true,
|
ClusterType::Development => true,
|
||||||
|
@ -9202,4 +9215,27 @@ mod tests {
|
||||||
assert!(new_activations.is_empty());
|
assert!(new_activations.is_empty());
|
||||||
assert!(bank.feature_set.is_active(&test_feature));
|
assert!(bank.feature_set.is_active(&test_feature));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_spl_token_v2_multisig_fix() {
|
||||||
|
let (genesis_config, _mint_keypair) = create_genesis_config(0);
|
||||||
|
let mut bank = Bank::new(&genesis_config);
|
||||||
|
|
||||||
|
// Setup a simulated account
|
||||||
|
bank.add_account_and_update_capitalization(
|
||||||
|
&inline_spl_token_v2_0::id(),
|
||||||
|
&Account {
|
||||||
|
lamports: 100,
|
||||||
|
..Account::default()
|
||||||
|
},
|
||||||
|
);
|
||||||
|
assert_eq!(bank.get_balance(&inline_spl_token_v2_0::id()), 100);
|
||||||
|
let original_capitalization = bank.capitalization();
|
||||||
|
|
||||||
|
bank.apply_spl_token_v2_multisig_fix();
|
||||||
|
|
||||||
|
// 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.capitalization(), original_capitalization - 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,10 @@ pub mod pico_inflation {
|
||||||
solana_sdk::declare_id!("GaBtBJvmS4Arjj5W1NmFcyvPjsHN38UGYDq2MDwbs9Qu");
|
solana_sdk::declare_id!("GaBtBJvmS4Arjj5W1NmFcyvPjsHN38UGYDq2MDwbs9Qu");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod spl_token_v2_multisig_fix {
|
||||||
|
solana_sdk::declare_id!("E5JiFDQCwyC6QfT9REFyMpfK2mHcmv1GUDySU1Ue7TYv");
|
||||||
|
}
|
||||||
|
|
||||||
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> = [
|
||||||
|
@ -28,6 +32,7 @@ lazy_static! {
|
||||||
(secp256k1_program_enabled::id(), "secp256k1 program"),
|
(secp256k1_program_enabled::id(), "secp256k1 program"),
|
||||||
(consistent_recent_blockhashes_sysvar::id(), "consistent recentblockhashes sysvar"),
|
(consistent_recent_blockhashes_sysvar::id(), "consistent recentblockhashes sysvar"),
|
||||||
(pico_inflation::id(), "pico-inflation"),
|
(pico_inflation::id(), "pico-inflation"),
|
||||||
|
(spl_token_v2_multisig_fix::id(), "spl-token multisig fix"),
|
||||||
/*************** ADD NEW FEATURES HERE ***************/
|
/*************** ADD NEW FEATURES HERE ***************/
|
||||||
]
|
]
|
||||||
.iter()
|
.iter()
|
||||||
|
|
Loading…
Reference in New Issue