From 0e89d1b93ddcbaa45b6b0b1044abd46211235b19 Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Wed, 14 Oct 2020 18:26:54 +0200 Subject: [PATCH 1/6] Refactor x/evidence to ADR-031 --- proto/cosmos/evidence/v1beta1/tx.proto | 10 + x/evidence/exported/evidence.go | 4 +- x/evidence/handler.go | 28 +-- x/evidence/handler_test.go | 4 +- x/evidence/keeper/keeper.go | 4 +- x/evidence/keeper/keeper_test.go | 10 +- x/evidence/keeper/msg_server.go | 30 +++ x/evidence/types/msgs.go | 2 +- x/evidence/types/msgs_test.go | 2 +- x/evidence/types/tx.pb.go | 250 ++++++++++++++++++++++++- 10 files changed, 300 insertions(+), 44 deletions(-) create mode 100644 x/evidence/keeper/msg_server.go diff --git a/proto/cosmos/evidence/v1beta1/tx.proto b/proto/cosmos/evidence/v1beta1/tx.proto index 352f7a1c23a7..6d92be7f775e 100644 --- a/proto/cosmos/evidence/v1beta1/tx.proto +++ b/proto/cosmos/evidence/v1beta1/tx.proto @@ -8,6 +8,13 @@ import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; import "cosmos_proto/cosmos.proto"; +// Msg defines the evidence Msg service. +service Msg { + // Send submits an arbitrary Evidence of misbehavior such as equivocation or + // counterfactual signing. + rpc SubmitEvidence(MsgSubmitEvidence) returns (MsgSubmitEvidenceResponse); +} + // MsgSubmitEvidence represents a message that supports submitting arbitrary // Evidence of misbehavior such as equivocation or counterfactual signing. message MsgSubmitEvidence { @@ -17,3 +24,6 @@ message MsgSubmitEvidence { string submitter = 1; google.protobuf.Any evidence = 2 [(cosmos_proto.accepts_interface) = "Evidence"]; } + +// MsgSubmitEvidenceResponse defines the Msg/SubmitEvidence response type. +message MsgSubmitEvidenceResponse {} diff --git a/x/evidence/exported/evidence.go b/x/evidence/exported/evidence.go index 0bba5fc487ab..1be263a8703b 100644 --- a/x/evidence/exported/evidence.go +++ b/x/evidence/exported/evidence.go @@ -34,10 +34,10 @@ type ValidatorEvidence interface { GetTotalPower() int64 } -// MsgSubmitEvidence defines the specific interface a concrete message must +// MsgSubmitEvidenceI defines the specific interface a concrete message must // implement in order to process submitted evidence. The concrete MsgSubmitEvidence // must be defined at the application-level. -type MsgSubmitEvidence interface { +type MsgSubmitEvidenceI interface { sdk.Msg GetEvidence() Evidence diff --git a/x/evidence/handler.go b/x/evidence/handler.go index 60c59158ede9..7cf9d6b687d2 100644 --- a/x/evidence/handler.go +++ b/x/evidence/handler.go @@ -3,42 +3,22 @@ package evidence import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/evidence/exported" "github.com/cosmos/cosmos-sdk/x/evidence/keeper" "github.com/cosmos/cosmos-sdk/x/evidence/types" ) +// NewHandler returns a handler for evidence messages. func NewHandler(k keeper.Keeper) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - case exported.MsgSubmitEvidence: - return handleMsgSubmitEvidence(ctx, k, msg) + case *types.MsgSubmitEvidence: + res, err := k.SubmitEvidence(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) } } } - -func handleMsgSubmitEvidence(ctx sdk.Context, k keeper.Keeper, msg exported.MsgSubmitEvidence) (*sdk.Result, error) { - evidence := msg.GetEvidence() - if err := k.SubmitEvidence(ctx, evidence); err != nil { - return nil, err - } - - ctx.EventManager().EmitEvent( - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, msg.GetSubmitter().String()), - ), - ) - - return &sdk.Result{ - Data: evidence.Hash(), - Events: ctx.EventManager().ABCIEvents(), - }, nil -} diff --git a/x/evidence/handler_test.go b/x/evidence/handler_test.go index 40114836883e..2faf8b40703e 100644 --- a/x/evidence/handler_test.go +++ b/x/evidence/handler_test.go @@ -25,7 +25,7 @@ type HandlerTestSuite struct { app *simapp.SimApp } -func testMsgSubmitEvidence(r *require.Assertions, e exported.Evidence, s sdk.AccAddress) exported.MsgSubmitEvidence { +func testMsgSubmitEvidence(r *require.Assertions, e exported.Evidence, s sdk.AccAddress) exported.MsgSubmitEvidenceI { msg, err := types.NewMsgSubmitEvidence(s, e) r.NoError(err) return msg @@ -113,7 +113,7 @@ func (suite *HandlerTestSuite) TestMsgSubmitEvidence() { suite.Require().NoError(err, "unexpected error; tc #%d", i) suite.Require().NotNil(res, "expected non-nil result; tc #%d", i) - msg := tc.msg.(exported.MsgSubmitEvidence) + msg := tc.msg.(exported.MsgSubmitEvidenceI) suite.Require().Equal(msg.GetEvidence().Hash().Bytes(), res.Data, "invalid hash; tc #%d", i) } } diff --git a/x/evidence/keeper/keeper.go b/x/evidence/keeper/keeper.go index e15cd74c8a07..9868dd74f6ee 100644 --- a/x/evidence/keeper/keeper.go +++ b/x/evidence/keeper/keeper.go @@ -71,11 +71,11 @@ func (k Keeper) GetEvidenceHandler(evidenceRoute string) (types.Handler, error) return k.router.GetRoute(evidenceRoute), nil } -// SubmitEvidence attempts to match evidence against the keepers router and execute +// submitEvidence attempts to match evidence against the keepers router and execute // the corresponding registered Evidence Handler. An error is returned if no // registered Handler exists or if the Handler fails. Otherwise, the evidence is // persisted. -func (k Keeper) SubmitEvidence(ctx sdk.Context, evidence exported.Evidence) error { +func (k Keeper) SubmitEvidenceI(ctx sdk.Context, evidence exported.Evidence) error { if _, ok := k.GetEvidence(ctx, evidence.Hash()); ok { return sdkerrors.Wrap(types.ErrEvidenceExists, evidence.Hash().String()) } diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index 0017f12f25b8..81bf275171d7 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -118,7 +118,7 @@ func (suite *KeeperTestSuite) populateEvidence(ctx sdk.Context, numEvidence int) ConsensusAddress: sdk.ConsAddress(pk.PubKey().Address().Bytes()).String(), } - suite.Nil(suite.app.EvidenceKeeper.SubmitEvidence(ctx, evidence[i])) + suite.Nil(suite.app.EvidenceKeeper.SubmitEvidenceI(ctx, evidence[i])) } return evidence @@ -147,7 +147,7 @@ func (suite *KeeperTestSuite) TestSubmitValidEvidence() { ConsensusAddress: sdk.ConsAddress(pk.PubKey().Address().Bytes()).String(), } - suite.Nil(suite.app.EvidenceKeeper.SubmitEvidence(ctx, e)) + suite.Nil(suite.app.EvidenceKeeper.SubmitEvidenceI(ctx, e)) res, ok := suite.app.EvidenceKeeper.GetEvidence(ctx, e.Hash()) suite.True(ok) @@ -165,8 +165,8 @@ func (suite *KeeperTestSuite) TestSubmitValidEvidence_Duplicate() { ConsensusAddress: sdk.ConsAddress(pk.PubKey().Address().Bytes()).String(), } - suite.Nil(suite.app.EvidenceKeeper.SubmitEvidence(ctx, e)) - suite.Error(suite.app.EvidenceKeeper.SubmitEvidence(ctx, e)) + suite.Nil(suite.app.EvidenceKeeper.SubmitEvidenceI(ctx, e)) + suite.Error(suite.app.EvidenceKeeper.SubmitEvidenceI(ctx, e)) res, ok := suite.app.EvidenceKeeper.GetEvidence(ctx, e.Hash()) suite.True(ok) @@ -183,7 +183,7 @@ func (suite *KeeperTestSuite) TestSubmitInvalidEvidence() { ConsensusAddress: sdk.ConsAddress(pk.PubKey().Address().Bytes()).String(), } - suite.Error(suite.app.EvidenceKeeper.SubmitEvidence(ctx, e)) + suite.Error(suite.app.EvidenceKeeper.SubmitEvidenceI(ctx, e)) res, ok := suite.app.EvidenceKeeper.GetEvidence(ctx, e.Hash()) suite.False(ok) diff --git a/x/evidence/keeper/msg_server.go b/x/evidence/keeper/msg_server.go new file mode 100644 index 000000000000..c6528df7362d --- /dev/null +++ b/x/evidence/keeper/msg_server.go @@ -0,0 +1,30 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/evidence/types" +) + +var _ types.MsgServer = Keeper{} + +// SubmitEvidence implements the MsgServer.SubmitEvidence method. +func (k Keeper) SubmitEvidence(goCtx context.Context, msg *types.MsgSubmitEvidence) (*types.MsgSubmitEvidenceResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + evidence := msg.GetEvidence() + if err := k.SubmitEvidenceI(ctx, evidence); err != nil { + return nil, err + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, msg.GetSubmitter().String()), + ), + ) + + return &types.MsgSubmitEvidenceResponse{}, nil +} diff --git a/x/evidence/types/msgs.go b/x/evidence/types/msgs.go index 74ffd0f500d8..cd2e2ba0321d 100644 --- a/x/evidence/types/msgs.go +++ b/x/evidence/types/msgs.go @@ -19,7 +19,7 @@ const ( var ( _ sdk.Msg = &MsgSubmitEvidence{} _ types.UnpackInterfacesMessage = MsgSubmitEvidence{} - _ exported.MsgSubmitEvidence = &MsgSubmitEvidence{} + _ exported.MsgSubmitEvidenceI = &MsgSubmitEvidence{} ) // NewMsgSubmitEvidence returns a new MsgSubmitEvidence with a signer/submitter. diff --git a/x/evidence/types/msgs_test.go b/x/evidence/types/msgs_test.go index 8bcf061ff3e3..4248b0dfba94 100644 --- a/x/evidence/types/msgs_test.go +++ b/x/evidence/types/msgs_test.go @@ -12,7 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/evidence/types" ) -func testMsgSubmitEvidence(t *testing.T, e exported.Evidence, s sdk.AccAddress) exported.MsgSubmitEvidence { +func testMsgSubmitEvidence(t *testing.T, e exported.Evidence, s sdk.AccAddress) exported.MsgSubmitEvidenceI { msg, err := types.NewMsgSubmitEvidence(s, e) require.NoError(t, err) return msg diff --git a/x/evidence/types/tx.pb.go b/x/evidence/types/tx.pb.go index 876bf30e6416..791f8208f58d 100644 --- a/x/evidence/types/tx.pb.go +++ b/x/evidence/types/tx.pb.go @@ -4,11 +4,16 @@ package types import ( + context "context" fmt "fmt" types "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" _ "github.com/regen-network/cosmos-proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" io "io" math "math" math_bits "math/bits" @@ -65,14 +70,52 @@ func (m *MsgSubmitEvidence) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSubmitEvidence proto.InternalMessageInfo +// MsgSubmitEvidenceResponse defines the Msg/SubmitEvidence response type. +type MsgSubmitEvidenceResponse struct { +} + +func (m *MsgSubmitEvidenceResponse) Reset() { *m = MsgSubmitEvidenceResponse{} } +func (m *MsgSubmitEvidenceResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitEvidenceResponse) ProtoMessage() {} +func (*MsgSubmitEvidenceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3e3242cb23c956e0, []int{1} +} +func (m *MsgSubmitEvidenceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubmitEvidenceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubmitEvidenceResponse.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 *MsgSubmitEvidenceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitEvidenceResponse.Merge(m, src) +} +func (m *MsgSubmitEvidenceResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSubmitEvidenceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitEvidenceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubmitEvidenceResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgSubmitEvidence)(nil), "cosmos.evidence.v1beta1.MsgSubmitEvidence") + proto.RegisterType((*MsgSubmitEvidenceResponse)(nil), "cosmos.evidence.v1beta1.MsgSubmitEvidenceResponse") } func init() { proto.RegisterFile("cosmos/evidence/v1beta1/tx.proto", fileDescriptor_3e3242cb23c956e0) } var fileDescriptor_3e3242cb23c956e0 = []byte{ - // 257 bytes of a gzipped FileDescriptorProto + // 299 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x2d, 0xcb, 0x4c, 0x49, 0xcd, 0x4b, 0x4e, 0xd5, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x87, 0xa8, @@ -84,12 +127,120 @@ var fileDescriptor_3e3242cb23c956e0 = []byte{ 0x10, 0x42, 0x40, 0xc8, 0x8e, 0x8b, 0x03, 0xe6, 0x24, 0x09, 0x26, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x11, 0x3d, 0x88, 0xdd, 0x7a, 0x30, 0xbb, 0xf5, 0x1c, 0xf3, 0x2a, 0x9d, 0x78, 0x4e, 0x6d, 0xd1, 0xe5, 0x80, 0x99, 0x19, 0x04, 0xd7, 0x63, 0xc5, 0xd1, 0xb1, 0x40, 0x9e, 0xe1, 0xc5, 0x02, 0x79, - 0x06, 0x27, 0xef, 0x15, 0x8f, 0xe4, 0x18, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, - 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, - 0x21, 0x4a, 0x37, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x17, 0xea, 0x66, 0x28, - 0xa5, 0x5b, 0x9c, 0x92, 0xad, 0x5f, 0x81, 0x08, 0xb9, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, - 0xb0, 0xe5, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x60, 0x3b, 0xe2, 0x83, 0x59, 0x01, 0x00, - 0x00, + 0x06, 0x25, 0x69, 0x2e, 0x49, 0x0c, 0xcb, 0x83, 0x52, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x8d, + 0xca, 0xb9, 0x98, 0x7d, 0x8b, 0xd3, 0x85, 0x0a, 0xb8, 0xf8, 0xd0, 0x5c, 0xa7, 0xa5, 0x87, 0x23, + 0x60, 0xf4, 0x30, 0x0c, 0x93, 0x32, 0x22, 0x5e, 0x2d, 0xcc, 0x62, 0x27, 0xef, 0x15, 0x8f, 0xe4, + 0x18, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, + 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x37, 0x3d, 0xb3, 0x24, + 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x17, 0x1a, 0x92, 0x50, 0x4a, 0xb7, 0x38, 0x25, 0x5b, 0xbf, + 0x02, 0x11, 0x9f, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0x20, 0x31, 0x06, 0x04, 0x00, + 0x00, 0xff, 0xff, 0xd5, 0x3e, 0xfd, 0x43, 0xef, 0x01, 0x00, 0x00, +} + +func (this *MsgSubmitEvidenceResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgSubmitEvidenceResponse) + if !ok { + that2, ok := that.(MsgSubmitEvidenceResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // Send submits an arbitrary Evidence of misbehavior such as equivocation or + // counterfactual signing. + SubmitEvidence(ctx context.Context, in *MsgSubmitEvidence, opts ...grpc.CallOption) (*MsgSubmitEvidenceResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) SubmitEvidence(ctx context.Context, in *MsgSubmitEvidence, opts ...grpc.CallOption) (*MsgSubmitEvidenceResponse, error) { + out := new(MsgSubmitEvidenceResponse) + err := c.cc.Invoke(ctx, "/cosmos.evidence.v1beta1.Msg/SubmitEvidence", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // Send submits an arbitrary Evidence of misbehavior such as equivocation or + // counterfactual signing. + SubmitEvidence(context.Context, *MsgSubmitEvidence) (*MsgSubmitEvidenceResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) SubmitEvidence(ctx context.Context, req *MsgSubmitEvidence) (*MsgSubmitEvidenceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SubmitEvidence not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_SubmitEvidence_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSubmitEvidence) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SubmitEvidence(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.evidence.v1beta1.Msg/SubmitEvidence", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SubmitEvidence(ctx, req.(*MsgSubmitEvidence)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cosmos.evidence.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SubmitEvidence", + Handler: _Msg_SubmitEvidence_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/evidence/v1beta1/tx.proto", } func (m *MsgSubmitEvidence) Marshal() (dAtA []byte, err error) { @@ -134,6 +285,29 @@ func (m *MsgSubmitEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgSubmitEvidenceResponse) 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 *MsgSubmitEvidenceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitEvidenceResponse) 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 @@ -162,6 +336,15 @@ func (m *MsgSubmitEvidence) Size() (n int) { return n } +func (m *MsgSubmitEvidenceResponse) 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 } @@ -289,6 +472,59 @@ func (m *MsgSubmitEvidence) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgSubmitEvidenceResponse) 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: MsgSubmitEvidenceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitEvidenceResponse: 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 { + return ErrInvalidLengthTx + } + if (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 From 301b077e7da648c7c9c691718258b5502cee615f Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Thu, 15 Oct 2020 17:37:38 +0200 Subject: [PATCH 2/6] Add hash in response --- proto/cosmos/evidence/v1beta1/tx.proto | 5 +- x/evidence/handler.go | 3 +- x/evidence/handler_test.go | 5 +- x/evidence/keeper/msg_server.go | 4 +- x/evidence/types/tx.pb.go | 77 +++++++++++++++++++++++--- 5 files changed, 80 insertions(+), 14 deletions(-) diff --git a/proto/cosmos/evidence/v1beta1/tx.proto b/proto/cosmos/evidence/v1beta1/tx.proto index 6d92be7f775e..f740d2ce1995 100644 --- a/proto/cosmos/evidence/v1beta1/tx.proto +++ b/proto/cosmos/evidence/v1beta1/tx.proto @@ -26,4 +26,7 @@ message MsgSubmitEvidence { } // MsgSubmitEvidenceResponse defines the Msg/SubmitEvidence response type. -message MsgSubmitEvidenceResponse {} +message MsgSubmitEvidenceResponse { + // hash defines the hash of the evidence. + bytes hash = 4; +} diff --git a/x/evidence/handler.go b/x/evidence/handler.go index 7cf9d6b687d2..018448759ec8 100644 --- a/x/evidence/handler.go +++ b/x/evidence/handler.go @@ -3,12 +3,11 @@ package evidence import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/evidence/keeper" "github.com/cosmos/cosmos-sdk/x/evidence/types" ) // NewHandler returns a handler for evidence messages. -func NewHandler(k keeper.Keeper) sdk.Handler { +func NewHandler(k types.MsgServer) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) diff --git a/x/evidence/handler_test.go b/x/evidence/handler_test.go index 2faf8b40703e..b3f95c300a4f 100644 --- a/x/evidence/handler_test.go +++ b/x/evidence/handler_test.go @@ -114,7 +114,10 @@ func (suite *HandlerTestSuite) TestMsgSubmitEvidence() { suite.Require().NotNil(res, "expected non-nil result; tc #%d", i) msg := tc.msg.(exported.MsgSubmitEvidenceI) - suite.Require().Equal(msg.GetEvidence().Hash().Bytes(), res.Data, "invalid hash; tc #%d", i) + + var resultData types.MsgSubmitEvidenceResponse + suite.app.AppCodec().UnmarshalBinaryBare(res.Data, &resultData) + suite.Require().Equal(msg.GetEvidence().Hash().Bytes(), resultData.Hash, "invalid hash; tc #%d", i) } } } diff --git a/x/evidence/keeper/msg_server.go b/x/evidence/keeper/msg_server.go index c6528df7362d..efeacfe89b79 100644 --- a/x/evidence/keeper/msg_server.go +++ b/x/evidence/keeper/msg_server.go @@ -26,5 +26,7 @@ func (k Keeper) SubmitEvidence(goCtx context.Context, msg *types.MsgSubmitEviden ), ) - return &types.MsgSubmitEvidenceResponse{}, nil + return &types.MsgSubmitEvidenceResponse{ + Hash: evidence.Hash(), + }, nil } diff --git a/x/evidence/types/tx.pb.go b/x/evidence/types/tx.pb.go index 791f8208f58d..5dc9c0fb6cf3 100644 --- a/x/evidence/types/tx.pb.go +++ b/x/evidence/types/tx.pb.go @@ -4,6 +4,7 @@ package types import ( + bytes "bytes" context "context" fmt "fmt" types "github.com/cosmos/cosmos-sdk/codec/types" @@ -72,6 +73,8 @@ var xxx_messageInfo_MsgSubmitEvidence proto.InternalMessageInfo // MsgSubmitEvidenceResponse defines the Msg/SubmitEvidence response type. type MsgSubmitEvidenceResponse struct { + // hash defines the hash of the evidence. + Hash []byte `protobuf:"bytes,4,opt,name=hash,proto3" json:"hash,omitempty"` } func (m *MsgSubmitEvidenceResponse) Reset() { *m = MsgSubmitEvidenceResponse{} } @@ -107,6 +110,13 @@ func (m *MsgSubmitEvidenceResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSubmitEvidenceResponse proto.InternalMessageInfo +func (m *MsgSubmitEvidenceResponse) GetHash() []byte { + if m != nil { + return m.Hash + } + return nil +} + func init() { proto.RegisterType((*MsgSubmitEvidence)(nil), "cosmos.evidence.v1beta1.MsgSubmitEvidence") proto.RegisterType((*MsgSubmitEvidenceResponse)(nil), "cosmos.evidence.v1beta1.MsgSubmitEvidenceResponse") @@ -115,7 +125,7 @@ func init() { func init() { proto.RegisterFile("cosmos/evidence/v1beta1/tx.proto", fileDescriptor_3e3242cb23c956e0) } var fileDescriptor_3e3242cb23c956e0 = []byte{ - // 299 bytes of a gzipped FileDescriptorProto + // 316 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x2d, 0xcb, 0x4c, 0x49, 0xcd, 0x4b, 0x4e, 0xd5, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x87, 0xa8, @@ -127,14 +137,15 @@ var fileDescriptor_3e3242cb23c956e0 = []byte{ 0x10, 0x42, 0x40, 0xc8, 0x8e, 0x8b, 0x03, 0xe6, 0x24, 0x09, 0x26, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x11, 0x3d, 0x88, 0xdd, 0x7a, 0x30, 0xbb, 0xf5, 0x1c, 0xf3, 0x2a, 0x9d, 0x78, 0x4e, 0x6d, 0xd1, 0xe5, 0x80, 0x99, 0x19, 0x04, 0xd7, 0x63, 0xc5, 0xd1, 0xb1, 0x40, 0x9e, 0xe1, 0xc5, 0x02, 0x79, - 0x06, 0x25, 0x69, 0x2e, 0x49, 0x0c, 0xcb, 0x83, 0x52, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x8d, - 0xca, 0xb9, 0x98, 0x7d, 0x8b, 0xd3, 0x85, 0x0a, 0xb8, 0xf8, 0xd0, 0x5c, 0xa7, 0xa5, 0x87, 0x23, - 0x60, 0xf4, 0x30, 0x0c, 0x93, 0x32, 0x22, 0x5e, 0x2d, 0xcc, 0x62, 0x27, 0xef, 0x15, 0x8f, 0xe4, - 0x18, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, - 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x37, 0x3d, 0xb3, 0x24, - 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x17, 0x1a, 0x92, 0x50, 0x4a, 0xb7, 0x38, 0x25, 0x5b, 0xbf, - 0x02, 0x11, 0x9f, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0x20, 0x31, 0x06, 0x04, 0x00, - 0x00, 0xff, 0xff, 0xd5, 0x3e, 0xfd, 0x43, 0xef, 0x01, 0x00, 0x00, + 0x06, 0x25, 0x7d, 0x2e, 0x49, 0x0c, 0xcb, 0x83, 0x52, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x85, + 0x84, 0xb8, 0x58, 0x32, 0x12, 0x8b, 0x33, 0x24, 0x58, 0x14, 0x18, 0x35, 0x78, 0x82, 0xc0, 0x6c, + 0xa3, 0x72, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x02, 0x2e, 0x3e, 0x34, 0x17, 0x6b, 0xe9, 0xe1, + 0x08, 0x2c, 0x3d, 0x0c, 0x0b, 0xa4, 0x8c, 0x88, 0x57, 0x0b, 0x73, 0x8c, 0x93, 0xf7, 0x8a, 0x47, + 0x72, 0x8c, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, + 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x9b, 0x9e, 0x59, + 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0x0b, 0x0d, 0x5d, 0x28, 0xa5, 0x5b, 0x9c, 0x92, 0xad, + 0x5f, 0x81, 0x88, 0xe3, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x30, 0x19, 0x03, 0x02, + 0x00, 0x00, 0xff, 0xff, 0xa7, 0x78, 0xdf, 0xa8, 0x03, 0x02, 0x00, 0x00, } func (this *MsgSubmitEvidenceResponse) Equal(that interface{}) bool { @@ -156,6 +167,9 @@ func (this *MsgSubmitEvidenceResponse) Equal(that interface{}) bool { } else if this == nil { return false } + if !bytes.Equal(this.Hash, that1.Hash) { + return false + } return true } @@ -305,6 +319,13 @@ func (m *MsgSubmitEvidenceResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro _ = i var l int _ = l + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintTx(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0x22 + } return len(dAtA) - i, nil } @@ -342,6 +363,10 @@ func (m *MsgSubmitEvidenceResponse) Size() (n int) { } var l int _ = l + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -501,6 +526,40 @@ func (m *MsgSubmitEvidenceResponse) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: MsgSubmitEvidenceResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) + if m.Hash == nil { + m.Hash = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) From d4b06b2ed2fd6c1fdc135df1f0e6de06e69b7c8e Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Thu, 15 Oct 2020 17:41:59 +0200 Subject: [PATCH 3/6] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e52621cc53f..b09bc01d73e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Client Breaking * (x/staking) [\#7499](https://github.com/cosmos/cosmos-sdk/pull/7499) `BondStatus` is now a protobuf `enum` instead of an `int32`, and JSON serialized using its protobuf name, so expect names like `BOND_STATUS_UNBONDING` as opposed to `Unbonding`. +* (x/evidence) [\#7538](https://github.com/cosmos/cosmos-sdk/pull/7538) The ABCI's `Result.Data` field of `MsgSubmitEvidence` does not contain the raw evidence's hash, but the encoded `MsgSubmitEvidenceResponse` struct. ### API Breaking From 0869f26616afe2eb518109a43427725fdc442b9f Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Thu, 15 Oct 2020 18:45:44 +0200 Subject: [PATCH 4/6] Update x/evidence/keeper/keeper.go --- x/evidence/keeper/keeper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/evidence/keeper/keeper.go b/x/evidence/keeper/keeper.go index 9868dd74f6ee..346b009ef1fc 100644 --- a/x/evidence/keeper/keeper.go +++ b/x/evidence/keeper/keeper.go @@ -71,7 +71,7 @@ func (k Keeper) GetEvidenceHandler(evidenceRoute string) (types.Handler, error) return k.router.GetRoute(evidenceRoute), nil } -// submitEvidence attempts to match evidence against the keepers router and execute +// SubmitEvidenceI attempts to match evidence against the keepers router and execute // the corresponding registered Evidence Handler. An error is returned if no // registered Handler exists or if the Handler fails. Otherwise, the evidence is // persisted. From f434c3da2578d85b2969187f54ab646b86eacb9e Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Fri, 16 Oct 2020 11:47:38 +0200 Subject: [PATCH 5/6] Update proto/cosmos/evidence/v1beta1/tx.proto Co-authored-by: Marie Gauthier --- proto/cosmos/evidence/v1beta1/tx.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/cosmos/evidence/v1beta1/tx.proto b/proto/cosmos/evidence/v1beta1/tx.proto index f740d2ce1995..38795f25d4e3 100644 --- a/proto/cosmos/evidence/v1beta1/tx.proto +++ b/proto/cosmos/evidence/v1beta1/tx.proto @@ -10,7 +10,7 @@ import "cosmos_proto/cosmos.proto"; // Msg defines the evidence Msg service. service Msg { - // Send submits an arbitrary Evidence of misbehavior such as equivocation or + // SubmitEvidence submits an arbitrary Evidence of misbehavior such as equivocation or // counterfactual signing. rpc SubmitEvidence(MsgSubmitEvidence) returns (MsgSubmitEvidenceResponse); } From 12bf8c18f605ee92641a1b5902e5f1ba7aa998a7 Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Fri, 16 Oct 2020 17:34:17 +0200 Subject: [PATCH 6/6] Use msgServer struct --- x/bank/handler.go | 4 ++-- x/evidence/handler.go | 7 +++++-- x/evidence/keeper/keeper.go | 4 ++-- x/evidence/keeper/keeper_test.go | 10 +++++----- x/evidence/keeper/msg_server.go | 16 +++++++++++++--- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/x/bank/handler.go b/x/bank/handler.go index d7c04897a5df..0fb0f53a4cd8 100644 --- a/x/bank/handler.go +++ b/x/bank/handler.go @@ -9,11 +9,11 @@ import ( // NewHandler returns a handler for "bank" type messages. func NewHandler(k keeper.Keeper) sdk.Handler { + msgServer := keeper.NewMsgServerImpl(k) + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) - msgServer := keeper.NewMsgServerImpl(k) - switch msg := msg.(type) { case *types.MsgSend: res, err := msgServer.Send(sdk.WrapSDKContext(ctx), msg) diff --git a/x/evidence/handler.go b/x/evidence/handler.go index 018448759ec8..93da4d7bf50d 100644 --- a/x/evidence/handler.go +++ b/x/evidence/handler.go @@ -3,17 +3,20 @@ package evidence import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/evidence/keeper" "github.com/cosmos/cosmos-sdk/x/evidence/types" ) // NewHandler returns a handler for evidence messages. -func NewHandler(k types.MsgServer) sdk.Handler { +func NewHandler(k keeper.Keeper) sdk.Handler { + msgServer := keeper.NewMsgServerImpl(k) + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { case *types.MsgSubmitEvidence: - res, err := k.SubmitEvidence(sdk.WrapSDKContext(ctx), msg) + res, err := msgServer.SubmitEvidence(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) default: diff --git a/x/evidence/keeper/keeper.go b/x/evidence/keeper/keeper.go index 346b009ef1fc..e15cd74c8a07 100644 --- a/x/evidence/keeper/keeper.go +++ b/x/evidence/keeper/keeper.go @@ -71,11 +71,11 @@ func (k Keeper) GetEvidenceHandler(evidenceRoute string) (types.Handler, error) return k.router.GetRoute(evidenceRoute), nil } -// SubmitEvidenceI attempts to match evidence against the keepers router and execute +// SubmitEvidence attempts to match evidence against the keepers router and execute // the corresponding registered Evidence Handler. An error is returned if no // registered Handler exists or if the Handler fails. Otherwise, the evidence is // persisted. -func (k Keeper) SubmitEvidenceI(ctx sdk.Context, evidence exported.Evidence) error { +func (k Keeper) SubmitEvidence(ctx sdk.Context, evidence exported.Evidence) error { if _, ok := k.GetEvidence(ctx, evidence.Hash()); ok { return sdkerrors.Wrap(types.ErrEvidenceExists, evidence.Hash().String()) } diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index 81bf275171d7..0017f12f25b8 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -118,7 +118,7 @@ func (suite *KeeperTestSuite) populateEvidence(ctx sdk.Context, numEvidence int) ConsensusAddress: sdk.ConsAddress(pk.PubKey().Address().Bytes()).String(), } - suite.Nil(suite.app.EvidenceKeeper.SubmitEvidenceI(ctx, evidence[i])) + suite.Nil(suite.app.EvidenceKeeper.SubmitEvidence(ctx, evidence[i])) } return evidence @@ -147,7 +147,7 @@ func (suite *KeeperTestSuite) TestSubmitValidEvidence() { ConsensusAddress: sdk.ConsAddress(pk.PubKey().Address().Bytes()).String(), } - suite.Nil(suite.app.EvidenceKeeper.SubmitEvidenceI(ctx, e)) + suite.Nil(suite.app.EvidenceKeeper.SubmitEvidence(ctx, e)) res, ok := suite.app.EvidenceKeeper.GetEvidence(ctx, e.Hash()) suite.True(ok) @@ -165,8 +165,8 @@ func (suite *KeeperTestSuite) TestSubmitValidEvidence_Duplicate() { ConsensusAddress: sdk.ConsAddress(pk.PubKey().Address().Bytes()).String(), } - suite.Nil(suite.app.EvidenceKeeper.SubmitEvidenceI(ctx, e)) - suite.Error(suite.app.EvidenceKeeper.SubmitEvidenceI(ctx, e)) + suite.Nil(suite.app.EvidenceKeeper.SubmitEvidence(ctx, e)) + suite.Error(suite.app.EvidenceKeeper.SubmitEvidence(ctx, e)) res, ok := suite.app.EvidenceKeeper.GetEvidence(ctx, e.Hash()) suite.True(ok) @@ -183,7 +183,7 @@ func (suite *KeeperTestSuite) TestSubmitInvalidEvidence() { ConsensusAddress: sdk.ConsAddress(pk.PubKey().Address().Bytes()).String(), } - suite.Error(suite.app.EvidenceKeeper.SubmitEvidenceI(ctx, e)) + suite.Error(suite.app.EvidenceKeeper.SubmitEvidence(ctx, e)) res, ok := suite.app.EvidenceKeeper.GetEvidence(ctx, e.Hash()) suite.False(ok) diff --git a/x/evidence/keeper/msg_server.go b/x/evidence/keeper/msg_server.go index efeacfe89b79..df3cabd4fe67 100644 --- a/x/evidence/keeper/msg_server.go +++ b/x/evidence/keeper/msg_server.go @@ -7,14 +7,24 @@ import ( "github.com/cosmos/cosmos-sdk/x/evidence/types" ) -var _ types.MsgServer = Keeper{} +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the bank MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} // SubmitEvidence implements the MsgServer.SubmitEvidence method. -func (k Keeper) SubmitEvidence(goCtx context.Context, msg *types.MsgSubmitEvidence) (*types.MsgSubmitEvidenceResponse, error) { +func (ms msgServer) SubmitEvidence(goCtx context.Context, msg *types.MsgSubmitEvidence) (*types.MsgSubmitEvidenceResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) evidence := msg.GetEvidence() - if err := k.SubmitEvidenceI(ctx, evidence); err != nil { + if err := ms.Keeper.SubmitEvidence(ctx, evidence); err != nil { return nil, err }