Closed rllola closed 1 month ago
I might have solve it... I realized that the account status for this specific contract is StorageCleared
so I guess it indicates me that when calculating the storage root I should just take null...
I ended up having the same state root when doing this so I guess I can close this issue.
Reopening because it didn't work actually... Other account with StorageCleared
status return the wrong storage hash...
Revm is part of Reth so you can assume it is working correctly.
SELFDESTRUCT just marks an account for destruction, selfdestruction is applied AFTER transaction finishes its execution. You can check State that is used in Reth: https://github.com/bluealloy/revm/tree/main/crates/revm/src/db/states Or simple example in CacheDb: https://github.com/bluealloy/revm/blob/c2a04cbb2ba5862e56212caa6ceca2c11bcac3d0/crates/revm/src/db/in_memory_db.rs#L136-L142
Revm is part of Reth so you can assume it is working correctly. That was my thought too.
I am trying to calculate the the storage root after I did the commit indeed.
The only difference I get is the storage for 0xf9c2a99482823c30062ded531e049163034273c2
contract which appears with this transaction (https://etherscan.io/tx/0xe9b2d3e8a2bc996a1c7742de825fdae2466ae783ce53484304efffe304ff232d#statechange)
Using JSON-RPC or Etherscan it is telling me that there is nothing in the storage trie for this smart contract. But using revm it is telling me there is. I have no doubt I am doing something wrong but I still don't know what I am missing.
When calculating the state root for this block I just ignore the storage for 0xf9c2a99482823c30062ded531e049163034273c2
and I have the correct root. I just don't know why.
Could it be some early weird rule in Ethereum that I need to consider ?
I have looked into reth code base and I have found this filter in case the value is 0.
Could it be this ?
Adding this weird rule when calculating storage root is working. I am no sure why this is being isgnored when the value is 0 specifically ?
Thanks @rakita for your time. Closing this for good now.
I am trying to replay all the blocks of mainnet using revm. I have been stuck at blocks 49157 as their state root calculated is different from the one in the block header.
After some digging I noticed a difference in the storage trie for the smart contract created in the only transaction in this block.
With revm, we have 1 storage slot used
using a JSON-RPC endpoint, it indicates it have none.
The smart contract has apparently self-destructed. My understanding is that it remove all the stored values when it happens. I know someone already tried to use revm to replay all the blocks so could it be that I am missing something ?
I have instanciated the evm like this
Cheers