Explore the series

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?”