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

refactor: remove gogoproto stringer annotations and MarshalYAML functions #13850

Merged
merged 25 commits into from
Nov 28, 2022

Conversation

julienrbrt
Copy link
Member

Description

Follow-up of cosmos/gogoproto#24 / #10965
Fix tests mentioning #10965 by using .String() instead of marshalling and unmarshalling for comparing value.


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)

@julienrbrt julienrbrt requested a review from a team as a code owner November 14, 2022 09:12
@julienrbrt julienrbrt changed the title fix: bump gogoproto and fix tests mentioning #10965 fix: fix tests mentioning #10965 after cosmos/gogoproto bump Nov 14, 2022
go.mod Outdated Show resolved Hide resolved
@julienrbrt julienrbrt force-pushed the julien/bump-gogoproto branch from 7abd5f5 to d0f0e1d Compare November 14, 2022 15:09
@julienrbrt julienrbrt added the backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release label Nov 14, 2022
@julienrbrt julienrbrt marked this pull request as draft November 14, 2022 15:30
@julienrbrt julienrbrt changed the title fix: fix tests mentioning #10965 after cosmos/gogoproto bump refactor: refactor tests mentioning #10965 after cosmos/gogoproto bump Nov 14, 2022
@julienrbrt julienrbrt changed the title refactor: refactor tests mentioning #10965 after cosmos/gogoproto bump refactor: remove gogoproto stringer annotations and MarshalYAML functions Nov 14, 2022
@julienrbrt julienrbrt marked this pull request as ready for review November 16, 2022 09:51
@julienrbrt
Copy link
Member Author

My main concerns of removing some .String() methods, is that the generated String() methods, is sometimes less human-readable. Are we okay with that?
cc @AmauryM

amaury1093
amaury1093 previously approved these changes Nov 16, 2022
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

Thanks! Removing this proto annotation feels great.

My main concerns of removing some .String() methods, is that the generated String() methods, is sometimes less human-readable. Are we okay with that?

Yes, I think the consensus in #12908 was that the trade-off is reasonable. Morever, if people want more human-friendliness, they can always go the JSON->YAML route.

CHANGELOG.md Outdated Show resolved Hide resolved
@julienrbrt
Copy link
Member Author

Yes, I think the consensus in #12908 was that the trade-off is reasonable. Morever, if people want more human-friendliness, they can always go the JSON->YAML route.

Okay, I can continue to do that across the codebase if 64db167 is acceptable.

tac0turtle
tac0turtle previously approved these changes Nov 16, 2022
Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

LGTM, thank for this cleanup

@julienrbrt julienrbrt disabled auto-merge November 16, 2022 16:14
@julienrbrt julienrbrt force-pushed the julien/bump-gogoproto branch from c976491 to 06a7d61 Compare November 18, 2022 06:25
CHANGELOG.md Outdated Show resolved Hide resolved
@sonarqubecloud
Copy link

[Cosmos SDK] SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

have we checked if the string versions were compatible? we should document some of the breaking formats, if there are any(?).

I think the stable query checks would have caught on some of the strings in staking.

@julienrbrt
Copy link
Member Author

julienrbrt commented Nov 27, 2022

have we checked if the string versions were compatible? we should document some of the breaking formats, if there are any(?).

I think the stable query checks would have caught on some of the strings in staking.

String results are different because they are differently stringified. Here they however contain all same values.

I can look further into staking, but note that not all Stringer have been removed for that exact reason (because sometimes the amount of returned contains less information than using the proto generated String method - I need to look at what is the impact of that).

Are chains dev using Strings methods for any other reason than display?

@tac0turtle
Copy link
Member

It should be fine, worried mainly that it breaks an endpoint for users and we aren't aware of it.

@amaury1093
Copy link
Contributor

I'm not worried about endpoints, we generally use protobuf (not .String) for them. I'm slightly more worried about state-machine, like @julienrbrt pointed out:

Are chains dev using Strings methods for any other reason than display?

I think in the SDK we're fine, we have 2-3 instances like this one, where we use String for comparison, potentially in state-machine code. I think it's a terrible pattern, and should not be encouraged.

Maybe we can add a small note in the changelog/upgrading guide to tell chain devs to double-check they are not doing this anymore?

@julienrbrt julienrbrt enabled auto-merge (squash) November 28, 2022 12:39
@julienrbrt julienrbrt merged commit 41f0ab1 into main Nov 28, 2022
@julienrbrt julienrbrt deleted the julien/bump-gogoproto branch November 28, 2022 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants