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
substrate/frame/treasury/src/lib.rs
Lines 275 to 276 in 596f377
substrate/frame/treasury/src/lib.rs
Lines 295 to 296 in 596f377
substrate/frame/indices/src/lib.rs
Line 79 in 596f377
substrate/frame/proxy/src/lib.rs
Lines 157 to 160 in 596f377
Missing bookkeeping:
substrate/frame/elections-phragmen/src/lib.rs
Line 828 in 596f377
substrate/frame/elections-phragmen/src/lib.rs
Line 581 in 596f377
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
Activity
xlc commentedon Oct 2, 2020
Take this account for example (picked randomly)
https://polkascan.io/kusama/account/DwFd1YbZD2cZjox1CrsdDXFVsnSY8Fw2YWgcVgeaxrvwYfv#transactions
Reserved 0.05 KSM to
electionsPhragmen.vote
, the currently theVotingBond
is0.00833
. This means0.04167
KSM is inaccessible anymore.kianenigma commentedon Oct 2, 2020
+1
Accounts that technically lost some money due to this bug can and should be fixed through governance.
And the elections module will transition to bookkeeping in this PR #7040
kianenigma commentedon Oct 2, 2020
Would be good to sweep and clean these incidents before they get too old.
kianenigma commentedon Oct 12, 2020
@xlc I want to move on with the above PR, but if the issue that you named has happened, I should clean that first. Are you sure the voting bond has changed in kusama? it seem to be 5 * some power of ten even now:
https://github.com/paritytech/polkadot/blob/15ba4efdab9e228797cafb817753ae38fa1114c7/runtime/kusama/src/lib.rs#L457
xlc commentedon Oct 12, 2020
This is the change reduce all the fees on Kusama https://github.com/paritytech/polkadot/pull/1252/files#diff-50080fd40b82a07448f519b041450378R22
Use
state_getMetadata
, you can query historical metadata which includes the constants.This is on block 100
This is on a recent head
You can see the voting bond changed from
0x00743ba40b0000000000000000000000
(50000000000) to0x5293b4f0010000000000000000000000
(8333333330)kianenigma commentedon Oct 14, 2020
I'll try and prepare a scrape of the chain that includes the list of all accounts affected soon.
kianenigma commentedon Oct 19, 2020
Here are the list of accounts that need to be refunded:
This is basically a scrape of
PhragmenElection
->Voting
at715dbf4012cdca810bcb2dca507d856e3fa719f3cf072058a2be378fd3aedeeb
. Why this block? because the runtime that caused this issue was 2008. How? we check forCodeUpdated
events, and this is the block: https://polkascan.io/kusama/block/2728002. See the runtime version here and in parent.Once someone else confirms the list, I'll move forward.
jacogr commentedon Oct 19, 2020
EDIT: short explanation as to how I got to my list -
keysAt
API for all queries (it was logged, this was the right time to close it)const keys = await api.query.phragmenElection.voting.keysAt(HASH)
const conv = keys.map(({ args }) => hashing.encodeAddress(args[0))
(All in the JS console on the apps UI)
My list, 192 ids (converted to 42) -
kianenigma commentedon Dec 11, 2020
An important first step toward this is to be able to correctly de-compose the current reserved balance of each account into separate modules. We worked with @shawntabrizi on a small half-finished script to do this a while ago. I couldn't finish it because in the case of anonymous proxies and multisig accounts, it gets a bit complicated.
6 remaining items