Skip to content

Commit df5c186

Browse files
committed
full unbond instead
1 parent 0b8ef9e commit df5c186

7 files changed

Lines changed: 25 additions & 38 deletions

File tree

polkadot/runtime/westend/src/weights/pallet_staking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ impl<T: frame_system::Config> pallet_staking::WeightInfo for WeightInfo<T> {
801801
.saturating_add(T::DbWeight::get().writes(1))
802802
}
803803

804-
fn force_unbond() -> Weight {
804+
fn full_unbond() -> Weight {
805805
todo!()
806806
}
807807
}

prdoc/pr_3629.prdoc

Lines changed: 0 additions & 10 deletions
This file was deleted.

prdoc/pr_3811.prdoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
title: "[pallet_staking] Staking `full_unbond`"
2+
3+
doc:
4+
- audience: Runtime Dev
5+
description: |
6+
Full unbond when staking such that to fully unbond as a validator or nominator, chilled occurs first
7+
before unbonding
8+
9+
crates:
10+
- name: pallet-staking

substrate/frame/staking/src/benchmarking.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ benchmarks! {
953953
assert_eq!(MinCommission::<T>::get(), Perbill::from_percent(100));
954954
}
955955

956-
force_unbond {
956+
full_unbond {
957957
// clean up any existing state.
958958
clear_validators_and_nominators::<T>();
959959

@@ -972,7 +972,7 @@ benchmarks! {
972972
let original_bonded: BalanceOf<T> = ledger.active;
973973

974974
whitelist_account!(controller);
975-
}: _(RawOrigin::Signed(controller.clone()), original_bonded)
975+
}: _(RawOrigin::Signed(controller.clone()))
976976
verify {
977977
let ledger = Ledger::<T>::get(&controller).ok_or("ledger not created after")?;
978978
let new_bonded: BalanceOf<T> = ledger.active;

substrate/frame/staking/src/pallet/mod.rs

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,37 +1909,24 @@ pub mod pallet {
19091909
Ok(Some(T::WeightInfo::deprecate_controller_batch(controllers.len() as u32)).into())
19101910
}
19111911

1912-
/// Forcefully Unbonds by Chilling first
1912+
/// Fully Unbonds by Chilling first
19131913
/// Emits `Unbonded`.
19141914
#[pallet::call_index(29)]
19151915
#[pallet::weight(
1916-
T::WeightInfo::withdraw_unbonded_kill(SPECULATIVE_NUM_SPANS).saturating_add(T::WeightInfo::force_unbond()))
1916+
T::WeightInfo::withdraw_unbonded_kill(SPECULATIVE_NUM_SPANS).saturating_add(T::WeightInfo::full_unbond()))
19171917
]
1918-
pub fn force_unbond(
1919-
origin: OriginFor<T>,
1920-
#[pallet::compact] value: BalanceOf<T>,
1921-
) -> DispatchResultWithPostInfo {
1918+
pub fn full_unbond(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
19221919
let controller = ensure_signed(origin)?;
19231920

19241921
let ledger = Self::ledger(StakingAccount::Controller(controller.clone()))?;
19251922

1926-
let min_active_bond = if Nominators::<T>::contains_key(&ledger.stash) {
1927-
MinNominatorBond::<T>::get()
1928-
} else if Validators::<T>::contains_key(&ledger.stash) {
1929-
MinValidatorBond::<T>::get()
1930-
} else {
1931-
Zero::zero()
1932-
};
1933-
1934-
if (ledger.active - value) <= min_active_bond {
1935-
Self::chill_stash(&ledger.stash);
1936-
}
1923+
Self::chill_stash(&ledger.stash);
19371924

1938-
let maybe_withdraw_weight = Self::do_unbond(controller, value)?;
1925+
let maybe_withdraw_weight = Self::do_unbond(controller, ledger.active)?;
19391926
let actual_weight = if let Some(withdraw_weight) = maybe_withdraw_weight {
1940-
Some(T::WeightInfo::force_unbond().saturating_add(withdraw_weight))
1927+
Some(T::WeightInfo::full_unbond().saturating_add(withdraw_weight))
19411928
} else {
1942-
Some(T::WeightInfo::force_unbond())
1929+
Some(T::WeightInfo::full_unbond())
19431930
};
19441931

19451932
Ok(actual_weight.into())

substrate/frame/staking/src/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4070,7 +4070,7 @@ fn test_multi_page_payout_stakers_by_page() {
40704070
}
40714071

40724072
#[test]
4073-
fn force_unbond_works() {
4073+
fn full_unbond_works() {
40744074
//
40754075
// * Should test
40764076
// * Given an account being bonded [and chosen as a validator](not mandatory)
@@ -4107,7 +4107,7 @@ fn force_unbond_works() {
41074107
);
41084108

41094109
// Force Unbond all of the funds in stash which makes the call to chill first.
4110-
let res = Staking::force_unbond(RuntimeOrigin::signed(11), 1000);
4110+
let res = Staking::full_unbond(RuntimeOrigin::signed(11));
41114111
assert!(res.is_ok());
41124112
})
41134113
}

substrate/frame/staking/src/weights.rs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)