Building an EVM from scratch part 1 - the execution context
Building an EVM from scratch part 2 - branching instructions
Building an EVM from scratch part 3 - calldata and the function dispatcher
π©π©π©π©π©π©π©π¨β¬β¬ 108/142 instructions implemented
It all started with this tweet:
https://twitter.com/0x796/status/1615640000904691714
Talk about a nerd-snipe. As someone who wrote an EVM for fun, I didnβt consider EVM disassembly to be particularly challenging, but it turns out that this contract did indeed trick commonly used disassemblers to error out.
Weβre going to build a basic disassembler, and progressively make it better until it can reliably work on arbitrary bytecode. Along the way, I collected some guidelines that I believe every disassembler should follow to become more robust:
π Donβt interpret data as code
π Donβt interpret code as data
π Disassembling should be exactly reversible
π When in doubt, ask βwhat would the EVM do?β