feat: x/tx/signing/aminojson: Marshal sort fields#16254
Merged
Conversation
69494b9 to
1f4e97c
Compare
Contributor
Author
|
Kindly cc-ing @elias-orijtech @ValarDragon |
09eadd3 to
9294068
Compare
19f9be6 to
bbb8189
Compare
Contributor
|
Can we change sdk.MustSortJson to use this then? |
Member
There should be no more need for MustSortJson. See #16062 |
aaronc
approved these changes
May 23, 2023
7460420 to
28b3a52
Compare
tac0turtle
approved these changes
May 30, 2023
Contributor
tac0turtle
left a comment
There was a problem hiding this comment.
utACK, seems some integration tests are still failing
Contributor
Author
|
Thanks @tac0turtle and @aaronc for the reviews and approvals. Sure let me take a look at the tests. |
kocubinski
reviewed
May 30, 2023
Contributor
Contributor
|
merged matts pr that fixes tests, @odeke-em if you can rebase then we can merge this |
This change gives (aminojson.Encoder).Marshal the ability to sort field names before marshalling, mimicking the outward behavior of encoding/json.Marshal and thus eliminating a long prior roundtrip that required sdk.*SortJSON which would take the produced JSON and encoding/json.Unmarshal it to an interface firstly, then encoding/json.Marshal it out to get the field names sorted. While here, this change adds an opt-out field to aminojson.EncoderOptions called "DoNotSortFields", in case one wants to preserve legacy behavior for compatibility checks/reasons. The performance benchmarks from before and after reveal improvements ```shell $ benchstat before.txt after.txt name old time/op new time/op delta AminoJSON-8 76.4µs ± 1% 61.7µs ± 2% -19.28% (p=0.000 n=9+10) name old alloc/op new alloc/op delta AminoJSON-8 15.0kB ± 0% 9.4kB ± 0% -37.28% (p=0.000 n=10+10) name old allocs/op new allocs/op delta AminoJSON-8 332 ± 0% 234 ± 0% -29.52% (p=0.000 n=10+10) ``` Fixes #2350
085ee2b to
bf4e8fe
Compare
Contributor
Author
|
Awesome and thank you @kocubinski and @tac0turtle, thank you for the reviews! Rebase done. |
12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change gives (aminojson.Encoder).Marshal the ability to sort field names before marshalling, mimicking the outward behavior of encoding/json.Marshal and thus eliminating a long prior roundtrip that required sdk.*SortJSON which would take the produced JSON and encoding/json.Unmarshal it to an interface firstly, then encoding/json.Marshal it out to get the field names sorted. While here, this change adds an opt-out field to aminojson.EncoderOptions called "DoNotSortFields", in case one wants to preserve legacy behavior for compatibility checks/reasons.
The performance benchmarks from before and after reveal improvements
Fixes #2350