diff --git a/modules/core/02-client/types/codec.go b/modules/core/02-client/types/codec.go index c71caaede98..dbe5b036c20 100644 --- a/modules/core/02-client/types/codec.go +++ b/modules/core/02-client/types/codec.go @@ -49,6 +49,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { &MsgUpgradeClient{}, &MsgSubmitMisbehaviour{}, &MsgUpdateParams{}, + &MsgRecoverClient{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/modules/core/02-client/types/msgs.go b/modules/core/02-client/types/msgs.go index 764154afcb5..b854155fdb6 100644 --- a/modules/core/02-client/types/msgs.go +++ b/modules/core/02-client/types/msgs.go @@ -17,6 +17,7 @@ var ( _ sdk.Msg = (*MsgSubmitMisbehaviour)(nil) _ sdk.Msg = (*MsgUpgradeClient)(nil) _ sdk.Msg = (*MsgUpdateParams)(nil) + _ sdk.Msg = (*MsgRecoverClient)(nil) _ codectypes.UnpackInterfacesMessage = (*MsgCreateClient)(nil) _ codectypes.UnpackInterfacesMessage = (*MsgUpdateClient)(nil) @@ -283,3 +284,34 @@ func (msg *MsgUpdateParams) ValidateBasic() error { } return msg.Params.Validate() } + +// NewMsgRecoverClient creates a new MsgRecoverClient instance +func NewMsgRecoverClient(signer, subjectClientID, substituteClientID string) *MsgRecoverClient { + return &MsgRecoverClient{ + Signer: signer, + SubjectClientId: subjectClientID, + SubstituteClientId: substituteClientID, + } +} + +// GetSigners returns the expected signers for a MsgRecoverClient message. +func (msg *MsgRecoverClient) GetSigners() []sdk.AccAddress { + accAddr, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + panic(err) + } + return []sdk.AccAddress{accAddr} +} + +// ValidateBasic performs basic checks on a MsgRecoverClient. +func (msg *MsgRecoverClient) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) + } + + if err := host.ClientIdentifierValidator(msg.SubjectClientId); err != nil { + return err + } + + return host.ClientIdentifierValidator(msg.SubstituteClientId) +} diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index b200524221f..03fc09b59b9 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -12,6 +12,8 @@ import ( "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types" + host "github.com/cosmos/ibc-go/v7/modules/core/24-host" + ibcerrors "github.com/cosmos/ibc-go/v7/modules/core/errors" solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine" ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v7/testing" @@ -678,3 +680,86 @@ func TestMsgUpdateParamsGetSigners(t *testing.T) { } } } + +// TestMsgRecoverClientValidateBasic tests ValidateBasic for MsgRecoverClient +func (suite *TypesTestSuite) TestMsgRecoverClientValidateBasic() { + var msg *types.MsgRecoverClient + + testCases := []struct { + name string + malleate func() + expError error + }{ + { + "success: valid signer and client identifiers", + func() {}, + nil, + }, + { + "failure: invalid signer address", + func() { + msg.Signer = "invalid" + }, + ibcerrors.ErrInvalidAddress, + }, + { + "failure: invalid subject client ID", + func() { + msg.SubjectClientId = "" + }, + host.ErrInvalidID, + }, + { + "failure: invalid substitute client ID", + func() { + msg.SubjectClientId = "" + }, + host.ErrInvalidID, + }, + } + + for _, tc := range testCases { + msg = types.NewMsgRecoverClient( + ibctesting.TestAccAddress, + ibctesting.FirstClientID, + ibctesting.FirstClientID, + ) + + tc.malleate() + + err := msg.ValidateBasic() + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err, "valid case %s failed", tc.name) + } else { + suite.Require().Error(err, "invalid case %s passed", tc.name) + suite.Require().ErrorIs(err, tc.expError, "invalid case %s passed", tc.name) + } + } +} + +// TestMsgRecoverClientGetSigners tests GetSigners for MsgRecoverClient +func TestMsgRecoverClientGetSigners(t *testing.T) { + testCases := []struct { + name string + address sdk.AccAddress + expPass bool + }{ + {"success: valid address", sdk.AccAddress(ibctesting.TestAccAddress), true}, + {"failure: nil address", nil, false}, + } + + for _, tc := range testCases { + // Leave subject client ID and substitute client ID as empty strings + msg := types.MsgRecoverClient{ + Signer: tc.address.String(), + } + if tc.expPass { + require.Equal(t, []sdk.AccAddress{tc.address}, msg.GetSigners()) + } else { + require.Panics(t, func() { + msg.GetSigners() + }) + } + } +} diff --git a/modules/core/02-client/types/tx.pb.go b/modules/core/02-client/types/tx.pb.go index b7bda73776a..d52b6bb51f5 100644 --- a/modules/core/02-client/types/tx.pb.go +++ b/modules/core/02-client/types/tx.pb.go @@ -445,6 +445,87 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo +// MsgRecoverClient defines the sdk.Msg type to recover a client. +type MsgRecoverClient struct { + // signer address (it may be the the address that controls the module, which defaults to x/gov unless overwritten). + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` + // the client identifier for the client to be updated if the proposal passes + SubjectClientId string `protobuf:"bytes,2,opt,name=subject_client_id,json=subjectClientId,proto3" json:"subject_client_id,omitempty"` + // the substitute client identifier for the client standing in for the subject + // client + SubstituteClientId string `protobuf:"bytes,3,opt,name=substitute_client_id,json=substituteClientId,proto3" json:"substitute_client_id,omitempty"` +} + +func (m *MsgRecoverClient) Reset() { *m = MsgRecoverClient{} } +func (m *MsgRecoverClient) String() string { return proto.CompactTextString(m) } +func (*MsgRecoverClient) ProtoMessage() {} +func (*MsgRecoverClient) Descriptor() ([]byte, []int) { + return fileDescriptor_cb5dc4651eb49a04, []int{10} +} +func (m *MsgRecoverClient) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRecoverClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRecoverClient.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgRecoverClient) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRecoverClient.Merge(m, src) +} +func (m *MsgRecoverClient) XXX_Size() int { + return m.Size() +} +func (m *MsgRecoverClient) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRecoverClient.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRecoverClient proto.InternalMessageInfo + +// MsgRecoverClientResponse defines the MsgRecoverClient response type. +type MsgRecoverClientResponse struct { +} + +func (m *MsgRecoverClientResponse) Reset() { *m = MsgRecoverClientResponse{} } +func (m *MsgRecoverClientResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRecoverClientResponse) ProtoMessage() {} +func (*MsgRecoverClientResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_cb5dc4651eb49a04, []int{11} +} +func (m *MsgRecoverClientResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRecoverClientResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRecoverClientResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgRecoverClientResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRecoverClientResponse.Merge(m, src) +} +func (m *MsgRecoverClientResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRecoverClientResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRecoverClientResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRecoverClientResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgCreateClient)(nil), "ibc.core.client.v1.MsgCreateClient") proto.RegisterType((*MsgCreateClientResponse)(nil), "ibc.core.client.v1.MsgCreateClientResponse") @@ -456,53 +537,60 @@ func init() { proto.RegisterType((*MsgSubmitMisbehaviourResponse)(nil), "ibc.core.client.v1.MsgSubmitMisbehaviourResponse") proto.RegisterType((*MsgUpdateParams)(nil), "ibc.core.client.v1.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "ibc.core.client.v1.MsgUpdateParamsResponse") + proto.RegisterType((*MsgRecoverClient)(nil), "ibc.core.client.v1.MsgRecoverClient") + proto.RegisterType((*MsgRecoverClientResponse)(nil), "ibc.core.client.v1.MsgRecoverClientResponse") } func init() { proto.RegisterFile("ibc/core/client/v1/tx.proto", fileDescriptor_cb5dc4651eb49a04) } var fileDescriptor_cb5dc4651eb49a04 = []byte{ - // 658 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x95, 0x3f, 0x6f, 0xd3, 0x4e, - 0x18, 0xc7, 0xe3, 0xfe, 0x89, 0x7e, 0xb9, 0xa6, 0xed, 0x8f, 0x53, 0xa1, 0xa9, 0x4b, 0x9d, 0x2a, - 0x30, 0x94, 0x42, 0xed, 0x26, 0x0c, 0x8d, 0x8a, 0x18, 0xda, 0x4e, 0x0c, 0x91, 0x90, 0x2b, 0x16, - 0x96, 0x60, 0x3b, 0x97, 0x8b, 0xa5, 0xd8, 0x67, 0xf9, 0xec, 0x88, 0x0c, 0x48, 0x88, 0x89, 0x11, - 0x24, 0x16, 0x36, 0x5e, 0x42, 0xc5, 0x7b, 0x40, 0xea, 0xd8, 0x91, 0x09, 0xa1, 0x64, 0xe8, 0xdb, - 0x40, 0xf6, 0x5d, 0x1c, 0xdb, 0x8d, 0x4d, 0x2a, 0x36, 0xfb, 0x9e, 0xcf, 0x73, 0xdf, 0xef, 0xf3, - 0xf8, 0x39, 0x1f, 0xd8, 0x36, 0x75, 0x43, 0x31, 0x88, 0x8b, 0x14, 0xa3, 0x6f, 0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 0xb5, 0xa0, 0x72, 0xfe, 0x18, 0x4e, - 0xec, 0x4d, 0x77, 0x4b, 0x8c, 0x2e, 0x4b, 0x9a, 0x38, 0x6b, 0x7c, 0x5e, 0x02, 0x8b, 0x2d, 0x8a, - 0xe1, 0x1b, 0x50, 0x4e, 0xfc, 0x40, 0x1e, 0xcc, 0x12, 0x4c, 0x9d, 0x58, 0xf1, 0xf1, 0x1c, 0xd0, - 0x44, 0x29, 0x50, 0x48, 0x1c, 0xe9, 0x2c, 0x85, 0x38, 0x94, 0xa9, 0x30, 0xeb, 0x18, 0x42, 0x03, - 0xac, 0x26, 0x67, 0xf7, 0x61, 0x66, 0x76, 0x8c, 0x12, 0x9f, 0xcc, 0x43, 0x45, 0x22, 0x2e, 0x80, - 0x33, 0x66, 0xf0, 0x51, 0xc6, 0x1e, 0x37, 0x51, 0xb1, 0x3e, 0x37, 0x1a, 0x69, 0x76, 0x01, 0x8c, - 0x17, 0xcc, 0x27, 0x28, 0xbf, 0x81, 0x0c, 0xfa, 0x4b, 0x03, 0x93, 0xc3, 0x20, 0x2e, 0xbf, 0xbf, - 0xbe, 0xd8, 0x17, 0x4e, 0xd5, 0xcb, 0x91, 0x24, 0x5c, 0x8d, 0x24, 0xe1, 0xf7, 0x48, 0x12, 0x3e, - 0x8d, 0xa5, 0xc2, 0xd5, 0x58, 0x2a, 0xfc, 0x1c, 0x4b, 0x85, 0xd7, 0x4d, 0x6c, 0x7a, 0x3d, 0x5f, - 0x97, 0x0d, 0x62, 0x29, 0xfc, 0x82, 0x33, 0x75, 0xe3, 0x00, 0x13, 0x65, 0x70, 0xa4, 0x58, 0xa4, - 0xe3, 0xf7, 0x11, 0x65, 0x77, 0xd5, 0x61, 0xe3, 0x80, 0x5f, 0x57, 0xde, 0xd0, 0x41, 0x54, 0x2f, - 0x86, 0x27, 0xed, 0xe9, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x70, 0x00, 0x5d, 0xdc, 0x49, 0x07, + // 738 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x96, 0x31, 0x6f, 0xd3, 0x40, + 0x14, 0xc7, 0x73, 0x69, 0x1b, 0x91, 0x6b, 0xda, 0xd0, 0x23, 0xd0, 0xd4, 0xa5, 0x49, 0x15, 0x18, + 0x4a, 0xa1, 0x76, 0x5b, 0x86, 0x56, 0x45, 0x0c, 0x6d, 0x27, 0x86, 0x48, 0xc8, 0x15, 0x0b, 0x4b, + 0xb0, 0x9d, 0xeb, 0xd5, 0xa8, 0xce, 0x45, 0xbe, 0x73, 0x44, 0x06, 0x24, 0xc4, 0xc4, 0xc8, 0xc0, + 0xc2, 0x80, 0xc4, 0x47, 0xa8, 0xf8, 0x0e, 0x48, 0x1d, 0x3b, 0x32, 0x21, 0xd4, 0x0e, 0xe5, 0x13, + 0x30, 0x23, 0xfb, 0x2e, 0x8e, 0xed, 0xda, 0x21, 0x15, 0x5b, 0x7c, 0xef, 0xf7, 0xee, 0xfd, 0xdf, + 0xff, 0x9e, 0xcf, 0x81, 0x8b, 0xb6, 0x69, 0x69, 0x16, 0x75, 0xb1, 0x66, 0x1d, 0xdb, 0xb8, 0xc3, + 0xb5, 0xde, 0x86, 0xc6, 0xdf, 0xa8, 0x5d, 0x97, 0x72, 0x8a, 0x90, 0x6d, 0x5a, 0xaa, 0x1f, 0x54, + 0x45, 0x50, 0xed, 0x6d, 0x28, 0xf3, 0x16, 0x65, 0x0e, 0x65, 0x9a, 0xc3, 0x88, 0xcf, 0x3a, 0x8c, + 0x08, 0x58, 0xa9, 0x10, 0x4a, 0x68, 0xf0, 0x53, 0xf3, 0x7f, 0xc9, 0xd5, 0x05, 0x42, 0x29, 0x39, + 0xc6, 0x5a, 0xf0, 0x64, 0x7a, 0x87, 0x9a, 0xd1, 0xe9, 0xcb, 0x50, 0x3d, 0xa5, 0xb4, 0xac, 0x13, + 0x00, 0x8d, 0x6f, 0x00, 0x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1b, 0x00, 0x00, 0xff, 0xff, 0x35, 0xf8, 0xa6, 0x5f, 0x6a, 0x08, 0x00, 0x00, } @@ -528,6 +616,8 @@ type MsgClient interface { SubmitMisbehaviour(ctx context.Context, in *MsgSubmitMisbehaviour, opts ...grpc.CallOption) (*MsgSubmitMisbehaviourResponse, error) // UpdateClientParams defines a rpc handler method for MsgUpdateParams. UpdateClientParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + // Recover defines a rpc handler method for MsgRecoverClient. + RecoverClient(ctx context.Context, in *MsgRecoverClient, opts ...grpc.CallOption) (*MsgRecoverClientResponse, error) } type msgClient struct { @@ -583,6 +673,15 @@ func (c *msgClient) UpdateClientParams(ctx context.Context, in *MsgUpdateParams, return out, nil } +func (c *msgClient) RecoverClient(ctx context.Context, in *MsgRecoverClient, opts ...grpc.CallOption) (*MsgRecoverClientResponse, error) { + out := new(MsgRecoverClientResponse) + err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Msg/RecoverClient", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // CreateClient defines a rpc handler method for MsgCreateClient. @@ -595,6 +694,8 @@ type MsgServer interface { SubmitMisbehaviour(context.Context, *MsgSubmitMisbehaviour) (*MsgSubmitMisbehaviourResponse, error) // UpdateClientParams defines a rpc handler method for MsgUpdateParams. UpdateClientParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + // Recover defines a rpc handler method for MsgRecoverClient. + RecoverClient(context.Context, *MsgRecoverClient) (*MsgRecoverClientResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -616,6 +717,9 @@ func (*UnimplementedMsgServer) SubmitMisbehaviour(ctx context.Context, req *MsgS func (*UnimplementedMsgServer) UpdateClientParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateClientParams not implemented") } +func (*UnimplementedMsgServer) RecoverClient(ctx context.Context, req *MsgRecoverClient) (*MsgRecoverClientResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RecoverClient not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -711,6 +815,24 @@ func _Msg_UpdateClientParams_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Msg_RecoverClient_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRecoverClient) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RecoverClient(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.client.v1.Msg/RecoverClient", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RecoverClient(ctx, req.(*MsgRecoverClient)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.core.client.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -735,6 +857,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateClientParams", Handler: _Msg_UpdateClientParams_Handler, }, + { + MethodName: "RecoverClient", + Handler: _Msg_RecoverClient_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/core/client/v1/tx.proto", @@ -1122,6 +1248,73 @@ func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *MsgRecoverClient) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgRecoverClient) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRecoverClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SubstituteClientId) > 0 { + i -= len(m.SubstituteClientId) + copy(dAtA[i:], m.SubstituteClientId) + i = encodeVarintTx(dAtA, i, uint64(len(m.SubstituteClientId))) + i-- + dAtA[i] = 0x1a + } + if len(m.SubjectClientId) > 0 { + i -= len(m.SubjectClientId) + copy(dAtA[i:], m.SubjectClientId) + i = encodeVarintTx(dAtA, i, uint64(len(m.SubjectClientId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRecoverClientResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgRecoverClientResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRecoverClientResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1289,6 +1482,36 @@ func (m *MsgUpdateParamsResponse) Size() (n int) { return n } +func (m *MsgRecoverClient) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.SubjectClientId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.SubstituteClientId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRecoverClientResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2368,6 +2591,202 @@ func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgRecoverClient) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgRecoverClient: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRecoverClient: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubjectClientId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SubjectClientId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubstituteClientId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SubstituteClientId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRecoverClientResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgRecoverClientResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRecoverClientResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 02e41a0ab83..8e2fae23a8c 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -100,6 +100,11 @@ func (k Keeper) SubmitMisbehaviour(goCtx context.Context, msg *clienttypes.MsgSu return &clienttypes.MsgSubmitMisbehaviourResponse{}, nil } +// RecoverClient defines a rpc handler method for MsgRecoverClient. +func (k Keeper) RecoverClient(goCtx context.Context, msg *clienttypes.MsgRecoverClient) (*clienttypes.MsgRecoverClientResponse, error) { //nolint:revive + return &clienttypes.MsgRecoverClientResponse{}, nil +} + // ConnectionOpenInit defines a rpc handler method for MsgConnectionOpenInit. func (k Keeper) ConnectionOpenInit(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenInit) (*connectiontypes.MsgConnectionOpenInitResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/proto/ibc/core/client/v1/tx.proto b/proto/ibc/core/client/v1/tx.proto index 76efcc7e7b1..bb96ac2c70c 100644 --- a/proto/ibc/core/client/v1/tx.proto +++ b/proto/ibc/core/client/v1/tx.proto @@ -27,6 +27,9 @@ service Msg { // UpdateClientParams defines a rpc handler method for MsgUpdateParams. rpc UpdateClientParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + + // RecoverClient defines a rpc handler method for MsgRecoverClient. + rpc RecoverClient(MsgRecoverClient) returns (MsgRecoverClientResponse); } // MsgCreateClient defines a message to create an IBC client @@ -127,4 +130,21 @@ message MsgUpdateParams { } // MsgUpdateParamsResponse defines the MsgUpdateParams response type. -message MsgUpdateParamsResponse {} \ No newline at end of file +message MsgUpdateParamsResponse {} + +// MsgRecoverClient defines the sdk.Msg type to recover a client. +message MsgRecoverClient { + option (gogoproto.goproto_getters) = false; + option (cosmos.msg.v1.signer) = "signer"; + + // signer address (it may be the the address that controls the module, which defaults to x/gov unless overwritten). + string signer = 1; + // the client identifier for the client to be updated if the proposal passes + string subject_client_id = 2; + // the substitute client identifier for the client which will replace the subject + // client + string substitute_client_id = 3; +} + +// MsgRecoverClientResponse defines the MsgRecoverClient response type. +message MsgRecoverClientResponse {} \ No newline at end of file