cosmos-sdk
cosmos-sdk copied to clipboard
[Bug]: `SDKGasMeter.GasConsumedToLimit` returns incorrect values
Is there an existing issue for this?
- [X] I have searched the existing issues
What happened?
SDKGasMeter's GasConsumedToLimit function returns remaining gas instead of consumed gas.
I also don't see this type used anywhere in the SDK. What is it for?
Cosmos SDK Version
main
How to reproduce?
No response
Hey! This is used in runTx, and it's run on every tx.
The implementation is the following:
// GasConsumedToLimit returns the gas limit if gas consumed is past the limit,
// otherwise it returns the consumed gas.
//
// NOTE: This behavior is only called when recovering from panic when
// BlockGasMeter consumes gas past the limit.
func (g *basicGasMeter) GasConsumedToLimit() Gas {
if g.IsPastLimit() {
return g.limit
}
return g.consumed
}
It looks correct to me, why do you think it is returning the remaining gas? Do you have an example?
We also have the function GasRemaining() btw
I am not talking about basicGasMeter. I am talking about SDKGasMeter.
I linked to the exact line in the code in my first post: https://github.com/cosmos/cosmos-sdk/blob/01abf4fbf92c72ab4d13a983e730dc006db19b27/runtime/gas.go#L65