Skip to content

Incomplete EVM Support #1838

@f0rki

Description

@f0rki

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    EVMArchoutdated-moduleIssue due to an outdated arch module

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions