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

feat: add deterministic proto JSON marshaler (WIP) #13187

Closed
wants to merge 8 commits into from

Conversation

aaronc
Copy link
Member

@aaronc aaronc commented Sep 7, 2022

Description

Started pulling some code from https://github.com/cosmos/cosmos-sdk/tree/main/orm/internal/stablejson into its own package and filling in pieces I was missing before. Ref #12994 (comment)


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...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

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...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@codecov
Copy link

codecov bot commented Sep 7, 2022

Codecov Report

Merging #13187 (fb2cba3) into main (4fe7797) will decrease coverage by 2.14%.
The diff coverage is 66.02%.

❗ Current head fb2cba3 differs from pull request most recent head a6777c1. Consider uploading reports for the commit a6777c1 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #13187      +/-   ##
==========================================
- Coverage   55.87%   53.73%   -2.15%     
==========================================
  Files         646      653       +7     
  Lines       54895    55407     +512     
==========================================
- Hits        30675    29773     -902     
- Misses      21762    23240    +1478     
+ Partials     2458     2394      -64     
Impacted Files Coverage Δ
baseapp/abci.go 67.01% <0.00%> (+2.59%) ⬆️
baseapp/baseapp.go 77.93% <ø> (+1.06%) ⬆️
baseapp/options.go 69.23% <ø> (+0.71%) ⬆️
client/cmd.go 57.73% <0.00%> (ø)
client/context.go 54.49% <0.00%> (-1.79%) ⬇️
client/flags/flags.go 19.35% <0.00%> (-0.32%) ⬇️
client/rpc/status.go 66.66% <ø> (ø)
client/utils.go 34.92% <0.00%> (ø)
crypto/keys/secp256k1/secp256k1.go 88.63% <ø> (ø)
server/config/config.go 38.00% <ø> (-1.59%) ⬇️
... and 173 more

@@ -0,0 +1,64 @@
package stablejson
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you quickly tldr this?

Things like this was part of the reason moving away from amino. We didnt want to maintain our own encoding.

Copy link
Member Author

@aaronc aaronc Sep 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My goal here is not to change the protojson encoding. I just want something deterministic. I needed it for the orm and now for typed events (not sure determinism is 100% necessary but feel better with it than without). The existing protojson implementations are explicitly non deterministic.

There is a separate convo to change bytes encoding to hex. I don't actually agree. I think we should stick with the standard. But that's a separate matter.

@aaronc
Copy link
Member Author

aaronc commented Sep 8, 2022

@marbar3778 @AmauryM so was the conclusion we should move this to the cosmos-proto repo? Should the amino json support live there too?

@tac0turtle
Copy link
Member

tac0turtle commented Sep 8, 2022

that makes more sense to me

@amaury1093
Copy link
Contributor

amaury1093 commented Sep 8, 2022

Should the amino json support live there too?

Not sure if that's possible, but I think stablejson should be in cosmos-proto, but the amino part in the SDK. I'm not sure it should be exposed to anyone else apart from the SDK internals.

@aaronc
Copy link
Member Author

aaronc commented Sep 8, 2022

Should the amino json support live there too?

Not sure if that's possible, but I think stablejson should be in cosmos-proto, but the amino part in the SDK. I'm not sure it should be exposed to anyone else apart from the SDK internals.

I think it would be easiest for them to be in the same place so some code can be shared. (Although duplication may be terrible... or even unavoidable if the implementation ends up being really different).

@amaury1093
Copy link
Contributor

Altnernatively, we could also bring cosmos-proto here as a standalone module.

@aaronc
Copy link
Member Author

aaronc commented Sep 8, 2022

I don't have a strong opinion. Let's just make a call

@tac0turtle
Copy link
Member

cosmos-proto, please

@aaronc
Copy link
Member Author

aaronc commented Sep 8, 2022

moving to cosmos-proto

@aaronc aaronc closed this Sep 8, 2022
@aaronc
Copy link
Member Author

aaronc commented Sep 8, 2022

see cosmos/cosmos-proto#83

@tac0turtle tac0turtle deleted the aaronc/stable-proto-json branch April 6, 2023 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants