diff --git a/.github/workflows-helpers/run-e2e-test-job-template.yaml b/.github/workflows-helpers/run-e2e-test-job-template.yaml index 21d3f0e1a..ca03ca867 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/api/poktroll/application/types.pulsar.go b/api/poktroll/application/types.pulsar.go index 78bcffe29..21eb04ac4 100644 --- a/api/poktroll/application/types.pulsar.go +++ b/api/poktroll/application/types.pulsar.go @@ -2182,35 +2182,37 @@ 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. + // 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 // This prevents applications from over-servicing. - // The field is kept repeated (a list) for both legacy and future logic reaosns. - // References: + // 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 - 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 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"` - // 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/service.pulsar.go b/api/poktroll/shared/service.pulsar.go index 92dcfb12b..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 != float32(0) || math.Signbit(float64(x.RevSharePercentage)) { - value := protoreflect.ValueOfFloat32(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 != float32(0) || math.Signbit(float64(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 = float32(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.ValueOfFloat32(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 = float32(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.ValueOfFloat32(float32(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(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] = 0x18 } if len(x.Address) > 0 { i -= len(x.Address) @@ -2749,17 +2746,25 @@ func (x *fastReflection_ServiceRevenueShare) ProtoMethods() *protoiface.Methods } x.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: - if wireType != 5 { + case 3: + 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 |= uint64(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 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() float32 { +func (x *ServiceRevenueShare) GetRevSharePercentage() uint64 { if x != nil { return x.RevSharePercentage } @@ -3724,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, 0x02, 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, 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, + 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/api/poktroll/shared/supplier.pulsar.go b/api/poktroll/shared/supplier.pulsar.go index be0da6a07..8ac084889 100644 --- a/api/poktroll/shared/supplier.pulsar.go +++ b/api/poktroll/shared/supplier.pulsar.go @@ -1066,29 +1066,30 @@ 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 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"` + // 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 + // 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/api/poktroll/supplier/query.pulsar.go b/api/poktroll/supplier/query.pulsar.go index d1f087c62..392f4aa39 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:]) @@ -2755,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() { @@ -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"` // unique service identifier to filter by +} + +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/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/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/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/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/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..32446be7a 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. @@ -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/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/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/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/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/e2e/tests/init_test.go b/e2e/tests/init_test.go index 680806c87..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) @@ -569,11 +570,22 @@ 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 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) + } 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 @@ -662,7 +674,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...) @@ -752,7 +764,7 @@ func (s *suite) getSupplierInfo(supplierOperatorName string) *sharedtypes.Suppli } 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 var resp suppliertypes.QueryGetSupplierResponse 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/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/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 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/makefiles/suppliers.mk b/makefiles/suppliers.mk index 2cceb2d8f..2e0f885e8 100644 --- a/makefiles/suppliers.mk +++ b/makefiles/suppliers.mk @@ -4,7 +4,15 @@ .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_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) 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/proto/poktroll/application/types.proto b/proto/poktroll/application/types.proto index 8982cecda..81e7e893e 100644 --- a/proto/poktroll/application/types.proto +++ b/proto/poktroll/application/types.proto @@ -14,30 +14,38 @@ 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. + // 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 // 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 + // 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 + 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 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]; - // 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 00dac4300..340c89abb 100644 --- a/proto/poktroll/shared/service.proto +++ b/proto/poktroll/shared/service.proto @@ -57,8 +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 uint64 + // 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 - float rev_share_percentage = 2; // 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/proto/poktroll/shared/supplier.proto b/proto/poktroll/shared/supplier.proto index dfa6689ae..7b88dff05 100644 --- a/proto/poktroll/shared/supplier.proto +++ b/proto/poktroll/shared/supplier.proto @@ -10,24 +10,30 @@ 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 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 + 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 + // 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/proto/poktroll/supplier/query.proto b/proto/poktroll/supplier/query.proto index cb7a4d31a..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 { @@ -53,6 +54,10 @@ message QueryGetSupplierResponse { message QueryAllSuppliersRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1; + + oneof filter { + string service_id = 2; // unique service identifier to filter by + } } message QueryAllSuppliersResponse { 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/application/types/types.pb.go b/x/application/types/types.pb.go index 4a7e43bba..ec942dee4 100644 --- a/x/application/types/types.pb.go +++ b/x/application/types/types.pb.go @@ -27,31 +27,33 @@ 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. + // 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 // 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 + // 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 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 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"` - // 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/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/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", diff --git a/x/shared/types/service.pb.go b/x/shared/types/service.pb.go index 358154b9f..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 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 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() float32 { +func (m *ServiceRevenueShare) GetRevSharePercentage() uint64 { if m != nil { return m.RevSharePercentage } @@ -431,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, 0x36, 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, 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 0x4d, 0x7e, 0xee, 0xdd, 0x1f, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x19, 0xf1, 0x60, 0x3f, 0x04, 0x00, 0x00, + // 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, + 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, 0x10, 0x88, 0xdb, 0x78, 0xbe, 0x6f, 0x66, 0xbe, 0xfd, 0x76, 0xbc, 0xb0, 0x1e, + 0xf0, 0xcb, 0x48, 0x70, 0xcf, 0x6b, 0x85, 0x17, 0x96, 0x60, 0x4e, 0x2b, 0x64, 0x62, 0xe2, 0xda, + 0xac, 0x19, 0x08, 0x1e, 0x71, 0x5c, 0xcd, 0xe1, 0x66, 0x0a, 0xaf, 0x3d, 0xb4, 0x79, 0x38, 0xe6, + 0xa1, 0x99, 0xc0, 0xad, 0xf4, 0x23, 0xe5, 0xae, 0xd5, 0x47, 0x7c, 0xc4, 0xd3, 0xbc, 0x8c, 0xd2, + 0x6c, 0xe3, 0x23, 0x81, 0xb2, 0x91, 0xf6, 0xc4, 0x1a, 0x14, 0x5d, 0x47, 0x23, 0x1b, 0x64, 0xb3, + 0x4a, 0x8b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+ 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) { @@ -680,10 +680,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] = 0x18 } if len(m.Address) > 0 { i -= len(m.Address) @@ -836,7 +835,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 } @@ -1456,17 +1455,25 @@ func (m *ServiceRevenueShare) Unmarshal(dAtA []byte) error { } m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: - if wireType != 5 { + case 3: + 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 |= uint64(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..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 := float32(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/shared/types/supplier.pb.go b/x/shared/types/supplier.pb.go index 9c0287112..dee27dc69 100644 --- a/x/shared/types/supplier.pb.go +++ b/x/shared/types/supplier.pb.go @@ -26,25 +26,26 @@ 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 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"` + // 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 + // 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/config/supplier_configs_reader.go b/x/supplier/config/supplier_configs_reader.go index c2f009c2e..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]float32 `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]float32 `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]float32{} + 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/supplier/keeper/query_supplier.go b/x/supplier/keeper/query_supplier.go index 3d370a8fa..bdecfd975 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,25 @@ 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 + } + } + + // 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 }, @@ -62,10 +88,13 @@ 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) } + // 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 } diff --git a/x/supplier/keeper/query_supplier_test.go b/x/supplier/keeper/query_supplier_test.go index b0d448ec4..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,8 @@ 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 request *types.QueryGetSupplierRequest @@ -43,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", @@ -70,7 +74,13 @@ 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) + + // 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{ @@ -84,12 +94,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), ) } @@ -97,12 +107,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 @@ -111,9 +121,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), ) }) @@ -122,3 +132,39 @@ 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) + suppliers := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 5) + + // Get the first service ID from the first supplier to use as filter + firstServiceId := suppliers[0].Services[0].ServiceId + + request := &types.QueryAllSuppliersRequest{ + Filter: &types.QueryAllSuppliersRequest_ServiceId{ + ServiceId: firstServiceId, + }, + Pagination: &query.PageRequest{ + Limit: uint64(len(suppliers)), + }, + } + + 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 + 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/keeper/supplier_test.go b/x/supplier/keeper/supplier_test.go index 8cbddd555..cde7952c5 100644 --- a/x/supplier/keeper/supplier_test.go +++ b/x/supplier/keeper/supplier_test.go @@ -8,8 +8,11 @@ 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" + "google.golang.org/grpc/codes" "github.com/pokt-network/poktroll/cmd/poktrolld/cmd" keepertest "github.com/pokt-network/poktroll/testutil/keeper" @@ -27,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 { @@ -59,7 +56,15 @@ func createNSuppliers(keeper keeper.Keeper, ctx context.Context, n int) []shared return suppliers } -func TestSupplierGet(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 { @@ -74,7 +79,7 @@ func TestSupplierGet(t *testing.T) { } } -func TestSupplierRemove(t *testing.T) { +func TestSupplier_Remove(t *testing.T) { supplierModuleKeepers, ctx := keepertest.SupplierKeeper(t) suppliers := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 10) for _, supplier := range suppliers { @@ -86,7 +91,7 @@ func TestSupplierRemove(t *testing.T) { } } -func TestSupplierGetAll(t *testing.T) { +func TestSupplier_GetAll(t *testing.T) { supplierModuleKeepers, ctx := keepertest.SupplierKeeper(t) suppliers := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 10) require.ElementsMatch(t, @@ -94,3 +99,145 @@ func TestSupplierGetAll(t *testing.T) { nullify.Fill(supplierModuleKeepers.GetAllSuppliers(ctx)), ) } + +func TestSupplier_Query(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.ErrorContains(t, stat.Err(), test.expectedErr.Error()) + } else { + require.NoError(t, err) + require.NotNil(t, response) + require.Equal(t, + nullify.Fill(test.response), + nullify.Fill(response), + ) + } + }) + } +} + +func TestSuppliers_QueryAll_Pagination(t *testing.T) { + keeper, ctx := keepertest.SupplierKeeper(t) + suppliers := createNSuppliers(*keeper.Keeper, ctx, 5) + + 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), + ) + }) +} + +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/autocli.go b/x/supplier/module/autocli.go index 716e3774f..a64176dd8 100644 --- a/x/supplier/module/autocli.go +++ b/x/supplier/module/autocli.go @@ -10,30 +10,58 @@ 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", - // 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", + // }, + { + Alias: []string{"suppliers", "ls"}, + RpcMethod: "AllSuppliers", + 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 + 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}, + }, + }, + { + Alias: []string{"supplier", "s"}, + RpcMethod: "Supplier", + Use: "show-supplier [operator_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 }, }, 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..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 81a18454e..000000000 --- a/x/supplier/module/query_supplier.go +++ /dev/null @@ -1,78 +0,0 @@ -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", - 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 deleted file mode 100644 index 78c529d90..000000000 --- a/x/supplier/module/query_supplier_test.go +++ /dev/null @@ -1,140 +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 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) - - ctx := net.Validators[0].ClientCtx - request := func(next []byte, offset, limit uint64, total bool) []string { - args := []string{ - fmt.Sprintf("--%s=json", cometcli.OutputFlag), - } - 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)) - if total { - args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal)) - } - 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), - ) - }) -} 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.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, 0x40, 0x85, 0x58, 0x58, 0x58, 0x91, 0x18, 0x99, 0xd8, - 0x3a, 0x32, 0xf0, 0x21,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aa, - 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, 0x98, 0xae, 0xdb, 0x45, 0x88, 0x1e, 0xc7, 0x0e, 0xb6, + 0x15, 0xc9, 0x23, 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00, 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:]) diff --git a/x/supplier/types/query_validation.go b/x/supplier/types/query_validation.go new file mode 100644 index 000000000..ccab23065 --- /dev/null +++ b/x/supplier/types/query_validation.go @@ -0,0 +1,44 @@ +package types + +import ( + "context" + + 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 +// 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 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 listing suppliers") + } + + return nil +} diff --git a/x/tokenomics/keeper/token_logic_modules_test.go b/x/tokenomics/keeper/token_logic_modules_test.go index b70d32608..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 := []float32{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 := []float32{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 := []float32{12.5, 37.5, 50} + supplierRevShareRatios := []uint64{12, 38, 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) @@ -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(float32(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