a tool to get readable state diffs and enumerate complete contract storage
🚧 status: proof of concept 🚧
storage-layout storage <contract>print all slots and valuesstorage-layout layout <txhash>print a decoded state diff
- get storage layout of a contract, which comes as one of compiler output format. here i use a modified vyper compiler with a test contract.
- get storage diff, here i use
trace_replayTransactioninstateDiffmode. this is not strictly necessary since you can get allSSTOREfromvmTrace. - extract preimages from a trace. we look for all
SHA3calls which hash two words and write downkeyandslot. - then we unwrap storage slots using preimages we have collected until we reach basic storage indexes we have in the layout. for exmaple, a
slotvalue for mapping could be among preimages, we record a path we traversed to construct nested keys. - decode abi types using metadata from contract storage layout.
how to dump the complete contract storage and print it in a readable way.
this tool can already dump the entire storage using parity_listStorageKeys, but to decode it we need to collect all preimages.
for this we can find all calls to the address using trace_filter and then vmTrace all transactions and record all preimages.
slither-read-storagecan do more advanced forward storage readingsol2umlcan draw storage layout diagrams