diff --git a/CHANGELOG.md b/CHANGELOG.md index b074365664..d226ebb035 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## Features * Add marker cli has two new flags to set SupplyFixed and AllowGovernanceControl #241 * Modify 'enable governance' behavior on marker module #227 +* Typed Events and Metric counters in Name Module #85 ### Improvements * Add some extra aliases for the CLI query metadata commands. diff --git a/proto/provenance/name/v1/name.proto b/proto/provenance/name/v1/name.proto index 3be74bb10d..0ce8700c72 100644 --- a/proto/provenance/name/v1/name.proto +++ b/proto/provenance/name/v1/name.proto @@ -45,4 +45,16 @@ message CreateRootNameProposal { string name = 3; string owner = 4; bool restricted = 5; -} \ No newline at end of file +} + +// Event emitted when name is bound. +message EventNameBound { + string address = 1; + string name = 2; +} + +// Event emitted when name is unbound. +message EventNameUnbound { + string address = 1; + string name = 2; +} diff --git a/x/name/handler_test.go b/x/name/handler_test.go new file mode 100644 index 0000000000..5dda2d4ad3 --- /dev/null +++ b/x/name/handler_test.go @@ -0,0 +1,159 @@ +package name_test + +import ( + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + simapp "github.com/provenance-io/provenance/app" + "github.com/provenance-io/provenance/x/name" + "github.com/provenance-io/provenance/x/name/keeper" + nametypes "github.com/provenance-io/provenance/x/name/types" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "strings" + "testing" +) + +func TestInvalidMsg(t *testing.T) { + k := keeper.Keeper{} + h := name.NewHandler(k) + + res, err := h(sdk.NewContext(nil, tmproto.Header{}, false, nil), testdata.NewTestMsg()) + require.Error(t, err) + require.Nil(t, res) + + _, _, log := sdkerrors.ABCIInfo(err, false) + require.True(t, strings.Contains(log, "unrecognized name message type")) +} + +// create name record +func TestCreateName(t *testing.T) { + priv1 := secp256k1.GenPrivKey() + addr1 := sdk.AccAddress(priv1.PubKey().Address()) + priv2 := secp256k1.GenPrivKey() + addr2 := sdk.AccAddress(priv2.PubKey().Address()) + + tests := []struct { + name string + expectedError error + msg *nametypes.MsgBindNameRequest + expectedEvent *nametypes.EventNameBound + }{ + { + name: "create name record", + msg: nametypes.NewMsgBindNameRequest(nametypes.NewNameRecord("new", addr2, false), nametypes.NewNameRecord("example.name", addr1, false)), + expectedError: nil, + expectedEvent: &nametypes.EventNameBound{ + Address: addr2.String(), + Name: "new.example.name", + }, + }, + { + name: "create bad name record", + msg: nametypes.NewMsgBindNameRequest(nametypes.NewNameRecord("new", addr2, false), nametypes.NewNameRecord("foo.name", addr1, false)), + expectedError: sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, nametypes.ErrNameNotBound.Error()), + }, + } + + acc1 := &authtypes.BaseAccount{ + Address: addr1.String(), + } + accs := authtypes.GenesisAccounts{acc1} + app := simapp.SetupWithGenesisAccounts(accs) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + em := ctx.EventManager() + var nameData nametypes.GenesisState + nameData.Bindings = append(nameData.Bindings, nametypes.NewNameRecord("name", addr1, false)) + nameData.Bindings = append(nameData.Bindings, nametypes.NewNameRecord("example.name", addr1, false)) + nameData.Params.AllowUnrestrictedNames = false + nameData.Params.MaxNameLevels = 16 + nameData.Params.MinSegmentLength = 2 + nameData.Params.MaxSegmentLength = 16 + + app.NameKeeper.InitGenesis(ctx, nameData) + + app.NameKeeper = keeper.NewKeeper(app.AppCodec(), app.GetKey(nametypes.ModuleName), app.GetSubspace(nametypes.ModuleName)) + handler := name.NewHandler(app.NameKeeper) + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + _, err := handler(ctx, tc.msg) + if tc.expectedError != nil { + require.EqualError(t, err, tc.expectedError.Error()) + } else { + require.NoError(t, err) + } + if tc.expectedEvent != nil { + require.Equal(t, 1, len(em.Events().ToABCIEvents())) + msg1, _ := sdk.ParseTypedEvent(em.Events().ToABCIEvents()[0]) + require.Equal(t, tc.expectedEvent, msg1) + } + }) + } +} + +// delete name record +func TestDeleteName(t *testing.T) { + priv1 := secp256k1.GenPrivKey() + addr1 := sdk.AccAddress(priv1.PubKey().Address()) + + tests := []struct { + name string + expectedError error + msg *nametypes.MsgDeleteNameRequest + expectedEvent *nametypes.EventNameUnbound + }{ + { + name: "delete name record", + msg: nametypes.NewMsgDeleteNameRequest(nametypes.NewNameRecord("example.name", addr1, false)), + expectedError: nil, + expectedEvent: &nametypes.EventNameUnbound{ + Address: addr1.String(), + Name: "example.name", + }, + }, + { + name: "create bad name record", + msg: nametypes.NewMsgDeleteNameRequest(nametypes.NewNameRecord("example.name", addr1, false)), + expectedError: sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "name does not exist"), + }, + } + + acc1 := &authtypes.BaseAccount{ + Address: addr1.String(), + } + accs := authtypes.GenesisAccounts{acc1} + app := simapp.SetupWithGenesisAccounts(accs) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + em := ctx.EventManager() + var nameData nametypes.GenesisState + nameData.Bindings = append(nameData.Bindings, nametypes.NewNameRecord("name", addr1, false)) + nameData.Bindings = append(nameData.Bindings, nametypes.NewNameRecord("example.name", addr1, false)) + nameData.Params.AllowUnrestrictedNames = false + nameData.Params.MaxNameLevels = 16 + nameData.Params.MinSegmentLength = 2 + nameData.Params.MaxSegmentLength = 16 + + app.NameKeeper.InitGenesis(ctx, nameData) + + app.NameKeeper = keeper.NewKeeper(app.AppCodec(), app.GetKey(nametypes.ModuleName), app.GetSubspace(nametypes.ModuleName)) + handler := name.NewHandler(app.NameKeeper) + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + _, err := handler(ctx, tc.msg) + if tc.expectedError != nil { + require.EqualError(t, err, tc.expectedError.Error()) + } else { + require.NoError(t, err) + } + if tc.expectedEvent != nil { + require.Equal(t, 1, len(em.Events().ToABCIEvents())) + msg1, _ := sdk.ParseTypedEvent(em.Events().ToABCIEvents()[0]) + require.Equal(t, tc.expectedEvent, msg1) + } + }) + } +} diff --git a/x/name/keeper/msg_server.go b/x/name/keeper/msg_server.go index 39ba33946d..64f959af50 100644 --- a/x/name/keeper/msg_server.go +++ b/x/name/keeper/msg_server.go @@ -4,6 +4,8 @@ import ( "context" "fmt" + "github.com/armon/go-metrics" + "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -70,14 +72,36 @@ func (s msgServer) BindName(goCtx context.Context, msg *types.MsgBindNameRequest ctx.Logger().Error("unable to bind name", "err", err) return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } + // create event. + nameBoundEvent := types.EventNameBound{ + Address: msg.Record.Address, + Name: name, + } + + // before name of the event was `types.EventTypeNameBound` == name_bound + // because proto message format's do not encourage _ like convention + // but prefer CamelCase for message name, NameBound + // https://developers.google.com/protocol-buffers/docs/style + // Use CamelCase (with an initial capital) for message names – for example, SongServerRequest. + // Use underscore_separated_names for field names (including oneof field and extension names) – for example, song_name. + // Emit event and return - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeNameBound, - sdk.NewAttribute(types.KeyAttributeAddress, msg.Record.Address), - sdk.NewAttribute(types.KeyAttributeName, name), - ), - ) + + // Sample event: + // [{"events":[{"type":"message","attributes":[{"key":"action","value":"bind_name"},{"key":"sender","value":"tp13ulywwfe7v38y0vetsqayccsgzexh6zq38h3d4"}]},{"type":"provenance.name.v1.EventNameBound","attributes":[{"key":"address","value":"\"tp13ulywwfe7v38y0vetsqayccsgzexh6zq38h3d4\""},{"key":"name","value":"\"sc1.pb\""}]},{"type":"transfer","attributes":[{"key":"recipient","value":"tp17xpfvakm2amg962yls6f84z3kell8c5l2udfyt"},{"key":"sender","value":"tp13ulywwfe7v38y0vetsqayccsgzexh6zq38h3d4"},{"key":"amount","value":"2000nhash"}]}]}] + if err := ctx.EventManager().EmitTypedEvent(&nameBoundEvent); err != nil { + return nil, err + } + + // key: modulename+name+bind + defer func() { + telemetry.IncrCounterWithLabels( + []string{types.ModuleName, "name", "bind"}, + 1, + []metrics.Label{telemetry.NewLabel("name", name), telemetry.NewLabel("address", msg.Record.Address)}, + ) + }() + return &types.MsgBindNameResponse{}, nil } @@ -116,13 +140,25 @@ func (s msgServer) DeleteName(goCtx context.Context, msg *types.MsgDeleteNameReq ctx.Logger().Error("error deleting name", "err", err) return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } + + // create name unbound event. + nameUnboundEvent := types.EventNameUnbound{ + Address: msg.Record.Address, + Name: name, + } // Emit event and return - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeNameUnbound, - sdk.NewAttribute(types.KeyAttributeAddress, msg.Record.Address), - sdk.NewAttribute(types.KeyAttributeName, msg.Record.Name), - ), - ) + if err := ctx.EventManager().EmitTypedEvent(&nameUnboundEvent); err != nil { + return nil, err + } + + // key: modulename+name+unbind + defer func() { + telemetry.IncrCounterWithLabels( + []string{types.ModuleName, "name", "unbind"}, + 1, + []metrics.Label{telemetry.NewLabel("name", name), telemetry.NewLabel("address", msg.Record.Address)}, + ) + }() + return &types.MsgDeleteNameResponse{}, nil } diff --git a/x/name/simulation/decoder_test.go b/x/name/simulation/decoder_test.go index 62cf291728..0ae7556b9f 100644 --- a/x/name/simulation/decoder_test.go +++ b/x/name/simulation/decoder_test.go @@ -15,7 +15,7 @@ import ( ) func TestDecodeStore(t *testing.T) { - cdc:= app.MakeEncodingConfig().Marshaler + cdc := app.MakeEncodingConfig().Marshaler dec := simulation.NewDecodeStore(cdc) testNameRecord := types.NewNameRecord("test", sdk.AccAddress{}, true) diff --git a/x/name/types/name.pb.go b/x/name/types/name.pb.go index 7327d3f18a..88f7456838 100644 --- a/x/name/types/name.pb.go +++ b/x/name/types/name.pb.go @@ -202,42 +202,152 @@ func (m *CreateRootNameProposal) XXX_DiscardUnknown() { var xxx_messageInfo_CreateRootNameProposal proto.InternalMessageInfo +// Event emitted when name is bound. +type EventNameBound struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` +} + +func (m *EventNameBound) Reset() { *m = EventNameBound{} } +func (m *EventNameBound) String() string { return proto.CompactTextString(m) } +func (*EventNameBound) ProtoMessage() {} +func (*EventNameBound) Descriptor() ([]byte, []int) { + return fileDescriptor_a314256905bb00ec, []int{3} +} +func (m *EventNameBound) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventNameBound) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventNameBound.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 *EventNameBound) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventNameBound.Merge(m, src) +} +func (m *EventNameBound) XXX_Size() int { + return m.Size() +} +func (m *EventNameBound) XXX_DiscardUnknown() { + xxx_messageInfo_EventNameBound.DiscardUnknown(m) +} + +var xxx_messageInfo_EventNameBound proto.InternalMessageInfo + +func (m *EventNameBound) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *EventNameBound) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +// Event emitted when name is unbound. +type EventNameUnbound struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` +} + +func (m *EventNameUnbound) Reset() { *m = EventNameUnbound{} } +func (m *EventNameUnbound) String() string { return proto.CompactTextString(m) } +func (*EventNameUnbound) ProtoMessage() {} +func (*EventNameUnbound) Descriptor() ([]byte, []int) { + return fileDescriptor_a314256905bb00ec, []int{4} +} +func (m *EventNameUnbound) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventNameUnbound) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventNameUnbound.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 *EventNameUnbound) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventNameUnbound.Merge(m, src) +} +func (m *EventNameUnbound) XXX_Size() int { + return m.Size() +} +func (m *EventNameUnbound) XXX_DiscardUnknown() { + xxx_messageInfo_EventNameUnbound.DiscardUnknown(m) +} + +var xxx_messageInfo_EventNameUnbound proto.InternalMessageInfo + +func (m *EventNameUnbound) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *EventNameUnbound) GetName() string { + if m != nil { + return m.Name + } + return "" +} + func init() { proto.RegisterType((*Params)(nil), "provenance.name.v1.Params") proto.RegisterType((*NameRecord)(nil), "provenance.name.v1.NameRecord") proto.RegisterType((*CreateRootNameProposal)(nil), "provenance.name.v1.CreateRootNameProposal") + proto.RegisterType((*EventNameBound)(nil), "provenance.name.v1.EventNameBound") + proto.RegisterType((*EventNameUnbound)(nil), "provenance.name.v1.EventNameUnbound") } func init() { proto.RegisterFile("provenance/name/v1/name.proto", fileDescriptor_a314256905bb00ec) } var fileDescriptor_a314256905bb00ec = []byte{ - // 411 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x92, 0xb1, 0x6e, 0x13, 0x41, - 0x10, 0x86, 0x6f, 0x89, 0x1d, 0xe2, 0x81, 0x08, 0xb4, 0x32, 0xd1, 0x09, 0x89, 0xb3, 0xe5, 0x02, - 0xa5, 0x00, 0x1f, 0x11, 0x0d, 0xa2, 0x84, 0x36, 0x42, 0xd6, 0x22, 0x1a, 0x1a, 0xb3, 0xb9, 0x1b, - 0x5d, 0x56, 0xba, 0xdd, 0x3d, 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0x44, 0xf4, 0x03, 0x41, 0x35, 0x4f, - 0xe1, 0xae, 0x2c, 0x4b, 0x87, 0xde, 0x13, 0xe6, 0x40, 0xdc, 0xb4, 0x3c, 0x03, 0xd8, 0x3e, 0x47, - 0x60, 0x07, 0xa2, 0xa3, 0xbc, 0xee, 0x7d, 0x5b, 0x8d, 0x92, 0xc9, 0x77, 0x06, 0x47, 0x6f, 0x1d, - 0xca, 0x80, 0xc2, 0xda, 0x10, 0x97, 0xcd, 0x9c, 0x6d, 0xac, 0x97, 0x35, 0x1f, 0x42, 0x3f, 0xa8, - 0x50, 0xdf, 0xec, 0x6b, 0x1b, 0x3e, 0x86, 0x7b, 0x25, 0xfa, 0xc2, 0xa9, 0x26, 0x28, 0x6b, 0xae, - 0x97, 0x76, 0xa5, 0x7f, 0x98, 0x7b, 0x1d, 0xcc, 0x21, 0xf4, 0xed, 0xa5, 0x41, 0x47, 0xff, 0x77, - 0x20, 0xda, 0x66, 0x07, 0xb1, 0x7f, 0x0b, 0xf1, 0xfe, 0x97, 0xd5, 0x28, 0x89, 0x98, 0x7f, 0x56, - 0xa3, 0xe4, 0x4d, 0xf1, 0x73, 0x9d, 0xb1, 0xab, 0x75, 0xc6, 0x7e, 0xaf, 0x33, 0xf6, 0x75, 0x93, - 0x25, 0x57, 0x9b, 0x2c, 0xf9, 0xb5, 0xc9, 0x12, 0x78, 0xa4, 0xe8, 0xcb, 0xef, 0x1c, 0xc7, 0x8c, - 0x7d, 0x7c, 0x51, 0xa9, 0x70, 0x7e, 0x71, 0x36, 0x2d, 0xac, 0xce, 0xb7, 0x81, 0xe7, 0xca, 0x76, - 0xba, 0x7c, 0xd9, 0x1e, 0x5b, 0xf8, 0xdc, 0xa0, 0x3f, 0xdb, 0xa7, 0x0b, 0x7a, 0xf9, 0x37, 0x00, - 0x00, 0xff, 0xff, 0x56, 0x4f, 0x81, 0x5c, 0x8c, 0x02, 0x00, 0x00, + // 446 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b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x4d, 0xfd, + 0x99, 0x9a, 0xfe, 0x7f, 0x87, 0x93, 0xf4, 0xe7, 0x22, 0x62, 0x57, 0x8b, 0x88, 0xfd, 0x5e, 0x44, + 0xec, 0xeb, 0x32, 0x0a, 0xae, 0x96, 0x51, 0xf0, 0x6b, 0x19, 0x05, 0xf0, 0x50, 0xd2, 0xed, 0x6d, + 0x9c, 0xe7, 0x98, 0x7d, 0x7c, 0x9e, 0x4b, 0x77, 0x3e, 0x9b, 0x8e, 0x52, 0x5d, 0xc6, 0x6b, 0xc3, + 0x33, 0xa9, 0x5b, 0x51, 0x3c, 0x6f, 0xce, 0xdd, 0x7d, 0xae, 0xd0, 0x4e, 0x77, 0xe8, 0x86, 0x5f, + 0xfc, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x10, 0x3c, 0x3a, 0x83, 0x0e, 0x03, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -396,6 +506,80 @@ func (m *CreateRootNameProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *EventNameBound) 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 *EventNameBound) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventNameBound) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintName(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintName(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventNameUnbound) 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 *EventNameUnbound) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventNameUnbound) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintName(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintName(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintName(dAtA []byte, offset int, v uint64) int { offset -= sovName(v) base := offset @@ -476,6 +660,40 @@ func (m *CreateRootNameProposal) Size() (n int) { return n } +func (m *EventNameBound) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovName(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovName(uint64(l)) + } + return n +} + +func (m *EventNameUnbound) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovName(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovName(uint64(l)) + } + return n +} + func sovName(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -941,6 +1159,234 @@ func (m *CreateRootNameProposal) Unmarshal(dAtA []byte) error { } return nil } +func (m *EventNameBound) 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 ErrIntOverflowName + } + 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: EventNameBound: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventNameBound: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowName + } + 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 ErrInvalidLengthName + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthName + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowName + } + 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 ErrInvalidLengthName + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthName + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipName(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthName + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventNameUnbound) 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 ErrIntOverflowName + } + 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: EventNameUnbound: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventNameUnbound: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowName + } + 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 ErrInvalidLengthName + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthName + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowName + } + 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 ErrInvalidLengthName + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthName + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipName(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthName + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipName(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0