From 9dbe0652ea1287c8ed1e20426250f1492712dad9 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Mon, 13 Jan 2025 11:40:09 -0500 Subject: [PATCH 01/24] WIP --- x/supplier/module/autocli.go | 34 ++++++++++++++--------------- x/supplier/module/query_supplier.go | 1 + 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/x/supplier/module/autocli.go b/x/supplier/module/autocli.go index 716e3774f..5ed0b3570 100644 --- a/x/supplier/module/autocli.go +++ b/x/supplier/module/autocli.go @@ -10,24 +10,24 @@ import ( func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { return &autocliv1.ModuleOptions{ Query: &autocliv1.ServiceCommandDescriptor{ - Service: modulev1.Query_ServiceDesc.ServiceName, + Service: modulev1.Query_ServiceDesc.ServiceName, RpcCommandOptions: []*autocliv1.RpcCommandOptions{ - //{ - // RpcMethod: "Params", - // Use: "params", - // Short: "Shows the parameters of the module", - //}, - //{ - // RpcMethod: "AllSuppliers", - // Use: "list-supplier", - // Short: "List all supplier", - //}, - //{ - // RpcMethod: "Supplier", - // Use: "show-supplier [id]", - // Short: "Shows a supplier", - // PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "index"}}, - //}, + // { + // RpcMethod: "Params", + // Use: "params", + // Short: "Shows the parameters of the module", + // }, + { + RpcMethod: "AllSuppliers", + Use: "list-supplier", + Short: "List all supplier", + }, + // { + // RpcMethod: "Supplier", + // Use: "show-supplier [id]", + // Short: "Shows a supplier", + // PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "index"}}, + // }, // this line is used by ignite scaffolding # autocli/query }, }, diff --git a/x/supplier/module/query_supplier.go b/x/supplier/module/query_supplier.go index 81a18454e..7216507aa 100644 --- a/x/supplier/module/query_supplier.go +++ b/x/supplier/module/query_supplier.go @@ -8,6 +8,7 @@ import ( "github.com/pokt-network/poktroll/x/supplier/types" ) +// TODO_IMPROVE: func CmdListSuppliers() *cobra.Command { cmd := &cobra.Command{ Use: "list-supplier", From 7b785727a581534a907242267ea4a13e1d9556f1 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Mon, 13 Jan 2025 16:50:41 -0500 Subject: [PATCH 02/24] WIP --- api/poktroll/supplier/query.pulsar.go | 238 +++++++++++++----- docusaurus/docs/README.md | 2 +- .../contributing/code_review_guidelines.md | 2 +- .../contributing/poktrolld_cli_updates.md | 19 ++ .../{quickstart.md => walkthrough.md} | 4 +- .../quickstart/docker_compose_walkthrough.md | 4 +- .../operate/quickstart/gateway_cheatsheet.md | 2 +- .../operate/quickstart/service_cheatsheet.md | 2 +- .../operate/quickstart/supplier_cheatsheet.md | 2 +- .../run_a_node/full_node_walkthrough.md | 2 +- .../{install.md => poktrolld_cli.md} | 2 +- proto/poktroll/supplier/query.proto | 4 + x/supplier/module/autocli.go | 31 ++- x/supplier/module/query_supplier.go | 1 - x/supplier/types/query.pb.go | 180 ++++++++++--- 15 files changed, 388 insertions(+), 107 deletions(-) create mode 100644 docusaurus/docs/develop/contributing/poktrolld_cli_updates.md rename docusaurus/docs/develop/developer_guide/{quickstart.md => walkthrough.md} (99%) rename docusaurus/docs/operate/user_guide/{install.md => poktrolld_cli.md} (98%) diff --git a/api/poktroll/supplier/query.pulsar.go b/api/poktroll/supplier/query.pulsar.go index d1f087c62..a9f7007cb 100644 --- a/api/poktroll/supplier/query.pulsar.go +++ b/api/poktroll/supplier/query.pulsar.go @@ -1668,12 +1668,14 @@ func (x *fastReflection_QueryGetSupplierResponse) ProtoMethods() *protoiface.Met var ( md_QueryAllSuppliersRequest protoreflect.MessageDescriptor fd_QueryAllSuppliersRequest_pagination protoreflect.FieldDescriptor + fd_QueryAllSuppliersRequest_service_id protoreflect.FieldDescriptor ) func init() { file_poktroll_supplier_query_proto_init() md_QueryAllSuppliersRequest = File_poktroll_supplier_query_proto.Messages().ByName("QueryAllSuppliersRequest") fd_QueryAllSuppliersRequest_pagination = md_QueryAllSuppliersRequest.Fields().ByName("pagination") + fd_QueryAllSuppliersRequest_service_id = md_QueryAllSuppliersRequest.Fields().ByName("service_id") } var _ protoreflect.Message = (*fastReflection_QueryAllSuppliersRequest)(nil) @@ -1747,6 +1749,16 @@ func (x *fastReflection_QueryAllSuppliersRequest) Range(f func(protoreflect.Fiel return } } + if x.Filter != nil { + switch o := x.Filter.(type) { + case *QueryAllSuppliersRequest_ServiceId: + v := o.ServiceId + value := protoreflect.ValueOfString(v) + if !f(fd_QueryAllSuppliersRequest_service_id, value) { + return + } + } + } } // Has reports whether a field is populated. @@ -1764,6 +1776,14 @@ func (x *fastReflection_QueryAllSuppliersRequest) Has(fd protoreflect.FieldDescr switch fd.FullName() { case "poktroll.supplier.QueryAllSuppliersRequest.pagination": return x.Pagination != nil + case "poktroll.supplier.QueryAllSuppliersRequest.service_id": + if x.Filter == nil { + return false + } else if _, ok := x.Filter.(*QueryAllSuppliersRequest_ServiceId); ok { + return true + } else { + return false + } default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.supplier.QueryAllSuppliersRequest")) @@ -1782,6 +1802,8 @@ func (x *fastReflection_QueryAllSuppliersRequest) Clear(fd protoreflect.FieldDes switch fd.FullName() { case "poktroll.supplier.QueryAllSuppliersRequest.pagination": x.Pagination = nil + case "poktroll.supplier.QueryAllSuppliersRequest.service_id": + x.Filter = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.supplier.QueryAllSuppliersRequest")) @@ -1801,6 +1823,14 @@ func (x *fastReflection_QueryAllSuppliersRequest) Get(descriptor protoreflect.Fi case "poktroll.supplier.QueryAllSuppliersRequest.pagination": value := x.Pagination return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "poktroll.supplier.QueryAllSuppliersRequest.service_id": + if x.Filter == nil { + return protoreflect.ValueOfString("") + } else if v, ok := x.Filter.(*QueryAllSuppliersRequest_ServiceId); ok { + return protoreflect.ValueOfString(v.ServiceId) + } else { + return protoreflect.ValueOfString("") + } default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.supplier.QueryAllSuppliersRequest")) @@ -1823,6 +1853,9 @@ func (x *fastReflection_QueryAllSuppliersRequest) Set(fd protoreflect.FieldDescr switch fd.FullName() { case "poktroll.supplier.QueryAllSuppliersRequest.pagination": x.Pagination = value.Message().Interface().(*v1beta1.PageRequest) + case "poktroll.supplier.QueryAllSuppliersRequest.service_id": + cv := value.Interface().(string) + x.Filter = &QueryAllSuppliersRequest_ServiceId{ServiceId: cv} default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.supplier.QueryAllSuppliersRequest")) @@ -1848,6 +1881,8 @@ func (x *fastReflection_QueryAllSuppliersRequest) Mutable(fd protoreflect.FieldD x.Pagination = new(v1beta1.PageRequest) } return protoreflect.ValueOfMessage(x.Pagination.ProtoReflect()) + case "poktroll.supplier.QueryAllSuppliersRequest.service_id": + panic(fmt.Errorf("field service_id of message poktroll.supplier.QueryAllSuppliersRequest is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.supplier.QueryAllSuppliersRequest")) @@ -1864,6 +1899,8 @@ func (x *fastReflection_QueryAllSuppliersRequest) NewField(fd protoreflect.Field case "poktroll.supplier.QueryAllSuppliersRequest.pagination": m := new(v1beta1.PageRequest) return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "poktroll.supplier.QueryAllSuppliersRequest.service_id": + return protoreflect.ValueOfString("") default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.supplier.QueryAllSuppliersRequest")) @@ -1877,6 +1914,14 @@ func (x *fastReflection_QueryAllSuppliersRequest) NewField(fd protoreflect.Field // It panics if the oneof descriptor does not belong to this message. func (x *fastReflection_QueryAllSuppliersRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { switch d.FullName() { + case "poktroll.supplier.QueryAllSuppliersRequest.filter": + if x.Filter == nil { + return nil + } + switch x.Filter.(type) { + case *QueryAllSuppliersRequest_ServiceId: + return x.Descriptor().Fields().ByName("service_id") + } default: panic(fmt.Errorf("%s is not a oneof field in poktroll.supplier.QueryAllSuppliersRequest", d.FullName())) } @@ -1937,6 +1982,14 @@ func (x *fastReflection_QueryAllSuppliersRequest) ProtoMethods() *protoiface.Met l = options.Size(x.Pagination) n += 1 + l + runtime.Sov(uint64(l)) } + switch x := x.Filter.(type) { + case *QueryAllSuppliersRequest_ServiceId: + if x == nil { + break + } + l = len(x.ServiceId) + n += 1 + l + runtime.Sov(uint64(l)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -1966,6 +2019,14 @@ func (x *fastReflection_QueryAllSuppliersRequest) ProtoMethods() *protoiface.Met i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + switch x := x.Filter.(type) { + case *QueryAllSuppliersRequest_ServiceId: + i -= len(x.ServiceId) + copy(dAtA[i:], x.ServiceId) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ServiceId))) + i-- + dAtA[i] = 0x12 + } if x.Pagination != nil { encoded, err := options.Marshal(x.Pagination) if err != nil { @@ -2065,6 +2126,38 @@ func (x *fastReflection_QueryAllSuppliersRequest) ProtoMethods() *protoiface.Met return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ServiceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Filter = &QueryAllSuppliersRequest_ServiceId{string(dAtA[iNdEx:postIndex])} + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -2826,6 +2919,10 @@ type QueryAllSuppliersRequest struct { unknownFields protoimpl.UnknownFields Pagination *v1beta1.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` + // Types that are assignable to Filter: + // + // *QueryAllSuppliersRequest_ServiceId + Filter isQueryAllSuppliersRequest_Filter `protobuf_oneof:"filter"` } func (x *QueryAllSuppliersRequest) Reset() { @@ -2855,6 +2952,30 @@ func (x *QueryAllSuppliersRequest) GetPagination() *v1beta1.PageRequest { return nil } +func (x *QueryAllSuppliersRequest) GetFilter() isQueryAllSuppliersRequest_Filter { + if x != nil { + return x.Filter + } + return nil +} + +func (x *QueryAllSuppliersRequest) GetServiceId() string { + if x, ok := x.GetFilter().(*QueryAllSuppliersRequest_ServiceId); ok { + return x.ServiceId + } + return "" +} + +type isQueryAllSuppliersRequest_Filter interface { + isQueryAllSuppliersRequest_Filter() +} + +type QueryAllSuppliersRequest_ServiceId struct { + ServiceId string `protobuf:"bytes,2,opt,name=service_id,json=serviceId,proto3,oneof"` +} + +func (*QueryAllSuppliersRequest_ServiceId) isQueryAllSuppliersRequest_Filter() {} + type QueryAllSuppliersResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2937,65 +3058,67 @@ var file_poktroll_supplier_query_proto_rawDesc = []byte{ 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x08, 0x73, 0x75, 0x70, 0x70, - 0x6c, 0x69, 0x65, 0x72, 0x22, 0x62, 0x0a, 0x18, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, - 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x46, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, - 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x0a, 0x70, 0x61, - 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xa1, 0x01, 0x0a, 0x19, 0x51, 0x75, 0x65, - 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x08, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, - 0x65, 0x72, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x53, 0x75, 0x70, 0x70, 0x6c, - 0x69, 0x65, 0x72, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x08, 0x73, 0x75, 0x70, 0x70, 0x6c, - 0x69, 0x65, 0x72, 0x12, 0x47, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0xda, 0x03, 0x0a, - 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x87, 0x01, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x12, 0x25, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, - 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x51, 0x75, 0x65, - 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x2e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x28, 0x12, 0x26, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, - 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, - 0x2f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, - 0x12, 0xa8, 0x01, 0x0a, 0x08, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x12, 0x2a, 0x2e, + 0x6c, 0x69, 0x65, 0x72, 0x22, 0x8d, 0x01, 0x0a, 0x18, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, + 0x6c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x46, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, + 0x61, 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x0a, 0x70, + 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0a, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, + 0x09, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x42, 0x08, 0x0a, 0x06, 0x66, 0x69, + 0x6c, 0x74, 0x65, 0x72, 0x22, 0xa1, 0x01, 0x0a, 0x19, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, + 0x6c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x08, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, + 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x42, + 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x08, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x12, + 0x47, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, + 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, + 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0a, 0x70, 0x61, + 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0xda, 0x03, 0x0a, 0x05, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x12, 0x87, 0x01, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x25, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, - 0x72, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, - 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x70, 0x6f, 0x6b, 0x74, + 0x72, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, + 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2e, 0x82, 0xd3, + 0xe4, 0x93, 0x02, 0x28, 0x12, 0x26, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x75, 0x70, + 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0xa8, 0x01, 0x0a, + 0x08, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x12, 0x2a, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x43, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x3d, 0x12, 0x3b, - 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, - 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2f, - 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2f, 0x7b, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, - 0x6f, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x7d, 0x12, 0x9b, 0x01, 0x0a, 0x0c, - 0x41, 0x6c, 0x6c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x73, 0x12, 0x2b, 0x2e, 0x70, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, - 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, - 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x70, 0x6f, 0x6b, 0x74, - 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x51, 0x75, - 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x30, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2a, 0x12, - 0x28, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, - 0x2f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x42, 0xb0, 0x01, 0xd8, 0xe2, 0x1e, 0x01, - 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, - 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x22, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, - 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, - 0x2f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, - 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x75, 0x70, 0x70, 0x6c, - 0x69, 0x65, 0x72, 0xca, 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, - 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0xe2, 0x02, 0x1d, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, - 0x6c, 0x6c, 0x5c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x5c, 0x47, 0x50, 0x42, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x12, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, - 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, + 0x65, 0x74, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x43, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x3d, 0x12, 0x3b, 0x2f, 0x70, 0x6f, 0x6b, + 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x2f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2f, 0x73, 0x75, 0x70, 0x70, + 0x6c, 0x69, 0x65, 0x72, 0x2f, 0x7b, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x61, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x7d, 0x12, 0x9b, 0x01, 0x0a, 0x0c, 0x41, 0x6c, 0x6c, 0x53, + 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x73, 0x12, 0x2b, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, + 0x6c, 0x6c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x30, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2a, 0x12, 0x28, 0x2f, 0x70, 0x6f, + 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2f, 0x73, 0x75, 0x70, + 0x70, 0x6c, 0x69, 0x65, 0x72, 0x42, 0xb0, 0x01, 0xd8, 0xe2, 0x1e, 0x01, 0x0a, 0x15, 0x63, 0x6f, + 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, + 0x69, 0x65, 0x72, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, + 0x01, 0x5a, 0x22, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x75, 0x70, + 0x70, 0x6c, 0x69, 0x65, 0x72, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x11, 0x50, 0x6f, + 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0xca, + 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x75, 0x70, 0x70, 0x6c, + 0x69, 0x65, 0x72, 0xe2, 0x02, 0x1d, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, + 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0xea, 0x02, 0x12, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, + 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -3122,6 +3245,9 @@ func file_poktroll_supplier_query_proto_init() { } } } + file_poktroll_supplier_query_proto_msgTypes[4].OneofWrappers = []interface{}{ + (*QueryAllSuppliersRequest_ServiceId)(nil), + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/docusaurus/docs/README.md b/docusaurus/docs/README.md index f226dc1d4..1de7ee4d7 100644 --- a/docusaurus/docs/README.md +++ b/docusaurus/docs/README.md @@ -57,7 +57,7 @@ You can view the Shannon Roadmap on [Github](https://github.com/orgs/pokt-networ ## Quickstart -The best way to get involved is by following the [quickstart instructions](./develop/developer_guide/quickstart.md). +The best way to get involved is by following the [quickstart instructions](develop/developer_guide/walkthrough.md). ## Godoc diff --git a/docusaurus/docs/develop/contributing/code_review_guidelines.md b/docusaurus/docs/develop/contributing/code_review_guidelines.md index 287b5d5d7..41f892a97 100644 --- a/docusaurus/docs/develop/contributing/code_review_guidelines.md +++ b/docusaurus/docs/develop/contributing/code_review_guidelines.md @@ -3,7 +3,7 @@ sidebar_position: 3 title: Code Review Guidelines --- -# Code Review Guidelines +## Code Review Guidelines :::note This is a living document and will be updated as the ecosystem matures & grows. diff --git a/docusaurus/docs/develop/contributing/poktrolld_cli_updates.md b/docusaurus/docs/develop/contributing/poktrolld_cli_updates.md new file mode 100644 index 000000000..40d70285f --- /dev/null +++ b/docusaurus/docs/develop/contributing/poktrolld_cli_updates.md @@ -0,0 +1,19 @@ +--- +sidebar_position: 4 +title: CLI Updates +--- + +## CLI Update Tutorial + +You can follow this guide if you're interested in making additions +to the `poktrolld`. + +## Prerequisites + +1. You have familiar and have a functional [LocalNet](../developer_guide/walkthrough.md) +2. You are familiar with the [poktrolld CLI](../../operate/user_guide/poktrolld_cli.md) + +## + +1. Example PR +2. make ignite_poktrolld_build \ No newline at end of file diff --git a/docusaurus/docs/develop/developer_guide/quickstart.md b/docusaurus/docs/develop/developer_guide/walkthrough.md similarity index 99% rename from docusaurus/docs/develop/developer_guide/quickstart.md rename to docusaurus/docs/develop/developer_guide/walkthrough.md index a899fba64..da5f30ed3 100644 --- a/docusaurus/docs/develop/developer_guide/quickstart.md +++ b/docusaurus/docs/develop/developer_guide/walkthrough.md @@ -1,11 +1,11 @@ --- sidebar_position: 1 -title: Quickstart +title: Walkthrough --- import ReactPlayer from "react-player"; -# Quickstart +## Walkthrough :::info The goal of this document is to get you up and running with a LocalNet, some diff --git a/docusaurus/docs/operate/quickstart/docker_compose_walkthrough.md b/docusaurus/docs/operate/quickstart/docker_compose_walkthrough.md index 40e008fd1..6123e5ce8 100644 --- a/docusaurus/docs/operate/quickstart/docker_compose_walkthrough.md +++ b/docusaurus/docs/operate/quickstart/docker_compose_walkthrough.md @@ -132,7 +132,7 @@ Make sure to replace `olshansky` with your username. You can generally do everything as the `root` user, but it's recommended to create a new user and give it sudo permissions. -This is necessary, in particular, if you want to use [homebrew](https://brew.sh/) [to install `poktrolld`](../user_guide/install.md). +This is necessary, in particular, if you want to use [homebrew](https://brew.sh/) [to install `poktrolld`](../user_guide/poktrolld_cli.md). ```bash adduser poktroll @@ -190,7 +190,7 @@ sed -i -e s/NODE_HOSTNAME=/NODE_HOSTNAME=69.42.690.420/g .env You can generally do everything as the `root` user, but it's recommended to create a new user and give it sudo permissions. -This is necessary, in particular, if you want to use [homebrew](https://brew.sh/) [to install `poktrolld`](../user_guide/install.md). +This is necessary, in particular, if you want to use [homebrew](https://brew.sh/) [to install `poktrolld`](../user_guide/poktrolld_cli.md). You can create a new user (e.g. poktroll), provide sudo permissions and switch users like so: diff --git a/docusaurus/docs/operate/quickstart/gateway_cheatsheet.md b/docusaurus/docs/operate/quickstart/gateway_cheatsheet.md index 741966d13..861c2b06a 100644 --- a/docusaurus/docs/operate/quickstart/gateway_cheatsheet.md +++ b/docusaurus/docs/operate/quickstart/gateway_cheatsheet.md @@ -38,7 +38,7 @@ streamline development and reduce friction for any new potential contributor. ## Pre-Requisites -1. Make sure to [install the `poktrolld` CLI](../user_guide/install.md). +1. Make sure to [install the `poktrolld` CLI](../user_guide/poktrolld_cli.md). 2. Make sure you know how to [create and fund a new account](../user_guide/create-new-wallet.md). :::warning diff --git a/docusaurus/docs/operate/quickstart/service_cheatsheet.md b/docusaurus/docs/operate/quickstart/service_cheatsheet.md index 4e3304db5..eda5d4af5 100644 --- a/docusaurus/docs/operate/quickstart/service_cheatsheet.md +++ b/docusaurus/docs/operate/quickstart/service_cheatsheet.md @@ -14,7 +14,7 @@ title: Service Cheat Sheet ### Pre-Requisites -1. Make sure to [install the `poktrolld` CLI](../user_guide/install.md). +1. Make sure to [install the `poktrolld` CLI](../user_guide/poktrolld_cli.md). 2. Make sure you know how to [create and fund a new account](../user_guide/create-new-wallet.md). ### How do I query for all existing onchain Services? diff --git a/docusaurus/docs/operate/quickstart/supplier_cheatsheet.md b/docusaurus/docs/operate/quickstart/supplier_cheatsheet.md index 1bc9eed64..894361602 100644 --- a/docusaurus/docs/operate/quickstart/supplier_cheatsheet.md +++ b/docusaurus/docs/operate/quickstart/supplier_cheatsheet.md @@ -39,7 +39,7 @@ streamline development and reduce friction for any new potential contributor. ## Pre-Requisites -1. Make sure to [install the `poktrolld` CLI](../user_guide/install.md). +1. Make sure to [install the `poktrolld` CLI](../user_guide/poktrolld_cli.md). 2. Make sure you know how to [create and fund a new account](../user_guide/create-new-wallet.md). 3. You have either [staked a new `service` or found an existing one](./service_cheatsheet.md). 4. `[Optional]` You can run things locally or have dedicated long-running hardware. See the [Docker Compose Cheat Sheet](./docker_compose_debian_cheatsheet#deploy-your-server) if you're interested in the latter. diff --git a/docusaurus/docs/operate/run_a_node/full_node_walkthrough.md b/docusaurus/docs/operate/run_a_node/full_node_walkthrough.md index 2a19269fb..44ab1e221 100644 --- a/docusaurus/docs/operate/run_a_node/full_node_walkthrough.md +++ b/docusaurus/docs/operate/run_a_node/full_node_walkthrough.md @@ -130,7 +130,7 @@ source ~/.profile ### 5. Install `poktrolld` -Follow the instructions in the [CLI Installation Guide](../user_guide/install.md) page to install `poktrolld`. +Follow the instructions in the [CLI Installation Guide](../user_guide/poktrolld_cli.md) page to install `poktrolld`. Create a symlink of the binary so Comosvisor knows where to find it: diff --git a/docusaurus/docs/operate/user_guide/install.md b/docusaurus/docs/operate/user_guide/poktrolld_cli.md similarity index 98% rename from docusaurus/docs/operate/user_guide/install.md rename to docusaurus/docs/operate/user_guide/poktrolld_cli.md index dab4f98b2..9ca5431b9 100644 --- a/docusaurus/docs/operate/user_guide/install.md +++ b/docusaurus/docs/operate/user_guide/poktrolld_cli.md @@ -1,5 +1,5 @@ --- -title: CLI Installation +title: poktrolld CLI Installation sidebar_position: 0 --- diff --git a/proto/poktroll/supplier/query.proto b/proto/poktroll/supplier/query.proto index cb7a4d31a..bc26ac2d1 100644 --- a/proto/poktroll/supplier/query.proto +++ b/proto/poktroll/supplier/query.proto @@ -53,6 +53,10 @@ message QueryGetSupplierResponse { message QueryAllSuppliersRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1; + + oneof filter { + string service_id = 2; + } } message QueryAllSuppliersResponse { diff --git a/x/supplier/module/autocli.go b/x/supplier/module/autocli.go index 5ed0b3570..c65b4b8e0 100644 --- a/x/supplier/module/autocli.go +++ b/x/supplier/module/autocli.go @@ -6,6 +6,30 @@ import ( modulev1 "github.com/pokt-network/poktroll/api/poktroll/supplier" ) +// Query: &autocliv1.ServiceCommandDescriptor{ +// Service: modulev1.Query_ServiceDesc.ServiceName, +// RpcCommandOptions: []*autocliv1.RpcCommandOptions{ +// // { +// // RpcMethod: "Params", +// // Use: "params", +// // Short: "Shows the parameters of the module", +// // }, +// // { +// // RpcMethod: "AllServices", +// // Use: "list-service", +// // Short: "List all service", +// // }, +// { +// RpcMethod: "Service", +// Use: "show-service [id]", +// Short: "Shows a service", +// Long: "Retrieve the service details by its id.", +// PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "id"}}, +// }, +// // this line is used by ignite scaffolding # autocli/query +// }, +// }, + // AutoCLIOptions implements the autocli.HasAutoCLIConfig interface. func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { return &autocliv1.ModuleOptions{ @@ -19,8 +43,11 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { // }, { RpcMethod: "AllSuppliers", - Use: "list-supplier", - Short: "List all supplier", + Use: "list-suppliers", + Short: "List all suppliers on the Pocket Network", + Long: "Retrieves a paginated list of all suppliers currently registered on the Pocket Network, including their stakes and services.", + Example: "poktrolld query supplier list-suppliers\npoktrolld query supplier list-suppliers --page 2 --limit 50", + Alias: []string{"suppliers", "ls"}, }, // { // RpcMethod: "Supplier", diff --git a/x/supplier/module/query_supplier.go b/x/supplier/module/query_supplier.go index 7216507aa..81a18454e 100644 --- a/x/supplier/module/query_supplier.go +++ b/x/supplier/module/query_supplier.go @@ -8,7 +8,6 @@ import ( "github.com/pokt-network/poktroll/x/supplier/types" ) -// TODO_IMPROVE: func CmdListSuppliers() *cobra.Command { cmd := &cobra.Command{ Use: "list-supplier", diff --git a/x/supplier/types/query.pb.go b/x/supplier/types/query.pb.go index fc4da1c09..739fb0ef7 100644 --- a/x/supplier/types/query.pb.go +++ b/x/supplier/types/query.pb.go @@ -191,6 +191,9 @@ func (m *QueryGetSupplierResponse) GetSupplier() types.Supplier { type QueryAllSuppliersRequest struct { Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` + // Types that are valid to be assigned to Filter: + // *QueryAllSuppliersRequest_ServiceId + Filter isQueryAllSuppliersRequest_Filter `protobuf_oneof:"filter"` } func (m *QueryAllSuppliersRequest) Reset() { *m = QueryAllSuppliersRequest{} } @@ -222,6 +225,25 @@ func (m *QueryAllSuppliersRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAllSuppliersRequest proto.InternalMessageInfo +type isQueryAllSuppliersRequest_Filter interface { + isQueryAllSuppliersRequest_Filter() + MarshalTo([]byte) (int, error) + Size() int +} + +type QueryAllSuppliersRequest_ServiceId struct { + ServiceId string `protobuf:"bytes,2,opt,name=service_id,json=serviceId,proto3,oneof" json:"service_id,omitempty"` +} + +func (*QueryAllSuppliersRequest_ServiceId) isQueryAllSuppliersRequest_Filter() {} + +func (m *QueryAllSuppliersRequest) GetFilter() isQueryAllSuppliersRequest_Filter { + if m != nil { + return m.Filter + } + return nil +} + func (m *QueryAllSuppliersRequest) GetPagination() *query.PageRequest { if m != nil { return m.Pagination @@ -229,6 +251,20 @@ func (m *QueryAllSuppliersRequest) GetPagination() *query.PageRequest { return nil } +func (m *QueryAllSuppliersRequest) GetServiceId() string { + if x, ok := m.GetFilter().(*QueryAllSuppliersRequest_ServiceId); ok { + return x.ServiceId + } + return "" +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*QueryAllSuppliersRequest) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*QueryAllSuppliersRequest_ServiceId)(nil), + } +} + type QueryAllSuppliersResponse struct { Supplier []types.Supplier `protobuf:"bytes,1,rep,name=supplier,proto3" json:"supplier"` Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` @@ -289,43 +325,45 @@ func init() { func init() { proto.RegisterFile("poktroll/supplier/query.proto", fileDescriptor_7a8c18c53656bd0d) } var fileDescriptor_7a8c18c53656bd0d = []byte{ - // 567 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x31, 0x6f, 0x13, 0x31, - 0x14, 0xc7, 0xe3, 0x16, 0xa2, 0xd6, 0x20, 0x41, 0x4d, 0x24, 0x92, 0x08, 0x0e, 0x74, 0x12, 0x21, - 0x0a, 0xd4, 0x26, 0x65, 0x2c, 0x0c, 0x4d, 0x25, 0x3a, 0x52, 0x92, 0x01, 0x89, 0x81, 0xca, 0x49, - 0xac, 0xeb, 0xa9, 0x97, 0xb3, 0x6b, 0x3b, 0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, 0x32, 0x4b, 0x66, 0xeb, 0xf9, 0xf8, 0xfd, 0x8f, 0x3f, 0x9f, 0x16, 0xaa, - 0xa8, 0x42, 0x46, 0xfa, 0xd5, 0x98, 0xe9, 0xd7, 0x5c, 0xee, 0x91, 0x69, 0x5b, 0x8e, 0x0e, 0x01, - 0x5c, 0x4a, 0x5e, 0x8e, 0x6a, 0xd3, 0x8a, 0xa4, 0x57, 0xae, 0x7c, 0x6f, 0x2e, 0xad, 0xa3, 0xda, - 0x34, 0x54, 0x8f, 0xd1, 0xfa, 0x2c, 0xaa, 0xf1, 0xe1, 0xed, 0xff, 0xfb, 0xfc, 0x0e, 0x7d, 0x06, - 0xf0, 0xf2, 0xe4, 0x74, 0xd1, 0x54, 0x84, 0x8c, 0x45, 0x2b, 0xdf, 0x9f, 0x4f, 0xec, 0x80, 0x1f, - 0x18, 0xe0, 0x1a, 0xaa, 0xce, 0x0b, 0xdc, 0x78, 0x7a, 0x34, 0xf0, 0xc0, 0xf1, 0xc0, 0x03, 0x27, - 0x03, 0x0f, 0xfc, 0x1e, 0x78, 0xe0, 0xe3, 0xd0, 0xcb, 0x1d, 0x0f, 0xbd, 0xdc, 0xc9, 0xd0, 0xcb, - 0xbd, 0xa8, 0x07, 0xa1, 0xde, 0xed, 0xb7, 0x71, 0x87, 0xf7, 0xa6, 0x64, 0x7c, 0x73, 0x9a, 0x53, - 0x1f, 0x08, 0xa6, 0xda, 0x79, 0xf3, 0x07, 0xf3, 0xf0, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, - 0x67, 0x7e, 0xca, 0x82, 0x05, 0x00, 0x00, + // 602 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xb1, 0x6f, 0x13, 0x3f, + 0x18, 0x8d, 0xd3, 0xdf, 0x2f, 0x4a, 0x0c, 0x12, 0xd4, 0x44, 0x22, 0x89, 0xe0, 0x8a, 0x4e, 0x22, + 0x44, 0x81, 0xde, 0x91, 0x32, 0x16, 0x86, 0xa6, 0x12, 0x85, 0x89, 0x72, 0x19, 0x90, 0x18, 0x88, + 0x9c, 0xc4, 0x5c, 0xad, 0x5e, 0xce, 0x57, 0xdb, 0x29, 0x54, 0x88, 0x85, 0x85, 0x09, 0x09, 0x89, + 0x91, 0x89, 0xad, 0x23, 0x03, 0x7f, 0x44, 0xc7, 0x0a, 0x96, 0x8a, 0x01, 0xa1, 0x04, 0x89, 0x7f, + 0x03, 0x9d, 0xed, 0x4b, 0x53, 0x2e, 0x51, 0xc2, 0x12, 0xd9, 0xfe, 0xde, 0x7b, 0xdf, 0x7b, 0xf6, + 0x97, 0x83, 0x57, 0x23, 0xb6, 0x2b, 0x39, 0x0b, 0x02, 0x57, 0x0c, 0xa2, 0x28, 0xa0, 0x84, 0xbb, + 0x7b, 0x03, 0xc2, 0x0f, 0x9c, 0x88, 0x33, 0xc9, 0xd0, 0x72, 0x52, 0x76, 0x92, 0x72, 0x65, 0x19, + 0xf7, 0x69, 0xc8, 0x5c, 0xf5, 0xab, 0x51, 0x95, 0xa2, 0xcf, 0x7c, 0xa6, 0x96, 0x6e, 0xbc, 0x32, + 0xa7, 0x57, 0x7c, 0xc6, 0xfc, 0x80, 0xb8, 0x38, 0xa2, 0x2e, 0x0e, 0x43, 0x26, 0xb1, 0xa4, 0x2c, + 0x14, 0xa6, 0x5a, 0xee, 0x32, 0xd1, 0x67, 0xa2, 0xad, 0x69, 0x7a, 0x63, 0x4a, 0x75, 0xbd, 0x73, + 0x3b, 0x58, 0x10, 0xed, 0xc6, 0xdd, 0x6f, 0x74, 0x88, 0xc4, 0x0d, 0x37, 0xc2, 0x3e, 0x0d, 0x95, + 0x8e, 0xc1, 0x5a, 0x93, 0xd8, 0x04, 0xd5, 0x65, 0x74, 0x5c, 0x4f, 0xe7, 0x8b, 0x30, 0xc7, 0x7d, + 0x91, 0xae, 0xef, 0x60, 0x4e, 0x7a, 0x63, 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d, 0x79, 0x10, 0x11, 0xd1, 0xc9, 0xa9, 0x8f, 0xd1, 0x9d, 0x3f, 0x01, 0x00, 0x00, + 0xff, 0xff, 0xc0, 0xc9, 0xa7, 0x97, 0xae, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -623,6 +661,15 @@ func (m *QueryAllSuppliersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error _ = i var l int _ = l + if m.Filter != nil { + { + size := m.Filter.Size() + i -= size + if _, err := m.Filter.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } if m.Pagination != nil { { size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) @@ -638,6 +685,20 @@ func (m *QueryAllSuppliersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } +func (m *QueryAllSuppliersRequest_ServiceId) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllSuppliersRequest_ServiceId) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + i -= len(m.ServiceId) + copy(dAtA[i:], m.ServiceId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ServiceId))) + i-- + dAtA[i] = 0x12 + return len(dAtA) - i, nil +} func (m *QueryAllSuppliersResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -752,9 +813,22 @@ func (m *QueryAllSuppliersRequest) Size() (n int) { l = m.Pagination.Size() n += 1 + l + sovQuery(uint64(l)) } + if m.Filter != nil { + n += m.Filter.Size() + } return n } +func (m *QueryAllSuppliersRequest_ServiceId) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ServiceId) + n += 1 + l + sovQuery(uint64(l)) + return n +} func (m *QueryAllSuppliersResponse) Size() (n int) { if m == nil { return 0 @@ -1143,6 +1217,38 @@ func (m *QueryAllSuppliersRequest) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ServiceId", 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.Filter = &QueryAllSuppliersRequest_ServiceId{string(dAtA[iNdEx:postIndex])} + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) From 984cb7c5638b3ed81e980fb82ca47143e5a29714 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Mon, 13 Jan 2025 17:33:35 -0500 Subject: [PATCH 03/24] Checkpoint --- api/poktroll/supplier/query.pulsar.go | 2 +- proto/poktroll/supplier/query.proto | 2 +- x/proof/keeper/query_proof.go | 5 ++- x/proof/types/query_validation.go | 1 + x/service/keeper/query_service.go | 3 +- x/supplier/keeper/query_supplier.go | 27 +++++++++++++-- x/supplier/keeper/query_supplier_test.go | 33 +++++++++++++++++++ x/supplier/types/errors.go | 1 + x/supplier/types/query_validation.go | 42 ++++++++++++++++++++++++ 9 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 x/supplier/types/query_validation.go diff --git a/api/poktroll/supplier/query.pulsar.go b/api/poktroll/supplier/query.pulsar.go index a9f7007cb..270ce57f6 100644 --- a/api/poktroll/supplier/query.pulsar.go +++ b/api/poktroll/supplier/query.pulsar.go @@ -2971,7 +2971,7 @@ type isQueryAllSuppliersRequest_Filter interface { } type QueryAllSuppliersRequest_ServiceId struct { - ServiceId string `protobuf:"bytes,2,opt,name=service_id,json=serviceId,proto3,oneof"` + ServiceId string `protobuf:"bytes,2,opt,name=service_id,json=serviceId,proto3,oneof"` // unique service identifier to filter by } func (*QueryAllSuppliersRequest_ServiceId) isQueryAllSuppliersRequest_Filter() {} diff --git a/proto/poktroll/supplier/query.proto b/proto/poktroll/supplier/query.proto index bc26ac2d1..585d9ad07 100644 --- a/proto/poktroll/supplier/query.proto +++ b/proto/poktroll/supplier/query.proto @@ -55,7 +55,7 @@ message QueryAllSuppliersRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1; oneof filter { - string service_id = 2; + string service_id = 2; // unique service identifier to filter by } } diff --git a/x/proof/keeper/query_proof.go b/x/proof/keeper/query_proof.go index f2a84ba42..4d596f948 100644 --- a/x/proof/keeper/query_proof.go +++ b/x/proof/keeper/query_proof.go @@ -13,7 +13,10 @@ import ( "github.com/pokt-network/poktroll/x/proof/types" ) -func (k Keeper) AllProofs(ctx context.Context, req *types.QueryAllProofsRequest) (*types.QueryAllProofsResponse, error) { +func (k Keeper) AllProofs( + ctx context.Context, + req *types.QueryAllProofsRequest, +) (*types.QueryAllProofsResponse, error) { logger := k.Logger().With("method", "AllProofs") if req == nil { diff --git a/x/proof/types/query_validation.go b/x/proof/types/query_validation.go index e1742dd99..50e3cbb7f 100644 --- a/x/proof/types/query_validation.go +++ b/x/proof/types/query_validation.go @@ -59,6 +59,7 @@ func (query *QueryGetProofRequest) ValidateBasic() error { return nil } +// ValidateBasic performs basic (non-state-dependant) validation on a QueryAllProofsRequest. func (query *QueryAllProofsRequest) ValidateBasic() error { // TODO_TECHDEBT: update function signature to receive a context. logger := polylog.Ctx(context.TODO()) diff --git a/x/service/keeper/query_service.go b/x/service/keeper/query_service.go index 73f420edc..999962eba 100644 --- a/x/service/keeper/query_service.go +++ b/x/service/keeper/query_service.go @@ -54,7 +54,8 @@ func (k Keeper) Service(ctx context.Context, req *types.QueryGetServiceRequest) service, found := k.GetService(ctx, req.Id) if !found { - return nil, status.Error(codes.NotFound, "service ID not found") + msg := fmt.Sprintf("service ID not found: %q", req.GetId()) + return nil, status.Error(codes.NotFound, msg) } return &types.QueryGetServiceResponse{Service: service}, nil diff --git a/x/supplier/keeper/query_supplier.go b/x/supplier/keeper/query_supplier.go index 3d370a8fa..72be0ae0f 100644 --- a/x/supplier/keeper/query_supplier.go +++ b/x/supplier/keeper/query_supplier.go @@ -24,11 +24,18 @@ func (k Keeper) AllSuppliers( return nil, status.Error(codes.InvalidArgument, "invalid request") } - var suppliers []sharedtypes.Supplier + if err := req.ValidateBasic(); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + // TODO_IMPROVE: Consider adding a custom onchain index (similar to proofs) + // based on other parameters (e.g. serviceId) if/when the performance of the + // flags used to filter the response becomes an issue. store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) supplierStore := prefix.NewStore(store, types.KeyPrefix(types.SupplierKeyOperatorPrefix)) + var suppliers []sharedtypes.Supplier + pageRes, err := query.Paginate( supplierStore, req.Pagination, @@ -40,6 +47,21 @@ func (k Keeper) AllSuppliers( return status.Error(codes.Internal, err.Error()) } + serviceIdFilter := req.GetServiceId() + if serviceIdFilter != "" { + hasService := false + for _, supplierServiceConfig := range supplier.Services { + if supplierServiceConfig.ServiceId == serviceIdFilter { + hasService = true + break + } + } + // Do not include the current supplier in the list returned. + if !hasService { + return nil + } + } + suppliers = append(suppliers, supplier) return nil }, @@ -62,8 +84,7 @@ func (k Keeper) Supplier( supplier, found := k.GetSupplier(ctx, req.OperatorAddress) if !found { - // TODO_TECHDEBT(@bryanchriswhite, #384): conform to logging conventions once established - msg := fmt.Sprintf("supplier with address %q", req.GetOperatorAddress()) + msg := fmt.Sprintf("supplier with address: %q", req.GetOperatorAddress()) return nil, status.Error(codes.NotFound, msg) } diff --git a/x/supplier/keeper/query_supplier_test.go b/x/supplier/keeper/query_supplier_test.go index b0d448ec4..0e8d8c169 100644 --- a/x/supplier/keeper/query_supplier_test.go +++ b/x/supplier/keeper/query_supplier_test.go @@ -20,6 +20,7 @@ var _ = strconv.IntSize func TestSupplierQuerySingle(t *testing.T) { supplierModuleKeepers, ctx := keepertest.SupplierKeeper(t) suppliers := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 2) + tests := []struct { desc string request *types.QueryGetSupplierRequest @@ -122,3 +123,35 @@ func TestSupplierQueryPaginated(t *testing.T) { require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) }) } + +func TestSupplierQueryFilterByServiceId(t *testing.T) { + supplierModuleKeepers, ctx := keepertest.SupplierKeeper(t) + msgs := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 5) + + // Get the first service ID from the first supplier to use as filter + firstServiceId := msgs[0].Services[0].ServiceId + + request := &types.QueryAllSuppliersRequest{ + Filter: &types.QueryAllSuppliersRequest_ServiceId{ + ServiceId: firstServiceId, + }, + Pagination: &query.PageRequest{ + Limit: uint64(len(msgs)), + }, + } + + resp, err := supplierModuleKeepers.AllSuppliers(ctx, request) + require.NoError(t, err) + + // Verify each returned supplier has the filtered service + for _, supplier := range resp.Supplier { + hasService := false + for _, service := range supplier.Services { + if service.ServiceId == firstServiceId { + hasService = true + break + } + } + require.True(t, hasService, "Supplier should have the filtered service") + } +} diff --git a/x/supplier/types/errors.go b/x/supplier/types/errors.go index c6188aade..d3a615a3b 100644 --- a/x/supplier/types/errors.go +++ b/x/supplier/types/errors.go @@ -15,4 +15,5 @@ var ( ErrSupplierServiceNotFound = sdkerrors.Register(ModuleName, 1106, "service not found") ErrSupplierParamInvalid = sdkerrors.Register(ModuleName, 1107, "the provided param is invalid") ErrSupplierEmitEvent = sdkerrors.Register(ModuleName, 1108, "failed to emit event") + ErrSupplierInvalidServiceId = sdkerrors.Register(ModuleName, 1109, "invalid service ID") ) diff --git a/x/supplier/types/query_validation.go b/x/supplier/types/query_validation.go new file mode 100644 index 000000000..5f6ef9779 --- /dev/null +++ b/x/supplier/types/query_validation.go @@ -0,0 +1,42 @@ +package types + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/pokt-network/poktroll/pkg/polylog" +) + +// NOTE: Please note that these messages are not of type `sdk.Msg`, and are therefore not a message/request +// that will be signable or invoke a state transition. However, following a similar `ValidateBasic` pattern +// allows us to localize & reuse validation logic. + +// ValidateBasic performs basic (non-state-dependant) validation on a QueryGetSupplierRequest. +func (query *QueryGetSupplierRequest) ValidateBasic() error { + // Validate the supplier operator address + if _, err := sdk.AccAddressFromBech32(query.OperatorAddress); err != nil { + return ErrSupplierInvalidAddress.Wrapf("invalid supplier operator address %s; (%v)", query.OperatorAddress, err) + } + + return nil +} + +// ValidateBasic performs basic (non-state-dependant) validation on a QueryAllSuppliersRequest. +func (query *QueryAllSuppliersRequest) ValidateBasic() error { + // TODO_TECHDEBT: update function signature to receive a context. + logger := polylog.Ctx(context.TODO()) + + switch filter := query.Filter.(type) { + case *QueryAllSuppliersRequest_ServiceId: + if filter.ServiceId == "" { + return ErrSupplierInvalidServiceId.Wrap("invalid empty service ID for suppliers being retrieved") + } + + default: + // No filter is set + logger.Info().Msg("No specific filter set when requesting proofs") + } + + return nil +} From 8ad0e75276160647099838b5d38849899681cf57 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Mon, 13 Jan 2025 19:39:25 -0500 Subject: [PATCH 04/24] Added flags --- .../run-e2e-test-job-template.yaml | 2 +- .../operate/quickstart/supplier_cheatsheet.md | 2 +- makefiles/suppliers.mk | 2 +- makefiles/testnet.mk | 2 +- testutil/network/network.go | 1 + x/supplier/keeper/query_supplier_test.go | 6 +- x/supplier/module/autocli.go | 19 +++-- x/supplier/module/flags.go | 5 ++ x/supplier/module/query.go | 2 +- x/supplier/module/query_supplier.go | 70 +++++++++---------- x/supplier/module/query_supplier_test.go | 48 +++++++++++-- x/supplier/types/query_validation.go | 6 +- 12 files changed, 110 insertions(+), 55 deletions(-) create mode 100644 x/supplier/module/flags.go diff --git a/.github/workflows-helpers/run-e2e-test-job-template.yaml b/.github/workflows-helpers/run-e2e-test-job-template.yaml index 9db41ed01..18de7d105 100644 --- a/.github/workflows-helpers/run-e2e-test-job-template.yaml +++ b/.github/workflows-helpers/run-e2e-test-job-template.yaml @@ -37,7 +37,7 @@ spec: ls -l /root/.poktroll/keyring-test/ && \ poktrolld q gateway list-gateway --node=$POCKET_NODE && \ poktrolld q application list-application --node=$POCKET_NODE && \ - poktrolld q supplier list-supplier --node=$POCKET_NODE && \ + poktrolld q supplier list-suppliers --node=$POCKET_NODE && \ make acc_initialize_pubkeys && \ go test -v ./e2e/tests/... -tags=e2e env: diff --git a/docusaurus/docs/operate/quickstart/supplier_cheatsheet.md b/docusaurus/docs/operate/quickstart/supplier_cheatsheet.md index 894361602..32446be7a 100644 --- a/docusaurus/docs/operate/quickstart/supplier_cheatsheet.md +++ b/docusaurus/docs/operate/quickstart/supplier_cheatsheet.md @@ -277,5 +277,5 @@ poktrolld query supplier -h Then, you can query for all services like so: ```bash -poktrolld query supplier list-supplier --node https://shannon-testnet-grove-rpc.beta.poktroll.com --output json | jq +poktrolld query supplier list-suppliers --node https://shannon-testnet-grove-rpc.beta.poktroll.com --output json | jq ``` diff --git a/makefiles/suppliers.mk b/makefiles/suppliers.mk index 2cceb2d8f..89669feda 100644 --- a/makefiles/suppliers.mk +++ b/makefiles/suppliers.mk @@ -4,7 +4,7 @@ .PHONY: supplier_list supplier_list: ## List all the staked supplier - poktrolld --home=$(POKTROLLD_HOME) q supplier list-supplier --node $(POCKET_NODE) + poktrolld --home=$(POKTROLLD_HOME) q supplier list-suppliers --node $(POCKET_NODE) .PHONY: supplier_stake supplier_stake: ## Stake tokens for the supplier specified (must specify the SUPPLIER and SUPPLIER_CONFIG env vars) diff --git a/makefiles/testnet.mk b/makefiles/testnet.mk index 0a13c056c..cd974a8d1 100644 --- a/makefiles/testnet.mk +++ b/makefiles/testnet.mk @@ -4,7 +4,7 @@ .PHONY: testnet_supplier_list testnet_supplier_list: ## List all the staked supplier on TestNet - poktrolld q supplier list-supplier --node=$(TESTNET_RPC) + poktrolld q supplier list-suppliers --node=$(TESTNET_RPC) .PHONY: testnet_gateway_list testnet_gateway_list: ## List all the staked gateways on TestNet diff --git a/testutil/network/network.go b/testutil/network/network.go index b7cc1fa1c..b7525fd08 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -158,6 +158,7 @@ func DefaultSupplierModuleGenesisState(t *testing.T, n int) *suppliertypes.Genes } // TODO_CONSIDERATION: Evaluate whether we need `nullify.Fill` or if we should enforce `(gogoproto.nullable) = false` everywhere // nullify.Fill(&supplier) + fmt.Println("OLSH", supplier) state.SupplierList = append(state.SupplierList, supplier) } return state diff --git a/x/supplier/keeper/query_supplier_test.go b/x/supplier/keeper/query_supplier_test.go index 0e8d8c169..93e57f6f4 100644 --- a/x/supplier/keeper/query_supplier_test.go +++ b/x/supplier/keeper/query_supplier_test.go @@ -46,7 +46,7 @@ func TestSupplierQuerySingle(t *testing.T) { request: &types.QueryGetSupplierRequest{ OperatorAddress: strconv.Itoa(100000), }, - expectedErr: status.Error(codes.NotFound, "supplier with address \"100000\""), + expectedErr: status.Error(codes.NotFound, "supplier with address: \"100000\""), }, { desc: "InvalidRequest", @@ -143,6 +143,10 @@ func TestSupplierQueryFilterByServiceId(t *testing.T) { resp, err := supplierModuleKeepers.AllSuppliers(ctx, request) require.NoError(t, err) + // createNSuppliers assigns a separate service to each supplier + // so we can only expect one supplier to have the filtered service. + require.Len(t, resp.Supplier, 1) + // Verify each returned supplier has the filtered service for _, supplier := range resp.Supplier { hasService := false diff --git a/x/supplier/module/autocli.go b/x/supplier/module/autocli.go index c65b4b8e0..6644f0ab1 100644 --- a/x/supplier/module/autocli.go +++ b/x/supplier/module/autocli.go @@ -34,7 +34,8 @@ import ( func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { return &autocliv1.ModuleOptions{ Query: &autocliv1.ServiceCommandDescriptor{ - Service: modulev1.Query_ServiceDesc.ServiceName, + Service: modulev1.Query_ServiceDesc.ServiceName, + EnhanceCustomCommand: true, // only required if you want to use the custom command (for backwards compatibility) RpcCommandOptions: []*autocliv1.RpcCommandOptions{ // { // RpcMethod: "Params", @@ -42,12 +43,16 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { // Short: "Shows the parameters of the module", // }, { - RpcMethod: "AllSuppliers", - Use: "list-suppliers", - Short: "List all suppliers on the Pocket Network", - Long: "Retrieves a paginated list of all suppliers currently registered on the Pocket Network, including their stakes and services.", - Example: "poktrolld query supplier list-suppliers\npoktrolld query supplier list-suppliers --page 2 --limit 50", Alias: []string{"suppliers", "ls"}, + RpcMethod: "AllSuppliers", + Use: "list-suppliers [service-id]", + Short: "List all suppliers on Pocket Network", + Long: "Retrieves a paginated list of all suppliers currently registered on Pocket Network, including all their details.", + Example: " poktrolld query supplier list-suppliers \n poktrolld query supplier list-suppliers --service-id anvil \n poktrolld query supplier list-suppliers --page 2 --limit 50", + FlagOptions: map[string]*autocliv1.FlagOptions{ + "service_id": {Name: "service-id", Shorthand: "s", Usage: "service id to filter by", Hidden: false}, + }, + // PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "service_id"}}, }, // { // RpcMethod: "Supplier", @@ -60,7 +65,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, Tx: &autocliv1.ServiceCommandDescriptor{ Service: modulev1.Msg_ServiceDesc.ServiceName, - EnhanceCustomCommand: true, // only required if you want to use the custom command + EnhanceCustomCommand: true, // only required if you want to use the custom command (for backwards compatibility) RpcCommandOptions: []*autocliv1.RpcCommandOptions{ //{ // RpcMethod: "UpdateParams", diff --git a/x/supplier/module/flags.go b/x/supplier/module/flags.go new file mode 100644 index 000000000..e4b1cbd9e --- /dev/null +++ b/x/supplier/module/flags.go @@ -0,0 +1,5 @@ +package supplier + +const ( + FlagServiceId = "service-id" +) diff --git a/x/supplier/module/query.go b/x/supplier/module/query.go index b49ebf142..1faf27e61 100644 --- a/x/supplier/module/query.go +++ b/x/supplier/module/query.go @@ -22,7 +22,7 @@ func (am AppModule) GetQueryCmd() *cobra.Command { } cmd.AddCommand(CmdQueryParams()) - cmd.AddCommand(CmdListSuppliers()) + // cmd.AddCommand(CmdListSuppliers()) cmd.AddCommand(CmdShowSupplier()) // this line is used by starport scaffolding # 1 diff --git a/x/supplier/module/query_supplier.go b/x/supplier/module/query_supplier.go index 81a18454e..acc114b8c 100644 --- a/x/supplier/module/query_supplier.go +++ b/x/supplier/module/query_supplier.go @@ -8,41 +8,41 @@ import ( "github.com/pokt-network/poktroll/x/supplier/types" ) -func CmdListSuppliers() *cobra.Command { - cmd := &cobra.Command{ - Use: "list-supplier", - Short: "list all supplier", - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - pageReq, err := client.ReadPageRequest(cmd.Flags()) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - params := &types.QueryAllSuppliersRequest{ - Pagination: pageReq, - } - - res, err := queryClient.AllSuppliers(cmd.Context(), params) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddPaginationFlagsToCmd(cmd, cmd.Use) - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} +// func CmdListSuppliers() *cobra.Command { +// cmd := &cobra.Command{ +// Use: "list-supplier", +// Short: "list all supplier", +// RunE: func(cmd *cobra.Command, args []string) error { +// clientCtx, err := client.GetClientQueryContext(cmd) +// if err != nil { +// return err +// } + +// pageReq, err := client.ReadPageRequest(cmd.Flags()) +// if err != nil { +// return err +// } + +// queryClient := types.NewQueryClient(clientCtx) + +// params := &types.QueryAllSuppliersRequest{ +// Pagination: pageReq, +// } + +// res, err := queryClient.AllSuppliers(cmd.Context(), params) +// if err != nil { +// return err +// } + +// return clientCtx.PrintProto(res) +// }, +// } + +// flags.AddPaginationFlagsToCmd(cmd, cmd.Use) +// flags.AddQueryFlagsToCmd(cmd) + +// return cmd +// } func CmdShowSupplier() *cobra.Command { cmd := &cobra.Command{ diff --git a/x/supplier/module/query_supplier_test.go b/x/supplier/module/query_supplier_test.go index 78c529d90..44783c3f6 100644 --- a/x/supplier/module/query_supplier_test.go +++ b/x/supplier/module/query_supplier_test.go @@ -77,25 +77,43 @@ func TestListSuppliers(t *testing.T) { net, suppliers := networkWithSupplierObjects(t, 5) ctx := net.Validators[0].ClientCtx - request := func(next []byte, offset, limit uint64, total bool) []string { + request := func( + next []byte, + offset, + limit uint64, + total bool, + serviceId string, + ) []string { + // Build the base args for the command args := []string{ fmt.Sprintf("--%s=json", cometcli.OutputFlag), + fmt.Sprintf("--%s=%d", flags.FlagLimit, limit), } + + // Add pagination flags if they're set if next == nil { args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset)) } else { args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next)) } - args = append(args, fmt.Sprintf("--%s=%d", flags.FlagLimit, limit)) + + // Add the total flag if it's set if total { args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal)) } + + // Add the service ID if it's set + if serviceId != "" { + args = append(args, fmt.Sprintf("--%s=%s", supplier.FlagServiceId, serviceId)) + } + return args } + t.Run("ByOffset", func(t *testing.T) { step := 2 for i := 0; i < len(suppliers); i += step { - args := request(nil, uint64(i), uint64(step), false) + args := request(nil, uint64(i), uint64(step), false, "") out, err := clitestutil.ExecTestCLICmd(ctx, supplier.CmdListSuppliers(), args) require.NoError(t, err) var resp types.QueryAllSuppliersResponse @@ -107,11 +125,12 @@ func TestListSuppliers(t *testing.T) { ) } }) + t.Run("ByKey", func(t *testing.T) { step := 2 var next []byte for i := 0; i < len(suppliers); i += step { - args := request(next, 0, uint64(step), false) + args := request(next, 0, uint64(step), false, "") out, err := clitestutil.ExecTestCLICmd(ctx, supplier.CmdListSuppliers(), args) require.NoError(t, err) var resp types.QueryAllSuppliersResponse @@ -124,8 +143,9 @@ func TestListSuppliers(t *testing.T) { next = resp.Pagination.NextKey } }) + t.Run("Total", func(t *testing.T) { - args := request(nil, 0, uint64(len(suppliers)), true) + args := request(nil, 0, uint64(len(suppliers)), true, "") out, err := clitestutil.ExecTestCLICmd(ctx, supplier.CmdListSuppliers(), args) require.NoError(t, err) var resp types.QueryAllSuppliersResponse @@ -137,4 +157,22 @@ func TestListSuppliers(t *testing.T) { nullify.Fill(resp.Supplier), ) }) + + t.Run("Filter By ServiceId", func(t *testing.T) { + fmt.Println("OLSH", suppliers[0].Services) + serviceId := suppliers[0].Services[0].ServiceId + + args := request(nil, 0, uint64(len(suppliers)), false, serviceId) + _, err := clitestutil.ExecTestCLICmd(ctx, supplier.CmdListSuppliers(), args) + require.NoError(t, err) + + // var resp types.QueryAllSuppliersResponse + // require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + // require.NoError(t, err) + // require.Equal(t, 1, int(resp.Pagination.Total)) + // require.ElementsMatch(t, + // nullify.Fill(suppliers), + // nullify.Fill(resp.Supplier), + // ) + }) } diff --git a/x/supplier/types/query_validation.go b/x/supplier/types/query_validation.go index 5f6ef9779..ccab23065 100644 --- a/x/supplier/types/query_validation.go +++ b/x/supplier/types/query_validation.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/pokt-network/poktroll/pkg/polylog" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) // NOTE: Please note that these messages are not of type `sdk.Msg`, and are therefore not a message/request @@ -29,13 +30,14 @@ func (query *QueryAllSuppliersRequest) ValidateBasic() error { switch filter := query.Filter.(type) { case *QueryAllSuppliersRequest_ServiceId: - if filter.ServiceId == "" { + // If the service ID is set, check if it's valid + if filter.ServiceId != "" && !sharedtypes.IsValidServiceId(filter.ServiceId) { return ErrSupplierInvalidServiceId.Wrap("invalid empty service ID for suppliers being retrieved") } default: // No filter is set - logger.Info().Msg("No specific filter set when requesting proofs") + logger.Info().Msg("No specific filter set when listing suppliers") } return nil From 3e3553d3eff1864fdc3f2435b9853388ce158a2d Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Mon, 13 Jan 2025 23:30:34 -0500 Subject: [PATCH 05/24] Works poktrolld --home=./localnet/poktrolld q supplier list-suppliers --service-id abc poktrolld --home=./localnet/poktrolld q supplier list-suppliers --service-id ollama --- api/poktroll/shared/service.pulsar.go | 57 +++++----- proto/poktroll/shared/service.proto | 2 +- testutil/network/network.go | 1 - x/shared/types/service.pb.go | 106 ++++++++++--------- x/shared/types/service_configs.go | 2 +- x/supplier/config/supplier_configs_reader.go | 6 +- x/supplier/module/autocli.go | 12 +-- 7 files changed, 98 insertions(+), 88 deletions(-) diff --git a/api/poktroll/shared/service.pulsar.go b/api/poktroll/shared/service.pulsar.go index 92dcfb12b..3bb395524 100644 --- a/api/poktroll/shared/service.pulsar.go +++ b/api/poktroll/shared/service.pulsar.go @@ -2,7 +2,6 @@ package shared import ( - binary "encoding/binary" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" @@ -11,7 +10,6 @@ import ( protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" io "io" - math "math" reflect "reflect" sync "sync" ) @@ -2418,8 +2416,8 @@ func (x *fastReflection_ServiceRevenueShare) Range(f func(protoreflect.FieldDesc return } } - if x.RevSharePercentage != float32(0) || math.Signbit(float64(x.RevSharePercentage)) { - value := protoreflect.ValueOfFloat32(x.RevSharePercentage) + if x.RevSharePercentage != uint32(0) { + value := protoreflect.ValueOfUint32(x.RevSharePercentage) if !f(fd_ServiceRevenueShare_rev_share_percentage, value) { return } @@ -2442,7 +2440,7 @@ func (x *fastReflection_ServiceRevenueShare) Has(fd protoreflect.FieldDescriptor case "poktroll.shared.ServiceRevenueShare.address": return x.Address != "" case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": - return x.RevSharePercentage != float32(0) || math.Signbit(float64(x.RevSharePercentage)) + return x.RevSharePercentage != uint32(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2462,7 +2460,7 @@ func (x *fastReflection_ServiceRevenueShare) Clear(fd protoreflect.FieldDescript case "poktroll.shared.ServiceRevenueShare.address": x.Address = "" case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": - x.RevSharePercentage = float32(0) + x.RevSharePercentage = uint32(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2484,7 +2482,7 @@ func (x *fastReflection_ServiceRevenueShare) Get(descriptor protoreflect.FieldDe return protoreflect.ValueOfString(value) case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": value := x.RevSharePercentage - return protoreflect.ValueOfFloat32(value) + return protoreflect.ValueOfUint32(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2508,7 +2506,7 @@ func (x *fastReflection_ServiceRevenueShare) Set(fd protoreflect.FieldDescriptor case "poktroll.shared.ServiceRevenueShare.address": x.Address = value.Interface().(string) case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": - x.RevSharePercentage = float32(value.Float()) + x.RevSharePercentage = uint32(value.Uint()) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2549,7 +2547,7 @@ func (x *fastReflection_ServiceRevenueShare) NewField(fd protoreflect.FieldDescr case "poktroll.shared.ServiceRevenueShare.address": return protoreflect.ValueOfString("") case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": - return protoreflect.ValueOfFloat32(float32(0)) + return protoreflect.ValueOfUint32(uint32(0)) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2623,8 +2621,8 @@ func (x *fastReflection_ServiceRevenueShare) ProtoMethods() *protoiface.Methods if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } - if x.RevSharePercentage != 0 || math.Signbit(float64(x.RevSharePercentage)) { - n += 5 + if x.RevSharePercentage != 0 { + n += 1 + runtime.Sov(uint64(x.RevSharePercentage)) } if x.unknownFields != nil { n += len(x.unknownFields) @@ -2655,11 +2653,10 @@ func (x *fastReflection_ServiceRevenueShare) ProtoMethods() *protoiface.Methods i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if x.RevSharePercentage != 0 || math.Signbit(float64(x.RevSharePercentage)) { - i -= 4 - binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(x.RevSharePercentage)))) + if x.RevSharePercentage != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.RevSharePercentage)) i-- - dAtA[i] = 0x15 + dAtA[i] = 0x10 } if len(x.Address) > 0 { i -= len(x.Address) @@ -2750,16 +2747,24 @@ func (x *fastReflection_ServiceRevenueShare) ProtoMethods() *protoiface.Methods x.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 5 { + if wireType != 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field RevSharePercentage", wireType) } - var v uint32 - if (iNdEx + 4) > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + x.RevSharePercentage = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.RevSharePercentage |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } } - v = uint32(binary.LittleEndian.Uint32(dAtA[iNdEx:])) - iNdEx += 4 - x.RevSharePercentage = float32(math.Float32frombits(v)) default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -3598,8 +3603,8 @@ type ServiceRevenueShare struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the revenue share recipient - RevSharePercentage float32 `protobuf:"fixed32,2,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` // The percentage of revenue share the recipient will receive + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the revenue share recipient + RevSharePercentage uint32 `protobuf:"varint,2,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` // The percentage of revenue share the recipient will receive } func (x *ServiceRevenueShare) Reset() { @@ -3629,7 +3634,7 @@ func (x *ServiceRevenueShare) GetAddress() string { return "" } -func (x *ServiceRevenueShare) GetRevSharePercentage() float32 { +func (x *ServiceRevenueShare) GetRevSharePercentage() uint32 { if x != nil { return x.RevSharePercentage } @@ -3730,7 +3735,7 @@ var file_poktroll_shared_service_proto_rawDesc = []byte{ 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x30, 0x0a, 0x14, 0x72, 0x65, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x5f, 0x70, 0x65, 0x72, - 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x02, 0x52, 0x12, 0x72, + 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x12, 0x72, 0x65, 0x76, 0x53, 0x68, 0x61, 0x72, 0x65, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x22, 0x56, 0x0a, 0x0c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x30, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, diff --git a/proto/poktroll/shared/service.proto b/proto/poktroll/shared/service.proto index 00dac4300..99e090304 100644 --- a/proto/poktroll/shared/service.proto +++ b/proto/poktroll/shared/service.proto @@ -58,7 +58,7 @@ message SupplierEndpoint { // ServiceRevenueShare message to hold revenue share configuration details message ServiceRevenueShare { string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the revenue share recipient - float rev_share_percentage = 2; // The percentage of revenue share the recipient will receive + uint32 rev_share_percentage = 2; // The percentage of revenue share the recipient will receive } // Enum to define RPC types diff --git a/testutil/network/network.go b/testutil/network/network.go index b7525fd08..b7cc1fa1c 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -158,7 +158,6 @@ func DefaultSupplierModuleGenesisState(t *testing.T, n int) *suppliertypes.Genes } // TODO_CONSIDERATION: Evaluate whether we need `nullify.Fill` or if we should enforce `(gogoproto.nullable) = false` everywhere // nullify.Fill(&supplier) - fmt.Println("OLSH", supplier) state.SupplierList = append(state.SupplierList, supplier) } return state diff --git a/x/shared/types/service.pb.go b/x/shared/types/service.pb.go index 358154b9f..e8e9bf1e7 100644 --- a/x/shared/types/service.pb.go +++ b/x/shared/types/service.pb.go @@ -7,7 +7,6 @@ package types import ( - encoding_binary "encoding/binary" fmt "fmt" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/gogoproto/gogoproto" @@ -321,8 +320,8 @@ func (m *SupplierEndpoint) GetConfigs() []*ConfigOption { // ServiceRevenueShare message to hold revenue share configuration details type ServiceRevenueShare struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - RevSharePercentage float32 `protobuf:"fixed32,2,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + RevSharePercentage uint32 `protobuf:"varint,2,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` } func (m *ServiceRevenueShare) Reset() { *m = ServiceRevenueShare{} } @@ -361,7 +360,7 @@ func (m *ServiceRevenueShare) GetAddress() string { return "" } -func (m *ServiceRevenueShare) GetRevSharePercentage() float32 { +func (m *ServiceRevenueShare) GetRevSharePercentage() uint32 { if m != nil { return m.RevSharePercentage } @@ -433,44 +432,44 @@ func init() { proto.RegisterFile("poktroll/shared/service.proto", fileDescriptor var fileDescriptor_302c2f793a11ae1e = []byte{ // 621 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0xcd, 0x26, 0x81, 0x24, 0xd3, 0x36, 0xb5, 0x86, 0x20, 0x4c, 0xa5, 0x5a, 0x25, 0xe2, 0x50, + 0x10, 0xcd, 0x26, 0x81, 0x24, 0xd3, 0x26, 0xb5, 0x86, 0x20, 0x4c, 0xa5, 0x5a, 0x25, 0xe2, 0x50, 0x55, 0x6a, 0x52, 0xa5, 0x42, 0x88, 0x03, 0x42, 0x6d, 0x14, 0xaa, 0x52, 0x35, 0x89, 0xd6, 0x29, 0x95, 0xb8, 0x58, 0xae, 0xbd, 0xa4, 0x56, 0x13, 0xaf, 0xb5, 0xb6, 0x53, 0x22, 0x7e, 0x02, 0xf1, 0x0b, 0xfc, 0x02, 0x27, 0xbe, 0x80, 0x63, 0xc5, 0xa9, 0x47, 0x94, 0xfe, 0x08, 0x5a, 0xaf, 0x1d, - 0xa0, 0x41, 0x20, 0x6e, 0xe3, 0x79, 0x6f, 0x66, 0xde, 0xbe, 0x1d, 0x2f, 0xac, 0x07, 0xfc, 0x22, - 0x12, 0x7c, 0x34, 0x6a, 0x86, 0x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0x57, 0x60, 0xe9, 0xb8, 0x77, 0xd8, 0xeb, 0x9f, 0xf4, + 0x2c, 0x3a, 0xe8, 0x68, 0x39, 0x2c, 0x43, 0x71, 0x5f, 0x46, 0x04, 0xab, 0x50, 0x39, 0xe9, 0xee, + 0x99, 0xfd, 0xce, 0x61, 0x77, 0xa8, 0xe5, 0x71, 0x19, 0xca, 0xaf, 0xcc, 0xbe, 0xa2, 0x15, 0x24, + 0x8d, 0x76, 0xcd, 0xa1, 0x56, 0xdc, 0xdc, 0x86, 0xea, 0x6f, 0x83, 0x11, 0xa1, 0x96, 0xb5, 0xec, + 0xf4, 0x7b, 0x2f, 0x0f, 0xf6, 0xb5, 0x1c, 0x2e, 0x41, 0x69, 0x78, 0x70, 0xd4, 0xed, 0x1f, 0x0f, + 0x35, 0xb2, 0x77, 0xf4, 0x75, 0x6e, 0x90, 0xcb, 0xb9, 0x41, 0xae, 0xe6, 0x06, 0xf9, 0x3e, 0x37, + 0xc8, 0x87, 0x6b, 0x23, 0x77, 0x79, 0x6d, 0xe4, 0xae, 0xae, 0x8d, 0xdc, 0x9b, 0xd6, 0xc8, 0x8b, + 0xce, 0xe2, 0xd3, 0xa6, 0xc3, 0x27, 0x2d, 0x79, 0xc2, 0x2d, 0x9f, 0x45, 0x17, 0x5c, 0x9c, 0xb7, + 0x16, 0xaf, 0xc3, 0xbb, 0xec, 0x7d, 0x90, 0x3b, 0x10, 0x9e, 0xde, 0x4d, 0x7e, 0xee, 0x9d, 0x1f, + 0x01, 0x00, 0x00, 0xff, 0xff, 0xeb, 0xd3, 0x3c, 0x70, 0x3f, 0x04, 0x00, 0x00, } func (m *Service) Marshal() (dAtA []byte, err error) { @@ -680,10 +679,9 @@ func (m *ServiceRevenueShare) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if m.RevSharePercentage != 0 { - i -= 4 - encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.RevSharePercentage)))) + i = encodeVarintService(dAtA, i, uint64(m.RevSharePercentage)) i-- - dAtA[i] = 0x15 + dAtA[i] = 0x10 } if len(m.Address) > 0 { i -= len(m.Address) @@ -836,7 +834,7 @@ func (m *ServiceRevenueShare) Size() (n int) { n += 1 + l + sovService(uint64(l)) } if m.RevSharePercentage != 0 { - n += 5 + n += 1 + sovService(uint64(m.RevSharePercentage)) } return n } @@ -1457,16 +1455,24 @@ func (m *ServiceRevenueShare) Unmarshal(dAtA []byte) error { m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 5 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field RevSharePercentage", wireType) } - var v uint32 - if (iNdEx + 4) > l { - return io.ErrUnexpectedEOF + m.RevSharePercentage = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RevSharePercentage |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } } - v = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) - iNdEx += 4 - m.RevSharePercentage = float32(math.Float32frombits(v)) default: iNdEx = preIndex skippy, err := skipService(dAtA[iNdEx:]) diff --git a/x/shared/types/service_configs.go b/x/shared/types/service_configs.go index 122a10241..30e4cb7ae 100644 --- a/x/shared/types/service_configs.go +++ b/x/shared/types/service_configs.go @@ -95,7 +95,7 @@ func ValidateSupplierServiceConfigs(services []*SupplierServiceConfig) error { // ensuring that the sum of the revenue share percentages is 100. // NB: This function is unit tested via the supplier staking config tests. func ValidateServiceRevShare(revShareList []*ServiceRevenueShare) error { - revSharePercentageSum := float32(0) + revSharePercentageSum := uint32(0) if len(revShareList) == 0 { return ErrSharedInvalidRevShare.Wrap("no rev share configurations") diff --git a/x/supplier/config/supplier_configs_reader.go b/x/supplier/config/supplier_configs_reader.go index c2f009c2e..01885de7c 100644 --- a/x/supplier/config/supplier_configs_reader.go +++ b/x/supplier/config/supplier_configs_reader.go @@ -19,14 +19,14 @@ type YAMLStakeConfig struct { OperatorAddress string `yaml:"operator_address"` StakeAmount string `yaml:"stake_amount"` Services []*YAMLStakeService `yaml:"services"` - DefaultRevSharePercent map[string]float32 `yaml:"default_rev_share_percent"` + DefaultRevSharePercent map[string]uint32 `yaml:"default_rev_share_percent"` } // YAMLStakeService is the structure describing a single service entry in the // stake config file. type YAMLStakeService struct { ServiceId string `yaml:"service_id"` - RevSharePercent map[string]float32 `yaml:"rev_share_percent"` + RevSharePercent map[string]uint32 `yaml:"rev_share_percent"` Endpoints []YAMLServiceEndpoint `yaml:"endpoints"` } @@ -102,7 +102,7 @@ func ParseSupplierConfigs(ctx context.Context, configContent []byte) (*SupplierS ) } - defaultRevSharePercent := map[string]float32{} + defaultRevSharePercent := map[string]uint32{} if len(stakeConfig.DefaultRevSharePercent) == 0 { // Ensure that if no default rev share is provided, the owner address is set // to 100% rev share. diff --git a/x/supplier/module/autocli.go b/x/supplier/module/autocli.go index 6644f0ab1..b35337e6b 100644 --- a/x/supplier/module/autocli.go +++ b/x/supplier/module/autocli.go @@ -54,12 +54,12 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, // PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "service_id"}}, }, - // { - // RpcMethod: "Supplier", - // Use: "show-supplier [id]", - // Short: "Shows a supplier", - // PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "index"}}, - // }, + { + RpcMethod: "Supplier", + Use: "show-supplier [id]", + Short: "Shows a supplier", + // PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "index"}}, + }, // this line is used by ignite scaffolding # autocli/query }, }, From a2d6dfa0b3f51a2b3d4a625b663a9e11204379b7 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Wed, 15 Jan 2025 16:57:20 -0500 Subject: [PATCH 06/24] Checkpoint --- x/shared/types/service_configs.go | 2 +- x/supplier/config/supplier_configs_reader.go | 6 +- x/supplier/module/query.go | 2 +- x/supplier/module/query_supplier.go | 58 +++++++++----------- 4 files changed, 30 insertions(+), 38 deletions(-) diff --git a/x/shared/types/service_configs.go b/x/shared/types/service_configs.go index 30e4cb7ae..122a10241 100644 --- a/x/shared/types/service_configs.go +++ b/x/shared/types/service_configs.go @@ -95,7 +95,7 @@ func ValidateSupplierServiceConfigs(services []*SupplierServiceConfig) error { // ensuring that the sum of the revenue share percentages is 100. // NB: This function is unit tested via the supplier staking config tests. func ValidateServiceRevShare(revShareList []*ServiceRevenueShare) error { - revSharePercentageSum := uint32(0) + revSharePercentageSum := float32(0) if len(revShareList) == 0 { return ErrSharedInvalidRevShare.Wrap("no rev share configurations") diff --git a/x/supplier/config/supplier_configs_reader.go b/x/supplier/config/supplier_configs_reader.go index 01885de7c..c2f009c2e 100644 --- a/x/supplier/config/supplier_configs_reader.go +++ b/x/supplier/config/supplier_configs_reader.go @@ -19,14 +19,14 @@ type YAMLStakeConfig struct { OperatorAddress string `yaml:"operator_address"` StakeAmount string `yaml:"stake_amount"` Services []*YAMLStakeService `yaml:"services"` - DefaultRevSharePercent map[string]uint32 `yaml:"default_rev_share_percent"` + DefaultRevSharePercent map[string]float32 `yaml:"default_rev_share_percent"` } // YAMLStakeService is the structure describing a single service entry in the // stake config file. type YAMLStakeService struct { ServiceId string `yaml:"service_id"` - RevSharePercent map[string]uint32 `yaml:"rev_share_percent"` + RevSharePercent map[string]float32 `yaml:"rev_share_percent"` Endpoints []YAMLServiceEndpoint `yaml:"endpoints"` } @@ -102,7 +102,7 @@ func ParseSupplierConfigs(ctx context.Context, configContent []byte) (*SupplierS ) } - defaultRevSharePercent := map[string]uint32{} + defaultRevSharePercent := map[string]float32{} if len(stakeConfig.DefaultRevSharePercent) == 0 { // Ensure that if no default rev share is provided, the owner address is set // to 100% rev share. diff --git a/x/supplier/module/query.go b/x/supplier/module/query.go index 1faf27e61..272af326e 100644 --- a/x/supplier/module/query.go +++ b/x/supplier/module/query.go @@ -23,7 +23,7 @@ func (am AppModule) GetQueryCmd() *cobra.Command { cmd.AddCommand(CmdQueryParams()) // cmd.AddCommand(CmdListSuppliers()) - cmd.AddCommand(CmdShowSupplier()) + // cmd.AddCommand(CmdShowSupplier()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/supplier/module/query_supplier.go b/x/supplier/module/query_supplier.go index acc114b8c..dd3ea86c0 100644 --- a/x/supplier/module/query_supplier.go +++ b/x/supplier/module/query_supplier.go @@ -1,13 +1,5 @@ package supplier -import ( - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/spf13/cobra" - - "github.com/pokt-network/poktroll/x/supplier/types" -) - // func CmdListSuppliers() *cobra.Command { // cmd := &cobra.Command{ // Use: "list-supplier", @@ -44,35 +36,35 @@ import ( // return cmd // } -func CmdShowSupplier() *cobra.Command { - cmd := &cobra.Command{ - Use: "show-supplier ", - Short: "shows a supplier", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } +// func CmdShowSupplier() *cobra.Command { +// cmd := &cobra.Command{ +// Use: "show-supplier ", +// Short: "shows a supplier", +// Args: cobra.ExactArgs(1), +// RunE: func(cmd *cobra.Command, args []string) (err error) { +// clientCtx, err := client.GetClientQueryContext(cmd) +// if err != nil { +// return err +// } - queryClient := types.NewQueryClient(clientCtx) +// queryClient := types.NewQueryClient(clientCtx) - argAddress := args[0] +// argAddress := args[0] - params := &types.QueryGetSupplierRequest{ - OperatorAddress: argAddress, - } +// params := &types.QueryGetSupplierRequest{ +// OperatorAddress: argAddress, +// } - res, err := queryClient.Supplier(cmd.Context(), params) - if err != nil { - return err - } +// res, err := queryClient.Supplier(cmd.Context(), params) +// if err != nil { +// return err +// } - return clientCtx.PrintProto(res) - }, - } +// return clientCtx.PrintProto(res) +// }, +// } - flags.AddQueryFlagsToCmd(cmd) +// flags.AddQueryFlagsToCmd(cmd) - return cmd -} +// return cmd +// } From d88bbbed6dd75f79af8886b8711e5a94fe5e8f48 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Thu, 16 Jan 2025 11:16:14 -0500 Subject: [PATCH 07/24] Checkpoint --- api/poktroll/shared/service.pulsar.go | 72 +++++++-------- .../contributing/poktrolld_cli_updates.md | 19 ---- .../configs/supplier_staking_config.md | 4 +- .../config/supplier1_stake_config.yaml | 4 +- .../config/supplier_stake_config_example.yaml | 4 +- proto/poktroll/shared/service.proto | 5 +- x/shared/types/service.pb.go | 87 ++++++++++--------- x/shared/types/service_configs.go | 2 +- x/supplier/config/supplier_configs_reader.go | 6 +- x/supplier/keeper/supplier_test.go | 49 +++++++++++ x/supplier/module/query.go | 2 - x/supplier/module/query_supplier.go | 70 --------------- x/supplier/module/query_supplier_test.go | 54 ------------ 13 files changed, 143 insertions(+), 235 deletions(-) delete mode 100644 docusaurus/docs/develop/contributing/poktrolld_cli_updates.md delete mode 100644 x/supplier/module/query_supplier.go diff --git a/api/poktroll/shared/service.pulsar.go b/api/poktroll/shared/service.pulsar.go index 3bb395524..9990cff20 100644 --- a/api/poktroll/shared/service.pulsar.go +++ b/api/poktroll/shared/service.pulsar.go @@ -2656,7 +2656,7 @@ func (x *fastReflection_ServiceRevenueShare) ProtoMethods() *protoiface.Methods if x.RevSharePercentage != 0 { i = runtime.EncodeVarint(dAtA, i, uint64(x.RevSharePercentage)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x18 } if len(x.Address) > 0 { i -= len(x.Address) @@ -2746,7 +2746,7 @@ func (x *fastReflection_ServiceRevenueShare) ProtoMethods() *protoiface.Methods } x.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field RevSharePercentage", wireType) } @@ -3604,7 +3604,7 @@ type ServiceRevenueShare struct { unknownFields protoimpl.UnknownFields Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the revenue share recipient - RevSharePercentage uint32 `protobuf:"varint,2,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` // The percentage of revenue share the recipient will receive + RevSharePercentage uint32 `protobuf:"varint,3,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` // The percentage of revenue share the recipient will receive } func (x *ServiceRevenueShare) Reset() { @@ -3729,39 +3729,39 @@ var file_poktroll_shared_service_proto_rawDesc = []byte{ 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x73, 0x22, 0x7b, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, - 0x65, 0x76, 0x65, 0x6e, 0x75, 0x65, 0x53, 0x68, 0x61, 0x72, 0x65, 0x12, 0x32, 0x0a, 0x07, 0x61, - 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, - 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, - 0x30, 0x0a, 0x14, 0x72, 0x65, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x5f, 0x70, 0x65, 0x72, - 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x12, 0x72, - 0x65, 0x76, 0x53, 0x68, 0x61, 0x72, 0x65, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, - 0x65, 0x22, 0x56, 0x0a, 0x0c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4f, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x12, 0x30, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, - 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, - 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x03, - 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2a, 0x4b, 0x0a, 0x07, 0x52, 0x50, 0x43, - 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, - 0x52, 0x50, 0x43, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x47, 0x52, 0x50, 0x43, 0x10, 0x01, 0x12, - 0x0d, 0x0a, 0x09, 0x57, 0x45, 0x42, 0x53, 0x4f, 0x43, 0x4b, 0x45, 0x54, 0x10, 0x02, 0x12, 0x0c, - 0x0a, 0x08, 0x4a, 0x53, 0x4f, 0x4e, 0x5f, 0x52, 0x50, 0x43, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, - 0x52, 0x45, 0x53, 0x54, 0x10, 0x04, 0x2a, 0x30, 0x0a, 0x0d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x0e, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, - 0x57, 0x4e, 0x5f, 0x43, 0x4f, 0x4e, 0x46, 0x49, 0x47, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x54, - 0x49, 0x4d, 0x45, 0x4f, 0x55, 0x54, 0x10, 0x01, 0x42, 0xa6, 0x01, 0xd8, 0xe2, 0x1e, 0x01, 0x0a, - 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, - 0x61, 0x72, 0x65, 0x64, 0x42, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, - 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, - 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x0f, 0x50, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0xca, 0x02, - 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, - 0xe2, 0x02, 0x1b, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, - 0x65, 0x64, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, - 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x68, 0x61, 0x72, 0x65, - 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x66, 0x69, 0x67, 0x73, 0x22, 0x81, 0x01, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x52, 0x65, 0x76, 0x65, 0x6e, 0x75, 0x65, 0x53, 0x68, 0x61, 0x72, 0x65, 0x12, 0x32, 0x0a, 0x07, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, + 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x12, 0x30, 0x0a, 0x14, 0x72, 0x65, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x5f, 0x70, 0x65, + 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x12, + 0x72, 0x65, 0x76, 0x53, 0x68, 0x61, 0x72, 0x65, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, + 0x67, 0x65, 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x22, 0x56, 0x0a, 0x0c, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x30, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x2a, 0x4b, 0x0a, 0x07, 0x52, 0x50, 0x43, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x55, + 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, 0x52, 0x50, 0x43, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, + 0x47, 0x52, 0x50, 0x43, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x57, 0x45, 0x42, 0x53, 0x4f, 0x43, + 0x4b, 0x45, 0x54, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x4a, 0x53, 0x4f, 0x4e, 0x5f, 0x52, 0x50, + 0x43, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x45, 0x53, 0x54, 0x10, 0x04, 0x2a, 0x30, 0x0a, + 0x0d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, + 0x0a, 0x0e, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, 0x43, 0x4f, 0x4e, 0x46, 0x49, 0x47, + 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x54, 0x49, 0x4d, 0x45, 0x4f, 0x55, 0x54, 0x10, 0x01, 0x42, + 0xa6, 0x01, 0xd8, 0xe2, 0x1e, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, + 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x42, 0x0c, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x20, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, + 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0xa2, 0x02, 0x03, + 0x50, 0x53, 0x58, 0xaa, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, + 0x68, 0x61, 0x72, 0x65, 0x64, 0xca, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0xe2, 0x02, 0x1b, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x3a, 0x3a, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/docusaurus/docs/develop/contributing/poktrolld_cli_updates.md b/docusaurus/docs/develop/contributing/poktrolld_cli_updates.md deleted file mode 100644 index 40d70285f..000000000 --- a/docusaurus/docs/develop/contributing/poktrolld_cli_updates.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -sidebar_position: 4 -title: CLI Updates ---- - -## CLI Update Tutorial - -You can follow this guide if you're interested in making additions -to the `poktrolld`. - -## Prerequisites - -1. You have familiar and have a functional [LocalNet](../developer_guide/walkthrough.md) -2. You are familiar with the [poktrolld CLI](../../operate/user_guide/poktrolld_cli.md) - -## - -1. Example PR -2. make ignite_poktrolld_build \ No newline at end of file diff --git a/docusaurus/docs/operate/configs/supplier_staking_config.md b/docusaurus/docs/operate/configs/supplier_staking_config.md index 169221639..41ba22758 100644 --- a/docusaurus/docs/operate/configs/supplier_staking_config.md +++ b/docusaurus/docs/operate/configs/supplier_staking_config.md @@ -214,8 +214,8 @@ _`Optional`_, _`Non-empty`_ ```yaml default_rev_share_percent: - : - : + : + : ``` `default_rev_share_percent` is an optional map that defines the default the revenue diff --git a/localnet/poktrolld/config/supplier1_stake_config.yaml b/localnet/poktrolld/config/supplier1_stake_config.yaml index e3d475939..046fddb4c 100644 --- a/localnet/poktrolld/config/supplier1_stake_config.yaml +++ b/localnet/poktrolld/config/supplier1_stake_config.yaml @@ -2,8 +2,8 @@ owner_address: pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 operator_address: pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 stake_amount: 1000069upokt default_rev_share_percent: - pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4: 80.5 - pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw: 19.5 + pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4: 80 + pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw: 20 services: - service_id: anvil endpoints: diff --git a/localnet/poktrolld/config/supplier_stake_config_example.yaml b/localnet/poktrolld/config/supplier_stake_config_example.yaml index ce14f4a08..2fef94f0b 100644 --- a/localnet/poktrolld/config/supplier_stake_config_example.yaml +++ b/localnet/poktrolld/config/supplier_stake_config_example.yaml @@ -30,8 +30,8 @@ stake_amount: 1000069upokt # or include at least one item. default_rev_share_percent: # The sum of all shares MUST equal 100%. Staking will fail otherwise. - pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4: 80.5 - pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw: 19.5 + pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4: 80 + pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw: 20 services: # The endpoint URL for the Anvil service is provided via the RelayMiner. # The RelayMiner acts as a proxy, forwarding requests to the actual Anvil data node behind it. diff --git a/proto/poktroll/shared/service.proto b/proto/poktroll/shared/service.proto index 99e090304..6df07cdcb 100644 --- a/proto/poktroll/shared/service.proto +++ b/proto/poktroll/shared/service.proto @@ -57,8 +57,11 @@ message SupplierEndpoint { // ServiceRevenueShare message to hold revenue share configuration details message ServiceRevenueShare { + // 2 was reserved in #1028 during the change of rev_share_percentage from float to uint32 + reserved 2; + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the revenue share recipient - uint32 rev_share_percentage = 2; // The percentage of revenue share the recipient will receive + uint32 rev_share_percentage = 3; // The percentage of revenue share the recipient will receive } // Enum to define RPC types diff --git a/x/shared/types/service.pb.go b/x/shared/types/service.pb.go index e8e9bf1e7..fd0704264 100644 --- a/x/shared/types/service.pb.go +++ b/x/shared/types/service.pb.go @@ -321,7 +321,7 @@ func (m *SupplierEndpoint) GetConfigs() []*ConfigOption { // ServiceRevenueShare message to hold revenue share configuration details type ServiceRevenueShare struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - RevSharePercentage uint32 `protobuf:"varint,2,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` + RevSharePercentage uint32 `protobuf:"varint,3,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` } func (m *ServiceRevenueShare) Reset() { *m = ServiceRevenueShare{} } @@ -430,46 +430,47 @@ func init() { func init() { proto.RegisterFile("poktroll/shared/service.proto", fileDescriptor_302c2f793a11ae1e) } var fileDescriptor_302c2f793a11ae1e = []byte{ - // 621 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0xcd, 0x26, 0x81, 0x24, 0xd3, 0x26, 0xb5, 0x86, 0x20, 0x4c, 0xa5, 0x5a, 0x25, 0xe2, 0x50, - 0x55, 0x6a, 0x52, 0xa5, 0x42, 0x88, 0x03, 0x42, 0x6d, 0x14, 0xaa, 0x52, 0x35, 0x89, 0xd6, 0x29, - 0x95, 0xb8, 0x58, 0xae, 0xbd, 0xa4, 0x56, 0x13, 0xaf, 0xb5, 0xb6, 0x53, 0x22, 0x7e, 0x02, 0xf1, - 0x0b, 0xfc, 0x02, 0x27, 0xbe, 0x80, 0x63, 0xc5, 0xa9, 0x47, 0x94, 0xfe, 0x08, 0x5a, 0xaf, 0x1d, - 0xa0, 0x45, 0x20, 0x6e, 0xe3, 0x79, 0x6f, 0x66, 0xde, 0xbe, 0x1d, 0x2f, 0xac, 0x05, 0xfc, 0x3c, - 0x12, 0x7c, 0x3c, 0x6e, 0x85, 0x67, 0xb6, 0x60, 0x6e, 0x2b, 0x64, 0x62, 0xea, 0x39, 0xac, 0x19, - 0x08, 0x1e, 0x71, 0x5c, 0xc9, 0xe0, 0xa6, 0x82, 0x57, 0x1f, 0x3a, 0x3c, 0x9c, 0xf0, 0xd0, 0x4a, - 0xe0, 0x96, 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xa8, 0x08, 0x36, 0xb5, 0x12, 0xa6, 0x5e, 0x48, - 0x1a, 0x3c, 0xbe, 0xdd, 0x40, 0xcd, 0xa3, 0x6c, 0xca, 0xfc, 0x98, 0x99, 0x32, 0x49, 0xcb, 0x82, - 0x4d, 0x93, 0xa8, 0xf1, 0x91, 0x80, 0x76, 0x73, 0x04, 0x6a, 0x50, 0x88, 0xc5, 0x38, 0x15, 0x2c, - 0x43, 0xdc, 0x81, 0xb2, 0x08, 0x1c, 0x2b, 0x9a, 0x05, 0xea, 0xb2, 0x6a, 0x6d, 0xfd, 0xd6, 0x20, - 0x3a, 0xe8, 0x0c, 0x67, 0x01, 0xa3, 0x25, 0x11, 0x38, 0x32, 0xc0, 0xa7, 0x50, 0x72, 0x12, 0x23, - 0xc2, 0x54, 0xdc, 0xda, 0xad, 0x1a, 0x65, 0x54, 0x3f, 0x90, 0xa6, 0xd3, 0x8c, 0xdd, 0x78, 0x0f, - 0xf7, 0xfe, 0xa0, 0x1a, 0xdb, 0x50, 0xca, 0x2e, 0x97, 0xfc, 0xe3, 0x72, 0x33, 0x22, 0x6e, 0x43, - 0x7d, 0x61, 0x91, 0xdc, 0x24, 0x87, 0xf9, 0x91, 0x3d, 0x52, 0x87, 0xa8, 0x52, 0xcc, 0x7c, 0x18, - 0x2c, 0x90, 0xc6, 0x6b, 0x58, 0xfe, 0x55, 0x15, 0x6e, 0x43, 0xe1, 0x9c, 0xcd, 0x92, 0x89, 0xb5, - 0xb6, 0xf1, 0xd7, 0x13, 0x84, 0x54, 0x52, 0xb1, 0x0e, 0x77, 0xa6, 0xf6, 0x38, 0xce, 0xd6, 0x5a, - 0x7d, 0x6c, 0x1e, 0x42, 0x29, 0x75, 0x08, 0x57, 0x60, 0xe9, 0xb8, 0x77, 0xd8, 0xeb, 0x9f, 0xf4, - 0x2c, 0x3a, 0xe8, 0x68, 0x39, 0x2c, 0x43, 0x71, 0x5f, 0x46, 0x04, 0xab, 0x50, 0x39, 0xe9, 0xee, - 0x99, 0xfd, 0xce, 0x61, 0x77, 0xa8, 0xe5, 0x71, 0x19, 0xca, 0xaf, 0xcc, 0xbe, 0xa2, 0x15, 0x24, - 0x8d, 0x76, 0xcd, 0xa1, 0x56, 0xdc, 0xdc, 0x86, 0xea, 0x6f, 0x83, 0x11, 0xa1, 0x96, 0xb5, 0xec, - 0xf4, 0x7b, 0x2f, 0x0f, 0xf6, 0xb5, 0x1c, 0x2e, 0x41, 0x69, 0x78, 0x70, 0xd4, 0xed, 0x1f, 0x0f, - 0x35, 0xb2, 0x77, 0xf4, 0x75, 0x6e, 0x90, 0xcb, 0xb9, 0x41, 0xae, 0xe6, 0x06, 0xf9, 0x3e, 0x37, - 0xc8, 0x87, 0x6b, 0x23, 0x77, 0x79, 0x6d, 0xe4, 0xae, 0xae, 0x8d, 0xdc, 0x9b, 0xd6, 0xc8, 0x8b, - 0xce, 0xe2, 0xd3, 0xa6, 0xc3, 0x27, 0x2d, 0x79, 0xc2, 0x2d, 0x9f, 0x45, 0x17, 0x5c, 0x9c, 0xb7, - 0x16, 0xaf, 0xc3, 0xbb, 0xec, 0x7d, 0x90, 0x3b, 0x10, 0x9e, 0xde, 0x4d, 0x7e, 0xee, 0x9d, 0x1f, - 0x01, 0x00, 0x00, 0xff, 0xff, 0xeb, 0xd3, 0x3c, 0x70, 0x3f, 0x04, 0x00, 0x00, + // 630 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcf, 0x6e, 0xd3, 0x4e, + 0x10, 0xce, 0xc6, 0xf9, 0xfd, 0x92, 0x4c, 0x9b, 0xd4, 0x1a, 0x82, 0x30, 0x95, 0x6a, 0x95, 0x88, + 0x43, 0x55, 0xa9, 0x49, 0x95, 0x0a, 0x21, 0x0e, 0x08, 0xb5, 0x51, 0xa8, 0xda, 0xaa, 0x49, 0xb4, + 0x4e, 0xa9, 0xc4, 0xc5, 0x72, 0xed, 0x25, 0xb5, 0xea, 0x78, 0xad, 0xb5, 0x9d, 0x92, 0x23, 0x6f, + 0x80, 0x78, 0x05, 0x5e, 0x81, 0x13, 0x4f, 0xc0, 0xb1, 0xe2, 0xd4, 0x23, 0x4a, 0x5f, 0x04, 0xad, + 0xff, 0x04, 0x68, 0x11, 0x88, 0xdb, 0x78, 0xbe, 0x6f, 0x66, 0xbe, 0xfd, 0x76, 0xbc, 0xb0, 0x16, + 0xf0, 0x8b, 0x48, 0x70, 0xcf, 0x6b, 0x87, 0xe7, 0x96, 0x60, 0x4e, 0x3b, 0x64, 0x62, 0xea, 0xda, + 0xac, 0x15, 0x08, 0x1e, 0x71, 0x5c, 0xc9, 0xe1, 0x56, 0x0a, 0xaf, 0x3e, 0xb4, 0x79, 0x38, 0xe1, + 0xa1, 0x99, 0xc0, 0xed, 0xf4, 0x23, 0xe5, 0xae, 0x36, 0xc6, 0x7c, 0xcc, 0xd3, 0xbc, 0x8c, 0xd2, + 0x6c, 0xf3, 0x23, 0x81, 0xb2, 0x91, 0xf6, 0xc4, 0x3a, 0x14, 0x5d, 0x47, 0x23, 0xeb, 0x64, 0xa3, + 0x4a, 0x8b, 0xae, 0x83, 0x08, 0x25, 0xdf, 0x9a, 0x30, 0xad, 0x98, 0x64, 0x92, 0x18, 0x9f, 0xc0, + 0x03, 0x9b, 0x4f, 0x82, 0x38, 0x62, 0x66, 0xec, 0xbb, 0x51, 0x68, 0x06, 0x4c, 0x98, 0x82, 0x79, + 0xd6, 0x4c, 0x53, 0xd6, 0xc9, 0x46, 0x89, 0x36, 0x32, 0xf8, 0x44, 0xa2, 0x43, 0x26, 0xa8, 0xc4, + 0xf0, 0x39, 0xd4, 0xf8, 0xa5, 0xcf, 0x84, 0x69, 0x39, 0x8e, 0x60, 0x61, 0xa8, 0x95, 0x64, 0xcf, + 0x3d, 0xed, 0xeb, 0xa7, 0xad, 0x46, 0xa6, 0x72, 0x37, 0x45, 0x8c, 0x48, 0xb8, 0xfe, 0x98, 0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6d, 0xfe, 0x4c, 0xc8, + 0x55, 0x08, 0xcf, 0xfe, 0x4f, 0xfe, 0xf1, 0x9d, 0xef, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x27, + 0x73, 0xed, 0x46, 0x04, 0x00, 0x00, } func (m *Service) Marshal() (dAtA []byte, err error) { @@ -681,7 +682,7 @@ func (m *ServiceRevenueShare) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.RevSharePercentage != 0 { i = encodeVarintService(dAtA, i, uint64(m.RevSharePercentage)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x18 } if len(m.Address) > 0 { i -= len(m.Address) @@ -1454,7 +1455,7 @@ func (m *ServiceRevenueShare) Unmarshal(dAtA []byte) error { } m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field RevSharePercentage", wireType) } diff --git a/x/shared/types/service_configs.go b/x/shared/types/service_configs.go index 122a10241..30e4cb7ae 100644 --- a/x/shared/types/service_configs.go +++ b/x/shared/types/service_configs.go @@ -95,7 +95,7 @@ func ValidateSupplierServiceConfigs(services []*SupplierServiceConfig) error { // ensuring that the sum of the revenue share percentages is 100. // NB: This function is unit tested via the supplier staking config tests. func ValidateServiceRevShare(revShareList []*ServiceRevenueShare) error { - revSharePercentageSum := float32(0) + revSharePercentageSum := uint32(0) if len(revShareList) == 0 { return ErrSharedInvalidRevShare.Wrap("no rev share configurations") diff --git a/x/supplier/config/supplier_configs_reader.go b/x/supplier/config/supplier_configs_reader.go index c2f009c2e..fc956f9c6 100644 --- a/x/supplier/config/supplier_configs_reader.go +++ b/x/supplier/config/supplier_configs_reader.go @@ -19,14 +19,14 @@ type YAMLStakeConfig struct { OperatorAddress string `yaml:"operator_address"` StakeAmount string `yaml:"stake_amount"` Services []*YAMLStakeService `yaml:"services"` - DefaultRevSharePercent map[string]float32 `yaml:"default_rev_share_percent"` + DefaultRevSharePercent map[string]uint32 `yaml:"default_rev_share_percent"` } // YAMLStakeService is the structure describing a single service entry in the // stake config file. type YAMLStakeService struct { ServiceId string `yaml:"service_id"` - RevSharePercent map[string]float32 `yaml:"rev_share_percent"` + RevSharePercent map[string]uint32 `yaml:"rev_share_percent"` Endpoints []YAMLServiceEndpoint `yaml:"endpoints"` } @@ -102,7 +102,7 @@ func ParseSupplierConfigs(ctx context.Context, configContent []byte) (*SupplierS ) } - defaultRevSharePercent := map[string]float32{} + defaultRevSharePercent := map[string]uint32{} if len(stakeConfig.DefaultRevSharePercent) == 0 { // Ensure that if no default rev share is provided, the owner address is set // to 100% rev share. diff --git a/x/supplier/keeper/supplier_test.go b/x/supplier/keeper/supplier_test.go index 8cbddd555..36f02df82 100644 --- a/x/supplier/keeper/supplier_test.go +++ b/x/supplier/keeper/supplier_test.go @@ -9,7 +9,9 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/gogo/status" "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" "github.com/pokt-network/poktroll/cmd/poktrolld/cmd" keepertest "github.com/pokt-network/poktroll/testutil/keeper" @@ -59,6 +61,53 @@ func createNSuppliers(keeper keeper.Keeper, ctx context.Context, n int) []shared return suppliers } +func TestSupplierQuery(t *testing.T) { + keeper, ctx := keepertest.SupplierKeeper(t) + suppliers := createNSuppliers(*keeper.Keeper, ctx, 2) + + tests := []struct { + desc string + request *types.QueryGetSupplierRequest + response *types.QueryGetSupplierResponse + expectedErr error + }{ + { + desc: "supplier found", + request: &types.QueryGetSupplierRequest{ + OperatorAddress: suppliers[0].OperatorAddress, + }, + response: &types.QueryGetSupplierResponse{ + Supplier: suppliers[0], + }, + }, + { + desc: "supplier not found", + request: &types.QueryGetSupplierRequest{ + OperatorAddress: "non_existent_address", + }, + expectedErr: status.Error(codes.NotFound, fmt.Sprintf("supplier with address: %q", "non_existent_address")), + }, + } + + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + response, err := keeper.Supplier(ctx, test.request) + if test.expectedErr != nil { + stat, ok := status.FromError(test.expectedErr) + require.True(t, ok) + require.ErrorIs(t, stat.Err(), test.expectedErr) + } else { + require.NoError(t, err) + require.NotNil(t, response) + require.Equal(t, + nullify.Fill(test.response), + nullify.Fill(response), + ) + } + }) + } +} + func TestSupplierGet(t *testing.T) { supplierModuleKeepers, ctx := keepertest.SupplierKeeper(t) suppliers := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 10) diff --git a/x/supplier/module/query.go b/x/supplier/module/query.go index 272af326e..bb81daf33 100644 --- a/x/supplier/module/query.go +++ b/x/supplier/module/query.go @@ -22,8 +22,6 @@ func (am AppModule) GetQueryCmd() *cobra.Command { } cmd.AddCommand(CmdQueryParams()) - // cmd.AddCommand(CmdListSuppliers()) - // cmd.AddCommand(CmdShowSupplier()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/supplier/module/query_supplier.go b/x/supplier/module/query_supplier.go deleted file mode 100644 index dd3ea86c0..000000000 --- a/x/supplier/module/query_supplier.go +++ /dev/null @@ -1,70 +0,0 @@ -package supplier - -// func CmdListSuppliers() *cobra.Command { -// cmd := &cobra.Command{ -// Use: "list-supplier", -// Short: "list all supplier", -// RunE: func(cmd *cobra.Command, args []string) error { -// clientCtx, err := client.GetClientQueryContext(cmd) -// if err != nil { -// return err -// } - -// pageReq, err := client.ReadPageRequest(cmd.Flags()) -// if err != nil { -// return err -// } - -// queryClient := types.NewQueryClient(clientCtx) - -// params := &types.QueryAllSuppliersRequest{ -// Pagination: pageReq, -// } - -// res, err := queryClient.AllSuppliers(cmd.Context(), params) -// if err != nil { -// return err -// } - -// return clientCtx.PrintProto(res) -// }, -// } - -// flags.AddPaginationFlagsToCmd(cmd, cmd.Use) -// flags.AddQueryFlagsToCmd(cmd) - -// return cmd -// } - -// func CmdShowSupplier() *cobra.Command { -// cmd := &cobra.Command{ -// Use: "show-supplier ", -// Short: "shows a supplier", -// Args: cobra.ExactArgs(1), -// RunE: func(cmd *cobra.Command, args []string) (err error) { -// clientCtx, err := client.GetClientQueryContext(cmd) -// if err != nil { -// return err -// } - -// queryClient := types.NewQueryClient(clientCtx) - -// argAddress := args[0] - -// params := &types.QueryGetSupplierRequest{ -// OperatorAddress: argAddress, -// } - -// res, err := queryClient.Supplier(cmd.Context(), params) -// if err != nil { -// return err -// } - -// return clientCtx.PrintProto(res) -// }, -// } - -// flags.AddQueryFlagsToCmd(cmd) - -// return cmd -// } diff --git a/x/supplier/module/query_supplier_test.go b/x/supplier/module/query_supplier_test.go index 44783c3f6..2c6c2ba61 100644 --- a/x/supplier/module/query_supplier_test.go +++ b/x/supplier/module/query_supplier_test.go @@ -18,60 +18,6 @@ import ( "github.com/pokt-network/poktroll/x/supplier/types" ) -func TestShowSupplier(t *testing.T) { - net, suppliers := networkWithSupplierObjects(t, 2) - - ctx := net.Validators[0].ClientCtx - common := []string{ - fmt.Sprintf("--%s=json", cometcli.OutputFlag), - } - tests := []struct { - desc string - idAddress string - - args []string - expectedErr error - supplier sharedtypes.Supplier - }{ - { - desc: "supplier found", - idAddress: suppliers[0].OperatorAddress, - - args: common, - supplier: suppliers[0], - }, - { - desc: "supplier not found", - idAddress: strconv.Itoa(100000), - - args: common, - expectedErr: status.Error(codes.NotFound, "not found"), - }, - } - for _, test := range tests { - t.Run(test.desc, func(t *testing.T) { - args := []string{ - test.idAddress, - } - args = append(args, test.args...) - out, err := clitestutil.ExecTestCLICmd(ctx, supplier.CmdShowSupplier(), args) - if test.expectedErr != nil { - stat, ok := status.FromError(test.expectedErr) - require.True(t, ok) - require.ErrorIs(t, stat.Err(), test.expectedErr) - } else { - require.NoError(t, err) - var resp types.QueryGetSupplierResponse - require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) - require.NotNil(t, resp.Supplier) - require.Equal(t, - nullify.Fill(&test.supplier), - nullify.Fill(&resp.Supplier), - ) - } - }) - } -} func TestListSuppliers(t *testing.T) { net, suppliers := networkWithSupplierObjects(t, 5) From 6b028dc624d0d793e7b7c7b58735a809fc65950b Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Thu, 16 Jan 2025 11:57:07 -0500 Subject: [PATCH 08/24] Migrated some of the unit tests --- localnet/poktrolld/config/config.toml | 4 +- x/supplier/keeper/supplier_test.go | 176 ++++++++++++++++++----- x/supplier/module/query_supplier_test.go | 124 ---------------- 3 files changed, 139 insertions(+), 165 deletions(-) delete mode 100644 x/supplier/module/query_supplier_test.go diff --git a/localnet/poktrolld/config/config.toml b/localnet/poktrolld/config/config.toml index bbfa0366f..35dcda640 100644 --- a/localnet/poktrolld/config/config.toml +++ b/localnet/poktrolld/config/config.toml @@ -174,7 +174,7 @@ timeout_broadcast_tx_commit = "10s" max_request_batch_size = 10 # Maximum size of request body, in bytes -max_body_bytes = 1000000 +max_body_bytes = 100000000 # Maximum size of request header, in bytes max_header_bytes = 1048576 @@ -330,7 +330,7 @@ keep-invalid-txs-in-cache = false # Maximum size of a single transaction. # NOTE: the max size of a tx transmitted over the network is {max_tx_bytes}. -max_tx_bytes = 1048576 +max_tx_bytes = 100000000 # Maximum size of a batch of transactions to send to a peer # Including space needed by encoding (one varint per transaction). diff --git a/x/supplier/keeper/supplier_test.go b/x/supplier/keeper/supplier_test.go index 36f02df82..cde7952c5 100644 --- a/x/supplier/keeper/supplier_test.go +++ b/x/supplier/keeper/supplier_test.go @@ -8,6 +8,7 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/gogo/status" "github.com/stretchr/testify/require" @@ -29,13 +30,7 @@ func init() { cmd.InitSDKConfig() } -// The module address is derived off of its semantic name. -// This test is a helper for us to easily identify the underlying address. -func TestModuleAddressSupplier(t *testing.T) { - moduleAddress := authtypes.NewModuleAddress(types.ModuleName) - require.Equal(t, "pokt1j40dzzmn6cn9kxku7a5tjnud6hv37vesr5ccaa", moduleAddress.String()) -} - +// createNSuppliers creates n suppliers and stores them in the keeper func createNSuppliers(keeper keeper.Keeper, ctx context.Context, n int) []sharedtypes.Supplier { suppliers := make([]sharedtypes.Supplier, n) for i := range suppliers { @@ -61,7 +56,51 @@ func createNSuppliers(keeper keeper.Keeper, ctx context.Context, n int) []shared return suppliers } -func TestSupplierQuery(t *testing.T) { +// DEV_NOTE: The account address is derived off of the module's semantic name (supplier). +// This test is a helper for us to easily identify the underlying address. +// See Module Accounts for more details: https://docs.cosmos.network/main/learn/beginner/accounts#module-accounts +func TestModuleAddressSupplier(t *testing.T) { + moduleAddress := authtypes.NewModuleAddress(types.ModuleName) + require.Equal(t, "pokt1j40dzzmn6cn9kxku7a5tjnud6hv37vesr5ccaa", moduleAddress.String()) +} + +func TestSupplier_Get(t *testing.T) { + supplierModuleKeepers, ctx := keepertest.SupplierKeeper(t) + suppliers := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 10) + for _, supplier := range suppliers { + supplierFound, isSupplierFound := supplierModuleKeepers.GetSupplier(ctx, + supplier.OperatorAddress, + ) + require.True(t, isSupplierFound) + require.Equal(t, + nullify.Fill(&supplier), + nullify.Fill(&supplierFound), + ) + } +} + +func TestSupplier_Remove(t *testing.T) { + supplierModuleKeepers, ctx := keepertest.SupplierKeeper(t) + suppliers := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 10) + for _, supplier := range suppliers { + supplierModuleKeepers.RemoveSupplier(ctx, supplier.OperatorAddress) + _, isSupplierFound := supplierModuleKeepers.GetSupplier(ctx, + supplier.OperatorAddress, + ) + require.False(t, isSupplierFound) + } +} + +func TestSupplier_GetAll(t *testing.T) { + supplierModuleKeepers, ctx := keepertest.SupplierKeeper(t) + suppliers := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 10) + require.ElementsMatch(t, + nullify.Fill(suppliers), + nullify.Fill(supplierModuleKeepers.GetAllSuppliers(ctx)), + ) +} + +func TestSupplier_Query(t *testing.T) { keeper, ctx := keepertest.SupplierKeeper(t) suppliers := createNSuppliers(*keeper.Keeper, ctx, 2) @@ -95,7 +134,7 @@ func TestSupplierQuery(t *testing.T) { if test.expectedErr != nil { stat, ok := status.FromError(test.expectedErr) require.True(t, ok) - require.ErrorIs(t, stat.Err(), test.expectedErr) + require.ErrorContains(t, stat.Err(), test.expectedErr.Error()) } else { require.NoError(t, err) require.NotNil(t, response) @@ -108,38 +147,97 @@ func TestSupplierQuery(t *testing.T) { } } -func TestSupplierGet(t *testing.T) { - supplierModuleKeepers, ctx := keepertest.SupplierKeeper(t) - suppliers := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 10) - for _, supplier := range suppliers { - supplierFound, isSupplierFound := supplierModuleKeepers.GetSupplier(ctx, - supplier.OperatorAddress, - ) - require.True(t, isSupplierFound) - require.Equal(t, - nullify.Fill(&supplier), - nullify.Fill(&supplierFound), - ) - } -} +func TestSuppliers_QueryAll_Pagination(t *testing.T) { + keeper, ctx := keepertest.SupplierKeeper(t) + suppliers := createNSuppliers(*keeper.Keeper, ctx, 5) -func TestSupplierRemove(t *testing.T) { - supplierModuleKeepers, ctx := keepertest.SupplierKeeper(t) - suppliers := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 10) - for _, supplier := range suppliers { - supplierModuleKeepers.RemoveSupplier(ctx, supplier.OperatorAddress) - _, isSupplierFound := supplierModuleKeepers.GetSupplier(ctx, - supplier.OperatorAddress, + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(suppliers); i += step { + req := &types.QueryAllSuppliersRequest{ + Pagination: &query.PageRequest{ + Offset: uint64(i), + Limit: uint64(step), + }, + } + resp, err := keeper.AllSuppliers(ctx, req) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.Supplier), step) + require.Subset(t, + nullify.Fill(suppliers), + nullify.Fill(resp.Supplier), + ) + } + }) + + t.Run("ByKey", func(t *testing.T) { + step := 2 + var nextKey []byte + for i := 0; i < len(suppliers); i += step { + req := &types.QueryAllSuppliersRequest{ + Pagination: &query.PageRequest{ + Key: nextKey, + Limit: uint64(step), + }, + } + resp, err := keeper.AllSuppliers(ctx, req) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.Supplier), step) + require.Subset(t, + nullify.Fill(suppliers), + nullify.Fill(resp.Supplier), + ) + nextKey = resp.Pagination.NextKey + } + }) + + t.Run("Total", func(t *testing.T) { + req := &types.QueryAllSuppliersRequest{ + Pagination: &query.PageRequest{ + Offset: 0, + Limit: uint64(len(suppliers)), + CountTotal: true, + }, + } + resp, err := keeper.AllSuppliers(ctx, req) + require.NoError(t, err) + require.Equal(t, len(suppliers), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(suppliers), + nullify.Fill(resp.Supplier), ) - require.False(t, isSupplierFound) - } + }) } -func TestSupplierGetAll(t *testing.T) { - supplierModuleKeepers, ctx := keepertest.SupplierKeeper(t) - suppliers := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 10) - require.ElementsMatch(t, - nullify.Fill(suppliers), - nullify.Fill(supplierModuleKeepers.GetAllSuppliers(ctx)), - ) +func TestSuppliers_QueryAll_Filters(t *testing.T) { + keeper, ctx := keepertest.SupplierKeeper(t) + suppliers := createNSuppliers(*keeper.Keeper, ctx, 5) + + t.Run("Filter By ServiceId", func(t *testing.T) { + // Assuming the first supplier has at least one service + serviceId := suppliers[0].Services[0].ServiceId + req := &types.QueryAllSuppliersRequest{ + Pagination: &query.PageRequest{ + Offset: 0, + Limit: uint64(len(suppliers)), + }, + Filter: &types.QueryAllSuppliersRequest_ServiceId{ + ServiceId: serviceId, + }, + } + resp, err := keeper.AllSuppliers(ctx, req) + require.NoError(t, err) + + // Verify each returned supplier has the specified service + for _, s := range resp.Supplier { + hasService := false + for _, service := range s.Services { + if service.ServiceId == serviceId { + hasService = true + break + } + } + require.True(t, hasService, "Returned supplier does not have the specified service") + } + }) } diff --git a/x/supplier/module/query_supplier_test.go b/x/supplier/module/query_supplier_test.go deleted file mode 100644 index 2c6c2ba61..000000000 --- a/x/supplier/module/query_supplier_test.go +++ /dev/null @@ -1,124 +0,0 @@ -package supplier_test - -import ( - "fmt" - "strconv" - "testing" - - cometcli "github.com/cometbft/cometbft/libs/cli" - "github.com/cosmos/cosmos-sdk/client/flags" - clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" - "github.com/stretchr/testify/require" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - "github.com/pokt-network/poktroll/testutil/nullify" - sharedtypes "github.com/pokt-network/poktroll/x/shared/types" - supplier "github.com/pokt-network/poktroll/x/supplier/module" - "github.com/pokt-network/poktroll/x/supplier/types" -) - - -func TestListSuppliers(t *testing.T) { - net, suppliers := networkWithSupplierObjects(t, 5) - - ctx := net.Validators[0].ClientCtx - request := func( - next []byte, - offset, - limit uint64, - total bool, - serviceId string, - ) []string { - // Build the base args for the command - args := []string{ - fmt.Sprintf("--%s=json", cometcli.OutputFlag), - fmt.Sprintf("--%s=%d", flags.FlagLimit, limit), - } - - // Add pagination flags if they're set - if next == nil { - args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset)) - } else { - args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next)) - } - - // Add the total flag if it's set - if total { - args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal)) - } - - // Add the service ID if it's set - if serviceId != "" { - args = append(args, fmt.Sprintf("--%s=%s", supplier.FlagServiceId, serviceId)) - } - - return args - } - - t.Run("ByOffset", func(t *testing.T) { - step := 2 - for i := 0; i < len(suppliers); i += step { - args := request(nil, uint64(i), uint64(step), false, "") - out, err := clitestutil.ExecTestCLICmd(ctx, supplier.CmdListSuppliers(), args) - require.NoError(t, err) - var resp types.QueryAllSuppliersResponse - require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) - require.LessOrEqual(t, len(resp.Supplier), step) - require.Subset(t, - nullify.Fill(suppliers), - nullify.Fill(resp.Supplier), - ) - } - }) - - t.Run("ByKey", func(t *testing.T) { - step := 2 - var next []byte - for i := 0; i < len(suppliers); i += step { - args := request(next, 0, uint64(step), false, "") - out, err := clitestutil.ExecTestCLICmd(ctx, supplier.CmdListSuppliers(), args) - require.NoError(t, err) - var resp types.QueryAllSuppliersResponse - require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) - require.LessOrEqual(t, len(resp.Supplier), step) - require.Subset(t, - nullify.Fill(suppliers), - nullify.Fill(resp.Supplier), - ) - next = resp.Pagination.NextKey - } - }) - - t.Run("Total", func(t *testing.T) { - args := request(nil, 0, uint64(len(suppliers)), true, "") - out, err := clitestutil.ExecTestCLICmd(ctx, supplier.CmdListSuppliers(), args) - require.NoError(t, err) - var resp types.QueryAllSuppliersResponse - require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) - require.NoError(t, err) - require.Equal(t, len(suppliers), int(resp.Pagination.Total)) - require.ElementsMatch(t, - nullify.Fill(suppliers), - nullify.Fill(resp.Supplier), - ) - }) - - t.Run("Filter By ServiceId", func(t *testing.T) { - fmt.Println("OLSH", suppliers[0].Services) - serviceId := suppliers[0].Services[0].ServiceId - - args := request(nil, 0, uint64(len(suppliers)), false, serviceId) - _, err := clitestutil.ExecTestCLICmd(ctx, supplier.CmdListSuppliers(), args) - require.NoError(t, err) - - // var resp types.QueryAllSuppliersResponse - // require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) - // require.NoError(t, err) - // require.Equal(t, 1, int(resp.Pagination.Total)) - // require.ElementsMatch(t, - // nullify.Fill(suppliers), - // nullify.Fill(resp.Supplier), - // ) - }) -} From 0ea39d080ebbf74f6bc5b58a7c8c00342f2be570 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Thu, 16 Jan 2025 12:33:02 -0500 Subject: [PATCH 09/24] Revert one of the files --- localnet/poktrolld/config/config.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/localnet/poktrolld/config/config.toml b/localnet/poktrolld/config/config.toml index 35dcda640..bbfa0366f 100644 --- a/localnet/poktrolld/config/config.toml +++ b/localnet/poktrolld/config/config.toml @@ -174,7 +174,7 @@ timeout_broadcast_tx_commit = "10s" max_request_batch_size = 10 # Maximum size of request body, in bytes -max_body_bytes = 100000000 +max_body_bytes = 1000000 # Maximum size of request header, in bytes max_header_bytes = 1048576 @@ -330,7 +330,7 @@ keep-invalid-txs-in-cache = false # Maximum size of a single transaction. # NOTE: the max size of a tx transmitted over the network is {max_tx_bytes}. -max_tx_bytes = 100000000 +max_tx_bytes = 1048576 # Maximum size of a batch of transactions to send to a peer # Including space needed by encoding (one varint per transaction). From 8986389b453820d8594a90379c1f7b586090a330 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Thu, 16 Jan 2025 12:51:08 -0500 Subject: [PATCH 10/24] Update Makefile --- makefiles/suppliers.mk | 8 +++++ x/supplier/module/autocli.go | 58 ++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/makefiles/suppliers.mk b/makefiles/suppliers.mk index 89669feda..2e0f885e8 100644 --- a/makefiles/suppliers.mk +++ b/makefiles/suppliers.mk @@ -6,6 +6,14 @@ supplier_list: ## List all the staked supplier poktrolld --home=$(POKTROLLD_HOME) q supplier list-suppliers --node $(POCKET_NODE) +.PHONY: supplier_list_anvil +supplier_list_anvil: ## List all the staked supplier staked for the anvil service + poktrolld --home=$(POKTROLLD_HOME) q supplier list-suppliers --service-id anvil --node $(POCKET_NODE) + +.PHONY: supplier_show_supplier1 +supplier_show_supplier1: ## Show supplier1 details + poktrolld --home=$(POKTROLLD_HOME) q supplier show-supplier supplier1 --node $(POCKET_NODE) + .PHONY: supplier_stake supplier_stake: ## Stake tokens for the supplier specified (must specify the SUPPLIER and SUPPLIER_CONFIG env vars) poktrolld --home=$(POKTROLLD_HOME) tx supplier stake-supplier -y --config $(POKTROLLD_HOME)/config/$(SERVICES) --keyring-backend test --from $(SUPPLIER) --node $(POCKET_NODE) diff --git a/x/supplier/module/autocli.go b/x/supplier/module/autocli.go index b35337e6b..50ff57418 100644 --- a/x/supplier/module/autocli.go +++ b/x/supplier/module/autocli.go @@ -6,30 +6,6 @@ import ( modulev1 "github.com/pokt-network/poktroll/api/poktroll/supplier" ) -// Query: &autocliv1.ServiceCommandDescriptor{ -// Service: modulev1.Query_ServiceDesc.ServiceName, -// RpcCommandOptions: []*autocliv1.RpcCommandOptions{ -// // { -// // RpcMethod: "Params", -// // Use: "params", -// // Short: "Shows the parameters of the module", -// // }, -// // { -// // RpcMethod: "AllServices", -// // Use: "list-service", -// // Short: "List all service", -// // }, -// { -// RpcMethod: "Service", -// Use: "show-service [id]", -// Short: "Shows a service", -// Long: "Retrieve the service details by its id.", -// PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "id"}}, -// }, -// // this line is used by ignite scaffolding # autocli/query -// }, -// }, - // AutoCLIOptions implements the autocli.HasAutoCLIConfig interface. func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { return &autocliv1.ModuleOptions{ @@ -47,18 +23,42 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { RpcMethod: "AllSuppliers", Use: "list-suppliers [service-id]", Short: "List all suppliers on Pocket Network", - Long: "Retrieves a paginated list of all suppliers currently registered on Pocket Network, including all their details.", - Example: " poktrolld query supplier list-suppliers \n poktrolld query supplier list-suppliers --service-id anvil \n poktrolld query supplier list-suppliers --page 2 --limit 50", + Long: `Retrieves a paginated list of all suppliers currently registered on Pocket Network, including all their details. + +The command supports optional filtering by service ID and pagination parameters. +Returns supplier addresses, staked amounts, service details, and current status.`, + + Example: ` + poktrolld query supplier list-suppliers + poktrolld query supplier list-suppliers --service-id anvil + poktrolld query supplier list-suppliers --page 2 --limit 50 + poktrolld query supplier list-suppliers --service-id anvil --page 1 --limit 100`, FlagOptions: map[string]*autocliv1.FlagOptions{ "service_id": {Name: "service-id", Shorthand: "s", Usage: "service id to filter by", Hidden: false}, }, // PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "service_id"}}, }, { + Alias: []string{"supplier", "s"}, RpcMethod: "Supplier", - Use: "show-supplier [id]", - Short: "Shows a supplier", - // PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "index"}}, + Use: "show-supplier [address]", + Short: "Shows detailed information about a specific supplier", + Long: `Retrieves comprehensive information about a supplier identified by their address. + +Returns details include things like: +- Supplier's staked amount and status +- List of services they provide`, + + Example: ` + + poktrolld query supplier show-supplier pokt1abc...xyz + poktrolld query supplier show-supplier pokt1abc...xyz --output json + poktrolld query supplier show-supplier pokt1abc...xyz --height 100`, + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + { + ProtoField: "operator_address", + }, + }, }, // this line is used by ignite scaffolding # autocli/query }, From c91b3cfb3a3c63ae38882c500e4f28d2eb379d9d Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Thu, 16 Jan 2025 13:03:35 -0500 Subject: [PATCH 11/24] Fix typo --- e2e/tests/init_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/tests/init_test.go b/e2e/tests/init_test.go index 680806c87..09706f0fb 100644 --- a/e2e/tests/init_test.go +++ b/e2e/tests/init_test.go @@ -662,7 +662,7 @@ func (s *suite) buildSupplierMap() { argsAndFlags := []string{ "query", "supplier", - "list-supplier", + "list-suppliers", fmt.Sprintf("--%s=json", cometcli.OutputFlag), } res, err := s.pocketd.RunCommandOnHostWithRetry("", numQueryRetries, argsAndFlags...) From 54742fe6b9b414cb21c4251888e05d1c1a892f47 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Thu, 16 Jan 2025 19:52:28 -0500 Subject: [PATCH 12/24] Reply to red0ne's comments --- api/poktroll/shared/service.pulsar.go | 57 +++++---- api/poktroll/supplier/query.pulsar.go | 2 +- localnet/poktrolld/config/config.toml | 4 +- .../config/supplier1_stake_config.yaml | 4 +- .../config/supplier_stake_config_example.yaml | 4 +- proto/poktroll/shared/service.proto | 4 +- proto/poktroll/supplier/query.proto | 1 + x/shared/types/service.pb.go | 108 +++++++++--------- x/shared/types/service_configs.go | 2 +- x/supplier/config/supplier_configs_reader.go | 6 +- x/supplier/keeper/query_supplier_test.go | 20 ++-- x/supplier/module/autocli.go | 2 +- .../keeper/token_logic_modules_test.go | 6 +- 13 files changed, 105 insertions(+), 115 deletions(-) diff --git a/api/poktroll/shared/service.pulsar.go b/api/poktroll/shared/service.pulsar.go index 9990cff20..131bf6936 100644 --- a/api/poktroll/shared/service.pulsar.go +++ b/api/poktroll/shared/service.pulsar.go @@ -2,6 +2,7 @@ package shared import ( + binary "encoding/binary" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" @@ -10,6 +11,7 @@ import ( protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" io "io" + math "math" reflect "reflect" sync "sync" ) @@ -2416,8 +2418,8 @@ func (x *fastReflection_ServiceRevenueShare) Range(f func(protoreflect.FieldDesc return } } - if x.RevSharePercentage != uint32(0) { - value := protoreflect.ValueOfUint32(x.RevSharePercentage) + if x.RevSharePercentage != float64(0) || math.Signbit(x.RevSharePercentage) { + value := protoreflect.ValueOfFloat64(x.RevSharePercentage) if !f(fd_ServiceRevenueShare_rev_share_percentage, value) { return } @@ -2440,7 +2442,7 @@ func (x *fastReflection_ServiceRevenueShare) Has(fd protoreflect.FieldDescriptor case "poktroll.shared.ServiceRevenueShare.address": return x.Address != "" case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": - return x.RevSharePercentage != uint32(0) + return x.RevSharePercentage != float64(0) || math.Signbit(x.RevSharePercentage) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2460,7 +2462,7 @@ func (x *fastReflection_ServiceRevenueShare) Clear(fd protoreflect.FieldDescript case "poktroll.shared.ServiceRevenueShare.address": x.Address = "" case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": - x.RevSharePercentage = uint32(0) + x.RevSharePercentage = float64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2482,7 +2484,7 @@ func (x *fastReflection_ServiceRevenueShare) Get(descriptor protoreflect.FieldDe return protoreflect.ValueOfString(value) case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": value := x.RevSharePercentage - return protoreflect.ValueOfUint32(value) + return protoreflect.ValueOfFloat64(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2506,7 +2508,7 @@ func (x *fastReflection_ServiceRevenueShare) Set(fd protoreflect.FieldDescriptor case "poktroll.shared.ServiceRevenueShare.address": x.Address = value.Interface().(string) case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": - x.RevSharePercentage = uint32(value.Uint()) + x.RevSharePercentage = value.Float() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2547,7 +2549,7 @@ func (x *fastReflection_ServiceRevenueShare) NewField(fd protoreflect.FieldDescr case "poktroll.shared.ServiceRevenueShare.address": return protoreflect.ValueOfString("") case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": - return protoreflect.ValueOfUint32(uint32(0)) + return protoreflect.ValueOfFloat64(float64(0)) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2621,8 +2623,8 @@ func (x *fastReflection_ServiceRevenueShare) ProtoMethods() *protoiface.Methods if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } - if x.RevSharePercentage != 0 { - n += 1 + runtime.Sov(uint64(x.RevSharePercentage)) + if x.RevSharePercentage != 0 || math.Signbit(x.RevSharePercentage) { + n += 9 } if x.unknownFields != nil { n += len(x.unknownFields) @@ -2653,10 +2655,11 @@ func (x *fastReflection_ServiceRevenueShare) ProtoMethods() *protoiface.Methods i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if x.RevSharePercentage != 0 { - i = runtime.EncodeVarint(dAtA, i, uint64(x.RevSharePercentage)) + if x.RevSharePercentage != 0 || math.Signbit(x.RevSharePercentage) { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(x.RevSharePercentage)))) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x19 } if len(x.Address) > 0 { i -= len(x.Address) @@ -2747,24 +2750,16 @@ func (x *fastReflection_ServiceRevenueShare) ProtoMethods() *protoiface.Methods x.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 0 { + if wireType != 1 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field RevSharePercentage", wireType) } - x.RevSharePercentage = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - x.RevSharePercentage |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } + var v uint64 + if (iNdEx + 8) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + x.RevSharePercentage = float64(math.Float64frombits(v)) default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -3603,8 +3598,8 @@ type ServiceRevenueShare struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the revenue share recipient - RevSharePercentage uint32 `protobuf:"varint,3,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` // The percentage of revenue share the recipient will receive + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the revenue share recipient + RevSharePercentage float64 `protobuf:"fixed64,3,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` // The percentage of revenue share the recipient will receive } func (x *ServiceRevenueShare) Reset() { @@ -3634,7 +3629,7 @@ func (x *ServiceRevenueShare) GetAddress() string { return "" } -func (x *ServiceRevenueShare) GetRevSharePercentage() uint32 { +func (x *ServiceRevenueShare) GetRevSharePercentage() float64 { if x != nil { return x.RevSharePercentage } @@ -3735,7 +3730,7 @@ var file_poktroll_shared_service_proto_rawDesc = []byte{ 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x30, 0x0a, 0x14, 0x72, 0x65, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x5f, 0x70, 0x65, - 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x12, + 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x12, 0x72, 0x65, 0x76, 0x53, 0x68, 0x61, 0x72, 0x65, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x22, 0x56, 0x0a, 0x0c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x30, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, diff --git a/api/poktroll/supplier/query.pulsar.go b/api/poktroll/supplier/query.pulsar.go index 270ce57f6..392f4aa39 100644 --- a/api/poktroll/supplier/query.pulsar.go +++ b/api/poktroll/supplier/query.pulsar.go @@ -2848,7 +2848,7 @@ type QueryGetSupplierRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` + OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` // TODO_TECHDEBT: Add the ability to query for a supplier by owner_id } func (x *QueryGetSupplierRequest) Reset() { diff --git a/localnet/poktrolld/config/config.toml b/localnet/poktrolld/config/config.toml index bbfa0366f..35dcda640 100644 --- a/localnet/poktrolld/config/config.toml +++ b/localnet/poktrolld/config/config.toml @@ -174,7 +174,7 @@ timeout_broadcast_tx_commit = "10s" max_request_batch_size = 10 # Maximum size of request body, in bytes -max_body_bytes = 1000000 +max_body_bytes = 100000000 # Maximum size of request header, in bytes max_header_bytes = 1048576 @@ -330,7 +330,7 @@ keep-invalid-txs-in-cache = false # Maximum size of a single transaction. # NOTE: the max size of a tx transmitted over the network is {max_tx_bytes}. -max_tx_bytes = 1048576 +max_tx_bytes = 100000000 # Maximum size of a batch of transactions to send to a peer # Including space needed by encoding (one varint per transaction). diff --git a/localnet/poktrolld/config/supplier1_stake_config.yaml b/localnet/poktrolld/config/supplier1_stake_config.yaml index 046fddb4c..e3d475939 100644 --- a/localnet/poktrolld/config/supplier1_stake_config.yaml +++ b/localnet/poktrolld/config/supplier1_stake_config.yaml @@ -2,8 +2,8 @@ owner_address: pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 operator_address: pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 stake_amount: 1000069upokt default_rev_share_percent: - pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4: 80 - pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw: 20 + pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4: 80.5 + pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw: 19.5 services: - service_id: anvil endpoints: diff --git a/localnet/poktrolld/config/supplier_stake_config_example.yaml b/localnet/poktrolld/config/supplier_stake_config_example.yaml index 2fef94f0b..ce14f4a08 100644 --- a/localnet/poktrolld/config/supplier_stake_config_example.yaml +++ b/localnet/poktrolld/config/supplier_stake_config_example.yaml @@ -30,8 +30,8 @@ stake_amount: 1000069upokt # or include at least one item. default_rev_share_percent: # The sum of all shares MUST equal 100%. Staking will fail otherwise. - pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4: 80 - pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw: 20 + pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4: 80.5 + pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw: 19.5 services: # The endpoint URL for the Anvil service is provided via the RelayMiner. # The RelayMiner acts as a proxy, forwarding requests to the actual Anvil data node behind it. diff --git a/proto/poktroll/shared/service.proto b/proto/poktroll/shared/service.proto index 6df07cdcb..8d400dd33 100644 --- a/proto/poktroll/shared/service.proto +++ b/proto/poktroll/shared/service.proto @@ -57,11 +57,11 @@ message SupplierEndpoint { // ServiceRevenueShare message to hold revenue share configuration details message ServiceRevenueShare { - // 2 was reserved in #1028 during the change of rev_share_percentage from float to uint32 + // 2 was reserved in #1028 during the change of rev_share_percentage from float to double reserved 2; string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the revenue share recipient - uint32 rev_share_percentage = 3; // The percentage of revenue share the recipient will receive + double rev_share_percentage = 3; // The percentage of revenue share the recipient will receive } // Enum to define RPC types diff --git a/proto/poktroll/supplier/query.proto b/proto/poktroll/supplier/query.proto index 585d9ad07..71de22f24 100644 --- a/proto/poktroll/supplier/query.proto +++ b/proto/poktroll/supplier/query.proto @@ -45,6 +45,7 @@ message QueryParamsResponse { message QueryGetSupplierRequest { string operator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // TODO_TECHDEBT: Add the ability to query for a supplier by owner_id } message QueryGetSupplierResponse { diff --git a/x/shared/types/service.pb.go b/x/shared/types/service.pb.go index fd0704264..b483b2743 100644 --- a/x/shared/types/service.pb.go +++ b/x/shared/types/service.pb.go @@ -7,6 +7,7 @@ package types import ( + encoding_binary "encoding/binary" fmt "fmt" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/gogoproto/gogoproto" @@ -320,8 +321,8 @@ func (m *SupplierEndpoint) GetConfigs() []*ConfigOption { // ServiceRevenueShare message to hold revenue share configuration details type ServiceRevenueShare struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - RevSharePercentage uint32 `protobuf:"varint,3,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + RevSharePercentage float64 `protobuf:"fixed64,3,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` } func (m *ServiceRevenueShare) Reset() { *m = ServiceRevenueShare{} } @@ -360,7 +361,7 @@ func (m *ServiceRevenueShare) GetAddress() string { return "" } -func (m *ServiceRevenueShare) GetRevSharePercentage() uint32 { +func (m *ServiceRevenueShare) GetRevSharePercentage() float64 { if m != nil { return m.RevSharePercentage } @@ -432,45 +433,45 @@ func init() { proto.RegisterFile("poktroll/shared/service.proto", fileDescriptor var fileDescriptor_302c2f793a11ae1e = []byte{ // 630 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcf, 0x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 0x77, 0xb4, - 0x3b, 0x83, 0xe8, 0xb0, 0x3b, 0x9a, 0x05, 0x8c, 0x96, 0x45, 0x60, 0xcb, 0x00, 0x9f, 0x42, 0xd9, - 0x4e, 0x8c, 0x08, 0x33, 0x71, 0x6b, 0x77, 0x6a, 0x52, 0xa3, 0x06, 0x81, 0x34, 0x9d, 0xe6, 0xec, - 0xe6, 0x3b, 0x02, 0xf7, 0x7e, 0x23, 0x1b, 0x3b, 0x50, 0xce, 0x6f, 0x97, 0xfc, 0xe5, 0x76, 0x73, - 0x22, 0x6e, 0x43, 0x63, 0xe1, 0x91, 0x5c, 0x25, 0x9b, 0xf9, 0x91, 0x35, 0x66, 0xc9, 0x2e, 0xd5, - 0x28, 0xe6, 0x46, 0x0c, 0x17, 0xc8, 0x61, 0xa9, 0x52, 0x54, 0x95, 0xe6, 0x2b, 0x58, 0xfe, 0x59, - 0x1c, 0x6e, 0x83, 0x72, 0xc1, 0x66, 0xc9, 0xdc, 0x7a, 0x47, 0xff, 0xe3, 0x41, 0x42, 0x2a, 0xa9, - 0xd8, 0x80, 0xff, 0xa6, 0x96, 0x17, 0xe7, 0xdb, 0x9d, 0x7e, 0x6c, 0x1e, 0x41, 0x39, 0x33, 0x0a, - 0x57, 0x60, 0xe9, 0xa4, 0x7f, 0xd4, 0x1f, 0x9c, 0xf6, 0x4d, 0x3a, 0xec, 0xaa, 0x05, 0xac, 0x40, - 0x69, 0x5f, 0x46, 0x04, 0x6b, 0x50, 0x3d, 0xed, 0xed, 0x19, 0x83, 0xee, 0x51, 0x6f, 0xa4, 0x16, - 0x71, 0x19, 0x2a, 0x87, 0xc6, 0x20, 0xa5, 0x29, 0x92, 0x46, 0x7b, 0xc6, 0x48, 0x2d, 0x6d, 0x6e, - 0x43, 0xed, 0x97, 0xc1, 0x88, 0x50, 0xcf, 0x5b, 0x76, 0x07, 0xfd, 0x97, 0x07, 0xfb, 0x6a, 0x01, - 0x97, 0xa0, 0x3c, 0x3a, 0x38, 0xee, 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28, 0x0f, 0x0f, 0x4f, 0xba, 0xfd, 0xd3, 0xa1, 0x4a, 0xf6, 0x4f, 0xbe, 0xcc, 0x74, 0x72, + 0x3d, 0xd3, 0xc9, 0xcd, 0x4c, 0x27, 0xdf, 0x66, 0x3a, 0x79, 0x7f, 0xab, 0x17, 0xae, 0x6f, 0xf5, + 0xc2, 0xcd, 0xad, 0x5e, 0x78, 0xdd, 0x1a, 0xb9, 0xd1, 0x45, 0x7c, 0xde, 0xb4, 0xf9, 0xb8, 0x25, + 0x4f, 0xb8, 0xed, 0xb3, 0xe8, 0x8a, 0x8b, 0xcb, 0xd6, 0xfc, 0x91, 0x78, 0x9b, 0x3f, 0x13, 0x72, + 0x15, 0xc2, 0xf3, 0xff, 0x93, 0x7f, 0x7c, 0xf7, 0x7b, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1e, 0x46, + 0x55, 0xcc, 0x46, 0x04, 0x00, 0x00, } func (m *Service) Marshal() (dAtA []byte, err error) { @@ -680,9 +681,10 @@ func (m *ServiceRevenueShare) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if m.RevSharePercentage != 0 { - i = encodeVarintService(dAtA, i, uint64(m.RevSharePercentage)) + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.RevSharePercentage)))) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x19 } if len(m.Address) > 0 { i -= len(m.Address) @@ -835,7 +837,7 @@ func (m *ServiceRevenueShare) Size() (n int) { n += 1 + l + sovService(uint64(l)) } if m.RevSharePercentage != 0 { - n += 1 + sovService(uint64(m.RevSharePercentage)) + n += 9 } return n } @@ -1456,24 +1458,16 @@ func (m *ServiceRevenueShare) Unmarshal(dAtA []byte) error { m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 0 { + if wireType != 1 { return fmt.Errorf("proto: wrong wireType = %d for field RevSharePercentage", wireType) } - m.RevSharePercentage = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RevSharePercentage |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.RevSharePercentage = float64(math.Float64frombits(v)) default: iNdEx = preIndex skippy, err := skipService(dAtA[iNdEx:]) diff --git a/x/shared/types/service_configs.go b/x/shared/types/service_configs.go index 30e4cb7ae..019f8f442 100644 --- a/x/shared/types/service_configs.go +++ b/x/shared/types/service_configs.go @@ -95,7 +95,7 @@ func ValidateSupplierServiceConfigs(services []*SupplierServiceConfig) error { // ensuring that the sum of the revenue share percentages is 100. // NB: This function is unit tested via the supplier staking config tests. func ValidateServiceRevShare(revShareList []*ServiceRevenueShare) error { - revSharePercentageSum := uint32(0) + revSharePercentageSum := float64(0) if len(revShareList) == 0 { return ErrSharedInvalidRevShare.Wrap("no rev share configurations") diff --git a/x/supplier/config/supplier_configs_reader.go b/x/supplier/config/supplier_configs_reader.go index fc956f9c6..e07cc68c7 100644 --- a/x/supplier/config/supplier_configs_reader.go +++ b/x/supplier/config/supplier_configs_reader.go @@ -19,14 +19,14 @@ type YAMLStakeConfig struct { OperatorAddress string `yaml:"operator_address"` StakeAmount string `yaml:"stake_amount"` Services []*YAMLStakeService `yaml:"services"` - DefaultRevSharePercent map[string]uint32 `yaml:"default_rev_share_percent"` + DefaultRevSharePercent map[string]float64 `yaml:"default_rev_share_percent"` } // YAMLStakeService is the structure describing a single service entry in the // stake config file. type YAMLStakeService struct { ServiceId string `yaml:"service_id"` - RevSharePercent map[string]uint32 `yaml:"rev_share_percent"` + RevSharePercent map[string]float64 `yaml:"rev_share_percent"` Endpoints []YAMLServiceEndpoint `yaml:"endpoints"` } @@ -102,7 +102,7 @@ func ParseSupplierConfigs(ctx context.Context, configContent []byte) (*SupplierS ) } - defaultRevSharePercent := map[string]uint32{} + defaultRevSharePercent := map[string]float64{} if len(stakeConfig.DefaultRevSharePercent) == 0 { // Ensure that if no default rev share is provided, the owner address is set // to 100% rev share. diff --git a/x/supplier/keeper/query_supplier_test.go b/x/supplier/keeper/query_supplier_test.go index 93e57f6f4..8e3e240c1 100644 --- a/x/supplier/keeper/query_supplier_test.go +++ b/x/supplier/keeper/query_supplier_test.go @@ -71,7 +71,7 @@ func TestSupplierQuerySingle(t *testing.T) { func TestSupplierQueryPaginated(t *testing.T) { supplierModuleKeepers, ctx := keepertest.SupplierKeeper(t) - msgs := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 5) + suppliers := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 5) request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllSuppliersRequest { return &types.QueryAllSuppliersRequest{ @@ -85,12 +85,12 @@ func TestSupplierQueryPaginated(t *testing.T) { } t.Run("ByOffset", func(t *testing.T) { step := 2 - for i := 0; i < len(msgs); i += step { + for i := 0; i < len(suppliers); i += step { resp, err := supplierModuleKeepers.AllSuppliers(ctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.Supplier), step) require.Subset(t, - nullify.Fill(msgs), + nullify.Fill(suppliers), nullify.Fill(resp.Supplier), ) } @@ -98,12 +98,12 @@ func TestSupplierQueryPaginated(t *testing.T) { t.Run("ByKey", func(t *testing.T) { step := 2 var next []byte - for i := 0; i < len(msgs); i += step { + for i := 0; i < len(suppliers); i += step { resp, err := supplierModuleKeepers.AllSuppliers(ctx, request(next, 0, uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.Supplier), step) require.Subset(t, - nullify.Fill(msgs), + nullify.Fill(suppliers), nullify.Fill(resp.Supplier), ) next = resp.Pagination.NextKey @@ -112,9 +112,9 @@ func TestSupplierQueryPaginated(t *testing.T) { t.Run("Total", func(t *testing.T) { resp, err := supplierModuleKeepers.AllSuppliers(ctx, request(nil, 0, 0, true)) require.NoError(t, err) - require.Equal(t, len(msgs), int(resp.Pagination.Total)) + require.Equal(t, len(suppliers), int(resp.Pagination.Total)) require.ElementsMatch(t, - nullify.Fill(msgs), + nullify.Fill(suppliers), nullify.Fill(resp.Supplier), ) }) @@ -126,17 +126,17 @@ func TestSupplierQueryPaginated(t *testing.T) { func TestSupplierQueryFilterByServiceId(t *testing.T) { supplierModuleKeepers, ctx := keepertest.SupplierKeeper(t) - msgs := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 5) + suppliers := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 5) // Get the first service ID from the first supplier to use as filter - firstServiceId := msgs[0].Services[0].ServiceId + firstServiceId := suppliers[0].Services[0].ServiceId request := &types.QueryAllSuppliersRequest{ Filter: &types.QueryAllSuppliersRequest_ServiceId{ ServiceId: firstServiceId, }, Pagination: &query.PageRequest{ - Limit: uint64(len(msgs)), + Limit: uint64(len(suppliers)), }, } diff --git a/x/supplier/module/autocli.go b/x/supplier/module/autocli.go index 50ff57418..2463a57a1 100644 --- a/x/supplier/module/autocli.go +++ b/x/supplier/module/autocli.go @@ -41,7 +41,7 @@ Returns supplier addresses, staked amounts, service details, and current status. { Alias: []string{"supplier", "s"}, RpcMethod: "Supplier", - Use: "show-supplier [address]", + Use: "show-supplier [operator_address]", Short: "Shows detailed information about a specific supplier", Long: `Retrieves comprehensive information about a supplier identified by their address. diff --git a/x/tokenomics/keeper/token_logic_modules_test.go b/x/tokenomics/keeper/token_logic_modules_test.go index b70d32608..6cfb1cd08 100644 --- a/x/tokenomics/keeper/token_logic_modules_test.go +++ b/x/tokenomics/keeper/token_logic_modules_test.go @@ -45,7 +45,7 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Valid(t *testing.T) { // Test Parameters appInitialStake := apptypes.DefaultMinStake.Amount.Mul(cosmosmath.NewInt(2)) supplierInitialStake := cosmosmath.NewInt(1000000) - supplierRevShareRatios := []float32{12.5, 37.5, 50} + supplierRevShareRatios := []float64{12.5, 37.5, 50} globalComputeUnitsToTokensMultiplier := uint64(1) serviceComputeUnitsPerRelay := uint64(1) service := prepareTestService(serviceComputeUnitsPerRelay) @@ -447,7 +447,7 @@ func TestProcessTokenLogicModules_TLMGlobalMint_Valid_MintDistributionCorrect(t propMint := cosmosmath.NewInt(int64(numTokensMinted * tokenomicsParams.MintAllocationPercentages.Proposer)) serviceOwnerMint := cosmosmath.NewInt(int64(numTokensMinted * tokenomicsParams.MintAllocationPercentages.SourceOwner)) appMint := cosmosmath.NewInt(int64(numTokensMinted * tokenomicsParams.MintAllocationPercentages.Application)) - supplierMint := float32(numTokensMinted * tokenomicsParams.MintAllocationPercentages.Supplier) + supplierMint := float64(numTokensMinted * tokenomicsParams.MintAllocationPercentages.Supplier) // Ensure the balance was increased to the appropriate amount. require.Equal(t, daoBalanceBefore.Amount.Add(daoMint).Add(numTokensMintedInt), daoBalanceAfter.Amount) @@ -459,7 +459,7 @@ func TestProcessTokenLogicModules_TLMGlobalMint_Valid_MintDistributionCorrect(t balanceBefore := supplierShareholderBalancesBefore[addr] balanceAfter := supplierShareholderBalancesAfter[addr].Amount.Int64() mintShare := int64(supplierMint * revShare.RevSharePercentage / 100) - rewardShare := int64(float32(numTokensClaimed) * revShare.RevSharePercentage / 100) + rewardShare := int64(float64(numTokensClaimed) * revShare.RevSharePercentage / 100) balanceIncrease := cosmosmath.NewInt(mintShare + rewardShare) expectedBalanceAfter := balanceBefore.Amount.Add(balanceIncrease).Int64() // TODO_MAINNET(@red-0ne): Remove the InDelta check and use the exact amount once the floating point arithmetic is fixed From aa9cd01031f828fc55fd7c9c517f3b4c721c6e03 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Fri, 17 Jan 2025 10:58:47 -0500 Subject: [PATCH 13/24] Fix unit tests and docs --- docusaurus/docs/operate/user_guide/check-balance.md | 2 +- docusaurus/docs/operate/user_guide/create-new-wallet.md | 2 +- docusaurus/docs/operate/user_guide/recover-with-mnemonic.md | 2 +- docusaurus/docs/operate/user_guide/send-tokens.md | 2 +- x/tokenomics/keeper/token_logic_modules_test.go | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docusaurus/docs/operate/user_guide/check-balance.md b/docusaurus/docs/operate/user_guide/check-balance.md index 98557295a..60897ca22 100644 --- a/docusaurus/docs/operate/user_guide/check-balance.md +++ b/docusaurus/docs/operate/user_guide/check-balance.md @@ -26,7 +26,7 @@ balance using the `poktrolld` command-line interface (CLI). ## Pre-requisites -1. `poktrolld` is installed on your system; see the [installation guide](./install) for more details +1. `poktrolld` is installed on your system; see the [installation guide](./poktrolld_cli.md) for more details 2. You have the address of the wallet you wish to check 3. You know the token denomination you wish to check; `upokt` for POKT tokens diff --git a/docusaurus/docs/operate/user_guide/create-new-wallet.md b/docusaurus/docs/operate/user_guide/create-new-wallet.md index 8df204d14..d5444dce7 100644 --- a/docusaurus/docs/operate/user_guide/create-new-wallet.md +++ b/docusaurus/docs/operate/user_guide/create-new-wallet.md @@ -51,7 +51,7 @@ refer to the [Cosmos SDK Keyring documentation](https://docs.cosmos.network/main Ensure you have `poktrolld` installed on your system. -Follow the [installation guide](./install) specific to your operating system. +Follow the [installation guide](./poktrolld_cli.md) specific to your operating system. ## Step 2: Creating the Wallet diff --git a/docusaurus/docs/operate/user_guide/recover-with-mnemonic.md b/docusaurus/docs/operate/user_guide/recover-with-mnemonic.md index ca561ec80..6343667f9 100644 --- a/docusaurus/docs/operate/user_guide/recover-with-mnemonic.md +++ b/docusaurus/docs/operate/user_guide/recover-with-mnemonic.md @@ -24,7 +24,7 @@ seed phrase, recovering your account is straightforward! ## Pre-requisites - You have the mnemonic seed phrase of the wallet you wish to recover -- `poktrolld` is installed on your system; see the [installation guide](./install) for more details +- `poktrolld` is installed on your system; see the [installation guide](./poktrolld_cli.md) for more details ## Step 1: Prepare to Recover Your Wallet diff --git a/docusaurus/docs/operate/user_guide/send-tokens.md b/docusaurus/docs/operate/user_guide/send-tokens.md index dbff2914d..6d3c5676c 100644 --- a/docusaurus/docs/operate/user_guide/send-tokens.md +++ b/docusaurus/docs/operate/user_guide/send-tokens.md @@ -17,7 +17,7 @@ Pocket Network using the `poktrolld` command-line interface (CLI). ## Pre-requisites -1. `poktrolld` is installed on your system; see the [installation guide](./install) for more details +1. `poktrolld` is installed on your system; see the [installation guide](./poktrolld_cli.md) for more details 2. You have access to your wallet with sufficient tokens for the transaction and fees 3. You have the recipient's address diff --git a/x/tokenomics/keeper/token_logic_modules_test.go b/x/tokenomics/keeper/token_logic_modules_test.go index 6cfb1cd08..9f955e735 100644 --- a/x/tokenomics/keeper/token_logic_modules_test.go +++ b/x/tokenomics/keeper/token_logic_modules_test.go @@ -185,7 +185,7 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Valid_SupplierExceedsMaxClai service := prepareTestService(serviceComputeUnitsPerRelay) numRelays := uint64(1000) // By a single supplier for application in this session supplierInitialStake := cosmosmath.NewInt(1000000) - supplierRevShareRatios := []float32{12.5, 37.5, 50} + supplierRevShareRatios := []float64{12.5, 37.5, 50} // Prepare the keepers keepers, ctx := testkeeper.NewTokenomicsModuleKeepers(t, @@ -338,7 +338,7 @@ func TestProcessTokenLogicModules_TLMGlobalMint_Valid_MintDistributionCorrect(t // Test Parameters appInitialStake := apptypes.DefaultMinStake.Amount.Mul(cosmosmath.NewInt(2)) supplierInitialStake := cosmosmath.NewInt(1000000) - supplierRevShareRatios := []float32{12.5, 37.5, 50} + supplierRevShareRatios := []float64{12.5, 37.5, 50} globalComputeUnitsToTokensMultiplier := uint64(1) serviceComputeUnitsPerRelay := uint64(1) service := prepareTestService(serviceComputeUnitsPerRelay) From 527f1500408b690d8fd94975932b783df5e92a42 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Fri, 17 Jan 2025 11:22:34 -0500 Subject: [PATCH 14/24] Fix unit test --- x/service/keeper/query_service_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/service/keeper/query_service_test.go b/x/service/keeper/query_service_test.go index 7f2ab0584..02d123f36 100644 --- a/x/service/keeper/query_service_test.go +++ b/x/service/keeper/query_service_test.go @@ -43,9 +43,9 @@ func TestServiceQuerySingle(t *testing.T) { { desc: "KeyNotFound", request: &types.QueryGetServiceRequest{ - Id: strconv.Itoa(100000), + Id: "service", }, - expectedErr: status.Error(codes.NotFound, "service ID not found"), + expectedErr: status.Error(codes.NotFound, "service ID not found: \"service\""), }, { desc: "InvalidRequest", From 0643ea0ca569e78c47742513729fc13f8e520873 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Fri, 17 Jan 2025 12:15:32 -0500 Subject: [PATCH 15/24] CLI nits --- x/supplier/module/autocli.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/x/supplier/module/autocli.go b/x/supplier/module/autocli.go index 2463a57a1..a64176dd8 100644 --- a/x/supplier/module/autocli.go +++ b/x/supplier/module/autocli.go @@ -21,22 +21,20 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { { Alias: []string{"suppliers", "ls"}, RpcMethod: "AllSuppliers", - Use: "list-suppliers [service-id]", + Use: "list-suppliers", Short: "List all suppliers on Pocket Network", Long: `Retrieves a paginated list of all suppliers currently registered on Pocket Network, including all their details. The command supports optional filtering by service ID and pagination parameters. Returns supplier addresses, staked amounts, service details, and current status.`, - Example: ` - poktrolld query supplier list-suppliers + Example: ` poktrolld query supplier list-suppliers poktrolld query supplier list-suppliers --service-id anvil poktrolld query supplier list-suppliers --page 2 --limit 50 poktrolld query supplier list-suppliers --service-id anvil --page 1 --limit 100`, FlagOptions: map[string]*autocliv1.FlagOptions{ "service_id": {Name: "service-id", Shorthand: "s", Usage: "service id to filter by", Hidden: false}, }, - // PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "service_id"}}, }, { Alias: []string{"supplier", "s"}, @@ -49,9 +47,7 @@ Returns details include things like: - Supplier's staked amount and status - List of services they provide`, - Example: ` - - poktrolld query supplier show-supplier pokt1abc...xyz + Example: ` poktrolld query supplier show-supplier pokt1abc...xyz poktrolld query supplier show-supplier pokt1abc...xyz --output json poktrolld query supplier show-supplier pokt1abc...xyz --height 100`, PositionalArgs: []*autocliv1.PositionalArgDescriptor{ From 389f24ab1527517f24cec6954ce900eaef2a71cc Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Fri, 17 Jan 2025 13:00:05 -0500 Subject: [PATCH 16/24] Reverted back to uin64 for rev_share --- api/poktroll/shared/service.pulsar.go | 57 ++++++++-------- config.yml | 6 +- .../config/supplier1_stake_config.yaml | 4 +- .../config/supplier_stake_config_example.yaml | 4 +- proto/poktroll/shared/service.proto | 5 +- testutil/integration/app.go | 2 +- testutil/keeper/tokenomics.go | 2 +- x/shared/types/service.pb.go | 66 ++++++++++--------- x/shared/types/service_configs.go | 6 +- x/supplier/config/supplier_configs_reader.go | 6 +- .../config/supplier_configs_reader_test.go | 26 ++------ .../keeper/token_logic_modules_test.go | 10 +-- .../token_logic_module/distribution.go | 2 +- 13 files changed, 95 insertions(+), 101 deletions(-) diff --git a/api/poktroll/shared/service.pulsar.go b/api/poktroll/shared/service.pulsar.go index 131bf6936..a923eda0b 100644 --- a/api/poktroll/shared/service.pulsar.go +++ b/api/poktroll/shared/service.pulsar.go @@ -2,7 +2,6 @@ package shared import ( - binary "encoding/binary" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" @@ -11,7 +10,6 @@ import ( protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" io "io" - math "math" reflect "reflect" sync "sync" ) @@ -2418,8 +2416,8 @@ func (x *fastReflection_ServiceRevenueShare) Range(f func(protoreflect.FieldDesc return } } - if x.RevSharePercentage != float64(0) || math.Signbit(x.RevSharePercentage) { - value := protoreflect.ValueOfFloat64(x.RevSharePercentage) + if x.RevSharePercentage != uint64(0) { + value := protoreflect.ValueOfUint64(x.RevSharePercentage) if !f(fd_ServiceRevenueShare_rev_share_percentage, value) { return } @@ -2442,7 +2440,7 @@ func (x *fastReflection_ServiceRevenueShare) Has(fd protoreflect.FieldDescriptor case "poktroll.shared.ServiceRevenueShare.address": return x.Address != "" case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": - return x.RevSharePercentage != float64(0) || math.Signbit(x.RevSharePercentage) + return x.RevSharePercentage != uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2462,7 +2460,7 @@ func (x *fastReflection_ServiceRevenueShare) Clear(fd protoreflect.FieldDescript case "poktroll.shared.ServiceRevenueShare.address": x.Address = "" case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": - x.RevSharePercentage = float64(0) + x.RevSharePercentage = uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2484,7 +2482,7 @@ func (x *fastReflection_ServiceRevenueShare) Get(descriptor protoreflect.FieldDe return protoreflect.ValueOfString(value) case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": value := x.RevSharePercentage - return protoreflect.ValueOfFloat64(value) + return protoreflect.ValueOfUint64(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2508,7 +2506,7 @@ func (x *fastReflection_ServiceRevenueShare) Set(fd protoreflect.FieldDescriptor case "poktroll.shared.ServiceRevenueShare.address": x.Address = value.Interface().(string) case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": - x.RevSharePercentage = value.Float() + x.RevSharePercentage = value.Uint() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2549,7 +2547,7 @@ func (x *fastReflection_ServiceRevenueShare) NewField(fd protoreflect.FieldDescr case "poktroll.shared.ServiceRevenueShare.address": return protoreflect.ValueOfString("") case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": - return protoreflect.ValueOfFloat64(float64(0)) + return protoreflect.ValueOfUint64(uint64(0)) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2623,8 +2621,8 @@ func (x *fastReflection_ServiceRevenueShare) ProtoMethods() *protoiface.Methods if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } - if x.RevSharePercentage != 0 || math.Signbit(x.RevSharePercentage) { - n += 9 + if x.RevSharePercentage != 0 { + n += 1 + runtime.Sov(uint64(x.RevSharePercentage)) } if x.unknownFields != nil { n += len(x.unknownFields) @@ -2655,11 +2653,10 @@ func (x *fastReflection_ServiceRevenueShare) ProtoMethods() *protoiface.Methods i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if x.RevSharePercentage != 0 || math.Signbit(x.RevSharePercentage) { - i -= 8 - binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(x.RevSharePercentage)))) + if x.RevSharePercentage != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.RevSharePercentage)) i-- - dAtA[i] = 0x19 + dAtA[i] = 0x18 } if len(x.Address) > 0 { i -= len(x.Address) @@ -2750,16 +2747,24 @@ func (x *fastReflection_ServiceRevenueShare) ProtoMethods() *protoiface.Methods x.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 1 { + if wireType != 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field RevSharePercentage", wireType) } - var v uint64 - if (iNdEx + 8) > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + x.RevSharePercentage = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.RevSharePercentage |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } } - v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - x.RevSharePercentage = float64(math.Float64frombits(v)) default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -3598,8 +3603,8 @@ type ServiceRevenueShare struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the revenue share recipient - RevSharePercentage float64 `protobuf:"fixed64,3,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` // The percentage of revenue share the recipient will receive + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the revenue share recipient + RevSharePercentage uint64 `protobuf:"varint,3,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` // The percentage of revenue share the recipient will receive } func (x *ServiceRevenueShare) Reset() { @@ -3629,7 +3634,7 @@ func (x *ServiceRevenueShare) GetAddress() string { return "" } -func (x *ServiceRevenueShare) GetRevSharePercentage() float64 { +func (x *ServiceRevenueShare) GetRevSharePercentage() uint64 { if x != nil { return x.RevSharePercentage } @@ -3730,7 +3735,7 @@ var file_poktroll_shared_service_proto_rawDesc = []byte{ 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x30, 0x0a, 0x14, 0x72, 0x65, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x5f, 0x70, 0x65, - 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x12, + 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x12, 0x72, 0x65, 0x76, 0x53, 0x68, 0x61, 0x72, 0x65, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x22, 0x56, 0x0a, 0x0c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x30, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, diff --git a/config.yml b/config.yml index 5be451816..cbd3fbe25 100644 --- a/config.yml +++ b/config.yml @@ -229,7 +229,7 @@ genesis: url: http://relayminer1:8545 rev_share: - address: pokt19a3t4yunp0dlpfjrp7qwnzwlrzd5fzs2gjaaaj - rev_share_percentage: "100" + rev_share_percentage: 100 - service_id: rest endpoints: - configs: [] @@ -237,7 +237,7 @@ genesis: url: http://relayminer1:8545 rev_share: - address: pokt19a3t4yunp0dlpfjrp7qwnzwlrzd5fzs2gjaaaj - rev_share_percentage: "100" + rev_share_percentage: 100 - service_id: ollama endpoints: - configs: [] @@ -245,7 +245,7 @@ genesis: url: http://relayminer1:8545 rev_share: - address: pokt19a3t4yunp0dlpfjrp7qwnzwlrzd5fzs2gjaaaj - rev_share_percentage: "100" + rev_share_percentage: 100 stake: # NB: This value should be exactly 1upokt smaller than the value in # `supplier1_stake_config.yaml` so that the stake command causes a state change. diff --git a/localnet/poktrolld/config/supplier1_stake_config.yaml b/localnet/poktrolld/config/supplier1_stake_config.yaml index e3d475939..046fddb4c 100644 --- a/localnet/poktrolld/config/supplier1_stake_config.yaml +++ b/localnet/poktrolld/config/supplier1_stake_config.yaml @@ -2,8 +2,8 @@ owner_address: pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 operator_address: pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 stake_amount: 1000069upokt default_rev_share_percent: - pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4: 80.5 - pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw: 19.5 + pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4: 80 + pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw: 20 services: - service_id: anvil endpoints: diff --git a/localnet/poktrolld/config/supplier_stake_config_example.yaml b/localnet/poktrolld/config/supplier_stake_config_example.yaml index ce14f4a08..2fef94f0b 100644 --- a/localnet/poktrolld/config/supplier_stake_config_example.yaml +++ b/localnet/poktrolld/config/supplier_stake_config_example.yaml @@ -30,8 +30,8 @@ stake_amount: 1000069upokt # or include at least one item. default_rev_share_percent: # The sum of all shares MUST equal 100%. Staking will fail otherwise. - pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4: 80.5 - pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw: 19.5 + pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4: 80 + pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw: 20 services: # The endpoint URL for the Anvil service is provided via the RelayMiner. # The RelayMiner acts as a proxy, forwarding requests to the actual Anvil data node behind it. diff --git a/proto/poktroll/shared/service.proto b/proto/poktroll/shared/service.proto index 8d400dd33..9a5cdd470 100644 --- a/proto/poktroll/shared/service.proto +++ b/proto/poktroll/shared/service.proto @@ -57,11 +57,12 @@ message SupplierEndpoint { // ServiceRevenueShare message to hold revenue share configuration details message ServiceRevenueShare { - // 2 was reserved in #1028 during the change of rev_share_percentage from float to double + // 2 was reserved in #1028 during the change of rev_share_percentage from float to uint64 + // TODO_TECHDEBT: Investigate why we can't use a double or float: https://github.com/pokt-network/poktroll/actions/runs/12832899448/job/35787150432?pr=1028 reserved 2; string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the revenue share recipient - double rev_share_percentage = 3; // The percentage of revenue share the recipient will receive + uint64 rev_share_percentage = 3; // The percentage of revenue share the recipient will receive } // Enum to define RPC types diff --git a/testutil/integration/app.go b/testutil/integration/app.go index 25d0a0c6e..04305089a 100644 --- a/testutil/integration/app.go +++ b/testutil/integration/app.go @@ -908,7 +908,7 @@ func (app *App) setupDefaultActorsState( RevShare: []*sharedtypes.ServiceRevenueShare{ { Address: sample.AccAddress(), - RevSharePercentage: 100, + RevSharePercentage: uint64(100), }, }, ServiceId: defaultService.Id, diff --git a/testutil/keeper/tokenomics.go b/testutil/keeper/tokenomics.go index 626aa5b11..31f5dc53a 100644 --- a/testutil/keeper/tokenomics.go +++ b/testutil/keeper/tokenomics.go @@ -146,7 +146,7 @@ func TokenomicsKeeperWithActorAddrs(t testing.TB) ( RevShare: []*sharedtypes.ServiceRevenueShare{ { Address: supplierOwnerAddr, - RevSharePercentage: 100, + RevSharePercentage: uint64(100), }, }, }, diff --git a/x/shared/types/service.pb.go b/x/shared/types/service.pb.go index b483b2743..6da21cd5f 100644 --- a/x/shared/types/service.pb.go +++ b/x/shared/types/service.pb.go @@ -7,7 +7,6 @@ package types import ( - encoding_binary "encoding/binary" fmt "fmt" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/gogoproto/gogoproto" @@ -321,8 +320,8 @@ func (m *SupplierEndpoint) GetConfigs() []*ConfigOption { // ServiceRevenueShare message to hold revenue share configuration details type ServiceRevenueShare struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - RevSharePercentage float64 `protobuf:"fixed64,3,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + RevSharePercentage uint64 `protobuf:"varint,3,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` } func (m *ServiceRevenueShare) Reset() { *m = ServiceRevenueShare{} } @@ -361,7 +360,7 @@ func (m *ServiceRevenueShare) GetAddress() string { return "" } -func (m *ServiceRevenueShare) GetRevSharePercentage() float64 { +func (m *ServiceRevenueShare) GetRevSharePercentage() uint64 { if m != nil { return m.RevSharePercentage } @@ -431,7 +430,7 @@ func init() { func init() { proto.RegisterFile("poktroll/shared/service.proto", fileDescriptor_302c2f793a11ae1e) } var fileDescriptor_302c2f793a11ae1e = []byte{ - // 630 bytes of a gzipped FileDescriptorProto + // 628 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcf, 0x6e, 0xd3, 0x4e, 0x10, 0xce, 0xc6, 0xf9, 0xfd, 0x92, 0x4c, 0xdb, 0xd4, 0x1a, 0x82, 0x30, 0x95, 0x6a, 0x95, 0x88, 0x43, 0x55, 0xa9, 0x49, 0x95, 0x0a, 0x21, 0x0e, 0x08, 0xb5, 0x51, 0xa8, 0xda, 0xaa, 0x49, 0xb4, @@ -458,20 +457,20 @@ var fileDescriptor_302c2f793a11ae1e = []byte{ 0x85, 0x41, 0x74, 0xd0, 0x19, 0x4e, 0x03, 0x46, 0xcb, 0x22, 0xb0, 0x65, 0x80, 0x4f, 0xa1, 0x6c, 0x27, 0x46, 0x84, 0x99, 0xb8, 0xf5, 0x85, 0x9a, 0xd4, 0xa8, 0x7e, 0x20, 0x4d, 0xa7, 0x39, 0xbb, 0xf1, 0x8e, 0xc0, 0xbd, 0xdf, 0xc8, 0xc6, 0x36, 0x94, 0xf3, 0xdb, 0x25, 0x7f, 0xb9, 0xdd, 0x9c, - 0x88, 0x3b, 0x50, 0x9f, 0x7b, 0x24, 0x57, 0xc9, 0x66, 0x7e, 0x64, 0x8d, 0x58, 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xc2, 0xf3, 0xff, 0x93, 0x7f, 0x7c, 0xf7, 0x7b, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1e, 0x46, - 0x55, 0xcc, 0x46, 0x04, 0x00, 0x00, + 0x88, 0x3b, 0x50, 0x9f, 0x7b, 0x24, 0x57, 0xc9, 0x66, 0x7e, 0x64, 0x8d, 0x58, 0xb6, 0x4b, 0x98, + 0x1b, 0x31, 0x98, 0x23, 0x47, 0xa5, 0x4a, 0x51, 0x55, 0x1a, 0xaf, 0x60, 0xf9, 0x67, 0x71, 0xb8, + 0x03, 0xca, 0x25, 0x9b, 0x26, 0x73, 0x6b, 0x6d, 0xfd, 0x8f, 0x07, 0x09, 0xa9, 0xa4, 0x62, 0x1d, + 0xfe, 0x9b, 0x58, 0x5e, 0x9c, 0x6f, 0x77, 0xfa, 0xb1, 0x75, 0x0c, 0xe5, 0xcc, 0x28, 0x5c, 0x85, + 0xa5, 0xd3, 0xde, 0x71, 0xaf, 0x7f, 0xd6, 0x33, 0xe9, 0xa0, 0xa3, 0x16, 0xb0, 0x02, 0xa5, 0x03, + 0x19, 0x11, 0x5c, 0x81, 0xea, 0x59, 0x77, 0xdf, 0xe8, 0x77, 0x8e, 0xbb, 0x43, 0xb5, 0x88, 0xcb, + 0x50, 0x39, 0x32, 0xfa, 0x29, 0x4d, 0x91, 0x34, 0xda, 0x35, 0x86, 0x6a, 0x69, 0x6b, 0x07, 0x56, + 0x7e, 0x19, 0x8c, 0x08, 0xb5, 0xbc, 0x65, 0xa7, 0xdf, 0x7b, 0x79, 0x78, 0xa0, 0x16, 0x70, 0x09, + 0xca, 0xc3, 0xc3, 0x93, 0x6e, 0xff, 0x74, 0xa8, 0x92, 0xfd, 0x93, 0x2f, 0x33, 0x9d, 0x5c, 0xcf, + 0x74, 0x72, 0x33, 0xd3, 0xc9, 0xb7, 0x99, 0x4e, 0xde, 0xdf, 0xea, 0x85, 0xeb, 0x5b, 0xbd, 0x70, + 0x73, 0xab, 0x17, 0x5e, 0xb7, 0x46, 0x6e, 0x74, 0x11, 0x9f, 0x37, 0x6d, 0x3e, 0x6e, 0xc9, 0x13, + 0x6e, 0xfb, 0x2c, 0xba, 0xe2, 0xe2, 0xb2, 0x35, 0x7f, 0x24, 0xde, 0xe6, 0xcf, 0x84, 0x5c, 0x85, + 0xf0, 0xfc, 0xff, 0xe4, 0x1f, 0xdf, 0xfd, 0x1e, 0x00, 0x00, 0xff, 0xff, 0x46, 0xaf, 0x53, 0xa2, + 0x46, 0x04, 0x00, 0x00, } func (m *Service) Marshal() (dAtA []byte, err error) { @@ -681,10 +680,9 @@ func (m *ServiceRevenueShare) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if m.RevSharePercentage != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.RevSharePercentage)))) + i = encodeVarintService(dAtA, i, uint64(m.RevSharePercentage)) i-- - dAtA[i] = 0x19 + dAtA[i] = 0x18 } if len(m.Address) > 0 { i -= len(m.Address) @@ -837,7 +835,7 @@ func (m *ServiceRevenueShare) Size() (n int) { n += 1 + l + sovService(uint64(l)) } if m.RevSharePercentage != 0 { - n += 9 + n += 1 + sovService(uint64(m.RevSharePercentage)) } return n } @@ -1458,16 +1456,24 @@ func (m *ServiceRevenueShare) Unmarshal(dAtA []byte) error { m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 1 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field RevSharePercentage", wireType) } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF + m.RevSharePercentage = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RevSharePercentage |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.RevSharePercentage = float64(math.Float64frombits(v)) default: iNdEx = preIndex skippy, err := skipService(dAtA[iNdEx:]) diff --git a/x/shared/types/service_configs.go b/x/shared/types/service_configs.go index 019f8f442..bcfb3935e 100644 --- a/x/shared/types/service_configs.go +++ b/x/shared/types/service_configs.go @@ -7,7 +7,7 @@ import ( ) const ( - requiredRevSharePercentageSum = 100 + requiredRevSharePercentageSum = uint64(100) ) // ValidateAppServiceConfigs returns an error if any of the application service configs are invalid @@ -95,7 +95,7 @@ func ValidateSupplierServiceConfigs(services []*SupplierServiceConfig) error { // ensuring that the sum of the revenue share percentages is 100. // NB: This function is unit tested via the supplier staking config tests. func ValidateServiceRevShare(revShareList []*ServiceRevenueShare) error { - revSharePercentageSum := float64(0) + revSharePercentageSum := uint64(0) if len(revShareList) == 0 { return ErrSharedInvalidRevShare.Wrap("no rev share configurations") @@ -106,7 +106,7 @@ func ValidateServiceRevShare(revShareList []*ServiceRevenueShare) error { return ErrSharedInvalidRevShare.Wrap("rev share cannot be nil") } - // Validate the revshare address + // Validate the revenue share address if revShare.Address == "" { return ErrSharedInvalidRevShare.Wrapf("rev share address cannot be empty: %v", revShare) } diff --git a/x/supplier/config/supplier_configs_reader.go b/x/supplier/config/supplier_configs_reader.go index e07cc68c7..6c604677e 100644 --- a/x/supplier/config/supplier_configs_reader.go +++ b/x/supplier/config/supplier_configs_reader.go @@ -19,14 +19,14 @@ type YAMLStakeConfig struct { OperatorAddress string `yaml:"operator_address"` StakeAmount string `yaml:"stake_amount"` Services []*YAMLStakeService `yaml:"services"` - DefaultRevSharePercent map[string]float64 `yaml:"default_rev_share_percent"` + DefaultRevSharePercent map[string]uint64 `yaml:"default_rev_share_percent"` } // YAMLStakeService is the structure describing a single service entry in the // stake config file. type YAMLStakeService struct { ServiceId string `yaml:"service_id"` - RevSharePercent map[string]float64 `yaml:"rev_share_percent"` + RevSharePercent map[string]uint64 `yaml:"rev_share_percent"` Endpoints []YAMLServiceEndpoint `yaml:"endpoints"` } @@ -102,7 +102,7 @@ func ParseSupplierConfigs(ctx context.Context, configContent []byte) (*SupplierS ) } - defaultRevSharePercent := map[string]float64{} + defaultRevSharePercent := map[string]uint64{} if len(stakeConfig.DefaultRevSharePercent) == 0 { // Ensure that if no default rev share is provided, the owner address is set // to 100% rev share. diff --git a/x/supplier/config/supplier_configs_reader_test.go b/x/supplier/config/supplier_configs_reader_test.go index f5d557345..5b0f149bc 100644 --- a/x/supplier/config/supplier_configs_reader_test.go +++ b/x/supplier/config/supplier_configs_reader_test.go @@ -287,8 +287,8 @@ func Test_ParseSupplierConfigs_Services(t *testing.T) { owner_address: %s operator_address: %s default_rev_share_percent: - %s: 50.5 - %s: 49.5 + %s: 51 + %s: 49 stake_amount: 1000upokt services: # Service with default rev share @@ -322,11 +322,11 @@ func Test_ParseSupplierConfigs_Services(t *testing.T) { RevShare: []*types.ServiceRevenueShare{ { Address: firstShareHolderAddress, - RevSharePercentage: 50.5, + RevSharePercentage: 51, }, { Address: secondShareHolderAddress, - RevSharePercentage: 49.5, + RevSharePercentage: 49, }, }, }, @@ -728,24 +728,6 @@ func Test_ParseSupplierConfigs_Services(t *testing.T) { `, ownerAddress, operatorAddress, firstShareHolderAddress, ""), expectedError: config.ErrSupplierConfigUnmarshalYAML, }, - { - desc: "negative revenue share allocation is disallowed", - inputConfig: fmt.Sprintf(` - owner_address: %s - operator_address: %s - stake_amount: 1000upokt - services: - - service_id: svc - endpoints: - - publicly_exposed_url: http://pokt.network:8081 - rpc_type: json_rpc - rev_share_percent: - %s: 90 - %s: 11 - %s: -1 - `, ownerAddress, operatorAddress, ownerAddress, firstShareHolderAddress, secondShareHolderAddress), - expectedError: sharedtypes.ErrSharedInvalidRevShare, - }, { desc: "errors when the rev share config is empty", inputConfig: fmt.Sprintf(` diff --git a/x/tokenomics/keeper/token_logic_modules_test.go b/x/tokenomics/keeper/token_logic_modules_test.go index 9f955e735..eae0d4628 100644 --- a/x/tokenomics/keeper/token_logic_modules_test.go +++ b/x/tokenomics/keeper/token_logic_modules_test.go @@ -45,7 +45,7 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Valid(t *testing.T) { // Test Parameters appInitialStake := apptypes.DefaultMinStake.Amount.Mul(cosmosmath.NewInt(2)) supplierInitialStake := cosmosmath.NewInt(1000000) - supplierRevShareRatios := []float64{12.5, 37.5, 50} + supplierRevShareRatios := []uint64{12, 38, 50} globalComputeUnitsToTokensMultiplier := uint64(1) serviceComputeUnitsPerRelay := uint64(1) service := prepareTestService(serviceComputeUnitsPerRelay) @@ -185,7 +185,7 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Valid_SupplierExceedsMaxClai service := prepareTestService(serviceComputeUnitsPerRelay) numRelays := uint64(1000) // By a single supplier for application in this session supplierInitialStake := cosmosmath.NewInt(1000000) - supplierRevShareRatios := []float64{12.5, 37.5, 50} + supplierRevShareRatios := []uint64{12, 38, 50} // Prepare the keepers keepers, ctx := testkeeper.NewTokenomicsModuleKeepers(t, @@ -338,7 +338,7 @@ func TestProcessTokenLogicModules_TLMGlobalMint_Valid_MintDistributionCorrect(t // Test Parameters appInitialStake := apptypes.DefaultMinStake.Amount.Mul(cosmosmath.NewInt(2)) supplierInitialStake := cosmosmath.NewInt(1000000) - supplierRevShareRatios := []float64{12.5, 37.5, 50} + supplierRevShareRatios := []uint64{12, 38, 50} globalComputeUnitsToTokensMultiplier := uint64(1) serviceComputeUnitsPerRelay := uint64(1) service := prepareTestService(serviceComputeUnitsPerRelay) @@ -458,8 +458,8 @@ func TestProcessTokenLogicModules_TLMGlobalMint_Valid_MintDistributionCorrect(t addr := revShare.Address balanceBefore := supplierShareholderBalancesBefore[addr] balanceAfter := supplierShareholderBalancesAfter[addr].Amount.Int64() - mintShare := int64(supplierMint * revShare.RevSharePercentage / 100) - rewardShare := int64(float64(numTokensClaimed) * revShare.RevSharePercentage / 100) + mintShare := int64(supplierMint * float64(revShare.RevSharePercentage) / 100.0) + rewardShare := int64(float64(numTokensClaimed) * float64(revShare.RevSharePercentage) / 100.0) balanceIncrease := cosmosmath.NewInt(mintShare + rewardShare) expectedBalanceAfter := balanceBefore.Amount.Add(balanceIncrease).Int64() // TODO_MAINNET(@red-0ne): Remove the InDelta check and use the exact amount once the floating point arithmetic is fixed diff --git a/x/tokenomics/token_logic_module/distribution.go b/x/tokenomics/token_logic_module/distribution.go index bdd2b5c38..f7071562d 100644 --- a/x/tokenomics/token_logic_module/distribution.go +++ b/x/tokenomics/token_logic_module/distribution.go @@ -94,7 +94,7 @@ func GetShareAmountMap( shareAmountMap = make(map[string]uint64, len(serviceRevShare)) for _, revShare := range serviceRevShare { // TODO_MAINNET(@red-0ne): Use big.Rat for deterministic results. - sharePercentageFloat := big.NewFloat(float64(revShare.RevSharePercentage) / 100) + sharePercentageFloat := big.NewFloat(float64(revShare.RevSharePercentage) / float64(100.0)) amountToDistributeFloat := big.NewFloat(float64(amountToDistribute)) shareAmount, _ := big.NewFloat(0).Mul(amountToDistributeFloat, sharePercentageFloat).Uint64() shareAmountMap[revShare.Address] = shareAmount From 513b849d0669389cbbc711ed76d49fa61e2c3c74 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Fri, 17 Jan 2025 13:44:58 -0500 Subject: [PATCH 17/24] Fix E2E test --- e2e/tests/init_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/e2e/tests/init_test.go b/e2e/tests/init_test.go index 09706f0fb..1670c8789 100644 --- a/e2e/tests/init_test.go +++ b/e2e/tests/init_test.go @@ -569,11 +569,19 @@ func (s *suite) TheUserWaitsForTheApplicationForAccountPeriodToFinish(accName, p func (s *suite) getStakedAmount(actorType, accName string) (int, bool) { s.Helper() + + listCommand := fmt.Sprintf("list-%s", actorType) + // TODO_TECHDEBT(@olshansky): As of #1028, we started migrating some parts + // of the CLI to use AutoCLI. + if actorType == suppliertypes.ModuleName { + listCommand = fmt.Sprintf("%ss", listCommand) + } args := []string{ "query", actorType, - fmt.Sprintf("list-%s", actorType), + listCommand, } + res, err := s.pocketd.RunCommandOnHostWithRetry("", numQueryRetries, args...) require.NoError(s, err, "error getting %s", actorType) s.pocketd.result = res From 20a0d3f6cf7db171b31ed345acd041eb1443ba08 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Fri, 17 Jan 2025 13:45:46 -0500 Subject: [PATCH 18/24] Fix E2E test --- e2e/tests/init_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/e2e/tests/init_test.go b/e2e/tests/init_test.go index 1670c8789..3a1fb59ba 100644 --- a/e2e/tests/init_test.go +++ b/e2e/tests/init_test.go @@ -572,7 +572,10 @@ func (s *suite) getStakedAmount(actorType, accName string) (int, bool) { listCommand := fmt.Sprintf("list-%s", actorType) // TODO_TECHDEBT(@olshansky): As of #1028, we started migrating some parts - // of the CLI to use AutoCLI. + // of the CLI to use AutoCLI which made list commands pluralized. + // E.g. "list-suppliers" instead of "list-supplier". + // Over time, all actor commands will be updated like so and this if can + // be removed. if actorType == suppliertypes.ModuleName { listCommand = fmt.Sprintf("%ss", listCommand) } From a740395a1f3af81733c5e7e3a31ff56d3940e74f Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Fri, 17 Jan 2025 17:57:45 -0500 Subject: [PATCH 19/24] A few more edits --- api/poktroll/application/types.pulsar.go | 35 ++++++++++---------- api/poktroll/shared/supplier.pulsar.go | 33 +++++++++---------- go.mod | 1 + go.sum | 2 ++ proto/poktroll/application/types.proto | 41 ++++++++++++++---------- proto/poktroll/shared/service.proto | 2 +- proto/poktroll/shared/supplier.proto | 38 ++++++++++++---------- x/application/types/types.pb.go | 35 ++++++++++---------- x/shared/types/supplier.pb.go | 31 +++++++++--------- x/supplier/keeper/query_supplier.go | 4 +++ x/supplier/keeper/query_supplier_test.go | 6 ++++ 11 files changed, 126 insertions(+), 102 deletions(-) diff --git a/api/poktroll/application/types.pulsar.go b/api/poktroll/application/types.pulsar.go index 78bcffe29..4f45ce0f8 100644 --- a/api/poktroll/application/types.pulsar.go +++ b/api/poktroll/application/types.pulsar.go @@ -2182,35 +2182,36 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// Application defines the type used to store an onchain definition and state for an application +// Application represents the on-chain definition and state of an application type Application struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the application. - Stake *v1beta1.Coin `protobuf:"bytes,2,opt,name=stake,proto3" json:"stake,omitempty"` // The total amount of uPOKT the application has staked - // CRITICAL_DEV_NOTE: The number of service_configs must be EXACTLY ONE. - // This prevents applications from over-servicing. - // The field is kept repeated (a list) for both legacy and future logic reaosns. - // References: + // Bech32 address of the application + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // Total amount of staked uPOKT + Stake *v1beta1.Coin `protobuf:"bytes,2,opt,name=stake,proto3" json:"stake,omitempty"` + // CRITICAL: Must contain EXACTLY ONE service config + // Kept as repeated for legacy and future compatibility + // Refs: // - https://github.com/pokt-network/poktroll/pull/750#discussion_r1735025033 // - https://www.notion.so/buildwithgrove/Off-chain-Application-Stake-Tracking-6a8bebb107db4f7f9dc62cbe7ba555f7 - ServiceConfigs []*shared.ApplicationServiceConfig `protobuf:"bytes,3,rep,name=service_configs,json=serviceConfigs,proto3" json:"service_configs,omitempty"` // The list of services this appliccation is configured to request service for + ServiceConfigs []*shared.ApplicationServiceConfig `protobuf:"bytes,3,rep,name=service_configs,json=serviceConfigs,proto3" json:"service_configs,omitempty"` // TODO_BETA(@bryanchriswhite): Rename `delegatee_gateway_addresses` to `gateway_addresses_delegated_to`. // Ensure to rename all relevant configs, comments, variables, function names, etc as well. - DelegateeGatewayAddresses []string `protobuf:"bytes,4,rep,name=delegatee_gateway_addresses,json=delegateeGatewayAddresses,proto3" json:"delegatee_gateway_addresses,omitempty"` // The Bech32 encoded addresses for all delegatee Gateways, in a non-nullable slice - // A map from sessionEndHeights to a list of Gateways. - // The key is the height of the last block of the session during which the - // respective undelegation was committed. - // The value is a list of gateways being undelegated from. + // Non-nullable list of Bech32 encoded delegatee Gateway addresses + DelegateeGatewayAddresses []string `protobuf:"bytes,4,rep,name=delegatee_gateway_addresses,json=delegateeGatewayAddresses,proto3" json:"delegatee_gateway_addresses,omitempty"` + // Mapping of session end heights to gateways being undelegated from + // Key: Height of the last block of the session when undelegation was committed + // Value: List of gateways being undelegated from // TODO_DOCUMENT(@red-0ne): Need to document the flow from this comment // so its clear to everyone why this is necessary; https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. PendingUndelegations map[uint64]*UndelegatingGatewayList `protobuf:"bytes,5,rep,name=pending_undelegations,json=pendingUndelegations,proto3" json:"pending_undelegations,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - // The end height of the session at which an application initiated its unstaking process. - // If the application did not unstake, this value will be 0. - UnstakeSessionEndHeight uint64 `protobuf:"varint,6,opt,name=unstake_session_end_height,json=unstakeSessionEndHeight,proto3" json:"unstake_session_end_height,omitempty"` - PendingTransfer *PendingApplicationTransfer `protobuf:"bytes,7,opt,name=pending_transfer,json=pendingTransfer,proto3" json:"pending_transfer,omitempty"` + // Session end height when application initiated unstaking (0 if not unstaking) + UnstakeSessionEndHeight uint64 `protobuf:"varint,6,opt,name=unstake_session_end_height,json=unstakeSessionEndHeight,proto3" json:"unstake_session_end_height,omitempty"` + // Information about pending application transfers + PendingTransfer *PendingApplicationTransfer `protobuf:"bytes,7,opt,name=pending_transfer,json=pendingTransfer,proto3" json:"pending_transfer,omitempty"` } func (x *Application) Reset() { diff --git a/api/poktroll/shared/supplier.pulsar.go b/api/poktroll/shared/supplier.pulsar.go index be0da6a07..92e1f60de 100644 --- a/api/poktroll/shared/supplier.pulsar.go +++ b/api/poktroll/shared/supplier.pulsar.go @@ -1066,29 +1066,28 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// Supplier is the type defining the actor in Pocket Network that provides RPC services. +// Supplier represents an actor in Pocket Network that provides RPC services type Supplier struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The address of the owner (i.e. staker, custodial) that owns the funds for staking. - // By default, this address is the one that receives all the rewards unless owtherwise specified. - // This property cannot be updated by the operator. - OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` // Bech32 cosmos address - // The operator address of the supplier operator (i.e. the one managing the offchain server). - // The operator address can update the supplier's configurations excluding the owner address. - // This property does not change over the supplier's lifespan, the supplier must be unstaked - // and re-staked to effectively update this value. - OperatorAddress string `protobuf:"bytes,2,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` // Bech32 cosmos address - Stake *v1beta1.Coin `protobuf:"bytes,3,opt,name=stake,proto3" json:"stake,omitempty"` // The total amount of uPOKT the supplier has staked - Services []*SupplierServiceConfig `protobuf:"bytes,4,rep,name=services,proto3" json:"services,omitempty"` // The service configs this supplier can support - // The session end height at which an actively unbonding supplier unbonds its stake. - // If the supplier did not unstake, this value will be 0. + // Owner address that controls the staked funds and receives rewards by default + // Cannot be updated by the operator + OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` + // Operator address managing the off-chain server + // Immutable for supplier's lifespan - requires unstake/re-stake to change + // Can update supplier configs except owner address + OperatorAddress string `protobuf:"bytes,2,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` + // Total amount of staked uPOKT + Stake *v1beta1.Coin `protobuf:"bytes,3,opt,name=stake,proto3" json:"stake,omitempty"` + // List of service configurations supported by this supplier + Services []*SupplierServiceConfig `protobuf:"bytes,4,rep,name=services,proto3" json:"services,omitempty"` + // Session end height when supplier initiated unstaking (0 if not unstaking) UnstakeSessionEndHeight uint64 `protobuf:"varint,5,opt,name=unstake_session_end_height,json=unstakeSessionEndHeight,proto3" json:"unstake_session_end_height,omitempty"` - // services_activation_heights_map is a map of serviceIds to the height at - // which the staked supplier will become active for that service. - // Activation heights are session start heights. + // Mapping of serviceIds to their activation heights + // Key: serviceId + // Value: Session start height when supplier becomes active for the service ServicesActivationHeightsMap map[string]uint64 `protobuf:"bytes,6,rep,name=services_activation_heights_map,json=servicesActivationHeightsMap,proto3" json:"services_activation_heights_map,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` } diff --git a/go.mod b/go.mod index 162807307..d1f28b975 100644 --- a/go.mod +++ b/go.mod @@ -82,6 +82,7 @@ require ( cosmossdk.io/x/tx v0.13.4 github.com/jhump/protoreflect v1.16.0 github.com/mitchellh/mapstructure v1.5.0 + go.uber.org/mock v0.5.0 ) require ( diff --git a/go.sum b/go.sum index 761f5909e..b89406d11 100644 --- a/go.sum +++ b/go.sum @@ -1211,6 +1211,8 @@ go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0 go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU= +go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= diff --git a/proto/poktroll/application/types.proto b/proto/poktroll/application/types.proto index 8982cecda..6626eedcb 100644 --- a/proto/poktroll/application/types.proto +++ b/proto/poktroll/application/types.proto @@ -14,30 +14,37 @@ import "cosmos_proto/cosmos.proto"; import "poktroll/shared/service.proto"; -// Application defines the type used to store an onchain definition and state for an application +// Application represents the on-chain definition and state of an application message Application { - string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application. - cosmos.base.v1beta1.Coin stake = 2; // The total amount of uPOKT the application has staked - // CRITICAL_DEV_NOTE: The number of service_configs must be EXACTLY ONE. - // This prevents applications from over-servicing. - // The field is kept repeated (a list) for both legacy and future logic reaosns. - // References: - // - https://github.com/pokt-network/poktroll/pull/750#discussion_r1735025033 - // - https://www.notion.so/buildwithgrove/Off-chain-Application-Stake-Tracking-6a8bebb107db4f7f9dc62cbe7ba555f7 - repeated poktroll.shared.ApplicationServiceConfig service_configs = 3; // The list of services this appliccation is configured to request service for + // Bech32 address of the application + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // Total amount of staked uPOKT + cosmos.base.v1beta1.Coin stake = 2; + + // CRITICAL: Must contain EXACTLY ONE service config + // Kept as repeated for legacy and future compatibility + // Refs: + // - https://github.com/pokt-network/poktroll/pull/750#discussion_r1735025033 + // - https://www.notion.so/buildwithgrove/Off-chain-Application-Stake-Tracking-6a8bebb107db4f7f9dc62cbe7ba555f7 + repeated poktroll.shared.ApplicationServiceConfig service_configs = 3; + // TODO_BETA(@bryanchriswhite): Rename `delegatee_gateway_addresses` to `gateway_addresses_delegated_to`. // Ensure to rename all relevant configs, comments, variables, function names, etc as well. - repeated string delegatee_gateway_addresses = 4 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.nullable) = false]; // The Bech32 encoded addresses for all delegatee Gateways, in a non-nullable slice - // A map from sessionEndHeights to a list of Gateways. - // The key is the height of the last block of the session during which the - // respective undelegation was committed. - // The value is a list of gateways being undelegated from. + // Non-nullable list of Bech32 encoded delegatee Gateway addresses + repeated string delegatee_gateway_addresses = 4 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.nullable) = false]; + + // Mapping of session end heights to gateways being undelegated from + // Key: Height of the last block of the session when undelegation was committed + // Value: List of gateways being undelegated from // TODO_DOCUMENT(@red-0ne): Need to document the flow from this comment // so its clear to everyone why this is necessary; https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. map pending_undelegations = 5 [(gogoproto.nullable) = false]; - // The end height of the session at which an application initiated its unstaking process. - // If the application did not unstake, this value will be 0. + + // Session end height when application initiated unstaking (0 if not unstaking) uint64 unstake_session_end_height = 6; + + // Information about pending application transfers PendingApplicationTransfer pending_transfer = 7; } diff --git a/proto/poktroll/shared/service.proto b/proto/poktroll/shared/service.proto index 9a5cdd470..340c89abb 100644 --- a/proto/poktroll/shared/service.proto +++ b/proto/poktroll/shared/service.proto @@ -58,7 +58,7 @@ message SupplierEndpoint { // ServiceRevenueShare message to hold revenue share configuration details message ServiceRevenueShare { // 2 was reserved in #1028 during the change of rev_share_percentage from float to uint64 - // TODO_TECHDEBT: Investigate why we can't use a double or float: https://github.com/pokt-network/poktroll/actions/runs/12832899448/job/35787150432?pr=1028 + // TODO_TECHDEBT(#1033): Investigate if we can use a double instead. reserved 2; string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the revenue share recipient diff --git a/proto/poktroll/shared/supplier.proto b/proto/poktroll/shared/supplier.proto index dfa6689ae..60cb30770 100644 --- a/proto/poktroll/shared/supplier.proto +++ b/proto/poktroll/shared/supplier.proto @@ -10,24 +10,28 @@ import "cosmos/base/v1beta1/coin.proto"; import "poktroll/shared/service.proto"; import "gogoproto/gogo.proto"; -// Supplier is the type defining the actor in Pocket Network that provides RPC services. +// Supplier represents an actor in Pocket Network that provides RPC services message Supplier { - // The address of the owner (i.e. staker, custodial) that owns the funds for staking. - // By default, this address is the one that receives all the rewards unless owtherwise specified. - // This property cannot be updated by the operator. - string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // Bech32 cosmos address - // The operator address of the supplier operator (i.e. the one managing the offchain server). - // The operator address can update the supplier's configurations excluding the owner address. - // This property does not change over the supplier's lifespan, the supplier must be unstaked - // and re-staked to effectively update this value. - string operator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // Bech32 cosmos address - cosmos.base.v1beta1.Coin stake = 3; // The total amount of uPOKT the supplier has staked - repeated SupplierServiceConfig services = 4; // The service configs this supplier can support - // The session end height at which an actively unbonding supplier unbonds its stake. - // If the supplier did not unstake, this value will be 0. + // Owner address that controls the staked funds and receives rewards by default + // Cannot be updated by the operator + string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // Operator address managing the off-chain server + // Immutable for supplier's lifespan - requires unstake/re-stake to change + // Can update supplier configs except owner address + string operator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // Total amount of staked uPOKT + cosmos.base.v1beta1.Coin stake = 3; + + // List of service configurations supported by this supplier + repeated SupplierServiceConfig services = 4; + + // Session end height when supplier initiated unstaking (0 if not unstaking) uint64 unstake_session_end_height = 5; - // services_activation_heights_map is a map of serviceIds to the height at - // which the staked supplier will become active for that service. - // Activation heights are session start heights. + + // Mapping of serviceIds to their activation heights + // Key: serviceId + // Value: Session start height when supplier becomes active for the service map services_activation_heights_map = 6; } diff --git a/x/application/types/types.pb.go b/x/application/types/types.pb.go index 4a7e43bba..da7b95da7 100644 --- a/x/application/types/types.pb.go +++ b/x/application/types/types.pb.go @@ -27,31 +27,32 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// Application defines the type used to store an onchain definition and state for an application +// Application represents the on-chain definition and state of an application type Application struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - Stake *types.Coin `protobuf:"bytes,2,opt,name=stake,proto3" json:"stake,omitempty"` - // CRITICAL_DEV_NOTE: The number of service_configs must be EXACTLY ONE. - // This prevents applications from over-servicing. - // The field is kept repeated (a list) for both legacy and future logic reaosns. - // References: - // - https://github.com/pokt-network/poktroll/pull/750#discussion_r1735025033 - // - https://www.notion.so/buildwithgrove/Off-chain-Application-Stake-Tracking-6a8bebb107db4f7f9dc62cbe7ba555f7 + // Bech32 address of the application + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // Total amount of staked uPOKT + Stake *types.Coin `protobuf:"bytes,2,opt,name=stake,proto3" json:"stake,omitempty"` + // CRITICAL: Must contain EXACTLY ONE service config + // Kept as repeated for legacy and future compatibility + // Refs: + // - https://github.com/pokt-network/poktroll/pull/750#discussion_r1735025033 + // - https://www.notion.so/buildwithgrove/Off-chain-Application-Stake-Tracking-6a8bebb107db4f7f9dc62cbe7ba555f7 ServiceConfigs []*types1.ApplicationServiceConfig `protobuf:"bytes,3,rep,name=service_configs,json=serviceConfigs,proto3" json:"service_configs,omitempty"` // TODO_BETA(@bryanchriswhite): Rename `delegatee_gateway_addresses` to `gateway_addresses_delegated_to`. // Ensure to rename all relevant configs, comments, variables, function names, etc as well. + // Non-nullable list of Bech32 encoded delegatee Gateway addresses DelegateeGatewayAddresses []string `protobuf:"bytes,4,rep,name=delegatee_gateway_addresses,json=delegateeGatewayAddresses,proto3" json:"delegatee_gateway_addresses,omitempty"` - // A map from sessionEndHeights to a list of Gateways. - // The key is the height of the last block of the session during which the - // respective undelegation was committed. - // The value is a list of gateways being undelegated from. + // Mapping of session end heights to gateways being undelegated from + // Key: Height of the last block of the session when undelegation was committed + // Value: List of gateways being undelegated from // TODO_DOCUMENT(@red-0ne): Need to document the flow from this comment // so its clear to everyone why this is necessary; https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. PendingUndelegations map[uint64]UndelegatingGatewayList `protobuf:"bytes,5,rep,name=pending_undelegations,json=pendingUndelegations,proto3" json:"pending_undelegations" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - // The end height of the session at which an application initiated its unstaking process. - // If the application did not unstake, this value will be 0. - UnstakeSessionEndHeight uint64 `protobuf:"varint,6,opt,name=unstake_session_end_height,json=unstakeSessionEndHeight,proto3" json:"unstake_session_end_height,omitempty"` - PendingTransfer *PendingApplicationTransfer `protobuf:"bytes,7,opt,name=pending_transfer,json=pendingTransfer,proto3" json:"pending_transfer,omitempty"` + // Session end height when application initiated unstaking (0 if not unstaking) + UnstakeSessionEndHeight uint64 `protobuf:"varint,6,opt,name=unstake_session_end_height,json=unstakeSessionEndHeight,proto3" json:"unstake_session_end_height,omitempty"` + // Information about pending application transfers + PendingTransfer *PendingApplicationTransfer `protobuf:"bytes,7,opt,name=pending_transfer,json=pendingTransfer,proto3" json:"pending_transfer,omitempty"` } func (m *Application) Reset() { *m = Application{} } diff --git a/x/shared/types/supplier.pb.go b/x/shared/types/supplier.pb.go index 9c0287112..6041f3841 100644 --- a/x/shared/types/supplier.pb.go +++ b/x/shared/types/supplier.pb.go @@ -26,25 +26,24 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// Supplier is the type defining the actor in Pocket Network that provides RPC services. +// Supplier represents an actor in Pocket Network that provides RPC services type Supplier struct { - // The address of the owner (i.e. staker, custodial) that owns the funds for staking. - // By default, this address is the one that receives all the rewards unless owtherwise specified. - // This property cannot be updated by the operator. + // Owner address that controls the staked funds and receives rewards by default + // Cannot be updated by the operator OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` - // The operator address of the supplier operator (i.e. the one managing the offchain server). - // The operator address can update the supplier's configurations excluding the owner address. - // This property does not change over the supplier's lifespan, the supplier must be unstaked - // and re-staked to effectively update this value. - OperatorAddress string `protobuf:"bytes,2,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` - Stake *types.Coin `protobuf:"bytes,3,opt,name=stake,proto3" json:"stake,omitempty"` - Services []*SupplierServiceConfig `protobuf:"bytes,4,rep,name=services,proto3" json:"services,omitempty"` - // The session end height at which an actively unbonding supplier unbonds its stake. - // If the supplier did not unstake, this value will be 0. + // Operator address managing the off-chain server + // Immutable for supplier's lifespan - requires unstake/re-stake to change + // Can update supplier configs except owner address + OperatorAddress string `protobuf:"bytes,2,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` + // Total amount of staked uPOKT + Stake *types.Coin `protobuf:"bytes,3,opt,name=stake,proto3" json:"stake,omitempty"` + // List of service configurations supported by this supplier + Services []*SupplierServiceConfig `protobuf:"bytes,4,rep,name=services,proto3" json:"services,omitempty"` + // Session end height when supplier initiated unstaking (0 if not unstaking) UnstakeSessionEndHeight uint64 `protobuf:"varint,5,opt,name=unstake_session_end_height,json=unstakeSessionEndHeight,proto3" json:"unstake_session_end_height,omitempty"` - // services_activation_heights_map is a map of serviceIds to the height at - // which the staked supplier will become active for that service. - // Activation heights are session start heights. + // Mapping of serviceIds to their activation heights + // Key: serviceId + // Value: Session start height when supplier becomes active for the service ServicesActivationHeightsMap map[string]uint64 `protobuf:"bytes,6,rep,name=services_activation_heights_map,json=servicesActivationHeightsMap,proto3" json:"services_activation_heights_map,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` } diff --git a/x/supplier/keeper/query_supplier.go b/x/supplier/keeper/query_supplier.go index 72be0ae0f..a0d2c1e9d 100644 --- a/x/supplier/keeper/query_supplier.go +++ b/x/supplier/keeper/query_supplier.go @@ -62,6 +62,10 @@ func (k Keeper) AllSuppliers( } } + // TODO_MAINNET(@olshansk, #1033): Newer version of the CosmosSDK doesn't support maps. + // Decide on a direction w.r.t maps in protos based on feedback from the CosmoSDK team. + supplier.ServicesActivationHeightsMap = nil + suppliers = append(suppliers, supplier) return nil }, diff --git a/x/supplier/keeper/query_supplier_test.go b/x/supplier/keeper/query_supplier_test.go index 8e3e240c1..417921624 100644 --- a/x/supplier/keeper/query_supplier_test.go +++ b/x/supplier/keeper/query_supplier_test.go @@ -73,6 +73,12 @@ func TestSupplierQueryPaginated(t *testing.T) { supplierModuleKeepers, ctx := keepertest.SupplierKeeper(t) suppliers := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 5) + // TODO_MAINNET(@olshansk, #1033): Newer version of the CosmosSDK doesn't support maps. + // Decide on a direction w.r.t maps in protos based on feedback from the CosmoSDK team. + for _, supplier := range suppliers { + supplier.ServicesActivationHeightsMap = nil + } + request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllSuppliersRequest { return &types.QueryAllSuppliersRequest{ Pagination: &query.PageRequest{ From c274e52b355490242d374d372dffd889825c3085 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Fri, 17 Jan 2025 18:28:54 -0500 Subject: [PATCH 20/24] Added another TODO_MAINNET(@olshansk, #1033) --- api/poktroll/shared/supplier.pulsar.go | 2 ++ e2e/tests/stake_supplier.feature | 36 ++++++++++++++------------ go.mod | 1 - go.sum | 2 -- proto/poktroll/shared/supplier.proto | 2 ++ x/shared/types/supplier.pb.go | 2 ++ 6 files changed, 26 insertions(+), 19 deletions(-) diff --git a/api/poktroll/shared/supplier.pulsar.go b/api/poktroll/shared/supplier.pulsar.go index 92e1f60de..4135f5dc3 100644 --- a/api/poktroll/shared/supplier.pulsar.go +++ b/api/poktroll/shared/supplier.pulsar.go @@ -1088,6 +1088,8 @@ type Supplier struct { // Mapping of serviceIds to their activation heights // Key: serviceId // Value: Session start height when supplier becomes active for the service + // TODO_MAINNET(@olshansk, #1033): Look into moving this to an external repeated protobuf + // because maps are no longer supported for serialized types in the CosmoSDK. ServicesActivationHeightsMap map[string]uint64 `protobuf:"bytes,6,rep,name=services_activation_heights_map,json=servicesActivationHeightsMap,proto3" json:"services_activation_heights_map,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` } diff --git a/e2e/tests/stake_supplier.feature b/e2e/tests/stake_supplier.feature index b24a579d9..3d9607fdc 100644 --- a/e2e/tests/stake_supplier.feature +++ b/e2e/tests/stake_supplier.feature @@ -30,19 +30,23 @@ Feature: Stake Supplier Namespace And the user verifies the "supplier" for account "supplier2" is not staked And the account balance of "supplier2" should be "1000070" uPOKT "more" than before - Scenario: User can restake a Supplier waiting for it to become active again - Given the user has the pocketd binary installed - # Reduce the application unbonding period to avoid timeouts and speed up scenarios. - And the "supplier" unbonding period param is successfully set to "1" sessions of "2" blocks - And the user verifies the "supplier" for account "supplier2" is not staked - Then the user stakes a "supplier" with "1000070" uPOKT for "anvil" service from the account "supplier2" - And the user should wait for the "supplier" module "StakeSupplier" message to be submitted - Then the user should see that the supplier for account "supplier2" is staked - But the session for application "app1" and service "anvil" does not contain "supplier2" - When the user waits for supplier "supplier2" to become active for service "anvil" - Then the session for application "app1" and service "anvil" contains the supplier "supplier2" - # Cleanup to make this feature idempotent. - And the user unstakes a "supplier" from the account "supplier2" - And the supplier for account "supplier2" is unbonding - And the user should wait for the "supplier" module "SupplierUnbondingBegin" tx event to be broadcast - And a "supplier" module "SupplierUnbondingEnd" end block event is broadcast + # TODO_MAINNET(@olshansk, #1033): Since the "to become active for service" step + # requires reading "ServicesActivationHeightsMap", which is temporarily set to nil, + # this test has been commented out. See #1033 for details and re-enable this test + # once that data is retrievable through a different method. + # Scenario: User can restake a Supplier waiting for it to become active again + # Given the user has the pocketd binary installed + # # Reduce the application unbonding period to avoid timeouts and speed up scenarios. + # And the "supplier" unbonding period param is successfully set to "1" sessions of "2" blocks + # And the user verifies the "supplier" for account "supplier2" is not staked + # Then the user stakes a "supplier" with "1000070" uPOKT for "anvil" service from the account "supplier2" + # And the user should wait for the "supplier" module "StakeSupplier" message to be submitted + # Then the user should see that the supplier for account "supplier2" is staked + # But the session for application "app1" and service "anvil" does not contain "supplier2" + # When the user waits for supplier "supplier2" to become active for service "anvil" + # Then the session for application "app1" and service "anvil" contains the supplier "supplier2" + # # Cleanup to make this feature idempotent. + # And the user unstakes a "supplier" from the account "supplier2" + # And the supplier for account "supplier2" is unbonding + # And the user should wait for the "supplier" module "SupplierUnbondingBegin" tx event to be broadcast + # And a "supplier" module "SupplierUnbondingEnd" end block event is broadcast diff --git a/go.mod b/go.mod index d1f28b975..162807307 100644 --- a/go.mod +++ b/go.mod @@ -82,7 +82,6 @@ require ( cosmossdk.io/x/tx v0.13.4 github.com/jhump/protoreflect v1.16.0 github.com/mitchellh/mapstructure v1.5.0 - go.uber.org/mock v0.5.0 ) require ( diff --git a/go.sum b/go.sum index b89406d11..761f5909e 100644 --- a/go.sum +++ b/go.sum @@ -1211,8 +1211,6 @@ go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0 go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU= -go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= diff --git a/proto/poktroll/shared/supplier.proto b/proto/poktroll/shared/supplier.proto index 60cb30770..17d6bd5c4 100644 --- a/proto/poktroll/shared/supplier.proto +++ b/proto/poktroll/shared/supplier.proto @@ -33,5 +33,7 @@ message Supplier { // Mapping of serviceIds to their activation heights // Key: serviceId // Value: Session start height when supplier becomes active for the service + // TODO_MAINNET(@olshansk, #1033): Look into moving this to an external repeated protobuf + // because maps are no longer supported for serialized types in the CosmoSDK. map services_activation_heights_map = 6; } diff --git a/x/shared/types/supplier.pb.go b/x/shared/types/supplier.pb.go index 6041f3841..1f818bc41 100644 --- a/x/shared/types/supplier.pb.go +++ b/x/shared/types/supplier.pb.go @@ -44,6 +44,8 @@ type Supplier struct { // Mapping of serviceIds to their activation heights // Key: serviceId // Value: Session start height when supplier becomes active for the service + // TODO_MAINNET(@olshansk, #1033): Look into moving this to an external repeated protobuf + // because maps are no longer supported for serialized types in the CosmoSDK. ServicesActivationHeightsMap map[string]uint64 `protobuf:"bytes,6,rep,name=services_activation_heights_map,json=servicesActivationHeightsMap,proto3" json:"services_activation_heights_map,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` } From 7ec70841dc296e8ae00f392ca757f2bd670b11e1 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Mon, 20 Jan 2025 10:22:54 -0500 Subject: [PATCH 21/24] Checkpoint - uncomitted changes from friday --- api/poktroll/application/types.pulsar.go | 7 ++++--- api/poktroll/shared/supplier.pulsar.go | 10 +++++----- e2e/tests/init_test.go | 3 ++- e2e/tests/stake_supplier.feature | 14 +++++++------- localnet/poktrolld/config/config.toml | 4 ++-- proto/poktroll/application/types.proto | 7 ++++--- proto/poktroll/shared/supplier.proto | 10 +++++----- x/application/types/types.pb.go | 7 ++++--- x/shared/types/supplier.pb.go | 10 +++++----- x/supplier/keeper/query_supplier_test.go | 7 +++++-- 10 files changed, 43 insertions(+), 36 deletions(-) diff --git a/api/poktroll/application/types.pulsar.go b/api/poktroll/application/types.pulsar.go index 4f45ce0f8..21eb04ac4 100644 --- a/api/poktroll/application/types.pulsar.go +++ b/api/poktroll/application/types.pulsar.go @@ -2193,7 +2193,8 @@ type Application struct { // Total amount of staked uPOKT Stake *v1beta1.Coin `protobuf:"bytes,2,opt,name=stake,proto3" json:"stake,omitempty"` // CRITICAL: Must contain EXACTLY ONE service config - // Kept as repeated for legacy and future compatibility + // This prevents applications from over-servicing. + // Kept as repeated field for legacy and future compatibility // Refs: // - https://github.com/pokt-network/poktroll/pull/750#discussion_r1735025033 // - https://www.notion.so/buildwithgrove/Off-chain-Application-Stake-Tracking-6a8bebb107db4f7f9dc62cbe7ba555f7 @@ -2203,8 +2204,8 @@ type Application struct { // Non-nullable list of Bech32 encoded delegatee Gateway addresses DelegateeGatewayAddresses []string `protobuf:"bytes,4,rep,name=delegatee_gateway_addresses,json=delegateeGatewayAddresses,proto3" json:"delegatee_gateway_addresses,omitempty"` // Mapping of session end heights to gateways being undelegated from - // Key: Height of the last block of the session when undelegation was committed - // Value: List of gateways being undelegated from + // - Key: Height of the last block of the session when undelegation tx was committed + // - Value: List of gateways being undelegated from // TODO_DOCUMENT(@red-0ne): Need to document the flow from this comment // so its clear to everyone why this is necessary; https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. PendingUndelegations map[uint64]*UndelegatingGatewayList `protobuf:"bytes,5,rep,name=pending_undelegations,json=pendingUndelegations,proto3" json:"pending_undelegations,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` diff --git a/api/poktroll/shared/supplier.pulsar.go b/api/poktroll/shared/supplier.pulsar.go index 4135f5dc3..8ac084889 100644 --- a/api/poktroll/shared/supplier.pulsar.go +++ b/api/poktroll/shared/supplier.pulsar.go @@ -1075,9 +1075,9 @@ type Supplier struct { // Owner address that controls the staked funds and receives rewards by default // Cannot be updated by the operator OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` - // Operator address managing the off-chain server - // Immutable for supplier's lifespan - requires unstake/re-stake to change - // Can update supplier configs except owner address + // Operator address managing the offchain server + // Immutable for supplier's lifespan - requires unstake/re-stake to change. + // Can update supplier configs except for owner address. OperatorAddress string `protobuf:"bytes,2,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` // Total amount of staked uPOKT Stake *v1beta1.Coin `protobuf:"bytes,3,opt,name=stake,proto3" json:"stake,omitempty"` @@ -1086,8 +1086,8 @@ type Supplier struct { // Session end height when supplier initiated unstaking (0 if not unstaking) UnstakeSessionEndHeight uint64 `protobuf:"varint,5,opt,name=unstake_session_end_height,json=unstakeSessionEndHeight,proto3" json:"unstake_session_end_height,omitempty"` // Mapping of serviceIds to their activation heights - // Key: serviceId - // Value: Session start height when supplier becomes active for the service + // - Key: serviceId + // - Value: Session start height when supplier becomes active for the service // TODO_MAINNET(@olshansk, #1033): Look into moving this to an external repeated protobuf // because maps are no longer supported for serialized types in the CosmoSDK. ServicesActivationHeightsMap map[string]uint64 `protobuf:"bytes,6,rep,name=services_activation_heights_map,json=servicesActivationHeightsMap,proto3" json:"services_activation_heights_map,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` diff --git a/e2e/tests/init_test.go b/e2e/tests/init_test.go index 3a1fb59ba..fa63a29c3 100644 --- a/e2e/tests/init_test.go +++ b/e2e/tests/init_test.go @@ -761,10 +761,11 @@ func (s *suite) getSupplierInfo(supplierOperatorName string) *sharedtypes.Suppli supplierOperatorAddr, "--output=json", } - + fmt.Println("OLSH1") res, err := s.pocketd.RunCommandOnHostWithRetry("", numQueryRetries, args...) require.NoError(s, err, "error getting supplier %s", supplierOperatorAddr) s.pocketd.result = res + fmt.Println("OLSH2") var resp suppliertypes.QueryGetSupplierResponse responseBz := []byte(strings.TrimSpace(res.Stdout)) diff --git a/e2e/tests/stake_supplier.feature b/e2e/tests/stake_supplier.feature index 3d9607fdc..9e655d0cc 100644 --- a/e2e/tests/stake_supplier.feature +++ b/e2e/tests/stake_supplier.feature @@ -21,14 +21,14 @@ Feature: Stake Supplier Namespace And the "supplier" for account "supplier2" is staked with "1000070" uPOKT And an account exists for "supplier2" When the user unstakes a "supplier" from the account "supplier2" - Then the user should be able to see standard output containing "txhash:" - And the user should be able to see standard output containing "code: 0" - And the pocketd binary should exit without error + # Then the user should be able to see standard output containing "txhash:" + # And the user should be able to see standard output containing "code: 0" + # And the pocketd binary should exit without error And the supplier for account "supplier2" is unbonding - And the user should wait for the "supplier" module "SupplierUnbondingBegin" tx event to be broadcast - And a "supplier" module "SupplierUnbondingEnd" end block event is broadcast - And the user verifies the "supplier" for account "supplier2" is not staked - And the account balance of "supplier2" should be "1000070" uPOKT "more" than before + # And the user should wait for the "supplier" module "SupplierUnbondingBegin" tx event to be broadcast + # And a "supplier" module "SupplierUnbondingEnd" end block event is broadcast + # And the user verifies the "supplier" for account "supplier2" is not staked + # And the account balance of "supplier2" should be "1000070" uPOKT "more" than before # TODO_MAINNET(@olshansk, #1033): Since the "to become active for service" step # requires reading "ServicesActivationHeightsMap", which is temporarily set to nil, diff --git a/localnet/poktrolld/config/config.toml b/localnet/poktrolld/config/config.toml index 35dcda640..bbfa0366f 100644 --- a/localnet/poktrolld/config/config.toml +++ b/localnet/poktrolld/config/config.toml @@ -174,7 +174,7 @@ timeout_broadcast_tx_commit = "10s" max_request_batch_size = 10 # Maximum size of request body, in bytes -max_body_bytes = 100000000 +max_body_bytes = 1000000 # Maximum size of request header, in bytes max_header_bytes = 1048576 @@ -330,7 +330,7 @@ keep-invalid-txs-in-cache = false # Maximum size of a single transaction. # NOTE: the max size of a tx transmitted over the network is {max_tx_bytes}. -max_tx_bytes = 100000000 +max_tx_bytes = 1048576 # Maximum size of a batch of transactions to send to a peer # Including space needed by encoding (one varint per transaction). diff --git a/proto/poktroll/application/types.proto b/proto/poktroll/application/types.proto index 6626eedcb..81e7e893e 100644 --- a/proto/poktroll/application/types.proto +++ b/proto/poktroll/application/types.proto @@ -23,7 +23,8 @@ message Application { cosmos.base.v1beta1.Coin stake = 2; // CRITICAL: Must contain EXACTLY ONE service config - // Kept as repeated for legacy and future compatibility + // This prevents applications from over-servicing. + // Kept as repeated field for legacy and future compatibility // Refs: // - https://github.com/pokt-network/poktroll/pull/750#discussion_r1735025033 // - https://www.notion.so/buildwithgrove/Off-chain-Application-Stake-Tracking-6a8bebb107db4f7f9dc62cbe7ba555f7 @@ -35,8 +36,8 @@ message Application { repeated string delegatee_gateway_addresses = 4 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.nullable) = false]; // Mapping of session end heights to gateways being undelegated from - // Key: Height of the last block of the session when undelegation was committed - // Value: List of gateways being undelegated from + // - Key: Height of the last block of the session when undelegation tx was committed + // - Value: List of gateways being undelegated from // TODO_DOCUMENT(@red-0ne): Need to document the flow from this comment // so its clear to everyone why this is necessary; https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. map pending_undelegations = 5 [(gogoproto.nullable) = false]; diff --git a/proto/poktroll/shared/supplier.proto b/proto/poktroll/shared/supplier.proto index 17d6bd5c4..7b88dff05 100644 --- a/proto/poktroll/shared/supplier.proto +++ b/proto/poktroll/shared/supplier.proto @@ -16,9 +16,9 @@ message Supplier { // Cannot be updated by the operator string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // Operator address managing the off-chain server - // Immutable for supplier's lifespan - requires unstake/re-stake to change - // Can update supplier configs except owner address + // Operator address managing the offchain server + // Immutable for supplier's lifespan - requires unstake/re-stake to change. + // Can update supplier configs except for owner address. string operator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // Total amount of staked uPOKT @@ -31,8 +31,8 @@ message Supplier { uint64 unstake_session_end_height = 5; // Mapping of serviceIds to their activation heights - // Key: serviceId - // Value: Session start height when supplier becomes active for the service + // - Key: serviceId + // - Value: Session start height when supplier becomes active for the service // TODO_MAINNET(@olshansk, #1033): Look into moving this to an external repeated protobuf // because maps are no longer supported for serialized types in the CosmoSDK. map services_activation_heights_map = 6; diff --git a/x/application/types/types.pb.go b/x/application/types/types.pb.go index da7b95da7..ec942dee4 100644 --- a/x/application/types/types.pb.go +++ b/x/application/types/types.pb.go @@ -34,7 +34,8 @@ type Application struct { // Total amount of staked uPOKT Stake *types.Coin `protobuf:"bytes,2,opt,name=stake,proto3" json:"stake,omitempty"` // CRITICAL: Must contain EXACTLY ONE service config - // Kept as repeated for legacy and future compatibility + // This prevents applications from over-servicing. + // Kept as repeated field for legacy and future compatibility // Refs: // - https://github.com/pokt-network/poktroll/pull/750#discussion_r1735025033 // - https://www.notion.so/buildwithgrove/Off-chain-Application-Stake-Tracking-6a8bebb107db4f7f9dc62cbe7ba555f7 @@ -44,8 +45,8 @@ type Application struct { // Non-nullable list of Bech32 encoded delegatee Gateway addresses DelegateeGatewayAddresses []string `protobuf:"bytes,4,rep,name=delegatee_gateway_addresses,json=delegateeGatewayAddresses,proto3" json:"delegatee_gateway_addresses,omitempty"` // Mapping of session end heights to gateways being undelegated from - // Key: Height of the last block of the session when undelegation was committed - // Value: List of gateways being undelegated from + // - Key: Height of the last block of the session when undelegation tx was committed + // - Value: List of gateways being undelegated from // TODO_DOCUMENT(@red-0ne): Need to document the flow from this comment // so its clear to everyone why this is necessary; https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. PendingUndelegations map[uint64]UndelegatingGatewayList `protobuf:"bytes,5,rep,name=pending_undelegations,json=pendingUndelegations,proto3" json:"pending_undelegations" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` diff --git a/x/shared/types/supplier.pb.go b/x/shared/types/supplier.pb.go index 1f818bc41..dee27dc69 100644 --- a/x/shared/types/supplier.pb.go +++ b/x/shared/types/supplier.pb.go @@ -31,9 +31,9 @@ type Supplier struct { // Owner address that controls the staked funds and receives rewards by default // Cannot be updated by the operator OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` - // Operator address managing the off-chain server - // Immutable for supplier's lifespan - requires unstake/re-stake to change - // Can update supplier configs except owner address + // Operator address managing the offchain server + // Immutable for supplier's lifespan - requires unstake/re-stake to change. + // Can update supplier configs except for owner address. OperatorAddress string `protobuf:"bytes,2,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` // Total amount of staked uPOKT Stake *types.Coin `protobuf:"bytes,3,opt,name=stake,proto3" json:"stake,omitempty"` @@ -42,8 +42,8 @@ type Supplier struct { // Session end height when supplier initiated unstaking (0 if not unstaking) UnstakeSessionEndHeight uint64 `protobuf:"varint,5,opt,name=unstake_session_end_height,json=unstakeSessionEndHeight,proto3" json:"unstake_session_end_height,omitempty"` // Mapping of serviceIds to their activation heights - // Key: serviceId - // Value: Session start height when supplier becomes active for the service + // - Key: serviceId + // - Value: Session start height when supplier becomes active for the service // TODO_MAINNET(@olshansk, #1033): Look into moving this to an external repeated protobuf // because maps are no longer supported for serialized types in the CosmoSDK. ServicesActivationHeightsMap map[string]uint64 `protobuf:"bytes,6,rep,name=services_activation_heights_map,json=servicesActivationHeightsMap,proto3" json:"services_activation_heights_map,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` diff --git a/x/supplier/keeper/query_supplier_test.go b/x/supplier/keeper/query_supplier_test.go index 417921624..880f815f9 100644 --- a/x/supplier/keeper/query_supplier_test.go +++ b/x/supplier/keeper/query_supplier_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "fmt" "strconv" "testing" @@ -11,6 +12,7 @@ import ( keepertest "github.com/pokt-network/poktroll/testutil/keeper" "github.com/pokt-network/poktroll/testutil/nullify" + "github.com/pokt-network/poktroll/testutil/sample" "github.com/pokt-network/poktroll/x/supplier/types" ) @@ -20,6 +22,7 @@ var _ = strconv.IntSize func TestSupplierQuerySingle(t *testing.T) { supplierModuleKeepers, ctx := keepertest.SupplierKeeper(t) suppliers := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 2) + supplierAddr := sample.AccAddress() tests := []struct { desc string @@ -44,9 +47,9 @@ func TestSupplierQuerySingle(t *testing.T) { { desc: "KeyNotFound", request: &types.QueryGetSupplierRequest{ - OperatorAddress: strconv.Itoa(100000), + OperatorAddress: supplierAddr, }, - expectedErr: status.Error(codes.NotFound, "supplier with address: \"100000\""), + expectedErr: status.Error(codes.NotFound, fmt.Sprintf("supplier with address: \"%s\"", supplierAddr)), }, { desc: "InvalidRequest", From bd05818879c6ac085d09dae716c9ff90a3295a1c Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Mon, 20 Jan 2025 10:33:23 -0500 Subject: [PATCH 22/24] Automatic changes from running localnet --- localnet/poktrolld/config/config.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/localnet/poktrolld/config/config.toml b/localnet/poktrolld/config/config.toml index bbfa0366f..35dcda640 100644 --- a/localnet/poktrolld/config/config.toml +++ b/localnet/poktrolld/config/config.toml @@ -174,7 +174,7 @@ timeout_broadcast_tx_commit = "10s" max_request_batch_size = 10 # Maximum size of request body, in bytes -max_body_bytes = 1000000 +max_body_bytes = 100000000 # Maximum size of request header, in bytes max_header_bytes = 1048576 @@ -330,7 +330,7 @@ keep-invalid-txs-in-cache = false # Maximum size of a single transaction. # NOTE: the max size of a tx transmitted over the network is {max_tx_bytes}. -max_tx_bytes = 1048576 +max_tx_bytes = 100000000 # Maximum size of a batch of transactions to send to a peer # Including space needed by encoding (one varint per transaction). From c29a891d69285854c770266aa7f9fa9e000bb3f0 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Mon, 20 Jan 2025 12:28:51 -0500 Subject: [PATCH 23/24] Tests passing locally --- e2e/tests/init_test.go | 16 ++++++++-------- e2e/tests/node.go | 13 ++++++++++++- x/supplier/keeper/query_supplier.go | 4 ++++ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/e2e/tests/init_test.go b/e2e/tests/init_test.go index fa63a29c3..08804373d 100644 --- a/e2e/tests/init_test.go +++ b/e2e/tests/init_test.go @@ -171,7 +171,7 @@ func (s *suite) ThePocketdBinaryShouldExitWithoutError() { func (s *suite) TheUserRunsTheCommand(cmd string) { cmds := strings.Split(cmd, " ") res, err := s.pocketd.RunCommand(cmds...) - require.NoError(s, err, "error running command %s", cmd) + require.NoError(s, err, "error running command %s due to: %v", cmd, err) s.pocketd.result = res } @@ -192,7 +192,7 @@ func (s *suite) TheUserSendsUpoktFromAccountToAccount(amount int64, accName1, ac "-y", } res, err := s.pocketd.RunCommandOnHost("", args...) - require.NoError(s, err, "error sending upokt from %q to %q", accName1, accName2) + require.NoError(s, err, "error sending upokt from %q to %q due to: %v", accName1, accName2, err) s.pocketd.result = res } @@ -267,6 +267,7 @@ func (s *suite) TheUserStakesAWithUpoktFromTheAccount(actorType string, amount i "-y", } res, err := s.pocketd.RunCommandOnHost("", args...) + require.NoError(s, err, "error staking %s due to: %v", actorType, err) // Remove the temporary config file err = os.Remove(configFile.Name()) @@ -301,7 +302,7 @@ func (s *suite) TheUserStakesAWithUpoktForServiceFromTheAccount(actorType string "-y", } res, err := s.pocketd.RunCommandOnHost("", args...) - require.NoError(s, err, "error staking %s for service %s", actorType, serviceId) + require.NoError(s, err, "error staking %s for service %s due to: %v", actorType, serviceId, err) // Remove the temporary config file err = os.Remove(configFile.Name()) @@ -372,7 +373,7 @@ func (s *suite) TheUserUnstakesAFromTheAccount(actorType string, accName string) } res, err := s.pocketd.RunCommandOnHost("", args...) - require.NoError(s, err, "error unstaking %s", actorType) + require.NoError(s, err, "error unstaking %s due to: %v", actorType, err) // Get current balance balanceKey := accBalanceKey(accName) @@ -463,7 +464,7 @@ func (s *suite) TheApplicationSendsTheSupplierASuccessfulRequestForServiceWithPa appAddr := accNameToAddrMap[appName] res, err := s.pocketd.RunCurlWithRetry(pathUrl, serviceId, method, path, appAddr, requestData, 5) - require.NoError(s, err, "error sending relay request from app %q to supplier %q for service %q", appName, supplierOperatorName, serviceId) + require.NoError(s, err, "error sending relay request from app %q to supplier %q for service %q due to: %v", appName, supplierOperatorName, serviceId, err) var jsonContent json.RawMessage err = json.Unmarshal([]byte(res.Stdout), &jsonContent) @@ -761,11 +762,10 @@ func (s *suite) getSupplierInfo(supplierOperatorName string) *sharedtypes.Suppli supplierOperatorAddr, "--output=json", } - fmt.Println("OLSH1") + res, err := s.pocketd.RunCommandOnHostWithRetry("", numQueryRetries, args...) - require.NoError(s, err, "error getting supplier %s", supplierOperatorAddr) + require.NoError(s, err, "error getting supplier %s due to error: %v", supplierOperatorAddr, err) s.pocketd.result = res - fmt.Println("OLSH2") var resp suppliertypes.QueryGetSupplierResponse responseBz := []byte(strings.TrimSpace(res.Stdout)) diff --git a/e2e/tests/node.go b/e2e/tests/node.go index 8d0f8710d..6620c995e 100644 --- a/e2e/tests/node.go +++ b/e2e/tests/node.go @@ -93,7 +93,18 @@ func (p *pocketdBin) RunCommandOnHostWithRetry(rpcUrl string, numRetries uint8, if err == nil { return res, nil } - // TODO_HACK: Figure out a better solution for retries. A parameter? Exponential backoff? What else? + // DEV_NOTE: Intentionally keeping a print statement here so errors are + // very visible even though the output may be noisy. + fmt.Printf(` +---------------------------------------- +Retrying command due to error: + - RPC URL: %s + - Arguments: %v + - Response: %v + - Error: %v +---------------------------------------- +`, rpcUrl, args, res, err) + // TODO_TECHDEBT(@bryanchriswhite): Figure out a better solution for retries. A parameter? Exponential backoff? What else? time.Sleep(5 * time.Second) return p.RunCommandOnHostWithRetry(rpcUrl, numRetries-1, args...) } diff --git a/x/supplier/keeper/query_supplier.go b/x/supplier/keeper/query_supplier.go index a0d2c1e9d..bdecfd975 100644 --- a/x/supplier/keeper/query_supplier.go +++ b/x/supplier/keeper/query_supplier.go @@ -92,5 +92,9 @@ func (k Keeper) Supplier( return nil, status.Error(codes.NotFound, msg) } + // TODO_MAINNET(@olshansk, #1033): Newer version of the CosmosSDK doesn't support maps. + // Decide on a direction w.r.t maps in protos based on feedback from the CosmoSDK team. + supplier.ServicesActivationHeightsMap = nil + return &types.QueryGetSupplierResponse{Supplier: supplier}, nil } From 96f2f288d7398d4d6a64a5b14c2df92b5bbe3597 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Mon, 20 Jan 2025 13:13:17 -0500 Subject: [PATCH 24/24] Uncomment part of E2E tests --- e2e/tests/stake_supplier.feature | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/e2e/tests/stake_supplier.feature b/e2e/tests/stake_supplier.feature index 9e655d0cc..3d9607fdc 100644 --- a/e2e/tests/stake_supplier.feature +++ b/e2e/tests/stake_supplier.feature @@ -21,14 +21,14 @@ Feature: Stake Supplier Namespace And the "supplier" for account "supplier2" is staked with "1000070" uPOKT And an account exists for "supplier2" When the user unstakes a "supplier" from the account "supplier2" - # Then the user should be able to see standard output containing "txhash:" - # And the user should be able to see standard output containing "code: 0" - # And the pocketd binary should exit without error + Then the user should be able to see standard output containing "txhash:" + And the user should be able to see standard output containing "code: 0" + And the pocketd binary should exit without error And the supplier for account "supplier2" is unbonding - # And the user should wait for the "supplier" module "SupplierUnbondingBegin" tx event to be broadcast - # And a "supplier" module "SupplierUnbondingEnd" end block event is broadcast - # And the user verifies the "supplier" for account "supplier2" is not staked - # And the account balance of "supplier2" should be "1000070" uPOKT "more" than before + And the user should wait for the "supplier" module "SupplierUnbondingBegin" tx event to be broadcast + And a "supplier" module "SupplierUnbondingEnd" end block event is broadcast + And the user verifies the "supplier" for account "supplier2" is not staked + And the account balance of "supplier2" should be "1000070" uPOKT "more" than before # TODO_MAINNET(@olshansk, #1033): Since the "to become active for service" step # requires reading "ServicesActivationHeightsMap", which is temporarily set to nil,