Skip to content

Commit

Permalink
Staking: chill_other takes stash instead of controller (paritytech#…
Browse files Browse the repository at this point in the history
…2501)

The `chill_other` call is the only staking call that explicitly requires
`controller` in its signature. This PR changes the controller arg to be
the stash instead, with `StakingLedger` then fetching the controller
from storage.

This is not a breaking change per se - the call types do not change, but
is noteworthy as UIs will now want to pass the stash account into
`chill_other` calls, & metadata will reflect this.

Note: This is very low impact. `chill_other` has [hardly ever been
used](https://polkadot.subscan.io/extrinsic?address=&module=staking&call=chill_other&result=all&signedChecked=signed%20only&startDate=&endDate=&startBlock=&timeType=date&version=9431&endBlock=)
on Polkadot - notwithstanding the one called 11 days ago at block
18177457 that was a part of test I did, the last call was made 493 days
ago. Only 2 calls have ever been successful.

Addresses controller deprecation paritytech#2500

---------

Co-authored-by: command-bot <>
Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com>
  • Loading branch information
Ross Bulat and gpestana committed Nov 27, 2023
1 parent a3cbf66 commit c898ab9
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 194 deletions.
2 changes: 1 addition & 1 deletion substrate/frame/staking/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ benchmarks! {
)?;

let caller = whitelisted_caller();
}: _(RawOrigin::Signed(caller), controller)
}: _(RawOrigin::Signed(caller), stash.clone())
verify {
assert!(!T::VoterList::contains(&stash));
}
Expand Down
13 changes: 9 additions & 4 deletions substrate/frame/staking/src/pallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ pub mod pallet {
// (temporary) passive migration.
Self::ledger(StakingAccount::Stash(stash.clone())).map(|ledger| {
let controller = ledger.controller()
.defensive_proof("ledger was fetched used the StakingInterface, so controller field must exist; qed.")
.defensive_proof("Ledger's controller field didn't exist. The controller should have been fetched using StakingLedger.")
.ok_or(Error::<T>::NotController)?;

if controller == stash {
Expand Down Expand Up @@ -1764,11 +1764,16 @@ pub mod pallet {
/// who do not satisfy these requirements.
#[pallet::call_index(23)]
#[pallet::weight(T::WeightInfo::chill_other())]
pub fn chill_other(origin: OriginFor<T>, controller: T::AccountId) -> DispatchResult {
pub fn chill_other(origin: OriginFor<T>, stash: T::AccountId) -> DispatchResult {
// Anyone can call this function.
let caller = ensure_signed(origin)?;
let ledger = Self::ledger(Controller(controller.clone()))?;
let stash = ledger.stash;
let ledger = Self::ledger(Stash(stash.clone()))?;
let controller = ledger
.controller()
.defensive_proof(
"Ledger's controller field didn't exist. The controller should have been fetched using StakingLedger.",
)
.ok_or(Error::<T>::NotController)?;

// In order for one user to chill another user, the following conditions must be met:
//
Expand Down
Loading

0 comments on commit c898ab9

Please sign in to comment.