Hi there, some points which are not mentioned in the EIP, which I want to note based upon the current Geth implementation.
They are either not mentioned, or they are not consistent, so I have some suggestions. But before opening a PR to the EIP to fix these, I’d rather discuss them first.
- If current gas limit is less than the base fee of an opcode, or the memory expansion overflows, then the reported gas is the base fee (is the base fee of each operation defined unambiguously?). Note the defer function which handles these errors.
- If an invalid opcode is reached, the previous gas cost is reported. (cost variable is not updated)
- If any calculation of the dynamic gas part of an opcode runs into an error (stack underflow, out of gas, etc.) then the dynamic gas part will return
0, and thus the reported gas for that step is still the base fee. - For
*CALL*opcodes, the gas cost is the dynamic gas cost + base fee of the call, but this is added to the gas sent to the next call frame (so the calculated gas limit of the call) - However, for
CREATE*opcodes, the gas supplied to the next frame is not added to the base fee + dynamic cost of the operation.
Discussion
- Should be added to the EIP
- This is inconsistent. Since invalid operations consume all gas, the cost of this operation is thus the current gas left.
- I am not sure here, since these errors consume all gas, is this inconsistent? I think it would make more sense to also report “consume all gas” here as cost, instead of just reporting the base fee.
- This should be added to the EIP. This makes sense; this gas is sent to the next call frame and could thus all be consumed. At this point it is unknown how much it will cost in the end, but at this point we don’t care.
- This is not very consistent with (4), I’d say this should also report the gas limit that is sent to the next frame (so 63/64 of current gas left in almost all forks, or the 100% of the gas limit in historical forks)