echidna icon indicating copy to clipboard operation
echidna copied to clipboard

Deploying a contract to an address that's also an EOA

Open rappie opened this issue 3 years ago • 3 comments

As soon as I add an address to the sender list in echidnas config I can't deploy a Contract to that address by setting it's address in the etheno log.

Could someone take a look to see if this is something that can be fixed/added in echidna or if it's a HEVM thing or something?

It is possible to set contractAddr to an EOA address, so in theory it should be possible :smile:

Thanks.

rappie avatar Jun 14 '22 16:06 rappie

Simple test log .json file.

Make sure to test with and without the contract's address in the sender list:

sender: ["0x6Ecbe1DB9EF729CBe972C83Fb886247691Fb6beb"]

JSON:

[
  {
    "event": "AccountCreated",
    "address": "5409ed021d9299bf6814279a6a1411a7e866a631"
  },
  {
    "event": "AccountCreated",
    "address": "6ecbe1db9ef729cbe972c83fb886247691fb6beb"
  },
  {
    "event": "AccountCreated",
    "address": "e36ea790bc9d7ab70c55260c66d52b1eca985f84"
  },
  {
    "event": "AccountCreated",
    "address": "e834ec434daba538cd1b9fe1582052b880bd7e63"
  },
  {
    "event": "AccountCreated",
    "address": "78dc5d2d739606d31509c31d654056a45185ecb6"
  },
  {
    "event": "AccountCreated",
    "address": "a8dda8d7f5310e4a9e24f8eba77e091ac264f872"
  },
  {
    "event": "AccountCreated",
    "address": "06cef8e666768cc40cc78cf93d9611019ddcb628"
  },
  {
    "event": "AccountCreated",
    "address": "4404ac8bd8f9618d27ad2f1485aa1b2cfd82482d"
  },
  {
    "event": "AccountCreated",
    "address": "7457d5e02197480db681d3fdf256c7aca21bdc12"
  },
  {
    "event": "AccountCreated",
    "address": "91c987bf62d25945db517bdaa840a6c661374402"
  },
  {
    "event": "ContractCreated",
    "from": "0x5409ed021d9299bf6814279a6a1411a7e866a631",
    "contract_address": "0x6Ecbe1DB9EF729CBe972C83Fb886247691Fb6beb",
    "gas_used": "0xf4b7d",
    "gas_price": "0x4a817c800",
    "data": "0x608060405234801561001057600080fd5b50607b60016000600181526020019081526020016000208190555061024d8061003a6000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806322aacad51461005157806361bc221a1461005b5780638ada066e146100795780639b3874b114610097575b600080fd5b6100596100c7565b005b6100636100e2565b6040516100709190610156565b60405180910390f35b6100816100e8565b60405161008e9190610156565b60405180910390f35b6100b160048036038101906100ac919061011e565b6100f1565b6040516100be9190610156565b60405180910390f35b60016000808282546100d99190610171565b92505081905550565b60005481565b60008054905090565b60016020528060005260406000206000915090505481565b60008135905061011881610200565b92915050565b60006020828403121561013057600080fd5b600061013e84828501610109565b91505092915050565b610150816101c7565b82525050565b600060208201905061016b6000830184610147565b92915050565b600061017c826101c7565b9150610187836101c7565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156101bc576101bb6101d1565b5b828201905092915050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b610209816101c7565b811461021457600080fd5b5056fea26469706673582212202304195a4769d11c78dd6a66f3100632a937461ce37ca08407b6faeeb4ba967e64736f6c63430008040033",
    "value": "0x0"
  }
]

rappie avatar Jun 30 '22 13:06 rappie

Great, I can reproduce it using:

contract C {
  function f() public {
    assert(isContract(address(0x6Ecbe1DB9EF729CBe972C83Fb886247691Fb6beb)));
  }

  function isContract(address _addr) private returns (bool isContract){
    uint32 size;
    assembly {
      size := extcodesize(_addr)
    }
    return (size > 0);
  }
}

with the initialization you provided. Now is time to fix it..

gustavo-grieco avatar Jun 30 '22 13:06 gustavo-grieco

I think it is fixed in #795, please test (remember that binaries are available in the GitHub action, when that is complete)

gustavo-grieco avatar Jun 30 '22 14:06 gustavo-grieco