-
Notifications
You must be signed in to change notification settings - Fork 518
Description
We have two types of gas:
WasmD Gas- the unit that is used inWasmD,WasmVM Gas- currently1 Cosmos Gas=140_000 WasmVM Gas
The test case TestLimitRecursiveQueryGas runs the following scenario:
- Translate
WasmD GastoWasmVM Gasand set the limit for the Query call, - Run WasmVM to perform and finish a recursive Query call, return the amount of
WasmVM gasused, - Translate the returned
WasmVM Gasback toWasmD Gasand subtract it from the gas limit assigned for the whole operation, - Check in WasmD if there is no gas left - panic in such case.
When we updated WasmVM to v2.2 the gas fee calculations in WasmVM has changed. We encountered the following scenario:
- Translate
WasmD GastoWasmVM Gasand set the limit for the Query call, - Run WasmVM to perform and finish a recursive Query call, return the amount of
WasmVM Gasused. This step returnedVmError::GasDepletionerror.
In the second case if we artificially increase the gas limit set for the Query operation of 1 WasmD Gas or 116_370 WasmVM Gas, the test behave the same way as in the first case i.e. the WasmVM finishes the operation and WasmD panics when theres 0 gas left.
WasmD panics when it has 0 WasmD Gas left, regardless of the fact that there was enough gas to run the whole procedure for WasmVM. In the first case WasmVM finished and returned 23_630 WasmVM Gas. After translation WasmD is left with 23_630 WasmVM Gas / 140_000 = 0.214285714 WasmD Gas. This is rounded down to 0, that's why we get panic from WasmD and not the error from WasmVM.
It seems to me that getting VmError::GasDepletion should be the only valid way to raise the RanOutOfGas panic in WasmD.