-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
fix(math)!: make LegacyDec zero values marshaled equal #17613
Conversation
This comment has been minimized.
This comment has been minimized.
Later on, please backport it to v0.47 |
bz, _ := empty.MarshalText() | ||
nilJSON, _ = json.Marshal(string(bz)) | ||
empty := LegacyNewDec(0) | ||
nilJSON, _ = empty.MarshalJSON() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense, aligns more with our migration to math and cleaning up code
I have some doubts wether or not we can backport this (although I don't think we use this marshalling for state anywhere), to avoid delaying your work I'd suggest you define all the Dec fields, at least for now. |
I guess you do, because this is v0.47 where we found the bug
yes, this is current workaround but we would like to not force our users to set fields which are not required |
We cannot backport it for the reason Facu mentioned and the issue is worse than that actually because Math is actually its own go mod (not the fix but the deployment). Given that old chains/sdk version can use math and that it can be state breaking; I do not think we can fix this in math/v1. |
I don't really understand the reason because @facundomedica didn't explain it, despite saying that it might not be possible. From my perspective, the case is really simple. Somewhere in Cosmos SDK v0.47, or inside its dependencies, there is a bug causing wrong serialization of |
There is anyway no backport needed as math is tracked separately from the Cosmos SDK releases. See the math/CHANGELOG.md. The issue is that if this bug is relied upon in the state machine, then that is a state machine breaking change to fix the behavior, which cannot be introduced in patch releases. Bugs that are state machine breaking, unless critical, are fixed in the next major version. |
@julienrbrt Thanks for explanation, now I see your point. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking this until we discuss about deployment.
As discussed in our standup, we will not address this issue in math v1. Correct me if I am wrong @facundomedica |
@julienrbrt @facundomedica Could you elaborate more, on why you made this decision? It seems weird that bugs are not fixed even when you know how to fix them. |
The issue is the deployment of such bug fix. We have tracked the bug in a separate issue, and we will fix it in a breaking version of math. Given than math is its own go.mod, feel free to fork it, and use it in your chain if you are sure this won't cause for you any state break. |
Description
Would like to get comments regarding why this was like this in the first place and if it's something we should fix or not.
The issue was that
MarshalJSON(LegacyDec{}) != MarshalJSON(LegacyNewDec(0))
as one produces"0"
and the other one"0.00000..."
.Closes: #17606
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
make lint
andmake test
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change