DE
Devconnect
/Solidity Summit

Differential Testing with Foundry

Thu, Nov 16, 2023, 11:40 AM · 25:59

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.

Anna Carroll is a protocol engineer with years of experience architecting smart contracts for the EVM. Her areas of expertise include Solidity, cross-chain protocols, DAOs and governance. Throughout her time in the crypto space, Anna has worked on a range of projects including PartyBid, Nomad, Celo and Dharma. Anna graduated from Stanford with a degree in Computer Science and is now based in Berlin where she enjoys a vibrant crypto community.