-
-
Notifications
You must be signed in to change notification settings - Fork 804
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 SafeMath to num
type
#475
Comments
Safemath is a pretty easy thing, basically just assertions that the math won't overflow before you do the math e.g. It's more a strategic issue to me. Do we want to enforce all math to be safe math, therefore adding extra assertion code and costing extra gas? I believe for Viper that answer is yes, but I wanted to clarify this point. |
Also this is adding runtime errors that don't have to do with out of gas errors, and therefore hard to track (without an error log) Speaking of error logs, what do you think about a native Viper error log on all contracts? |
Related to error logs, if cond:
logs.Error('AssertionError', ...)
throw |
@fubuloubu I think everything being overflow / underflow is worth the extra gas, given that so far we've been prioritizing trying to prioritize safety everywhere so far. |
@DavidKnott @fubuloubu I believe this has been implemented? |
I think so In the future we can run optimizations that can formally verify SafeMath as unnecessary and remove it for gas savings. Wayyyy down the line though. |
Re-opening as the above test case still fails. |
|
Safety everywhere indeed! |
Yip exactly! Vyper's main goal is to make it maximally difficult to introduce insecure code 😉 and to focus on auditable / readable code. |
💯 |
What's your issue about?
num
is currently able to overflow in Viper`The following code works:
How can it be fixed?
Added SafeMath checks to
num
arithmetic.Fill this in if you know how to fix it.
In
expr.py
in functiondef arithmetic(self):
Add in SafeMath LLLCute Animal Picture
The text was updated successfully, but these errors were encountered: