fix: incorrect state transition handling #395
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
We had an issue of block 380550 on our Mainnet when processing stress test.
It told me, the state root of Raiko is different from Geth. My first impression is that there are differences in the modifications to Accounts during the execution of EVM. But...
Root cause
I found that there was an unexpected
account-deleted
behavior in Raiko.And there are two transactions related to it in block 380550,
Because the first one received zero ETH, so it's
nonce
andbalance
weren't changed. But, Revm marked it as Destroyed.(LoadedEmptyEIP161 → Destroyed)
And the second one let the status convert from Destroyed to DestroyedChanged
Revm has a function to tell people whether the Account is destroyed.
Raiko considered it an account-deleted action. Actually, it can't. The DestroyedChanged maybe happened in our issue.
Conclusion
The first transaction did not change the account information, no data needs to be stored, but it was marked as Destroyed by EIP161. The followed second transaction's status in the same block changed from Destroyed to DestroyedChanged. We simply assume that DestroyedChanged is what needs to be deleted.
Debug journey
Future plan
Replace it with Raiko-in-Reth project. Raiko added an extra state transformation. It may be more prone to bugs.
(Account status from Revm)
(Account status from Raiko)