[Feature] Add deposit to fast-unstake (#12366)

* [Feature] Add deposit to fast-unstake

* disable on ErasToCheckPerBlock == 0

* removed signed ext

* remove obsolete import

* remove some obsolete stuff

* fix some comments

* fixed all the comments

* remove obsolete imports

* fix some tests

* CallNotAllowed tests

* Update frame/fast-unstake/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* fix tests

* fix deregister + tests

* more fixes

* make sure we go above existential deposit

* fixed the last test

* some nit fixes

* fix node

* fix bench

* last bench fix

* Update frame/fast-unstake/src/lib.rs

* ".git/.scripts/fmt.sh" 1

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: command-bot <>
This commit is contained in:
Roman Useinov
2022-09-27 19:31:12 +02:00
committed by GitHub
parent e6b1aae97f
commit 1f687256fb
6 changed files with 313 additions and 238 deletions
@@ -110,18 +110,18 @@ fn on_idle_full_block<T: Config>() {
benchmarks! {
// on_idle, we we don't check anyone, but fully unbond and move them to another pool.
on_idle_unstake {
ErasToCheckPerBlock::<T>::put(1);
let who = create_unexposed_nominator::<T>();
assert_ok!(FastUnstake::<T>::register_fast_unstake(
RawOrigin::Signed(who.clone()).into(),
));
ErasToCheckPerBlock::<T>::put(1);
// run on_idle once. This will check era 0.
assert_eq!(Head::<T>::get(), None);
on_idle_full_block::<T>();
assert_eq!(
Head::<T>::get(),
Some(UnstakeRequest { stash: who.clone(), checked: vec![0].try_into().unwrap() })
Some(UnstakeRequest { stash: who.clone(), checked: vec![0].try_into().unwrap(), deposit: T::Deposit::get() })
);
}
: {
@@ -162,7 +162,7 @@ benchmarks! {
let checked: frame_support::BoundedVec<_, _> = (1..=u).rev().collect::<Vec<EraIndex>>().try_into().unwrap();
assert_eq!(
Head::<T>::get(),
Some(UnstakeRequest { stash: who.clone(), checked })
Some(UnstakeRequest { stash: who.clone(), checked, deposit: T::Deposit::get() })
);
assert!(matches!(
fast_unstake_events::<T>().last(),
@@ -171,6 +171,7 @@ benchmarks! {
}
register_fast_unstake {
ErasToCheckPerBlock::<T>::put(1);
let who = create_unexposed_nominator::<T>();
whitelist_account!(who);
assert_eq!(Queue::<T>::count(), 0);
@@ -182,6 +183,7 @@ benchmarks! {
}
deregister {
ErasToCheckPerBlock::<T>::put(1);
let who = create_unexposed_nominator::<T>();
assert_ok!(FastUnstake::<T>::register_fast_unstake(
RawOrigin::Signed(who.clone()).into(),