1

I have this code in a proxy fallback:

assembly {
    calldatacopy(mload(0x40), 0, calldatasize())
    let result := delegatecall(gas(), destination, mload(0x40), calldatasize(), mload(0x40), 0)
    returndatacopy(mload(0x40), 0, returndatasize())
    switch result
    case 1 { return(mload(0x40), returndatasize()) }
    default { revert(mload(0x40), returndatasize()) }
}

The problem arises when destination is a zero address (0x0000000000000000000000). delegatecall goes through, returns 1, then hits case 1 with return data completely empty which triggers ... did it run out of gas error (which is not really related to the question).

I have just swapped to newest Hardhat and web3 (v1.6.1) from Ganache where this would hit default case and revert. Is there something I do not know or was changed recently?

Whytecrowe
  • 31
  • 3
  • 3
    You can call delegatecall on external account, check this: https://ethereum.stackexchange.com/questions/17406/can-i-use-delegatecall-in-a-transaction I think you can check whether address is contract. – Peter Lai Dec 01 '21 at 03:53
  • @PeterLai yeah, security team removed the address check. it's too expensive and not that much of a problem. however, I think a check for 0 address does need to happen... – Whytecrowe Dec 01 '21 at 04:12

0 Answers0