From dcc67642fa03144e1998c2dfe6b80ddbe01c4dee Mon Sep 17 00:00:00 2001 From: Marko Date: Mon, 8 Jun 2020 11:49:47 +0200 Subject: [PATCH] proto: remove amino proto tests (#4982) ## Description These tests were made to test the compatibility of amino and protobuf. Since we are moving to protobuf they are not needed anymore. The proto3 directory was created to be used only in these tests Closes: #XXX --- types/proto3/block.pb.go | 1870 -------------------------------------- types/proto3/block.proto | 55 -- types/proto3/result.go | 74 -- types/proto3_test.go | 102 --- 4 files changed, 2101 deletions(-) delete mode 100644 types/proto3/block.pb.go delete mode 100644 types/proto3/block.proto delete mode 100644 types/proto3/result.go delete mode 100644 types/proto3_test.go diff --git a/types/proto3/block.pb.go b/types/proto3/block.pb.go deleted file mode 100644 index 8a557b53c..000000000 --- a/types/proto3/block.pb.go +++ /dev/null @@ -1,1870 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: types/proto3/block.proto - -package proto3 - -import ( - fmt "fmt" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// 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 - -type PartSetHeader struct { - Total int32 `protobuf:"varint,1,opt,name=Total,proto3" json:"Total,omitempty"` - Hash []byte `protobuf:"bytes,2,opt,name=Hash,proto3" json:"Hash,omitempty"` -} - -func (m *PartSetHeader) Reset() { *m = PartSetHeader{} } -func (m *PartSetHeader) String() string { return proto.CompactTextString(m) } -func (*PartSetHeader) ProtoMessage() {} -func (*PartSetHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_760f4d5ceb2a11f0, []int{0} -} -func (m *PartSetHeader) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PartSetHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PartSetHeader.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 *PartSetHeader) XXX_Merge(src proto.Message) { - xxx_messageInfo_PartSetHeader.Merge(m, src) -} -func (m *PartSetHeader) XXX_Size() int { - return m.Size() -} -func (m *PartSetHeader) XXX_DiscardUnknown() { - xxx_messageInfo_PartSetHeader.DiscardUnknown(m) -} - -var xxx_messageInfo_PartSetHeader proto.InternalMessageInfo - -func (m *PartSetHeader) GetTotal() int32 { - if m != nil { - return m.Total - } - return 0 -} - -func (m *PartSetHeader) GetHash() []byte { - if m != nil { - return m.Hash - } - return nil -} - -type BlockID struct { - Hash []byte `protobuf:"bytes,1,opt,name=Hash,proto3" json:"Hash,omitempty"` - PartsHeader *PartSetHeader `protobuf:"bytes,2,opt,name=PartsHeader,proto3" json:"PartsHeader,omitempty"` -} - -func (m *BlockID) Reset() { *m = BlockID{} } -func (m *BlockID) String() string { return proto.CompactTextString(m) } -func (*BlockID) ProtoMessage() {} -func (*BlockID) Descriptor() ([]byte, []int) { - return fileDescriptor_760f4d5ceb2a11f0, []int{1} -} -func (m *BlockID) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BlockID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BlockID.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 *BlockID) XXX_Merge(src proto.Message) { - xxx_messageInfo_BlockID.Merge(m, src) -} -func (m *BlockID) XXX_Size() int { - return m.Size() -} -func (m *BlockID) XXX_DiscardUnknown() { - xxx_messageInfo_BlockID.DiscardUnknown(m) -} - -var xxx_messageInfo_BlockID proto.InternalMessageInfo - -func (m *BlockID) GetHash() []byte { - if m != nil { - return m.Hash - } - return nil -} - -func (m *BlockID) GetPartsHeader() *PartSetHeader { - if m != nil { - return m.PartsHeader - } - return nil -} - -type Header struct { - // basic block info - Version *Version `protobuf:"bytes,1,opt,name=Version,proto3" json:"Version,omitempty"` - ChainID string `protobuf:"bytes,2,opt,name=ChainID,proto3" json:"ChainID,omitempty"` - Height int64 `protobuf:"varint,3,opt,name=Height,proto3" json:"Height,omitempty"` - Time *Timestamp `protobuf:"bytes,4,opt,name=Time,proto3" json:"Time,omitempty"` - // prev block info - LastBlockID *BlockID `protobuf:"bytes,5,opt,name=LastBlockID,proto3" json:"LastBlockID,omitempty"` - // hashes of block data - LastCommitHash []byte `protobuf:"bytes,6,opt,name=LastCommitHash,proto3" json:"LastCommitHash,omitempty"` - DataHash []byte `protobuf:"bytes,7,opt,name=DataHash,proto3" json:"DataHash,omitempty"` - // hashes from the app output from the prev block - ValidatorsHash []byte `protobuf:"bytes,8,opt,name=ValidatorsHash,proto3" json:"ValidatorsHash,omitempty"` - NextValidatorsHash []byte `protobuf:"bytes,9,opt,name=NextValidatorsHash,proto3" json:"NextValidatorsHash,omitempty"` - ConsensusHash []byte `protobuf:"bytes,10,opt,name=ConsensusHash,proto3" json:"ConsensusHash,omitempty"` - AppHash []byte `protobuf:"bytes,11,opt,name=AppHash,proto3" json:"AppHash,omitempty"` - LastResultsHash []byte `protobuf:"bytes,12,opt,name=LastResultsHash,proto3" json:"LastResultsHash,omitempty"` - // consensus info - EvidenceHash []byte `protobuf:"bytes,13,opt,name=EvidenceHash,proto3" json:"EvidenceHash,omitempty"` - ProposerAddress []byte `protobuf:"bytes,14,opt,name=ProposerAddress,proto3" json:"ProposerAddress,omitempty"` -} - -func (m *Header) Reset() { *m = Header{} } -func (m *Header) String() string { return proto.CompactTextString(m) } -func (*Header) ProtoMessage() {} -func (*Header) Descriptor() ([]byte, []int) { - return fileDescriptor_760f4d5ceb2a11f0, []int{2} -} -func (m *Header) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Header) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Header.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 *Header) XXX_Merge(src proto.Message) { - xxx_messageInfo_Header.Merge(m, src) -} -func (m *Header) XXX_Size() int { - return m.Size() -} -func (m *Header) XXX_DiscardUnknown() { - xxx_messageInfo_Header.DiscardUnknown(m) -} - -var xxx_messageInfo_Header proto.InternalMessageInfo - -func (m *Header) GetVersion() *Version { - if m != nil { - return m.Version - } - return nil -} - -func (m *Header) GetChainID() string { - if m != nil { - return m.ChainID - } - return "" -} - -func (m *Header) GetHeight() int64 { - if m != nil { - return m.Height - } - return 0 -} - -func (m *Header) GetTime() *Timestamp { - if m != nil { - return m.Time - } - return nil -} - -func (m *Header) GetLastBlockID() *BlockID { - if m != nil { - return m.LastBlockID - } - return nil -} - -func (m *Header) GetLastCommitHash() []byte { - if m != nil { - return m.LastCommitHash - } - return nil -} - -func (m *Header) GetDataHash() []byte { - if m != nil { - return m.DataHash - } - return nil -} - -func (m *Header) GetValidatorsHash() []byte { - if m != nil { - return m.ValidatorsHash - } - return nil -} - -func (m *Header) GetNextValidatorsHash() []byte { - if m != nil { - return m.NextValidatorsHash - } - return nil -} - -func (m *Header) GetConsensusHash() []byte { - if m != nil { - return m.ConsensusHash - } - return nil -} - -func (m *Header) GetAppHash() []byte { - if m != nil { - return m.AppHash - } - return nil -} - -func (m *Header) GetLastResultsHash() []byte { - if m != nil { - return m.LastResultsHash - } - return nil -} - -func (m *Header) GetEvidenceHash() []byte { - if m != nil { - return m.EvidenceHash - } - return nil -} - -func (m *Header) GetProposerAddress() []byte { - if m != nil { - return m.ProposerAddress - } - return nil -} - -type Version struct { - Block uint64 `protobuf:"varint,1,opt,name=Block,proto3" json:"Block,omitempty"` - App uint64 `protobuf:"varint,2,opt,name=App,proto3" json:"App,omitempty"` -} - -func (m *Version) Reset() { *m = Version{} } -func (m *Version) String() string { return proto.CompactTextString(m) } -func (*Version) ProtoMessage() {} -func (*Version) Descriptor() ([]byte, []int) { - return fileDescriptor_760f4d5ceb2a11f0, []int{3} -} -func (m *Version) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Version) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Version.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 *Version) XXX_Merge(src proto.Message) { - xxx_messageInfo_Version.Merge(m, src) -} -func (m *Version) XXX_Size() int { - return m.Size() -} -func (m *Version) XXX_DiscardUnknown() { - xxx_messageInfo_Version.DiscardUnknown(m) -} - -var xxx_messageInfo_Version proto.InternalMessageInfo - -func (m *Version) GetBlock() uint64 { - if m != nil { - return m.Block - } - return 0 -} - -func (m *Version) GetApp() uint64 { - if m != nil { - return m.App - } - return 0 -} - -// Timestamp wraps how amino encodes time. -// This is the protobuf well-known type protobuf/timestamp.proto -// See: -// https://github.com/google/protobuf/blob/d2980062c859649523d5fd51d6b55ab310e47482/src/google/protobuf/timestamp.proto#L123-L135 -// NOTE/XXX: nanos do not get skipped if they are zero in amino. -type Timestamp struct { - Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"` - Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"` -} - -func (m *Timestamp) Reset() { *m = Timestamp{} } -func (m *Timestamp) String() string { return proto.CompactTextString(m) } -func (*Timestamp) ProtoMessage() {} -func (*Timestamp) Descriptor() ([]byte, []int) { - return fileDescriptor_760f4d5ceb2a11f0, []int{4} -} -func (m *Timestamp) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Timestamp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Timestamp.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 *Timestamp) XXX_Merge(src proto.Message) { - xxx_messageInfo_Timestamp.Merge(m, src) -} -func (m *Timestamp) XXX_Size() int { - return m.Size() -} -func (m *Timestamp) XXX_DiscardUnknown() { - xxx_messageInfo_Timestamp.DiscardUnknown(m) -} - -var xxx_messageInfo_Timestamp proto.InternalMessageInfo - -func (m *Timestamp) GetSeconds() int64 { - if m != nil { - return m.Seconds - } - return 0 -} - -func (m *Timestamp) GetNanos() int32 { - if m != nil { - return m.Nanos - } - return 0 -} - -func init() { - proto.RegisterType((*PartSetHeader)(nil), "tendermint.types.proto3.PartSetHeader") - proto.RegisterType((*BlockID)(nil), "tendermint.types.proto3.BlockID") - proto.RegisterType((*Header)(nil), "tendermint.types.proto3.Header") - proto.RegisterType((*Version)(nil), "tendermint.types.proto3.Version") - proto.RegisterType((*Timestamp)(nil), "tendermint.types.proto3.Timestamp") -} - -func init() { proto.RegisterFile("types/proto3/block.proto", fileDescriptor_760f4d5ceb2a11f0) } - -var fileDescriptor_760f4d5ceb2a11f0 = []byte{ - // 500 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xcf, 0x8a, 0x13, 0x41, - 0x10, 0xc6, 0x77, 0xcc, 0x24, 0xd9, 0xd4, 0x24, 0xab, 0x34, 0xa2, 0x83, 0x87, 0x21, 0x0c, 0xb2, - 0xe4, 0xe2, 0x04, 0x77, 0x41, 0x50, 0x4f, 0xf9, 0x23, 0x66, 0x41, 0x64, 0x69, 0x97, 0x3d, 0x78, - 0xeb, 0x64, 0x9a, 0x64, 0x30, 0xd3, 0x3d, 0x74, 0x77, 0x44, 0xdf, 0xc2, 0xa7, 0x12, 0x8f, 0x7b, - 0xf4, 0x28, 0xc9, 0x8b, 0x48, 0x57, 0x4f, 0xb2, 0x99, 0x60, 0xf0, 0x94, 0xfe, 0xaa, 0x7e, 0xf5, - 0x75, 0x75, 0xa5, 0x06, 0x42, 0xf3, 0xbd, 0xe0, 0xba, 0x5f, 0x28, 0x69, 0xe4, 0x65, 0x7f, 0xba, - 0x94, 0xb3, 0x2f, 0x09, 0x0a, 0xf2, 0xd4, 0x70, 0x91, 0x72, 0x95, 0x67, 0xc2, 0x24, 0x08, 0xb9, - 0xf8, 0x65, 0xfc, 0x1a, 0x3a, 0xd7, 0x4c, 0x99, 0x4f, 0xdc, 0x4c, 0x38, 0x4b, 0xb9, 0x22, 0x8f, - 0xa1, 0x7e, 0x23, 0x0d, 0x5b, 0x86, 0x5e, 0xd7, 0xeb, 0xd5, 0xa9, 0x13, 0x84, 0x80, 0x3f, 0x61, - 0x7a, 0x11, 0x3e, 0xe8, 0x7a, 0xbd, 0x36, 0xc5, 0x73, 0x3c, 0x87, 0xe6, 0xd0, 0x5e, 0x71, 0x35, - 0xde, 0xa5, 0xbd, 0xfb, 0x34, 0x99, 0x40, 0x60, 0x9d, 0xb5, 0xf3, 0xc5, 0xca, 0xe0, 0xe2, 0x3c, - 0x39, 0xd2, 0x48, 0x52, 0xe9, 0x82, 0xee, 0x97, 0xc6, 0x3f, 0x7d, 0x68, 0x94, 0xdd, 0xbd, 0x81, - 0xe6, 0x2d, 0x57, 0x3a, 0x93, 0x02, 0xef, 0x0a, 0x2e, 0xba, 0x47, 0x0d, 0x4b, 0x8e, 0x6e, 0x0b, - 0x48, 0x08, 0xcd, 0xd1, 0x82, 0x65, 0xe2, 0x6a, 0x8c, 0xcd, 0xb4, 0xe8, 0x56, 0x92, 0x27, 0xd6, - 0x3f, 0x9b, 0x2f, 0x4c, 0x58, 0xeb, 0x7a, 0xbd, 0x1a, 0x2d, 0x15, 0x79, 0x05, 0xfe, 0x4d, 0x96, - 0xf3, 0xd0, 0xc7, 0xab, 0xe2, 0xa3, 0x57, 0x59, 0x48, 0x1b, 0x96, 0x17, 0x14, 0x79, 0x32, 0x84, - 0xe0, 0x03, 0xd3, 0xa6, 0x9c, 0x4e, 0x58, 0xff, 0x4f, 0xa7, 0x25, 0x47, 0xf7, 0x8b, 0xc8, 0x39, - 0x9c, 0x59, 0x39, 0x92, 0x79, 0x9e, 0x19, 0x1c, 0x6e, 0x03, 0x87, 0x7b, 0x10, 0x25, 0xcf, 0xe0, - 0x74, 0xcc, 0x0c, 0x43, 0xa2, 0x89, 0xc4, 0x4e, 0x5b, 0x8f, 0x5b, 0xb6, 0xcc, 0x52, 0x66, 0xa4, - 0xd2, 0x48, 0x9c, 0x3a, 0x8f, 0x6a, 0x94, 0x24, 0x40, 0x3e, 0xf2, 0x6f, 0xe6, 0x80, 0x6d, 0x21, - 0xfb, 0x8f, 0x0c, 0x79, 0x0e, 0x9d, 0x91, 0x14, 0x9a, 0x0b, 0xbd, 0x72, 0x28, 0x20, 0x5a, 0x0d, - 0xda, 0x79, 0x0f, 0x8a, 0x02, 0xf3, 0x01, 0xe6, 0xb7, 0x92, 0xf4, 0xe0, 0xa1, 0x7d, 0x05, 0xe5, - 0x7a, 0xb5, 0x34, 0xce, 0xa1, 0x8d, 0xc4, 0x61, 0x98, 0xc4, 0xd0, 0x7e, 0xf7, 0x35, 0x4b, 0xb9, - 0x98, 0x71, 0xc4, 0x3a, 0x88, 0x55, 0x62, 0xd6, 0xed, 0x5a, 0xc9, 0x42, 0x6a, 0xae, 0x06, 0x69, - 0xaa, 0xb8, 0xd6, 0xe1, 0x99, 0x73, 0x3b, 0x08, 0xc7, 0x2f, 0x77, 0xdb, 0x63, 0xd7, 0x1c, 0x27, - 0x8d, 0x6b, 0xe4, 0x53, 0x27, 0xc8, 0x23, 0xa8, 0x0d, 0x8a, 0x02, 0xd7, 0xc3, 0xa7, 0xf6, 0x18, - 0xbf, 0x85, 0xd6, 0xee, 0xdf, 0xb5, 0x2f, 0xd2, 0x7c, 0x26, 0x45, 0xaa, 0xb1, 0xac, 0x46, 0xb7, - 0xd2, 0xda, 0x09, 0x26, 0xa4, 0xc6, 0xd2, 0x3a, 0x75, 0x62, 0xf8, 0xfe, 0xd7, 0x3a, 0xf2, 0xee, - 0xd6, 0x91, 0xf7, 0x67, 0x1d, 0x79, 0x3f, 0x36, 0xd1, 0xc9, 0xdd, 0x26, 0x3a, 0xf9, 0xbd, 0x89, - 0x4e, 0x3e, 0xbf, 0x98, 0x67, 0x66, 0xb1, 0x9a, 0x26, 0x33, 0x99, 0xf7, 0xef, 0xd7, 0xa2, 0x72, - 0xdc, 0xfb, 0x94, 0xa7, 0x0d, 0xf7, 0xfb, 0x37, 0x00, 0x00, 0xff, 0xff, 0xce, 0xe0, 0x8f, 0x1e, - 0xe1, 0x03, 0x00, 0x00, -} - -func (m *PartSetHeader) 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 *PartSetHeader) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PartSetHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Hash) > 0 { - i -= len(m.Hash) - copy(dAtA[i:], m.Hash) - i = encodeVarintBlock(dAtA, i, uint64(len(m.Hash))) - i-- - dAtA[i] = 0x12 - } - if m.Total != 0 { - i = encodeVarintBlock(dAtA, i, uint64(m.Total)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *BlockID) 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 *BlockID) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BlockID) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.PartsHeader != nil { - { - size, err := m.PartsHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintBlock(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Hash) > 0 { - i -= len(m.Hash) - copy(dAtA[i:], m.Hash) - i = encodeVarintBlock(dAtA, i, uint64(len(m.Hash))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Header) 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 *Header) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ProposerAddress) > 0 { - i -= len(m.ProposerAddress) - copy(dAtA[i:], m.ProposerAddress) - i = encodeVarintBlock(dAtA, i, uint64(len(m.ProposerAddress))) - i-- - dAtA[i] = 0x72 - } - if len(m.EvidenceHash) > 0 { - i -= len(m.EvidenceHash) - copy(dAtA[i:], m.EvidenceHash) - i = encodeVarintBlock(dAtA, i, uint64(len(m.EvidenceHash))) - i-- - dAtA[i] = 0x6a - } - if len(m.LastResultsHash) > 0 { - i -= len(m.LastResultsHash) - copy(dAtA[i:], m.LastResultsHash) - i = encodeVarintBlock(dAtA, i, uint64(len(m.LastResultsHash))) - i-- - dAtA[i] = 0x62 - } - if len(m.AppHash) > 0 { - i -= len(m.AppHash) - copy(dAtA[i:], m.AppHash) - i = encodeVarintBlock(dAtA, i, uint64(len(m.AppHash))) - i-- - dAtA[i] = 0x5a - } - if len(m.ConsensusHash) > 0 { - i -= len(m.ConsensusHash) - copy(dAtA[i:], m.ConsensusHash) - i = encodeVarintBlock(dAtA, i, uint64(len(m.ConsensusHash))) - i-- - dAtA[i] = 0x52 - } - if len(m.NextValidatorsHash) > 0 { - i -= len(m.NextValidatorsHash) - copy(dAtA[i:], m.NextValidatorsHash) - i = encodeVarintBlock(dAtA, i, uint64(len(m.NextValidatorsHash))) - i-- - dAtA[i] = 0x4a - } - if len(m.ValidatorsHash) > 0 { - i -= len(m.ValidatorsHash) - copy(dAtA[i:], m.ValidatorsHash) - i = encodeVarintBlock(dAtA, i, uint64(len(m.ValidatorsHash))) - i-- - dAtA[i] = 0x42 - } - if len(m.DataHash) > 0 { - i -= len(m.DataHash) - copy(dAtA[i:], m.DataHash) - i = encodeVarintBlock(dAtA, i, uint64(len(m.DataHash))) - i-- - dAtA[i] = 0x3a - } - if len(m.LastCommitHash) > 0 { - i -= len(m.LastCommitHash) - copy(dAtA[i:], m.LastCommitHash) - i = encodeVarintBlock(dAtA, i, uint64(len(m.LastCommitHash))) - i-- - dAtA[i] = 0x32 - } - if m.LastBlockID != nil { - { - size, err := m.LastBlockID.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintBlock(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - if m.Time != nil { - { - size, err := m.Time.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintBlock(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if m.Height != 0 { - i = encodeVarintBlock(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x18 - } - if len(m.ChainID) > 0 { - i -= len(m.ChainID) - copy(dAtA[i:], m.ChainID) - i = encodeVarintBlock(dAtA, i, uint64(len(m.ChainID))) - i-- - dAtA[i] = 0x12 - } - if m.Version != nil { - { - size, err := m.Version.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintBlock(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Version) 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 *Version) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Version) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.App != 0 { - i = encodeVarintBlock(dAtA, i, uint64(m.App)) - i-- - dAtA[i] = 0x10 - } - if m.Block != 0 { - i = encodeVarintBlock(dAtA, i, uint64(m.Block)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Timestamp) 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 *Timestamp) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Timestamp) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Nanos != 0 { - i = encodeVarintBlock(dAtA, i, uint64(m.Nanos)) - i-- - dAtA[i] = 0x10 - } - if m.Seconds != 0 { - i = encodeVarintBlock(dAtA, i, uint64(m.Seconds)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintBlock(dAtA []byte, offset int, v uint64) int { - offset -= sovBlock(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *PartSetHeader) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Total != 0 { - n += 1 + sovBlock(uint64(m.Total)) - } - l = len(m.Hash) - if l > 0 { - n += 1 + l + sovBlock(uint64(l)) - } - return n -} - -func (m *BlockID) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Hash) - if l > 0 { - n += 1 + l + sovBlock(uint64(l)) - } - if m.PartsHeader != nil { - l = m.PartsHeader.Size() - n += 1 + l + sovBlock(uint64(l)) - } - return n -} - -func (m *Header) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Version != nil { - l = m.Version.Size() - n += 1 + l + sovBlock(uint64(l)) - } - l = len(m.ChainID) - if l > 0 { - n += 1 + l + sovBlock(uint64(l)) - } - if m.Height != 0 { - n += 1 + sovBlock(uint64(m.Height)) - } - if m.Time != nil { - l = m.Time.Size() - n += 1 + l + sovBlock(uint64(l)) - } - if m.LastBlockID != nil { - l = m.LastBlockID.Size() - n += 1 + l + sovBlock(uint64(l)) - } - l = len(m.LastCommitHash) - if l > 0 { - n += 1 + l + sovBlock(uint64(l)) - } - l = len(m.DataHash) - if l > 0 { - n += 1 + l + sovBlock(uint64(l)) - } - l = len(m.ValidatorsHash) - if l > 0 { - n += 1 + l + sovBlock(uint64(l)) - } - l = len(m.NextValidatorsHash) - if l > 0 { - n += 1 + l + sovBlock(uint64(l)) - } - l = len(m.ConsensusHash) - if l > 0 { - n += 1 + l + sovBlock(uint64(l)) - } - l = len(m.AppHash) - if l > 0 { - n += 1 + l + sovBlock(uint64(l)) - } - l = len(m.LastResultsHash) - if l > 0 { - n += 1 + l + sovBlock(uint64(l)) - } - l = len(m.EvidenceHash) - if l > 0 { - n += 1 + l + sovBlock(uint64(l)) - } - l = len(m.ProposerAddress) - if l > 0 { - n += 1 + l + sovBlock(uint64(l)) - } - return n -} - -func (m *Version) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Block != 0 { - n += 1 + sovBlock(uint64(m.Block)) - } - if m.App != 0 { - n += 1 + sovBlock(uint64(m.App)) - } - return n -} - -func (m *Timestamp) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Seconds != 0 { - n += 1 + sovBlock(uint64(m.Seconds)) - } - if m.Nanos != 0 { - n += 1 + sovBlock(uint64(m.Nanos)) - } - return n -} - -func sovBlock(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozBlock(x uint64) (n int) { - return sovBlock(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *PartSetHeader) 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 ErrIntOverflowBlock - } - 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: PartSetHeader: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PartSetHeader: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Total", wireType) - } - m.Total = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Total |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) - if m.Hash == nil { - m.Hash = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipBlock(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthBlock - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthBlock - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *BlockID) 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 ErrIntOverflowBlock - } - 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: BlockID: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BlockID: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) - if m.Hash == nil { - m.Hash = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PartsHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.PartsHeader == nil { - m.PartsHeader = &PartSetHeader{} - } - if err := m.PartsHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipBlock(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthBlock - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthBlock - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Header) 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 ErrIntOverflowBlock - } - 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: Header: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Header: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Version == nil { - m.Version = &Version{} - } - if err := m.Version.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainID", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - 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 ErrInvalidLengthBlock - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChainID = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Time == nil { - m.Time = &Timestamp{} - } - if err := m.Time.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LastBlockID", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.LastBlockID == nil { - m.LastBlockID = &BlockID{} - } - if err := m.LastBlockID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LastCommitHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.LastCommitHash = append(m.LastCommitHash[:0], dAtA[iNdEx:postIndex]...) - if m.LastCommitHash == nil { - m.LastCommitHash = []byte{} - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DataHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DataHash = append(m.DataHash[:0], dAtA[iNdEx:postIndex]...) - if m.DataHash == nil { - m.DataHash = []byte{} - } - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorsHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ValidatorsHash = append(m.ValidatorsHash[:0], dAtA[iNdEx:postIndex]...) - if m.ValidatorsHash == nil { - m.ValidatorsHash = []byte{} - } - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NextValidatorsHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.NextValidatorsHash = append(m.NextValidatorsHash[:0], dAtA[iNdEx:postIndex]...) - if m.NextValidatorsHash == nil { - m.NextValidatorsHash = []byte{} - } - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsensusHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsensusHash = append(m.ConsensusHash[:0], dAtA[iNdEx:postIndex]...) - if m.ConsensusHash == nil { - m.ConsensusHash = []byte{} - } - iNdEx = postIndex - case 11: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AppHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AppHash = append(m.AppHash[:0], dAtA[iNdEx:postIndex]...) - if m.AppHash == nil { - m.AppHash = []byte{} - } - iNdEx = postIndex - case 12: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LastResultsHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.LastResultsHash = append(m.LastResultsHash[:0], dAtA[iNdEx:postIndex]...) - if m.LastResultsHash == nil { - m.LastResultsHash = []byte{} - } - iNdEx = postIndex - case 13: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EvidenceHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EvidenceHash = append(m.EvidenceHash[:0], dAtA[iNdEx:postIndex]...) - if m.EvidenceHash == nil { - m.EvidenceHash = []byte{} - } - iNdEx = postIndex - case 14: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProposerAddress", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthBlock - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthBlock - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProposerAddress = append(m.ProposerAddress[:0], dAtA[iNdEx:postIndex]...) - if m.ProposerAddress == nil { - m.ProposerAddress = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipBlock(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthBlock - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthBlock - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Version) 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 ErrIntOverflowBlock - } - 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: Version: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Version: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) - } - m.Block = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Block |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field App", wireType) - } - m.App = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.App |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipBlock(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthBlock - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthBlock - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Timestamp) 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 ErrIntOverflowBlock - } - 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: Timestamp: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Timestamp: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Seconds", wireType) - } - m.Seconds = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Seconds |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Nanos", wireType) - } - m.Nanos = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBlock - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Nanos |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipBlock(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthBlock - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthBlock - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipBlock(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, ErrIntOverflowBlock - } - 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, ErrIntOverflowBlock - } - 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, ErrIntOverflowBlock - } - 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, ErrInvalidLengthBlock - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupBlock - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthBlock - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthBlock = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowBlock = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupBlock = fmt.Errorf("proto: unexpected end of group") -) diff --git a/types/proto3/block.proto b/types/proto3/block.proto deleted file mode 100644 index adaa0a00d..000000000 --- a/types/proto3/block.proto +++ /dev/null @@ -1,55 +0,0 @@ -syntax = "proto3"; - -package tendermint.types.proto3; -option go_package = "github.com/tendermint/tendermint/types/proto3"; - -message PartSetHeader { - int32 Total = 1; - bytes Hash = 2; -} - -message BlockID { - bytes Hash = 1; - PartSetHeader PartsHeader = 2; -} - -message Header { - // basic block info - Version Version = 1; - string ChainID = 2; - int64 Height = 3; - Timestamp Time = 4; - - // prev block info - BlockID LastBlockID = 5; - - // hashes of block data - bytes LastCommitHash = 6; // commit from validators from the last block - bytes DataHash = 7; // transactions - - // hashes from the app output from the prev block - bytes ValidatorsHash = 8; // validators for the current block - bytes NextValidatorsHash = 9; // validators for the next block - bytes ConsensusHash = 10; // consensus params for current block - bytes AppHash = 11; // state after txs from the previous block - bytes LastResultsHash = 12; // root hash of all results from the txs from the previous block - - // consensus info - bytes EvidenceHash = 13; // evidence included in the block - bytes ProposerAddress = 14; // original proposer of the block -} - -message Version { - uint64 Block = 1; - uint64 App = 2; -} - -// Timestamp wraps how amino encodes time. -// This is the protobuf well-known type protobuf/timestamp.proto -// See: -// https://github.com/google/protobuf/blob/d2980062c859649523d5fd51d6b55ab310e47482/src/google/protobuf/timestamp.proto#L123-L135 -// NOTE/XXX: nanos do not get skipped if they are zero in amino. -message Timestamp { - int64 seconds = 1; - int32 nanos = 2; -} diff --git a/types/proto3/result.go b/types/proto3/result.go deleted file mode 100644 index ee5269bd3..000000000 --- a/types/proto3/result.go +++ /dev/null @@ -1,74 +0,0 @@ -package proto3 - -import ( - "bytes" - "encoding/json" - - "github.com/gogo/protobuf/jsonpb" -) - -//--------------------------------------------------------------------------- -// override JSON marshalling so we emit defaults (ie. disable omitempty) - -var ( - jsonpbMarshaller = jsonpb.Marshaler{ - EnumsAsInts: true, - EmitDefaults: true, - } - jsonpbUnmarshaller = jsonpb.Unmarshaler{} -) - -func (r *PartSetHeader) MarshalJSON() ([]byte, error) { - s, err := jsonpbMarshaller.MarshalToString(r) - return []byte(s), err -} - -func (r *PartSetHeader) UnmarshalJSON(b []byte) error { - reader := bytes.NewBuffer(b) - return jsonpbUnmarshaller.Unmarshal(reader, r) -} - -func (r *Header) MarshalJSON() ([]byte, error) { - s, err := jsonpbMarshaller.MarshalToString(r) - return []byte(s), err -} - -func (r *Header) UnmarshalJSON(b []byte) error { - reader := bytes.NewBuffer(b) - return jsonpbUnmarshaller.Unmarshal(reader, r) -} - -func (r *Version) MarshalJSON() ([]byte, error) { - s, err := jsonpbMarshaller.MarshalToString(r) - return []byte(s), err -} - -func (r *Version) UnmarshalJSON(b []byte) error { - reader := bytes.NewBuffer(b) - return jsonpbUnmarshaller.Unmarshal(reader, r) -} - -func (r *Timestamp) MarshalJSON() ([]byte, error) { - s, err := jsonpbMarshaller.MarshalToString(r) - return []byte(s), err -} - -func (r *Timestamp) UnmarshalJSON(b []byte) error { - reader := bytes.NewBuffer(b) - return jsonpbUnmarshaller.Unmarshal(reader, r) -} - -// Some compile time assertions to ensure we don't -// have accidental runtime surprises later on. -// jsonEncodingRoundTripper ensures that asserted -// interfaces implement both MarshalJSON and UnmarshalJSON - -type jsonRoundTripper interface { - json.Marshaler - json.Unmarshaler -} - -var _ jsonRoundTripper = (*PartSetHeader)(nil) -var _ jsonRoundTripper = (*Header)(nil) -var _ jsonRoundTripper = (*Version)(nil) -var _ jsonRoundTripper = (*Timestamp)(nil) diff --git a/types/proto3_test.go b/types/proto3_test.go deleted file mode 100644 index ad4881380..000000000 --- a/types/proto3_test.go +++ /dev/null @@ -1,102 +0,0 @@ -package types - -import ( - "testing" - "time" - - "github.com/gogo/protobuf/proto" - "github.com/stretchr/testify/assert" - - "github.com/tendermint/tendermint/types/proto3" -) - -func TestProto3Compatibility(t *testing.T) { - tm, err := time.Parse("Mon Jan 2 15:04:05 -0700 MST 2006", "Mon Jan 2 15:04:05 -0700 MST 2006") - assert.NoError(t, err) - // add some nanos, otherwise protobuf will skip over this while amino (still) won't! - tm = tm.Add(50000 * time.Nanosecond) - seconds := tm.Unix() - nanos := int32(tm.Nanosecond()) - t.Log("seconds", seconds) - t.Log("nanos", nanos) - - pbHeader := proto3.Header{ - ChainID: "cosmos", - Height: 150, - Time: &proto3.Timestamp{Seconds: seconds, Nanos: nanos}, - LastBlockID: &proto3.BlockID{ - Hash: []byte("some serious hashing"), - PartsHeader: &proto3.PartSetHeader{ - Total: 8, - Hash: []byte("some more serious hashing"), - }, - }, - LastCommitHash: []byte("commit hash"), - DataHash: []byte("data hash"), - ValidatorsHash: []byte("validators hash"), - } - aminoHeader := Header{ - ChainID: "cosmos", - Height: 150, - Time: tm, - LastBlockID: BlockID{ - Hash: []byte("some serious hashing"), - PartsHeader: PartSetHeader{ - Total: 8, - Hash: []byte("some more serious hashing"), - }, - }, - LastCommitHash: []byte("commit hash"), - DataHash: []byte("data hash"), - ValidatorsHash: []byte("validators hash"), - } - ab, err := cdc.MarshalBinaryBare(aminoHeader) - assert.NoError(t, err, "unexpected error") - - pb, err := proto.Marshal(&pbHeader) - assert.NoError(t, err, "unexpected error") - // This works: - assert.Equal(t, ab, pb, "encoding doesn't match") - - emptyLastBlockPb := proto3.Header{ - ChainID: "cosmos", - Height: 150, - Time: &proto3.Timestamp{Seconds: seconds, Nanos: nanos}, - LastCommitHash: []byte("commit hash"), - DataHash: []byte("data hash"), - ValidatorsHash: []byte("validators hash"), - } - emptyLastBlockAm := Header{ - ChainID: "cosmos", - Height: 150, - Time: tm, - LastCommitHash: []byte("commit hash"), - DataHash: []byte("data hash"), - ValidatorsHash: []byte("validators hash"), - } - - ab, err = cdc.MarshalBinaryBare(emptyLastBlockAm) - assert.NoError(t, err, "unexpected error") - - pb, err = proto.Marshal(&emptyLastBlockPb) - assert.NoError(t, err, "unexpected error") - // This works: - assert.Equal(t, ab, pb, "encoding doesn't match") - - pb, err = proto.Marshal(&proto3.Header{}) - assert.NoError(t, err, "unexpected error") - t.Log(pb) - - // While in protobuf Header{} encodes to an empty byte slice it does not in amino: - ab, err = cdc.MarshalBinaryBare(Header{}) - assert.NoError(t, err, "unexpected error") - t.Log(ab) - - pb, err = proto.Marshal(&proto3.Timestamp{}) - assert.NoError(t, err, "unexpected error") - t.Log(pb) - - ab, err = cdc.MarshalBinaryBare(time.Time{}) - assert.NoError(t, err, "unexpected error") - t.Log(ab) -}