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]: math.LegacyDec nil values cannot be symmetrically marshaled and unmarshaled #21808

Closed
1 task done
kocubinski opened this issue Sep 18, 2024 · 2 comments
Closed
1 task done
Labels

Comments

@kocubinski
Copy link
Member

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

#21806 documents this behavior as a test. Briefly:

math.LegacyDec{}.Marshal() -> "0"
math.LegacyZeroDec.Marshal() -> "0"
math.LegacyDec{}.Unmarshal("0") -> math.LegacyZeroDec()

Thus a nil (default) valued LegacyDec is not recoverable after marshaling. Importantly, this impacts Amino JSON marshaling and signing, which must be deterministic because the two types marshal to JSON differently:

math.LegacyDec{}.MarshalJSON() -> "0"
math.LegacyZeroDec().MarshalJSON() -> "0.000000000000000000"

Cosmos SDK Version

main

How to reproduce?

see #21806

@julienrbrt
Copy link
Member

This makes me think of point 1 of #17750
-> #17613

I don't think we can fix it without being breaking (#17613 (comment))

@kocubinski
Copy link
Member Author

Yea.. those issues are pointing to the same thing. I missed them when briefly searching for existing issues (sometimes they're hard to find). At least we should document it with a test.

@julienrbrt julienrbrt mentioned this issue Sep 19, 2024
3 tasks
@julienrbrt julienrbrt closed this as not planned Won't fix, can't repro, duplicate, stale Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🥳 Done
Development

No branches or pull requests

2 participants