Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect state transition handling #395

Merged
merged 1 commit into from
Oct 23, 2024
Merged

Conversation

johntaiko
Copy link
Contributor

Background

We had an issue of block 380550 on our Mainnet when processing stress test.

2024-10-13T08:58:58.429218Z ERROR raiko_host::proof: There was an error with the core: There was an error with a guest prover: ProverError::GuestError `Condition failed: `self.input.block.state_ro
ot == state_root``

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.
image
And there are two transactions related to it in block 380550,
image

no role value
969 to 0 ETH
977 to 0.0001 ETH

Because the first one received zero ETH, so it's nonce and balance weren't changed. But, Revm marked it as Destroyed.
image

image

(LoadedEmptyEIP161 → Destroyed)

And the second one let the status convert from Destroyed to DestroyedChanged
image

Revm has a function to tell people whether the Account is destroyed.
image

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

  1. I thought the issue was due to EVM execution differences, so I compared the EVM execution traces of Geth and Reth to troubleshoot, but ultimately, they were identical.
  2. I troubleshoot the issue by comparing state changes after each transaction execution in EVM. They were also the same.
  3. Finally, I tracked the state changes in the Raiko's MemDB, and discovered the differences.

Future plan

Replace it with Raiko-in-Reth project. Raiko added an extra state transformation. It may be more prone to bugs.

image

(Account status from Revm)

image

(Account status from Raiko)

@johntaiko johntaiko added this pull request to the merge queue Oct 23, 2024
Merged via the queue into main with commit 6d1f3ae Oct 23, 2024
15 of 16 checks passed
@johntaiko johntaiko deleted the fix/state_convert branch October 23, 2024 07:58
@Brechtpd
Copy link
Contributor

MPT will be our end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants