To enable this feature, Mythril builds its own smart contract database. The contract data is received from an Ethereum node over IPC or RPC (--sync-db command). This is however slow and inefficient. A much better way would be to directly access the LevelDB database of a locally installed go-ethereum node.
In this challenge, your task is to add a local geth leveldb interface to Mythril. This should be accomplished by writing a Python class capable of doing the following:
- Obtain the runtime bytecode and balance of a contract account by address;
- Access the storage of any account by address;
- Iterate through all existing contract accounts;
- Iterate through a subset of contract accounts, such as those with non-zero balance.
$ myth -d/-x/-g -a [address] # disassemble / analyze / create CFG of contract at address
$ myth —search # search all smart contracts for opcode and function patterns
$ myth --storage 0,1 # read account storage contents
Notes:States in the leveldb are represented as a Merkle patricia tree (the “trie"). The goethereum implementation can be found here:
Article about the Trie:
Related issue on the Mytrhil Github repo:
A few stack overflow posts (unfortunately not very helpful):