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

Exclusive reserves for pallet-balances #7223

@xlc

Description

@xlc

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:

/// Amount held on deposit for this information.
pub deposit: Balance,

/// The amount held on deposit (reserved) for making this proposal.
bond: Balance,

/// The amount held on deposit for this tip.
deposit: Balance,

): map hasher(blake2_128_concat) T::AccountIndex => Option<(T::AccountId, BalanceOf<T>, bool)>;

/// 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:

T::Currency::unreserve(who, T::VotingBond::get());

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

Metadata

Metadata

Assignees

Labels

I3-bugThe node fails to follow expected behavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions