From 81974e1cf6c28cb49b0c29d44c7dd54dd403eafd Mon Sep 17 00:00:00 2001 From: Gav Date: Mon, 15 May 2023 13:09:27 +0100 Subject: [PATCH 1/3] Actually thaw when locking zero. --- frame/balances/src/impl_currency.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/frame/balances/src/impl_currency.rs b/frame/balances/src/impl_currency.rs index 9f764a37b8b89..634ddbe596c59 100644 --- a/frame/balances/src/impl_currency.rs +++ b/frame/balances/src/impl_currency.rs @@ -846,17 +846,13 @@ 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() { - return - } let mut new_lock = Some(BalanceLock { id, amount, reasons: reasons.into() }); let mut locks = Self::locks(who) .into_iter() From 9adb7db3d27273eabfc4423ce975a9c6a93b0d41 Mon Sep 17 00:00:00 2001 From: Gav Date: Mon, 22 May 2023 14:26:04 +0100 Subject: [PATCH 2/3] Fixes --- frame/offences/benchmarking/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frame/offences/benchmarking/src/lib.rs b/frame/offences/benchmarking/src/lib.rs index e7fc39657a190..92a87fb58b8c5 100644 --- a/frame/offences/benchmarking/src/lib.rs +++ b/frame/offences/benchmarking/src/lib.rs @@ -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 ); } @@ -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 ); } From 16a45f0f2758228343867640421f1f9e317bd0fc Mon Sep 17 00:00:00 2001 From: Gav Date: Mon, 22 May 2023 18:03:14 +0100 Subject: [PATCH 3/3] Just remove the lock if semantically viable --- frame/balances/src/impl_currency.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frame/balances/src/impl_currency.rs b/frame/balances/src/impl_currency.rs index 634ddbe596c59..baa153c119b20 100644 --- a/frame/balances/src/impl_currency.rs +++ b/frame/balances/src/impl_currency.rs @@ -853,6 +853,11 @@ where amount: T::Balance, reasons: WithdrawReasons, ) { + 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()