From ec77ab3f42ff14c8e2708f8960158c83caef4b80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Sat, 27 May 2023 16:46:07 +0200 Subject: [PATCH] Improves documentation on `num_slashing_spans` when calling `withdraw_unbounded` in Staking. (#14185) * gpestana/11714-num_slashing_spans_docs * Update frame/staking/src/pallet/mod.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * All calls that take num_slashing_span as parameters refer to comments on it --------- Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- frame/staking/src/pallet/mod.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index d8a7de2193bae..bff51312e7121 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -1040,8 +1040,8 @@ pub mod pallet { /// Remove any unlocked chunks from the `unlocking` queue from our management. /// - /// This essentially frees up that balance to be used by the stash account to do - /// whatever it wants. + /// This essentially frees up that balance to be used by the stash account to do whatever + /// it wants. /// /// The dispatch origin for this call must be _Signed_ by the controller. /// @@ -1049,6 +1049,15 @@ pub mod pallet { /// /// See also [`Call::unbond`]. /// + /// ## Parameters + /// + /// - `num_slashing_spans` indicates the number of metadata slashing spans to clear when + /// this call results in a complete removal of all the data related to the stash account. + /// In this case, the `num_slashing_spans` must be larger or equal to the number of + /// slashing spans associated with the stash account in the [`SlashingSpans`] storage type, + /// otherwise the call will fail. The call weight is directly propotional to + /// `num_slashing_spans`. + /// /// ## Complexity /// O(S) where S is the number of slashing spans to remove /// NOTE: Weight annotation is the kill scenario, we refund otherwise. @@ -1377,6 +1386,11 @@ pub mod pallet { /// Force a current staker to become completely unstaked, immediately. /// /// The dispatch origin must be Root. + /// + /// ## Parameters + /// + /// - `num_slashing_spans`: Refer to comments on [`Call::withdraw_unbonded`] for more + /// details. #[pallet::call_index(15)] #[pallet::weight(T::WeightInfo::force_unstake(*num_slashing_spans))] pub fn force_unstake( @@ -1517,6 +1531,11 @@ pub mod pallet { /// It can be called by anyone, as long as `stash` meets the above requirements. /// /// Refunds the transaction fees upon successful execution. + /// + /// ## Parameters + /// + /// - `num_slashing_spans`: Refer to comments on [`Call::withdraw_unbonded`] for more + /// details. #[pallet::call_index(20)] #[pallet::weight(T::WeightInfo::reap_stash(*num_slashing_spans))] pub fn reap_stash(