Skip to content

Commit

Permalink
Add tolerance to nom pool pending rewards try-state (paritytech#1236)
Browse files Browse the repository at this point in the history
Closes paritytech#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>
  • Loading branch information
liamaharon and Ank4n committed Sep 14, 2023
1 parent 92160a8 commit ef41ee9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions substrate/frame/nomination-pools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {:?}",
Expand All @@ -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(())
})?;

Expand Down

0 comments on commit ef41ee9

Please sign in to comment.