0/5
--- ### Debugging with Hexadecimal Values When encountering an issue in MathMasters, it's crucial to identify where the error is originating. Typically, we start by examining the most likely sections of code, which, in this case, is the top half. Here’s how you can pinpoint the error using a hexadecimal (hex) approach. #### The Cheat Sheet: Casting to Hex 1. **Casting Decimals to Hexadecimal**: - Take the decimal value and convert it to hex. - For example, if the decimal casts to hex as "FFFF...", this indicates a full set of F’s in hexadecimal. 2. **Replacing Values**: - If the hex result is a series of F's (e.g., "FFFF"), replace the existing value with "FFFF...". - Perform this check consistently across multiple variables or segments to ensure uniformity. #### Example Debugging Steps: - **First Decimal**: Convert to hex, result is "FFFF...". Replace original value with "FFFF...". - **Second Decimal**: Repeat the process. Convert, check, and replace with "FFFF..." if necessary. - **Third Decimal**: Follow the same steps, ensuring the value aligns with expected hex output. - **Fourth Decimal**: This conversion shows "FFF2A", different from the others. This discrepancy suggests a potential error. #### Implementing the Fix: 1. **Update the Code**: - Replace the erroneous "FFF2A" with the correct "FFFF..." or appropriate value. - Update this in the MathMasters code base to ensure consistency and correctness. 2. **Verification**: - With the changes made, conduct a modular verification to see if the adjustments align with the expected outcomes from a similar, trusted module, such as Soulmate. - Use tools like Certora for running checks. Successful verification shows no errors, confirming that the issue likely resides in the modified segment. #### Final Checks and Validation: - **Review Configuration Files**: Ensure there are no additional settings or rules that might interfere with the fixed implementations. - **Rule Sanity Check**: Quick validation that no other configuration disrupts the intended behavior.
A practical guide to finding a bug in a square root function using modular verification - In this lesson, we explore the concept of modular verification and use it to locate a bug in a square root function. We will leverage the Certora tool to execute verification checks, ensuring that our code matches the intended behavior of the square root 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