Msg.sender.transfer runs out of gas on a payable upgradeable proxy contract

:computer: Environment

Truffle v5.1.43
Solidity 0.5.7

:memo:Details

Hello everyone! I am trying to withdraw weth on Kovan to get some Ether on my upgradeable proxy contract but the transaction runs out of gas every single time. It fails on the following line on the weth contract:

msg.sender.transfer(wad);

I am aware that sending some ether to a contract will run out of gas if there is no payable fallback function. So I added that function to my contract but no luck.

I have verified I can send Ether to my proxy instance from an EOA and that works. I must be missing something simple here but I can’t find the problem, any help would be great!

:1234: Code to reproduce

Here is a simple test proxy contract to reproduce my issue:

pragma solidity ^0.5.0;
pragma experimental ABIEncoderV2;


interface IWETH {
    function deposit()
        external
        payable;

    function withdraw(
        uint256 wad
    )
        external;
}


contract WethTest {

    function() external payable { }

    function getWrappedEthInstance() public view returns (IWETH) {
      return IWETH(0x8a18c7034aCEfD1748199a58683Ee5F22e2d4e45);
    }

    function unwrapEtherAndWithdraw(address payable _to, uint256 _withdrawalAmount)
      external
    {
      this.getWrappedEthInstance().withdraw(_withdrawalAmount);
      _to.transfer(_withdrawalAmount);
    }

}

And here is a tenderly link for a transaction that failed, you can clearly see the transaction failing after the eth is unwrapped but just when sending ether to the proxy instance:

https://dashboard.tenderly.co/tx/kovan/0x1978d3040f53170aa7e8fac67dd3f451434453ef7455d3e917b21c21e0ee91a4

1 Like

Hi @westerly,

The issue is due to the Istanbul repricing, see: OpenZeppelin upgradeable contracts affected by Istanbul hardfork

Unfortunately you will need to change how you get Ether to your upgradeable contract.

Ho right thanks much @abcoathup I missed this one!

1 Like