Skip to content

Commit

Permalink
Merge pull request #382 from opentensor/hotfix/unstake-entire-balance
Browse files Browse the repository at this point in the history
hotfix: allow unstake below the min nom threshold when unstaking entire stake
  • Loading branch information
orriin committed Apr 30, 2024
2 parents e2dd8c5 + 562a0fa commit 9b1c533
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pallets/subtensor/src/staking.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::*;
use frame_support::storage::IterableStorageDoubleMap;
use sp_runtime::traits::Zero;

impl<T: Config> Pallet<T> {
// ---- The implementation for the extrinsic become_delegate: signals that this hotkey allows delegated stake.
Expand Down Expand Up @@ -305,7 +306,8 @@ impl<T: Config> Pallet<T> {
Stake::<T>::get(&hotkey, &coldkey).saturating_sub(stake_to_be_removed);

ensure!(
total_stake_after_remove >= NominatorMinRequiredStake::<T>::get(),
total_stake_after_remove.is_zero()
|| total_stake_after_remove >= NominatorMinRequiredStake::<T>::get(),
Error::<T>::NomStakeBelowMinimumThreshold
);
}
Expand Down
7 changes: 7 additions & 0 deletions pallets/subtensor/tests/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2695,5 +2695,12 @@ fn test_remove_stake_below_minimum_threshold() {
),
Error::<Test>::NomStakeBelowMinimumThreshold
);

// Nomination stake can still remove their entire stake
assert_ok!(SubtensorModule::remove_stake(
<<Test as Config>::RuntimeOrigin>::signed(coldkey2),
hotkey1,
initial_stake
));
})
}
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// `spec_version`, and `authoring_version` are the same between Wasm and native.
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
// the compatible custom types.
spec_version: 147,
spec_version: 148,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down

0 comments on commit 9b1c533

Please sign in to comment.