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

Inconsistency in Uint128 api for overflow/underflow behaviour #850

Closed
yihuang opened this issue Mar 24, 2021 · 2 comments · Fixed by #853
Closed

Inconsistency in Uint128 api for overflow/underflow behaviour #850

yihuang opened this issue Mar 24, 2021 · 2 comments · Fixed by #853
Milestone

Comments

@yihuang
Copy link
Contributor

yihuang commented Mar 24, 2021

Add use default + operator under the hood, while Sub use checked_sub.
I think it would be better to keep is consistent with rust std's behaviour:

  • default operator +/-, panic when wrapping.
  • add methods for explicit checked_*/wrapping_*/saturating_* operations.
@webmaster128
Copy link
Member

Thank you for bringing this up. Good point. I'll check with Ethan, who originally created the Underflow error case to find a way tht is consistent.

Panics in smart contracts are a bit problematic because they are very hard to debug. Your code is terminated but there is no error message or stack trace available.

@webmaster128 webmaster128 added this to the 0.14.0 milestone Mar 24, 2021
@yihuang
Copy link
Contributor Author

yihuang commented Mar 24, 2021

I think it maybe already causing overflow troubles in the example contracts like: https://github.com/CosmWasm/cosmwasm-plus/blob/master/contracts/cw20-base/src/contract.rs#L132

I guess adding the explicit methods like checked_*/wrapping_*/saturating_* is less controversial,
then we need to decide on the default behavior of the operators.

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 a pull request may close this issue.

2 participants