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

chore: MsgUpdateClient rename header to client_message #1316

Merged
merged 2 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3418,13 +3418,13 @@ type.

### MsgUpdateClient
MsgUpdateClient defines an sdk.Msg to update a IBC client state using
the given header.
the given client message.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `client_id` | [string](#string) | | client unique identifier |
| `header` | [google.protobuf.Any](#google.protobuf.Any) | | header to update the light client |
| `client_message` | [google.protobuf.Any](#google.protobuf.Any) | | client message to update the light client |
| `signer` | [string](#string) | | signer address |


Expand Down
2 changes: 1 addition & 1 deletion modules/core/02-client/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func NewTxCmd() *cobra.Command {
txCmd.AddCommand(
NewCreateClientCmd(),
NewUpdateClientCmd(),
NewSubmitMisbehaviourCmd(),
NewSubmitMisbehaviourCmd(), // Deprecated
NewUpgradeClientCmd(),
)

Expand Down
22 changes: 12 additions & 10 deletions modules/core/02-client/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ func NewCreateClientCmd() *cobra.Command {
// NewUpdateClientCmd defines the command to update an IBC client.
func NewUpdateClientCmd() *cobra.Command {
return &cobra.Command{
Use: "update [client-id] [path/to/header.json]",
Short: "update existing client with a header",
Long: "update existing client with a header",
Example: fmt.Sprintf("%s tx ibc %s update [client-id] [path/to/header.json] --from node0 --home ../node0/<app>cli --chain-id $CID", version.AppName, types.SubModuleName),
Use: "update [client-id] [path/to/client_msg.json]",
Short: "update existing client with a client message",
Long: "update existing client with a client message, for example a header, misbehaviour or batch update",
Example: fmt.Sprintf("%s tx ibc %s update [client-id] [path/to/client_msg.json] --from node0 --home ../node0/<app>cli --chain-id $CID", version.AppName, types.SubModuleName),
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
Expand All @@ -100,22 +100,22 @@ func NewUpdateClientCmd() *cobra.Command {

cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry)

var header exported.ClientMessage
headerContentOrFileName := args[1]
if err := cdc.UnmarshalInterfaceJSON([]byte(headerContentOrFileName), &header); err != nil {
var clientMsg exported.ClientMessage
clientMsgContentOrFileName := args[1]
if err := cdc.UnmarshalInterfaceJSON([]byte(clientMsgContentOrFileName), &clientMsg); err != nil {

// check for file path if JSON input is not provided
contents, err := ioutil.ReadFile(headerContentOrFileName)
contents, err := ioutil.ReadFile(clientMsgContentOrFileName)
if err != nil {
return fmt.Errorf("neither JSON input nor path to .json file for header were provided: %w", err)
}

if err := cdc.UnmarshalInterfaceJSON(contents, &header); err != nil {
if err := cdc.UnmarshalInterfaceJSON(contents, &clientMsg); err != nil {
return fmt.Errorf("error unmarshalling header file: %w", err)
}
}

msg, err := types.NewMsgUpdateClient(clientID, header, clientCtx.GetFromAddress().String())
msg, err := types.NewMsgUpdateClient(clientID, clientMsg, clientCtx.GetFromAddress().String())
if err != nil {
return err
}
Expand All @@ -127,6 +127,8 @@ func NewUpdateClientCmd() *cobra.Command {

// NewSubmitMisbehaviourCmd defines the command to submit a misbehaviour to prevent
// future updates.
// Deprecated: NewSubmitMisbehaviourCmd is deprecated and will be removed in a future release.
// Please use NewUpdateClientCmd instead.
func NewSubmitMisbehaviourCmd() *cobra.Command {
return &cobra.Command{
Use: "misbehaviour [clientID] [path/to/misbehaviour.json]",
Expand Down
18 changes: 9 additions & 9 deletions modules/core/02-client/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,16 @@ func (msg MsgCreateClient) UnpackInterfaces(unpacker codectypes.AnyUnpacker) err

// NewMsgUpdateClient creates a new MsgUpdateClient instance
//nolint:interfacer
func NewMsgUpdateClient(id string, header exported.ClientMessage, signer string) (*MsgUpdateClient, error) {
anyHeader, err := PackClientMessage(header)
func NewMsgUpdateClient(id string, clientMsg exported.ClientMessage, signer string) (*MsgUpdateClient, error) {
anyClientMsg, err := PackClientMessage(clientMsg)
if err != nil {
return nil, err
}

return &MsgUpdateClient{
ClientId: id,
Header: anyHeader,
Signer: signer,
ClientId: id,
ClientMessage: anyClientMsg,
Signer: signer,
}, nil
}

Expand All @@ -120,11 +120,11 @@ func (msg MsgUpdateClient) ValidateBasic() error {
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err)
}
header, err := UnpackClientMessage(msg.Header)
clientMsg, err := UnpackClientMessage(msg.ClientMessage)
if err != nil {
return err
}
if err := header.ValidateBasic(); err != nil {
if err := clientMsg.ValidateBasic(); err != nil {
return err
}
return host.ClientIdentifierValidator(msg.ClientId)
Expand All @@ -141,8 +141,8 @@ func (msg MsgUpdateClient) GetSigners() []sdk.AccAddress {

// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
func (msg MsgUpdateClient) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
var header exported.ClientMessage
return unpacker.UnpackAny(msg.Header, &header)
var clientMsg exported.ClientMessage
return unpacker.UnpackAny(msg.ClientMessage, &clientMsg)
}

// NewMsgUpgradeClient creates a new MsgUpgradeClient instance
Expand Down
2 changes: 1 addition & 1 deletion modules/core/02-client/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (suite *TypesTestSuite) TestMsgUpdateClient_ValidateBasic() {
{
"failed to unpack header",
func() {
msg.Header = nil
msg.ClientMessage = nil
},
false,
},
Expand Down
100 changes: 50 additions & 50 deletions modules/core/02-client/types/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions modules/core/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ func (k Keeper) CreateClient(goCtx context.Context, msg *clienttypes.MsgCreateCl
func (k Keeper) UpdateClient(goCtx context.Context, msg *clienttypes.MsgUpdateClient) (*clienttypes.MsgUpdateClientResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

header, err := clienttypes.UnpackClientMessage(msg.Header)
clientMsg, err := clienttypes.UnpackClientMessage(msg.ClientMessage)
if err != nil {
return nil, err
}

if err = k.ClientKeeper.UpdateClient(ctx, msg.ClientId, header); err != nil {
if err = k.ClientKeeper.UpdateClient(ctx, msg.ClientId, clientMsg); err != nil {
return nil, err
}

Expand Down
6 changes: 3 additions & 3 deletions proto/ibc/core/client/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ message MsgCreateClient {
message MsgCreateClientResponse {}

// MsgUpdateClient defines an sdk.Msg to update a IBC client state using
// the given header.
// the given client message.
message MsgUpdateClient {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// client unique identifier
string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""];
// header to update the light client
google.protobuf.Any header = 2;
// client message to update the light client
google.protobuf.Any client_message = 2;
Comment on lines -50 to +51
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 unsure if this was forgotten about or if this was intended to be left as header. If not required we can close this PR or take the deprecation notices to another PR.

My only concern here is that relayers would be required to support both field names simultaneous depending on what version a chain and it's counterparty are running. Afaik hermes queries chains to determine ibc-go versions already but I am not sure if they have had to support such a scenario yet.
Despite this I think we should still be allowed to freely rename such fields for major version releases.

Curious to hear the thoughts of the team! :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Good question... If needed I can check with Adi and Justin.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe updating the naming should be fine. But we should check with relayers

// signer address
string signer = 3;
}
Expand Down