diff --git a/Makefile b/Makefile index bc1a2daf4ad..e32facd4e14 100644 --- a/Makefile +++ b/Makefile @@ -251,6 +251,10 @@ proto-all: proto-tools proto-gen proto-lint proto-check-breaking proto-gen: @./scripts/protocgen.sh +# This generates the SDK's custom wrapper for google.protobuf.Any. It should only be run manually when needed +proto-gen-any: + @./scripts/protocgen-any.sh + proto-lint: @buf check lint --error-format=json diff --git a/buf.yaml b/buf.yaml index a0b081889b2..ba91745ba7d 100644 --- a/buf.yaml +++ b/buf.yaml @@ -1,6 +1,8 @@ build: roots: - . + excludes: + - third_party/proto/google lint: use: - DEFAULT diff --git a/codec/amino_codec.go b/codec/amino_codec.go index 0140556034f..fc6fa7fdc45 100644 --- a/codec/amino_codec.go +++ b/codec/amino_codec.go @@ -1,5 +1,11 @@ package codec +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/codec/types" +) + // AminoCodec defines a codec that utilizes Amino for both binary and JSON // encoding. type AminoCodec struct { @@ -57,3 +63,7 @@ func (ac *AminoCodec) UnmarshalJSON(bz []byte, ptr interface{}) error { func (ac *AminoCodec) MustUnmarshalJSON(bz []byte, ptr interface{}) { ac.amino.MustUnmarshalJSON(bz, ptr) } + +func (*AminoCodec) UnpackAny(*types.Any, interface{}) error { + return fmt.Errorf("AminoCodec can't handle unpack protobuf Any's") +} diff --git a/codec/codec.go b/codec/codec.go index c5a235a7b4b..dee51a9da78 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -4,6 +4,8 @@ import ( "encoding/binary" "io" + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/gogo/protobuf/proto" ) @@ -31,6 +33,7 @@ type ( MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) JSONMarshaler + types.AnyUnpacker } JSONMarshaler interface { diff --git a/codec/hybrid_codec.go b/codec/hybrid_codec.go index 481d1f29786..7fbd109a3db 100644 --- a/codec/hybrid_codec.go +++ b/codec/hybrid_codec.go @@ -1,5 +1,7 @@ package codec +import "github.com/cosmos/cosmos-sdk/codec/types" + // HybridCodec defines a codec that utilizes Protobuf for binary encoding // and Amino for JSON encoding. type HybridCodec struct { @@ -7,9 +9,9 @@ type HybridCodec struct { amino Marshaler } -func NewHybridCodec(amino *Codec) Marshaler { +func NewHybridCodec(amino *Codec, unpacker types.AnyUnpacker) Marshaler { return &HybridCodec{ - proto: NewProtoCodec(), + proto: NewProtoCodec(unpacker), amino: NewAminoCodec(amino), } } @@ -61,3 +63,7 @@ func (hc *HybridCodec) UnmarshalJSON(bz []byte, ptr interface{}) error { func (hc *HybridCodec) MustUnmarshalJSON(bz []byte, ptr interface{}) { hc.amino.MustUnmarshalJSON(bz, ptr) } + +func (hc *HybridCodec) UnpackAny(any *types.Any, iface interface{}) error { + return hc.proto.UnpackAny(any, iface) +} diff --git a/codec/hybrid_codec_test.go b/codec/hybrid_codec_test.go index 911ae8c9d9f..2718807bd47 100644 --- a/codec/hybrid_codec_test.go +++ b/codec/hybrid_codec_test.go @@ -20,7 +20,7 @@ func TestHybridCodec(t *testing.T) { }{ { "valid encoding and decoding", - codec.NewHybridCodec(createTestCodec()), + codec.NewHybridCodec(createTestCodec(), createTestInterfaceRegistry()), &testdata.Dog{Name: "rufus"}, &testdata.Dog{}, false, @@ -28,7 +28,7 @@ func TestHybridCodec(t *testing.T) { }, { "invalid decode type", - codec.NewHybridCodec(createTestCodec()), + codec.NewHybridCodec(createTestCodec(), createTestInterfaceRegistry()), &testdata.Dog{Name: "rufus"}, &testdata.Cat{}, false, diff --git a/codec/proto_codec.go b/codec/proto_codec.go index 16fca0576dd..2c9825db704 100644 --- a/codec/proto_codec.go +++ b/codec/proto_codec.go @@ -6,15 +6,19 @@ import ( "fmt" "strings" + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/gogo/protobuf/jsonpb" ) // ProtoCodec defines a codec that utilizes Protobuf for both binary and JSON // encoding. -type ProtoCodec struct{} +type ProtoCodec struct { + anyUnpacker types.AnyUnpacker +} -func NewProtoCodec() Marshaler { - return &ProtoCodec{} +func NewProtoCodec(anyUnpacker types.AnyUnpacker) Marshaler { + return &ProtoCodec{anyUnpacker: anyUnpacker} } func (pc *ProtoCodec) MarshalBinaryBare(o ProtoMarshaler) ([]byte, error) { @@ -58,7 +62,15 @@ func (pc *ProtoCodec) MustMarshalBinaryLengthPrefixed(o ProtoMarshaler) []byte { } func (pc *ProtoCodec) UnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) error { - return ptr.Unmarshal(bz) + err := ptr.Unmarshal(bz) + if err != nil { + return err + } + err = types.UnpackInterfaces(ptr, pc.anyUnpacker) + if err != nil { + return err + } + return nil } func (pc *ProtoCodec) MustUnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) { @@ -80,7 +92,7 @@ func (pc *ProtoCodec) UnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshale } bz = bz[n:] - return ptr.Unmarshal(bz) + return pc.UnmarshalBinaryBare(bz, ptr) } func (pc *ProtoCodec) MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) { @@ -121,3 +133,7 @@ func (pc *ProtoCodec) MustUnmarshalJSON(bz []byte, ptr interface{}) { panic(err) } } + +func (pc *ProtoCodec) UnpackAny(any *types.Any, iface interface{}) error { + return pc.anyUnpacker.UnpackAny(any, iface) +} diff --git a/codec/proto_codec_test.go b/codec/proto_codec_test.go index aae71b4dfd1..a914b6f3dbc 100644 --- a/codec/proto_codec_test.go +++ b/codec/proto_codec_test.go @@ -7,8 +7,20 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/testdata" + "github.com/cosmos/cosmos-sdk/codec/types" ) +func createTestInterfaceRegistry() types.InterfaceRegistry { + interfaceRegistry := types.NewInterfaceRegistry() + interfaceRegistry.RegisterInterface("testdata.Animal", + (*testdata.Animal)(nil), + &testdata.Dog{}, + &testdata.Cat{}, + ) + + return interfaceRegistry +} + func TestProtoCodec(t *testing.T) { testCases := []struct { name string @@ -20,7 +32,7 @@ func TestProtoCodec(t *testing.T) { }{ { "valid encoding and decoding", - codec.NewProtoCodec(), + codec.NewProtoCodec(createTestInterfaceRegistry()), &testdata.Dog{Name: "rufus"}, &testdata.Dog{}, false, @@ -28,7 +40,7 @@ func TestProtoCodec(t *testing.T) { }, { "invalid decode type", - codec.NewProtoCodec(), + codec.NewProtoCodec(createTestInterfaceRegistry()), &testdata.Dog{Name: "rufus"}, &testdata.Cat{}, false, diff --git a/codec/testdata/animal.go b/codec/testdata/animal.go index 05c8102487d..04617cb04f7 100644 --- a/codec/testdata/animal.go +++ b/codec/testdata/animal.go @@ -5,6 +5,8 @@ package testdata import ( "fmt" + + "github.com/cosmos/cosmos-sdk/codec/types" ) type Animal interface { @@ -18,3 +20,10 @@ func (c Cat) Greet() string { func (d Dog) Greet() string { return fmt.Sprintf("Roof, my name is %s", d.Name) } + +var _ types.UnpackInterfacesMessage = HasAnimal{} + +func (m HasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error { + var animal Animal + return unpacker.UnpackAny(m.Animal, &animal) +} diff --git a/codec/testdata/proto.pb.go b/codec/testdata/proto.pb.go index d92daf3ec22..1544aa661a8 100644 --- a/codec/testdata/proto.pb.go +++ b/codec/testdata/proto.pb.go @@ -5,6 +5,7 @@ package testdata import ( fmt "fmt" + types "github.com/cosmos/cosmos-sdk/codec/types" proto "github.com/gogo/protobuf/proto" io "io" math "math" @@ -126,28 +127,85 @@ func (m *Cat) GetLives() int32 { return 0 } +type HasAnimal struct { + Animal *types.Any `protobuf:"bytes,1,opt,name=animal,proto3" json:"animal,omitempty"` + X int64 `protobuf:"varint,2,opt,name=x,proto3" json:"x,omitempty"` +} + +func (m *HasAnimal) Reset() { *m = HasAnimal{} } +func (m *HasAnimal) String() string { return proto.CompactTextString(m) } +func (*HasAnimal) ProtoMessage() {} +func (*HasAnimal) Descriptor() ([]byte, []int) { + return fileDescriptor_ae1353846770e6e2, []int{2} +} +func (m *HasAnimal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *HasAnimal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_HasAnimal.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 *HasAnimal) XXX_Merge(src proto.Message) { + xxx_messageInfo_HasAnimal.Merge(m, src) +} +func (m *HasAnimal) XXX_Size() int { + return m.Size() +} +func (m *HasAnimal) XXX_DiscardUnknown() { + xxx_messageInfo_HasAnimal.DiscardUnknown(m) +} + +var xxx_messageInfo_HasAnimal proto.InternalMessageInfo + +func (m *HasAnimal) GetAnimal() *types.Any { + if m != nil { + return m.Animal + } + return nil +} + +func (m *HasAnimal) GetX() int64 { + if m != nil { + return m.X + } + return 0 +} + func init() { proto.RegisterType((*Dog)(nil), "cosmos_sdk.codec.v1.Dog") proto.RegisterType((*Cat)(nil), "cosmos_sdk.codec.v1.Cat") + proto.RegisterType((*HasAnimal)(nil), "cosmos_sdk.codec.v1.HasAnimal") } func init() { proto.RegisterFile("codec/testdata/proto.proto", fileDescriptor_ae1353846770e6e2) } var fileDescriptor_ae1353846770e6e2 = []byte{ - // 195 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0xce, 0x4f, 0x49, - 0x4d, 0xd6, 0x2f, 0x49, 0x2d, 0x2e, 0x49, 0x49, 0x2c, 0x49, 0xd4, 0x2f, 0x28, 0xca, 0x2f, 0xc9, - 0xd7, 0x03, 0x93, 0x42, 0xc2, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xf1, 0xc5, 0x29, 0xd9, 0x7a, - 0x60, 0x65, 0x7a, 0x65, 0x86, 0x4a, 0xba, 0x5c, 0xcc, 0x2e, 0xf9, 0xe9, 0x42, 0x42, 0x5c, 0x2c, - 0xc5, 0x99, 0x55, 0xa9, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x60, 0x36, 0x48, 0x2c, 0x2f, - 0x31, 0x37, 0x55, 0x82, 0x09, 0x22, 0x06, 0x62, 0x2b, 0x99, 0x72, 0x31, 0x3b, 0x27, 0x96, 0x08, - 0x49, 0x70, 0xb1, 0xe7, 0xe6, 0xe7, 0x65, 0x66, 0xa7, 0x16, 0x41, 0x75, 0xc0, 0xb8, 0x42, 0x22, - 0x5c, 0xac, 0x39, 0x99, 0x65, 0xa9, 0xc5, 0x60, 0x5d, 0xac, 0x41, 0x10, 0x8e, 0x93, 0xeb, 0x89, - 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, - 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x69, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, - 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0xdc, 0x07, 0xa5, 0x74, 0x8b, 0x53, 0xb2, 0xf5, 0x51, 0x7d, - 0x93, 0xc4, 0x06, 0xf6, 0x88, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x64, 0x25, 0x07, 0xc7, 0xe6, - 0x00, 0x00, 0x00, + // 264 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0xbd, 0x4e, 0xc3, 0x30, + 0x14, 0x85, 0x63, 0x42, 0x8b, 0x6a, 0x98, 0x4c, 0x87, 0xd0, 0xc1, 0x42, 0x99, 0x90, 0xa0, 0xb6, + 0x00, 0xf1, 0x00, 0xe5, 0x47, 0x30, 0x67, 0x64, 0x41, 0x4e, 0x62, 0x82, 0x95, 0xd8, 0x17, 0xd5, + 0x6e, 0xd5, 0xf2, 0x14, 0x3c, 0x16, 0x63, 0x47, 0x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6b, + 0x6a, 0xcb, 0x9a, 0xef, 0x37, 0x96, 0x0f, 0xfd, 0x57, 0xb7, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, + 0x75, 0xe8, 0x4c, 0xa3, 0x4a, 0x01, 0x00, 0x00, } func (m *Dog) Marshal() (dAtA []byte, err error) { @@ -222,6 +280,46 @@ func (m *Cat) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *HasAnimal) 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 *HasAnimal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *HasAnimal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.X != 0 { + i = encodeVarintProto(dAtA, i, uint64(m.X)) + i-- + dAtA[i] = 0x10 + } + if m.Animal != nil { + { + size, err := m.Animal.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProto(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintProto(dAtA []byte, offset int, v uint64) int { offset -= sovProto(v) base := offset @@ -266,6 +364,22 @@ func (m *Cat) Size() (n int) { return n } +func (m *HasAnimal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Animal != nil { + l = m.Animal.Size() + n += 1 + l + sovProto(uint64(l)) + } + if m.X != 0 { + n += 1 + sovProto(uint64(m.X)) + } + return n +} + func sovProto(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -493,6 +607,114 @@ func (m *Cat) Unmarshal(dAtA []byte) error { } return nil } +func (m *HasAnimal) 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 ErrIntOverflowProto + } + 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: HasAnimal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: HasAnimal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Animal", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProto + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProto + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Animal == nil { + m.Animal = &types.Any{} + } + if err := m.Animal.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field X", wireType) + } + m.X = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.X |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipProto(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthProto + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthProto + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipProto(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/codec/testdata/proto.proto b/codec/testdata/proto.proto index 3616484b8a2..125db8a327c 100644 --- a/codec/testdata/proto.proto +++ b/codec/testdata/proto.proto @@ -1,6 +1,8 @@ syntax = "proto3"; package cosmos_sdk.codec.v1; +import "google/protobuf/any.proto"; + option go_package = "github.com/cosmos/cosmos-sdk/codec/testdata"; message Dog { @@ -12,3 +14,8 @@ message Cat { string moniker = 1; int32 lives = 2; } + +message HasAnimal { + google.protobuf.Any animal = 1; + int64 x = 2; +} diff --git a/codec/types/any.go b/codec/types/any.go new file mode 100644 index 00000000000..9ce08c4e28a --- /dev/null +++ b/codec/types/any.go @@ -0,0 +1,129 @@ +package types + +import ( + "fmt" + + "github.com/gogo/protobuf/proto" +) + +type Any struct { + // A URL/resource name that uniquely identifies the type of the serialized + // protocol buffer message. This string must contain at least + // one "/" character. The last segment of the URL's path must represent + // the fully qualified name of the type (as in + // `path/google.protobuf.Duration`). The name should be in a canonical form + // (e.g., leading "." is not accepted). + // + // In practice, teams usually precompile into the binary all types that they + // expect it to use in the context of Any. However, for URLs which use the + // scheme `http`, `https`, or no scheme, one can optionally set up a type + // server that maps type URLs to message definitions as follows: + // + // * If no scheme is provided, `https` is assumed. + // * An HTTP GET on the URL must yield a [google.protobuf.Type][] + // value in binary format, or produce an error. + // * Applications are allowed to cache lookup results based on the + // URL, or have them precompiled into a binary to avoid any + // lookup. Therefore, binary compatibility needs to be preserved + // on changes to types. (Use versioned type names to manage + // breaking changes.) + // + // Note: this functionality is not currently available in the official + // protobuf release, and it is not used for type URLs beginning with + // type.googleapis.com. + // + // Schemes other than `http`, `https` (or the empty scheme) might be + // used with implementation specific semantics. + + // nolint + TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl,proto3" json:"type_url,omitempty"` + // Must be a valid serialized protocol buffer of the above specified type. + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + + // nolint + XXX_NoUnkeyedLiteral struct{} `json:"-"` + + // nolint + XXX_unrecognized []byte `json:"-"` + + // nolint + XXX_sizecache int32 `json:"-"` + + cachedValue interface{} +} + +// NewAnyWithValue constructs a new Any packed with the value provided or +// returns an error if that value couldn't be packed. This also caches +// the packed value so that it can be retrieved from GetCachedValue without +// unmarshaling +func NewAnyWithValue(value proto.Message) (*Any, error) { + any := &Any{} + + err := any.Pack(value) + if err != nil { + return nil, err + } + + return any, nil +} + +// Pack packs the value x in the Any or returns an error. This also caches +// the packed value so that it can be retrieved from GetCachedValue without +// unmarshaling +func (any *Any) Pack(x proto.Message) error { + any.TypeUrl = "/" + proto.MessageName(x) + bz, err := proto.Marshal(x) + if err != nil { + return err + } + + any.Value = bz + any.cachedValue = x + + return nil +} + +// GetCachedValue returns the cached value from the Any if present +func (any *Any) GetCachedValue() interface{} { + return any.cachedValue +} + +// ClearCachedValue clears the cached value from the Any +func (any *Any) ClearCachedValue() { + any.cachedValue = nil +} + +// MarshalAny is a convenience function for packing the provided value in an +// Any and then proto marshaling it to bytes +func MarshalAny(x interface{}) ([]byte, error) { + msg, ok := x.(proto.Message) + if !ok { + return nil, fmt.Errorf("can't proto marshal %T", x) + } + + any := &Any{} + err := any.Pack(msg) + if err != nil { + return nil, err + } + + return any.Marshal() +} + +// UnmarshalAny is a convenience function for proto unmarshaling an Any from +// bz and then unpacking it to the interface pointer passed in as iface using +// the provided AnyUnpacker or returning an error +// +// Ex: +// var x MyInterface +// err := UnmarshalAny(unpacker, &x, bz) +func UnmarshalAny(unpacker AnyUnpacker, iface interface{}, bz []byte) error { + any := &Any{} + + err := any.Unmarshal(bz) + if err != nil { + return err + } + + return unpacker.UnpackAny(any, iface) +} diff --git a/codec/types/any.pb.go b/codec/types/any.pb.go new file mode 100644 index 00000000000..d084381696f --- /dev/null +++ b/codec/types/any.pb.go @@ -0,0 +1,584 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: third_party/proto/google/protobuf/any.proto + +package types + +import ( + bytes "bytes" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" + reflect "reflect" + strings "strings" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func (m *Any) Reset() { *m = Any{} } +func (*Any) ProtoMessage() {} +func (*Any) Descriptor() ([]byte, []int) { + return fileDescriptor_cb68f365a8e2bcdc, []int{0} +} +func (*Any) XXX_WellKnownType() string { return "Any" } +func (m *Any) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Any) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Any.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 *Any) XXX_Merge(src proto.Message) { + xxx_messageInfo_Any.Merge(m, src) +} +func (m *Any) XXX_Size() int { + return m.Size() +} +func (m *Any) XXX_DiscardUnknown() { + xxx_messageInfo_Any.DiscardUnknown(m) +} + +var xxx_messageInfo_Any proto.InternalMessageInfo + +func (m *Any) GetTypeUrl() string { + if m != nil { + return m.TypeUrl + } + return "" +} + +func (m *Any) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +func (*Any) XXX_MessageName() string { + return "google.protobuf.Any" +} +func init() { +} + +func init() { + proto.RegisterFile("third_party/proto/google/protobuf/any.proto", fileDescriptor_cb68f365a8e2bcdc) +} + +var fileDescriptor_cb68f365a8e2bcdc = []byte{ + // 246 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x2e,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1, 0x82, 0x2c, 0x2f, 0x5e, 0xc4, 0xc4, 0xec, 0x1e, 0xe0, 0xb4, 0x8a, 0x49, + 0xce, 0x1d, 0xa2, 0x34, 0x00, 0xaa, 0x54, 0x2f, 0x3c, 0x35, 0x27, 0xc7, 0x3b, 0x2f, 0xbf, 0x3c, + 0x2f, 0x04, 0xa4, 0x2c, 0x89, 0x0d, 0x6c, 0x86, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x16, 0xc3, + 0x46, 0x5f, 0x32, 0x01, 0x00, 0x00, +} + +func (this *Any) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*Any) + if !ok { + that2, ok := that.(Any) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.TypeUrl != that1.TypeUrl { + if this.TypeUrl < that1.TypeUrl { + return -1 + } + return 1 + } + if c := bytes.Compare(this.Value, that1.Value); c != 0 { + return c + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *Any) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Any) + if !ok { + that2, ok := that.(Any) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.TypeUrl != that1.TypeUrl { + return false + } + if !bytes.Equal(this.Value, that1.Value) { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Any) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&types.Any{") + s = append(s, "TypeUrl: "+fmt.Sprintf("%#v", this.TypeUrl)+",\n") + s = append(s, "Value: "+fmt.Sprintf("%#v", this.Value)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringAny(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} +func (m *Any) 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 *Any) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Any) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintAny(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x12 + } + if len(m.TypeUrl) > 0 { + i -= len(m.TypeUrl) + copy(dAtA[i:], m.TypeUrl) + i = encodeVarintAny(dAtA, i, uint64(len(m.TypeUrl))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintAny(dAtA []byte, offset int, v uint64) int { + offset -= sovAny(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func NewPopulatedAny(r randyAny, easy bool) *Any { + this := &Any{} + this.TypeUrl = string(randStringAny(r)) + v1 := r.Intn(100) + this.Value = make([]byte, v1) + for i := 0; i < v1; i++ { + this.Value[i] = byte(r.Intn(256)) + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedAny(r, 3) + } + return this +} + +type randyAny interface { + Float32() float32 + Float64() float64 + Int63() int64 + Int31() int32 + Uint32() uint32 + Intn(n int) int +} + +func randUTF8RuneAny(r randyAny) rune { + ru := r.Intn(62) + if ru < 10 { + return rune(ru + 48) + } else if ru < 36 { + return rune(ru + 55) + } + return rune(ru + 61) +} +func randStringAny(r randyAny) string { + v2 := r.Intn(100) + tmps := make([]rune, v2) + for i := 0; i < v2; i++ { + tmps[i] = randUTF8RuneAny(r) + } + return string(tmps) +} +func randUnrecognizedAny(r randyAny, maxFieldNumber int) (dAtA []byte) { + l := r.Intn(5) + for i := 0; i < l; i++ { + wire := r.Intn(4) + if wire == 3 { + wire = 5 + } + fieldNumber := maxFieldNumber + r.Intn(100) + dAtA = randFieldAny(dAtA, r, fieldNumber, wire) + } + return dAtA +} +func randFieldAny(dAtA []byte, r randyAny, fieldNumber int, wire int) []byte { + key := uint32(fieldNumber)<<3 | uint32(wire) + switch wire { + case 0: + dAtA = encodeVarintPopulateAny(dAtA, uint64(key)) + v3 := r.Int63() + if r.Intn(2) == 0 { + v3 *= -1 + } + dAtA = encodeVarintPopulateAny(dAtA, uint64(v3)) + case 1: + dAtA = encodeVarintPopulateAny(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + case 2: + dAtA = encodeVarintPopulateAny(dAtA, uint64(key)) + ll := r.Intn(100) + dAtA = encodeVarintPopulateAny(dAtA, uint64(ll)) + for j := 0; j < ll; j++ { + dAtA = append(dAtA, byte(r.Intn(256))) + } + default: + dAtA = encodeVarintPopulateAny(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + } + return dAtA +} +func encodeVarintPopulateAny(dAtA []byte, v uint64) []byte { + for v >= 1<<7 { + dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80)) + v >>= 7 + } + dAtA = append(dAtA, uint8(v)) + return dAtA +} +func (m *Any) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.TypeUrl) + if l > 0 { + n += 1 + l + sovAny(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovAny(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovAny(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozAny(x uint64) (n int) { + return sovAny(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *Any) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Any{`, + `TypeUrl:` + fmt.Sprintf("%v", this.TypeUrl) + `,`, + `Value:` + fmt.Sprintf("%v", this.Value) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func valueToStringAny(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *Any) 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 ErrIntOverflowAny + } + 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: Any: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Any: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TypeUrl", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAny + } + 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 ErrInvalidLengthAny + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAny + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TypeUrl = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAny + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAny + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAny + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAny(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthAny + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthAny + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAny(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAny + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAny + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAny + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthAny + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupAny + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthAny + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthAny = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAny = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAny = fmt.Errorf("proto: unexpected end of group") +) diff --git a/codec/types/doc.go b/codec/types/doc.go new file mode 100644 index 00000000000..9f89f0c9128 --- /dev/null +++ b/codec/types/doc.go @@ -0,0 +1,6 @@ +/* +Package types defines a custom wrapper for google.protobuf.Any which supports +cached values as well as InterfaceRegistry which keeps track of types which can +be used with Any for both security and introspection +*/ +package types diff --git a/codec/types/interface_registry.go b/codec/types/interface_registry.go new file mode 100644 index 00000000000..2403039eed6 --- /dev/null +++ b/codec/types/interface_registry.go @@ -0,0 +1,165 @@ +package types + +import ( + "fmt" + "reflect" + + "github.com/gogo/protobuf/proto" +) + +// AnyUnpacker is an interface which allows safely unpacking types packed +// in Any's against a whitelist of registered types +type AnyUnpacker interface { + // UnpackAny unpacks the value in any to the interface pointer passed in as + // iface. Note that the type in any must have been registered in the + // underlying whitelist registry as a concrete type for that interface + // Ex: + // var msg sdk.Msg + // err := cdc.UnpackAny(any, &msg) + // ... + UnpackAny(any *Any, iface interface{}) error +} + +// InterfaceRegistry provides a mechanism for registering interfaces and +// implementations that can be safely unpacked from Any +type InterfaceRegistry interface { + AnyUnpacker + + // RegisterInterface associates protoName as the public name for the + // interface passed in as iface. This is to be used primarily to create + // a public facing registry of interface implementations for clients. + // protoName should be a well-chosen public facing name that remains stable. + // RegisterInterface takes an optional list of impls to be registered + // as implementations of iface. + // + // Ex: + // registry.RegisterInterface("cosmos_sdk.Msg", (*sdk.Msg)(nil)) + RegisterInterface(protoName string, iface interface{}, impls ...proto.Message) + + // RegisterImplementations registers impls as concrete implementations of + // the interface iface. + // + // Ex: + // registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSend{}, &MsgMultiSend{}) + RegisterImplementations(iface interface{}, impls ...proto.Message) +} + +// UnpackInterfacesMessage is meant to extend protobuf types (which implement +// proto.Message) to support a post-deserialization phase which unpacks +// types packed within Any's using the whitelist provided by AnyUnpacker +type UnpackInterfacesMessage interface { + // UnpackInterfaces is implemented in order to unpack values packed within + // Any's using the AnyUnpacker. It should generally be implemented as + // follows: + // func (s *MyStruct) UnpackInterfaces(unpacker AnyUnpacker) error { + // var x AnInterface + // // where X is an Any field on MyStruct + // err := unpacker.UnpackAny(s.X, &x) + // if err != nil { + // return nil + // } + // // where Y is a field on MyStruct that implements UnpackInterfacesMessage itself + // err = s.Y.UnpackInterfaces(unpacker) + // if err != nil { + // return nil + // } + // return nil + // } + UnpackInterfaces(unpacker AnyUnpacker) error +} + +type interfaceRegistry struct { + interfaceNames map[string]reflect.Type + interfaceImpls map[reflect.Type]interfaceMap +} + +type interfaceMap = map[string]reflect.Type + +// NewInterfaceRegistry returns a new InterfaceRegistry +func NewInterfaceRegistry() InterfaceRegistry { + return &interfaceRegistry{ + interfaceNames: map[string]reflect.Type{}, + interfaceImpls: map[reflect.Type]interfaceMap{}, + } +} + +func (registry *interfaceRegistry) RegisterInterface(protoName string, iface interface{}, impls ...proto.Message) { + registry.interfaceNames[protoName] = reflect.TypeOf(iface) + registry.RegisterImplementations(iface, impls...) +} + +func (registry *interfaceRegistry) RegisterImplementations(iface interface{}, impls ...proto.Message) { + ityp := reflect.TypeOf(iface).Elem() + imap, found := registry.interfaceImpls[ityp] + if !found { + imap = map[string]reflect.Type{} + } + + for _, impl := range impls { + implType := reflect.TypeOf(impl) + if !implType.AssignableTo(ityp) { + panic(fmt.Errorf("type %T doesn't actually implement interface %T", implType, ityp)) + } + + imap["/"+proto.MessageName(impl)] = implType + } + + registry.interfaceImpls[ityp] = imap +} + +func (registry *interfaceRegistry) UnpackAny(any *Any, iface interface{}) error { + rv := reflect.ValueOf(iface) + if rv.Kind() != reflect.Ptr { + return fmt.Errorf("UnpackAny expects a pointer") + } + + rt := rv.Elem().Type() + + cachedValue := any.cachedValue + if cachedValue != nil { + if reflect.TypeOf(cachedValue).AssignableTo(rt) { + rv.Elem().Set(reflect.ValueOf(cachedValue)) + return nil + } + } + + imap, found := registry.interfaceImpls[rt] + if !found { + return fmt.Errorf("no registered implementations of interface type %T", iface) + } + + typ, found := imap[any.TypeUrl] + if !found { + return fmt.Errorf("no concrete type registered for type URL %s against interface %T", any.TypeUrl, iface) + } + + msg, ok := reflect.New(typ.Elem()).Interface().(proto.Message) + if !ok { + return fmt.Errorf("can't proto unmarshal %T", msg) + } + + err := proto.Unmarshal(any.Value, msg) + if err != nil { + return err + } + + err = UnpackInterfaces(msg, registry) + if err != nil { + return err + } + + rv.Elem().Set(reflect.ValueOf(msg)) + + any.cachedValue = msg + + return nil +} + +// UnpackInterfaces is a convenience function that calls UnpackInterfaces +// on x if x implements UnpackInterfacesMessage +func UnpackInterfaces(x interface{}, unpacker AnyUnpacker) error { + if msg, ok := x.(UnpackInterfacesMessage); ok { + return msg.UnpackInterfaces(unpacker) + } + return nil +} diff --git a/codec/types/types_test.go b/codec/types/types_test.go new file mode 100644 index 00000000000..f4f44b3a734 --- /dev/null +++ b/codec/types/types_test.go @@ -0,0 +1,120 @@ +package types_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/codec/types" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/codec/testdata" +) + +func NewTestInterfaceRegistry() types.InterfaceRegistry { + registry := types.NewInterfaceRegistry() + registry.RegisterInterface("Animal", (*testdata.Animal)(nil)) + registry.RegisterImplementations( + (*testdata.Animal)(nil), + &testdata.Dog{}, + &testdata.Cat{}, + ) + return registry +} + +func TestPackUnpack(t *testing.T) { + registry := NewTestInterfaceRegistry() + + spot := &testdata.Dog{Name: "Spot"} + any := types.Any{} + err := any.Pack(spot) + require.NoError(t, err) + + require.Equal(t, spot, any.GetCachedValue()) + + // without cache + any.ClearCachedValue() + var animal testdata.Animal + err = registry.UnpackAny(&any, &animal) + require.NoError(t, err) + require.Equal(t, spot, animal) + + // with cache + err = any.Pack(spot) + require.Equal(t, spot, any.GetCachedValue()) + require.NoError(t, err) + err = registry.UnpackAny(&any, &animal) + require.NoError(t, err) + require.Equal(t, spot, animal) +} + +func TestMarshalAny(t *testing.T) { + registry := types.NewInterfaceRegistry() + + kitty := &testdata.Cat{Moniker: "Kitty"} + bz, err := types.MarshalAny(kitty) + require.NoError(t, err) + + var animal testdata.Animal + + // empty registry should fail + err = types.UnmarshalAny(registry, &animal, bz) + require.Error(t, err) + + // wrong type registration should fail + registry.RegisterImplementations((*testdata.Animal)(nil), &testdata.Dog{}) + err = types.UnmarshalAny(registry, &animal, bz) + require.Error(t, err) + + // should pass + registry = NewTestInterfaceRegistry() + err = types.UnmarshalAny(registry, &animal, bz) + require.NoError(t, err) + require.Equal(t, kitty, animal) + + // nil should fail + registry = NewTestInterfaceRegistry() + err = types.UnmarshalAny(registry, nil, bz) +} + +type TestI interface { + DoSomething() +} + +func TestRegister(t *testing.T) { + registry := types.NewInterfaceRegistry() + registry.RegisterInterface("Animal", (*testdata.Animal)(nil)) + registry.RegisterInterface("TestI", (*TestI)(nil)) + require.NotPanics(t, func() { + registry.RegisterImplementations((*testdata.Animal)(nil), &testdata.Dog{}) + }) + require.Panics(t, func() { + registry.RegisterImplementations((*TestI)(nil), &testdata.Dog{}) + }) + require.Panics(t, func() { + registry.RegisterImplementations((*TestI)(nil), nil) + }) +} + +func TestUnpackInterfaces(t *testing.T) { + registry := NewTestInterfaceRegistry() + + spot := &testdata.Dog{Name: "Spot"} + any, err := types.NewAnyWithValue(spot) + require.NoError(t, err) + + hasAny := testdata.HasAnimal{ + Animal: any, + X: 1, + } + bz, err := hasAny.Marshal() + require.NoError(t, err) + + var hasAny2 testdata.HasAnimal + err = hasAny2.Unmarshal(bz) + require.NoError(t, err) + + err = types.UnpackInterfaces(hasAny2, registry) + require.NoError(t, err) + + require.Equal(t, spot, hasAny2.Animal.GetCachedValue()) +} diff --git a/docs/architecture/adr-019-protobuf-state-encoding.md b/docs/architecture/adr-019-protobuf-state-encoding.md index 98f9db6b82a..079c07ac3b8 100644 --- a/docs/architecture/adr-019-protobuf-state-encoding.md +++ b/docs/architecture/adr-019-protobuf-state-encoding.md @@ -262,13 +262,13 @@ To implement the `UnpackInterfaces` phase of deserialization which unpacks interfaces wrapped in `Any` before they're needed, we create an interface that `sdk.Msg`s and other types can implement: ```go -type UnpackInterfacesMsg interface { +type UnpackInterfacesMessage interface { UnpackInterfaces(InterfaceUnpacker) error } ``` We also introduce a private `cachedValue interface{}` field onto the `Any` -struct itself with a public getter `GetUnpackedValue() interface{}`. +struct itself with a public getter `GetCachedValue() interface{}`. The `UnpackInterfaces` method is to be invoked during message deserialization right after `Unmarshal` and any interface values packed in `Any`s will be decoded @@ -295,7 +295,7 @@ func (msg MsgSubmitEvidence) UnpackInterfaces(ctx sdk.InterfaceRegistry) error { } func (msg MsgSubmitEvidence) GetEvidence() eviexported.Evidence { - return msg.Evidence.GetUnpackedValue().(eviexported.Evidence) + return msg.Evidence.GetCachedValue().(eviexported.Evidence) } ``` diff --git a/scripts/protocgen-any.sh b/scripts/protocgen-any.sh new file mode 100755 index 00000000000..5622a91eea9 --- /dev/null +++ b/scripts/protocgen-any.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# This script generates a custom wrapper for google.protobuf.Any in +# codec/types/any.pb.go with a custom generated struct that lives in +# codec/types/any.go + +set -eo pipefail + +go install github.com/gogo/protobuf/protoc-gen-gogotypes + +protoc -I. --gogotypes_out=./codec/types third_party/proto/google/protobuf/any.proto +mv codec/types/third_party/proto/google/protobuf/any.pb.go codec/types +rm -rf codec/types/third_party + +# This removes the call to RegisterType in the custom generated Any wrapper +# so that only the Any type provided by gogo protobuf is registered in the +# global gogo protobuf type registry, which we aren't actually using +sed '/proto\.RegisterType/d' codec/types/any.pb.go > tmp && mv tmp codec/types/any.pb.go diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index 0818824a41b..1236a4417a4 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -6,6 +6,7 @@ proto_dirs=$(find . -path ./third_party -prune -o -name '*.proto' -print0 | xarg for dir in $proto_dirs; do protoc \ -I. \ - --gocosmos_out=plugins=interfacetype,paths=source_relative:. \ + --gocosmos_out=plugins=interfacetype,paths=source_relative,\ +Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \ $(find "${dir}" -name '*.proto') done diff --git a/simapp/app.go b/simapp/app.go index c7b474b6d7d..56021c8d86b 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -4,6 +4,8 @@ import ( "io" "os" + "github.com/cosmos/cosmos-sdk/codec/types" + abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" tmos "github.com/tendermint/tendermint/libs/os" @@ -94,7 +96,8 @@ var _ App = (*SimApp)(nil) // capabilities aren't needed for testing. type SimApp struct { *baseapp.BaseApp - cdc *codec.Codec + cdc *codec.Codec + appCodec *std.Codec invCheckPeriod uint @@ -140,8 +143,7 @@ func NewSimApp( ) *SimApp { // TODO: Remove cdc in favor of appCodec once all modules are migrated. - cdc := std.MakeCodec(ModuleBasics) - appCodec := std.NewAppCodec(cdc) + appCodec, cdc := MakeCodecs() bApp := baseapp.NewBaseApp(appName, logger, db, auth.DefaultTxDecoder(cdc), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) @@ -159,6 +161,7 @@ func NewSimApp( app := &SimApp{ BaseApp: bApp, cdc: cdc, + appCodec: appCodec, invCheckPeriod: invCheckPeriod, keys: keys, tkeys: tkeys, @@ -248,7 +251,7 @@ func NewSimApp( // create evidence keeper with router evidenceKeeper := evidence.NewKeeper( - appCodec, keys[evidence.StoreKey], &app.StakingKeeper, app.SlashingKeeper, + evidence.NewAnyCodec(appCodec), keys[evidence.StoreKey], &app.StakingKeeper, app.SlashingKeeper, ) evidenceRouter := evidence.NewRouter(). AddRoute(ibcclient.RouterKey, ibcclient.HandlerClientMisbehaviour(app.IBCKeeper.ClientKeeper)) @@ -270,7 +273,7 @@ func NewSimApp( distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), upgrade.NewAppModule(app.UpgradeKeeper), - evidence.NewAppModule(appCodec, app.EvidenceKeeper), + evidence.NewAppModule(app.EvidenceKeeper), ibc.NewAppModule(app.IBCKeeper), params.NewAppModule(app.ParamsKeeper), transferModule, @@ -314,7 +317,7 @@ func NewSimApp( distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), params.NewAppModule(app.ParamsKeeper), - evidence.NewAppModule(appCodec, app.EvidenceKeeper), + evidence.NewAppModule(app.EvidenceKeeper), ) app.sm.RegisterStoreDecoders() @@ -354,6 +357,18 @@ func NewSimApp( return app } +// MakeCodecs constructs the *std.Codec and *codec.Codec instances used by +// simapp. It is useful for tests and clients who do not want to construct the +// full simapp +func MakeCodecs() (*std.Codec, *codec.Codec) { + cdc := std.MakeCodec(ModuleBasics) + interfaceRegistry := types.NewInterfaceRegistry() + sdk.RegisterInterfaces(interfaceRegistry) + ModuleBasics.RegisterInterfaceModules(interfaceRegistry) + appCodec := std.NewAppCodec(cdc, interfaceRegistry) + return appCodec, cdc +} + // Name returns the name of the App func (app *SimApp) Name() string { return app.BaseApp.Name() } @@ -407,6 +422,14 @@ func (app *SimApp) Codec() *codec.Codec { return app.cdc } +// AppCodec returns SimApp's app codec. +// +// NOTE: This is solely to be used for testing purposes as it may be desirable +// for modules to register their own custom testing types. +func (app *SimApp) AppCodec() *std.Codec { + return app.appCodec +} + // GetKey returns the KVStoreKey for the provided store key. // // NOTE: This is solely to be used for testing purposes. diff --git a/simapp/cmd/simcli/main.go b/simapp/cmd/simcli/main.go index a4086c8f2f3..337fa166e3f 100644 --- a/simapp/cmd/simcli/main.go +++ b/simapp/cmd/simcli/main.go @@ -5,8 +5,6 @@ import ( "os" "path" - "github.com/cosmos/cosmos-sdk/std" - "github.com/spf13/cobra" "github.com/spf13/viper" "github.com/tendermint/go-amino" @@ -26,8 +24,7 @@ import ( ) var ( - cdc = std.MakeCodec(simapp.ModuleBasics) - appCodec = std.NewAppCodec(cdc) + appCodec, cdc = simapp.MakeCodecs() ) func init() { diff --git a/simapp/cmd/simd/main.go b/simapp/cmd/simd/main.go index cd393eeaa12..7078a453885 100644 --- a/simapp/cmd/simd/main.go +++ b/simapp/cmd/simd/main.go @@ -4,8 +4,6 @@ import ( "encoding/json" "io" - "github.com/cosmos/cosmos-sdk/std" - "github.com/spf13/cobra" "github.com/spf13/viper" abci "github.com/tendermint/tendermint/abci/types" @@ -31,8 +29,7 @@ const flagInvCheckPeriod = "inv-check-period" var invCheckPeriod uint func main() { - cdc := std.MakeCodec(simapp.ModuleBasics) - appCodec := std.NewAppCodec(cdc) + appCodec, cdc := simapp.MakeCodecs() config := sdk.GetConfig() config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub) diff --git a/std/codec.go b/std/codec.go index ef439745e7e..5557363f515 100644 --- a/std/codec.go +++ b/std/codec.go @@ -2,6 +2,7 @@ package std import ( "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/auth" @@ -9,16 +10,13 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/vesting" "github.com/cosmos/cosmos-sdk/x/bank" bankexported "github.com/cosmos/cosmos-sdk/x/bank/exported" - "github.com/cosmos/cosmos-sdk/x/evidence" - eviexported "github.com/cosmos/cosmos-sdk/x/evidence/exported" gov "github.com/cosmos/cosmos-sdk/x/gov/types" ) var ( - _ auth.Codec = (*Codec)(nil) - _ bank.Codec = (*Codec)(nil) - _ evidence.Codec = (*Codec)(nil) - _ gov.Codec = (*Codec)(nil) + _ auth.Codec = (*Codec)(nil) + _ bank.Codec = (*Codec)(nil) + _ gov.Codec = (*Codec)(nil) ) // Codec defines the application-level codec. This codec contains all the @@ -29,10 +27,12 @@ type Codec struct { // Keep reference to the amino codec to allow backwards compatibility along // with type, and interface registration. amino *codec.Codec + + anyUnpacker types.AnyUnpacker } -func NewAppCodec(amino *codec.Codec) *Codec { - return &Codec{Marshaler: codec.NewHybridCodec(amino), amino: amino} +func NewAppCodec(amino *codec.Codec, anyUnpacker types.AnyUnpacker) *Codec { + return &Codec{Marshaler: codec.NewHybridCodec(amino, anyUnpacker), amino: amino, anyUnpacker: anyUnpacker} } // MarshalAccount marshals an Account interface. If the given type implements @@ -113,46 +113,6 @@ func (c *Codec) UnmarshalSupplyJSON(bz []byte) (bankexported.SupplyI, error) { return supply.GetSupplyI(), nil } -// MarshalEvidence marshals an Evidence interface. If the given type implements -// the Marshaler interface, it is treated as a Proto-defined message and -// serialized that way. Otherwise, it falls back on the internal Amino codec. -func (c *Codec) MarshalEvidence(evidenceI eviexported.Evidence) ([]byte, error) { - evidence := &Evidence{} - if err := evidence.SetEvidence(evidenceI); err != nil { - return nil, err - } - - return c.Marshaler.MarshalBinaryBare(evidence) -} - -// UnmarshalEvidence returns an Evidence interface from raw encoded evidence -// bytes of a Proto-based Evidence type. An error is returned upon decoding -// failure. -func (c *Codec) UnmarshalEvidence(bz []byte) (eviexported.Evidence, error) { - evidence := &Evidence{} - if err := c.Marshaler.UnmarshalBinaryBare(bz, evidence); err != nil { - return nil, err - } - - return evidence.GetEvidence(), nil -} - -// MarshalEvidenceJSON JSON encodes an evidence object implementing the Evidence -// interface. -func (c *Codec) MarshalEvidenceJSON(evidence eviexported.Evidence) ([]byte, error) { - return c.Marshaler.MarshalJSON(evidence) -} - -// UnmarshalEvidenceJSON returns an Evidence from JSON encoded bytes -func (c *Codec) UnmarshalEvidenceJSON(bz []byte) (eviexported.Evidence, error) { - evidence := &Evidence{} - if err := c.Marshaler.UnmarshalJSON(bz, evidence); err != nil { - return nil, err - } - - return evidence.GetEvidence(), nil -} - // MarshalProposal marshals a Proposal. It accepts a Proposal defined by the x/gov // module and uses the application-level Proposal type which has the concrete // Content implementation to serialize. diff --git a/std/codec.pb.go b/std/codec.pb.go index 269f6706fd4..9f612475f72 100644 --- a/std/codec.pb.go +++ b/std/codec.pb.go @@ -6,22 +6,20 @@ package std import ( fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types10 "github.com/cosmos/cosmos-sdk/types" + types9 "github.com/cosmos/cosmos-sdk/types" github_com_cosmos_cosmos_sdk_x_auth_exported "github.com/cosmos/cosmos-sdk/x/auth/exported" types "github.com/cosmos/cosmos-sdk/x/auth/types" types1 "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" github_com_cosmos_cosmos_sdk_x_bank_exported "github.com/cosmos/cosmos-sdk/x/bank/exported" types2 "github.com/cosmos/cosmos-sdk/x/bank/types" - types7 "github.com/cosmos/cosmos-sdk/x/crisis/types" - types6 "github.com/cosmos/cosmos-sdk/x/distribution/types" - github_com_cosmos_cosmos_sdk_x_evidence_exported "github.com/cosmos/cosmos-sdk/x/evidence/exported" - types3 "github.com/cosmos/cosmos-sdk/x/evidence/types" + types6 "github.com/cosmos/cosmos-sdk/x/crisis/types" + types5 "github.com/cosmos/cosmos-sdk/x/distribution/types" github_com_cosmos_cosmos_sdk_x_gov_types "github.com/cosmos/cosmos-sdk/x/gov/types" - types4 "github.com/cosmos/cosmos-sdk/x/gov/types" + types3 "github.com/cosmos/cosmos-sdk/x/gov/types" proposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" - types8 "github.com/cosmos/cosmos-sdk/x/slashing/types" - types9 "github.com/cosmos/cosmos-sdk/x/staking/types" - types5 "github.com/cosmos/cosmos-sdk/x/upgrade/types" + types7 "github.com/cosmos/cosmos-sdk/x/slashing/types" + types8 "github.com/cosmos/cosmos-sdk/x/staking/types" + types4 "github.com/cosmos/cosmos-sdk/x/upgrade/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" _ "github.com/regen-network/cosmos-proto" @@ -244,127 +242,10 @@ func (*Supply) XXX_OneofWrappers() []interface{} { } } -// Evidence defines the application-level allowed Evidence to be submitted via a -// MsgSubmitEvidence message. -type Evidence struct { - // sum defines a set of all acceptable concrete Evidence implementations. - // - // Types that are valid to be assigned to Sum: - // *Evidence_Equivocation - Sum isEvidence_Sum `protobuf_oneof:"sum"` -} - -func (m *Evidence) Reset() { *m = Evidence{} } -func (m *Evidence) String() string { return proto.CompactTextString(m) } -func (*Evidence) ProtoMessage() {} -func (*Evidence) Descriptor() ([]byte, []int) { - return fileDescriptor_ff851c3a98ef46f7, []int{2} -} -func (m *Evidence) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Evidence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Evidence.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 *Evidence) XXX_Merge(src proto.Message) { - xxx_messageInfo_Evidence.Merge(m, src) -} -func (m *Evidence) XXX_Size() int { - return m.Size() -} -func (m *Evidence) XXX_DiscardUnknown() { - xxx_messageInfo_Evidence.DiscardUnknown(m) -} - -var xxx_messageInfo_Evidence proto.InternalMessageInfo - -type isEvidence_Sum interface { - isEvidence_Sum() - Equal(interface{}) bool - MarshalTo([]byte) (int, error) - Size() int -} - -type Evidence_Equivocation struct { - Equivocation *types3.Equivocation `protobuf:"bytes,1,opt,name=equivocation,proto3,oneof" json:"equivocation,omitempty"` -} - -func (*Evidence_Equivocation) isEvidence_Sum() {} - -func (m *Evidence) GetSum() isEvidence_Sum { - if m != nil { - return m.Sum - } - return nil -} - -func (m *Evidence) GetEquivocation() *types3.Equivocation { - if x, ok := m.GetSum().(*Evidence_Equivocation); ok { - return x.Equivocation - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*Evidence) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*Evidence_Equivocation)(nil), - } -} - -// MsgSubmitEvidence defines the application-level message type for handling -// evidence submission. -type MsgSubmitEvidence struct { - types3.MsgSubmitEvidenceBase `protobuf:"bytes,1,opt,name=base,proto3,embedded=base" json:"base"` - Evidence *Evidence `protobuf:"bytes,2,opt,name=evidence,proto3" json:"evidence,omitempty"` -} - -func (m *MsgSubmitEvidence) Reset() { *m = MsgSubmitEvidence{} } -func (m *MsgSubmitEvidence) String() string { return proto.CompactTextString(m) } -func (*MsgSubmitEvidence) ProtoMessage() {} -func (*MsgSubmitEvidence) Descriptor() ([]byte, []int) { - return fileDescriptor_ff851c3a98ef46f7, []int{3} -} -func (m *MsgSubmitEvidence) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgSubmitEvidence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgSubmitEvidence.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 *MsgSubmitEvidence) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSubmitEvidence.Merge(m, src) -} -func (m *MsgSubmitEvidence) XXX_Size() int { - return m.Size() -} -func (m *MsgSubmitEvidence) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSubmitEvidence.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgSubmitEvidence proto.InternalMessageInfo - // MsgSubmitProposal defines the application-level message type for handling // governance proposals. type MsgSubmitProposal struct { - types4.MsgSubmitProposalBase `protobuf:"bytes,1,opt,name=base,proto3,embedded=base" json:"base"` + types3.MsgSubmitProposalBase `protobuf:"bytes,1,opt,name=base,proto3,embedded=base" json:"base"` Content *Content `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` } @@ -372,7 +253,7 @@ func (m *MsgSubmitProposal) Reset() { *m = MsgSubmitProposal{} } func (m *MsgSubmitProposal) String() string { return proto.CompactTextString(m) } func (*MsgSubmitProposal) ProtoMessage() {} func (*MsgSubmitProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_ff851c3a98ef46f7, []int{4} + return fileDescriptor_ff851c3a98ef46f7, []int{2} } func (m *MsgSubmitProposal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -404,7 +285,7 @@ var xxx_messageInfo_MsgSubmitProposal proto.InternalMessageInfo // Proposal defines the application-level concrete proposal type used in governance // proposals. type Proposal struct { - types4.ProposalBase `protobuf:"bytes,1,opt,name=base,proto3,embedded=base" json:"base"` + types3.ProposalBase `protobuf:"bytes,1,opt,name=base,proto3,embedded=base" json:"base"` Content Content `protobuf:"bytes,2,opt,name=content,proto3" json:"content"` } @@ -412,7 +293,7 @@ func (m *Proposal) Reset() { *m = Proposal{} } func (m *Proposal) String() string { return proto.CompactTextString(m) } func (*Proposal) ProtoMessage() {} func (*Proposal) Descriptor() ([]byte, []int) { - return fileDescriptor_ff851c3a98ef46f7, []int{5} + return fileDescriptor_ff851c3a98ef46f7, []int{3} } func (m *Proposal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -466,7 +347,7 @@ func (m *Content) Reset() { *m = Content{} } func (m *Content) String() string { return proto.CompactTextString(m) } func (*Content) ProtoMessage() {} func (*Content) Descriptor() ([]byte, []int) { - return fileDescriptor_ff851c3a98ef46f7, []int{6} + return fileDescriptor_ff851c3a98ef46f7, []int{4} } func (m *Content) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -503,19 +384,19 @@ type isContent_Sum interface { } type Content_Text struct { - Text *types4.TextProposal `protobuf:"bytes,1,opt,name=text,proto3,oneof" json:"text,omitempty"` + Text *types3.TextProposal `protobuf:"bytes,1,opt,name=text,proto3,oneof" json:"text,omitempty"` } type Content_ParameterChange struct { ParameterChange *proposal.ParameterChangeProposal `protobuf:"bytes,2,opt,name=parameter_change,json=parameterChange,proto3,oneof" json:"parameter_change,omitempty"` } type Content_SoftwareUpgrade struct { - SoftwareUpgrade *types5.SoftwareUpgradeProposal `protobuf:"bytes,3,opt,name=software_upgrade,json=softwareUpgrade,proto3,oneof" json:"software_upgrade,omitempty"` + SoftwareUpgrade *types4.SoftwareUpgradeProposal `protobuf:"bytes,3,opt,name=software_upgrade,json=softwareUpgrade,proto3,oneof" json:"software_upgrade,omitempty"` } type Content_CancelSoftwareUpgrade struct { - CancelSoftwareUpgrade *types5.CancelSoftwareUpgradeProposal `protobuf:"bytes,4,opt,name=cancel_software_upgrade,json=cancelSoftwareUpgrade,proto3,oneof" json:"cancel_software_upgrade,omitempty"` + CancelSoftwareUpgrade *types4.CancelSoftwareUpgradeProposal `protobuf:"bytes,4,opt,name=cancel_software_upgrade,json=cancelSoftwareUpgrade,proto3,oneof" json:"cancel_software_upgrade,omitempty"` } type Content_CommunityPoolSpend struct { - CommunityPoolSpend *types6.CommunityPoolSpendProposal `protobuf:"bytes,5,opt,name=community_pool_spend,json=communityPoolSpend,proto3,oneof" json:"community_pool_spend,omitempty"` + CommunityPoolSpend *types5.CommunityPoolSpendProposal `protobuf:"bytes,5,opt,name=community_pool_spend,json=communityPoolSpend,proto3,oneof" json:"community_pool_spend,omitempty"` } func (*Content_Text) isContent_Sum() {} @@ -531,7 +412,7 @@ func (m *Content) GetSum() isContent_Sum { return nil } -func (m *Content) GetText() *types4.TextProposal { +func (m *Content) GetText() *types3.TextProposal { if x, ok := m.GetSum().(*Content_Text); ok { return x.Text } @@ -545,21 +426,21 @@ func (m *Content) GetParameterChange() *proposal.ParameterChangeProposal { return nil } -func (m *Content) GetSoftwareUpgrade() *types5.SoftwareUpgradeProposal { +func (m *Content) GetSoftwareUpgrade() *types4.SoftwareUpgradeProposal { if x, ok := m.GetSum().(*Content_SoftwareUpgrade); ok { return x.SoftwareUpgrade } return nil } -func (m *Content) GetCancelSoftwareUpgrade() *types5.CancelSoftwareUpgradeProposal { +func (m *Content) GetCancelSoftwareUpgrade() *types4.CancelSoftwareUpgradeProposal { if x, ok := m.GetSum().(*Content_CancelSoftwareUpgrade); ok { return x.CancelSoftwareUpgrade } return nil } -func (m *Content) GetCommunityPoolSpend() *types6.CommunityPoolSpendProposal { +func (m *Content) GetCommunityPoolSpend() *types5.CommunityPoolSpendProposal { if x, ok := m.GetSum().(*Content_CommunityPoolSpend); ok { return x.CommunityPoolSpend } @@ -589,7 +470,7 @@ func (m *Transaction) Reset() { *m = Transaction{} } func (m *Transaction) String() string { return proto.CompactTextString(m) } func (*Transaction) ProtoMessage() {} func (*Transaction) Descriptor() ([]byte, []int) { - return fileDescriptor_ff851c3a98ef46f7, []int{7} + return fileDescriptor_ff851c3a98ef46f7, []int{5} } func (m *Transaction) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -631,7 +512,6 @@ type Message struct { // *Message_MsgWithdrawDelegatorReward // *Message_MsgWithdrawValidatorCommission // *Message_MsgFundCommunityPool - // *Message_MsgSubmitEvidence // *Message_MsgSubmitProposal // *Message_MsgVote // *Message_MsgDeposit @@ -648,7 +528,7 @@ func (m *Message) Reset() { *m = Message{} } func (m *Message) String() string { return proto.CompactTextString(m) } func (*Message) ProtoMessage() {} func (*Message) Descriptor() ([]byte, []int) { - return fileDescriptor_ff851c3a98ef46f7, []int{8} + return fileDescriptor_ff851c3a98ef46f7, []int{6} } func (m *Message) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -690,49 +570,46 @@ type Message_MsgMultiSend struct { MsgMultiSend *types2.MsgMultiSend `protobuf:"bytes,2,opt,name=msg_multi_send,json=msgMultiSend,proto3,oneof" json:"msg_multi_send,omitempty"` } type Message_MsgVerifyInvariant struct { - MsgVerifyInvariant *types7.MsgVerifyInvariant `protobuf:"bytes,3,opt,name=msg_verify_invariant,json=msgVerifyInvariant,proto3,oneof" json:"msg_verify_invariant,omitempty"` + MsgVerifyInvariant *types6.MsgVerifyInvariant `protobuf:"bytes,3,opt,name=msg_verify_invariant,json=msgVerifyInvariant,proto3,oneof" json:"msg_verify_invariant,omitempty"` } type Message_MsgSetWithdrawAddress struct { - MsgSetWithdrawAddress *types6.MsgSetWithdrawAddress `protobuf:"bytes,4,opt,name=msg_set_withdraw_address,json=msgSetWithdrawAddress,proto3,oneof" json:"msg_set_withdraw_address,omitempty"` + MsgSetWithdrawAddress *types5.MsgSetWithdrawAddress `protobuf:"bytes,4,opt,name=msg_set_withdraw_address,json=msgSetWithdrawAddress,proto3,oneof" json:"msg_set_withdraw_address,omitempty"` } type Message_MsgWithdrawDelegatorReward struct { - MsgWithdrawDelegatorReward *types6.MsgWithdrawDelegatorReward `protobuf:"bytes,5,opt,name=msg_withdraw_delegator_reward,json=msgWithdrawDelegatorReward,proto3,oneof" json:"msg_withdraw_delegator_reward,omitempty"` + MsgWithdrawDelegatorReward *types5.MsgWithdrawDelegatorReward `protobuf:"bytes,5,opt,name=msg_withdraw_delegator_reward,json=msgWithdrawDelegatorReward,proto3,oneof" json:"msg_withdraw_delegator_reward,omitempty"` } type Message_MsgWithdrawValidatorCommission struct { - MsgWithdrawValidatorCommission *types6.MsgWithdrawValidatorCommission `protobuf:"bytes,6,opt,name=msg_withdraw_validator_commission,json=msgWithdrawValidatorCommission,proto3,oneof" json:"msg_withdraw_validator_commission,omitempty"` + MsgWithdrawValidatorCommission *types5.MsgWithdrawValidatorCommission `protobuf:"bytes,6,opt,name=msg_withdraw_validator_commission,json=msgWithdrawValidatorCommission,proto3,oneof" json:"msg_withdraw_validator_commission,omitempty"` } type Message_MsgFundCommunityPool struct { - MsgFundCommunityPool *types6.MsgFundCommunityPool `protobuf:"bytes,7,opt,name=msg_fund_community_pool,json=msgFundCommunityPool,proto3,oneof" json:"msg_fund_community_pool,omitempty"` -} -type Message_MsgSubmitEvidence struct { - MsgSubmitEvidence *MsgSubmitEvidence `protobuf:"bytes,8,opt,name=msg_submit_evidence,json=msgSubmitEvidence,proto3,oneof" json:"msg_submit_evidence,omitempty"` + MsgFundCommunityPool *types5.MsgFundCommunityPool `protobuf:"bytes,7,opt,name=msg_fund_community_pool,json=msgFundCommunityPool,proto3,oneof" json:"msg_fund_community_pool,omitempty"` } type Message_MsgSubmitProposal struct { MsgSubmitProposal *MsgSubmitProposal `protobuf:"bytes,9,opt,name=msg_submit_proposal,json=msgSubmitProposal,proto3,oneof" json:"msg_submit_proposal,omitempty"` } type Message_MsgVote struct { - MsgVote *types4.MsgVote `protobuf:"bytes,10,opt,name=msg_vote,json=msgVote,proto3,oneof" json:"msg_vote,omitempty"` + MsgVote *types3.MsgVote `protobuf:"bytes,10,opt,name=msg_vote,json=msgVote,proto3,oneof" json:"msg_vote,omitempty"` } type Message_MsgDeposit struct { - MsgDeposit *types4.MsgDeposit `protobuf:"bytes,11,opt,name=msg_deposit,json=msgDeposit,proto3,oneof" json:"msg_deposit,omitempty"` + MsgDeposit *types3.MsgDeposit `protobuf:"bytes,11,opt,name=msg_deposit,json=msgDeposit,proto3,oneof" json:"msg_deposit,omitempty"` } type Message_MsgUnjail struct { - MsgUnjail *types8.MsgUnjail `protobuf:"bytes,12,opt,name=msg_unjail,json=msgUnjail,proto3,oneof" json:"msg_unjail,omitempty"` + MsgUnjail *types7.MsgUnjail `protobuf:"bytes,12,opt,name=msg_unjail,json=msgUnjail,proto3,oneof" json:"msg_unjail,omitempty"` } type Message_MsgCreateValidator struct { - MsgCreateValidator *types9.MsgCreateValidator `protobuf:"bytes,13,opt,name=msg_create_validator,json=msgCreateValidator,proto3,oneof" json:"msg_create_validator,omitempty"` + MsgCreateValidator *types8.MsgCreateValidator `protobuf:"bytes,13,opt,name=msg_create_validator,json=msgCreateValidator,proto3,oneof" json:"msg_create_validator,omitempty"` } type Message_MsgEditValidator struct { - MsgEditValidator *types9.MsgEditValidator `protobuf:"bytes,14,opt,name=msg_edit_validator,json=msgEditValidator,proto3,oneof" json:"msg_edit_validator,omitempty"` + MsgEditValidator *types8.MsgEditValidator `protobuf:"bytes,14,opt,name=msg_edit_validator,json=msgEditValidator,proto3,oneof" json:"msg_edit_validator,omitempty"` } type Message_MsgDelegate struct { - MsgDelegate *types9.MsgDelegate `protobuf:"bytes,15,opt,name=msg_delegate,json=msgDelegate,proto3,oneof" json:"msg_delegate,omitempty"` + MsgDelegate *types8.MsgDelegate `protobuf:"bytes,15,opt,name=msg_delegate,json=msgDelegate,proto3,oneof" json:"msg_delegate,omitempty"` } type Message_MsgBeginRedelegate struct { - MsgBeginRedelegate *types9.MsgBeginRedelegate `protobuf:"bytes,16,opt,name=msg_begin_redelegate,json=msgBeginRedelegate,proto3,oneof" json:"msg_begin_redelegate,omitempty"` + MsgBeginRedelegate *types8.MsgBeginRedelegate `protobuf:"bytes,16,opt,name=msg_begin_redelegate,json=msgBeginRedelegate,proto3,oneof" json:"msg_begin_redelegate,omitempty"` } type Message_MsgUndelegate struct { - MsgUndelegate *types9.MsgUndelegate `protobuf:"bytes,17,opt,name=msg_undelegate,json=msgUndelegate,proto3,oneof" json:"msg_undelegate,omitempty"` + MsgUndelegate *types8.MsgUndelegate `protobuf:"bytes,17,opt,name=msg_undelegate,json=msgUndelegate,proto3,oneof" json:"msg_undelegate,omitempty"` } func (*Message_MsgSend) isMessage_Sum() {} @@ -742,7 +619,6 @@ func (*Message_MsgSetWithdrawAddress) isMessage_Sum() {} func (*Message_MsgWithdrawDelegatorReward) isMessage_Sum() {} func (*Message_MsgWithdrawValidatorCommission) isMessage_Sum() {} func (*Message_MsgFundCommunityPool) isMessage_Sum() {} -func (*Message_MsgSubmitEvidence) isMessage_Sum() {} func (*Message_MsgSubmitProposal) isMessage_Sum() {} func (*Message_MsgVote) isMessage_Sum() {} func (*Message_MsgDeposit) isMessage_Sum() {} @@ -774,48 +650,41 @@ func (m *Message) GetMsgMultiSend() *types2.MsgMultiSend { return nil } -func (m *Message) GetMsgVerifyInvariant() *types7.MsgVerifyInvariant { +func (m *Message) GetMsgVerifyInvariant() *types6.MsgVerifyInvariant { if x, ok := m.GetSum().(*Message_MsgVerifyInvariant); ok { return x.MsgVerifyInvariant } return nil } -func (m *Message) GetMsgSetWithdrawAddress() *types6.MsgSetWithdrawAddress { +func (m *Message) GetMsgSetWithdrawAddress() *types5.MsgSetWithdrawAddress { if x, ok := m.GetSum().(*Message_MsgSetWithdrawAddress); ok { return x.MsgSetWithdrawAddress } return nil } -func (m *Message) GetMsgWithdrawDelegatorReward() *types6.MsgWithdrawDelegatorReward { +func (m *Message) GetMsgWithdrawDelegatorReward() *types5.MsgWithdrawDelegatorReward { if x, ok := m.GetSum().(*Message_MsgWithdrawDelegatorReward); ok { return x.MsgWithdrawDelegatorReward } return nil } -func (m *Message) GetMsgWithdrawValidatorCommission() *types6.MsgWithdrawValidatorCommission { +func (m *Message) GetMsgWithdrawValidatorCommission() *types5.MsgWithdrawValidatorCommission { if x, ok := m.GetSum().(*Message_MsgWithdrawValidatorCommission); ok { return x.MsgWithdrawValidatorCommission } return nil } -func (m *Message) GetMsgFundCommunityPool() *types6.MsgFundCommunityPool { +func (m *Message) GetMsgFundCommunityPool() *types5.MsgFundCommunityPool { if x, ok := m.GetSum().(*Message_MsgFundCommunityPool); ok { return x.MsgFundCommunityPool } return nil } -func (m *Message) GetMsgSubmitEvidence() *MsgSubmitEvidence { - if x, ok := m.GetSum().(*Message_MsgSubmitEvidence); ok { - return x.MsgSubmitEvidence - } - return nil -} - func (m *Message) GetMsgSubmitProposal() *MsgSubmitProposal { if x, ok := m.GetSum().(*Message_MsgSubmitProposal); ok { return x.MsgSubmitProposal @@ -823,56 +692,56 @@ func (m *Message) GetMsgSubmitProposal() *MsgSubmitProposal { return nil } -func (m *Message) GetMsgVote() *types4.MsgVote { +func (m *Message) GetMsgVote() *types3.MsgVote { if x, ok := m.GetSum().(*Message_MsgVote); ok { return x.MsgVote } return nil } -func (m *Message) GetMsgDeposit() *types4.MsgDeposit { +func (m *Message) GetMsgDeposit() *types3.MsgDeposit { if x, ok := m.GetSum().(*Message_MsgDeposit); ok { return x.MsgDeposit } return nil } -func (m *Message) GetMsgUnjail() *types8.MsgUnjail { +func (m *Message) GetMsgUnjail() *types7.MsgUnjail { if x, ok := m.GetSum().(*Message_MsgUnjail); ok { return x.MsgUnjail } return nil } -func (m *Message) GetMsgCreateValidator() *types9.MsgCreateValidator { +func (m *Message) GetMsgCreateValidator() *types8.MsgCreateValidator { if x, ok := m.GetSum().(*Message_MsgCreateValidator); ok { return x.MsgCreateValidator } return nil } -func (m *Message) GetMsgEditValidator() *types9.MsgEditValidator { +func (m *Message) GetMsgEditValidator() *types8.MsgEditValidator { if x, ok := m.GetSum().(*Message_MsgEditValidator); ok { return x.MsgEditValidator } return nil } -func (m *Message) GetMsgDelegate() *types9.MsgDelegate { +func (m *Message) GetMsgDelegate() *types8.MsgDelegate { if x, ok := m.GetSum().(*Message_MsgDelegate); ok { return x.MsgDelegate } return nil } -func (m *Message) GetMsgBeginRedelegate() *types9.MsgBeginRedelegate { +func (m *Message) GetMsgBeginRedelegate() *types8.MsgBeginRedelegate { if x, ok := m.GetSum().(*Message_MsgBeginRedelegate); ok { return x.MsgBeginRedelegate } return nil } -func (m *Message) GetMsgUndelegate() *types9.MsgUndelegate { +func (m *Message) GetMsgUndelegate() *types8.MsgUndelegate { if x, ok := m.GetSum().(*Message_MsgUndelegate); ok { return x.MsgUndelegate } @@ -889,7 +758,6 @@ func (*Message) XXX_OneofWrappers() []interface{} { (*Message_MsgWithdrawDelegatorReward)(nil), (*Message_MsgWithdrawValidatorCommission)(nil), (*Message_MsgFundCommunityPool)(nil), - (*Message_MsgSubmitEvidence)(nil), (*Message_MsgSubmitProposal)(nil), (*Message_MsgVote)(nil), (*Message_MsgDeposit)(nil), @@ -913,7 +781,7 @@ func (m *SignDoc) Reset() { *m = SignDoc{} } func (m *SignDoc) String() string { return proto.CompactTextString(m) } func (*SignDoc) ProtoMessage() {} func (*SignDoc) Descriptor() ([]byte, []int) { - return fileDescriptor_ff851c3a98ef46f7, []int{9} + return fileDescriptor_ff851c3a98ef46f7, []int{7} } func (m *SignDoc) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -961,7 +829,7 @@ func (m *StdFee) Reset() { *m = StdFee{} } func (m *StdFee) String() string { return proto.CompactTextString(m) } func (*StdFee) ProtoMessage() {} func (*StdFee) Descriptor() ([]byte, []int) { - return fileDescriptor_ff851c3a98ef46f7, []int{10} + return fileDescriptor_ff851c3a98ef46f7, []int{8} } func (m *StdFee) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1001,7 +869,7 @@ func (m *StdSignature) Reset() { *m = StdSignature{} } func (m *StdSignature) String() string { return proto.CompactTextString(m) } func (*StdSignature) ProtoMessage() {} func (*StdSignature) Descriptor() ([]byte, []int) { - return fileDescriptor_ff851c3a98ef46f7, []int{11} + return fileDescriptor_ff851c3a98ef46f7, []int{9} } func (m *StdSignature) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1042,7 +910,7 @@ func (m *StdTxBase) Reset() { *m = StdTxBase{} } func (m *StdTxBase) String() string { return proto.CompactTextString(m) } func (*StdTxBase) ProtoMessage() {} func (*StdTxBase) Descriptor() ([]byte, []int) { - return fileDescriptor_ff851c3a98ef46f7, []int{12} + return fileDescriptor_ff851c3a98ef46f7, []int{10} } func (m *StdTxBase) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1106,7 +974,7 @@ func (m *StdSignDocBase) Reset() { *m = StdSignDocBase{} } func (m *StdSignDocBase) String() string { return proto.CompactTextString(m) } func (*StdSignDocBase) ProtoMessage() {} func (*StdSignDocBase) Descriptor() ([]byte, []int) { - return fileDescriptor_ff851c3a98ef46f7, []int{13} + return fileDescriptor_ff851c3a98ef46f7, []int{11} } func (m *StdSignDocBase) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1173,8 +1041,6 @@ func (m *StdSignDocBase) GetFee() StdFee { func init() { proto.RegisterType((*Account)(nil), "cosmos_sdk.std.v1.Account") proto.RegisterType((*Supply)(nil), "cosmos_sdk.std.v1.Supply") - proto.RegisterType((*Evidence)(nil), "cosmos_sdk.std.v1.Evidence") - proto.RegisterType((*MsgSubmitEvidence)(nil), "cosmos_sdk.std.v1.MsgSubmitEvidence") proto.RegisterType((*MsgSubmitProposal)(nil), "cosmos_sdk.std.v1.MsgSubmitProposal") proto.RegisterType((*Proposal)(nil), "cosmos_sdk.std.v1.Proposal") proto.RegisterType((*Content)(nil), "cosmos_sdk.std.v1.Content") @@ -1190,117 +1056,110 @@ func init() { func init() { proto.RegisterFile("std/codec.proto", fileDescriptor_ff851c3a98ef46f7) } var fileDescriptor_ff851c3a98ef46f7 = []byte{ - // 1746 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x58, 0xcf, 0x6f, 0x1b, 0xc7, - 0x15, 0xde, 0x8d, 0x68, 0x91, 0x1a, 0xd1, 0xb2, 0x34, 0xb1, 0x6b, 0x46, 0x71, 0x48, 0x9b, 0x29, - 0x8c, 0xd4, 0xa9, 0xc9, 0x38, 0x4e, 0x93, 0x9a, 0xe8, 0x2f, 0x93, 0xb2, 0x40, 0xb5, 0x51, 0x6b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0xe9, 0x38, 0xd5, 0x5f, 0x9a, 0xea, 0x4f, 0x56, 0xf3, 0xd2, 0xc5, 0x57, 0xb3, 0xdb, 0xf9, - 0xfc, 0xac, 0x6e, 0x3e, 0x3f, 0xab, 0x9b, 0xff, 0x3a, 0xab, 0x9b, 0x7f, 0x7c, 0x51, 0x37, 0x9e, - 0xbf, 0xa8, 0x1b, 0xff, 0x78, 0x51, 0x37, 0x7e, 0x7a, 0x73, 0x69, 0xca, 0x71, 0xe1, 0x0e, 0x56, - 0xd5, 0x5f, 0x31, 0xf7, 0xff, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x66, 0xa7, 0xb1, 0x54, 0x60, 0x13, - 0x00, 0x00, + // 1639 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0x4f, 0x6f, 0x1b, 0xb9, + 0x15, 0x97, 0x62, 0xc5, 0xb2, 0x69, 0xf9, 0x1f, 0x93, 0xd4, 0x8a, 0xeb, 0x48, 0x8e, 0x52, 0x04, + 0x69, 0x52, 0x4b, 0x71, 0x92, 0xa6, 0x8d, 0xd0, 0x7f, 0x91, 0x1d, 0x43, 0x6e, 0xeb, 0x36, 0x18, + 0x27, 0x2e, 0x5a, 0xb4, 0x1d, 0x50, 0x33, 0xf4, 0x98, 0xb5, 0x38, 0x9c, 0x0e, 0x39, 0xb2, 0x54, + 0xa0, 0xa7, 0x16, 0x45, 0x73, 0x28, 0xd0, 0x6b, 0x0f, 0x05, 0xd2, 0x6b, 0xcf, 0x39, 0xed, 0x27, + 0x08, 0x72, 0xca, 0x71, 0x4f, 0xde, 0x85, 0x73, 0x59, 0xe4, 0xb4, 0xc8, 0x27, 0x58, 0x90, 0xc3, + 0x19, 0x8d, 0xa4, 0x91, 0xe2, 0x05, 0xf6, 0x22, 0x90, 0xef, 0xbd, 0xdf, 0xef, 0xbd, 0xe1, 0x7b, + 0x8f, 0x8f, 0x02,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 0x7c, 0x9e, 0xe6, 0x8c, 0x78, 0x1f, 0xc7, 0x9f, 0xeb, 0xc7, 0x1f, 0x9d, 0xe6, 0xc5, + 0xf3, 0x9f, 0x66, 0xa3, 0xfe, 0xfa, 0xac, 0x94, 0x7d, 0x7b, 0x56, 0xca, 0x7e, 0x7e, 0x56, 0xca, + 0xfe, 0xfb, 0x5d, 0x29, 0xf3, 0xf6, 0x5d, 0x29, 0xf3, 0xe9, 0xbb, 0x52, 0xe6, 0x77, 0xeb, 0x13, + 0x4b, 0x8e, 0x0b, 0xbb, 0x35, 0xad, 0xfe, 0xe5, 0xdf, 0xff, 0x2a, 0x00, 0x00, 0xff, 0xff, 0x1a, + 0x12, 0x9f, 0x93, 0x9d, 0x11, 0x00, 0x00, } func (this *Supply) Equal(that interface{}) bool { @@ -1357,87 +1216,6 @@ func (this *Supply_Supply) Equal(that interface{}) bool { } return true } -func (this *Evidence) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*Evidence) - if !ok { - that2, ok := that.(Evidence) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if that1.Sum == nil { - if this.Sum != nil { - return false - } - } else if this.Sum == nil { - return false - } else if !this.Sum.Equal(that1.Sum) { - return false - } - return true -} -func (this *Evidence_Equivocation) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*Evidence_Equivocation) - if !ok { - that2, ok := that.(Evidence_Equivocation) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !this.Equivocation.Equal(that1.Equivocation) { - return false - } - return true -} -func (this *MsgSubmitEvidence) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*MsgSubmitEvidence) - if !ok { - that2, ok := that.(MsgSubmitEvidence) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !this.MsgSubmitEvidenceBase.Equal(&that1.MsgSubmitEvidenceBase) { - return false - } - if !this.Evidence.Equal(that1.Evidence) { - return false - } - return true -} func (this *MsgSubmitProposal) Equal(that interface{}) bool { if that == nil { return this == nil @@ -1738,29 +1516,6 @@ func (this *Supply) SetSupplyI(value github_com_cosmos_cosmos_sdk_x_bank_exporte return fmt.Errorf("can't encode value of type %T as message Supply", value) } -func (this *Evidence) GetEvidence() github_com_cosmos_cosmos_sdk_x_evidence_exported.Evidence { - if x := this.GetEquivocation(); x != nil { - return x - } - return nil -} - -func (this *Evidence) SetEvidence(value github_com_cosmos_cosmos_sdk_x_evidence_exported.Evidence) error { - if value == nil { - this.Sum = nil - return nil - } - switch vt := value.(type) { - case *types3.Equivocation: - this.Sum = &Evidence_Equivocation{vt} - return nil - case types3.Equivocation: - this.Sum = &Evidence_Equivocation{&vt} - return nil - } - return fmt.Errorf("can't encode value of type %T as message Evidence", value) -} - func (this *Content) GetContent() github_com_cosmos_cosmos_sdk_x_gov_types.Content { if x := this.GetText(); x != nil { return x @@ -1786,19 +1541,19 @@ func (this *Content) SetContent(value github_com_cosmos_cosmos_sdk_x_gov_types.C return nil } switch vt := value.(type) { - case *types4.TextProposal: + case *types3.TextProposal: this.Sum = &Content_Text{vt} return nil case *proposal.ParameterChangeProposal: this.Sum = &Content_ParameterChange{vt} return nil - case *types5.SoftwareUpgradeProposal: + case *types4.SoftwareUpgradeProposal: this.Sum = &Content_SoftwareUpgrade{vt} return nil - case *types5.CancelSoftwareUpgradeProposal: + case *types4.CancelSoftwareUpgradeProposal: this.Sum = &Content_CancelSoftwareUpgrade{vt} return nil - case *types6.CommunityPoolSpendProposal: + case *types5.CommunityPoolSpendProposal: this.Sum = &Content_CommunityPoolSpend{vt} return nil } @@ -1827,9 +1582,6 @@ func (this *Message) GetMsg() github_com_cosmos_cosmos_sdk_types.Msg { if x := this.GetMsgFundCommunityPool(); x != nil { return x } - if x := this.GetMsgSubmitEvidence(); x != nil { - return x - } if x := this.GetMsgSubmitProposal(); x != nil { return x } @@ -1878,94 +1630,88 @@ func (this *Message) SetMsg(value github_com_cosmos_cosmos_sdk_types.Msg) error case types2.MsgMultiSend: this.Sum = &Message_MsgMultiSend{&vt} return nil - case *types7.MsgVerifyInvariant: + case *types6.MsgVerifyInvariant: this.Sum = &Message_MsgVerifyInvariant{vt} return nil - case types7.MsgVerifyInvariant: + case types6.MsgVerifyInvariant: this.Sum = &Message_MsgVerifyInvariant{&vt} return nil - case *types6.MsgSetWithdrawAddress: + case *types5.MsgSetWithdrawAddress: this.Sum = &Message_MsgSetWithdrawAddress{vt} return nil - case types6.MsgSetWithdrawAddress: + case types5.MsgSetWithdrawAddress: this.Sum = &Message_MsgSetWithdrawAddress{&vt} return nil - case *types6.MsgWithdrawDelegatorReward: + case *types5.MsgWithdrawDelegatorReward: this.Sum = &Message_MsgWithdrawDelegatorReward{vt} return nil - case types6.MsgWithdrawDelegatorReward: + case types5.MsgWithdrawDelegatorReward: this.Sum = &Message_MsgWithdrawDelegatorReward{&vt} return nil - case *types6.MsgWithdrawValidatorCommission: + case *types5.MsgWithdrawValidatorCommission: this.Sum = &Message_MsgWithdrawValidatorCommission{vt} return nil - case types6.MsgWithdrawValidatorCommission: + case types5.MsgWithdrawValidatorCommission: this.Sum = &Message_MsgWithdrawValidatorCommission{&vt} return nil - case *types6.MsgFundCommunityPool: + case *types5.MsgFundCommunityPool: this.Sum = &Message_MsgFundCommunityPool{vt} return nil - case types6.MsgFundCommunityPool: + case types5.MsgFundCommunityPool: this.Sum = &Message_MsgFundCommunityPool{&vt} return nil - case *MsgSubmitEvidence: - this.Sum = &Message_MsgSubmitEvidence{vt} - return nil - case MsgSubmitEvidence: - this.Sum = &Message_MsgSubmitEvidence{&vt} - return nil case *MsgSubmitProposal: this.Sum = &Message_MsgSubmitProposal{vt} return nil case MsgSubmitProposal: this.Sum = &Message_MsgSubmitProposal{&vt} return nil - case *types4.MsgVote: + case *types3.MsgVote: this.Sum = &Message_MsgVote{vt} return nil - case types4.MsgVote: + case types3.MsgVote: this.Sum = &Message_MsgVote{&vt} return nil - case *types4.MsgDeposit: + case *types3.MsgDeposit: this.Sum = &Message_MsgDeposit{vt} return nil - case types4.MsgDeposit: + case types3.MsgDeposit: this.Sum = &Message_MsgDeposit{&vt} return nil - case *types8.MsgUnjail: + case *types7.MsgUnjail: this.Sum = &Message_MsgUnjail{vt} return nil - case types8.MsgUnjail: + case types7.MsgUnjail: this.Sum = &Message_MsgUnjail{&vt} return nil - case *types9.MsgCreateValidator: + case *types8.MsgCreateValidator: this.Sum = &Message_MsgCreateValidator{vt} return nil - case types9.MsgCreateValidator: + case types8.MsgCreateValidator: this.Sum = &Message_MsgCreateValidator{&vt} return nil - case *types9.MsgEditValidator: + case *types8.MsgEditValidator: this.Sum = &Message_MsgEditValidator{vt} return nil - case types9.MsgEditValidator: + case types8.MsgEditValidator: this.Sum = &Message_MsgEditValidator{&vt} return nil - case *types9.MsgDelegate: + case *types8.MsgDelegate: this.Sum = &Message_MsgDelegate{vt} return nil - case types9.MsgDelegate: + case types8.MsgDelegate: this.Sum = &Message_MsgDelegate{&vt} return nil - case *types9.MsgBeginRedelegate: + case *types8.MsgBeginRedelegate: this.Sum = &Message_MsgBeginRedelegate{vt} return nil - case types9.MsgBeginRedelegate: + case types8.MsgBeginRedelegate: this.Sum = &Message_MsgBeginRedelegate{&vt} return nil - case *types9.MsgUndelegate: + case *types8.MsgUndelegate: this.Sum = &Message_MsgUndelegate{vt} return nil - case types9.MsgUndelegate: + case types8.MsgUndelegate: this.Sum = &Message_MsgUndelegate{&vt} return nil } @@ -2162,104 +1908,6 @@ func (m *Supply_Supply) MarshalToSizedBuffer(dAtA []byte) (int, error) { } return len(dAtA) - i, nil } -func (m *Evidence) 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 *Evidence) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Evidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Sum != nil { - { - size := m.Sum.Size() - i -= size - if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *Evidence_Equivocation) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Evidence_Equivocation) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Equivocation != nil { - { - size, err := m.Equivocation.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCodec(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} -func (m *MsgSubmitEvidence) 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 *MsgSubmitEvidence) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgSubmitEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Evidence != nil { - { - size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCodec(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - { - size, err := m.MsgSubmitEvidenceBase.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCodec(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - func (m *MsgSubmitProposal) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2711,27 +2359,6 @@ func (m *Message_MsgFundCommunityPool) MarshalToSizedBuffer(dAtA []byte) (int, e } return len(dAtA) - i, nil } -func (m *Message_MsgSubmitEvidence) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message_MsgSubmitEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.MsgSubmitEvidence != nil { - { - size, err := m.MsgSubmitEvidence.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCodec(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - } - return len(dAtA) - i, nil -} func (m *Message_MsgSubmitProposal) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) @@ -3227,87 +2854,48 @@ func (m *Account_PeriodicVestingAccount) Size() (n int) { } var l int _ = l - if m.PeriodicVestingAccount != nil { - l = m.PeriodicVestingAccount.Size() - n += 1 + l + sovCodec(uint64(l)) - } - return n -} -func (m *Account_ModuleAccount) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ModuleAccount != nil { - l = m.ModuleAccount.Size() - n += 1 + l + sovCodec(uint64(l)) - } - return n -} -func (m *Supply) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Sum != nil { - n += m.Sum.Size() - } - return n -} - -func (m *Supply_Supply) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Supply != nil { - l = m.Supply.Size() + if m.PeriodicVestingAccount != nil { + l = m.PeriodicVestingAccount.Size() n += 1 + l + sovCodec(uint64(l)) } return n } -func (m *Evidence) Size() (n int) { +func (m *Account_ModuleAccount) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Sum != nil { - n += m.Sum.Size() + if m.ModuleAccount != nil { + l = m.ModuleAccount.Size() + n += 1 + l + sovCodec(uint64(l)) } return n } - -func (m *Evidence_Equivocation) Size() (n int) { +func (m *Supply) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Equivocation != nil { - l = m.Equivocation.Size() - n += 1 + l + sovCodec(uint64(l)) + if m.Sum != nil { + n += m.Sum.Size() } return n } -func (m *MsgSubmitEvidence) Size() (n int) { + +func (m *Supply_Supply) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = m.MsgSubmitEvidenceBase.Size() - n += 1 + l + sovCodec(uint64(l)) - if m.Evidence != nil { - l = m.Evidence.Size() + if m.Supply != nil { + l = m.Supply.Size() n += 1 + l + sovCodec(uint64(l)) } return n } - func (m *MsgSubmitProposal) Size() (n int) { if m == nil { return 0 @@ -3521,18 +3109,6 @@ func (m *Message_MsgFundCommunityPool) Size() (n int) { } return n } -func (m *Message_MsgSubmitEvidence) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.MsgSubmitEvidence != nil { - l = m.MsgSubmitEvidence.Size() - n += 1 + l + sovCodec(uint64(l)) - } - return n -} func (m *Message_MsgSubmitProposal) Size() (n int) { if m == nil { return 0 @@ -4061,216 +3637,6 @@ func (m *Supply) Unmarshal(dAtA []byte) error { } return nil } -func (m *Evidence) 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 ErrIntOverflowCodec - } - 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: Evidence: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Evidence: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Equivocation", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCodec - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCodec - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCodec - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &types3.Equivocation{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &Evidence_Equivocation{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCodec(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthCodec - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthCodec - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgSubmitEvidence) 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 ErrIntOverflowCodec - } - 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: MsgSubmitEvidence: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSubmitEvidence: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgSubmitEvidenceBase", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCodec - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCodec - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCodec - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MsgSubmitEvidenceBase.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCodec - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCodec - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCodec - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Evidence == nil { - m.Evidence = &Evidence{} - } - if err := m.Evidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCodec(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthCodec - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthCodec - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *MsgSubmitProposal) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -4570,7 +3936,7 @@ func (m *Content) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &types4.TextProposal{} + v := &types3.TextProposal{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -4640,7 +4006,7 @@ func (m *Content) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &types5.SoftwareUpgradeProposal{} + v := &types4.SoftwareUpgradeProposal{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -4675,7 +4041,7 @@ func (m *Content) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &types5.CancelSoftwareUpgradeProposal{} + v := &types4.CancelSoftwareUpgradeProposal{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -4710,7 +4076,7 @@ func (m *Content) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &types6.CommunityPoolSpendProposal{} + v := &types5.CommunityPoolSpendProposal{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -4988,7 +4354,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &types7.MsgVerifyInvariant{} + v := &types6.MsgVerifyInvariant{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -5023,7 +4389,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &types6.MsgSetWithdrawAddress{} + v := &types5.MsgSetWithdrawAddress{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -5058,7 +4424,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &types6.MsgWithdrawDelegatorReward{} + v := &types5.MsgWithdrawDelegatorReward{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -5093,7 +4459,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &types6.MsgWithdrawValidatorCommission{} + v := &types5.MsgWithdrawValidatorCommission{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -5128,47 +4494,12 @@ func (m *Message) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &types6.MsgFundCommunityPool{} + v := &types5.MsgFundCommunityPool{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } m.Sum = &Message_MsgFundCommunityPool{v} iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgSubmitEvidence", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCodec - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCodec - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCodec - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &MsgSubmitEvidence{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &Message_MsgSubmitEvidence{v} - iNdEx = postIndex case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MsgSubmitProposal", wireType) @@ -5233,7 +4564,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &types4.MsgVote{} + v := &types3.MsgVote{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -5268,7 +4599,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &types4.MsgDeposit{} + v := &types3.MsgDeposit{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -5303,7 +4634,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &types8.MsgUnjail{} + v := &types7.MsgUnjail{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -5338,7 +4669,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &types9.MsgCreateValidator{} + v := &types8.MsgCreateValidator{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -5373,7 +4704,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &types9.MsgEditValidator{} + v := &types8.MsgEditValidator{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -5408,7 +4739,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &types9.MsgDelegate{} + v := &types8.MsgDelegate{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -5443,7 +4774,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &types9.MsgBeginRedelegate{} + v := &types8.MsgBeginRedelegate{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -5478,7 +4809,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &types9.MsgUndelegate{} + v := &types8.MsgUndelegate{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -5686,7 +5017,7 @@ func (m *StdFee) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Amount = append(m.Amount, types10.Coin{}) + m.Amount = append(m.Amount, types9.Coin{}) if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/std/codec.proto b/std/codec.proto index 67ca3e77ca7..8f0bb11e7bb 100644 --- a/std/codec.proto +++ b/std/codec.proto @@ -9,7 +9,6 @@ import "x/auth/vesting/types/types.proto"; import "x/bank/types/types.proto"; import "x/crisis/types/types.proto"; import "x/distribution/types/types.proto"; -import "x/evidence/types/types.proto"; import "x/gov/types/types.proto"; import "x/slashing/types/types.proto"; import "x/staking/types/types.proto"; @@ -43,28 +42,6 @@ message Supply { } } -// Evidence defines the application-level allowed Evidence to be submitted via a -// MsgSubmitEvidence message. -message Evidence { - option (gogoproto.equal) = true; - option (cosmos_proto.interface_type) = "github.com/cosmos/cosmos-sdk/x/evidence/exported.Evidence"; - - // sum defines a set of all acceptable concrete Evidence implementations. - oneof sum { - cosmos_sdk.x.evidence.v1.Equivocation equivocation = 1; - } -} - -// MsgSubmitEvidence defines the application-level message type for handling -// evidence submission. -message MsgSubmitEvidence { - option (gogoproto.equal) = true; - option (gogoproto.goproto_getters) = false; - - cosmos_sdk.x.evidence.v1.MsgSubmitEvidenceBase base = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true]; - Evidence evidence = 2; -} - // MsgSubmitProposal defines the application-level message type for handling // governance proposals. message MsgSubmitProposal { @@ -124,7 +101,6 @@ message Message { cosmos_sdk.x.distribution.v1.MsgWithdrawDelegatorReward msg_withdraw_delegator_reward = 5; cosmos_sdk.x.distribution.v1.MsgWithdrawValidatorCommission msg_withdraw_validator_commission = 6; cosmos_sdk.x.distribution.v1.MsgFundCommunityPool msg_fund_community_pool = 7; - MsgSubmitEvidence msg_submit_evidence = 8; MsgSubmitProposal msg_submit_proposal = 9; cosmos_sdk.x.gov.v1.MsgVote msg_vote = 10; cosmos_sdk.x.gov.v1.MsgDeposit msg_deposit = 11; diff --git a/std/msgs.go b/std/msgs.go index f54f99e5f0f..259dad15602 100644 --- a/std/msgs.go +++ b/std/msgs.go @@ -3,49 +3,13 @@ package std import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/evidence" - eviexported "github.com/cosmos/cosmos-sdk/x/evidence/exported" gov "github.com/cosmos/cosmos-sdk/x/gov/types" ) var ( - _ eviexported.MsgSubmitEvidence = MsgSubmitEvidence{} - _ gov.MsgSubmitProposalI = &MsgSubmitProposal{} + _ gov.MsgSubmitProposalI = &MsgSubmitProposal{} ) -// NewMsgSubmitEvidence returns a new MsgSubmitEvidence. -func NewMsgSubmitEvidence(evidenceI eviexported.Evidence, s sdk.AccAddress) (MsgSubmitEvidence, error) { - e := &Evidence{} - if err := e.SetEvidence(evidenceI); err != nil { - return MsgSubmitEvidence{}, err - } - - return MsgSubmitEvidence{ - Evidence: e, - MsgSubmitEvidenceBase: evidence.NewMsgSubmitEvidenceBase(s), - }, nil -} - -// ValidateBasic performs basic (non-state-dependant) validation on a -// MsgSubmitEvidence. -func (msg MsgSubmitEvidence) ValidateBasic() error { - if err := msg.MsgSubmitEvidenceBase.ValidateBasic(); err != nil { - return nil - } - if msg.Evidence == nil { - return sdkerrors.Wrap(evidence.ErrInvalidEvidence, "missing evidence") - } - if err := msg.Evidence.GetEvidence().ValidateBasic(); err != nil { - return err - } - - return nil -} - -// nolint -func (msg MsgSubmitEvidence) GetEvidence() eviexported.Evidence { return msg.Evidence.GetEvidence() } -func (msg MsgSubmitEvidence) GetSubmitter() sdk.AccAddress { return msg.Submitter } - // NewMsgSubmitProposal returns a new MsgSubmitProposal. func NewMsgSubmitProposal(c gov.Content, d sdk.Coins, p sdk.AccAddress) (gov.MsgSubmitProposalI, error) { content := &Content{} diff --git a/std/msgs_test.go b/std/msgs_test.go index 603dcf0f7a8..a034c65a21d 100644 --- a/std/msgs_test.go +++ b/std/msgs_test.go @@ -2,7 +2,6 @@ package std_test import ( "testing" - "time" gov "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -10,25 +9,8 @@ import ( "github.com/cosmos/cosmos-sdk/std" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/evidence" ) -func TestNewMsgSubmitEvidence(t *testing.T) { - s := sdk.AccAddress("foo") - e := evidence.Equivocation{ - Height: 100, - Time: time.Now().UTC(), - Power: 40000000000, - ConsensusAddress: sdk.ConsAddress("test"), - } - - msg, err := std.NewMsgSubmitEvidence(e, s) - require.NoError(t, err) - require.Equal(t, msg.GetEvidence(), &e) - require.Equal(t, msg.GetSubmitter(), s) - require.NoError(t, msg.ValidateBasic()) -} - type invalidProposal struct { *gov.TextProposal } diff --git a/tests/cli/simd_test.go b/tests/cli/simd_test.go index a17e848c26d..91640226e94 100644 --- a/tests/cli/simd_test.go +++ b/tests/cli/simd_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/require" tmtypes "github.com/tendermint/tendermint/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/std" "github.com/cosmos/cosmos-sdk/tests/cli" sdk "github.com/cosmos/cosmos-sdk/types" @@ -98,7 +99,8 @@ func TestCLISimdAddGenesisAccount(t *testing.T) { genesisState := f.GenesisState() - appCodec := std.NewAppCodec(f.Cdc) + interfaceRegistry := codectypes.NewInterfaceRegistry() + appCodec := std.NewAppCodec(f.Cdc, interfaceRegistry) accounts := auth.GetGenesisStateFromAppState(appCodec, genesisState).Accounts balances := bank.GetGenesisStateFromAppState(f.Cdc, genesisState).Balances diff --git a/third_party/proto/google/protobuf/any.proto b/third_party/proto/google/protobuf/any.proto new file mode 100644 index 00000000000..a769fa3b222 --- /dev/null +++ b/third_party/proto/google/protobuf/any.proto @@ -0,0 +1,161 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package google.protobuf; + +import "third_party/proto/gogoproto/gogo.proto"; + +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option go_package = "types"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "AnyProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; + +// `Any` contains an arbitrary serialized protocol buffer message along with a +// URL that describes the type of the serialized message. +// +// Protobuf library provides support to pack/unpack Any values in the form +// of utility functions or additional generated methods of the Any type. +// +// Example 1: Pack and unpack a message in C++. +// +// Foo foo = ...; +// Any any; +// any.PackFrom(foo); +// ... +// if (any.UnpackTo(&foo)) { +// ... +// } +// +// Example 2: Pack and unpack a message in Java. +// +// Foo foo = ...; +// Any any = Any.pack(foo); +// ... +// if (any.is(Foo.class)) { +// foo = any.unpack(Foo.class); +// } +// +// Example 3: Pack and unpack a message in Python. +// +// foo = Foo(...) +// any = Any() +// any.Pack(foo) +// ... +// if any.Is(Foo.DESCRIPTOR): +// any.Unpack(foo) +// ... +// +// Example 4: Pack and unpack a message in Go +// +// foo := &pb.Foo{...} +// any, err := ptypes.MarshalAny(foo) +// ... +// foo := &pb.Foo{} +// if err := ptypes.UnmarshalAny(any, foo); err != nil { +// ... +// } +// +// The pack methods provided by protobuf library will by default use +// 'type.googleapis.com/full.type.name' as the type URL and the unpack +// methods only use the fully qualified type name after the last '/' +// in the type URL, for example "foo.bar.com/x/y.z" will yield type +// name "y.z". +// +// +// JSON +// ==== +// The JSON representation of an `Any` value uses the regular +// representation of the deserialized, embedded message, with an +// additional field `@type` which contains the type URL. Example: +// +// package google.profile; +// message Person { +// string first_name = 1; +// string last_name = 2; +// } +// +// { +// "@type": "type.googleapis.com/google.profile.Person", +// "firstName": , +// "lastName": +// } +// +// If the embedded message type is well-known and has a custom JSON +// representation, that representation will be embedded adding a field +// `value` which holds the custom JSON in addition to the `@type` +// field. Example (for message [google.protobuf.Duration][]): +// +// { +// "@type": "type.googleapis.com/google.protobuf.Duration", +// "value": "1.212s" +// } +// +message Any { + // A URL/resource name that uniquely identifies the type of the serialized + // protocol buffer message. This string must contain at least + // one "/" character. The last segment of the URL's path must represent + // the fully qualified name of the type (as in + // `path/google.protobuf.Duration`). The name should be in a canonical form + // (e.g., leading "." is not accepted). + // + // In practice, teams usually precompile into the binary all types that they + // expect it to use in the context of Any. However, for URLs which use the + // scheme `http`, `https`, or no scheme, one can optionally set up a type + // server that maps type URLs to message definitions as follows: + // + // * If no scheme is provided, `https` is assumed. + // * An HTTP GET on the URL must yield a [google.protobuf.Type][] + // value in binary format, or produce an error. + // * Applications are allowed to cache lookup results based on the + // URL, or have them precompiled into a binary to avoid any + // lookup. Therefore, binary compatibility needs to be preserved + // on changes to types. (Use versioned type names to manage + // breaking changes.) + // + // Note: this functionality is not currently available in the official + // protobuf release, and it is not used for type URLs beginning with + // type.googleapis.com. + // + // Schemes other than `http`, `https` (or the empty scheme) might be + // used with implementation specific semantics. + // + string type_url = 1; + + // Must be a valid serialized protocol buffer of the above specified type. + bytes value = 2; + + option (gogoproto.typedecl) = false; +} + +option (gogoproto.goproto_registration) = false; diff --git a/types/codec.go b/types/codec.go index 9cd1097c201..c00d95b2ee8 100644 --- a/types/codec.go +++ b/types/codec.go @@ -3,6 +3,8 @@ package types import ( jsonc "github.com/gibson042/canonicaljson-go" + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/codec" ) @@ -12,6 +14,11 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterInterface((*Tx)(nil), nil) } +// Register the sdk message type +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterInterface("cosmos_sdk.v1.Msg", (*Msg)(nil)) +} + // CanonicalSignBytes returns a canonical JSON encoding of a Proto message that // can be signed over. The JSON encoding ensures all field names adhere to their // Proto definition, default values are omitted, and follows the JSON Canonical diff --git a/types/module/interface_module.go b/types/module/interface_module.go new file mode 100644 index 00000000000..1aaec42ea89 --- /dev/null +++ b/types/module/interface_module.go @@ -0,0 +1,21 @@ +package module + +import "github.com/cosmos/cosmos-sdk/codec/types" + +// InterfaceModule is an interface that modules can implement in order to +// register their interfaces and implementations in an InterfaceRegistry +type InterfaceModule interface { + RegisterInterfaceTypes(registry types.InterfaceRegistry) +} + +// RegisterInterfaceModules calls RegisterInterfaceTypes with the registry +// parameter on all of the modules which implement InterfaceModule in the manager +func (bm BasicManager) RegisterInterfaceModules(registry types.InterfaceRegistry) { + for _, m := range bm { + im, ok := m.(InterfaceModule) + if !ok { + continue + } + im.RegisterInterfaceTypes(registry) + } +} diff --git a/x/auth/alias.go b/x/auth/alias.go index 927fb5a550a..f8ffe899c0d 100644 --- a/x/auth/alias.go +++ b/x/auth/alias.go @@ -68,7 +68,6 @@ var ( NewModuleAccount = types.NewModuleAccount // variable aliases - ModuleCdc = types.ModuleCdc AddressStoreKeyPrefix = types.AddressStoreKeyPrefix GlobalAccountNumberKey = types.GlobalAccountNumberKey KeyMaxMemoCharacters = types.KeyMaxMemoCharacters diff --git a/x/auth/keeper/keeper_test.go b/x/auth/keeper/keeper_test.go index 6e5748b87b0..e3f5d7f3d88 100644 --- a/x/auth/keeper/keeper_test.go +++ b/x/auth/keeper/keeper_test.go @@ -3,11 +3,11 @@ package keeper_test import ( "testing" - "github.com/cosmos/cosmos-sdk/std" - "github.com/stretchr/testify/require" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/std" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -108,7 +108,7 @@ func TestSupply_ValidatePermissions(t *testing.T) { maccPerms[multiPerm] = []string{types.Burner, types.Minter, types.Staking} maccPerms[randomPerm] = []string{"random"} - appCodec := std.NewAppCodec(app.Codec()) + appCodec := std.NewAppCodec(app.Codec(), codectypes.NewInterfaceRegistry()) keeper := auth.NewAccountKeeper( appCodec, app.GetKey(types.StoreKey), app.GetSubspace(types.ModuleName), types.ProtoBaseAccount, maccPerms, diff --git a/x/auth/simulation/decoder_test.go b/x/auth/simulation/decoder_test.go index e4f189c0149..829d0d9c2cc 100644 --- a/x/auth/simulation/decoder_test.go +++ b/x/auth/simulation/decoder_test.go @@ -4,8 +4,6 @@ import ( "fmt" "testing" - "github.com/cosmos/cosmos-sdk/std" - gogotypes "github.com/gogo/protobuf/types" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/ed25519" @@ -23,7 +21,7 @@ var ( ) func TestDecodeStore(t *testing.T) { - cdc := std.NewAppCodec(std.MakeCodec(simapp.ModuleBasics)) + cdc, _ := simapp.MakeCodecs() acc := types.NewBaseAccountWithAddress(delAddr1) dec := simulation.NewDecodeStore(cdc) diff --git a/x/auth/types/codec.go b/x/auth/types/codec.go index b4be63155da..c4609d8a40f 100644 --- a/x/auth/types/codec.go +++ b/x/auth/types/codec.go @@ -32,19 +32,10 @@ func RegisterCodec(cdc *codec.Codec) { // another module for the internal ModuleCdc. func RegisterKeyTypeCodec(o interface{}, name string) { amino.RegisterConcrete(o, name, nil) - ModuleCdc = codec.NewHybridCodec(amino) } var ( amino = codec.New() - - // ModuleCdc references the global x/auth module codec. Note, the codec should - // ONLY be used in certain instances of tests and for JSON encoding as Amino is - // still used for that purpose. - // - // The actual codec used for serialization should be provided to x/auth and - // defined at the application level. - ModuleCdc = codec.NewHybridCodec(amino) ) func init() { diff --git a/x/auth/types/common_test.go b/x/auth/types/common_test.go index 1ba524bcafe..4f361059ad3 100644 --- a/x/auth/types/common_test.go +++ b/x/auth/types/common_test.go @@ -2,10 +2,9 @@ package types_test import ( "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/std" ) var ( - app = simapp.Setup(false) - appCodec = std.NewAppCodec(app.Codec()) + app = simapp.Setup(false) + appCodec, _ = simapp.MakeCodecs() ) diff --git a/x/auth/vesting/types/common_test.go b/x/auth/vesting/types/common_test.go index 1ba524bcafe..4f361059ad3 100644 --- a/x/auth/vesting/types/common_test.go +++ b/x/auth/vesting/types/common_test.go @@ -2,10 +2,9 @@ package types_test import ( "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/std" ) var ( - app = simapp.Setup(false) - appCodec = std.NewAppCodec(app.Codec()) + app = simapp.Setup(false) + appCodec, _ = simapp.MakeCodecs() ) diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 5acd6d84172..8c23ef3e44a 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -4,8 +4,6 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/std" - "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" tmkv "github.com/tendermint/tendermint/libs/kv" @@ -92,7 +90,7 @@ func (suite *IntegrationTestSuite) TestSupply() { func (suite *IntegrationTestSuite) TestSupply_SendCoins() { app := simapp.Setup(false) ctx := app.BaseApp.NewContext(false, abci.Header{Height: 1}) - appCodec := std.NewAppCodec(app.Codec()) + appCodec := app.AppCodec() // add module accounts to supply keeper maccPerms := simapp.GetMaccPerms() @@ -155,7 +153,7 @@ func (suite *IntegrationTestSuite) TestSupply_SendCoins() { func (suite *IntegrationTestSuite) TestSupply_MintCoins() { app := simapp.Setup(false) ctx := app.BaseApp.NewContext(false, abci.Header{Height: 1}) - appCodec := std.NewAppCodec(app.Codec()) + appCodec := app.AppCodec() // add module accounts to supply keeper maccPerms := simapp.GetMaccPerms() @@ -209,7 +207,7 @@ func (suite *IntegrationTestSuite) TestSupply_MintCoins() { func (suite *IntegrationTestSuite) TestSupply_BurnCoins() { app := simapp.Setup(false) ctx := app.BaseApp.NewContext(false, abci.Header{Height: 1}) - appCodec := std.NewAppCodec(app.Codec()) + appCodec, _ := simapp.MakeCodecs() // add module accounts to supply keeper maccPerms := simapp.GetMaccPerms() diff --git a/x/bank/simulation/decoder_test.go b/x/bank/simulation/decoder_test.go index 4b6f5937bac..4f0e8016036 100644 --- a/x/bank/simulation/decoder_test.go +++ b/x/bank/simulation/decoder_test.go @@ -4,8 +4,6 @@ import ( "fmt" "testing" - "github.com/cosmos/cosmos-sdk/std" - "github.com/stretchr/testify/require" tmkv "github.com/tendermint/tendermint/libs/kv" @@ -16,7 +14,7 @@ import ( ) func TestDecodeStore(t *testing.T) { - cdc := std.NewAppCodec(std.MakeCodec(simapp.ModuleBasics)) + cdc, _ := simapp.MakeCodecs() dec := simulation.NewDecodeStore(cdc) totalSupply := types.NewSupply(sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000))) diff --git a/x/bank/types/codec.go b/x/bank/types/codec.go index bb2d0e306af..c8e945aef7c 100644 --- a/x/bank/types/codec.go +++ b/x/bank/types/codec.go @@ -2,6 +2,7 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/x/bank/exported" ) @@ -35,7 +36,7 @@ var ( // // The actual codec used for serialization should be provided to x/staking and // defined at the application level. - ModuleCdc = codec.NewHybridCodec(amino) + ModuleCdc = codec.NewHybridCodec(amino, types.NewInterfaceRegistry()) ) func init() { diff --git a/x/capability/alias.go b/x/capability/alias.go index c21ca73cf9b..da91311953b 100644 --- a/x/capability/alias.go +++ b/x/capability/alias.go @@ -26,7 +26,6 @@ var ( ErrOwnerClaimed = types.ErrOwnerClaimed ErrCapabilityNotOwned = types.ErrCapabilityNotOwned RegisterCodec = types.RegisterCodec - ModuleCdc = types.ModuleCdc NewOwner = types.NewOwner NewCapabilityOwners = types.NewCapabilityOwners ) diff --git a/x/capability/keeper/keeper_test.go b/x/capability/keeper/keeper_test.go index ba3d58d053d..c025deb158e 100644 --- a/x/capability/keeper/keeper_test.go +++ b/x/capability/keeper/keeper_test.go @@ -7,7 +7,6 @@ import ( "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/bank" @@ -28,7 +27,7 @@ type KeeperTestSuite struct { func (suite *KeeperTestSuite) SetupTest() { checkTx := false app := simapp.Setup(checkTx) - cdc := codec.NewHybridCodec(app.Codec()) + cdc := app.AppCodec() // create new keeper so we can define custom scoping before init and seal keeper := keeper.NewKeeper(cdc, app.GetKey(capability.StoreKey), app.GetMemKey(capability.MemStoreKey)) diff --git a/x/capability/simulation/decoder_test.go b/x/capability/simulation/decoder_test.go index 72130b59ada..8f10e908542 100644 --- a/x/capability/simulation/decoder_test.go +++ b/x/capability/simulation/decoder_test.go @@ -8,14 +8,13 @@ import ( tmkv "github.com/tendermint/tendermint/libs/kv" "github.com/cosmos/cosmos-sdk/simapp" - codecstd "github.com/cosmos/cosmos-sdk/std" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/capability/simulation" "github.com/cosmos/cosmos-sdk/x/capability/types" ) func TestDecodeStore(t *testing.T) { - cdc := codecstd.NewAppCodec(codecstd.MakeCodec(simapp.ModuleBasics)) + cdc, _ := simapp.MakeCodecs() dec := simulation.NewDecodeStore(cdc) capOwners := types.CapabilityOwners{ diff --git a/x/capability/types/codec.go b/x/capability/types/codec.go index c12a54b6fb6..887a68655eb 100644 --- a/x/capability/types/codec.go +++ b/x/capability/types/codec.go @@ -14,14 +14,6 @@ func RegisterCodec(cdc *codec.Codec) { var ( amino = codec.New() - - // ModuleCdc references the global x/capability module codec. Note, the codec should - // ONLY be used in certain instances of tests and for JSON encoding as Amino is - // still used for that purpose. - // - // The actual codec used for serialization should be provided to x/capability and - // defined at the application level. - ModuleCdc = codec.NewHybridCodec(amino) ) func init() { diff --git a/x/crisis/types/codec.go b/x/crisis/types/codec.go index b7906953cf6..04802607cbe 100644 --- a/x/crisis/types/codec.go +++ b/x/crisis/types/codec.go @@ -2,6 +2,7 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" ) // RegisterCodec registers the necessary x/crisis interfaces and concrete types @@ -19,7 +20,7 @@ var ( // // The actual codec used for serialization should be provided to x/crisis and // defined at the application level. - ModuleCdc = codec.NewHybridCodec(amino) + ModuleCdc = codec.NewHybridCodec(amino, types.NewInterfaceRegistry()) ) func init() { diff --git a/x/distribution/simulation/decoder_test.go b/x/distribution/simulation/decoder_test.go index c2091617793..7fddb1625c7 100644 --- a/x/distribution/simulation/decoder_test.go +++ b/x/distribution/simulation/decoder_test.go @@ -4,8 +4,6 @@ import ( "fmt" "testing" - "github.com/cosmos/cosmos-sdk/std" - "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/ed25519" @@ -25,7 +23,7 @@ var ( ) func TestDecodeDistributionStore(t *testing.T) { - cdc := std.NewAppCodec(std.MakeCodec(simapp.ModuleBasics)) + cdc, _ := simapp.MakeCodecs() dec := simulation.NewDecodeStore(cdc) decCoins := sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, sdk.OneDec())} diff --git a/x/distribution/types/codec.go b/x/distribution/types/codec.go index b57767de082..bd4242a00d0 100644 --- a/x/distribution/types/codec.go +++ b/x/distribution/types/codec.go @@ -2,6 +2,7 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" ) // RegisterCodec registers the necessary x/distribution interfaces and concrete types @@ -22,7 +23,7 @@ var ( // // The actual codec used for serialization should be provided to x/distribution and // defined at the application level. - ModuleCdc = codec.NewHybridCodec(amino) + ModuleCdc = codec.NewHybridCodec(amino, types.NewInterfaceRegistry()) ) func init() { diff --git a/x/evidence/abci.go b/x/evidence/abci.go index e12ed7065f9..2e42efa3d07 100644 --- a/x/evidence/abci.go +++ b/x/evidence/abci.go @@ -16,7 +16,7 @@ func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k Keeper) { switch tmEvidence.Type { case tmtypes.ABCIEvidenceTypeDuplicateVote: evidence := ConvertDuplicateVoteEvidence(tmEvidence) - k.HandleDoubleSign(ctx, evidence.(Equivocation)) + k.HandleDoubleSign(ctx, evidence.(*Equivocation)) default: k.Logger(ctx).Error(fmt.Sprintf("ignored unknown evidence type: %s", tmEvidence.Type)) diff --git a/x/evidence/alias.go b/x/evidence/alias.go index f8f85601e6f..bef91a3dc22 100644 --- a/x/evidence/alias.go +++ b/x/evidence/alias.go @@ -24,11 +24,13 @@ var ( NewKeeper = keeper.NewKeeper NewQuerier = keeper.NewQuerier - NewMsgSubmitEvidenceBase = types.NewMsgSubmitEvidenceBase + NewMsgSubmitEvidence = types.NewMsgSubmitEvidence NewRouter = types.NewRouter NewQueryEvidenceParams = types.NewQueryEvidenceParams NewQueryAllEvidenceParams = types.NewQueryAllEvidenceParams + NewAnyCodec = types.NewAnyCodec RegisterCodec = types.RegisterCodec + RegisterInterfaces = types.RegisterInterfaces ModuleCdc = types.ModuleCdc NewGenesisState = types.NewGenesisState DefaultGenesisState = types.DefaultGenesisState @@ -43,10 +45,11 @@ var ( type ( Keeper = keeper.Keeper - GenesisState = types.GenesisState - MsgSubmitEvidenceBase = types.MsgSubmitEvidenceBase - Handler = types.Handler - Router = types.Router - Equivocation = types.Equivocation - Codec = types.Codec + GenesisState = types.GenesisState + MsgSubmitEvidence = types.MsgSubmitEvidence + Handler = types.Handler + Router = types.Router + Equivocation = types.Equivocation + Codec = types.Codec + AnyCodec = types.AnyCodec ) diff --git a/x/evidence/genesis_test.go b/x/evidence/genesis_test.go index f14b987011a..32f60a55a4d 100644 --- a/x/evidence/genesis_test.go +++ b/x/evidence/genesis_test.go @@ -35,7 +35,7 @@ func (suite *GenesisTestSuite) TestInitGenesis_Valid() { testEvidence := make([]exported.Evidence, 100) for i := 0; i < 100; i++ { - testEvidence[i] = types.Equivocation{ + testEvidence[i] = &types.Equivocation{ Height: int64(i + 1), Power: 100, Time: time.Now().UTC(), @@ -58,7 +58,7 @@ func (suite *GenesisTestSuite) TestInitGenesis_Invalid() { testEvidence := make([]exported.Evidence, 100) for i := 0; i < 100; i++ { - testEvidence[i] = types.Equivocation{ + testEvidence[i] = &types.Equivocation{ Power: 100, Time: time.Now().UTC(), ConsensusAddress: pk.PubKey().Address().Bytes(), diff --git a/x/evidence/handler.go b/x/evidence/handler.go index 1d3c82f9372..711aff5f8ab 100644 --- a/x/evidence/handler.go +++ b/x/evidence/handler.go @@ -11,14 +11,10 @@ func NewHandler(k Keeper) sdk.Handler { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - case MsgSubmitEvidenceBase: - return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%T must be extended to support evidence", msg) + case exported.MsgSubmitEvidence: + return handleMsgSubmitEvidence(ctx, k, msg) default: - msgSubEv, ok := msg.(exported.MsgSubmitEvidence) - if ok { - return handleMsgSubmitEvidence(ctx, k, msgSubEv) - } return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", ModuleName, msg) } diff --git a/x/evidence/handler_test.go b/x/evidence/handler_test.go index 9c4b665e8ae..11ff3f7e331 100644 --- a/x/evidence/handler_test.go +++ b/x/evidence/handler_test.go @@ -5,8 +5,6 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/std" - "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" @@ -26,8 +24,8 @@ type HandlerTestSuite struct { app *simapp.SimApp } -func testMsgSubmitEvidence(r *require.Assertions, e exported.Evidence, s sdk.AccAddress) std.MsgSubmitEvidence { - msg, err := std.NewMsgSubmitEvidence(e, s) +func testMsgSubmitEvidence(r *require.Assertions, e exported.Evidence, s sdk.AccAddress) exported.MsgSubmitEvidence { + msg, err := evidence.NewMsgSubmitEvidence(s, e) r.NoError(err) return msg } @@ -56,7 +54,7 @@ func (suite *HandlerTestSuite) SetupTest() { // recreate keeper in order to use custom testing types evidenceKeeper := evidence.NewKeeper( - std.NewAppCodec(app.Codec()), app.GetKey(evidence.StoreKey), + evidence.NewAnyCodec(app.AppCodec()), app.GetKey(evidence.StoreKey), app.StakingKeeper, app.SlashingKeeper, ) router := evidence.NewRouter() @@ -103,10 +101,6 @@ func (suite *HandlerTestSuite) TestMsgSubmitEvidence() { ), true, }, - { - types.NewMsgSubmitEvidenceBase(s), - true, - }, } for i, tc := range testCases { @@ -119,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.(std.MsgSubmitEvidence) + msg := tc.msg.(exported.MsgSubmitEvidence) suite.Require().Equal(msg.GetEvidence().Hash().Bytes(), res.Data, "invalid hash; tc #%d", i) } } diff --git a/x/evidence/keeper/infraction.go b/x/evidence/keeper/infraction.go index b657341888d..75de7d4a2bc 100644 --- a/x/evidence/keeper/infraction.go +++ b/x/evidence/keeper/infraction.go @@ -22,7 +22,7 @@ import ( // // TODO: Some of the invalid constraints listed above may need to be reconsidered // in the case of a lunatic attack. -func (k Keeper) HandleDoubleSign(ctx sdk.Context, evidence types.Equivocation) { +func (k Keeper) HandleDoubleSign(ctx sdk.Context, evidence *types.Equivocation) { logger := k.Logger(ctx) consAddr := evidence.GetConsensusAddress() diff --git a/x/evidence/keeper/infraction_test.go b/x/evidence/keeper/infraction_test.go index a8dd15938f4..5c2f1198725 100644 --- a/x/evidence/keeper/infraction_test.go +++ b/x/evidence/keeper/infraction_test.go @@ -45,7 +45,7 @@ func (suite *KeeperTestSuite) TestHandleDoubleSign() { // double sign less than max age oldTokens := suite.app.StakingKeeper.Validator(ctx, operatorAddr).GetTokens() - evidence := types.Equivocation{ + evidence := &types.Equivocation{ Height: 0, Time: time.Unix(0, 0), Power: power, @@ -106,7 +106,7 @@ func (suite *KeeperTestSuite) TestHandleDoubleSign_TooOld() { ) suite.Equal(amt, suite.app.StakingKeeper.Validator(ctx, operatorAddr).GetBondedTokens()) - evidence := types.Equivocation{ + evidence := &types.Equivocation{ Height: 0, Time: ctx.BlockTime(), Power: power, diff --git a/x/evidence/keeper/keeper.go b/x/evidence/keeper/keeper.go index 98963ea4d08..e17fd9c48c4 100644 --- a/x/evidence/keeper/keeper.go +++ b/x/evidence/keeper/keeper.go @@ -165,3 +165,7 @@ func (k Keeper) MustMarshalEvidence(evidence exported.Evidence) []byte { return bz } + +func (k Keeper) UnmarshalEvidence(bz []byte) (exported.Evidence, error) { + return k.cdc.UnmarshalEvidence(bz) +} diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index 87544446efa..58ff2ade738 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -6,8 +6,6 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/std" - "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" @@ -58,7 +56,7 @@ func testEquivocationHandler(k interface{}) types.Handler { return err } - ee, ok := e.(types.Equivocation) + ee, ok := e.(*types.Equivocation) if !ok { return fmt.Errorf("unexpected evidence type: %T", e) } @@ -84,7 +82,7 @@ func (suite *KeeperTestSuite) SetupTest() { // recreate keeper in order to use custom testing types evidenceKeeper := evidence.NewKeeper( - std.NewAppCodec(app.Codec()), app.GetKey(evidence.StoreKey), + evidence.NewAnyCodec(app.AppCodec()), app.GetKey(evidence.StoreKey), app.StakingKeeper, app.SlashingKeeper, ) router := evidence.NewRouter() @@ -109,7 +107,7 @@ func (suite *KeeperTestSuite) populateEvidence(ctx sdk.Context, numEvidence int) for i := 0; i < numEvidence; i++ { pk := ed25519.GenPrivKey() - evidence[i] = types.Equivocation{ + evidence[i] = &types.Equivocation{ Height: 11, Power: 100, Time: time.Now().UTC(), @@ -138,7 +136,7 @@ func (suite *KeeperTestSuite) TestSubmitValidEvidence() { ctx := suite.ctx.WithIsCheckTx(false) pk := ed25519.GenPrivKey() - e := types.Equivocation{ + e := &types.Equivocation{ Height: 1, Power: 100, Time: time.Now().UTC(), @@ -149,14 +147,14 @@ func (suite *KeeperTestSuite) TestSubmitValidEvidence() { res, ok := suite.app.EvidenceKeeper.GetEvidence(ctx, e.Hash()) suite.True(ok) - suite.Equal(&e, res) + suite.Equal(e, res) } func (suite *KeeperTestSuite) TestSubmitValidEvidence_Duplicate() { ctx := suite.ctx.WithIsCheckTx(false) pk := ed25519.GenPrivKey() - e := types.Equivocation{ + e := &types.Equivocation{ Height: 1, Power: 100, Time: time.Now().UTC(), @@ -168,13 +166,13 @@ func (suite *KeeperTestSuite) TestSubmitValidEvidence_Duplicate() { res, ok := suite.app.EvidenceKeeper.GetEvidence(ctx, e.Hash()) suite.True(ok) - suite.Equal(&e, res) + suite.Equal(e, res) } func (suite *KeeperTestSuite) TestSubmitInvalidEvidence() { ctx := suite.ctx.WithIsCheckTx(false) pk := ed25519.GenPrivKey() - e := types.Equivocation{ + e := &types.Equivocation{ Height: 0, Power: 100, Time: time.Now().UTC(), @@ -198,7 +196,7 @@ func (suite *KeeperTestSuite) TestIterateEvidence() { } func (suite *KeeperTestSuite) TestGetEvidenceHandler() { - handler, err := suite.app.EvidenceKeeper.GetEvidenceHandler(types.Equivocation{}.Route()) + handler, err := suite.app.EvidenceKeeper.GetEvidenceHandler((&types.Equivocation{}).Route()) suite.NoError(err) suite.NotNil(handler) diff --git a/x/evidence/keeper/querier_test.go b/x/evidence/keeper/querier_test.go index 9c0883d7373..7433f099a07 100644 --- a/x/evidence/keeper/querier_test.go +++ b/x/evidence/keeper/querier_test.go @@ -3,6 +3,8 @@ package keeper_test import ( "strings" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/std" "github.com/cosmos/cosmos-sdk/x/evidence/exported" @@ -18,7 +20,7 @@ const ( func (suite *KeeperTestSuite) TestQueryEvidence_Existing() { ctx := suite.ctx.WithIsCheckTx(false) numEvidence := 100 - cdc := std.NewAppCodec(suite.app.Codec()) + cdc := std.NewAppCodec(suite.app.Codec(), codectypes.NewInterfaceRegistry()) evidence := suite.populateEvidence(ctx, numEvidence) query := abci.RequestQuery{ @@ -37,7 +39,7 @@ func (suite *KeeperTestSuite) TestQueryEvidence_Existing() { func (suite *KeeperTestSuite) TestQueryEvidence_NonExisting() { ctx := suite.ctx.WithIsCheckTx(false) - cdc := std.NewAppCodec(suite.app.Codec()) + cdc := std.NewAppCodec(suite.app.Codec(), codectypes.NewInterfaceRegistry()) numEvidence := 100 suite.populateEvidence(ctx, numEvidence) @@ -53,7 +55,7 @@ func (suite *KeeperTestSuite) TestQueryEvidence_NonExisting() { func (suite *KeeperTestSuite) TestQueryAllEvidence() { ctx := suite.ctx.WithIsCheckTx(false) - cdc := std.NewAppCodec(suite.app.Codec()) + cdc := std.NewAppCodec(suite.app.Codec(), codectypes.NewInterfaceRegistry()) numEvidence := 100 suite.populateEvidence(ctx, numEvidence) @@ -73,7 +75,7 @@ func (suite *KeeperTestSuite) TestQueryAllEvidence() { func (suite *KeeperTestSuite) TestQueryAllEvidence_InvalidPagination() { ctx := suite.ctx.WithIsCheckTx(false) - cdc := std.NewAppCodec(suite.app.Codec()) + cdc := std.NewAppCodec(suite.app.Codec(), codectypes.NewInterfaceRegistry()) numEvidence := 100 suite.populateEvidence(ctx, numEvidence) diff --git a/x/evidence/module.go b/x/evidence/module.go index e3c7cf353c0..99a2174c4f8 100644 --- a/x/evidence/module.go +++ b/x/evidence/module.go @@ -5,6 +5,8 @@ import ( "fmt" "math/rand" + "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -24,6 +26,7 @@ var ( _ module.AppModule = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} _ module.AppModuleSimulation = AppModule{} + _ module.InterfaceModule = AppModuleBasic{} ) // ---------------------------------------------------------------------------- @@ -32,7 +35,6 @@ var ( // AppModuleBasic implements the AppModuleBasic interface for the evidence module. type AppModuleBasic struct { - cdc Codec evidenceHandlers []client.EvidenceHandler // client evidence submission handlers } @@ -95,6 +97,10 @@ func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { return cli.GetQueryCmd(StoreKey, cdc) } +func (AppModuleBasic) RegisterInterfaceTypes(registry types.InterfaceRegistry) { + RegisterInterfaces(registry) +} + // ---------------------------------------------------------------------------- // AppModule // ---------------------------------------------------------------------------- @@ -106,9 +112,9 @@ type AppModule struct { keeper Keeper } -func NewAppModule(cdc Codec, keeper Keeper) AppModule { +func NewAppModule(keeper Keeper) AppModule { return AppModule{ - AppModuleBasic: AppModuleBasic{cdc: cdc}, + AppModuleBasic: AppModuleBasic{}, keeper: keeper, } } @@ -192,7 +198,7 @@ func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { // RegisterStoreDecoder registers a decoder for evidence module's types func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { - sdr[StoreKey] = simulation.NewDecodeStore(am.cdc) + sdr[StoreKey] = simulation.NewDecodeStore(am.keeper) } // WeightedOperations returns the all the gov module operations with their respective weights. diff --git a/x/evidence/simulation/decoder.go b/x/evidence/simulation/decoder.go index 7ad7e0ef9eb..dd5becbbbde 100644 --- a/x/evidence/simulation/decoder.go +++ b/x/evidence/simulation/decoder.go @@ -4,14 +4,20 @@ import ( "bytes" "fmt" + "github.com/cosmos/cosmos-sdk/x/evidence/exported" + tmkv "github.com/tendermint/tendermint/libs/kv" "github.com/cosmos/cosmos-sdk/x/evidence/types" ) +type EvidenceUnmarshaler interface { + UnmarshalEvidence([]byte) (exported.Evidence, error) +} + // NewDecodeStore returns a decoder function closure that unmarshals the KVPair's // Value to the corresponding evidence type. -func NewDecodeStore(cdc types.Codec) func(kvA, kvB tmkv.Pair) string { +func NewDecodeStore(cdc EvidenceUnmarshaler) func(kvA, kvB tmkv.Pair) string { return func(kvA, kvB tmkv.Pair) string { switch { case bytes.Equal(kvA.Key[:1], types.KeyPrefixEvidence): diff --git a/x/evidence/simulation/decoder_test.go b/x/evidence/simulation/decoder_test.go index 8e8f82172c5..b66e9d73893 100644 --- a/x/evidence/simulation/decoder_test.go +++ b/x/evidence/simulation/decoder_test.go @@ -5,8 +5,6 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/std" - "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/ed25519" tmkv "github.com/tendermint/tendermint/libs/kv" @@ -18,19 +16,20 @@ import ( ) func TestDecodeStore(t *testing.T) { - cdc := std.NewAppCodec(std.MakeCodec(simapp.ModuleBasics)) + m, _ := simapp.MakeCodecs() + cdc := types.NewAnyCodec(m) dec := simulation.NewDecodeStore(cdc) delPk1 := ed25519.GenPrivKey().PubKey() - ev := types.Equivocation{ + ev := &types.Equivocation{ Height: 10, Time: time.Now().UTC(), Power: 1000, ConsensusAddress: sdk.ConsAddress(delPk1.Address()), } - evBz, err := cdc.MarshalEvidence(&ev) + evBz, err := cdc.MarshalEvidence(ev) require.NoError(t, err) kvPairs := tmkv.Pairs{ diff --git a/x/evidence/types/codec.go b/x/evidence/types/codec.go index d0a9d1a5e1a..0acd26657c4 100644 --- a/x/evidence/types/codec.go +++ b/x/evidence/types/codec.go @@ -1,7 +1,13 @@ package types import ( + "fmt" + + "github.com/gogo/protobuf/proto" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/evidence/exported" ) @@ -19,8 +25,17 @@ type Codec interface { // evidence module. func RegisterCodec(cdc *codec.Codec) { cdc.RegisterInterface((*exported.Evidence)(nil), nil) - cdc.RegisterConcrete(MsgSubmitEvidenceBase{}, "cosmos-sdk/MsgSubmitEvidenceBase", nil) - cdc.RegisterConcrete(Equivocation{}, "cosmos-sdk/Equivocation", nil) + cdc.RegisterConcrete(MsgSubmitEvidence{}, "cosmos-sdk/MsgSubmitEvidence", nil) + cdc.RegisterConcrete(&Equivocation{}, "cosmos-sdk/Equivocation", nil) +} + +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitEvidence{}) + registry.RegisterInterface( + "cosmos_sdk.evidence.v1.Evidence", + (*exported.Evidence)(nil), + &Equivocation{}, + ) } var ( @@ -32,7 +47,7 @@ var ( // // The actual codec used for serialization should be provided to x/evidence and // defined at the application level. - ModuleCdc = codec.NewHybridCodec(amino) + ModuleCdc = codec.NewHybridCodec(amino, types.NewInterfaceRegistry()) ) func init() { @@ -40,3 +55,60 @@ func init() { codec.RegisterCrypto(amino) amino.Seal() } + +// AnyCodec is an evidence Codec that marshals evidence using google.protobuf.Any +type AnyCodec struct { + codec.Marshaler +} + +// NewAnyCodec returns a new AnyCodec +func NewAnyCodec(marshaler codec.Marshaler) Codec { + return AnyCodec{Marshaler: marshaler} +} + +// MarshalEvidence marshals an Evidence interface. If the given type implements +// the Marshaler interface, it is treated as a Proto-defined message and +// serialized that way. Otherwise, it falls back on the internal Amino codec. +func (c AnyCodec) MarshalEvidence(evidenceI exported.Evidence) ([]byte, error) { + return types.MarshalAny(evidenceI) +} + +// UnmarshalEvidence returns an Evidence interface from raw encoded evidence +// bytes of a Proto-based Evidence type. An error is returned upon decoding +// failure. +func (c AnyCodec) UnmarshalEvidence(bz []byte) (exported.Evidence, error) { + var evi exported.Evidence + err := types.UnmarshalAny(c, &evi, bz) + if err != nil { + return nil, err + } + return evi, nil +} + +// MarshalEvidenceJSON JSON encodes an evidence object implementing the Evidence +// interface. +func (c AnyCodec) MarshalEvidenceJSON(evidence exported.Evidence) ([]byte, error) { + msg, ok := evidence.(proto.Message) + if !ok { + return nil, fmt.Errorf("cannot proto marshal %T", evidence) + } + any, err := types.NewAnyWithValue(msg) + if err != nil { + return nil, err + } + return c.MarshalJSON(any) +} + +// UnmarshalEvidenceJSON returns an Evidence from JSON encoded bytes +func (c AnyCodec) UnmarshalEvidenceJSON(bz []byte) (exported.Evidence, error) { + var any types.Any + if err := c.UnmarshalJSON(bz, &any); err != nil { + return nil, err + } + + var evi exported.Evidence + if err := c.UnpackAny(&any, &evi); err != nil { + return nil, err + } + return evi, nil +} diff --git a/x/evidence/types/codec_test.go b/x/evidence/types/codec_test.go index ef24835d194..104bb4fb7a5 100644 --- a/x/evidence/types/codec_test.go +++ b/x/evidence/types/codec_test.go @@ -4,8 +4,6 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/std" - "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/ed25519" @@ -16,7 +14,7 @@ import ( func TestCodec(t *testing.T) { app := simapp.Setup(false) - appCodec := std.NewAppCodec(app.Codec()) + evidenceCodec := types.NewAnyCodec(app.AppCodec()) pk := ed25519.GenPrivKey() var e exported.Evidence = &types.Equivocation{ @@ -25,10 +23,10 @@ func TestCodec(t *testing.T) { Power: 100000, ConsensusAddress: pk.PubKey().Address().Bytes(), } - bz, err := appCodec.MarshalEvidence(e) + bz, err := evidenceCodec.MarshalEvidence(e) require.NoError(t, err) - other, err := appCodec.UnmarshalEvidence(bz) + other, err := evidenceCodec.UnmarshalEvidence(bz) require.NoError(t, err) require.Equal(t, e, other) } diff --git a/x/evidence/types/evidence.go b/x/evidence/types/evidence.go index d62023530a6..3049d6110b2 100644 --- a/x/evidence/types/evidence.go +++ b/x/evidence/types/evidence.go @@ -19,26 +19,26 @@ const ( TypeEquivocation = "equivocation" ) -var _ exported.Evidence = (*Equivocation)(nil) +var _ exported.Evidence = &Equivocation{} // Route returns the Evidence Handler route for an Equivocation type. -func (e Equivocation) Route() string { return RouteEquivocation } +func (e *Equivocation) Route() string { return RouteEquivocation } // Type returns the Evidence Handler type for an Equivocation type. -func (e Equivocation) Type() string { return TypeEquivocation } +func (e *Equivocation) Type() string { return TypeEquivocation } -func (e Equivocation) String() string { +func (e *Equivocation) String() string { bz, _ := yaml.Marshal(e) return string(bz) } // Hash returns the hash of an Equivocation object. -func (e Equivocation) Hash() tmbytes.HexBytes { - return tmhash.Sum(ModuleCdc.MustMarshalBinaryBare(&e)) +func (e *Equivocation) Hash() tmbytes.HexBytes { + return tmhash.Sum(ModuleCdc.MustMarshalBinaryBare(e)) } // ValidateBasic performs basic stateless validation checks on an Equivocation object. -func (e Equivocation) ValidateBasic() error { +func (e *Equivocation) ValidateBasic() error { if e.Time.IsZero() { return fmt.Errorf("invalid equivocation time: %s", e.Time) } @@ -83,7 +83,7 @@ func (e Equivocation) GetTotalPower() int64 { return 0 } // ConvertDuplicateVoteEvidence converts a Tendermint concrete Evidence type to // SDK Evidence using Equivocation as the concrete type. func ConvertDuplicateVoteEvidence(dupVote abci.Evidence) exported.Evidence { - return Equivocation{ + return &Equivocation{ Height: dupVote.Height, Power: dupVote.Validator.Power, ConsensusAddress: sdk.ConsAddress(dupVote.Validator.Address), diff --git a/x/evidence/types/genesis_test.go b/x/evidence/types/genesis_test.go index 2d121d3697d..c905c631826 100644 --- a/x/evidence/types/genesis_test.go +++ b/x/evidence/types/genesis_test.go @@ -22,7 +22,7 @@ func TestGenesisStateValidate_Valid(t *testing.T) { evidence := make([]exported.Evidence, 100) for i := 0; i < 100; i++ { - evidence[i] = types.Equivocation{ + evidence[i] = &types.Equivocation{ Height: int64(i) + 1, Power: 100, Time: time.Now().UTC(), @@ -39,7 +39,7 @@ func TestGenesisStateValidate_Invalid(t *testing.T) { evidence := make([]exported.Evidence, 100) for i := 0; i < 100; i++ { - evidence[i] = types.Equivocation{ + evidence[i] = &types.Equivocation{ Height: int64(i), Power: 100, Time: time.Now().UTC(), diff --git a/x/evidence/types/msgs.go b/x/evidence/types/msgs.go index eb0367b28b6..223904b1dc6 100644 --- a/x/evidence/types/msgs.go +++ b/x/evidence/types/msgs.go @@ -1,8 +1,14 @@ package types import ( + "fmt" + + "github.com/gogo/protobuf/proto" + + "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/evidence/exported" ) // Message types for the evidence module @@ -11,38 +17,71 @@ const ( ) var ( - _ sdk.Msg = MsgSubmitEvidenceBase{} + _ sdk.Msg = MsgSubmitEvidence{} + _ types.UnpackInterfacesMessage = MsgSubmitEvidence{} + _ exported.MsgSubmitEvidence = MsgSubmitEvidence{} ) -// NewMsgSubmitEvidenceBase returns a new MsgSubmitEvidenceBase with a signer/submitter. -// Note, the MsgSubmitEvidenceBase is not to be used as an actual message, but -// rather to be extended with Evidence. -func NewMsgSubmitEvidenceBase(s sdk.AccAddress) MsgSubmitEvidenceBase { - return MsgSubmitEvidenceBase{Submitter: s} +// NewMsgSubmitEvidence returns a new MsgSubmitEvidence with a signer/submitter. +func NewMsgSubmitEvidence(s sdk.AccAddress, evi exported.Evidence) (MsgSubmitEvidence, error) { + msg, ok := evi.(proto.Message) + if !ok { + return MsgSubmitEvidence{}, fmt.Errorf("cannot proto marshal %T", evi) + } + any, err := types.NewAnyWithValue(msg) + if err != nil { + return MsgSubmitEvidence{Submitter: s}, err + } + return MsgSubmitEvidence{Submitter: s, Evidence: any}, nil } -// Route returns the MsgSubmitEvidenceBase's route. -func (m MsgSubmitEvidenceBase) Route() string { return RouterKey } +// Route returns the MsgSubmitEvidence's route. +func (m MsgSubmitEvidence) Route() string { return RouterKey } -// Type returns the MsgSubmitEvidenceBase's type. -func (m MsgSubmitEvidenceBase) Type() string { return TypeMsgSubmitEvidence } +// Type returns the MsgSubmitEvidence's type. +func (m MsgSubmitEvidence) Type() string { return TypeMsgSubmitEvidence } -// ValidateBasic performs basic (non-state-dependant) validation on a MsgSubmitEvidenceBase. -func (m MsgSubmitEvidenceBase) ValidateBasic() error { +// ValidateBasic performs basic (non-state-dependant) validation on a MsgSubmitEvidence. +func (m MsgSubmitEvidence) ValidateBasic() error { if m.Submitter.Empty() { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, m.Submitter.String()) } + evi := m.GetEvidence() + if evi == nil { + return sdkerrors.Wrap(ErrInvalidEvidence, "missing evidence") + } + if err := evi.ValidateBasic(); err != nil { + return err + } + return nil } // GetSignBytes returns the raw bytes a signer is expected to sign when submitting -// a MsgSubmitEvidenceBase message. -func (m MsgSubmitEvidenceBase) GetSignBytes() []byte { +// a MsgSubmitEvidence message. +func (m MsgSubmitEvidence) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) } -// GetSigners returns the single expected signer for a MsgSubmitEvidenceBase. -func (m MsgSubmitEvidenceBase) GetSigners() []sdk.AccAddress { +// GetSigners returns the single expected signer for a MsgSubmitEvidence. +func (m MsgSubmitEvidence) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{m.Submitter} } + +func (m MsgSubmitEvidence) GetEvidence() exported.Evidence { + evi, ok := m.Evidence.GetCachedValue().(exported.Evidence) + if !ok { + return nil + } + return evi +} + +func (m MsgSubmitEvidence) GetSubmitter() sdk.AccAddress { + return m.Submitter +} + +func (m MsgSubmitEvidence) UnpackInterfaces(ctx types.AnyUnpacker) error { + var evi exported.Evidence + return ctx.UnpackAny(m.Evidence, &evi) +} diff --git a/x/evidence/types/msgs_test.go b/x/evidence/types/msgs_test.go index 639f2ffe1c5..6c1297ea64b 100644 --- a/x/evidence/types/msgs_test.go +++ b/x/evidence/types/msgs_test.go @@ -4,8 +4,6 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/std" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/evidence/exported" "github.com/cosmos/cosmos-sdk/x/evidence/types" @@ -14,8 +12,8 @@ import ( "github.com/tendermint/tendermint/crypto/ed25519" ) -func testMsgSubmitEvidence(t *testing.T, e exported.Evidence, s sdk.AccAddress) std.MsgSubmitEvidence { - msg, err := std.NewMsgSubmitEvidence(e, s) +func testMsgSubmitEvidence(t *testing.T, e exported.Evidence, s sdk.AccAddress) exported.MsgSubmitEvidence { + msg, err := types.NewMsgSubmitEvidence(s, e) require.NoError(t, err) return msg } @@ -29,11 +27,6 @@ func TestMsgSubmitEvidence(t *testing.T) { submitter sdk.AccAddress expectErr bool }{ - { - types.NewMsgSubmitEvidenceBase(submitter), - submitter, - false, - }, { testMsgSubmitEvidence(t, &types.Equivocation{ Height: 0, diff --git a/x/evidence/types/types.pb.go b/x/evidence/types/types.pb.go index 98e166cfbcb..cb7ca7b77d6 100644 --- a/x/evidence/types/types.pb.go +++ b/x/evidence/types/types.pb.go @@ -6,6 +6,7 @@ package types import ( bytes "bytes" fmt "fmt" + types "github.com/cosmos/cosmos-sdk/codec/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" @@ -29,29 +30,25 @@ var _ = time.Kitchen // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgSubmitEvidenceBase defines an sdk.Msg type that supports submitting arbitrary +// MsgSubmitEvidence defines an sdk.Msg type that supports submitting arbitrary // Evidence. -// -// Note, this message type provides the basis for which a true MsgSubmitEvidence -// can be constructed. Since the evidence submitted in the message can be arbitrary, -// assuming it fulfills the Evidence interface, it must be defined at the -// application-level and extend MsgSubmitEvidenceBase. -type MsgSubmitEvidenceBase struct { +type MsgSubmitEvidence struct { Submitter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=submitter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"submitter,omitempty"` + Evidence *types.Any `protobuf:"bytes,2,opt,name=evidence,proto3" json:"evidence,omitempty"` } -func (m *MsgSubmitEvidenceBase) Reset() { *m = MsgSubmitEvidenceBase{} } -func (m *MsgSubmitEvidenceBase) String() string { return proto.CompactTextString(m) } -func (*MsgSubmitEvidenceBase) ProtoMessage() {} -func (*MsgSubmitEvidenceBase) Descriptor() ([]byte, []int) { +func (m *MsgSubmitEvidence) Reset() { *m = MsgSubmitEvidence{} } +func (m *MsgSubmitEvidence) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitEvidence) ProtoMessage() {} +func (*MsgSubmitEvidence) Descriptor() ([]byte, []int) { return fileDescriptor_72113e6a7b2536ae, []int{0} } -func (m *MsgSubmitEvidenceBase) XXX_Unmarshal(b []byte) error { +func (m *MsgSubmitEvidence) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSubmitEvidenceBase) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgSubmitEvidence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSubmitEvidenceBase.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgSubmitEvidence.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -61,24 +58,17 @@ func (m *MsgSubmitEvidenceBase) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *MsgSubmitEvidenceBase) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSubmitEvidenceBase.Merge(m, src) +func (m *MsgSubmitEvidence) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitEvidence.Merge(m, src) } -func (m *MsgSubmitEvidenceBase) XXX_Size() int { +func (m *MsgSubmitEvidence) XXX_Size() int { return m.Size() } -func (m *MsgSubmitEvidenceBase) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSubmitEvidenceBase.DiscardUnknown(m) +func (m *MsgSubmitEvidence) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitEvidence.DiscardUnknown(m) } -var xxx_messageInfo_MsgSubmitEvidenceBase proto.InternalMessageInfo - -func (m *MsgSubmitEvidenceBase) GetSubmitter() github_com_cosmos_cosmos_sdk_types.AccAddress { - if m != nil { - return m.Submitter - } - return nil -} +var xxx_messageInfo_MsgSubmitEvidence proto.InternalMessageInfo // Equivocation implements the Evidence interface and defines evidence of double // signing misbehavior. @@ -122,49 +112,50 @@ func (m *Equivocation) XXX_DiscardUnknown() { var xxx_messageInfo_Equivocation proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgSubmitEvidenceBase)(nil), "cosmos_sdk.x.evidence.v1.MsgSubmitEvidenceBase") + proto.RegisterType((*MsgSubmitEvidence)(nil), "cosmos_sdk.x.evidence.v1.MsgSubmitEvidence") proto.RegisterType((*Equivocation)(nil), "cosmos_sdk.x.evidence.v1.Equivocation") } func init() { proto.RegisterFile("x/evidence/types/types.proto", fileDescriptor_72113e6a7b2536ae) } var fileDescriptor_72113e6a7b2536ae = []byte{ - // 390 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xa9, 0xd0, 0x4f, 0x2d, - 0xcb, 0x4c, 0x49, 0xcd, 0x4b, 0x4e, 0xd5, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0x86, 0x90, 0x7a, 0x05, - 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x12, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xf1, 0xc5, 0x29, 0xd9, - 0x7a, 0x15, 0x7a, 0x30, 0x85, 0x7a, 0x65, 0x86, 0x52, 0x6a, 0x25, 0x19, 0x99, 0x45, 0x29, 0xf1, - 0x05, 0x89, 0x45, 0x25, 0x95, 0xfa, 0x60, 0xc5, 0xfa, 0xe9, 0xf9, 0xe9, 0xf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0xf2, 0xd4, 0x22, 0x09, 0x66, 0xb0, 0x81, 0x10, 0x8e, 0x50, 0x35, 0x97, - 0x60, 0x72, 0x7e, 0x5e, 0x71, 0x6a, 0x5e, 0x71, 0x69, 0x71, 0x7c, 0x22, 0xc4, 0x61, 0x12, 0x2c, - 0x60, 0x1f, 0xf9, 0x7d, 0xba, 0x27, 0x2f, 0x51, 0x99, 0x98, 0x9b, 0x63, 0xa5, 0x84, 0xa1, 0x44, - 0xe9, 0xd7, 0x3d, 0x79, 0x3d, 0x22, 0x7c, 0xeb, 0x9c, 0x9f, 0x57, 0x0c, 0xf3, 0xae, 0x00, 0xdc, - 0x14, 0xa8, 0x88, 0x15, 0x47, 0xc7, 0x02, 0x79, 0x86, 0x19, 0x0b, 0xe4, 0x19, 0x9c, 0xbc, 0x57, - 0x3c, 0x92, 0x63, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, - 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xfc, 0xe1, - 0x8a, 0x9e, 0x4a, 0x92, 0xd8, 0xc0, 0xa1, 0x61, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xce, 0x16, - 0xee, 0xfa, 0x40, 0x02, 0x00, 0x00, + // 414 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xbd, 0xae, 0xd3, 0x30, + 0x18, 0x8d, 0xb9, 0xe5, 0xaa, 0x98, 0x3b, 0xd0, 0xa8, 0x42, 0xa1, 0x42, 0x71, 0x95, 0x01, 0x75, + 0xa9, 0x43, 0x61, 0x41, 0xdd, 0x5a, 0xd4, 0x09, 0x01, 0x52, 0x60, 0x62, 0xa9, 0xf2, 0x63, 0x12, + 0xab, 0x4d, 0x1c, 0x62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da, 0x58, 0x8a, 0xc2, 0xb5, + 0x28, 0x3c, 0x8a, 0x32, 0xeb, 0x88, 0x1a, 0x36, 0xbe, 0xae, 0x91, 0x62, 0xfc, 0x05, 0xf0, 0x66, + 0xf2, 0x29, 0xa5, 0x0b, 0xe6, 0xda, 0x82, 0xb2, 0x48, 0x7d, 0x08, 0xaf, 0x03, 0x42, 0xfd, 0x40, + 0x94, 0xb2, 0xae, 0xac, 0xaa, 0x52, 0x5f, 0xc0, 0xc6, 0xc1, 0x75, 0x45, 0xde, 0xb9, 0x20, 0x7f, + 0x5f, 0x47, 0x32, 0x6e, 0x6e, 0x72, 0xa4, 0xac, 0x7e, 0x21, 0x60, 0x95, 0x27, 0xd4, 0x36, 0xbc, + 0x1b, 0xb3, 0xcf, 0x24, 0xd1, 0xae, 0x4a, 0x42, 0x59, 0xa8, 0x5f, 0x60, 0xcb, 0x65, 0x11, 0x27, + 0x11, 0x4f, 0xf9, 0xd4, 0x96, 0x86, 0xb4, 0x46, 0x99, 0xc4, 0x9b, 0x3f, 0x39, 0xd2, 0x32, 0x3b, + 0x9c, 0x0f, 0x8d, 0x0b, 0x88, 0xb1, 0xcf, 0x11, 0xbe, 0x45, 0x4a, 0x2f, 0x59, 0xc4, 0xeb, 0x98, + 0x1e, 0x1c, 0x59, 0xaa, 0xce, 0xb0, 0x79, 0xf0, 0xfe, 0x6d, 0x8d, 0x94, 0xf1, 0xab, 0x1f, 0x85, + 0x0e, 0x36, 0x85, 0x0e, 0xb6, 0x85, 0x0e, 0x7e, 0x17, 0x3a, 0x58, 0xed, 0x74, 0x65, 0xbb, 0xd3, + 0x95, 0x9f, 0x3b, 0x5d, 0xf9, 0xf0, 0xff, 0xf7, 0x38, 0xff, 0x75, 0xce, 0x75, 0x99, 0xc6, 0xf3, + 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2c, 0xbe, 0x1a, 0x9c, 0x90, 0x02, 0x00, 0x00, } -func (this *MsgSubmitEvidenceBase) Equal(that interface{}) bool { +func (this *MsgSubmitEvidence) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*MsgSubmitEvidenceBase) + that1, ok := that.(*MsgSubmitEvidence) if !ok { - that2, ok := that.(MsgSubmitEvidenceBase) + that2, ok := that.(MsgSubmitEvidence) if ok { that1 = &that2 } else { @@ -179,6 +170,9 @@ func (this *MsgSubmitEvidenceBase) Equal(that interface{}) bool { if !bytes.Equal(this.Submitter, that1.Submitter) { return false } + if !this.Evidence.Equal(that1.Evidence) { + return false + } return true } func (this *Equivocation) Equal(that interface{}) bool { @@ -214,7 +208,7 @@ func (this *Equivocation) Equal(that interface{}) bool { } return true } -func (m *MsgSubmitEvidenceBase) Marshal() (dAtA []byte, err error) { +func (m *MsgSubmitEvidence) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -224,16 +218,28 @@ func (m *MsgSubmitEvidenceBase) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSubmitEvidenceBase) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSubmitEvidence) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSubmitEvidenceBase) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSubmitEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if m.Evidence != nil { + { + size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } if len(m.Submitter) > 0 { i -= len(m.Submitter) copy(dAtA[i:], m.Submitter) @@ -276,12 +282,12 @@ func (m *Equivocation) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x18 } - n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Time):]) - if err1 != nil { - return 0, err1 + n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Time):]) + if err2 != nil { + return 0, err2 } - i -= n1 - i = encodeVarintTypes(dAtA, i, uint64(n1)) + i -= n2 + i = encodeVarintTypes(dAtA, i, uint64(n2)) i-- dAtA[i] = 0x12 if m.Height != 0 { @@ -303,7 +309,7 @@ func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgSubmitEvidenceBase) Size() (n int) { +func (m *MsgSubmitEvidence) Size() (n int) { if m == nil { return 0 } @@ -313,6 +319,10 @@ func (m *MsgSubmitEvidenceBase) Size() (n int) { if l > 0 { n += 1 + l + sovTypes(uint64(l)) } + if m.Evidence != nil { + l = m.Evidence.Size() + n += 1 + l + sovTypes(uint64(l)) + } return n } @@ -343,7 +353,7 @@ func sovTypes(x uint64) (n int) { func sozTypes(x uint64) (n int) { return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgSubmitEvidenceBase) Unmarshal(dAtA []byte) error { +func (m *MsgSubmitEvidence) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -366,10 +376,10 @@ func (m *MsgSubmitEvidenceBase) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSubmitEvidenceBase: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSubmitEvidence: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSubmitEvidenceBase: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSubmitEvidence: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -406,6 +416,42 @@ func (m *MsgSubmitEvidenceBase) Unmarshal(dAtA []byte) error { m.Submitter = []byte{} } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Evidence == nil { + m.Evidence = &types.Any{} + } + if err := m.Evidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) diff --git a/x/evidence/types/types.proto b/x/evidence/types/types.proto index d9161abd0c9..1cbacfd9729 100644 --- a/x/evidence/types/types.proto +++ b/x/evidence/types/types.proto @@ -6,16 +6,14 @@ option (gogoproto.equal_all) = true; import "third_party/proto/gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; +import "google/protobuf/any.proto"; -// MsgSubmitEvidenceBase defines an sdk.Msg type that supports submitting arbitrary +// MsgSubmitEvidence defines an sdk.Msg type that supports submitting arbitrary // Evidence. -// -// Note, this message type provides the basis for which a true MsgSubmitEvidence -// can be constructed. Since the evidence submitted in the message can be arbitrary, -// assuming it fulfills the Evidence interface, it must be defined at the -// application-level and extend MsgSubmitEvidenceBase. -message MsgSubmitEvidenceBase { +message MsgSubmitEvidence { + option (gogoproto.goproto_getters) = false; bytes submitter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + google.protobuf.Any evidence = 2; } // Equivocation implements the Evidence interface and defines evidence of double diff --git a/x/gov/keeper/common_test.go b/x/gov/keeper/common_test.go index b2e1b6d8800..2cac40eb622 100644 --- a/x/gov/keeper/common_test.go +++ b/x/gov/keeper/common_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/std" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/staking" @@ -17,7 +16,7 @@ func createValidators(ctx sdk.Context, app *simapp.SimApp, powers []int64) ([]sd valAddrs := simapp.ConvertAddrsToValAddrs(addrs) pks := simapp.CreateTestPubKeys(5) - appCodec := std.NewAppCodec(app.Codec()) + appCodec, _ := simapp.MakeCodecs() app.StakingKeeper = staking.NewKeeper( appCodec, app.GetKey(staking.StoreKey), diff --git a/x/gov/keeper/querier_test.go b/x/gov/keeper/querier_test.go index 7816e0ece64..dd842af2933 100644 --- a/x/gov/keeper/querier_test.go +++ b/x/gov/keeper/querier_test.go @@ -6,8 +6,6 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/std" - "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" @@ -148,7 +146,7 @@ func getQueriedVotes(t *testing.T, ctx sdk.Context, cdc codec.JSONMarshaler, que func TestQueries(t *testing.T) { app := simapp.Setup(false) ctx := app.BaseApp.NewContext(false, abci.Header{}) - appCodec := std.NewAppCodec(app.Codec()) + appCodec := app.AppCodec() querier := keeper.NewQuerier(app.GovKeeper) @@ -296,7 +294,7 @@ func TestQueries(t *testing.T) { func TestPaginatedVotesQuery(t *testing.T) { app := simapp.Setup(false) ctx := app.BaseApp.NewContext(false, abci.Header{}) - appCodec := std.NewAppCodec(app.Codec()) + appCodec := app.AppCodec() proposal := types.Proposal{ ProposalBase: types.ProposalBase{ diff --git a/x/gov/simulation/decoder_test.go b/x/gov/simulation/decoder_test.go index 2129da2f471..5a11ab0304c 100644 --- a/x/gov/simulation/decoder_test.go +++ b/x/gov/simulation/decoder_test.go @@ -6,8 +6,6 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/std" - "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/ed25519" @@ -25,7 +23,7 @@ var ( ) func TestDecodeStore(t *testing.T) { - cdc := std.NewAppCodec(std.MakeCodec(simapp.ModuleBasics)) + cdc, _ := simapp.MakeCodecs() dec := simulation.NewDecodeStore(cdc) endTime := time.Now().UTC() diff --git a/x/gov/types/codec.go b/x/gov/types/codec.go index 0974df2ed24..7a6b4c0b97e 100644 --- a/x/gov/types/codec.go +++ b/x/gov/types/codec.go @@ -2,6 +2,7 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" ) // Codec defines the interface required to serialize custom x/gov types. @@ -42,7 +43,7 @@ var ( // // The actual codec used for serialization should be provided to x/gov and // defined at the application level. - ModuleCdc = codec.NewHybridCodec(amino) + ModuleCdc = codec.NewHybridCodec(amino, types.NewInterfaceRegistry()) ) func init() { diff --git a/x/mint/alias.go b/x/mint/alias.go index 62c75396a87..0fca6895ab0 100644 --- a/x/mint/alias.go +++ b/x/mint/alias.go @@ -33,7 +33,6 @@ var ( DefaultParams = types.DefaultParams // variable aliases - ModuleCdc = types.ModuleCdc MinterKey = types.MinterKey KeyMintDenom = types.KeyMintDenom KeyInflationRateChange = types.KeyInflationRateChange diff --git a/x/mint/simulation/decoder_test.go b/x/mint/simulation/decoder_test.go index d858447789b..0d69dc331b0 100644 --- a/x/mint/simulation/decoder_test.go +++ b/x/mint/simulation/decoder_test.go @@ -4,8 +4,6 @@ import ( "fmt" "testing" - "github.com/cosmos/cosmos-sdk/std" - "github.com/stretchr/testify/require" tmkv "github.com/tendermint/tendermint/libs/kv" @@ -17,7 +15,7 @@ import ( ) func TestDecodeStore(t *testing.T) { - cdc := std.NewAppCodec(std.MakeCodec(simapp.ModuleBasics)) + cdc, _ := simapp.MakeCodecs() dec := simulation.NewDecodeStore(cdc) minter := types.NewMinter(sdk.OneDec(), sdk.NewDec(15)) diff --git a/x/mint/types/codec.go b/x/mint/types/codec.go index 04b22f57f2a..974091a9792 100644 --- a/x/mint/types/codec.go +++ b/x/mint/types/codec.go @@ -6,14 +6,6 @@ import ( var ( amino = codec.New() - - // ModuleCdc references the global x/mint module codec. Note, the codec - // should ONLY be used in certain instances of tests and for JSON encoding as - // Amino is still used for that purpose. - // - // The actual codec used for serialization should be provided to x/mint and - // defined at the application level. - ModuleCdc = codec.NewHybridCodec(amino) ) func init() { diff --git a/x/params/types/proposal/codec.go b/x/params/types/proposal/codec.go index c1db160508f..959ec4a369e 100644 --- a/x/params/types/proposal/codec.go +++ b/x/params/types/proposal/codec.go @@ -2,6 +2,7 @@ package proposal import ( "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" ) type Codec struct { @@ -13,7 +14,7 @@ type Codec struct { } func NewCodec(amino *codec.Codec) *Codec { - return &Codec{Marshaler: codec.NewHybridCodec(amino), amino: amino} + return &Codec{Marshaler: codec.NewHybridCodec(amino, types.NewInterfaceRegistry()), amino: amino} } // ModuleCdc is the module codec. diff --git a/x/slashing/simulation/decoder_test.go b/x/slashing/simulation/decoder_test.go index a98b7a10b2b..3458d422fb2 100644 --- a/x/slashing/simulation/decoder_test.go +++ b/x/slashing/simulation/decoder_test.go @@ -5,8 +5,6 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/std" - gogotypes "github.com/gogo/protobuf/types" "github.com/stretchr/testify/require" @@ -29,7 +27,7 @@ var ( ) func TestDecodeStore(t *testing.T) { - cdc := std.NewAppCodec(std.MakeCodec(simapp.ModuleBasics)) + cdc, _ := simapp.MakeCodecs() dec := simulation.NewDecodeStore(cdc) info := types.NewValidatorSigningInfo(consAddr1, 0, 1, time.Now().UTC(), false, 0) diff --git a/x/slashing/types/codec.go b/x/slashing/types/codec.go index 04114f1465a..2d257b39ab0 100644 --- a/x/slashing/types/codec.go +++ b/x/slashing/types/codec.go @@ -2,6 +2,7 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" ) // RegisterCodec registers concrete types on codec @@ -18,7 +19,7 @@ var ( // // The actual codec used for serialization should be provided to x/slashing and // defined at the application level. - ModuleCdc = codec.NewHybridCodec(amino) + ModuleCdc = codec.NewHybridCodec(amino, types.NewInterfaceRegistry()) ) func init() { diff --git a/x/staking/common_test.go b/x/staking/common_test.go index 56cb18dfebd..c897cd019d3 100644 --- a/x/staking/common_test.go +++ b/x/staking/common_test.go @@ -5,8 +5,6 @@ import ( "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/secp256k1" - "github.com/cosmos/cosmos-sdk/std" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -44,7 +42,7 @@ func getBaseSimappWithCustomKeeper() (*codec.Codec, *simapp.SimApp, sdk.Context) app := simapp.Setup(false) ctx := app.BaseApp.NewContext(false, abci.Header{}) - appCodec := std.NewAppCodec(codec.New()) + appCodec := app.AppCodec() app.StakingKeeper = keeper.NewKeeper( appCodec, diff --git a/x/staking/keeper/common_test.go b/x/staking/keeper/common_test.go index b31c2d2701d..6be734af0e3 100644 --- a/x/staking/keeper/common_test.go +++ b/x/staking/keeper/common_test.go @@ -3,8 +3,6 @@ package keeper_test import ( "testing" - "github.com/cosmos/cosmos-sdk/std" - abci "github.com/tendermint/tendermint/abci/types" "github.com/cosmos/cosmos-sdk/codec" @@ -25,7 +23,7 @@ func createTestInput() (*codec.Codec, *simapp.SimApp, sdk.Context) { app := simapp.Setup(false) ctx := app.BaseApp.NewContext(false, abci.Header{}) - appCodec := std.NewAppCodec(codec.New()) + appCodec := app.AppCodec() app.StakingKeeper = keeper.NewKeeper( appCodec, diff --git a/x/staking/simulation/decoder_test.go b/x/staking/simulation/decoder_test.go index 13046c936be..2d98a6615b0 100644 --- a/x/staking/simulation/decoder_test.go +++ b/x/staking/simulation/decoder_test.go @@ -5,8 +5,6 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/std" - "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/ed25519" @@ -34,7 +32,7 @@ func makeTestCodec() (cdc *codec.Codec) { } func TestDecodeStore(t *testing.T) { - cdc := std.NewAppCodec(std.MakeCodec(simapp.ModuleBasics)) + cdc, _ := simapp.MakeCodecs() dec := simulation.NewDecodeStore(cdc) bondTime := time.Now().UTC() diff --git a/x/staking/types/codec.go b/x/staking/types/codec.go index 940e5ac8a4a..d6e4811e944 100644 --- a/x/staking/types/codec.go +++ b/x/staking/types/codec.go @@ -2,6 +2,7 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" ) // RegisterCodec registers the necessary x/staking interfaces and concrete types @@ -23,7 +24,7 @@ var ( // // The actual codec used for serialization should be provided to x/staking and // defined at the application level. - ModuleCdc = codec.NewHybridCodec(amino) + ModuleCdc = codec.NewHybridCodec(amino, types.NewInterfaceRegistry()) ) func init() {