ethereum / hevm

symbolic EVM evaluator
https://hevm.dev
GNU Affero General Public License v3.0
229 stars 48 forks source link

Advanced Fuzzing Pipelines #69

Closed d-xo closed 1 year ago

d-xo commented 1 year ago

Just noting some ideas that @msooseth and I discussed for nice fuzzing pipelines that we could write if had an Expr -> EVM compiler.

Compiling an Expr End into EVM bytecode should be fairly simple, especially if we produce yul instead of bytecode directly. Each ITE can be an if-then-else block, and translating return / revert leaves into return / revert statements in yul shouldn't be too hard.

Concrete Evaulation vs Geth

  1. Generate a random Expr End
  2. Compile that into evm
  3. Execute both against some concrete input value and compare the result

This would test our smt encoding to make sure that it matches the concrete semantics (we could use the concrete semantics from hevm or from geth).

Symbolic Exec vs Equivalence Checker

  1. Generate random bytecode
  2. Symbolically exec to produce an Expr
  3. Compile the Expr into EVM
  4. Run the equivalence checker against both

This would test the symbolic execution engine (and Expr -> EVM compiler) against the equivalence checker.

d-xo commented 1 year ago

Actually for the first case we don't even need an Expr -> EVM compiler, we can just generate random bytecode, produce an Expr from it, and then compare both against some concrete value.

msooseth commented 1 year ago

Notes to self:

Fuzz input generators: https://github.com/MariusVanDerWijden/tx-fuzz https://github.com/MariusVanDerWijden/FuzzyVM

Runners: https://github.com/holiman/goevmlab

Branch: fuzz-msoos2

Check accuracy through geth:

Catch errors with:

Fuzzing tools:

Tracing:

msooseth commented 1 year ago

This has been implemented in Tracing.hs, closing.