Building on the concept of invariant tests, I've developed my own unique approach to auditing smart contracts, which I term "invariant-based auditing." This method shares a philosophical lineage with invariant testing but diverges in its execution—opting for a manual, rather than automated, approach.
How Does It Work?
The process of invariant-based auditing unfolds in a pretty structured manner:
1. Define all invariants for the contract:
The first step involves identifying and clearly defining all the invariants pertinent to the specific contract under scrutiny. These invariants represent the core principles or conditions that must remain constant, regardless of the contract's state transitions.
2. Manual Review: Functions and Transitions:
Next, I undertake a thorough manual review of all functions within the contract, along with their corresponding state transitions. This step is crucial for manually ensuring that the identified invariants hold across all possible scenarios.
3. In-Depth Variable and State Change Analysis:
The final step involves a detailed examination of each state variable, specifically looking for any changes in status. During this phase, I also perform a meticulous check of the invariants against these state changes to ensure they consistently hold true.
Why Choose a Manual Approach?
You might wonder why I prefer a manual approach to invariant-based auditing over automatic tests. The answer lies in the depth of understanding and insight gained through this hands-on process. Unlike automated tests, which can efficiently cover a broad range of scenarios, the manual process allows for an unparalleled depth of engagement with the codebase. This deep dive facilitates a more nuanced comprehension of the contract's intricacies and potential flaws, enabling me to uncover subtle issues that automatic tests might overlook.
This is just one very specific step in my overall auditing process, time allocation is around 5-10% of the overall engagement.
How Does It Work?
The process of invariant-based auditing unfolds in a pretty structured manner:
1. Define all invariants for the contract:
The first step involves identifying and clearly defining all the invariants pertinent to the specific contract under scrutiny. These invariants represent the core principles or conditions that must remain constant, regardless of the contract's state transitions.
2. Manual Review: Functions and Transitions:
Next, I undertake a thorough manual review of all functions within the contract, along with their corresponding state transitions. This step is crucial for manually ensuring that the identified invariants hold across all possible scenarios.
3. In-Depth Variable and State Change Analysis:
The final step involves a detailed examination of each state variable, specifically looking for any changes in status. During this phase, I also perform a meticulous check of the invariants against these state changes to ensure they consistently hold true.
Why Choose a Manual Approach?
You might wonder why I prefer a manual approach to invariant-based auditing over automatic tests. The answer lies in the depth of understanding and insight gained through this hands-on process. Unlike automated tests, which can efficiently cover a broad range of scenarios, the manual process allows for an unparalleled depth of engagement with the codebase. This deep dive facilitates a more nuanced comprehension of the contract's intricacies and potential flaws, enabling me to uncover subtle issues that automatic tests might overlook.
This is just one very specific step in my overall auditing process, time allocation is around 5-10% of the overall engagement.
![](https://static.tildacdn.com/tild3966-3366-4236-b166-353733386435/yDeNNxdVuz-F0AbnWYEt.jpg)