Fast Unstake Pallet (#12129)

* add failing test for itamar

* an ugly example of fast unstake

* Revert "add failing test for itamar"

This reverts commit 16c4d8015698a0684c090c54fce8b470a2d2feb2.

* fast unstake wip

* clean it up a bit

* some comments

* on_idle logic

* fix

* comment

* new working version, checks all pass, looking good

* some notes

* add mock boilerplate

* more boilerplate

* simplify the weight stuff

* ExtBuilder for pools

* fmt

* rm bags-list, simplify setup_works

* mock + tests boilerplate

* make some benchmarks work

* mock boilerplate

* tests boilerplate

* run_to_block works

* add Error enums

* add test

* note

* make UnstakeRequest fields pub

* some tests

* fix origin

* fmt

* add fast_unstake_events_since_last_call

* text

* rewrite some benchmes and fix them -- the outcome is still strange

* Fix weights

* cleanup

* Update frame/election-provider-support/solution-type/src/single_page.rs

* fix build

* Fix pools tests

* iterate teset + mock

* test unfinished

* cleanup and add some tests

* add test successful_multi_queue

* comment

* rm Head check

* add TODO

* complete successful_multi_queue

* + test early_exit

* fix a lot of things above the beautiful atlantic ocean 🌊

* seemingly it is finished now

* Fix build

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

* Fix slashing amount as well

* better docs

* abstract types

* rm use

* import

* Update frame/nomination-pools/benchmarking/src/lib.rs

Co-authored-by: Nitwit <47109040+nitwit69@users.noreply.github.com>

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

Co-authored-by: Nitwit <47109040+nitwit69@users.noreply.github.com>

* Fix build

* fmt

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

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

* make bounded

* feedback from code review with Ankan

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

Co-authored-by: Roman Useinov <roman.useinov@gmail.com>

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

Co-authored-by: Roman Useinov <roman.useinov@gmail.com>

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

Co-authored-by: Roman Useinov <roman.useinov@gmail.com>

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

Co-authored-by: Roman Useinov <roman.useinov@gmail.com>

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

Co-authored-by: Roman Useinov <roman.useinov@gmail.com>

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

Co-authored-by: Roman Useinov <roman.useinov@gmail.com>

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

Co-authored-by: Roman Useinov <roman.useinov@gmail.com>

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

Co-authored-by: Roman Useinov <roman.useinov@gmail.com>

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

Co-authored-by: Roman Useinov <roman.useinov@gmail.com>

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

* update to master

* some final review comments

* fmt

* fix clippy

* remove unused

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

* make it all build again

* fmt

* undo fishy change

Co-authored-by: Ross Bulat <ross@jkrbinvestments.com>
Co-authored-by: command-bot <>
Co-authored-by: Nitwit <47109040+nitwit69@users.noreply.github.com>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
Co-authored-by: Roman Useinov <roman.useinov@gmail.com>
This commit is contained in:
Kian Paimani
2022-09-23 10:36:33 +01:00
committed by GitHub
parent 34bfd2ad00
commit b56c0e4cb6
21 changed files with 2650 additions and 29 deletions
+1 -1
View File
@@ -563,7 +563,7 @@ impl<T: Config> StakingLedger<T> {
///
/// This calls `Config::OnStakerSlash::on_slash` with information as to how the slash was
/// applied.
fn slash(
pub fn slash(
&mut self,
slash_amount: BalanceOf<T>,
minimum_balance: BalanceOf<T>,
+2 -2
View File
@@ -653,10 +653,10 @@ impl<T: Config> Pallet<T> {
#[cfg(feature = "runtime-benchmarks")]
pub fn add_era_stakers(
current_era: EraIndex,
controller: T::AccountId,
stash: T::AccountId,
exposure: Exposure<T::AccountId, BalanceOf<T>>,
) {
<ErasStakers<T>>::insert(&current_era, &controller, &exposure);
<ErasStakers<T>>::insert(&current_era, &stash, &exposure);
}
#[cfg(feature = "runtime-benchmarks")]
+3 -2
View File
@@ -504,6 +504,7 @@ pub mod pallet {
/// Slashing spans for stash accounts.
#[pallet::storage]
#[pallet::getter(fn slashing_spans)]
#[pallet::unbounded]
pub(crate) type SlashingSpans<T: Config> =
StorageMap<_, Twox64Concat, T::AccountId, slashing::SlashingSpans>;
@@ -656,8 +657,8 @@ pub mod pallet {
EraPaid(EraIndex, BalanceOf<T>, BalanceOf<T>),
/// The nominator has been rewarded by this amount. \[stash, amount\]
Rewarded(T::AccountId, BalanceOf<T>),
/// One validator (and its nominators) has been slashed by the given amount.
/// \[validator, amount\]
/// One staker (and potentially its nominators) has been slashed by the given amount.
/// \[staker, amount\]
Slashed(T::AccountId, BalanceOf<T>),
/// An old slashing report from a prior era was discarded because it could
/// not be processed. \[session_index\]