-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Exclusive reserves for pallet-balances #7223
Description
Currently the reserved balances are shared. Every pallets that uses reserve feature should keep a record how much is reserved so later it can unreserve / slash the same amount. Otherwise if deposits changes, a wrong value will be unserved / slashed.
Given that we should always have the reserved amount stored somewhere (or you may have bugs), we should just have pallet-balances (or another pallet) to do the bookkeeping. Also fund reserved by different pallets should not be shared. Reserve from pallet-identity cannot be used by pallet-proxy. This will simplify code, eliminates a category of bugs, and improve UX (How do I unreserve my money?).
Examples of extra deposit bookkeeping codes:
substrate/frame/identity/src/lib.rs
Lines 377 to 378 in 596f377
| /// Amount held on deposit for this information. | |
| pub deposit: Balance, |
substrate/frame/treasury/src/lib.rs
Lines 275 to 276 in 596f377
| /// The amount held on deposit (reserved) for making this proposal. | |
| bond: Balance, |
substrate/frame/treasury/src/lib.rs
Lines 295 to 296 in 596f377
| /// The amount held on deposit for this tip. | |
| deposit: Balance, |
substrate/frame/indices/src/lib.rs
Line 79 in 596f377
| ): map hasher(blake2_128_concat) T::AccountIndex => Option<(T::AccountId, BalanceOf<T>, bool)>; |
substrate/frame/proxy/src/lib.rs
Lines 157 to 160 in 596f377
| /// The set of account proxies. Maps the account which has delegated to the accounts | |
| /// which are being delegated to, together with the amount held on deposit. | |
| pub Proxies: map hasher(twox_64_concat) T::AccountId | |
| => (Vec<ProxyDefinition<T::AccountId, T::ProxyType, T::BlockNumber>>, BalanceOf<T>); |
Missing bookkeeping:
substrate/frame/elections-phragmen/src/lib.rs
Line 828 in 596f377
| T::Currency::unreserve(who, T::VotingBond::get()); |
substrate/frame/elections-phragmen/src/lib.rs
Line 581 in 596f377
| T::Currency::unreserve(&who, T::CandidacyBond::get()); |
I suspect some fund may already be locked forever for early Kusama council voters as the deposit have decreased once.
This will at same time closes #6724