Discussion for Add EIP: EXTCODEHASH optimize by ZWJKFLC · Pull Request #8261 · ethereum/EIPs · GitHub
EIP-1052
was proposed to save gas fees.
In order to include the role of BALANCE
, let the codehash of the address without balance be 0x, and the codehash of the address with balance be hash(0x).
The contract address can be calculated in advance. Whether it is create or create2, it is possible that the contract is not created but has a balance. For security, you can actually only use keccak256(add.code) == keccak256(bytes(" ")) instead of add.codehash == 0, which makes the original intention of EIP-1052 meaningless.
For example, uniswap V2 uses stored addresses to determine whether a contract exists. If this EXTCODEHASH
is optimized, can save a huge amount of gas.
If someone uses a codehash of 0x to determine whether a contract has been created, due to intuition and the lack of details in many documents, they will not think that the codehash of an address with a balance will change from 0x to hash (0x). If someone maliciously attacks at this time, it will cause some bad effects.