From c89890b111a9008e3950fbae16c2f6b542cd3926 Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Thu, 14 Apr 2022 16:40:03 -0400 Subject: [PATCH] proto/types: use fixed-length 64-bit integers for rounds in CanonicalVoteExtension Signed-off-by: Thane Thomson --- proto/tendermint/types/canonical.pb.go | 126 +++++++++++-------------- proto/tendermint/types/canonical.proto | 8 +- types/canonical.go | 2 +- 3 files changed, 60 insertions(+), 76 deletions(-) diff --git a/proto/tendermint/types/canonical.pb.go b/proto/tendermint/types/canonical.pb.go index 5df2dc30b..50c0c84fa 100644 --- a/proto/tendermint/types/canonical.pb.go +++ b/proto/tendermint/types/canonical.pb.go @@ -312,8 +312,8 @@ func (m *CanonicalVote) GetChainID() string { // a particular validator such that we can sign over those serialized bytes. type CanonicalVoteExtension struct { Extension []byte `protobuf:"bytes,1,opt,name=extension,proto3" json:"extension,omitempty"` - Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` - Round int32 `protobuf:"varint,3,opt,name=round,proto3" json:"round,omitempty"` + Height int64 `protobuf:"fixed64,2,opt,name=height,proto3" json:"height,omitempty"` + Round int64 `protobuf:"fixed64,3,opt,name=round,proto3" json:"round,omitempty"` ChainId string `protobuf:"bytes,4,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` } @@ -364,7 +364,7 @@ func (m *CanonicalVoteExtension) GetHeight() int64 { return 0 } -func (m *CanonicalVoteExtension) GetRound() int32 { +func (m *CanonicalVoteExtension) GetRound() int64 { if m != nil { return m.Round } @@ -389,40 +389,40 @@ func init() { func init() { proto.RegisterFile("tendermint/types/canonical.proto", fileDescriptor_8d1a1a84ff7267ed) } var fileDescriptor_8d1a1a84ff7267ed = []byte{ - // 528 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x94, 0xcf, 0x6e, 0xd3, 0x40, - 0x10, 0xc6, 0xe3, 0xc4, 0x49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, - 0xc1, 0x67, 0x40, 0xf2, 0x42, 0x14, 0x25, 0xcc, 0xcf, 0x58, 0x17, 0x4c, 0xb9, 0x9c, 0x75, 0xca, - 0x72, 0x6c, 0x16, 0x2f, 0xce, 0x7d, 0xe3, 0x7b, 0x1f, 0x4c, 0x1a, 0x5b, 0x97, 0x84, 0xe2, 0xff, - 0xc1, 0xb5, 0x0b, 0x4b, 0xfc, 0x97, 0xb0, 0x86, 0x7f, 0x0f, 0x6b, 0xf4, 0x00, 0xac, 0x6f, 0x9d, - 0x3f, 0x33, 0x63, 0xf5, 0xea, 0x0b, 0xc5, 0x49, 0x1e, 0x91, 0x04, 0x1e, 0x01, 0x19, 0xd7, 0x41, - 0xf5, 0x5d, 0xb5, 0x89, 0x1d, 0x3a, 0x83, 0xfb, 0xe9, 0x0c, 0x6b, 0x3a, 0x4f, 0x3b, 0x6e, 0x18, - 0x1d, 0xb9, 0x31, 0xe0, 0x7c, 0xb8, 0x29, 0x54, 0xe1, 0xb6, 0x50, 0x85, 0xdf, 0x85, 0x2a, 0x5c, - 0x6f, 0xd5, 0xde, 0xed, 0x56, 0xed, 0xfd, 0xd8, 0xaa, 0xbd, 0x8f, 0x2f, 0x82, 0x88, 0x86, 0xeb, - 0xa5, 0xe5, 0x91, 0x95, 0xdd, 0x7d, 0x31, 0xda, 0x63, 0xf9, 0xb2, 0xec, 0xbe, 0x26, 0xcb, 0x11, - 0xcf, 0x9f, 0xfc, 0x09, 0x00, 0x00, 0xff, 0xff, 0xc9, 0xa0, 0x6a, 0x61, 0xb2, 0x04, 0x00, 0x00, + // 523 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0x8d, 0x53, 0x27, 0xb1, 0xb7, 0x0d, 0x84, 0x55, 0x55, 0x99, 0xa8, 0xb2, 0x2d, 0x1f, 0x90, + 0xb9, 0xd8, 0x52, 0x7b, 0xe0, 0xee, 0x82, 0x44, 0x10, 0x88, 0xe2, 0x56, 0x3d, 0x70, 0x89, 0x36, + 0xf6, 0x62, 0x5b, 0x38, 0xde, 0x95, 0xbd, 0x91, 0xe8, 0x05, 0x7e, 0xa1, 0xdf, 0xc1, 0x97, 0xf4, + 0xd8, 0x23, 0x5c, 0x02, 0x72, 0x7e, 0x04, 0xed, 0xda, 0xb1, 0xad, 0x16, 0x55, 0x42, 0x20, 0x2e, + 0xd1, 0xcc, 0x9b, 0xb7, 0x33, 0x4f, 0x6f, 0xe2, 0x01, 0x26, 0xc3, 0x59, 0x88, 0xf3, 0x65, 0x92, + 0x31, 0x97, 0x5d, 0x52, 0x5c, 0xb8, 0x01, 0xca, 0x48, 0x96, 0x04, 0x28, 0x75, 0x68, 0x4e, 0x18, + 0x81, 0x93, 0x96, 0xe1, 0x08, 0xc6, 0x74, 0x3f, 0x22, 0x11, 0x11, 0x45, 0x97, 0x47, 0x15, 0x6f, + 0x7a, 0x78, 0xa7, 0x93, 0xf8, 0xad, 0xab, 0x46, 0x44, 0x48, 0x94, 0x62, 0x57, 0x64, 0x8b, 0xd5, + 0x07, 0x97, 0x25, 0x4b, 0x5c, 0x30, 0xb4, 0xa4, 0x15, 0xc1, 0xfa, 0x0c, 0x26, 0x27, 0xdb, 0xc9, + 0x5e, 0x4a, 0x82, 0x8f, 0xb3, 0xe7, 0x10, 0x02, 0x39, 0x46, 0x45, 0xac, 0x49, 0xa6, 0x64, 0xef, + 0xf9, 0x22, 0x86, 0x17, 0xe0, 0x21, 0x45, 0x39, 0x9b, 0x17, 0x98, 0xcd, 0x63, 0x8c, 0x42, 0x9c, + 0x6b, 0x7d, 0x53, 0xb2, 0x77, 0x8f, 0x6c, 0xe7, 0xb6, 0x50, 0xa7, 0x69, 0x78, 0x8a, 0x72, 0x76, + 0x86, 0xd9, 0x4b, 0xc1, 0xf7, 0xe4, 0xeb, 0xb5, 0xd1, 0xf3, 0xc7, 0xb4, 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e2, 0x2c, 0xb4, 0xbe, 0xf6, 0xc1, 0xb8, 0x91, 0x75, 0x41, 0x18, 0xfe, 0x1f, + 0xbe, 0x76, 0xcd, 0x92, 0xff, 0xa5, 0x59, 0x83, 0xbf, 0x37, 0x6b, 0x78, 0x8f, 0x59, 0x5f, 0x3a, + 0x7f, 0x66, 0xee, 0xd5, 0x8b, 0x4f, 0x0c, 0x67, 0x45, 0x42, 0x32, 0x78, 0x08, 0x54, 0xbc, 0x4d, + 0xea, 0xef, 0xaa, 0x05, 0xfe, 0xd0, 0x9d, 0xc7, 0x1d, 0x35, 0xdc, 0x1d, 0xb5, 0x11, 0xe0, 0xbd, + 0xbb, 0x2e, 0x75, 0xe9, 0xa6, 0xd4, 0xa5, 0x9f, 0xa5, 0x2e, 0x5d, 0x6d, 0xf4, 0xde, 0xcd, 0x46, + 0xef, 0x7d, 0xdb, 0xe8, 0xbd, 0xf7, 0xcf, 0xa2, 0x84, 0xc5, 0xab, 0x85, 0x13, 0x90, 0xa5, 0xdb, + 0xbd, 0x18, 0x6d, 0x58, 0x5d, 0x96, 0xdb, 0xd7, 0x64, 0x31, 0x14, 0xf8, 0xf1, 0xaf, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x2b, 0x89, 0x89, 0x5b, 0xb2, 0x04, 0x00, 0x00, } func (m *CanonicalBlockID) Marshal() (dAtA []byte, err error) { @@ -667,14 +667,16 @@ func (m *CanonicalVoteExtension) MarshalToSizedBuffer(dAtA []byte) (int, error) dAtA[i] = 0x22 } if m.Round != 0 { - i = encodeVarintCanonical(dAtA, i, uint64(m.Round)) + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Round)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x19 } if m.Height != 0 { - i = encodeVarintCanonical(dAtA, i, uint64(m.Height)) + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Height)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x11 } if len(m.Extension) > 0 { i -= len(m.Extension) @@ -798,10 +800,10 @@ func (m *CanonicalVoteExtension) Size() (n int) { n += 1 + l + sovCanonical(uint64(l)) } if m.Height != 0 { - n += 1 + sovCanonical(uint64(m.Height)) + n += 9 } if m.Round != 0 { - n += 1 + sovCanonical(uint64(m.Round)) + n += 9 } l = len(m.ChainId) if l > 0 { @@ -1499,43 +1501,25 @@ func (m *CanonicalVoteExtension) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 2: - if wireType != 0 { + if wireType != 1 { return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) } m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= int64(b&0x7F) << shift - if b < 0x80 { - break - } + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF } + m.Height = int64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 case 3: - if wireType != 0 { + if wireType != 1 { return fmt.Errorf("proto: wrong wireType = %d for field Round", wireType) } m.Round = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCanonical - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Round |= int32(b&0x7F) << shift - if b < 0x80 { - break - } + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF } + m.Round = int64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) diff --git a/proto/tendermint/types/canonical.proto b/proto/tendermint/types/canonical.proto index c442de441..e9ed1e55d 100644 --- a/proto/tendermint/types/canonical.proto +++ b/proto/tendermint/types/canonical.proto @@ -39,8 +39,8 @@ message CanonicalVote { // CanonicalVoteExtension provides us a way to serialize a vote extension from // a particular validator such that we can sign over those serialized bytes. message CanonicalVoteExtension { - bytes extension = 1; - int64 height = 2; - int32 round = 3; - string chain_id = 4; + bytes extension = 1; + sfixed64 height = 2; + sfixed64 round = 3; + string chain_id = 4; } diff --git a/types/canonical.go b/types/canonical.go index 768523180..9a3d995ec 100644 --- a/types/canonical.go +++ b/types/canonical.go @@ -72,7 +72,7 @@ func CanonicalizeVoteExtension(chainID string, vote *tmproto.Vote) tmproto.Canon return tmproto.CanonicalVoteExtension{ Extension: vote.Extension, Height: vote.Height, - Round: vote.Round, + Round: int64(vote.Round), ChainId: chainID, } }