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

Decrease CREATE2 address computation gas usage from 623 to 539 #2244

Merged
merged 2 commits into from
May 28, 2020

Conversation

k06a
Copy link
Contributor

@k06a k06a commented May 24, 2020

Small fix

@frangio
Copy link
Contributor

frangio commented May 26, 2020

Does the address cast do the necessary masking?

@k06a
Copy link
Contributor Author

k06a commented May 27, 2020

@frangio, yep, sure.

@nventuro
Copy link
Contributor

I run a small test to confirm this:

contract TestA {
    function foo(uint256 a) public pure returns (uint256) {
        address b = address(a);
        return uint256(b);
    }
}

When called with 115792089237316195423570985008687907853269984665640564039457584007913129639935 (2^255 - 1), it returns 1461501637330902918203684832716283019655932542975 (2^160 - 1).

Copy link
Contributor

@frangio frangio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. This looks good to me. Thanks!

@k06a
Copy link
Contributor Author

k06a commented May 28, 2020

@frangio 👌

@frangio frangio merged commit d418da6 into OpenZeppelin:master May 28, 2020
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 this pull request may close these issues.

3 participants