1/5
--- ### Quick Recap of Certora Usage #### Using Harnesses for Formal Verification One of the key strategies we covered is the use of a "harness" to simplify the formal verification of internal functions. This involves creating a wrapper contract around the desired functionality. An example provided was our compact code base, which serves as a formal verification harness. #### Defining Variables and Rules In our code bases, it's possible to: - Define various types of variables. - Establish rules with preconditions using `require`. - Ensure consistency in variable types across the application. Certora supports a range of types that are equivalent to Solidity's types but also includes unique ones. For instance, a `uint256` differs from a `mathint` primarily because `uint256` is capped by `uint256.max`, while `mathint` can vary in size, necessitating correct conversions between them. #### Verification Using Keywords and Invariance Certora leverages the `assert` keyword, similar to other tools like Halmos or Foundry, to check the correctness of functions. Another feature discussed is the concept of "invariance," where you can define one-liners that describe properties that should always hold true within the system. When additional conditions are necessary, `preserve` blocks can be used to enforce these properties. #### Practical Verification To demonstrate the effectiveness of the discussed methods, we revisited `MathMasters.sol` and made a critical update by commenting out a specific line. This change aimed to confirm the equivalence of results and the consistency of invariants. By running the prover after this adjustment, we observed: - The `mulWadUp invariant` passing. - The rule checks passing. - An error-free environment check passing.
A comprehensive recap of Certora invariants, harness, rules, and types - This lesson covers the basics of formally verifying internal functions using Certora. It explains how to use harness to wrap and verify the functionality of a function, and how to use definitions to define different types of variables. The lesson also demonstrates how to define rules, including pre-conditions and post-conditions, and how to use invariants to ensure the properties of the system hold. Finally, the lesson shows how to perform correct conversions between different types using the assert keyword.
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