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

Add overflow checks for exponentiation when the base and power are both unknown #2074

Open
iamdefinitelyahuman opened this issue Jun 30, 2020 · 0 comments

Comments

@iamdefinitelyahuman
Copy link
Contributor

Per #2072, we are performing overflow checks on exponentiation as long as either the base or power is a literal value. We still need to implement these checks in the case where both values are unknown at compile time.

Took a hand at (3) using the link @michwill sent: https://github.com/fubuloubu/integer-exponential. Looks like it takes 10994 gas in the uint256 case, and 9575 gas in the int128 case (one less round required). The calls normally take 558 gas and 752 gas respectively (no idea why uint256 is cheaper here), so about a 10x-20x markup for this most general case

Originally posted by @fubuloubu in #1684 (comment)

The arithmetic leg-work is done here, we just need to implement and test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant