-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
fix(client/v2): fix marshalling of queries with any #18309
Conversation
Warning Rate Limit Exceeded@julienrbrt has exceeded the limit for the number of files or commits that can be reviewed per hour. Please wait 18 minutes and 2 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the @coderabbitai review command. Alternatively, push new commits to this PR. We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per repository. WalkthroughThe changes primarily revolve around the update and improvement of the encoder in the project. The encoder now defaults amino types to the message type URL. The modifications also include changes in the handling of Changes
Poem
TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to filter (2)
- client/v2/go.mod
- x/tx/go.mod
Files selected for processing (5)
- client/v2/autocli/app.go (2 hunks)
- x/tx/CHANGELOG.md (1 hunks)
- x/tx/signing/aminojson/any.go (2 hunks)
- x/tx/signing/aminojson/json_marshal.go (2 hunks)
- x/tx/signing/aminojson/options.go (2 hunks)
Files skipped from review due to trivial changes (2)
- x/tx/CHANGELOG.md
- x/tx/signing/aminojson/any.go
Additional comments: 7
client/v2/autocli/app.go (2)
1-6: The import of
github.com/cosmos/gogoproto/proto
package has been removed. Ensure that this package is not used elsewhere in the file.65-71: The
FileResolver
field of theBuilder
struct has been changed fromproto.HybridResolver
toappOptions.ClientCtx.InterfaceRegistry
. This implies a change in the type ofappOptions.ClientCtx.InterfaceRegistry
. Ensure that this change is compatible with the rest of the codebase.x/tx/signing/aminojson/options.go (3)
2-8: The new import statement for the package "github.com/cosmos/gogoproto/proto" is introduced. Ensure that this package is included in your dependencies.
16-24: The function
getMessageAminoName
now accepts aprotoreflect.Message
parameter instead ofproto.Message
. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.29-46: The function
getMessageAminoNameAny
now accepts aprotoreflect.Message
parameter instead ofproto.Message
and returns a string instead of a string and a boolean. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.x/tx/signing/aminojson/json_marshal.go (2)
- 156-162: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [156-171]
The
Marshal
function has been updated to include afalse
argument in thebeginMarshal
function call. This change is likely due to the addition of theisAny
parameter in thebeginMarshal
function. Ensure that this change does not affect other parts of the codebase that use theMarshal
function.
- 173-187: The
beginMarshal
function now accepts an additionalisAny
parameter. This parameter is used to determine how thename
andnamed
variables are set. IfisAny
istrue
, thegetMessageAminoNameAny
function is used to setname
andnamed
is set totrue
. Otherwise, thegetMessageAminoName
function is used to setname
andnamed
. This change allows for different handling of the message based on whether it is anAny
message or not. Ensure that this change does not affect other parts of the codebase that use thebeginMarshal
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to filter (2)
- client/v2/go.mod
- x/tx/go.mod
Files selected for processing (5)
- client/v2/autocli/app.go (2 hunks)
- x/tx/CHANGELOG.md (1 hunks)
- x/tx/signing/aminojson/any.go (2 hunks)
- x/tx/signing/aminojson/json_marshal.go (2 hunks)
- x/tx/signing/aminojson/options.go (2 hunks)
Files skipped from review due to trivial changes (2)
- x/tx/CHANGELOG.md
- x/tx/signing/aminojson/any.go
Additional comments: 7
client/v2/autocli/app.go (2)
1-6: The removal of the
github.com/cosmos/gogoproto/proto
package import is fine as long as there are no references to it in the rest of the file.65-71: The change of
FileResolver
fromproto.HybridResolver
toappOptions.ClientCtx.InterfaceRegistry
changes the type ofFileResolver
. Ensure that all usages ofFileResolver
are compatible with the new type.- FileResolver: proto.HybridResolver, + FileResolver: appOptions.ClientCtx.InterfaceRegistry,x/tx/signing/aminojson/json_marshal.go (2)
156-160: The
Marshal
function has been updated to include a newisAny
parameter in thebeginMarshal
function call. This allows for different handling of the message based on whether it is anAny
message or not. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.173-187: The
beginMarshal
function has been updated to handle the newisAny
parameter and determine thename
andnamed
values accordingly. This change allows for different handling of the message based on whether it is anAny
message or not. Thenamed
variable and associated error check have been removed, and theenc.beginMarshal
function is now called with an additional boolean argument.x/tx/signing/aminojson/options.go (3)
2-8: The new import statement for the package "github.com/cosmos/gogoproto/proto" is introduced. Ensure that this package is included in your dependencies.
14-24: The function
getMessageAminoName
has been updated to accept aprotoreflect.Message
parameter instead ofproto.Message
. This change should be reflected wherever this function is called.- func getMessageAminoName(msg proto.Message) (string, bool) { + func getMessageAminoName(msg protoreflect.Message) (string, bool) {
- 26-46: A new function
getMessageAminoNameAny
has been added. This function returns the amino name of a message if it has been set by theamino.name
option, or the message URL if it cannot get the URL. This function seems to be a more flexible version ofgetMessageAminoName
and could be used in cases where the amino name might not be set.func getMessageAminoNameAny(msg protoreflect.Message) string { messageOptions := msg.Descriptor().Options() if proto.HasExtension(messageOptions, amino.E_Name) { name := proto.GetExtension(messageOptions, amino.E_Name) return name.(string) } msgURL := "/" + string(msg.Descriptor().FullName()) if msgURL != "/" { return msgURL } if m, ok := msg.(gogoproto.Message); ok { return "/" + gogoproto.MessageName(m) } return "" }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -66,7 +65,7 @@ func (appOptions AppOptions) EnhanceRootCommand(rootCmd *cobra.Command) error { | |||
builder := &Builder{ | |||
Builder: flag.Builder{ | |||
TypeResolver: protoregistry.GlobalTypes, | |||
FileResolver: proto.HybridResolver, | |||
FileResolver: appOptions.ClientCtx.InterfaceRegistry, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why favouring interface registry over the proto.HybridResolver?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to filter (1)
- client/v2/go.mod
Files selected for processing (1)
- x/tx/signing/aminojson/options_test.go (1 hunks)
Additional comments: 1
x/tx/signing/aminojson/options_test.go (1)
- 1-30: The tests are well written and cover the main functionality of the functions they are testing. They also handle both positive and negative cases. Good job on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- client/debug/main.go (1 hunks)
Additional comments: 1
client/debug/main.go (1)
- 86-92: The
cobra.ExactArgs(1)
ensures that the command requires exactly one argument. This is a good practice for command-line tools as it provides a clear interface for the user.
(cherry picked from commit 2caf00d) # Conflicts: # client/debug/main.go # client/v2/autocli/app.go # client/v2/go.mod # x/tx/CHANGELOG.md # x/tx/signing/aminojson/json_marshal.go
Description
ref: #18256
While investigating #18256 I have noticed that doing the following, after having submitted a proposal without amino annotations, would lead to the following:
In the backported PR, x/tx changes will be reverted as x/tx is tagged from main. x/tx v0.12 will be tagged once this PR is merged.
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...
!
to the type prefix if API or client breaking changeCHANGELOG.md
make lint
andmake test
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...
!
in the type prefix if API or client breaking changeSummary by CodeRabbit
Refactor:
FileResolver
field in theBuilder
struct to useappOptions.ClientCtx.InterfaceRegistry
instead ofproto.HybridResolver
, enhancing the type ofFileResolver
field.marshalAny
andmarshalDynamic
functions by removing thenamed
variable and error check, and introducing theenc.beginMarshal
function with an additional boolean argument.New Features:
getMessageAminoNameAny
that returns the amino name of a message or the message URL if the URL is not available.Style:
Marshal
function in theEncoder
struct.Chores:
github.com/cosmos/gogoproto/proto
package inclient/v2/autocli/app.go
.x/tx/signing/aminojson/options.go
.