Description
Function calls usually provide all available gas to the callee because it is extremely hard if not impossible to come up with a good estimate of how much gas the callee will need.
At he same time, this mechanism relies on actual gas costs inside the EVM and is very fragile:
The amount of gas left can be retrieved via the gas
instruction - the problem is that some gas is already spent again between this instruction and the actual call, most notably the gas for the call
instruction itself (which can even vary depending on its arguments).
The usual way to cope with this is to subtract a certain constant from the value of the gas
instruction (this constant includes the costs for performing this subtraction...).
This is of course all very fragile and means that if we ever increase the gas costs of the instructions call
, gas
, sub
or of pushing constants, we will break existing contracts.
Furthermore, sometimes some gas has to be retained by the caller because it cannot efficiently estimate how costly the call
opcode itself will be.
This is less an actual EIP but more a request for ideas about how to handle that situation.
Possibility 1: Use the special case of 2**256-1 gas to mean "all available gas". This would at least make future contracts more flexible.
Possibility 2: Change the semantics of push1 50 gas sub call
(similar for other constants) to mean "all available gas" regardless of the result of the actual computation. That should at least keep the intended semantics of existing contracts.
Activity