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

opcode create always return zero address if no require check #5593

Open
JeremyX2022 opened this issue Aug 10, 2024 · 1 comment
Open

opcode create always return zero address if no require check #5593

JeremyX2022 opened this issue Aug 10, 2024 · 1 comment
Assignees
Labels
status:needs-more-info There's not enough information to start working on this issue

Comments

@JeremyX2022
Copy link

JeremyX2022 commented Aug 10, 2024

Version of Hardhat

2.22.7

What happened?

    function func1(bytes memory code) public {
        address addr;
        assembly {
            addr := create(callvalue(), add(code, 0x20), mload(code))
        }
        emit Deployed(addr);
    }

    function func2(bytes memory code) public {
        address addr;
        assembly {
            addr := create(callvalue(), add(code, 0x20), mload(code))
        }
        require(addr != address(0));
        emit Deployed(addr);
    }

I'm using remix connected to a local hardhat node network.
Providing any same creation code to these 2 functions, the results are different. func1 always results address(0) while the func2 is OK.

Minimal reproduction steps

Try this code:

0x6080604052348015600f57600080fd5b506102048061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063093c3b9a1461003b57806373c3b2f914610050575b600080fd5b61004e610049366004610115565b610063565b005b61004e61005e366004610115565b6100ba565b600081516020830134f090506001600160a01b03811661008257600080fd5b6040516001600160a01b038216907ff40fcec21964ffb566044d083b4073f29f7f7929110ea19e1b3ebe375d89055e90600090a25050565b600081516020830134f06040519091506001600160a01b038216907ff40fcec21964ffb566044d083b4073f29f7f7929110ea19e1b3ebe375d89055e90600090a25050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561012757600080fd5b813567ffffffffffffffff81111561013e57600080fd5b8201601f8101841361014f57600080fd5b803567ffffffffffffffff811115610169576101696100ff565b604051601f8201601f19908116603f0116810167ffffffffffffffff81118282101715610198576101986100ff565b6040528181528282016020018610156101b057600080fd5b8160208401602083013760009181016020019190915294935050505056fea2646970667358221220703335b27726056742f3a58f7417edd792336fc3ec97b5fe28a8c277c0bdf3ca64736f6c634300081a0033

Search terms

No response

@kanej
Copy link
Member

kanej commented Sep 19, 2024

I think this is more of a Solidity question.

This seems ... odd.

The only difference I can see between the two calls is that func1 will return address(0) if there is problem in create, while func2 will revert.

@kanej kanej closed this as completed Sep 19, 2024
@kanej kanej reopened this Sep 19, 2024
@kanej kanej added status:needs-more-info There's not enough information to start working on this issue and removed status:triaging labels Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:needs-more-info There's not enough information to start working on this issue
Projects
Status: Done
Development

No branches or pull requests

3 participants