Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

create2 return 0x0 inconsistent with other chains #143

Closed
gpBlockchain opened this issue Apr 12, 2022 · 2 comments
Closed

create2 return 0x0 inconsistent with other chains #143

gpBlockchain opened this issue Apr 12, 2022 · 2 comments
Assignees

Comments

@gpBlockchain
Copy link
Collaborator

gpBlockchain commented Apr 12, 2022

env: https://godwoken-testnet-web3-v1-rpc.ckbapp.dev/

Transaction execution failed because create2 returned 0x0

step

  1. deploy contract
  2. invoke deploy method(contains create2)

code

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/mocks/Create2Impl.sol

invoke method
function deploy(
        uint256 value,
        bytes32 salt,
        bytes memory code
    ) public {
        Create2.deploy(value, salt, code);
    }
function deploy(
        uint256 amount,
        bytes32 salt,
        bytes memory bytecode
    ) internal returns (address) {
        address addr;
        require(address(this).balance >= amount, "Create2: insufficient balance");
        require(bytecode.length != 0, "Create2: bytecode length is zero");
        assembly {
            addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
        }
        require(addr != address(0), "Create2: Failed on deploy");
        return addr;
    }

test script

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/7392d8373873bed5da9ac9a97811d709f8c5ffbb/test/utils/Create2.test.js#L51

exec result

hardhat

exec pass

bsc

pass

https://testnet.bscscan.com/tx/0x4652964b7a2f7b938e1cd2992fd9e038357f5a1b6dc9c0987ae9f85af54f201a
https://testnet.bscscan.com/tx/0xf771011593d23946e866ed856c2e141209a1ce845ac71626eaa602d05aff8cef

godwoken

     Transaction has been reverted by the EVM:
{
  "transactionHash": "0x3d30ac45336c6732349dea5aa329fbe54f969b08286cf28c41e80b7a85b35e38",
  "blockHash": "0x33481367a4c0bcb69ce3e82d19bbae7338f2901c3d9a0add1ad238a2262b1cbd",
  "blockNumber": 81433,
  "transactionIndex": 0,
  "gasUsed": 125919,
  "cumulativeGasUsed": 125919,
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "logs": [],
  "contractAddress": null,
  "status": false,
  "from": "0x0000000000000000000000000000000000000000",
  "to": null,
  "failed_reason": {
    "status_code": "0x2",
    "status_type": "REVERT",
    "message": "Create2: Failed on deploy"
  }
}

@magicalne
Copy link
Contributor

There are two problems in this case.

We should set the gas limit in the config file like below.

gw_devnet_v1: {
      url: `http://localhost:8024`,
      accounts: [`0x${PRIVATE_KEY}`, `0x${PRIVATE_KEY2}`],
      gas: 1000000000000
}

the decimal

This case transfers 2 ether to the contract account. That will cause an insufficient balance error. This case will pass if we update to a smaller one, like const deposit = '20000';.

@magicalne
Copy link
Contributor

Confirm this was fix in #146.

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

No branches or pull requests

2 participants