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]: Unexpected gas prices behaviour when one of multiple gas prices is zero #17755

Closed
1 task done
migueldingli1997 opened this issue Sep 15, 2023 · 4 comments
Closed
1 task done
Labels

Comments

@migueldingli1997
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

The SDK lets us specify multiple gas prices, to give users the option to pay in one gas price or another. If one of multiple gas prices is set to zero, the assumption here is that the same reasoning applies, and the user will be able to either pay zero in the zeroed gas price, or a non-zero in any of the other gas prices.

For example: 0.025uatom,0uxyz - I expect to be able to pay zero uxyz or a non-zero amount of uatom.

What ends up happening because of the way that the gas price is parsed is that the zero coin gets removed by the sanitization applied by ParseDecCoins. This leaves us with just the non-zero token, and thus no option to not pay a fee.

Cosmos SDK Version

main

How to reproduce?

Set gas prices to any two unique tokens, one of which is zero.

@migueldingli1997 migueldingli1997 changed the title [Bug]: Unexpected gas prices behaviour [Bug]: Unexpected gas prices behaviour when one of multiple gas prices is zero Sep 15, 2023
@alexanderbez
Copy link
Contributor

Zero coins aren't valid. 0.025uatom,0uxyz isn't a valid expression. 0.025uatom is. Meaning you must may that gas price or higher.

@migueldingli1997
Copy link
Contributor Author

migueldingli1997 commented Sep 18, 2023

I understand, thanks. I just want to point out that as a user this was unexpected behaviour. I can also imagine that there is not a lot of use-cases for setting one of the gas prices to zero.

@alexanderbez
Copy link
Contributor

Can I ask why you think this is unexpected behavior?

If I proceed, for example, to use a mobile money transfer app, and that app requires a fee to use their service, the app wouldn't say "give us zero or more of this". It would either be free or it wouldn't. Similarly, it doesn't make sense to have "zero" of something. You either have it or you don't.

In the context of fees, your use case is totally valid, but that's just not the expression you'd use to describe it. Instead, what you'd say is just 0.0025uatom then your fee handler checks if fees are present (if they're not consider it a free tx) and if there are fees attached, you just check the value against the minimum.

@migueldingli1997
Copy link
Contributor Author

Yeah I guess this can be handled from the application side, perhaps by overriding the DeductFeeDecorator if this behaviour is really required. Thanks for considering it and presenting your reasoning.

@migueldingli1997 migueldingli1997 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants