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

Commit

Permalink
emit warn log on bad state (#14513)
Browse files Browse the repository at this point in the history
  • Loading branch information
liamaharon authored Jul 5, 2023
1 parent 8c823ec commit c32f5ed
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions frame/nomination-pools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3135,16 +3135,18 @@ impl<T: Config> Pallet<T> {
RewardPools::<T>::iter_keys().try_for_each(|id| -> Result<(), TryRuntimeError> {
// the sum of the pending rewards must be less than the leftover balance. Since the
// reward math rounds down, we might accumulate some dust here.
log!(
trace,
"pool {:?}, sum pending rewards = {:?}, remaining balance = {:?}",
id,
pools_members_pending_rewards.get(&id),
RewardPool::<T>::current_balance(id)
);
let pending_rewards_lt_leftover_bal = RewardPool::<T>::current_balance(id) >=
pools_members_pending_rewards.get(&id).copied().unwrap_or_default();
if !pending_rewards_lt_leftover_bal {
log::warn!(
"pool {:?}, sum pending rewards = {:?}, remaining balance = {:?}",
id,
pools_members_pending_rewards.get(&id),
RewardPool::<T>::current_balance(id)
);
}
ensure!(
RewardPool::<T>::current_balance(id) >=
pools_members_pending_rewards.get(&id).copied().unwrap_or_default(),
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 c32f5ed

Please sign in to comment.