From 849fad7e947cc60117070e04327046135bcba02e Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 30 Apr 2024 17:09:34 +0400 Subject: [PATCH 1/2] fix: allow unstaking entire balance --- pallets/subtensor/src/staking.rs | 4 +++- pallets/subtensor/tests/staking.rs | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pallets/subtensor/src/staking.rs b/pallets/subtensor/src/staking.rs index ce3d3a1c0d..651fff6ee3 100644 --- a/pallets/subtensor/src/staking.rs +++ b/pallets/subtensor/src/staking.rs @@ -1,5 +1,6 @@ use super::*; use frame_support::storage::IterableStorageDoubleMap; +use sp_runtime::traits::Zero; impl Pallet { // ---- The implementation for the extrinsic become_delegate: signals that this hotkey allows delegated stake. @@ -305,7 +306,8 @@ impl Pallet { Stake::::get(&hotkey, &coldkey).saturating_sub(stake_to_be_removed); ensure!( - total_stake_after_remove >= NominatorMinRequiredStake::::get(), + total_stake_after_remove.is_zero() + || total_stake_after_remove >= NominatorMinRequiredStake::::get(), Error::::NomStakeBelowMinimumThreshold ); } diff --git a/pallets/subtensor/tests/staking.rs b/pallets/subtensor/tests/staking.rs index 595ab87370..7d8eb0e5f6 100644 --- a/pallets/subtensor/tests/staking.rs +++ b/pallets/subtensor/tests/staking.rs @@ -2695,5 +2695,12 @@ fn test_remove_stake_below_minimum_threshold() { ), Error::::NomStakeBelowMinimumThreshold ); + + // Nomination stake can still remove their entire stake + assert_ok!(SubtensorModule::remove_stake( + <::RuntimeOrigin>::signed(coldkey2), + hotkey1, + initial_stake + )); }) } From 562a0faf7be92ab533dcb15401684f44c7c2b7be Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 30 Apr 2024 17:10:29 +0400 Subject: [PATCH 2/2] fix: bump spec version --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 5706376fc1..dd400cb8d7 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -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,