Open jangko opened 4 years ago
Regarding contract code:
The access key could be prefixed by the account address which would help to manage deleting an account + related data.
But this only solves half of the problem as it leaves the database with an inconsistent state. The problem occurs if an account is reverted when the MPT ledger database is rolled back to an earlier state. Then the account exists but the contract code data have gone for good.
So the contract code should be part of the ledger which kicks the can down the road. For a single state MPT ledger DB this would then be managed with the state.
Regarding storage data:
according to EIP161, empty accounts shall be removed after transaction execution.
current implementation: empty accounts are removed, but the contract code and storage trie are not removed.
but removing those contract code and storage trie is tricky. two or more accounts might be share the same contract code or share the same storage trie.
related issue: status-im/nim-eth#9.