From f2367338e1cadf4f5121c791f86324153080b347 Mon Sep 17 00:00:00 2001 From: Luis Carvalho Date: Mon, 29 Jul 2024 16:28:30 +0100 Subject: [PATCH] fix: add legacy skyway message (#1234) # Related Github tickets - Closes https://github.com/VolumeFi/paloma/issues/1921 # Background We need these messages to be registered so they can be correctly unmarshalled, both on genesis import/export, as well as pruning the skyway attestation queue. # Testing completed - [x] test coverage exists or has been added/updated - [x] tested in a private testnet # Breaking changes - [x] I have checked my code for breaking changes - [x] If there are breaking changes, there is a supporting migration. --- .../paloma/skyway/legacy_msgs.proto | 26 + x/skyway/types/codec.go | 4 + x/skyway/types/legacy_msgs.go | 72 ++ x/skyway/types/legacy_msgs.pb.go | 635 ++++++++++++++++++ 4 files changed, 737 insertions(+) create mode 100644 proto/palomachain/paloma/skyway/legacy_msgs.proto create mode 100644 x/skyway/types/legacy_msgs.go create mode 100644 x/skyway/types/legacy_msgs.pb.go diff --git a/proto/palomachain/paloma/skyway/legacy_msgs.proto b/proto/palomachain/paloma/skyway/legacy_msgs.proto new file mode 100644 index 00000000..7d9661a9 --- /dev/null +++ b/proto/palomachain/paloma/skyway/legacy_msgs.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package palomachain.paloma.skyway; + +import "cosmos/msg/v1/msg.proto"; +import "gogoproto/gogo.proto"; +import "palomachain/paloma/valset/common.proto"; + +option go_package = "github.com/palomachain/paloma/x/skyway/types"; + +// This message was renamed to `MsgBatchSendToRemoteClaim`. However, since we +// already had some messages in the skyway attestation queue, we now get errors +// on genesis import and when trying to prune the queue. +// The queue only keeps the latest 1000 events, so we can remove this file once +// the messages are rotated out. +message MsgBatchSendToEthClaim { + option (cosmos.msg.v1.signer) = "metadata"; + uint64 event_nonce = 1; + uint64 eth_block_height = 2; + uint64 batch_nonce = 3; + string token_contract = 4; + string chain_reference_id = 5; + string orchestrator = 6; + palomachain.paloma.valset.MsgMetadata metadata = 7 + [ (gogoproto.nullable) = false ]; + uint64 skyway_nonce = 8; +} diff --git a/x/skyway/types/codec.go b/x/skyway/types/codec.go index cefa3083..1501af2b 100644 --- a/x/skyway/types/codec.go +++ b/x/skyway/types/codec.go @@ -20,6 +20,8 @@ func init() { // nolint: exhaustruct func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), + // Register legacy messages + &MsgBatchSendToEthClaim{}, &MsgSendToRemote{}, &MsgConfirmBatch{}, &MsgSendToPalomaClaim{}, @@ -32,6 +34,8 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterInterface( "palomachain.paloma.skyway.EthereumClaim", (*EthereumClaim)(nil), + // Register legacy messages + &MsgBatchSendToEthClaim{}, &MsgSendToPalomaClaim{}, &MsgBatchSendToRemoteClaim{}, &MsgLightNodeSaleClaim{}, diff --git a/x/skyway/types/legacy_msgs.go b/x/skyway/types/legacy_msgs.go new file mode 100644 index 00000000..0d9e6343 --- /dev/null +++ b/x/skyway/types/legacy_msgs.go @@ -0,0 +1,72 @@ +package types + +import ( + fmt "fmt" + + sdkerrors "cosmossdk.io/errors" + "github.com/cometbft/cometbft/crypto/tmhash" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/palomachain/paloma/util/libmeta" +) + +var _ sdk.Msg = &MsgBatchSendToEthClaim{} + +var _ EthereumClaim = &MsgBatchSendToEthClaim{} + +func (msg *MsgBatchSendToEthClaim) SetOrchestrator(orchestrator sdk.AccAddress) { + msg.Orchestrator = orchestrator.String() +} + +// GetType returns the claim type +func (msg *MsgBatchSendToEthClaim) GetType() ClaimType { + return CLAIM_TYPE_BATCH_SEND_TO_ETH +} + +// ValidateBasic performs stateless checks +func (e *MsgBatchSendToEthClaim) ValidateBasic() error { + if err := libmeta.ValidateBasic(e); err != nil { + return err + } + if e.EventNonce == 0 { + return fmt.Errorf("event_nonce == 0") + } + if e.SkywayNonce == 0 { + return fmt.Errorf("skyway_nonce == 0") + } + if e.BatchNonce == 0 { + return fmt.Errorf("batch_nonce == 0") + } + if err := ValidateEthAddress(e.TokenContract); err != nil { + return sdkerrors.Wrap(err, "erc20 token") + } + return nil +} + +// Hash implements WithdrawBatch.Hash +func (msg *MsgBatchSendToEthClaim) ClaimHash() ([]byte, error) { + path := fmt.Sprintf("%d/%d/%d/%s", msg.SkywayNonce, msg.EthBlockHeight, msg.BatchNonce, msg.TokenContract) + return tmhash.Sum([]byte(path)), nil +} + +func (msg MsgBatchSendToEthClaim) GetClaimer() sdk.AccAddress { + err := msg.ValidateBasic() + if err != nil { + panic(fmt.Errorf("MsgBatchSendToEthClaim failed ValidateBasic! Should have been handled earlier: %v", err)) + } + val, err := sdk.AccAddressFromBech32(msg.Orchestrator) + if err != nil { + panic(fmt.Errorf("Invalid orchestrator: %v", err)) + } + return val +} + +// GetSigners defines whose signature is required +func (msg MsgBatchSendToEthClaim) GetSigners() []sdk.AccAddress { + return libmeta.GetSigners(&msg) +} + +// Route should return the name of the module +func (msg MsgBatchSendToEthClaim) Route() string { return RouterKey } + +// Type should return the action +func (msg MsgBatchSendToEthClaim) Type() string { return "batch_send_to_eth_claim" } diff --git a/x/skyway/types/legacy_msgs.pb.go b/x/skyway/types/legacy_msgs.pb.go new file mode 100644 index 00000000..c1c57980 --- /dev/null +++ b/x/skyway/types/legacy_msgs.pb.go @@ -0,0 +1,635 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: palomachain/paloma/skyway/legacy_msgs.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + types "github.com/palomachain/paloma/x/valset/types" + 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 + +// This message was renamed to `MsgBatchSendToRemoteClaim`. However, since we +// already had some messages in the skyway attestation queue, we now get errors +// on genesis import and when trying to prune the queue. +// The queue only keeps the latest 1000 events, so we can remove this file once +// the messages are rotated out. +type MsgBatchSendToEthClaim struct { + EventNonce uint64 `protobuf:"varint,1,opt,name=event_nonce,json=eventNonce,proto3" json:"event_nonce,omitempty"` + EthBlockHeight uint64 `protobuf:"varint,2,opt,name=eth_block_height,json=ethBlockHeight,proto3" json:"eth_block_height,omitempty"` + BatchNonce uint64 `protobuf:"varint,3,opt,name=batch_nonce,json=batchNonce,proto3" json:"batch_nonce,omitempty"` + TokenContract string `protobuf:"bytes,4,opt,name=token_contract,json=tokenContract,proto3" json:"token_contract,omitempty"` + ChainReferenceId string `protobuf:"bytes,5,opt,name=chain_reference_id,json=chainReferenceId,proto3" json:"chain_reference_id,omitempty"` + Orchestrator string `protobuf:"bytes,6,opt,name=orchestrator,proto3" json:"orchestrator,omitempty"` + Metadata types.MsgMetadata `protobuf:"bytes,7,opt,name=metadata,proto3" json:"metadata"` + SkywayNonce uint64 `protobuf:"varint,8,opt,name=skyway_nonce,json=skywayNonce,proto3" json:"skyway_nonce,omitempty"` +} + +func (m *MsgBatchSendToEthClaim) Reset() { *m = MsgBatchSendToEthClaim{} } +func (m *MsgBatchSendToEthClaim) String() string { return proto.CompactTextString(m) } +func (*MsgBatchSendToEthClaim) ProtoMessage() {} +func (*MsgBatchSendToEthClaim) Descriptor() ([]byte, []int) { + return fileDescriptor_1ec51423b5f9718d, []int{0} +} +func (m *MsgBatchSendToEthClaim) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBatchSendToEthClaim) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBatchSendToEthClaim.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 *MsgBatchSendToEthClaim) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBatchSendToEthClaim.Merge(m, src) +} +func (m *MsgBatchSendToEthClaim) XXX_Size() int { + return m.Size() +} +func (m *MsgBatchSendToEthClaim) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBatchSendToEthClaim.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBatchSendToEthClaim proto.InternalMessageInfo + +func (m *MsgBatchSendToEthClaim) GetEventNonce() uint64 { + if m != nil { + return m.EventNonce + } + return 0 +} + +func (m *MsgBatchSendToEthClaim) GetEthBlockHeight() uint64 { + if m != nil { + return m.EthBlockHeight + } + return 0 +} + +func (m *MsgBatchSendToEthClaim) GetBatchNonce() uint64 { + if m != nil { + return m.BatchNonce + } + return 0 +} + +func (m *MsgBatchSendToEthClaim) GetTokenContract() string { + if m != nil { + return m.TokenContract + } + return "" +} + +func (m *MsgBatchSendToEthClaim) GetChainReferenceId() string { + if m != nil { + return m.ChainReferenceId + } + return "" +} + +func (m *MsgBatchSendToEthClaim) GetOrchestrator() string { + if m != nil { + return m.Orchestrator + } + return "" +} + +func (m *MsgBatchSendToEthClaim) GetMetadata() types.MsgMetadata { + if m != nil { + return m.Metadata + } + return types.MsgMetadata{} +} + +func (m *MsgBatchSendToEthClaim) GetSkywayNonce() uint64 { + if m != nil { + return m.SkywayNonce + } + return 0 +} + +func init() { + proto.RegisterType((*MsgBatchSendToEthClaim)(nil), "palomachain.paloma.skyway.MsgBatchSendToEthClaim") +} + +func init() { + proto.RegisterFile("palomachain/paloma/skyway/legacy_msgs.proto", fileDescriptor_1ec51423b5f9718d) +} + +var fileDescriptor_1ec51423b5f9718d = []byte{ + // 415 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0x31, 0x6f, 0x13, 0x31, + 0x14, 0xc7, 0x73, 0x25, 0x94, 0xe2, 0xb4, 0x55, 0x65, 0x21, 0x38, 0x3a, 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x7e, 0xb9, 0x79, 0x41, 0xb4, 0x9c, 0x83, 0x9f, 0xec, 0x86, 0x2a, + 0x5f, 0xfc, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xb3, 0x05, 0x75, 0x87, 0x6b, 0x02, 0x00, 0x00, +} + +func (m *MsgBatchSendToEthClaim) 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 *MsgBatchSendToEthClaim) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBatchSendToEthClaim) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.SkywayNonce != 0 { + i = encodeVarintLegacyMsgs(dAtA, i, uint64(m.SkywayNonce)) + i-- + dAtA[i] = 0x40 + } + { + size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLegacyMsgs(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + if len(m.Orchestrator) > 0 { + i -= len(m.Orchestrator) + copy(dAtA[i:], m.Orchestrator) + i = encodeVarintLegacyMsgs(dAtA, i, uint64(len(m.Orchestrator))) + i-- + dAtA[i] = 0x32 + } + if len(m.ChainReferenceId) > 0 { + i -= len(m.ChainReferenceId) + copy(dAtA[i:], m.ChainReferenceId) + i = encodeVarintLegacyMsgs(dAtA, i, uint64(len(m.ChainReferenceId))) + i-- + dAtA[i] = 0x2a + } + if len(m.TokenContract) > 0 { + i -= len(m.TokenContract) + copy(dAtA[i:], m.TokenContract) + i = encodeVarintLegacyMsgs(dAtA, i, uint64(len(m.TokenContract))) + i-- + dAtA[i] = 0x22 + } + if m.BatchNonce != 0 { + i = encodeVarintLegacyMsgs(dAtA, i, uint64(m.BatchNonce)) + i-- + dAtA[i] = 0x18 + } + if m.EthBlockHeight != 0 { + i = encodeVarintLegacyMsgs(dAtA, i, uint64(m.EthBlockHeight)) + i-- + dAtA[i] = 0x10 + } + if m.EventNonce != 0 { + i = encodeVarintLegacyMsgs(dAtA, i, uint64(m.EventNonce)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintLegacyMsgs(dAtA []byte, offset int, v uint64) int { + offset -= sovLegacyMsgs(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgBatchSendToEthClaim) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.EventNonce != 0 { + n += 1 + sovLegacyMsgs(uint64(m.EventNonce)) + } + if m.EthBlockHeight != 0 { + n += 1 + sovLegacyMsgs(uint64(m.EthBlockHeight)) + } + if m.BatchNonce != 0 { + n += 1 + sovLegacyMsgs(uint64(m.BatchNonce)) + } + l = len(m.TokenContract) + if l > 0 { + n += 1 + l + sovLegacyMsgs(uint64(l)) + } + l = len(m.ChainReferenceId) + if l > 0 { + n += 1 + l + sovLegacyMsgs(uint64(l)) + } + l = len(m.Orchestrator) + if l > 0 { + n += 1 + l + sovLegacyMsgs(uint64(l)) + } + l = m.Metadata.Size() + n += 1 + l + sovLegacyMsgs(uint64(l)) + if m.SkywayNonce != 0 { + n += 1 + sovLegacyMsgs(uint64(m.SkywayNonce)) + } + return n +} + +func sovLegacyMsgs(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozLegacyMsgs(x uint64) (n int) { + return sovLegacyMsgs(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgBatchSendToEthClaim) 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 ErrIntOverflowLegacyMsgs + } + 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: MsgBatchSendToEthClaim: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBatchSendToEthClaim: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EventNonce", wireType) + } + m.EventNonce = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EventNonce |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EthBlockHeight", wireType) + } + m.EthBlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EthBlockHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BatchNonce", wireType) + } + m.BatchNonce = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BatchNonce |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenContract", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyMsgs + } + 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 ErrInvalidLengthLegacyMsgs + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLegacyMsgs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenContract = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainReferenceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyMsgs + } + 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 ErrInvalidLengthLegacyMsgs + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLegacyMsgs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainReferenceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Orchestrator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyMsgs + } + 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 ErrInvalidLengthLegacyMsgs + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLegacyMsgs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Orchestrator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLegacyMsgs + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLegacyMsgs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SkywayNonce", wireType) + } + m.SkywayNonce = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLegacyMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SkywayNonce |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipLegacyMsgs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLegacyMsgs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipLegacyMsgs(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, ErrIntOverflowLegacyMsgs + } + 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, ErrIntOverflowLegacyMsgs + } + 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, ErrIntOverflowLegacyMsgs + } + 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, ErrInvalidLengthLegacyMsgs + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupLegacyMsgs + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthLegacyMsgs + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthLegacyMsgs = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowLegacyMsgs = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupLegacyMsgs = fmt.Errorf("proto: unexpected end of group") +)