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

NEP-141: unchecked addition and subtraction operations #75

Closed
sept-en opened this issue Dec 24, 2021 · 1 comment · Fixed by near/near-sdk-rs#830
Closed

NEP-141: unchecked addition and subtraction operations #75

sept-en opened this issue Dec 24, 2021 · 1 comment · Fixed by near/near-sdk-rs#830

Comments

@sept-en
Copy link

sept-en commented Dec 24, 2021

The fungible token standard implementation provides a set of Rust macros. The macros perform unchecked
addition, subtraction, and multiplication operations. Unchecked mathematical operations will wrap in rust if
overflow_checks are not turned on in the cargo profile.

NEAR smart contracts release profile will have overflow_checks set to true. When set to true, any overflows will cause a panic, preventing malicious attacks on the contract. So this is rather informational but still requires action to fix it.

@austinabell
Copy link
Contributor

This option does not get added when using it at a library level, which is what the standards are. Overflow checks need to be enabled on the crate you are compiling. We add the overflow-checks in the example. This is potentially a good issue for documentation, to better explain the need for this. There is a basic comment about overflow checks here, but it can be improved.

I'm going to move this issue to the docs repo, but feel free to let me know if you believe I'm incorrect about how overflow checks are applied and I'm happy to move back. I did test and the option was not applied when using on the lib.

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