I'd like to point out several issues with supporting the EVM architecture. Currently, EVM support is kind of incomplete; couple of things I noticed:
- Missing/wrong instructions:
- byte
0xf5 / 245 should be disassembled as CREATE2
- Newer instructions like
SHR, SHL, SAR, SELFBALANCE and more seem to be missing.
- Correctly disassembling EVM is kind of tricky since there are multiple versions ("hard forks" in Ethereum lingo) of the EVM instruction set. For example, at block 1 the byte
0xf5 would be disassembled as INVALID, while at block 1400000 it must be disassembled as CREATE2. The EVM version can also change the base gas cost associated with instructions (e.g., EXTCODESIZE). Different Ethereum-based block chains also use different EVM versions. Now the question is how to deal with this issue in capstone.
- pyevmasm has a mechanism to select the right version according to block number or by hard fork name. I am not sure whether this is something that can be supported via the capstone API. Maybe as a
mode flag that can be passed to cs_open?
- Fortunately, the EVM does not remove instructions. So one could just disassemble instructions according to the latest EVM spec and add the EVM version to the details struct leaving the user to deal with the EVM version issue if needed. However, this wouldn't allow for correctly computing gas costs.
- Bugs:
I'd like to point out several issues with supporting the EVM architecture. Currently, EVM support is kind of incomplete; couple of things I noticed:
0xf5 / 245should be disassembled asCREATE2SHR,SHL,SAR,SELFBALANCEand more seem to be missing.0xf5would be disassembled asINVALID, while at block 1400000 it must be disassembled asCREATE2. The EVM version can also change the base gas cost associated with instructions (e.g.,EXTCODESIZE). Different Ethereum-based block chains also use different EVM versions. Now the question is how to deal with this issue in capstone.modeflag that can be passed tocs_open?