emit warn log on bad state (#14513)

This commit is contained in:
Liam Aharon
2023-07-06 00:44:56 +10:00
committed by GitHub
parent 032aa05221
commit 9c3ca04781
+11 -9
View File
@@ -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(())