FRAME: Minor fix for failsafe. (#13741)

* max instead of min

* Remove debug stuff

* remove debug code

* warn log on no provider ref

* format string for log

---------

Co-authored-by: muharem <ismailov.m.h@gmail.com>
This commit is contained in:
Gavin Wood
2023-04-01 23:59:37 +02:00
committed by GitHub
parent 197b8d6571
commit d997103476
2 changed files with 8 additions and 8 deletions
+6 -1
View File
@@ -786,7 +786,12 @@ pub mod pallet {
// Gah!! We have a non-zero reserve balance but no provider refs :(
// This shouldn't practically happen, but we need a failsafe anyway: let's give
// them enough for an ED.
a.free = a.free.min(Self::ed());
log::warn!(
target: LOG_TARGET,
"account with a non-zero reserve balance has no provider refs, account_id: '{:?}'.",
who
);
a.free = a.free.max(Self::ed());
system::Pallet::<T>::inc_providers(who);
}
let _ = system::Pallet::<T>::inc_consumers(who).defensive();
+2 -7
View File
@@ -480,9 +480,6 @@ pub mod pallet {
AlreadyCommunal,
/// The receipt is already private.
AlreadyPrivate,
Release1,
Release2,
Tah,
}
pub(crate) struct WeightCounter {
@@ -724,8 +721,7 @@ pub mod pallet {
let dropped = receipt.proportion.is_zero();
if amount > on_hold {
T::Currency::release(&T::HoldReason::get(), &who, on_hold, Exact)
.map_err(|_| Error::<T>::Release1)?;
T::Currency::release(&T::HoldReason::get(), &who, on_hold, Exact)?;
let deficit = amount - on_hold;
// Try to transfer deficit from pot to receipt owner.
summary.receipts_on_hold.saturating_reduce(on_hold);
@@ -756,8 +752,7 @@ pub mod pallet {
)?;
summary.receipts_on_hold.saturating_reduce(on_hold);
}
T::Currency::release(&T::HoldReason::get(), &who, amount, Exact)
.map_err(|_| Error::<T>::Release2)?;
T::Currency::release(&T::HoldReason::get(), &who, amount, Exact)?;
}
if dropped {