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

Inconsistent Limit in InfiniteGasMeter #9577

Closed
4 tasks
ethanfrey opened this issue Jun 24, 2021 · 3 comments · Fixed by #9651
Closed
4 tasks

Inconsistent Limit in InfiniteGasMeter #9577

ethanfrey opened this issue Jun 24, 2021 · 3 comments · Fixed by #9651
Assignees
Labels
C: gas T:Bug T: State Machine Breaking State machine breaking changes (impacts consensus).

Comments

@ethanfrey
Copy link
Contributor

Summary of Bug

Limit() on InfiniteGasMeter always returns 0: https://github.com/cosmos/cosmos-sdk/blob/master/store/types/gas.go#L148-L150

This is not true and causes issues in code that check for Limit before performing an action: CosmWasm/wasmd#539 (review)

The main point being there is no clear way to determine how much gas is left in the meter. Maybe you could expose a separate function to return that info. But, just returning max.Uint64 for infiniteGasMeter.Limit() would be a good start.

Version

v0.42.6, master, probably every other known version

Steps to Reproduce


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@fedekunze
Copy link
Collaborator

Agree that this is very confusing, I guess that's why the ConsumedToLimit function was implemented in the first place

@ethanfrey
Copy link
Contributor Author

That says how much was consumed, not how much was left.

We need to use this remaining gas as a limit in wasmer for the smart contracts. And have to special case limit == 0 only as we know the implementation of InfiniteGasMeter, which is fragile

@clevinson clevinson added this to the v0.44 milestone Jun 25, 2021
@clevinson clevinson added Status: Backlog T: State Machine Breaking State machine breaking changes (impacts consensus). labels Jun 25, 2021
@alexanderbez
Copy link
Contributor

For the time being, can you just check the type of the gas meter and not execute calls to Limit in cases where it's an InfiniteGasMeter?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: gas T:Bug T: State Machine Breaking State machine breaking changes (impacts consensus).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants