runevm icon indicating copy to clipboard operation
runevm copied to clipboard

Interface metering and source of truth for gas left

Open s1na opened this issue 5 years ago • 2 comments

In runevm there are two sources of truth for the remaining gas during a transaction. One stored by the host, and one by parity's interpreter.

This would be no problem if runevm were to meter everything and only do a consumeGas at the end to let the host know how much gas it has spent. But some hosts (e.g. hera) meter EEI methods themselves, which means the gas costs stored by the interpreter and the host diverges.

I was wondering what others think about these alternatives, and whether there are better approaches I'm not seeing:

  • Disable interface metering in hosts (e.g. add a flag to hera for this), add the methods mentioned in https://github.com/ewasm/design/issues/138 to the EEI, and do complete metering in runevm.
  • Keep interface metering in hosts and to keep the gas costs in sync (necessary for e.g. EIP150):
    • do a consumeGas after instructions which don't call an EEI method
    • do a getGasLeft after instructions which do call an EEI method

s1na avatar Apr 10 '19 13:04 s1na

Hera has an option to disable metering entirely. That was meant to be used with evm2wasm or runevm. In that case everything should be metered by runevm.

axic avatar Apr 11 '19 01:04 axic

Probably the best approach is to also make it optional in runevm for now.

axic avatar Apr 11 '19 01:04 axic