-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Labels
ConsensusConsensus related issuesConsensus related issuesaccountingAccounting-related issues (specifically the accounting crate and things related to it)Accounting-related issues (specifically the accounting crate and things related to it)storageEverything related to storage, whether it's blockchain, wallet or otherwiseEverything related to storage, whether it's blockchain, wallet or otherwise
Milestone
Description
All delegation information must be cleaned up from the database if:
- the pool is decommissioned
- the delegation balance is 0
Cleaning up means deleting Delegationid -> DelegationData entries and corresponding delegation balances.
There are 2 scenarios that lead to this:
- The pool is decommissioned and then delegation is spent;
- Delegation is spent and then the pool is decommissioned.
In #894 only the first case was covered.
The second one is more complicated to handle because of the way the db is structured right now. The only way to iterate through all delegations of a particular pool is to use PoSAccountingView::get_pool_delegations_shares, but if the balance is 0 the shares are no longer present and we cannot easily get all DelegationId of a pool.
There are 2 possible solutions:
- Keep zero values for delegation balances. This way
get_pool_delegations_shareswould return all delegations even with empty balances. The downside of this approach is that it requires storing useless data and changing low-level logic of theaccountingcrate where values are merged. - Change the schema of the db. Instead of having following maps:
DelegationId->DelegationDataDelegationId->Amount- (
PoolId,DelegationId) ->Amount
we could use something like: DelegationId->DelegationDataDelegationId->AmountPoolId-> Vec[DelegationId]
which will make manipulations and access more complex.
Metadata
Metadata
Assignees
Labels
ConsensusConsensus related issuesConsensus related issuesaccountingAccounting-related issues (specifically the accounting crate and things related to it)Accounting-related issues (specifically the accounting crate and things related to it)storageEverything related to storage, whether it's blockchain, wallet or otherwiseEverything related to storage, whether it's blockchain, wallet or otherwise