From 54742fe6b9b414cb21c4251888e05d1c1a892f47 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Thu, 16 Jan 2025 19:52:28 -0500 Subject: [PATCH] Reply to red0ne's comments --- api/poktroll/shared/service.pulsar.go | 57 +++++---- api/poktroll/supplier/query.pulsar.go | 2 +- localnet/poktrolld/config/config.toml | 4 +- .../config/supplier1_stake_config.yaml | 4 +- .../config/supplier_stake_config_example.yaml | 4 +- proto/poktroll/shared/service.proto | 4 +- proto/poktroll/supplier/query.proto | 1 + x/shared/types/service.pb.go | 108 +++++++++--------- x/shared/types/service_configs.go | 2 +- x/supplier/config/supplier_configs_reader.go | 6 +- x/supplier/keeper/query_supplier_test.go | 20 ++-- x/supplier/module/autocli.go | 2 +- .../keeper/token_logic_modules_test.go | 6 +- 13 files changed, 105 insertions(+), 115 deletions(-) diff --git a/api/poktroll/shared/service.pulsar.go b/api/poktroll/shared/service.pulsar.go index 9990cff20..131bf6936 100644 --- a/api/poktroll/shared/service.pulsar.go +++ b/api/poktroll/shared/service.pulsar.go @@ -2,6 +2,7 @@ package shared import ( + binary "encoding/binary" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" @@ -10,6 +11,7 @@ import ( protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" io "io" + math "math" reflect "reflect" sync "sync" ) @@ -2416,8 +2418,8 @@ func (x *fastReflection_ServiceRevenueShare) Range(f func(protoreflect.FieldDesc return } } - if x.RevSharePercentage != uint32(0) { - value := protoreflect.ValueOfUint32(x.RevSharePercentage) + if x.RevSharePercentage != float64(0) || math.Signbit(x.RevSharePercentage) { + value := protoreflect.ValueOfFloat64(x.RevSharePercentage) if !f(fd_ServiceRevenueShare_rev_share_percentage, value) { return } @@ -2440,7 +2442,7 @@ func (x *fastReflection_ServiceRevenueShare) Has(fd protoreflect.FieldDescriptor case "poktroll.shared.ServiceRevenueShare.address": return x.Address != "" case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": - return x.RevSharePercentage != uint32(0) + return x.RevSharePercentage != float64(0) || math.Signbit(x.RevSharePercentage) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2460,7 +2462,7 @@ func (x *fastReflection_ServiceRevenueShare) Clear(fd protoreflect.FieldDescript case "poktroll.shared.ServiceRevenueShare.address": x.Address = "" case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": - x.RevSharePercentage = uint32(0) + x.RevSharePercentage = float64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2482,7 +2484,7 @@ func (x *fastReflection_ServiceRevenueShare) Get(descriptor protoreflect.FieldDe return protoreflect.ValueOfString(value) case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": value := x.RevSharePercentage - return protoreflect.ValueOfUint32(value) + return protoreflect.ValueOfFloat64(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2506,7 +2508,7 @@ func (x *fastReflection_ServiceRevenueShare) Set(fd protoreflect.FieldDescriptor case "poktroll.shared.ServiceRevenueShare.address": x.Address = value.Interface().(string) case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": - x.RevSharePercentage = uint32(value.Uint()) + x.RevSharePercentage = value.Float() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2547,7 +2549,7 @@ func (x *fastReflection_ServiceRevenueShare) NewField(fd protoreflect.FieldDescr case "poktroll.shared.ServiceRevenueShare.address": return protoreflect.ValueOfString("") case "poktroll.shared.ServiceRevenueShare.rev_share_percentage": - return protoreflect.ValueOfUint32(uint32(0)) + return protoreflect.ValueOfFloat64(float64(0)) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ServiceRevenueShare")) @@ -2621,8 +2623,8 @@ func (x *fastReflection_ServiceRevenueShare) ProtoMethods() *protoiface.Methods if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } - if x.RevSharePercentage != 0 { - n += 1 + runtime.Sov(uint64(x.RevSharePercentage)) + if x.RevSharePercentage != 0 || math.Signbit(x.RevSharePercentage) { + n += 9 } if x.unknownFields != nil { n += len(x.unknownFields) @@ -2653,10 +2655,11 @@ func (x *fastReflection_ServiceRevenueShare) ProtoMethods() *protoiface.Methods i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if x.RevSharePercentage != 0 { - i = runtime.EncodeVarint(dAtA, i, uint64(x.RevSharePercentage)) + if x.RevSharePercentage != 0 || math.Signbit(x.RevSharePercentage) { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(x.RevSharePercentage)))) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x19 } if len(x.Address) > 0 { i -= len(x.Address) @@ -2747,24 +2750,16 @@ func (x *fastReflection_ServiceRevenueShare) ProtoMethods() *protoiface.Methods x.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 0 { + if wireType != 1 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field RevSharePercentage", wireType) } - x.RevSharePercentage = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - x.RevSharePercentage |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } + var v uint64 + if (iNdEx + 8) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + x.RevSharePercentage = float64(math.Float64frombits(v)) default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -3603,8 +3598,8 @@ type ServiceRevenueShare struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the revenue share recipient - RevSharePercentage uint32 `protobuf:"varint,3,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` // The percentage of revenue share the recipient will receive + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the revenue share recipient + RevSharePercentage float64 `protobuf:"fixed64,3,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` // The percentage of revenue share the recipient will receive } func (x *ServiceRevenueShare) Reset() { @@ -3634,7 +3629,7 @@ func (x *ServiceRevenueShare) GetAddress() string { return "" } -func (x *ServiceRevenueShare) GetRevSharePercentage() uint32 { +func (x *ServiceRevenueShare) GetRevSharePercentage() float64 { if x != nil { return x.RevSharePercentage } @@ -3735,7 +3730,7 @@ var file_poktroll_shared_service_proto_rawDesc = []byte{ 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x30, 0x0a, 0x14, 0x72, 0x65, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x5f, 0x70, 0x65, - 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x12, + 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x12, 0x72, 0x65, 0x76, 0x53, 0x68, 0x61, 0x72, 0x65, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x22, 0x56, 0x0a, 0x0c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x30, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, diff --git a/api/poktroll/supplier/query.pulsar.go b/api/poktroll/supplier/query.pulsar.go index 270ce57f6..392f4aa39 100644 --- a/api/poktroll/supplier/query.pulsar.go +++ b/api/poktroll/supplier/query.pulsar.go @@ -2848,7 +2848,7 @@ type QueryGetSupplierRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` + OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` // TODO_TECHDEBT: Add the ability to query for a supplier by owner_id } func (x *QueryGetSupplierRequest) Reset() { diff --git a/localnet/poktrolld/config/config.toml b/localnet/poktrolld/config/config.toml index bbfa0366f..35dcda640 100644 --- a/localnet/poktrolld/config/config.toml +++ b/localnet/poktrolld/config/config.toml @@ -174,7 +174,7 @@ timeout_broadcast_tx_commit = "10s" max_request_batch_size = 10 # Maximum size of request body, in bytes -max_body_bytes = 1000000 +max_body_bytes = 100000000 # Maximum size of request header, in bytes max_header_bytes = 1048576 @@ -330,7 +330,7 @@ keep-invalid-txs-in-cache = false # Maximum size of a single transaction. # NOTE: the max size of a tx transmitted over the network is {max_tx_bytes}. -max_tx_bytes = 1048576 +max_tx_bytes = 100000000 # Maximum size of a batch of transactions to send to a peer # Including space needed by encoding (one varint per transaction). diff --git a/localnet/poktrolld/config/supplier1_stake_config.yaml b/localnet/poktrolld/config/supplier1_stake_config.yaml index 046fddb4c..e3d475939 100644 --- a/localnet/poktrolld/config/supplier1_stake_config.yaml +++ b/localnet/poktrolld/config/supplier1_stake_config.yaml @@ -2,8 +2,8 @@ owner_address: pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 operator_address: pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 stake_amount: 1000069upokt default_rev_share_percent: - pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4: 80 - pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw: 20 + pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4: 80.5 + pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw: 19.5 services: - service_id: anvil endpoints: diff --git a/localnet/poktrolld/config/supplier_stake_config_example.yaml b/localnet/poktrolld/config/supplier_stake_config_example.yaml index 2fef94f0b..ce14f4a08 100644 --- a/localnet/poktrolld/config/supplier_stake_config_example.yaml +++ b/localnet/poktrolld/config/supplier_stake_config_example.yaml @@ -30,8 +30,8 @@ stake_amount: 1000069upokt # or include at least one item. default_rev_share_percent: # The sum of all shares MUST equal 100%. Staking will fail otherwise. - pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4: 80 - pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw: 20 + pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4: 80.5 + pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw: 19.5 services: # The endpoint URL for the Anvil service is provided via the RelayMiner. # The RelayMiner acts as a proxy, forwarding requests to the actual Anvil data node behind it. diff --git a/proto/poktroll/shared/service.proto b/proto/poktroll/shared/service.proto index 6df07cdcb..8d400dd33 100644 --- a/proto/poktroll/shared/service.proto +++ b/proto/poktroll/shared/service.proto @@ -57,11 +57,11 @@ message SupplierEndpoint { // ServiceRevenueShare message to hold revenue share configuration details message ServiceRevenueShare { - // 2 was reserved in #1028 during the change of rev_share_percentage from float to uint32 + // 2 was reserved in #1028 during the change of rev_share_percentage from float to double reserved 2; string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the revenue share recipient - uint32 rev_share_percentage = 3; // The percentage of revenue share the recipient will receive + double rev_share_percentage = 3; // The percentage of revenue share the recipient will receive } // Enum to define RPC types diff --git a/proto/poktroll/supplier/query.proto b/proto/poktroll/supplier/query.proto index 585d9ad07..71de22f24 100644 --- a/proto/poktroll/supplier/query.proto +++ b/proto/poktroll/supplier/query.proto @@ -45,6 +45,7 @@ message QueryParamsResponse { message QueryGetSupplierRequest { string operator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // TODO_TECHDEBT: Add the ability to query for a supplier by owner_id } message QueryGetSupplierResponse { diff --git a/x/shared/types/service.pb.go b/x/shared/types/service.pb.go index fd0704264..b483b2743 100644 --- a/x/shared/types/service.pb.go +++ b/x/shared/types/service.pb.go @@ -7,6 +7,7 @@ package types import ( + encoding_binary "encoding/binary" fmt "fmt" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/gogoproto/gogoproto" @@ -320,8 +321,8 @@ func (m *SupplierEndpoint) GetConfigs() []*ConfigOption { // ServiceRevenueShare message to hold revenue share configuration details type ServiceRevenueShare struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - RevSharePercentage uint32 `protobuf:"varint,3,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + RevSharePercentage float64 `protobuf:"fixed64,3,opt,name=rev_share_percentage,json=revSharePercentage,proto3" json:"rev_share_percentage,omitempty"` } func (m *ServiceRevenueShare) Reset() { *m = ServiceRevenueShare{} } @@ -360,7 +361,7 @@ func (m *ServiceRevenueShare) GetAddress() string { return "" } -func (m *ServiceRevenueShare) GetRevSharePercentage() uint32 { +func (m *ServiceRevenueShare) GetRevSharePercentage() float64 { if m != nil { return m.RevSharePercentage } @@ -432,45 +433,45 @@ func init() { proto.RegisterFile("poktroll/shared/service.proto", fileDescriptor var fileDescriptor_302c2f793a11ae1e = []byte{ // 630 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcf, 0x6e, 0xd3, 0x4e, - 0x10, 0xce, 0xc6, 0xf9, 0xfd, 0x92, 0x4c, 0x9b, 0xd4, 0x1a, 0x82, 0x30, 0x95, 0x6a, 0x95, 0x88, + 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, 0x11, 0x88, 0xdb, 0x78, 0xbe, 0x6f, 0x66, 0xbe, 0xfd, 0x76, 0xbc, 0xb0, 0x16, - 0xf0, 0x8b, 0x48, 0x70, 0xcf, 0x6b, 0x87, 0xe7, 0x96, 0x60, 0x4e, 0x3b, 0x64, 0x62, 0xea, 0xda, - 0xac, 0x15, 0x08, 0x1e, 0x71, 0x5c, 0xc9, 0xe1, 0x56, 0x0a, 0xaf, 0x3e, 0xb4, 0x79, 0x38, 0xe1, - 0xa1, 0x99, 0xc0, 0xed,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x55, 0xb0, 0xa9, 0x99, 0x30, - 0x35, 0x25, 0x69, 0xf0, 0xf8, 0x6e, 0x83, 0x74, 0x1e, 0x65, 0x53, 0xe6, 0xc7, 0xcc, 0x90, 0x49, - 0x5a, 0x11, 0x6c, 0x9a, 0x44, 0xcd, 0x0f, 0x04, 0xd4, 0xdb, 0x23, 0x50, 0x05, 0x25, 0x16, 0x5e, - 0x26, 0x58, 0x86, 0xb8, 0x03, 0x15, 0x11, 0xd8, 0x66, 0x34, 0x0b, 0xd2, 0xcb, 0xaa, 0x77, 0xb4, - 0x3b, 0x83, 0xe8, 0xb0, 0x3b, 0x9a, 0x05, 0x8c, 0x96, 0x45, 0x60, 0xcb, 0x00, 0x9f, 0x42, 0xd9, - 0x4e, 0x8c, 0x08, 0x33, 0x71, 0x6b, 0x77, 0x6a, 0x52, 0xa3, 0x06, 0x81, 0x34, 0x9d, 0xe6, 0xec, - 0xe6, 0x3b, 0x02, 0xf7, 0x7e, 0x23, 0x1b, 0x3b, 0x50, 0xce, 0x6f, 0x97, 0xfc, 0xe5, 0x76, 0x73, - 0x22, 0x6e, 0x43, 0x63, 0xe1, 0x91, 0x5c, 0x25, 0x9b, 0xf9, 0x91, 0x35, 0x66, 0xc9, 0x2e, 0xd5, - 0x28, 0xe6, 0x46, 0x0c, 0x17, 0xc8, 0x61, 0xa9, 0x52, 0x54, 0x95, 0xe6, 0x2b, 0x58, 0xfe, 0x59, - 0x1c, 0x6e, 0x83, 0x72, 0xc1, 0x66, 0xc9, 0xdc, 0x7a, 0x47, 0xff, 0xe3, 0x41, 0x42, 0x2a, 0xa9, - 0xd8, 0x80, 0xff, 0xa6, 0x96, 0x17, 0xe7, 0xdb, 0x9d, 0x7e, 0x6c, 0x1e, 0x41, 0x39, 0x33, 0x0a, - 0x57, 0x60, 0xe9, 0xa4, 0x7f, 0xd4, 0x1f, 0x9c, 0xf6, 0x4d, 0x3a, 0xec, 0xaa, 0x05, 0xac, 0x40, - 0x69, 0x5f, 0x46, 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+ 0x0e, 0x64, 0x44, 0x70, 0x05, 0xaa, 0x67, 0xdd, 0x7d, 0xa3, 0xdf, 0x39, 0xee, 0x0e, 0xd5, 0x22, + 0x2e, 0x43, 0xe5, 0xc8, 0xe8, 0xa7, 0x34, 0x45, 0xd2, 0x68, 0xd7, 0x18, 0xaa, 0xa5, 0xad, 0x1d, + 0x58, 0xf9, 0x65, 0x30, 0x22, 0xd4, 0xf2, 0x96, 0x9d, 0x7e, 0xef, 0xe5, 0xe1, 0x81, 0x5a, 0xc0, + 0x25, 0x28, 0x0f, 0x0f, 0x4f, 0xba, 0xfd, 0xd3, 0xa1, 0x4a, 0xf6, 0x4f, 0xbe, 0xcc, 0x74, 0x72, + 0x3d, 0xd3, 0xc9, 0xcd, 0x4c, 0x27, 0xdf, 0x66, 0x3a, 0x79, 0x7f, 0xab, 0x17, 0xae, 0x6f, 0xf5, + 0xc2, 0xcd, 0xad, 0x5e, 0x78, 0xdd, 0x1a, 0xb9, 0xd1, 0x45, 0x7c, 0xde, 0xb4, 0xf9, 0xb8, 0x25, + 0x4f, 0xb8, 0xed, 0xb3, 0xe8, 0x8a, 0x8b, 0xcb, 0xd6, 0xfc, 0x91, 0x78, 0x9b, 0x3f, 0x13, 0x72, + 0x15, 0xc2, 0xf3, 0xff, 0x93, 0x7f, 0x7c, 0xf7, 0x7b, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1e, 0x46, + 0x55, 0xcc, 0x46, 0x04, 0x00, 0x00, } func (m *Service) Marshal() (dAtA []byte, err error) { @@ -680,9 +681,10 @@ func (m *ServiceRevenueShare) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if m.RevSharePercentage != 0 { - i = encodeVarintService(dAtA, i, uint64(m.RevSharePercentage)) + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.RevSharePercentage)))) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x19 } if len(m.Address) > 0 { i -= len(m.Address) @@ -835,7 +837,7 @@ func (m *ServiceRevenueShare) Size() (n int) { n += 1 + l + sovService(uint64(l)) } if m.RevSharePercentage != 0 { - n += 1 + sovService(uint64(m.RevSharePercentage)) + n += 9 } return n } @@ -1456,24 +1458,16 @@ func (m *ServiceRevenueShare) Unmarshal(dAtA []byte) error { m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 0 { + if wireType != 1 { return fmt.Errorf("proto: wrong wireType = %d for field RevSharePercentage", wireType) } - m.RevSharePercentage = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RevSharePercentage |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.RevSharePercentage = float64(math.Float64frombits(v)) default: iNdEx = preIndex skippy, err := skipService(dAtA[iNdEx:]) diff --git a/x/shared/types/service_configs.go b/x/shared/types/service_configs.go index 30e4cb7ae..019f8f442 100644 --- a/x/shared/types/service_configs.go +++ b/x/shared/types/service_configs.go @@ -95,7 +95,7 @@ func ValidateSupplierServiceConfigs(services []*SupplierServiceConfig) error { // ensuring that the sum of the revenue share percentages is 100. // NB: This function is unit tested via the supplier staking config tests. func ValidateServiceRevShare(revShareList []*ServiceRevenueShare) error { - revSharePercentageSum := uint32(0) + revSharePercentageSum := float64(0) if len(revShareList) == 0 { return ErrSharedInvalidRevShare.Wrap("no rev share configurations") diff --git a/x/supplier/config/supplier_configs_reader.go b/x/supplier/config/supplier_configs_reader.go index fc956f9c6..e07cc68c7 100644 --- a/x/supplier/config/supplier_configs_reader.go +++ b/x/supplier/config/supplier_configs_reader.go @@ -19,14 +19,14 @@ type YAMLStakeConfig struct { OperatorAddress string `yaml:"operator_address"` StakeAmount string `yaml:"stake_amount"` Services []*YAMLStakeService `yaml:"services"` - DefaultRevSharePercent map[string]uint32 `yaml:"default_rev_share_percent"` + DefaultRevSharePercent map[string]float64 `yaml:"default_rev_share_percent"` } // YAMLStakeService is the structure describing a single service entry in the // stake config file. type YAMLStakeService struct { ServiceId string `yaml:"service_id"` - RevSharePercent map[string]uint32 `yaml:"rev_share_percent"` + RevSharePercent map[string]float64 `yaml:"rev_share_percent"` Endpoints []YAMLServiceEndpoint `yaml:"endpoints"` } @@ -102,7 +102,7 @@ func ParseSupplierConfigs(ctx context.Context, configContent []byte) (*SupplierS ) } - defaultRevSharePercent := map[string]uint32{} + defaultRevSharePercent := map[string]float64{} if len(stakeConfig.DefaultRevSharePercent) == 0 { // Ensure that if no default rev share is provided, the owner address is set // to 100% rev share. diff --git a/x/supplier/keeper/query_supplier_test.go b/x/supplier/keeper/query_supplier_test.go index 93e57f6f4..8e3e240c1 100644 --- a/x/supplier/keeper/query_supplier_test.go +++ b/x/supplier/keeper/query_supplier_test.go @@ -71,7 +71,7 @@ func TestSupplierQuerySingle(t *testing.T) { func TestSupplierQueryPaginated(t *testing.T) { supplierModuleKeepers, ctx := keepertest.SupplierKeeper(t) - msgs := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 5) + suppliers := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 5) request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllSuppliersRequest { return &types.QueryAllSuppliersRequest{ @@ -85,12 +85,12 @@ func TestSupplierQueryPaginated(t *testing.T) { } t.Run("ByOffset", func(t *testing.T) { step := 2 - for i := 0; i < len(msgs); i += step { + for i := 0; i < len(suppliers); i += step { resp, err := supplierModuleKeepers.AllSuppliers(ctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.Supplier), step) require.Subset(t, - nullify.Fill(msgs), + nullify.Fill(suppliers), nullify.Fill(resp.Supplier), ) } @@ -98,12 +98,12 @@ func TestSupplierQueryPaginated(t *testing.T) { t.Run("ByKey", func(t *testing.T) { step := 2 var next []byte - for i := 0; i < len(msgs); i += step { + for i := 0; i < len(suppliers); i += step { resp, err := supplierModuleKeepers.AllSuppliers(ctx, request(next, 0, uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.Supplier), step) require.Subset(t, - nullify.Fill(msgs), + nullify.Fill(suppliers), nullify.Fill(resp.Supplier), ) next = resp.Pagination.NextKey @@ -112,9 +112,9 @@ func TestSupplierQueryPaginated(t *testing.T) { t.Run("Total", func(t *testing.T) { resp, err := supplierModuleKeepers.AllSuppliers(ctx, request(nil, 0, 0, true)) require.NoError(t, err) - require.Equal(t, len(msgs), int(resp.Pagination.Total)) + require.Equal(t, len(suppliers), int(resp.Pagination.Total)) require.ElementsMatch(t, - nullify.Fill(msgs), + nullify.Fill(suppliers), nullify.Fill(resp.Supplier), ) }) @@ -126,17 +126,17 @@ func TestSupplierQueryPaginated(t *testing.T) { func TestSupplierQueryFilterByServiceId(t *testing.T) { supplierModuleKeepers, ctx := keepertest.SupplierKeeper(t) - msgs := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 5) + suppliers := createNSuppliers(*supplierModuleKeepers.Keeper, ctx, 5) // Get the first service ID from the first supplier to use as filter - firstServiceId := msgs[0].Services[0].ServiceId + firstServiceId := suppliers[0].Services[0].ServiceId request := &types.QueryAllSuppliersRequest{ Filter: &types.QueryAllSuppliersRequest_ServiceId{ ServiceId: firstServiceId, }, Pagination: &query.PageRequest{ - Limit: uint64(len(msgs)), + Limit: uint64(len(suppliers)), }, } diff --git a/x/supplier/module/autocli.go b/x/supplier/module/autocli.go index 50ff57418..2463a57a1 100644 --- a/x/supplier/module/autocli.go +++ b/x/supplier/module/autocli.go @@ -41,7 +41,7 @@ Returns supplier addresses, staked amounts, service details, and current status. { Alias: []string{"supplier", "s"}, RpcMethod: "Supplier", - Use: "show-supplier [address]", + Use: "show-supplier [operator_address]", Short: "Shows detailed information about a specific supplier", Long: `Retrieves comprehensive information about a supplier identified by their address. diff --git a/x/tokenomics/keeper/token_logic_modules_test.go b/x/tokenomics/keeper/token_logic_modules_test.go index b70d32608..6cfb1cd08 100644 --- a/x/tokenomics/keeper/token_logic_modules_test.go +++ b/x/tokenomics/keeper/token_logic_modules_test.go @@ -45,7 +45,7 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Valid(t *testing.T) { // Test Parameters appInitialStake := apptypes.DefaultMinStake.Amount.Mul(cosmosmath.NewInt(2)) supplierInitialStake := cosmosmath.NewInt(1000000) - supplierRevShareRatios := []float32{12.5, 37.5, 50} + supplierRevShareRatios := []float64{12.5, 37.5, 50} globalComputeUnitsToTokensMultiplier := uint64(1) serviceComputeUnitsPerRelay := uint64(1) service := prepareTestService(serviceComputeUnitsPerRelay) @@ -447,7 +447,7 @@ func TestProcessTokenLogicModules_TLMGlobalMint_Valid_MintDistributionCorrect(t propMint := cosmosmath.NewInt(int64(numTokensMinted * tokenomicsParams.MintAllocationPercentages.Proposer)) serviceOwnerMint := cosmosmath.NewInt(int64(numTokensMinted * tokenomicsParams.MintAllocationPercentages.SourceOwner)) appMint := cosmosmath.NewInt(int64(numTokensMinted * tokenomicsParams.MintAllocationPercentages.Application)) - supplierMint := float32(numTokensMinted * tokenomicsParams.MintAllocationPercentages.Supplier) + supplierMint := float64(numTokensMinted * tokenomicsParams.MintAllocationPercentages.Supplier) // Ensure the balance was increased to the appropriate amount. require.Equal(t, daoBalanceBefore.Amount.Add(daoMint).Add(numTokensMintedInt), daoBalanceAfter.Amount) @@ -459,7 +459,7 @@ func TestProcessTokenLogicModules_TLMGlobalMint_Valid_MintDistributionCorrect(t balanceBefore := supplierShareholderBalancesBefore[addr] balanceAfter := supplierShareholderBalancesAfter[addr].Amount.Int64() mintShare := int64(supplierMint * revShare.RevSharePercentage / 100) - rewardShare := int64(float32(numTokensClaimed) * revShare.RevSharePercentage / 100) + rewardShare := int64(float64(numTokensClaimed) * revShare.RevSharePercentage / 100) balanceIncrease := cosmosmath.NewInt(mintShare + rewardShare) expectedBalanceAfter := balanceBefore.Amount.Add(balanceIncrease).Int64() // TODO_MAINNET(@red-0ne): Remove the InDelta check and use the exact amount once the floating point arithmetic is fixed