diff --git a/proto/lavanet/lava/conflict/query.proto b/proto/lavanet/lava/conflict/query.proto index 56662d0ba7..157a2e3e07 100644 --- a/proto/lavanet/lava/conflict/query.proto +++ b/proto/lavanet/lava/conflict/query.proto @@ -26,6 +26,11 @@ service Query { option (google.api.http).get = "/lavanet/lava/conflict/conflict_vote"; } + // Gets a consumer's active conflict list. + rpc ConsumerConflicts(QueryConsumerConflictsRequest) returns (QueryConsumerConflictsResponse) { + option (google.api.http).get = "/lavanet/lava/conflict/consumer_conflicts/{consumer}"; + } + // Queries a provider's conflict list (ones that the provider was reported in and ones that the provider needs to vote) rpc ProviderConflicts(QueryProviderConflictsRequest) returns (QueryProviderConflictsResponse) { option (google.api.http).get = "/lavanet/lava/conflict/provider_conflicts/{provider}"; @@ -70,4 +75,12 @@ message QueryProviderConflictsResponse { repeated string not_voted = 2; } +message QueryConsumerConflictsRequest { + string consumer = 1; +} + +message QueryConsumerConflictsResponse { + repeated string conflicts = 1; +} + // this line is used by starport scaffolding # 3 diff --git a/scripts/cli_test.sh b/scripts/cli_test.sh index 50ab41ab44..3ac4d992a9 100755 --- a/scripts/cli_test.sh +++ b/scripts/cli_test.sh @@ -50,6 +50,7 @@ echo "Testing conflict q commands" trace lavad q conflict params >/dev/null trace lavad q conflict list-conflict-vote >/dev/null trace lavad q conflict provider-conflicts $(lavad keys show servicer1 -a) >/dev/null +trace lavad q conflict consumer-conflicts $(lavad keys show user1 -a) >/dev/null # trace lavad q conflict show-conflict-vote stam >/dev/null ## canot test that here echo "Testing downtime q commands" diff --git a/x/conflict/client/cli/query.go b/x/conflict/client/cli/query.go index 0dbecf6f1a..222a7d7e74 100644 --- a/x/conflict/client/cli/query.go +++ b/x/conflict/client/cli/query.go @@ -28,6 +28,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdListConflictVote()) cmd.AddCommand(CmdShowConflictVote()) cmd.AddCommand(CmdProviderConflicts()) + cmd.AddCommand(CmdConsumerConflicts()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/conflict/client/cli/query_consumer_conflicts.go b/x/conflict/client/cli/query_consumer_conflicts.go new file mode 100644 index 0000000000..e949403bb6 --- /dev/null +++ b/x/conflict/client/cli/query_consumer_conflicts.go @@ -0,0 +1,36 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/lavanet/lava/x/conflict/types" + "github.com/spf13/cobra" +) + +func CmdConsumerConflicts() *cobra.Command { + cmd := &cobra.Command{ + Use: "consumer-conflicts ", + Short: "Gets a consumer's active conflict list", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryConsumerConflictsRequest{ + Consumer: args[0], + } + + res, err := queryClient.ConsumerConflicts(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/conflict/keeper/grpc_query_consumer_conflicts.go b/x/conflict/keeper/grpc_query_consumer_conflicts.go new file mode 100644 index 0000000000..6a49893d17 --- /dev/null +++ b/x/conflict/keeper/grpc_query_consumer_conflicts.go @@ -0,0 +1,28 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/lavanet/lava/x/conflict/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) ConsumerConflicts(c context.Context, req *types.QueryConsumerConflictsRequest) (*types.QueryConsumerConflictsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + var conflictIndices []string + + ctx := sdk.UnwrapSDKContext(c) + conflicts := k.GetAllConflictVote(ctx) + for _, conflict := range conflicts { + if conflict.ClientAddress == req.Consumer { + conflictIndices = append(conflictIndices, conflict.Index) + } + } + + return &types.QueryConsumerConflictsResponse{Conflicts: conflictIndices}, nil +} diff --git a/x/conflict/keeper/grpc_query_consumer_conflicts_test.go b/x/conflict/keeper/grpc_query_consumer_conflicts_test.go new file mode 100644 index 0000000000..ad58640567 --- /dev/null +++ b/x/conflict/keeper/grpc_query_consumer_conflicts_test.go @@ -0,0 +1,52 @@ +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/lavanet/lava/testutil/keeper" + "github.com/lavanet/lava/x/conflict/types" + "github.com/stretchr/testify/require" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestConsumerConflicts(t *testing.T) { + keeper, ctx := keepertest.ConflictKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNConflictVote(keeper, ctx, 10) + for i, msg := range msgs { + msg.ClientAddress = "client" + strconv.Itoa(i%2) + keeper.SetConflictVote(ctx, msg) + } + + for _, tc := range []struct { + desc string + client string + expectedConflicts []string + }{ + { + desc: "client0 conflicts", + client: "client0", + expectedConflicts: []string{"0", "2", "4", "6", "8"}, + }, + { + desc: "client1 conflicts", + client: "client1", + expectedConflicts: []string{"1", "3", "5", "7", "9"}, + }, + { + desc: "invalid client", + client: "dummy", + expectedConflicts: []string{}, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + res, err := keeper.ConsumerConflicts(wctx, &types.QueryConsumerConflictsRequest{Consumer: tc.client}) + require.Nil(t, err) + require.ElementsMatch(t, res.Conflicts, tc.expectedConflicts) + }) + } +} diff --git a/x/conflict/types/query.pb.go b/x/conflict/types/query.pb.go index a0dfb585fa..bd075b79ba 100644 --- a/x/conflict/types/query.pb.go +++ b/x/conflict/types/query.pb.go @@ -393,6 +393,94 @@ func (m *QueryProviderConflictsResponse) GetNotVoted() []string { return nil } +type QueryConsumerConflictsRequest struct { + Consumer string `protobuf:"bytes,1,opt,name=consumer,proto3" json:"consumer,omitempty"` +} + +func (m *QueryConsumerConflictsRequest) Reset() { *m = QueryConsumerConflictsRequest{} } +func (m *QueryConsumerConflictsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryConsumerConflictsRequest) ProtoMessage() {} +func (*QueryConsumerConflictsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1179eb365bacd460, []int{8} +} +func (m *QueryConsumerConflictsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryConsumerConflictsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryConsumerConflictsRequest.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 *QueryConsumerConflictsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryConsumerConflictsRequest.Merge(m, src) +} +func (m *QueryConsumerConflictsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryConsumerConflictsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryConsumerConflictsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryConsumerConflictsRequest proto.InternalMessageInfo + +func (m *QueryConsumerConflictsRequest) GetConsumer() string { + if m != nil { + return m.Consumer + } + return "" +} + +type QueryConsumerConflictsResponse struct { + Conflicts []string `protobuf:"bytes,1,rep,name=conflicts,proto3" json:"conflicts,omitempty"` +} + +func (m *QueryConsumerConflictsResponse) Reset() { *m = QueryConsumerConflictsResponse{} } +func (m *QueryConsumerConflictsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryConsumerConflictsResponse) ProtoMessage() {} +func (*QueryConsumerConflictsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1179eb365bacd460, []int{9} +} +func (m *QueryConsumerConflictsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryConsumerConflictsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryConsumerConflictsResponse.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 *QueryConsumerConflictsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryConsumerConflictsResponse.Merge(m, src) +} +func (m *QueryConsumerConflictsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryConsumerConflictsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryConsumerConflictsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryConsumerConflictsResponse proto.InternalMessageInfo + +func (m *QueryConsumerConflictsResponse) GetConflicts() []string { + if m != nil { + return m.Conflicts + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "lavanet.lava.conflict.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "lavanet.lava.conflict.QueryParamsResponse") @@ -402,50 +490,56 @@ func init() { proto.RegisterType((*QueryAllConflictVoteResponse)(nil), "lavanet.lava.conflict.QueryAllConflictVoteResponse") proto.RegisterType((*QueryProviderConflictsRequest)(nil), "lavanet.lava.conflict.QueryProviderConflictsRequest") proto.RegisterType((*QueryProviderConflictsResponse)(nil), "lavanet.lava.conflict.QueryProviderConflictsResponse") + proto.RegisterType((*QueryConsumerConflictsRequest)(nil), "lavanet.lava.conflict.QueryConsumerConflictsRequest") + proto.RegisterType((*QueryConsumerConflictsResponse)(nil), "lavanet.lava.conflict.QueryConsumerConflictsResponse") } func init() { proto.RegisterFile("lavanet/lava/conflict/query.proto", fileDescriptor_1179eb365bacd460) } var fileDescriptor_1179eb365bacd460 = []byte{ - // 605 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x94, 0x31, 0x6f, 0xd3, 0x40, - 0x14, 0xc7, 0xe3, 0x40, 0xa2, 0xe6, 0x51, 0x09, 0x71, 0x04, 0xa9, 0x72, 0x1b, 0x17, 0x0c, 0x94, - 0xb6, 0xaa, 0xee, 0xd4, 0x24, 0xb0, 0x94, 0xa5, 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 0x2e, 0xcb, 0xff, 0x77, 0xe3, 0x6f, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xc3, 0x04, 0x1b, 0x73, 0xaa, 0x06, 0x00, 0x00, + // 662 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x95, 0x4d, 0x6f, 0xd3, 0x4c, + 0x10, 0xc7, 0xe3, 0x3c, 0x4f, 0xa3, 0x66, 0xa9, 0x84, 0x58, 0x82, 0x54, 0xb9, 0x89, 0x0b, 0x06, + 0x4a, 0x5b, 0x55, 0x5e, 0x35, 0x09, 0x5c, 0x8a, 0x90, 0x9a, 0x4a, 0xf4, 0x84, 0x54, 0x7c, 0x40, + 0x82, 0x4b, 0xe5, 0x38, 0x8b, 0xb1, 0xe4, 0xec, 0xba, 0xf6, 0x26, 0x6a, 0x55, 0xe5, 0xc2, 0x81, + 0x33, 0x12, 0x5f, 0x82, 0x0b, 0x57, 0x8e, 0x9c, 0x7b, 0xac, 0xc4, 0x85, 0x13, 0x42, 0x09, 0x57, + 0xbe, 0x03, 0xca, 0xbe, 0x24, 0x8e, 0x62, 0xbb, 0xa9, 0x38, 0xc5, 0x3b, 0x9e, 0xff, 0xcc, 0x6f, + 0x3c, 0x33, 0x1b, 0x70, 0x2f, 0x70, 0xfa, 0x0e, 0xc1, 0x0c, 0x8d, 0x7f, 0x91, 0x4b, 0xc9, 0xdb, + 0xc0, 0x77, 0x19, 0x3a, 0xe9, 0xe1, 0xe8, 0xcc, 0x0a, 0x23, 0xca, 0x28, 0xbc, 0x23, 0x5d, 0xac, + 0xf1, 0xaf, 0xa5, 0x5c, 0xf4, 0xaa, 0x47, 0xa9, 0x17, 0x60, 0xe4, 0x84, 0x3e, 0x72, 0x08, 0xa1, + 0xcc, 0x61, 0x3e, 0x25, 0xb1, 0x10, 0xe9, 0xdb, 0x2e, 0x8d, 0xbb, 0x34, 0x46, 0x6d, 0x27, 0xc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x99, 0x0c, 0xb7, 0x1f, 0x04, 0xf9, 0xc8, + 0xe9, 0x0b, 0x9a, 0x8f, 0x9c, 0xb1, 0x6c, 0xe6, 0x0e, 0x47, 0xde, 0x80, 0x0f, 0x16, 0x41, 0x86, + 0xdf, 0x34, 0x70, 0x6b, 0x6e, 0x52, 0x60, 0x33, 0x2f, 0x71, 0xd6, 0x54, 0xea, 0x8f, 0xaf, 0xa9, + 0x92, 0xc0, 0x4f, 0x39, 0xf0, 0x13, 0xd8, 0xcc, 0x06, 0xe6, 0xca, 0xe3, 0xc9, 0x8c, 0xa2, 0x73, + 0x65, 0x1b, 0xf0, 0x02, 0xe6, 0x56, 0x30, 0xbf, 0x80, 0xac, 0x75, 0xcf, 0x2f, 0x20, 0x73, 0xcf, + 0xaf, 0x2c, 0x40, 0x5d, 0x19, 0xc9, 0x02, 0x94, 0x6d, 0xd0, 0x6a, 0x5d, 0x0c, 0x0d, 0xed, 0x72, + 0x68, 0x68, 0xbf, 0x86, 0x86, 0xf6, 0x71, 0x64, 0x14, 0x2e, 0x47, 0x46, 0xe1, 0xc7, 0xc8, 0x28, + 0xbc, 0xd9, 0xf4, 0x7c, 0xf6, 0xae, 0xd7, 0xb6, 0x5c, 0xda, 0x9d, 0x8d, 0x7c, 0x3a, 0x8d, 0xcd, + 0xce, 0x42, 0x1c, 0xb7, 0x4b, 0xfc, 0xdf, 0xaf, 0xf1, 0x37, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x09, + 0xd5, 0x79, 0xe8, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -466,6 +560,8 @@ type QueryClient interface { ConflictVote(ctx context.Context, in *QueryGetConflictVoteRequest, opts ...grpc.CallOption) (*QueryGetConflictVoteResponse, error) // Queries a list of ConflictVote items. ConflictVoteAll(ctx context.Context, in *QueryAllConflictVoteRequest, opts ...grpc.CallOption) (*QueryAllConflictVoteResponse, error) + // Gets a consumer's active conflict list. + ConsumerConflicts(ctx context.Context, in *QueryConsumerConflictsRequest, opts ...grpc.CallOption) (*QueryConsumerConflictsResponse, error) // Queries a provider's conflict list (ones that the provider was reported in and ones that the provider needs to vote) ProviderConflicts(ctx context.Context, in *QueryProviderConflictsRequest, opts ...grpc.CallOption) (*QueryProviderConflictsResponse, error) } @@ -505,6 +601,15 @@ func (c *queryClient) ConflictVoteAll(ctx context.Context, in *QueryAllConflictV return out, nil } +func (c *queryClient) ConsumerConflicts(ctx context.Context, in *QueryConsumerConflictsRequest, opts ...grpc.CallOption) (*QueryConsumerConflictsResponse, error) { + out := new(QueryConsumerConflictsResponse) + err := c.cc.Invoke(ctx, "/lavanet.lava.conflict.Query/ConsumerConflicts", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) ProviderConflicts(ctx context.Context, in *QueryProviderConflictsRequest, opts ...grpc.CallOption) (*QueryProviderConflictsResponse, error) { out := new(QueryProviderConflictsResponse) err := c.cc.Invoke(ctx, "/lavanet.lava.conflict.Query/ProviderConflicts", in, out, opts...) @@ -522,6 +627,8 @@ type QueryServer interface { ConflictVote(context.Context, *QueryGetConflictVoteRequest) (*QueryGetConflictVoteResponse, error) // Queries a list of ConflictVote items. ConflictVoteAll(context.Context, *QueryAllConflictVoteRequest) (*QueryAllConflictVoteResponse, error) + // Gets a consumer's active conflict list. + ConsumerConflicts(context.Context, *QueryConsumerConflictsRequest) (*QueryConsumerConflictsResponse, error) // Queries a provider's conflict list (ones that the provider was reported in and ones that the provider needs to vote) ProviderConflicts(context.Context, *QueryProviderConflictsRequest) (*QueryProviderConflictsResponse, error) } @@ -539,6 +646,9 @@ func (*UnimplementedQueryServer) ConflictVote(ctx context.Context, req *QueryGet func (*UnimplementedQueryServer) ConflictVoteAll(ctx context.Context, req *QueryAllConflictVoteRequest) (*QueryAllConflictVoteResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ConflictVoteAll not implemented") } +func (*UnimplementedQueryServer) ConsumerConflicts(ctx context.Context, req *QueryConsumerConflictsRequest) (*QueryConsumerConflictsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ConsumerConflicts not implemented") +} func (*UnimplementedQueryServer) ProviderConflicts(ctx context.Context, req *QueryProviderConflictsRequest) (*QueryProviderConflictsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ProviderConflicts not implemented") } @@ -601,6 +711,24 @@ func _Query_ConflictVoteAll_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _Query_ConsumerConflicts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryConsumerConflictsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ConsumerConflicts(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lavanet.lava.conflict.Query/ConsumerConflicts", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ConsumerConflicts(ctx, req.(*QueryConsumerConflictsRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_ProviderConflicts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryProviderConflictsRequest) if err := dec(in); err != nil { @@ -635,6 +763,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "ConflictVoteAll", Handler: _Query_ConflictVoteAll_Handler, }, + { + MethodName: "ConsumerConflicts", + Handler: _Query_ConsumerConflicts_Handler, + }, { MethodName: "ProviderConflicts", Handler: _Query_ProviderConflicts_Handler, @@ -918,6 +1050,68 @@ func (m *QueryProviderConflictsResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *QueryConsumerConflictsRequest) 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 *QueryConsumerConflictsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryConsumerConflictsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Consumer) > 0 { + i -= len(m.Consumer) + copy(dAtA[i:], m.Consumer) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Consumer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryConsumerConflictsResponse) 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 *QueryConsumerConflictsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryConsumerConflictsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Conflicts) > 0 { + for iNdEx := len(m.Conflicts) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Conflicts[iNdEx]) + copy(dAtA[i:], m.Conflicts[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Conflicts[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1039,6 +1233,34 @@ func (m *QueryProviderConflictsResponse) Size() (n int) { return n } +func (m *QueryConsumerConflictsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Consumer) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryConsumerConflictsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Conflicts) > 0 { + for _, s := range m.Conflicts { + l = len(s) + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1745,6 +1967,170 @@ func (m *QueryProviderConflictsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryConsumerConflictsRequest) 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 ErrIntOverflowQuery + } + 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: QueryConsumerConflictsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryConsumerConflictsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Consumer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Consumer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryConsumerConflictsResponse) 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 ErrIntOverflowQuery + } + 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: QueryConsumerConflictsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryConsumerConflictsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Conflicts", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Conflicts = append(m.Conflicts, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/conflict/types/query.pb.gw.go b/x/conflict/types/query.pb.gw.go index f8b6bc15b6..61f0407187 100644 --- a/x/conflict/types/query.pb.gw.go +++ b/x/conflict/types/query.pb.gw.go @@ -141,6 +141,60 @@ func local_request_Query_ConflictVoteAll_0(ctx context.Context, marshaler runtim } +func request_Query_ConsumerConflicts_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryConsumerConflictsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer") + } + + protoReq.Consumer, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer", err) + } + + msg, err := client.ConsumerConflicts(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ConsumerConflicts_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryConsumerConflictsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer") + } + + protoReq.Consumer, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer", err) + } + + msg, err := server.ConsumerConflicts(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_ProviderConflicts_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryProviderConflictsRequest var metadata runtime.ServerMetadata @@ -270,6 +324,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_ConsumerConflicts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ConsumerConflicts_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ConsumerConflicts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_ProviderConflicts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -394,6 +471,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_ConsumerConflicts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ConsumerConflicts_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ConsumerConflicts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_ProviderConflicts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -424,6 +521,8 @@ var ( pattern_Query_ConflictVoteAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"lavanet", "lava", "conflict", "conflict_vote"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_ConsumerConflicts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"lavanet", "lava", "conflict", "consumer_conflicts", "consumer"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_ProviderConflicts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"lavanet", "lava", "conflict", "provider_conflicts", "provider"}, "", runtime.AssumeColonVerbOpt(false))) ) @@ -434,5 +533,7 @@ var ( forward_Query_ConflictVoteAll_0 = runtime.ForwardResponseMessage + forward_Query_ConsumerConflicts_0 = runtime.ForwardResponseMessage + forward_Query_ProviderConflicts_0 = runtime.ForwardResponseMessage )