Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staking: chill_other takes stash instead of controller #2501

Merged
merged 10 commits into from
Nov 27, 2023
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