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
Add clippy check for overflowing arithmetic, fix existing cases #1274
Conversation
Uses `checked_` where a `Result` is returned, and `saturating_sub` where a value of 0 on overflow makes sense.
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.
I'm not 100% convinced by the approach, we can discuss it on Slack.
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.
Seeing all these saturating adds here makes me question if this is a good idea or not, I could see a transaction being crafted to trigger these saturating adds and resulting in, at best an invalid transaction, at worse a malicious one.
Fix #1238.
Uses
[workspace.lints]
to set uniform linting configuration for all our packages (see[package.lints]
).Uses
checked_
where aResult
is returned from the function already, andsaturating_sub
where a value of 0 on overflow makes sense (to avoid refactoringResult
into most of the codebase).Checklist