mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 21:01:05 +00:00
nomination-pools: add permissionless condition to chill (#3453)
Currently, pool member funds cannot be unbonded if the depositor's stake is less than `MinNominatorBond`. This usually happens after `T::MinNominatorBond` is increased. To fix this, the above mentioned condition is added as a case for permissionless dispatch of `chill`. After pool is chilled, pool members can unbond their funds since pool won't be nominating anymore. Consequently, same check is added to `nominate` call, i.e pool can not start nominating if it's depositor does not have `MinNominatorBond` cc @Ank4n @kianenigma closes #2350 Polkadot address: 16FqwPZ8GRC5U5D4Fu7W33nA55ZXzXGWHwmbnE1eT6pxuqcT --------- Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com> Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com> Co-authored-by: command-bot <>
This commit is contained in:
@@ -4848,6 +4848,18 @@ mod nominate {
|
||||
Error::<Runtime>::NotNominator
|
||||
);
|
||||
|
||||
// if `depositor` stake is less than the `MinimumNominatorBond`, they can't nominate
|
||||
StakingMinBond::set(20);
|
||||
|
||||
// Can't nominate if depositor's stake is less than the `MinimumNominatorBond`
|
||||
assert_noop!(
|
||||
Pools::nominate(RuntimeOrigin::signed(900), 1, vec![21]),
|
||||
Error::<Runtime>::MinimumBondNotMet
|
||||
);
|
||||
|
||||
// restore `MinimumNominatorBond`
|
||||
StakingMinBond::set(10);
|
||||
|
||||
// Root can nominate
|
||||
assert_ok!(Pools::nominate(RuntimeOrigin::signed(900), 1, vec![21]));
|
||||
assert_eq!(Nominations::get().unwrap(), vec![21]);
|
||||
@@ -7338,3 +7350,33 @@ mod slash {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
mod chill {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn chill_works() {
|
||||
ExtBuilder::default().build_and_execute(|| {
|
||||
// only nominator or root can chill
|
||||
assert_noop!(
|
||||
Pools::chill(RuntimeOrigin::signed(10), 1),
|
||||
Error::<Runtime>::NotNominator
|
||||
);
|
||||
|
||||
// root can chill and re-nominate
|
||||
assert_ok!(Pools::chill(RuntimeOrigin::signed(900), 1));
|
||||
assert_ok!(Pools::nominate(RuntimeOrigin::signed(900), 1, vec![31]));
|
||||
|
||||
// nominator can chill and re-nominate
|
||||
assert_ok!(Pools::chill(RuntimeOrigin::signed(901), 1));
|
||||
assert_ok!(Pools::nominate(RuntimeOrigin::signed(901), 1, vec![31]));
|
||||
|
||||
// if `depositor` stake is less than the `MinimumNominatorBond`, then this call
|
||||
// becomes permissionless;
|
||||
StakingMinBond::set(20);
|
||||
|
||||
// any account can chill
|
||||
assert_ok!(Pools::chill(RuntimeOrigin::signed(10), 1));
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user