mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 09:37:55 +00:00
Introduces account existence providers reference counting (#7363)
* Initial draft * Latest changes * Final bits. * Fixes * Fixes * Test fixes * Fix tests * Fix babe tests * Fix * Fix * Fix * Fix * Fix * fix warnings in assets * Fix UI tests * fix line width * Fix * Update frame/system/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update frame/system/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Fix * fix unused warnings * Fix * Update frame/system/src/lib.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Update frame/system/src/lib.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Fix * fix slash and comprehensive slash test * fix reserved slash and comprehensive tests * check slash on non-existent account * Revert "Fix UI tests" This reverts commit e0002c0f13442f7d0c95a054a6c515536328a4a0. * Fix * Fix utility tests * keep dispatch error backwards compatible * Fix * Fix * fix ui test * Companion checker shouldn't be so anal. * Fix * Fix * Fix * Apply suggestions from code review Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> * Update frame/balances/src/lib.rs Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> * return correct slash info when failing gracefully * fix missing import * Update frame/system/src/lib.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Fix * Update frame/balances/src/tests_local.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Fixes Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
This commit is contained in:
@@ -274,6 +274,8 @@ decl_error! {
|
||||
MinBalanceZero,
|
||||
/// A mint operation lead to an overflow.
|
||||
Overflow,
|
||||
/// Some internal state is broken.
|
||||
BadState,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -863,7 +865,7 @@ impl<T: Config> Module<T> {
|
||||
) -> Result<bool, DispatchError> {
|
||||
let accounts = d.accounts.checked_add(1).ok_or(Error::<T>::Overflow)?;
|
||||
let r = Ok(if frame_system::Module::<T>::account_exists(who) {
|
||||
frame_system::Module::<T>::inc_ref(who);
|
||||
frame_system::Module::<T>::inc_consumers(who).map_err(|_| Error::<T>::BadState)?;
|
||||
false
|
||||
} else {
|
||||
ensure!(d.zombies < d.max_zombies, Error::<T>::TooManyZombies);
|
||||
@@ -881,7 +883,9 @@ impl<T: Config> Module<T> {
|
||||
is_zombie: &mut bool,
|
||||
) {
|
||||
if *is_zombie && frame_system::Module::<T>::account_exists(who) {
|
||||
frame_system::Module::<T>::inc_ref(who);
|
||||
// If the account exists, then it should have at least one provider
|
||||
// so this cannot fail... but being defensive anyway.
|
||||
let _ = frame_system::Module::<T>::inc_consumers(who);
|
||||
*is_zombie = false;
|
||||
d.zombies = d.zombies.saturating_sub(1);
|
||||
}
|
||||
@@ -895,7 +899,7 @@ impl<T: Config> Module<T> {
|
||||
if is_zombie {
|
||||
d.zombies = d.zombies.saturating_sub(1);
|
||||
} else {
|
||||
frame_system::Module::<T>::dec_ref(who);
|
||||
frame_system::Module::<T>::dec_consumers(who);
|
||||
}
|
||||
d.accounts = d.accounts.saturating_sub(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user