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>
This commit is contained in:
Liam Aharon
2023-09-14 10:25:50 +10:00
committed by GitHub
parent f1994c8690
commit cc39edd5a8
+4 -4
View File
@@ -3134,6 +3134,10 @@ impl<T: Config> Pallet<T> {
// reward math rounds down, we might accumulate some dust here.
let pending_rewards_lt_leftover_bal = RewardPool::<T>::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
// <https://github.com/paritytech/polkadot-sdk/pull/1255>. 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<T: Config> Pallet<T> {
RewardPool::<T>::current_balance(id)
);
}
ensure!(
pending_rewards_lt_leftover_bal,
"The sum of the pending rewards must be less than the leftover balance."
);
Ok(())
})?;