Closed bernard-wagner closed 2 years ago
good find!
@rakita wdyt about also keeping 0
values in the account storage, instead of removing them?
would this cause any side effects?
@mattsse makes sense to leave the default value. It will not disrupt anything in evm as commit
is postprocessing.
This is needed for both storage
and cache
(accounts)
@bernard-wagner Thank you, Sir
Here change in revm CacheDB, it is now aware if account was cleared(deleted) or not and storage will be removed if needed, https://github.com/bluealloy/revm/pull/140
Component
Forge, Cast, Anvil
Have you ensured that all of these are up to date?
What version of Foundry are you on?
anvil 0.1.0 (23f7db9 2022-06-08T18:32:28.171151Z)
What command(s) is the bug in?
anvil, cast run
Operating System
Linux
Describe the bug
Interesting behaviour between Anvil and cast run when using forked state. If a storage slot gets cleared, the ForkedDB will revert to using the cache and not the reset value. This is because
revm
removes the entry if the value is set to 0. ForkedDB looks for the existence of the entry to determine whether to use fork cache or in memory db.A temporary fix to test the theory:
Test scenario
This transaction should fail as there is a previous transaction in the block from the same caller that already withdraws the WETH: