Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: minimal invariant tests #195

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

test: minimal invariant tests #195

wants to merge 1 commit into from

Conversation

lekhovitsky
Copy link
Collaborator

@lekhovitsky lekhovitsky commented Mar 30, 2024

Stateful fuzzing of Gearbox is not an easy endeavour. Some actions in staking, gauge or pool contracts are fairly predictable. Most useful actions that can potentially lead to breaking important invariants are on the credit side though, and boi is it hard to fuzz those! Even verifying that a given multicall works is complicated, generating a random one that is guaranteed not to revert is nearly impossible because of all liquidity, solvency and economic security limits present in the system.

Without much hope to make fuzzer explore all the state space, this test suite's main goal's become to make us think deeply about the invariants: what are they? which ones are important? which actions can, in principle, be used to break a given invariant? After answering those questions, fuzzing in the head doesn't differ much from automated fuzzing (especially since there are no intractable math-heavy invariants).

In terms of organization, the suite consists of multiple test contracts (invariant/tests/), each implementing a different scenario of interest. Such contracts first deploy needed parts of the system (invariant/Deployer.sol) and prepare fuzz handlers (invariant/handlers/) in the setUp() function, and then pick which of existing invariants (invariant/Invariants.sol) should be asserted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant