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