VIP: Implement `EXTCODESIZE` check for `raw_call`
Simple Summary
Add a new kwarg is_contract to raw_call that performs an EXTCODESIZE check for the to address. By default, this is False. Also, we need to highlight that this check will return False for a to address in construction.
Motivation
Generally, the low-level functions call, delegatecall and staticcall return true as their first return value if the account called is non-existent, as part of the design of the EVM. For certain use cases, it could be useful to enforce that the called to address is checked for existing code, and reverted if this requirement is not met.
Currently, if I would like to ensure such a check I could use the address member is_contract to do so:
addr: address = to
if (to.is_contract):
raw_call(to, ...)
I think a built-in kwarg for raw_call is much cleaner.
Specification
raw_call(to: address, data: Bytes, max_outsize: int = 0, gas: uint256 = gasLeft,
value: uint256 = 0, is_delegate_call: bool = False, is_static_call: bool = False,
revert_on_failure: bool = True, is_contract: bool = False)→ Bytes[max_outsize]
Backwards Compatibility
No issues known since we set the default to False.
Dependencies
No known dependencies.
References
Not that I'm aware of.
Copyright
Copyright and related rights waived via CC0.