I am posting here to get feedback on our smart contract state analyzer and extractor tool from the Solidity community.
We are working on a tool named “SmartMuv” that can analyze and extract the complete state of a Solidity smart contract using static analysis techniques. The feature that separates it from other static analysis tools is the “Key Approximation Analysis” of mapping keys, which we perform using CFGs.
It uses ASTs to analyze the Slot Layout of the smart contract and performs “Key Approximation Analysis” on CFGs. It consists of two steps:
It is a data-flow analysis that statically determines which definitions may reach a given point in the code. During this analysis, we mark all the nodes where a key is appended/added to a mapping variable.
In backtracking, we use Reach Analysis results to reach the source of marked key variables.
We then extract the values of all the approximated mapping keys and then calculate their respective slots to extract their values from the chain.
Our tool can handle all types of variables including mapping variables, multi-dimensional arrays, and structs.
State extraction (snapshot) of smart contracts up to a certain block number.
Redeployment/upgrade of smart contracts along their existing state/data.
Migration of smart contracts along with contract data i.e. L1 to L2 or L2 to L2 migrations.
Slot Analysis of a smart contract, to get a complete storage layout of a smart contract.
We are currently implementing “Interprocedural Analysis” and “Event Analysis” to ensure we do not miss any mapping key source, and retrieve every possible value that could have been used as a mapping key.
GitHub: GitHub - WaizKhan7/SmartMuv: An EVM-compatible Solidity smart contract state analysis and extraction tool.
Publication: Storage State Analysis and Extraction of Ethereum Blockchain Smart Contracts | ACM Transactions on Software Engineering and Methodology