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

Fix fuzz max long test #101

Merged
merged 5 commits into from
May 16, 2024
Merged

Fix fuzz max long test #101

merged 5 commits into from
May 16, 2024

Conversation

dpaiton
Copy link
Member

@dpaiton dpaiton commented May 15, 2024

Resolved Issues

Partially resolves these two:
#88
#45

Description

The fee rounding behavior was adjusted recently to more closely match solidity, but the order of operations was not exactly the same. This caused an occasional slight variation in output (usually off by 1e1), that compounded in situations where we were iteratively assessing fees such as max_long. In that case, the error would grow to as much as 1e5.

During my effort to find this bug I

  • modified some math to use the e.g. .mul_down syntax instead of * where it was sufficiently complicated to require this to easily pattern match against Solidity.
  • modified calculate_max_long to return errors instead of panic. This makes checks in the tests ugly, but that is a temporary problem until we purge the panics all-together (Improved Testing of the Rust SDK #20)
  • purged the use of traced and trace_test which is helpful for debugging but was not actively being used and can slow down tests.

Review Checklists

Please check each item before approving the pull request. While going
through the checklist, it is recommended to leave comments on items that are
referenced in the checklist to make sure that they are reviewed.

  • Testing
    • Are there new or updated unit or integration tests?
    • Do the tests cover the happy paths?
    • Do the tests cover the unhappy paths?
    • Are there an adequate number of fuzz tests to ensure that we are
      covering the full input space?
    • If matching Solidity behavior, are there differential fuzz tests that
      ensure that Rust matches Solidity?

@dpaiton dpaiton force-pushed the dpaiton/fix-fuzz-max-long branch from 398ea48 to 957e481 Compare May 15, 2024 18:19
@dpaiton dpaiton force-pushed the dpaiton/fix-fuzz-max-long branch from 957e481 to 2ace8b8 Compare May 15, 2024 22:41
@dpaiton dpaiton linked an issue May 15, 2024 that may be closed by this pull request
3 tasks
@dpaiton dpaiton removed a link to an issue May 15, 2024
3 tasks
@dpaiton dpaiton marked this pull request as ready for review May 15, 2024 23:10
@dpaiton dpaiton changed the title fix fuzz max long Fix fuzz max long test May 15, 2024
Copy link
Contributor

@sentilesdal sentilesdal left a comment

Choose a reason for hiding this comment

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

nice!

crates/hyperdrive-math/src/long/max.rs Outdated Show resolved Hide resolved
@dpaiton dpaiton enabled auto-merge (squash) May 16, 2024 02:30
@dpaiton dpaiton merged commit c28bcdd into main May 16, 2024
8 checks passed
@dpaiton dpaiton deleted the dpaiton/fix-fuzz-max-long branch May 16, 2024 02:39
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