Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Actually respect locks of zero (#14144)
Browse files Browse the repository at this point in the history
* Actually thaw when locking zero.

* Fixes

* Just remove the lock if semantically viable

---------

Co-authored-by: parity-processbot <>
  • Loading branch information
gavofyork authored and Ank4n committed Jul 8, 2023
1 parent 36111be commit e07bf45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions frame/balances/src/impl_currency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,17 +846,18 @@ where

type MaxLocks = T::MaxLocks;

// Set a lock on the balance of `who`.
// Is a no-op if lock amount is zero or `reasons` `is_none()`.
// Set or alter a lock on the balance of `who`.
fn set_lock(
id: LockIdentifier,
who: &T::AccountId,
amount: T::Balance,
reasons: WithdrawReasons,
) {
if amount.is_zero() || reasons.is_empty() {
if reasons.is_empty() || amount.is_zero() {
Self::remove_lock(id, who);
return
}

let mut new_lock = Some(BalanceLock { id, amount, reasons: reasons.into() });
let mut locks = Self::locks(who)
.into_iter()
Expand Down
8 changes: 4 additions & 4 deletions frame/offences/benchmarking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ benchmarks! {
+ 1 // offence
+ 3 // reporter (reward + endowment)
+ 1 // offenders reported
+ 2 // offenders slashed
+ 3 // offenders slashed
+ 1 // offenders chilled
+ 2 * n // nominators slashed
+ 3 * n // nominators slashed
);
}

Expand Down Expand Up @@ -466,9 +466,9 @@ benchmarks! {
+ 1 // offence
+ 3 // reporter (reward + endowment)
+ 1 // offenders reported
+ 2 // offenders slashed
+ 3 // offenders slashed
+ 1 // offenders chilled
+ 2 * n // nominators slashed
+ 3 * n // nominators slashed
);
}

Expand Down

0 comments on commit e07bf45

Please sign in to comment.