mana icon indicating copy to clipboard operation
mana copied to clipboard

Inconsistent state on storage clearing in sstore operation

Open ayrat555 opened this issue 6 years ago • 4 comments

When clearing values in any account's storage, it affects other accounts.

The problem is in Trie.remove/2 method

The problem was found while fixing the refund_CallA test. It clears storage in the call message that leaves another account's storage in a wrong state. https://github.com/poanetwork/mana/pull/230

So now we're not removing trees - https://github.com/poanetwork/mana/blob/7c9ac5385df6b8d1b1ecaf77177861f894bbe84b/apps/merkle_patricia_tree/lib/merkle_patricia_tree/trie.ex#L176. We should why state becomes inconsistent

ayrat555 avatar Jul 06 '18 08:07 ayrat555

@ayrat555 Was this addressed / fixed by #435?

hayesgm avatar Oct 29 '18 06:10 hayesgm

@hayesgm nope. Currently, we don't remove anything from the storage https://github.com/poanetwork/mana/blob/7c9ac5385df6b8d1b1ecaf77177861f894bbe84b/apps/merkle_patricia_tree/lib/merkle_patricia_tree/trie.ex#L176

ayrat555 avatar Oct 29 '18 10:10 ayrat555

What's the right solution here? What should we do?

hayesgm avatar Nov 03 '18 20:11 hayesgm

@hayesgm I think the problem is caused by the fact that we're storing all account storages in the same db so collisions occur when storage tries share the same nodes. Maybe we somehow can store them in a way that won't cause collisions.

ayrat555 avatar Nov 04 '18 09:11 ayrat555