Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2633,14 +2633,16 @@ impl<T: Config + pallet_balances::Config<Balance = u64>>
Error::<T>::HotKeyAccountNotExists
);

let actual_alpha = Self::decrease_stake_for_hotkey_and_coldkey_on_subnet(
hotkey, coldkey, netuid, alpha,
);

// Decrese alpha out counter
SubnetAlphaOut::<T>::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)
}
}

Expand Down
6 changes: 3 additions & 3 deletions pallets/subtensor/src/tests/recycle_alpha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ fn test_burn_success() {
));

assert!(TotalHotkeyAlpha::<Test>::get(hotkey, netuid) < initial_alpha);
assert!(SubnetAlphaOut::<Test>::get(netuid) == initial_net_alpha);
assert!(SubnetAlphaOut::<Test>::get(netuid) == initial_net_alpha); // Expect NO decrease
assert!(
SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey, &coldkey, netuid)
< stake.into()
Expand Down Expand Up @@ -307,7 +307,7 @@ fn test_burn_staker_is_nominator() {
));

assert!(TotalHotkeyAlpha::<Test>::get(hotkey, netuid) < initial_alpha);
assert!(SubnetAlphaOut::<Test>::get(netuid) == initial_net_alpha);
assert!(SubnetAlphaOut::<Test>::get(netuid) == initial_net_alpha); // Expect NO decrease
assert!(
SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(
&hotkey,
Expand Down Expand Up @@ -376,7 +376,7 @@ fn test_burn_two_stakers() {
));

assert!(TotalHotkeyAlpha::<Test>::get(hotkey, netuid) < initial_alpha);
assert!(SubnetAlphaOut::<Test>::get(netuid) == initial_net_alpha);
assert!(SubnetAlphaOut::<Test>::get(netuid) == initial_net_alpha); // Expect NO decrease
assert!(
SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey, &coldkey, netuid)
< stake.into()
Expand Down