-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(cheatcodes): extend usable range in assertApproxEqRel
#10758
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
feat(cheatcodes): extend usable range in assertApproxEqRel
#10758
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense! Thanks
@zerosnacks let me add an overflow test quickly, I noticed it's missing |
cc @klkvr would you mind double checking this proposed change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
Motivation
For large values, the current implementation of the cheatcode
assertApproxEqRel
overflows during calculation of the relative delta. However, using a larger type for this calculation allows to prevent overflows and use the full range ofuint256
.Solution
The calculation was modified to use
U512
for the calculation and only check that the final value for the delta fits inside auint256
(a requirement of the error type).PR Checklist