mana-ethereum / mana

Ethereum full node implementation written in Elixir.
Other
274 stars 47 forks source link

Inconsistent state on storage clearing in sstore operation #229

Open ayrat555 opened 6 years ago

ayrat555 commented 6 years ago

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

hayesgm commented 5 years ago

@ayrat555 Was this addressed / fixed by #435?

ayrat555 commented 5 years ago

@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

hayesgm commented 5 years ago

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

ayrat555 commented 5 years ago

@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.