From ef41ee9056f4bcb87bd76244a1d7f0a28a8fb42d Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Thu, 14 Sep 2023 10:25:50 +1000 Subject: [PATCH] Add tolerance to nom pool pending rewards try-state (#1236) Closes https://github.com/paritytech/polkadot-sdk/issues/158 In our last FRAME call it was discussed that a likely solution to the ED imbalances is lazily fixing the pools as they are interacted with. So, we should add some tiny tolerance to the try-state checks so next time there's an ED change they don't start failing until they've all been interacted with. ### Update 12 Sept Rather than adding tolerance, have replaced the `ensure` with a warning. --------- Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com> --- substrate/frame/nomination-pools/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/substrate/frame/nomination-pools/src/lib.rs b/substrate/frame/nomination-pools/src/lib.rs index c4bebc5a1d030..485cdada7173b 100644 --- a/substrate/frame/nomination-pools/src/lib.rs +++ b/substrate/frame/nomination-pools/src/lib.rs @@ -3134,6 +3134,10 @@ impl Pallet { // reward math rounds down, we might accumulate some dust here. let pending_rewards_lt_leftover_bal = RewardPool::::current_balance(id) >= pools_members_pending_rewards.get(&id).copied().unwrap_or_default(); + + // this is currently broken in Kusama, a fix is being worked on in + // . until it is fixed, log a + // warning instead of panicing with an `ensure` statement. if !pending_rewards_lt_leftover_bal { log::warn!( "pool {:?}, sum pending rewards = {:?}, remaining balance = {:?}", @@ -3142,10 +3146,6 @@ impl Pallet { RewardPool::::current_balance(id) ); } - ensure!( - pending_rewards_lt_leftover_bal, - "The sum of the pending rewards must be less than the leftover balance." - ); Ok(()) })?;