Skip to content

Account(storage={}) infinite loop-checks account storage over RPC #2162

@jochem-brouwer

Description

@jochem-brouwer

What was wrong?

if "storage" in account.model_fields_set:
for key, value in account.storage.items():
storage_value = eth_rpc.get_storage_at(
address, Hash(key)
)
assert storage_value == value, (
f"Storage value at {key} of {address} is "
f"{storage_value}, expected {value}."
)

How can it be fixed?

The tests written in the tooling often contain checks for storage which inspect specific fields. The other fields, by default, can have any value, and allows to write focused tests where it is clear what is actually being tested. This raises the question what Account(storage={}) is supposed to be. If one key/value is added then only that key/value is checked to contain the correct value, the other storage keys do not matter. Therefore I think that Account(storage={}) is therefore meaningless as it allows all key/values in the storage. If a test writer explicitly wants to test that the storage is empty, then I believe a specific flag for that should be added (just like Account.NONEXISTENT -> Storage.EMPTY for instance).

To test this over RPC (via execute remote) it is not feasible to verify all keys are empty. It is also not possible to directly get the state root of an account. However, via eth_getProof we can get the relevant fields. For empty storage we can check if the root of the account is indeed the empty storage root. Note that getProof is not available for all RPCs and the format also depends on the trie type, so it is not super steady, but I believe this is the only way to check for empty storage over the eth_ RPC.

Additional Context

Currently the empty storage account will fetch all storage keys (2^256 keys) over RPC to verify if they are empty, i.e. the test will never pass as this check stalls the process.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: this is a bug, deviation, or other problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions