Optimizing a smart contract fuzzer
Summary: A Trail of Bits intern used GHC's Haskell profiler to find and fix two performance problems in the Echidna smart contract fuzzer, making it over six times faster. Memoizing the getBytecodeMetadata function, which was being recalculated on the same small set of contracts every execution cycle, cut runtime to under 30% of its original time, and removing the State data type in one function to avoid lazy-evaluation thunks filling the heap cut runtime to about 50% and fixed out-of-memory failures on long-running transactions.
Key Takeaway: Echidna was running over six times slower with coverage-guided fuzzing enabled, and long-running transactions such as a loop counting to one million could not be computed at all because the fuzzer ran out of memory - so the tool's ability to reach deeper contract code and surface bugs was constrained until these fixes shipped in the 2.0.0 release.
Read the original at Trail of Bits Blog ↗