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(sims): rm usage of GetSignBytes from NewOperationMsg #16036

Closed
wants to merge 18 commits into from

Conversation

kocubinski
Copy link
Member

@kocubinski kocubinski commented May 4, 2023

Description

Ref: #16024


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)

@kocubinski kocubinski force-pushed the kocubinski/sims-getsignbytes branch from 2a13f01 to 82ca71f Compare May 4, 2023 19:04
@kocubinski kocubinski marked this pull request as ready for review May 5, 2023 00:26
@kocubinski kocubinski requested a review from a team as a code owner May 5, 2023 00:26
_ "cosmossdk.io/api/cosmos/upgrade/v1beta1"
_ "cosmossdk.io/api/cosmos/vesting/module/v1"
_ "cosmossdk.io/api/cosmos/vesting/v1beta1"
)
Copy link
Member

@aaronc aaronc May 5, 2023

Choose a reason for hiding this comment

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

None of this should be necessary. This is only needed because the amino JSON encoder isn't properly setup to take a custom file resolver and use dynamicpb when there are is no concrete type. It should be possible to pass in proto.HybridResolver as an option to aminojson.NewEncoder and be done, without all these imports

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not following your suggestion. The usage in question in the aminojson package requires a protoregistry.MessageTypeResolver, not a ProtoFileResolver which is what a photo.HybridResolver is.

Copy link
Member Author

@kocubinski kocubinski May 5, 2023

Choose a reason for hiding this comment

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

I've moved the type resolution step up into this sims package to prevent passing an any to aminojson.Encoder, it would need an exclusion with types without amino.name. But I still need a typeResolver to get a protoreflect enabled msg for aminojson.Encoder. Any suggestions?

Copy link
Member

@aaronc aaronc May 5, 2023

Choose a reason for hiding this comment

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

Use dyncamicpb + the file resolver if the typeresolver doesn't have the type like I was saying above. Also the encoder should be parameterized by both file resolver and type resolver. See what autocli does

Copy link
Member Author

Choose a reason for hiding this comment

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

the encoder should be parameterized by both file resolver and type resolver. See what autocli does

Can we tackle this in a separate PR? I don't think any change is required here for sims to remove this last usage.

Copy link
Member

Choose a reason for hiding this comment

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

I guess so but addressing this issue with aminojson takes priority in my opinion. We said that it would work dynamically without depending on the API module. This PR has uncovered that this is not true. So we need to address that

Copy link
Member Author

Choose a reason for hiding this comment

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

We can merge both, I don't see them as blocking, but all right.

if err != nil {
panic(err)
}
encoder := aminojson.NewAminoJSON()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
encoder := aminojson.NewAminoJSON()
encoder := aminojson.NewEncoder()

The constructor name should match the type name

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. This should be a separate PR since it necessitates an x/tx release, please review when you get a chance.
#16044

@github-actions github-actions bot added the C:x/tx label May 5, 2023
if err != nil {
panic(fmt.Errorf("failed to marshal msg: %w", err))
}
err = proto.Unmarshal(gogoBytes, dynamicMsg)

Check warning

Code scanning / CodeQL

Useless assignment to local variable

This definition of err is never used.
@kocubinski kocubinski closed this May 8, 2023
@kocubinski
Copy link
Member Author

implemented in #16048

@tac0turtle tac0turtle deleted the kocubinski/sims-getsignbytes branch February 21, 2024 16:23
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.

2 participants