capstone
capstone copied to clipboard
Incomplete EVM Support
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 / 245should be disassembled asCREATE2 - Newer instructions like
SHR,SHL,SAR,SELFBALANCEand more seem to be missing.
- byte
- 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
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.-
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
modeflag that can be passed tocs_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.
-
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
- Bugs:
- Cannot get large push constants (see my PR #1231)
yeah I know that, we are planning to renew EVM during capstone 5.0-rc stage