diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index ef2d44e68b..dbc13eb727 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -2633,14 +2633,16 @@ impl> Error::::HotKeyAccountNotExists ); + let actual_alpha = Self::decrease_stake_for_hotkey_and_coldkey_on_subnet( + hotkey, coldkey, netuid, alpha, + ); + // Decrese alpha out counter SubnetAlphaOut::::mutate(netuid, |total| { - *total = total.saturating_sub(alpha); + *total = total.saturating_sub(actual_alpha); }); - Ok(Self::decrease_stake_for_hotkey_and_coldkey_on_subnet( - hotkey, coldkey, netuid, alpha, - )) + Ok(actual_alpha) } } diff --git a/pallets/subtensor/src/tests/recycle_alpha.rs b/pallets/subtensor/src/tests/recycle_alpha.rs index 32a95c700d..1b02a11397 100644 --- a/pallets/subtensor/src/tests/recycle_alpha.rs +++ b/pallets/subtensor/src/tests/recycle_alpha.rs @@ -246,7 +246,7 @@ fn test_burn_success() { )); assert!(TotalHotkeyAlpha::::get(hotkey, netuid) < initial_alpha); - assert!(SubnetAlphaOut::::get(netuid) == initial_net_alpha); + assert!(SubnetAlphaOut::::get(netuid) == initial_net_alpha); // Expect NO decrease assert!( SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey, &coldkey, netuid) < stake.into() @@ -307,7 +307,7 @@ fn test_burn_staker_is_nominator() { )); assert!(TotalHotkeyAlpha::::get(hotkey, netuid) < initial_alpha); - assert!(SubnetAlphaOut::::get(netuid) == initial_net_alpha); + assert!(SubnetAlphaOut::::get(netuid) == initial_net_alpha); // Expect NO decrease assert!( SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( &hotkey, @@ -376,7 +376,7 @@ fn test_burn_two_stakers() { )); assert!(TotalHotkeyAlpha::::get(hotkey, netuid) < initial_alpha); - assert!(SubnetAlphaOut::::get(netuid) == initial_net_alpha); + assert!(SubnetAlphaOut::::get(netuid) == initial_net_alpha); // Expect NO decrease assert!( SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey, &coldkey, netuid) < stake.into()