Differential Testing with Foundry
Solidity SummitDevconnectThu, Nov 16, 2023, 11:40 AM · 25:59
Speaker
Differential testing using the Foundry fuzzer can be utilized to ensure identical behavior between two implementations of the same contract. Developers can leverage differential fuzzing in their development workflow to transpile idiomatic Solidity into highly gas optimized contracts. We will outline the steps to replicate this development workflow, discuss common “gotchas” and workarounds, and circulate a template repo with example tests in order to empower devs to leverage this process. [detail] During the design process, developers can begin by writing their contract implementation in idiomatic Solidity, enabling quicker development and more intuitive understanding of contract functionality. Next, developers can transpile the reference implementation into a highly optimized version utilizing Yul / Assembly by leveraging `forge inspect ir` and other tools. Finally, developers can use differential fuzzing with Foundry to ensure the equality of the two implementations. The most notable example of this development process is OpenSea’s Seaport contracts.