Repository navigation
Conversation
CacheDB::get_storage reads an uncached slot of an account cached as absent as zero without asking its database. A database can hold storage for an account it reports as absent, such as a development node that loads empty accounts as absent under EIP-161 but keeps storage set on them, and code delegated to that account by EIP-7702 reads it. Anvil read zero there, while revm reads the database. Add DynDatabase::has_storage_for_absent_accounts, false by default. When the backing database returns true, only a storage wipe short-circuits the read. Deleting an account already wipes its storage, and remove_account_storage now leaves a wipe marker on an account cached as absent so its reads stay zero. Other databases keep the short-circuit and do no extra reads. Co-authored-by: Mablr <59505383+mablr@users.noreply.github.com>
mablr
requested review from
DaniPopes,
mattsse,
onbjerg and
rakita
as code owners
November 20, 2026 17:21
DbStats and a nested CacheDB now forward has_storage_for_absent_accounts. remove_account_storage keeps a wipe only when it drops one on an absent account, so an opted-in database still serves storage of an account it reports as absent until a committed deletion wipes it.
mattsse
approved these changes
Nov 21, 2026
mattsse
left a comment
Member
There was a problem hiding this comment.
LGTM with the pushed fix: DbStats and nested CacheDB now forward has_storage_for_absent_accounts, the backing database is only asked when the account is cached absent, and remove_account_storage keeps a wipe only for an absent account (e.g. after a committed selfdestruct). Covered by the updated test.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
CacheDB::get_storagereads an uncached slot of an account cached as absent as zero without asking its backing database. A database can hold storage for an account it reports as absent: Anvil loads empty accounts as absent under EIP-161 but keeps storage set on them withanvil_setStorageAtor astateDiffoverride. Code delegated to such an account by an EIP-7702 authorization in the same transaction then read zero, while revm read the stored value.This adds
DynDatabase::has_storage_for_absent_accounts,falseby default. When the backing database returnstrue, only a storage wipe short-circuits the read. Deleting an account already wipes its storage, andremove_account_storagekeeps that wipe on an account cached as absent, so its reads stay zero.DbStatsandCacheDBforward the opt-in to the database they wrap. Databases that don't opt in keep the short-circuit and do no extra backing reads, which matters for RPC-backed databases.Foundry opts in from Anvil's
EvmDb, returningtruefrom Spurious Dragon on. With that change, Anvil's results for the four repro scenarios (twoeth_calls with astateDiff, and two sponsored 7702 transactions overanvil_setStorageAt) match pre-migration Foundry exactly, including gas used.