1

I'm debugging a reverted transaction on Polygon and this is all the information I have: https://mumbai.polygonscan.com/tx/0xfa86dc4957e3a3da9298b7672b11a20ebe921854fa494dc073920c067c1e693f#internal

If I'm reading it correctly, it seems to be saying that a CREATE2 reverted. But what are some reasons why a CREATE2 can revert? I'm aware that it would revert if something already existed at the address, but this isn't the case here, as you can see from here: https://mumbai.polygonscan.com/address/0x6bb03ca906c0372f384b845bd5ce9ca4327ffbe6

Derek Chiang
  • 3,330
  • 6
  • 27
  • 34

2 Answers2

0

The linked transaction makes a message call (aka internal transaction) to contract deployed at 0x1079b7398b6efd9845c4db079e6fac8d21cf67b3.

This 0x1079b7... contract then tries to deploy a new contract on address 0x6bb03ca906c0372f384b845bd5ce9ca4327ffbe6, you can see the bytecode of the new contract for example in the Tenderly debugger.

As far as I'm aware, create2 can revert for 3 reasons:

  • Not enough gas left to perform the deployment

    • Not an issue in this case. Acording to the debugger there was ~9M gas units left and the deployment would take only ~1M gas units.
  • Deploying contract to address where another contract instance is already deployed.

    • Because you can predetermine the contract address with create2, this can happen. However not in this case either, the 0x6bb03c... address is empty, there's no contract deployed.
  • So we're left with uncaught exception during executing the constructor.

    pragma solidity ^0.8;
    
    contract MyContract {
         constructor() {
             require(false);
         }
    }
    

    A code like this fails the deployment and effectively causes the create2 code to revert.

    Unfortunately, without the new contract source code, it's hard to tell what exactly is the cause of constructor revert. Whether it's unexpected length or input params to the constructor, logical error, trying to make a call to non-existing contract, or anything else.

Petr Hejda
  • 40,554
  • 8
  • 72
  • 100
  • Hi Petr, thanks for the response. So the `0x1079b7` contract is [this one](https://github.com/eth-infinitism/account-abstraction/blob/develop/contracts/samples/SimpleWalletDeployer.sol), and `SimpleWallet` is [this one](https://github.com/eth-infinitism/account-abstraction/blob/develop/contracts/samples/SimpleWallet.sol). As you can see, the constructor pretty much does nothing, so it's unclear to me why it would be reverting. – Derek Chiang Oct 23 '22 at 00:51
  • 1
    Actually I might have found the real issue using the Tenderly link you sent earlier. So it's not actually the `CREATE2` that's reverting -- I'm reading Polygonscan wrong. Apparently just because there's a red mark next to the internal transaction doesn't mean that it's the internal transaction itself that's reverting. – Derek Chiang Oct 23 '22 at 01:57
0

It turns out that I'm misreading Polygonscan and that just because there's a red mark next to an internal transaction doesn't mean that it's the internal transaction itself that reverted; it means that the whole transaction reverted. Anyways, using the Tenderly debugger helped me identity the real bug.

Derek Chiang
  • 3,330
  • 6
  • 27
  • 34