1/5
--- #### Approach to the Function The initial step is to compare our square root function with a reliable, standard square root function. This comparison, ideally, is not performed in assembly to keep things straightforward. Interestingly, the project developers also followed this logic. They've integrated a few test square root functions within their code, choosing unit cases somewhat arbitrarily to facilitate testing. For the purposes of our discussion, we'll assume both functions are correct. The `uniswap square root` is notably easier to validate given its simplicity. We can readily verify its accuracy, thus, for now, we will trust both are implemented correctly. #### Fuzzing the Square Root As part of the development process, it's critical to include fuzz testing for these functions. Typically, if we were to run enough fuzz tests, we'd likely encounter errors. However, for demonstration, let's run a quick test using `forge test --mt`. Paste the command and execute it—our test is highly likely to pass under normal conditions. Even with modifications to extend or intensify the testing process, the outcome usually indicates that everything is functioning as expected.
A comprehensive guide to tackling the SQRT function - This lesson walks through the process of auditing a square root function by comparing different codebases and testing cases to find the most accurate and secure solution. We also learn how to utilize fuzz testing to identify any potential errors within the SQRT function.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Assembly
Writing smart contracts using Huff and Yul
Ethereum Virtual Machine OPCodes
Formal verification testing
Smart contract invariant testing
Halmos, Certora, Kontrol
Security researcher
$49,999 - $120,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Guest lecturers:
Josselin Feist
Head of Blockchain at Trail of Bits
Last updated on January 17, 2025
Solidity Developer
Assembly and Formal VerificationDuration: 30min
Duration: 4h 38min
Duration: 3h 57min
Duration: 1h 56min
Course Overview
About the course
Assembly
Writing smart contracts using Huff and Yul
Ethereum Virtual Machine OPCodes
Formal verification testing
Smart contract invariant testing
Halmos, Certora, Kontrol
Security researcher
$49,999 - $120,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Guest lecturers:
Josselin Feist
Head of Blockchain at Trail of Bits
Last updated on January 17, 2025
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar