From 603bdcfb9d9f06d2bd7f5ee0bc6bd542ab2e45cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 23 Feb 2022 13:11:44 +0100 Subject: [PATCH 01/11] generate proto files --- docs/ibc/proto-docs.md | 37 ++ modules/apps/29-fee/types/query.pb.go | 627 ++++++++++++++++++-- modules/apps/29-fee/types/query.pb.gw.go | 138 +++++ proto/ibc/applications/fee/v1/ack.proto | 2 +- proto/ibc/applications/fee/v1/genesis.proto | 11 +- proto/ibc/applications/fee/v1/query.proto | 23 + proto/ibc/applications/fee/v1/tx.proto | 2 +- 7 files changed, 798 insertions(+), 42 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 164017ca3b2..b103648e7f6 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -45,6 +45,8 @@ - [ibc/applications/fee/v1/query.proto](#ibc/applications/fee/v1/query.proto) - [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) - [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) + - [QueryIncentivizedPacketsForChannelRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsForChannelRequest) + - [QueryIncentivizedPacketsForChannelResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsForChannelResponse) - [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) - [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) @@ -917,6 +919,40 @@ QueryIncentivizedPacketsResponse is the response type for the incentivized packe + + +### QueryIncentivizedPacketsForChannelRequest +QueryIncentivizedPacketsForChannelRequest is the request type for querying for all incentivized packets +for a specific channel + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | +| `port_id` | [string](#string) | | | +| `channel_id` | [string](#string) | | | +| `query_height` | [uint64](#uint64) | | Height to query at | + + + + + + + + +### QueryIncentivizedPacketsForChannelResponse +QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `incentivized_packets` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | repeated | Map of all incentivized_packets | + + + + + + ### QueryIncentivizedPacketsRequest @@ -963,6 +999,7 @@ Query provides defines the gRPC querier service. | ----------- | ------------ | ------------- | ------------| ------- | -------- | | `IncentivizedPackets` | [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) | [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) | Gets all incentivized packets | GET|/ibc/apps/fee/v1/incentivized_packets| | `IncentivizedPacket` | [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) | [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) | Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the given packet | GET|/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| +| `IncentivizedPacketsForChannel` | [QueryIncentivizedPacketsForChannelRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsForChannelRequest) | [QueryIncentivizedPacketsForChannelResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsForChannelResponse) | Gets all incentivized packets for a specific channel | GET|/ibc/apps/fee/v1/incentivized_packets/{port_id}/{channel_id}| diff --git a/modules/apps/29-fee/types/query.pb.go b/modules/apps/29-fee/types/query.pb.go index 3bbbbee7b17..fb5699e2b05 100644 --- a/modules/apps/29-fee/types/query.pb.go +++ b/modules/apps/29-fee/types/query.pb.go @@ -233,11 +233,139 @@ func (m *QueryIncentivizedPacketResponse) GetIncentivizedPacket() *IdentifiedPac return nil } +// QueryIncentivizedPacketsForChannelRequest is the request type for querying for all incentivized packets +// for a specific channel +type QueryIncentivizedPacketsForChannelRequest struct { + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` + PortId string `protobuf:"bytes,2,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // Height to query at + QueryHeight uint64 `protobuf:"varint,4,opt,name=query_height,json=queryHeight,proto3" json:"query_height,omitempty"` +} + +func (m *QueryIncentivizedPacketsForChannelRequest) Reset() { + *m = QueryIncentivizedPacketsForChannelRequest{} +} +func (m *QueryIncentivizedPacketsForChannelRequest) String() string { + return proto.CompactTextString(m) +} +func (*QueryIncentivizedPacketsForChannelRequest) ProtoMessage() {} +func (*QueryIncentivizedPacketsForChannelRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{4} +} +func (m *QueryIncentivizedPacketsForChannelRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryIncentivizedPacketsForChannelRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryIncentivizedPacketsForChannelRequest.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 *QueryIncentivizedPacketsForChannelRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIncentivizedPacketsForChannelRequest.Merge(m, src) +} +func (m *QueryIncentivizedPacketsForChannelRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryIncentivizedPacketsForChannelRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIncentivizedPacketsForChannelRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryIncentivizedPacketsForChannelRequest proto.InternalMessageInfo + +func (m *QueryIncentivizedPacketsForChannelRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +func (m *QueryIncentivizedPacketsForChannelRequest) GetPortId() string { + if m != nil { + return m.PortId + } + return "" +} + +func (m *QueryIncentivizedPacketsForChannelRequest) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *QueryIncentivizedPacketsForChannelRequest) GetQueryHeight() uint64 { + if m != nil { + return m.QueryHeight + } + return 0 +} + +// QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC +type QueryIncentivizedPacketsForChannelResponse struct { + // Map of all incentivized_packets + IncentivizedPackets []*IdentifiedPacketFee `protobuf:"bytes,1,rep,name=incentivized_packets,json=incentivizedPackets,proto3" json:"incentivized_packets,omitempty"` +} + +func (m *QueryIncentivizedPacketsForChannelResponse) Reset() { + *m = QueryIncentivizedPacketsForChannelResponse{} +} +func (m *QueryIncentivizedPacketsForChannelResponse) String() string { + return proto.CompactTextString(m) +} +func (*QueryIncentivizedPacketsForChannelResponse) ProtoMessage() {} +func (*QueryIncentivizedPacketsForChannelResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{5} +} +func (m *QueryIncentivizedPacketsForChannelResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryIncentivizedPacketsForChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryIncentivizedPacketsForChannelResponse.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 *QueryIncentivizedPacketsForChannelResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIncentivizedPacketsForChannelResponse.Merge(m, src) +} +func (m *QueryIncentivizedPacketsForChannelResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryIncentivizedPacketsForChannelResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIncentivizedPacketsForChannelResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryIncentivizedPacketsForChannelResponse proto.InternalMessageInfo + +func (m *QueryIncentivizedPacketsForChannelResponse) GetIncentivizedPackets() []*IdentifiedPacketFee { + if m != nil { + return m.IncentivizedPackets + } + return nil +} + func init() { proto.RegisterType((*QueryIncentivizedPacketsRequest)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsRequest") proto.RegisterType((*QueryIncentivizedPacketsResponse)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsResponse") proto.RegisterType((*QueryIncentivizedPacketRequest)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketRequest") proto.RegisterType((*QueryIncentivizedPacketResponse)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketResponse") + proto.RegisterType((*QueryIncentivizedPacketsForChannelRequest)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsForChannelRequest") + proto.RegisterType((*QueryIncentivizedPacketsForChannelResponse)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsForChannelResponse") } func init() { @@ -245,42 +373,48 @@ func init() { } var fileDescriptor_0638a8a78ca2503c = []byte{ - // 554 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xc1, 0x6b, 0x13, 0x4f, - 0x14, 0xce, 0xa4, 0xfd, 0xfd, 0xd0, 0x89, 0xa7, 0x49, 0xc1, 0x10, 0x74, 0x9b, 0x46, 0xd4, 0x20, - 0x66, 0x86, 0xa4, 0x88, 0xed, 0x4d, 0x7a, 0x28, 0xe6, 0x64, 0xcd, 0x51, 0x90, 0xb0, 0x3b, 0xfb, - 0xb2, 0x19, 0x4c, 0x76, 0xb6, 0x99, 0xc9, 0x42, 0xab, 0x05, 0xa9, 0x78, 0xeb, 0x41, 0xf0, 0xa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0xc8, 0xd3, 0x75, 0x0d, - 0xcc, 0x9d, 0xef, 0xad, 0x4f, 0xb4, 0xc6, 0xcf, 0x51, 0xe2, 0xfc, 0x1d, 0x39, 0xbd, 0x8e, 0x73, - 0x16, 0xc9, 0xb1, 0x66, 0x6f, 0x17, 0x27, 0x8d, 0x9a, 0xf7, 0x9e, 0xf0, 0xcf, 0x16, 0x97, 0x3f, - 0xd3, 0xb3, 0xa5, 0xa4, 0xad, 0x8c, 0xd1, 0x90, 0x43, 0xb6, 0x3f, 0xaf, 0x9d, 0x1d, 0xbc, 0xb8, - 0x9c, 0x3a, 0xe8, 0x6a, 0xea, 0xa0, 0x9f, 0x53, 0x07, 0x7d, 0x9a, 0x39, 0x85, 0xab, 0x99, 0x53, - 0xf8, 0x3e, 0x73, 0x0a, 0xaf, 0x9e, 0x04, 0x42, 0x0f, 0x26, 0x1e, 0xe5, 0x72, 0xc4, 0xec, 0x5f, - 0x44, 0x78, 0xbc, 0x19, 0x48, 0x16, 0xef, 0xb2, 0x91, 0xf4, 0x27, 0x43, 0x50, 0xa9, 0xe9, 0xf6, - 0x7e, 0xd3, 0xf8, 0xd6, 0x27, 0x11, 0x28, 0xef, 0xff, 0xe4, 0x67, 0xb2, 0xfb, 0x3b, 0x00, 0x00, - 0xff, 0xff, 0xd3, 0xea, 0xdd, 0xe2, 0x32, 0x05, 0x00, 0x00, + // 652 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x95, 0xcd, 0x6b, 0x13, 0x4f, + 0x18, 0xc7, 0x33, 0x7d, 0xfb, 0xfd, 0x3a, 0xf5, 0x34, 0x2d, 0x34, 0x04, 0xb3, 0x4d, 0x23, 0x6a, + 0x2c, 0x66, 0x86, 0xa4, 0x88, 0x2d, 0x88, 0x48, 0x2a, 0xc1, 0x9c, 0xac, 0x7b, 0x14, 0x24, 0xec, + 0xcb, 0x64, 0x33, 0x98, 0xec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0xa7, 0x77, 0x1c, 0x16, 0x34, 0xbb, 0x26, 0xb6, 0x78, 0x9b, 0xa8, + 0x77, 0x89, 0x99, 0x56, 0xd1, 0xe1, 0x24, 0xdc, 0x25, 0x6d, 0x6e, 0x77, 0x5b, 0xd4, 0x8f, 0xca, + 0x96, 0xf7, 0x8b, 0xa2, 0x72, 0x70, 0xec, 0x51, 0xdf, 0x5c, 0x91, 0xcf, 0xd3, 0xee, 0x8f, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x5f, 0x15, 0x2f, 0x04, 0x84, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -300,6 +434,8 @@ type QueryClient interface { // Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the // given packet IncentivizedPacket(ctx context.Context, in *QueryIncentivizedPacketRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketResponse, error) + // Gets all incentivized packets for a specific channel + IncentivizedPacketsForChannel(ctx context.Context, in *QueryIncentivizedPacketsForChannelRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketsForChannelResponse, error) } type queryClient struct { @@ -328,6 +464,15 @@ func (c *queryClient) IncentivizedPacket(ctx context.Context, in *QueryIncentivi return out, nil } +func (c *queryClient) IncentivizedPacketsForChannel(ctx context.Context, in *QueryIncentivizedPacketsForChannelRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketsForChannelResponse, error) { + out := new(QueryIncentivizedPacketsForChannelResponse) + err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Query/IncentivizedPacketsForChannel", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Gets all incentivized packets @@ -335,6 +480,8 @@ type QueryServer interface { // Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the // given packet IncentivizedPacket(context.Context, *QueryIncentivizedPacketRequest) (*QueryIncentivizedPacketResponse, error) + // Gets all incentivized packets for a specific channel + IncentivizedPacketsForChannel(context.Context, *QueryIncentivizedPacketsForChannelRequest) (*QueryIncentivizedPacketsForChannelResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -347,6 +494,9 @@ func (*UnimplementedQueryServer) IncentivizedPackets(ctx context.Context, req *Q func (*UnimplementedQueryServer) IncentivizedPacket(ctx context.Context, req *QueryIncentivizedPacketRequest) (*QueryIncentivizedPacketResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method IncentivizedPacket not implemented") } +func (*UnimplementedQueryServer) IncentivizedPacketsForChannel(ctx context.Context, req *QueryIncentivizedPacketsForChannelRequest) (*QueryIncentivizedPacketsForChannelResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method IncentivizedPacketsForChannel not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -388,6 +538,24 @@ func _Query_IncentivizedPacket_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Query_IncentivizedPacketsForChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryIncentivizedPacketsForChannelRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).IncentivizedPacketsForChannel(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.applications.fee.v1.Query/IncentivizedPacketsForChannel", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).IncentivizedPacketsForChannel(ctx, req.(*QueryIncentivizedPacketsForChannelRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.applications.fee.v1.Query", HandlerType: (*QueryServer)(nil), @@ -400,6 +568,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "IncentivizedPacket", Handler: _Query_IncentivizedPacket_Handler, }, + { + MethodName: "IncentivizedPacketsForChannel", + Handler: _Query_IncentivizedPacketsForChannel_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/applications/fee/v1/query.proto", @@ -555,6 +727,97 @@ func (m *QueryIncentivizedPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int return len(dAtA) - i, nil } +func (m *QueryIncentivizedPacketsForChannelRequest) 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 *QueryIncentivizedPacketsForChannelRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryIncentivizedPacketsForChannelRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.QueryHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.QueryHeight)) + i-- + dAtA[i] = 0x20 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x1a + } + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0x12 + } + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryIncentivizedPacketsForChannelResponse) 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 *QueryIncentivizedPacketsForChannelResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryIncentivizedPacketsForChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.IncentivizedPackets) > 0 { + for iNdEx := len(m.IncentivizedPackets) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.IncentivizedPackets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -624,6 +887,45 @@ func (m *QueryIncentivizedPacketResponse) Size() (n int) { return n } +func (m *QueryIncentivizedPacketsForChannelRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.QueryHeight != 0 { + n += 1 + sovQuery(uint64(m.QueryHeight)) + } + return n +} + +func (m *QueryIncentivizedPacketsForChannelResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.IncentivizedPackets) > 0 { + for _, e := range m.IncentivizedPackets { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1007,6 +1309,259 @@ func (m *QueryIncentivizedPacketResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryIncentivizedPacketsForChannelRequest) 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: QueryIncentivizedPacketsForChannelRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryIncentivizedPacketsForChannelRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortId", 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.PortId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", 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.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QueryHeight", wireType) + } + m.QueryHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QueryHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *QueryIncentivizedPacketsForChannelResponse) 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: QueryIncentivizedPacketsForChannelResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryIncentivizedPacketsForChannelResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IncentivizedPackets", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.IncentivizedPackets = append(m.IncentivizedPackets, &IdentifiedPacketFee{}) + if err := m.IncentivizedPackets[len(m.IncentivizedPackets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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/modules/apps/29-fee/types/query.pb.gw.go b/modules/apps/29-fee/types/query.pb.gw.go index 3a9b3d581b2..906ebb0dded 100644 --- a/modules/apps/29-fee/types/query.pb.gw.go +++ b/modules/apps/29-fee/types/query.pb.gw.go @@ -183,6 +183,100 @@ func local_request_Query_IncentivizedPacket_0(ctx context.Context, marshaler run } +var ( + filter_Query_IncentivizedPacketsForChannel_0 = &utilities.DoubleArray{Encoding: map[string]int{"port_id": 0, "channel_id": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} +) + +func request_Query_IncentivizedPacketsForChannel_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryIncentivizedPacketsForChannelRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port_id") + } + + protoReq.PortId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err) + } + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_IncentivizedPacketsForChannel_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.IncentivizedPacketsForChannel(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_IncentivizedPacketsForChannel_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryIncentivizedPacketsForChannelRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port_id") + } + + protoReq.PortId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err) + } + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_IncentivizedPacketsForChannel_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.IncentivizedPacketsForChannel(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -229,6 +323,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_IncentivizedPacketsForChannel_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_IncentivizedPacketsForChannel_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_IncentivizedPacketsForChannel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -310,6 +424,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_IncentivizedPacketsForChannel_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_IncentivizedPacketsForChannel_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_IncentivizedPacketsForChannel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -317,10 +451,14 @@ var ( pattern_Query_IncentivizedPackets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"ibc", "apps", "fee", "v1", "incentivized_packets"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_IncentivizedPacket_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "incentivized_packet", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_IncentivizedPacketsForChannel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 1, 0, 4, 1, 5, 6}, []string{"ibc", "apps", "fee", "v1", "incentivized_packets", "port_id", "channel_id"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( forward_Query_IncentivizedPackets_0 = runtime.ForwardResponseMessage forward_Query_IncentivizedPacket_0 = runtime.ForwardResponseMessage + + forward_Query_IncentivizedPacketsForChannel_0 = runtime.ForwardResponseMessage ) diff --git a/proto/ibc/applications/fee/v1/ack.proto b/proto/ibc/applications/fee/v1/ack.proto index 1a0c5e3f404..6a77e4fce45 100644 --- a/proto/ibc/applications/fee/v1/ack.proto +++ b/proto/ibc/applications/fee/v1/ack.proto @@ -11,5 +11,5 @@ import "gogoproto/gogo.proto"; message IncentivizedAcknowledgement { bytes result = 1; string forward_relayer_address = 2 [(gogoproto.moretags) = "yaml:\"forward_relayer_address\""]; - bool underlying_app_success = 3 [(gogoproto.moretags) = "yaml:\"underlying_app_successl\""]; + bool underlying_app_success = 3 [(gogoproto.moretags) = "yaml:\"underlying_app_successl\""]; } diff --git a/proto/ibc/applications/fee/v1/genesis.proto b/proto/ibc/applications/fee/v1/genesis.proto index 134a16be850..07bde848a37 100644 --- a/proto/ibc/applications/fee/v1/genesis.proto +++ b/proto/ibc/applications/fee/v1/genesis.proto @@ -12,9 +12,12 @@ import "ibc/core/channel/v1/channel.proto"; message GenesisState { repeated IdentifiedPacketFee identified_fees = 1 [(gogoproto.moretags) = "yaml:\"identified_fees\"", (gogoproto.nullable) = false]; - repeated FeeEnabledChannel fee_enabled_channels = 2 [(gogoproto.moretags) = "yaml:\"fee_enabled_channels\"", (gogoproto.nullable) = false]; - repeated RegisteredRelayerAddress registered_relayers = 3 [(gogoproto.moretags) = "yaml:\"registered_relayers\"", (gogoproto.nullable) = false]; - repeated ForwardRelayerAddress forward_relayers = 4 [(gogoproto.moretags) = "yaml:\"forward_relayers\"", (gogoproto.nullable) = false]; + repeated FeeEnabledChannel fee_enabled_channels = 2 + [(gogoproto.moretags) = "yaml:\"fee_enabled_channels\"", (gogoproto.nullable) = false]; + repeated RegisteredRelayerAddress registered_relayers = 3 + [(gogoproto.moretags) = "yaml:\"registered_relayers\"", (gogoproto.nullable) = false]; + repeated ForwardRelayerAddress forward_relayers = 4 + [(gogoproto.moretags) = "yaml:\"forward_relayers\"", (gogoproto.nullable) = false]; } // FeeEnabledChannel contains the PortID & ChannelID for a fee enabled channel @@ -27,7 +30,7 @@ message FeeEnabledChannel { message RegisteredRelayerAddress { string address = 1; string counterparty_address = 2 [(gogoproto.moretags) = "yaml:\"counterparty_address\""]; - string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""]; + string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""]; } // ForwardRelayerAddress contains the forward relayer address and packetId used for async acknowledgements diff --git a/proto/ibc/applications/fee/v1/query.proto b/proto/ibc/applications/fee/v1/query.proto index 47db939a512..4fe3c8befa3 100644 --- a/proto/ibc/applications/fee/v1/query.proto +++ b/proto/ibc/applications/fee/v1/query.proto @@ -24,6 +24,12 @@ service Query { "/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/" "{packet_id.sequence}"; } + + // Gets all incentivized packets for a specific channel + rpc IncentivizedPacketsForChannel(QueryIncentivizedPacketsForChannelRequest) + returns (QueryIncentivizedPacketsForChannelResponse) { + option (google.api.http).get = "/ibc/apps/fee/v1/incentivized_packets/{port_id}/{channel_id}"; + } } // QueryIncentivizedPacketsRequest is the request type for querying for all incentivized packets @@ -53,3 +59,20 @@ message QueryIncentivizedPacketResponse { // Incentivized_packet ibc.applications.fee.v1.IdentifiedPacketFee incentivized_packet = 1; } + +// QueryIncentivizedPacketsForChannelRequest is the request type for querying for all incentivized packets +// for a specific channel +message QueryIncentivizedPacketsForChannelRequest { + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; + string port_id = 2; + string channel_id = 3; + // Height to query at + uint64 query_height = 4; +} + +// QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC +message QueryIncentivizedPacketsForChannelResponse { + // Map of all incentivized_packets + repeated ibc.applications.fee.v1.IdentifiedPacketFee incentivized_packets = 1; +} diff --git a/proto/ibc/applications/fee/v1/tx.proto b/proto/ibc/applications/fee/v1/tx.proto index 532524cd4b2..8209e14d531 100644 --- a/proto/ibc/applications/fee/v1/tx.proto +++ b/proto/ibc/applications/fee/v1/tx.proto @@ -32,7 +32,7 @@ message MsgRegisterCounterpartyAddress { string address = 1; string counterparty_address = 2 [(gogoproto.moretags) = "yaml:\"counterparty_address\""]; - string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""]; + string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""]; } // MsgRegisterCounterpartyAddressResponse defines the Msg/RegisterCounterypartyAddress response type From c9bdaf67e27bb6a96dd07e5c428adcd7c5d9cd71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 23 Feb 2022 13:21:23 +0100 Subject: [PATCH 02/11] feat: add gRPC for querying incentivized packets for a specific channel --- modules/apps/29-fee/keeper/grpc_query.go | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/modules/apps/29-fee/keeper/grpc_query.go b/modules/apps/29-fee/keeper/grpc_query.go index 1dae09d9265..343a0b0fe15 100644 --- a/modules/apps/29-fee/keeper/grpc_query.go +++ b/modules/apps/29-fee/keeper/grpc_query.go @@ -2,6 +2,8 @@ package keeper import ( "context" + "strconv" + "strings" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -12,6 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ) var _ types.QueryServer = Keeper{} @@ -63,3 +66,38 @@ func (k Keeper) IncentivizedPacket(c context.Context, req *types.QueryIncentiviz IncentivizedPacket: &fee, }, nil } + +// IncentivizedPacketsForChannel implements the IncentivizedPacketsForChannel gRPC method +func (k Keeper) IncentivizedPacketsForChannel(c context.Context, req *types.QueryIncentivizedPacketsForChannelRequest) (*types.QueryIncentivizedPacketsForChannelResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(c).WithBlockHeight(int64(req.QueryHeight)) + + var packets []*types.IdentifiedPacketFee + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyFeeInEscrowChannelPrefix(req.PortId, req.ChannelId)) + _, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { + keySplit := strings.Split(string(key), "/") + seq, err := strconv.ParseUint(keySplit[3], 10, 64) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + packetID := channeltypes.NewPacketId(req.ChannelId, req.PortId, seq) + + packetFees := k.MustUnmarshalFees(value) + identifiedPacketFees := types.NewIdentifiedPacketFees(packetID, packetFees) + packets = append(packets, &identifiedPacketFees) + return nil + }) + + if err != nil { + return nil, status.Error( + codes.NotFound, err.Error(), + ) + } + + return &types.QueryIncentivizedPacketsForChannelResponse{ + IncentivizedPackets: packets, + }, nil +} From 5365bee7cc7f2b03fbe4303d92da441de7e4d4dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 23 Feb 2022 13:34:15 +0100 Subject: [PATCH 03/11] test: add gRPC test for incentivized packets for channel query --- modules/apps/29-fee/keeper/grpc_query_test.go | 107 +++++++++++++++++- 1 file changed, 106 insertions(+), 1 deletion(-) diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index 649ff89e6b9..44de3f0a51b 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -11,7 +11,7 @@ import ( ibctesting "github.com/cosmos/ibc-go/v3/testing" ) -func (suite *KeeperTestSuite) TestQueryIncentivizedPacketI() { +func (suite *KeeperTestSuite) TestQueryIncentivizedPacket() { var ( req *types.QueryIncentivizedPacketRequest @@ -157,3 +157,108 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() { }) } } + +func (suite *KeeperTestSuite) TestQueryIncentivizedPacketsForChannel() { + var ( + req *types.QueryIncentivizedPacketsForChannelRequest + expPackets []*types.IdentifiedPacketFees + ) + + fee := types.Fee{ + AckFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, + RecvFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, + TimeoutFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, + } + + testCases := []struct { + msg string + malleate func() + expPass bool + }{ + { + "empty pagination", + func() { + req = &types.QueryIncentivizedPacketsForChannelRequest{} + }, + true, + }, + { + "success", + func() { + refundAcc := suite.chainA.SenderAccount.GetAddress() + packetFee := types.NewPacketFee(fee, refundAcc.String(), []string{}) + packetFees := types.NewPacketFees([]types.PacketFee{packetFee, packetFee, packetFee}) + + expPackets = make([]*types.IdentifiedPacketFees, 3) + expPackets[0] = types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1), packetFees) + expPackets[1] = types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 2), packetFees) + expPackets[2] = types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 3), packetFees) + + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) + for _, identifiedPacketFees := range expPackets { + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), identifiedPacketFee.PacketId, identifiedPacketFees.PacketFees) + } + + req = &types.QueryIncentivizedPacketsForChannelRequest{ + Pagination: &query.PageRequest{ + Limit: 5, + CountTotal: false, + }, + PortId: ibctesting.MockFeePort, + ChannelId: ibctesting.FirstChannelID, + QueryHeight: 0, + } + }, + true, + }, + { + "no packets for specified channel", + func() { + // set packets on channel-0 + // query with channel-10 + refundAcc := suite.chainA.SenderAccount.GetAddress() + packetFee := types.NewPacketFee(fee, refundAcc.String(), []string{}) + packetFees := types.NewPacketFees([]types.PacketFee{packetFee, packetFee, packetFee}) + + packets := make([]*types.IdentifiedPacketFees, 3) + packets[0] = types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1), packetFees) + packets[1] = types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 2), packetFees) + packets[2] = types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 3), packetFees) + + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) + for _, identifiedPacketFees := range packets { + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), identifiedPacketFee.PacketId, identifiedPacketFees.PacketFees) + } + + req = &types.QueryIncentivizedPacketsForChannelRequest{ + Pagination: &query.PageRequest{ + Limit: 5, + CountTotal: false, + }, + PortId: ibctesting.MockFeePort, + ChannelId: "channel-10", + QueryHeight: 0, + } + }, + true, + }, + } + + for _, tc := range testCases { + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + suite.SetupTest() // reset + tc.malleate() + ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) + + res, err := suite.queryClient.IncentivizedPacketsForChannel(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expPackets, res.IncentivizedPackets) + } else { + suite.Require().Error(err) + } + }) + } +} From b0a77455bf6eafc5d99d0cc5c8bffadef1a96e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 23 Feb 2022 17:15:56 +0100 Subject: [PATCH 04/11] fix build --- docs/ibc/proto-docs.md | 2 +- modules/apps/29-fee/keeper/grpc_query.go | 12 ++- modules/apps/29-fee/keeper/grpc_query_test.go | 34 ++++--- modules/apps/29-fee/types/fee.go | 10 ++ modules/apps/29-fee/types/query.pb.go | 91 ++++++++++--------- proto/ibc/applications/fee/v1/query.proto | 2 +- 6 files changed, 85 insertions(+), 66 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index db41f9ebbe5..2ef3194a4b1 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -982,7 +982,7 @@ QueryIncentivizedPacketsResponse is the response type for the incentivized packe | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `incentivized_packets` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | repeated | Map of all incentivized_packets | +| `incentivized_packets` | [IdentifiedPacketFees](#ibc.applications.fee.v1.IdentifiedPacketFees) | repeated | Map of all incentivized_packets | diff --git a/modules/apps/29-fee/keeper/grpc_query.go b/modules/apps/29-fee/keeper/grpc_query.go index 343a0b0fe15..58b4a8c520e 100644 --- a/modules/apps/29-fee/keeper/grpc_query.go +++ b/modules/apps/29-fee/keeper/grpc_query.go @@ -75,19 +75,23 @@ func (k Keeper) IncentivizedPacketsForChannel(c context.Context, req *types.Quer ctx := sdk.UnwrapSDKContext(c).WithBlockHeight(int64(req.QueryHeight)) - var packets []*types.IdentifiedPacketFee + var packets []*types.IdentifiedPacketFees store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyFeeInEscrowChannelPrefix(req.PortId, req.ChannelId)) _, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { + keySplit := strings.Split(string(key), "/") seq, err := strconv.ParseUint(keySplit[3], 10, 64) if err != nil { - return nil, status.Error(codes.Internal, err.Error()) + return status.Error(codes.Internal, err.Error()) } - packetID := channeltypes.NewPacketId(req.ChannelId, req.PortId, seq) + packetID := channeltypes.NewPacketId(req.ChannelId, req.PortId, seq) packetFees := k.MustUnmarshalFees(value) - identifiedPacketFees := types.NewIdentifiedPacketFees(packetID, packetFees) + + identifiedPacketFees := types.NewIdentifiedPacketFees(packetID, packetFees.PacketFees) + packets = append(packets, &identifiedPacketFees) + return nil }) diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index 44de3f0a51b..0b5b9dc1df6 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -160,8 +160,8 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() { func (suite *KeeperTestSuite) TestQueryIncentivizedPacketsForChannel() { var ( - req *types.QueryIncentivizedPacketsForChannelRequest - expPackets []*types.IdentifiedPacketFees + req *types.QueryIncentivizedPacketsForChannelRequest + expIdentifiedPacketFees []*types.IdentifiedPacketFees ) fee := types.Fee{ @@ -189,14 +189,16 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketsForChannel() { packetFee := types.NewPacketFee(fee, refundAcc.String(), []string{}) packetFees := types.NewPacketFees([]types.PacketFee{packetFee, packetFee, packetFee}) - expPackets = make([]*types.IdentifiedPacketFees, 3) - expPackets[0] = types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1), packetFees) - expPackets[1] = types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 2), packetFees) - expPackets[2] = types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 3), packetFees) + expIdentifiedPacketFees = make([]*types.IdentifiedPacketFees, 3) + identifiedFees1 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1), packetFees.PacketFees) + identifiedFees2 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 2), packetFees.PacketFees) + identifiedFees3 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 3), packetFees.PacketFees) + + expIdentifiedPacketFees = append(expIdentifiedPacketFees, &identifiedFees1, &identifiedFees2, &identifiedFees3) suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) - for _, identifiedPacketFees := range expPackets { - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), identifiedPacketFee.PacketId, identifiedPacketFees.PacketFees) + for _, identifiedPacketFees := range expIdentifiedPacketFees { + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), identifiedPacketFees.PacketId, types.NewPacketFees(identifiedPacketFees.PacketFees)) } req = &types.QueryIncentivizedPacketsForChannelRequest{ @@ -220,14 +222,16 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketsForChannel() { packetFee := types.NewPacketFee(fee, refundAcc.String(), []string{}) packetFees := types.NewPacketFees([]types.PacketFee{packetFee, packetFee, packetFee}) - packets := make([]*types.IdentifiedPacketFees, 3) - packets[0] = types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1), packetFees) - packets[1] = types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 2), packetFees) - packets[2] = types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 3), packetFees) + identifiedFees := make([]*types.IdentifiedPacketFees, 3) + identifiedFees1 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1), packetFees.PacketFees) + identifiedFees2 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 2), packetFees.PacketFees) + identifiedFees3 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 3), packetFees.PacketFees) + + identifiedFees = append(identifiedFees, &identifiedFees1, &identifiedFees2, &identifiedFees3) suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) - for _, identifiedPacketFees := range packets { - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), identifiedPacketFee.PacketId, identifiedPacketFees.PacketFees) + for _, identifiedPacketFees := range identifiedFees { + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), identifiedPacketFees.PacketId, types.NewPacketFees(identifiedPacketFees.PacketFees)) } req = &types.QueryIncentivizedPacketsForChannelRequest{ @@ -255,7 +259,7 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketsForChannel() { if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) - suite.Require().Equal(expPackets, res.IncentivizedPackets) + suite.Require().Equal(expIdentifiedPacketFees, res.IncentivizedPackets) } else { suite.Require().Error(err) } diff --git a/modules/apps/29-fee/types/fee.go b/modules/apps/29-fee/types/fee.go index 4dd73893888..3e8c7c5b322 100644 --- a/modules/apps/29-fee/types/fee.go +++ b/modules/apps/29-fee/types/fee.go @@ -5,6 +5,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ) // NewPacketFee creates and returns a new PacketFee struct including the incentivization fees, refund addres and relayers @@ -80,3 +82,11 @@ func (fee Fee) Validate() error { return nil } + +// NewIdentifiedPacketFees returns a IdentifiedPacketFees struct +func NewIdentifiedPacketFees(packetID channeltypes.PacketId, packetFees []PacketFee) IdentifiedPacketFees { + return IdentifiedPacketFees{ + PacketId: packetID, + PacketFees: packetFees, + } +} diff --git a/modules/apps/29-fee/types/query.pb.go b/modules/apps/29-fee/types/query.pb.go index fb5699e2b05..88d529e0f76 100644 --- a/modules/apps/29-fee/types/query.pb.go +++ b/modules/apps/29-fee/types/query.pb.go @@ -312,7 +312,7 @@ func (m *QueryIncentivizedPacketsForChannelRequest) GetQueryHeight() uint64 { // QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC type QueryIncentivizedPacketsForChannelResponse struct { // Map of all incentivized_packets - IncentivizedPackets []*IdentifiedPacketFee `protobuf:"bytes,1,rep,name=incentivized_packets,json=incentivizedPackets,proto3" json:"incentivized_packets,omitempty"` + IncentivizedPackets []*IdentifiedPacketFees `protobuf:"bytes,1,rep,name=incentivized_packets,json=incentivizedPackets,proto3" json:"incentivized_packets,omitempty"` } func (m *QueryIncentivizedPacketsForChannelResponse) Reset() { @@ -352,7 +352,7 @@ func (m *QueryIncentivizedPacketsForChannelResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryIncentivizedPacketsForChannelResponse proto.InternalMessageInfo -func (m *QueryIncentivizedPacketsForChannelResponse) GetIncentivizedPackets() []*IdentifiedPacketFee { +func (m *QueryIncentivizedPacketsForChannelResponse) GetIncentivizedPackets() []*IdentifiedPacketFees { if m != nil { return m.IncentivizedPackets } @@ -373,48 +373,49 @@ func init() { } var fileDescriptor_0638a8a78ca2503c = []byte{ - // 652 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x95, 0xcd, 0x6b, 0x13, 0x4f, - 0x18, 0xc7, 0x33, 0x7d, 0xfb, 0xfd, 0x3a, 0xf5, 0x34, 0x2d, 0x34, 0x04, 0xb3, 0x4d, 0x23, 0x6a, - 0x2c, 0x66, 0x86, 0xa4, 0x88, 0x2d, 0x88, 0x48, 0x2a, 0xc1, 0x9c, 0xac, 0x7b, 0x14, 0x24, 0xec, - 0xcb, 0x64, 0x33, 0x98, 0xec, 0x6c, 0xb3, 0x9b, 0x85, 0x36, 0x06, 0xa4, 0xe2, 0xad, 0x82, 0xe0, - 0x5f, 0xe3, 0xd9, 0x4b, 0x4f, 0x52, 0xf0, 0xe2, 0x49, 0x24, 0xf1, 0xec, 0xdf, 0x20, 0x33, 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, - 0x96, 0xf7, 0x8b, 0xa2, 0x72, 0x70, 0xec, 0x51, 0xdf, 0x5c, 0x91, 0xcf, 0xd3, 0xee, 0x8f, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x5f, 0x15, 0x2f, 0x04, 0x84, 0x07, 0x00, 0x00, + // 659 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x4d, 0x6b, 0x13, 0x41, + 0x18, 0xc7, 0x33, 0x7d, 0xd3, 0x4e, 0x3d, 0x4d, 0x0b, 0x2d, 0xc1, 0x6e, 0xd3, 0x88, 0x5a, 0x8b, + 0x99, 0x21, 0x29, 0x62, 0x0b, 0x22, 0xd2, 0x4a, 0x31, 0x27, 0xeb, 0x1e, 0x05, 0x89, 0xfb, 0x32, + 0xd9, 0x0c, 0x26, 0x3b, 0xdb, 0xcc, 0x66, 0xa1, 0x8d, 0x01, 0xa9, 0x78, 0x2b, 0x22, 0xf8, 0x69, + 0x3c, 0x7b, 0xe9, 0x49, 0x0a, 0x5e, 0x3c, 0x89, 0x24, 0x9e, 0xfd, 0x0c, 0x32, 0xb3, 0x93, 0x74, + 0x21, 0xd9, 0x9a, 0xa8, 0xb7, 0xdd, 0x79, 0xde, 0xfe, 0xf3, 0x7b, 0x9e, 0x99, 0x81, 0x37, 0x98, + 0xed, 0x10, 0x2b, 0x08, 0xea, 0xcc, 0xb1, 0x42, 0xc6, 0x7d, 0x41, 0xaa, 0x94, 0x92, 0xa8, 0x48, + 0x0e, 0x5b, 0xb4, 0x79, 0x84, 0x83, 0x26, 0x0f, 0x39, 0x5a, 0x66, 0xb6, 0x83, 0x93, 0x4e, 0xb8, + 0x4a, 0x29, 0x8e, 0x8a, 0xd9, 0x25, 0x8f, 0x7b, 0x5c, 0xf9, 0x10, 0xf9, 0x15, 0xbb, 0x67, 0xd7, + 0xd3, 0x72, 0xca, 0xa8, 0xd8, 0xe5, 0xba, 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0xa3, 0xe3, 0x71, 0x94, 0x13, 0x39, 0x58, 0xa4, 0x3d, 0x38, 0xcb, 0x58, 0xcf, + 0x5d, 0x67, 0x70, 0xbd, 0x26, 0x6c, 0x17, 0xa3, 0xd7, 0x21, 0x42, 0x0a, 0xf5, 0x1d, 0x9a, 0xb4, + 0xf7, 0xd7, 0x3a, 0xe8, 0x17, 0x80, 0xab, 0x97, 0x0e, 0x18, 0xda, 0x9d, 0xb8, 0x35, 0x43, 0xc7, + 0x2d, 0xbb, 0xf7, 0x4f, 0x39, 0x34, 0xaf, 0xc7, 0x0a, 0xd7, 0x43, 0xf4, 0x60, 0xac, 0x46, 0x93, + 0xf6, 0x00, 0x50, 0x3b, 0x81, 0x63, 0xf7, 0xe9, 0x59, 0xd7, 0x00, 0xe7, 0x5d, 0x03, 0xfc, 0xe8, + 0x1a, 0xe0, 0x43, 0xcf, 0xc8, 0x9c, 0xf7, 0x8c, 0xcc, 0xb7, 0x9e, 0x91, 0x79, 0x7e, 0xcf, 0x63, + 0x61, 0xad, 0x65, 0x63, 0x87, 0x37, 0x88, 0x7e, 0x98, 0x98, 0xed, 0x14, 0x3c, 0x4e, 0xa2, 0x2d, + 0xd2, 0xe0, 0x6e, 0xab, 0x4e, 0x45, 0x5c, 0xb6, 0xb4, 0x53, 0x90, 0x95, 0xc3, 0xa3, 0x80, 0x0a, + 0x7b, 0x4e, 0xbd, 0x4f, 0x5b, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xde, 0xc9, 0xc0, 0x33, 0x85, + 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1536,7 +1537,7 @@ func (m *QueryIncentivizedPacketsForChannelResponse) Unmarshal(dAtA []byte) erro if postIndex > l { return io.ErrUnexpectedEOF } - m.IncentivizedPackets = append(m.IncentivizedPackets, &IdentifiedPacketFee{}) + m.IncentivizedPackets = append(m.IncentivizedPackets, &IdentifiedPacketFees{}) if err := m.IncentivizedPackets[len(m.IncentivizedPackets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/proto/ibc/applications/fee/v1/query.proto b/proto/ibc/applications/fee/v1/query.proto index 4fe3c8befa3..618ec591ef9 100644 --- a/proto/ibc/applications/fee/v1/query.proto +++ b/proto/ibc/applications/fee/v1/query.proto @@ -74,5 +74,5 @@ message QueryIncentivizedPacketsForChannelRequest { // QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC message QueryIncentivizedPacketsForChannelResponse { // Map of all incentivized_packets - repeated ibc.applications.fee.v1.IdentifiedPacketFee incentivized_packets = 1; + repeated ibc.applications.fee.v1.IdentifiedPacketFees incentivized_packets = 1; } From ac019da7b436b788e9b5c2cf950e5590f0ee1494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 24 Feb 2022 12:14:51 +0100 Subject: [PATCH 05/11] partially fix tests --- modules/apps/29-fee/keeper/grpc_query.go | 4 ++-- modules/apps/29-fee/keeper/grpc_query_test.go | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/apps/29-fee/keeper/grpc_query.go b/modules/apps/29-fee/keeper/grpc_query.go index 58b4a8c520e..2f110973ade 100644 --- a/modules/apps/29-fee/keeper/grpc_query.go +++ b/modules/apps/29-fee/keeper/grpc_query.go @@ -76,11 +76,11 @@ func (k Keeper) IncentivizedPacketsForChannel(c context.Context, req *types.Quer ctx := sdk.UnwrapSDKContext(c).WithBlockHeight(int64(req.QueryHeight)) var packets []*types.IdentifiedPacketFees - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyFeeInEscrowChannelPrefix(req.PortId, req.ChannelId)) + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyFeesInEscrowChannelPrefix(req.PortId, req.ChannelId)) _, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { keySplit := strings.Split(string(key), "/") - seq, err := strconv.ParseUint(keySplit[3], 10, 64) + seq, err := strconv.ParseUint(keySplit[1], 10, 64) if err != nil { return status.Error(codes.Internal, err.Error()) } diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index 0b5b9dc1df6..f61883c1f7b 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -189,7 +189,6 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketsForChannel() { packetFee := types.NewPacketFee(fee, refundAcc.String(), []string{}) packetFees := types.NewPacketFees([]types.PacketFee{packetFee, packetFee, packetFee}) - expIdentifiedPacketFees = make([]*types.IdentifiedPacketFees, 3) identifiedFees1 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1), packetFees.PacketFees) identifiedFees2 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 2), packetFees.PacketFees) identifiedFees3 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 3), packetFees.PacketFees) @@ -222,7 +221,7 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketsForChannel() { packetFee := types.NewPacketFee(fee, refundAcc.String(), []string{}) packetFees := types.NewPacketFees([]types.PacketFee{packetFee, packetFee, packetFee}) - identifiedFees := make([]*types.IdentifiedPacketFees, 3) + var identifiedFees []*types.IdentifiedPacketFees identifiedFees1 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1), packetFees.PacketFees) identifiedFees2 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 2), packetFees.PacketFees) identifiedFees3 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 3), packetFees.PacketFees) From 53c94d7554051625fd84783e20ea6b1170c23375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 24 Feb 2022 13:09:41 +0100 Subject: [PATCH 06/11] chore: fix tests --- modules/apps/29-fee/keeper/grpc_query.go | 15 ++++++--------- modules/apps/29-fee/keeper/grpc_query_test.go | 8 +++++--- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/modules/apps/29-fee/keeper/grpc_query.go b/modules/apps/29-fee/keeper/grpc_query.go index 2f110973ade..e8fdb623ac7 100644 --- a/modules/apps/29-fee/keeper/grpc_query.go +++ b/modules/apps/29-fee/keeper/grpc_query.go @@ -3,15 +3,13 @@ package keeper import ( "context" "strconv" - "strings" - - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" @@ -76,13 +74,12 @@ func (k Keeper) IncentivizedPacketsForChannel(c context.Context, req *types.Quer ctx := sdk.UnwrapSDKContext(c).WithBlockHeight(int64(req.QueryHeight)) var packets []*types.IdentifiedPacketFees - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyFeesInEscrowChannelPrefix(req.PortId, req.ChannelId)) + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(string(types.KeyFeesInEscrowChannelPrefix(req.PortId, req.ChannelId))+"/")) _, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { - - keySplit := strings.Split(string(key), "/") - seq, err := strconv.ParseUint(keySplit[1], 10, 64) + // the key returned only includes the sequence + seq, err := strconv.ParseUint(string(key), 10, 64) if err != nil { - return status.Error(codes.Internal, err.Error()) + return err } packetID := channeltypes.NewPacketId(req.ChannelId, req.PortId, seq) diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index f61883c1f7b..328b281c57c 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -186,7 +186,7 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketsForChannel() { "success", func() { refundAcc := suite.chainA.SenderAccount.GetAddress() - packetFee := types.NewPacketFee(fee, refundAcc.String(), []string{}) + packetFee := types.NewPacketFee(fee, refundAcc.String(), nil) packetFees := types.NewPacketFees([]types.PacketFee{packetFee, packetFee, packetFee}) identifiedFees1 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1), packetFees.PacketFees) @@ -218,7 +218,7 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketsForChannel() { // set packets on channel-0 // query with channel-10 refundAcc := suite.chainA.SenderAccount.GetAddress() - packetFee := types.NewPacketFee(fee, refundAcc.String(), []string{}) + packetFee := types.NewPacketFee(fee, refundAcc.String(), nil) packetFees := types.NewPacketFees([]types.PacketFee{packetFee, packetFee, packetFee}) var identifiedFees []*types.IdentifiedPacketFees @@ -249,7 +249,9 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketsForChannel() { for _, tc := range testCases { suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.SetupTest() // reset + suite.SetupTest() // reset + expIdentifiedPacketFees = nil // reset + tc.malleate() ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) From 6107fd4c6222850d5771998f2e59db4138c16684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 24 Feb 2022 13:15:45 +0100 Subject: [PATCH 07/11] deduplicate code --- modules/apps/29-fee/keeper/grpc_query_test.go | 54 +++++++------------ 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index 328b281c57c..a861c3e257e 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -178,6 +178,7 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketsForChannel() { { "empty pagination", func() { + expIdentifiedPacketFees = nil req = &types.QueryIncentivizedPacketsForChannelRequest{} }, true, @@ -185,21 +186,6 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketsForChannel() { { "success", func() { - refundAcc := suite.chainA.SenderAccount.GetAddress() - packetFee := types.NewPacketFee(fee, refundAcc.String(), nil) - packetFees := types.NewPacketFees([]types.PacketFee{packetFee, packetFee, packetFee}) - - identifiedFees1 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1), packetFees.PacketFees) - identifiedFees2 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 2), packetFees.PacketFees) - identifiedFees3 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 3), packetFees.PacketFees) - - expIdentifiedPacketFees = append(expIdentifiedPacketFees, &identifiedFees1, &identifiedFees2, &identifiedFees3) - - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) - for _, identifiedPacketFees := range expIdentifiedPacketFees { - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), identifiedPacketFees.PacketId, types.NewPacketFees(identifiedPacketFees.PacketFees)) - } - req = &types.QueryIncentivizedPacketsForChannelRequest{ Pagination: &query.PageRequest{ Limit: 5, @@ -215,24 +201,7 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketsForChannel() { { "no packets for specified channel", func() { - // set packets on channel-0 - // query with channel-10 - refundAcc := suite.chainA.SenderAccount.GetAddress() - packetFee := types.NewPacketFee(fee, refundAcc.String(), nil) - packetFees := types.NewPacketFees([]types.PacketFee{packetFee, packetFee, packetFee}) - - var identifiedFees []*types.IdentifiedPacketFees - identifiedFees1 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1), packetFees.PacketFees) - identifiedFees2 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 2), packetFees.PacketFees) - identifiedFees3 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 3), packetFees.PacketFees) - - identifiedFees = append(identifiedFees, &identifiedFees1, &identifiedFees2, &identifiedFees3) - - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) - for _, identifiedPacketFees := range identifiedFees { - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), identifiedPacketFees.PacketId, types.NewPacketFees(identifiedPacketFees.PacketFees)) - } - + expIdentifiedPacketFees = nil req = &types.QueryIncentivizedPacketsForChannelRequest{ Pagination: &query.PageRequest{ Limit: 5, @@ -249,8 +218,23 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketsForChannel() { for _, tc := range testCases { suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.SetupTest() // reset - expIdentifiedPacketFees = nil // reset + suite.SetupTest() // reset + + // setup + refundAcc := suite.chainA.SenderAccount.GetAddress() + packetFee := types.NewPacketFee(fee, refundAcc.String(), nil) + packetFees := types.NewPacketFees([]types.PacketFee{packetFee, packetFee, packetFee}) + + identifiedFees1 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1), packetFees.PacketFees) + identifiedFees2 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 2), packetFees.PacketFees) + identifiedFees3 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 3), packetFees.PacketFees) + + expIdentifiedPacketFees = append(expIdentifiedPacketFees, &identifiedFees1, &identifiedFees2, &identifiedFees3) + + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) + for _, identifiedPacketFees := range expIdentifiedPacketFees { + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), identifiedPacketFees.PacketId, types.NewPacketFees(identifiedPacketFees.PacketFees)) + } tc.malleate() ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) From 11181f9a74fe581696c9707e310ba2964777fa46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Mon, 28 Feb 2022 13:15:35 +0100 Subject: [PATCH 08/11] chore: code cleanup --- modules/apps/29-fee/keeper/grpc_query.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/modules/apps/29-fee/keeper/grpc_query.go b/modules/apps/29-fee/keeper/grpc_query.go index fb156be1c58..c3709aa6c40 100644 --- a/modules/apps/29-fee/keeper/grpc_query.go +++ b/modules/apps/29-fee/keeper/grpc_query.go @@ -76,28 +76,24 @@ func (k Keeper) IncentivizedPacketsForChannel(c context.Context, req *types.Quer ctx := sdk.UnwrapSDKContext(c).WithBlockHeight(int64(req.QueryHeight)) var packets []*types.IdentifiedPacketFees - store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(string(types.KeyFeesInEscrowChannelPrefix(req.PortId, req.ChannelId))+"/")) + keyPrefix := types.KeyFeesInEscrowChannelPrefix(req.PortId, req.ChannelId) + store := prefix.NewStore(ctx.KVStore(k.storeKey), keyPrefix) _, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { - // the key returned only includes the sequence - seq, err := strconv.ParseUint(string(key), 10, 64) + packetID, err := types.ParseKeyFeesInEscrow(string(keyPrefix) + string(key)) if err != nil { return err } - packetID := channeltypes.NewPacketId(req.ChannelId, req.PortId, seq) packetFees := k.MustUnmarshalFees(value) identifiedPacketFees := types.NewIdentifiedPacketFees(packetID, packetFees.PacketFees) - packets = append(packets, &identifiedPacketFees) return nil }) if err != nil { - return nil, status.Error( - codes.NotFound, err.Error(), - ) + return nil, status.Error(codes.NotFound, err.Error()) } return &types.QueryIncentivizedPacketsForChannelResponse{ From e7eb430083a59e8863f0ea0622aee474178b33a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Mon, 28 Feb 2022 13:16:55 +0100 Subject: [PATCH 09/11] fix build --- modules/apps/29-fee/keeper/grpc_query.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/apps/29-fee/keeper/grpc_query.go b/modules/apps/29-fee/keeper/grpc_query.go index c3709aa6c40..44c9eb312c2 100644 --- a/modules/apps/29-fee/keeper/grpc_query.go +++ b/modules/apps/29-fee/keeper/grpc_query.go @@ -2,7 +2,6 @@ package keeper import ( "context" - "strconv" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" @@ -12,7 +11,6 @@ import ( "google.golang.org/grpc/status" "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" - channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ) var _ types.QueryServer = Keeper{} From 16fddb24ae0a7b0d3bd57efc38b68c2a5d76aec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 2 Mar 2022 16:23:33 +0100 Subject: [PATCH 10/11] remove changes from merge conflict --- modules/apps/29-fee/keeper/grpc_query_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index 04bff70c76f..4bd55b92903 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -246,7 +246,6 @@ func (suite *KeeperTestSuite) TestQueryTotalRecvFees() { expPass bool }{ { - "success", func() {}, true, @@ -285,6 +284,7 @@ func (suite *KeeperTestSuite) TestQueryTotalRecvFees() { ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) res, err := suite.queryClient.TotalRecvFees(ctx, req) + if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) From 4ee008ded164c118b488fd7cfb3ba087650e410e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 2 Mar 2022 16:24:39 +0100 Subject: [PATCH 11/11] nit: rename c to goCtx --- modules/apps/29-fee/keeper/grpc_query.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/apps/29-fee/keeper/grpc_query.go b/modules/apps/29-fee/keeper/grpc_query.go index b91f445de22..68f2cb332ca 100644 --- a/modules/apps/29-fee/keeper/grpc_query.go +++ b/modules/apps/29-fee/keeper/grpc_query.go @@ -66,12 +66,12 @@ func (k Keeper) IncentivizedPacket(c context.Context, req *types.QueryIncentiviz } // IncentivizedPacketsForChannel implements the IncentivizedPacketsForChannel gRPC method -func (k Keeper) IncentivizedPacketsForChannel(c context.Context, req *types.QueryIncentivizedPacketsForChannelRequest) (*types.QueryIncentivizedPacketsForChannelResponse, error) { +func (k Keeper) IncentivizedPacketsForChannel(goCtx context.Context, req *types.QueryIncentivizedPacketsForChannelRequest) (*types.QueryIncentivizedPacketsForChannelResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } - ctx := sdk.UnwrapSDKContext(c).WithBlockHeight(int64(req.QueryHeight)) + ctx := sdk.UnwrapSDKContext(goCtx).WithBlockHeight(int64(req.QueryHeight)) var packets []*types.IdentifiedPacketFees keyPrefix := types.KeyFeesInEscrowChannelPrefix(req.PortId, req.ChannelId)