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

One stable math fuzz test #1197

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

elshan-eth
Copy link
Contributor

Description

Added a fuzz test for stable matht to check that computeInvariant(balances) <= computeInvariant(balances + deltas)

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Dependency changes
  • Code refactor / cleanup
  • Optimization: [ ] gas / [ ] bytecode
  • Documentation or wording changes
  • Other

Checklist:

  • The diff is legible and has no extraneous changes
  • Complex code has been commented, including external interfaces
  • Tests have 100% code coverage
  • The base branch is either main, or there's a description of how to merge

Issue Resolution

Copy link
Contributor

@jubeira jubeira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is looking good!

Let's just do the same test focusing on a smaller delta range, which is more prone to have issues. If balances increase too much, chances are the invariant will also increase significantly and that's also tested elsewhere; the question is more about possible manipulations around small deltas (even though in practice they'd hit other guardrails).

pkg/solidity-utils/test/foundry/StableMath.t.sol Outdated Show resolved Hide resolved
Copy link
Contributor

@jubeira jubeira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, good finding! This makes sense.

We can now try a stateful test that checks the rate in a separate PR.

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.

2 participants