[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: SDKGasMeter.GasConsumedToLimit returns incorrect values #21440

Closed
1 task done
chipshort opened this issue Aug 28, 2024 · 2 comments · Fixed by #21443
Closed
1 task done

[Bug]: SDKGasMeter.GasConsumedToLimit returns incorrect values #21440

chipshort opened this issue Aug 28, 2024 · 2 comments · Fixed by #21443
Assignees
Labels

Comments

@chipshort
Copy link
Contributor

Is there an existing issue for this?

  • 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

@facundomedica
Copy link
Member

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

@facundomedica facundomedica self-assigned this Aug 28, 2024
@chipshort
Copy link
Contributor Author

I am not talking about basicGasMeter. I am talking about SDKGasMeter.
I linked to the exact line in the code in my first post:

return gm.gm.Remaining()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🥳 Done
Development

Successfully merging a pull request may close this issue.

3 participants