I have stated this before but I want to note it again.
In general in the design of EVM I do not understand why we have things as
CODESIZE. I can’t imagine that a simple check in one of the blocks regarding
EXTCODESIZE to check if we are calling on the current address adds any significant overhead. Hence I do not see why these opcodes are not merged together in a single opcode where the gas price depends on the address you are calling on (an external address costs more gas).
I do understand that an extra opcode
SELFBALANCE is consistent with the other opcodes
CODECOPY so adding this seems reasonable. However on all existing contracts which call their own balances (which are by no doubt a significant amount of contracts) a developer would like to change the
BALANCE opcode to the new
SELFBALANCE opcode regarding this EIP - but of course this is not possible in most if not all cases.
Why can’t we add an extra clause to the
BALANCE opcode where "if
BALANCE is called on the current
ADDRESS the gas cost will be the same as
SELFBALANCE" gas cost. I would like to propose this on
CODECOPY respectively too - so maybe this would be better in another EIP.
It just does not seem reasonable to me that in the current EIP the gas cost of an opcode is increased (
BALANCE), but a new opcode is added (
SELFBALANCE) where in some situations the “old” (
BALANCE) opcode performs the exact same operation - but with more gas.
What is confusing is that in test cases it says "Test that
balance(this) costs as before, " - this implies that reading the current account balance gas cost is the same - but it does not state which opcode is used for this?