diff --git a/api/poktroll/session/query.pulsar.go b/api/poktroll/session/query.pulsar.go index 413732a82..af6a9e120 100644 --- a/api/poktroll/session/query.pulsar.go +++ b/api/poktroll/session/query.pulsar.go @@ -3,7 +3,7 @@ package session import ( _ "cosmossdk.io/api/amino" - shared "github.com/pokt-network/poktroll/api/poktroll/shared" + _ "github.com/pokt-network/poktroll/api/poktroll/shared" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" @@ -811,7 +811,7 @@ func (x *fastReflection_QueryParamsResponse) ProtoMethods() *protoiface.Methods var ( md_QueryGetSessionRequest protoreflect.MessageDescriptor fd_QueryGetSessionRequest_application_address protoreflect.FieldDescriptor - fd_QueryGetSessionRequest_service protoreflect.FieldDescriptor + fd_QueryGetSessionRequest_service_id protoreflect.FieldDescriptor fd_QueryGetSessionRequest_block_height protoreflect.FieldDescriptor ) @@ -819,7 +819,7 @@ func init() { file_poktroll_session_query_proto_init() md_QueryGetSessionRequest = File_poktroll_session_query_proto.Messages().ByName("QueryGetSessionRequest") fd_QueryGetSessionRequest_application_address = md_QueryGetSessionRequest.Fields().ByName("application_address") - fd_QueryGetSessionRequest_service = md_QueryGetSessionRequest.Fields().ByName("service") + fd_QueryGetSessionRequest_service_id = md_QueryGetSessionRequest.Fields().ByName("service_id") fd_QueryGetSessionRequest_block_height = md_QueryGetSessionRequest.Fields().ByName("block_height") } @@ -894,9 +894,9 @@ func (x *fastReflection_QueryGetSessionRequest) Range(f func(protoreflect.FieldD return } } - if x.Service != nil { - value := protoreflect.ValueOfMessage(x.Service.ProtoReflect()) - if !f(fd_QueryGetSessionRequest_service, value) { + if x.ServiceId != "" { + value := protoreflect.ValueOfString(x.ServiceId) + if !f(fd_QueryGetSessionRequest_service_id, value) { return } } @@ -923,8 +923,8 @@ func (x *fastReflection_QueryGetSessionRequest) Has(fd protoreflect.FieldDescrip switch fd.FullName() { case "poktroll.session.QueryGetSessionRequest.application_address": return x.ApplicationAddress != "" - case "poktroll.session.QueryGetSessionRequest.service": - return x.Service != nil + case "poktroll.session.QueryGetSessionRequest.service_id": + return x.ServiceId != "" case "poktroll.session.QueryGetSessionRequest.block_height": return x.BlockHeight != int64(0) default: @@ -945,8 +945,8 @@ func (x *fastReflection_QueryGetSessionRequest) Clear(fd protoreflect.FieldDescr switch fd.FullName() { case "poktroll.session.QueryGetSessionRequest.application_address": x.ApplicationAddress = "" - case "poktroll.session.QueryGetSessionRequest.service": - x.Service = nil + case "poktroll.session.QueryGetSessionRequest.service_id": + x.ServiceId = "" case "poktroll.session.QueryGetSessionRequest.block_height": x.BlockHeight = int64(0) default: @@ -968,9 +968,9 @@ func (x *fastReflection_QueryGetSessionRequest) Get(descriptor protoreflect.Fiel case "poktroll.session.QueryGetSessionRequest.application_address": value := x.ApplicationAddress return protoreflect.ValueOfString(value) - case "poktroll.session.QueryGetSessionRequest.service": - value := x.Service - return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "poktroll.session.QueryGetSessionRequest.service_id": + value := x.ServiceId + return protoreflect.ValueOfString(value) case "poktroll.session.QueryGetSessionRequest.block_height": value := x.BlockHeight return protoreflect.ValueOfInt64(value) @@ -996,8 +996,8 @@ func (x *fastReflection_QueryGetSessionRequest) Set(fd protoreflect.FieldDescrip switch fd.FullName() { case "poktroll.session.QueryGetSessionRequest.application_address": x.ApplicationAddress = value.Interface().(string) - case "poktroll.session.QueryGetSessionRequest.service": - x.Service = value.Message().Interface().(*shared.Service) + case "poktroll.session.QueryGetSessionRequest.service_id": + x.ServiceId = value.Interface().(string) case "poktroll.session.QueryGetSessionRequest.block_height": x.BlockHeight = value.Int() default: @@ -1020,13 +1020,10 @@ func (x *fastReflection_QueryGetSessionRequest) Set(fd protoreflect.FieldDescrip // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetSessionRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.session.QueryGetSessionRequest.service": - if x.Service == nil { - x.Service = new(shared.Service) - } - return protoreflect.ValueOfMessage(x.Service.ProtoReflect()) case "poktroll.session.QueryGetSessionRequest.application_address": panic(fmt.Errorf("field application_address of message poktroll.session.QueryGetSessionRequest is not mutable")) + case "poktroll.session.QueryGetSessionRequest.service_id": + panic(fmt.Errorf("field service_id of message poktroll.session.QueryGetSessionRequest is not mutable")) case "poktroll.session.QueryGetSessionRequest.block_height": panic(fmt.Errorf("field block_height of message poktroll.session.QueryGetSessionRequest is not mutable")) default: @@ -1044,9 +1041,8 @@ func (x *fastReflection_QueryGetSessionRequest) NewField(fd protoreflect.FieldDe switch fd.FullName() { case "poktroll.session.QueryGetSessionRequest.application_address": return protoreflect.ValueOfString("") - case "poktroll.session.QueryGetSessionRequest.service": - m := new(shared.Service) - return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "poktroll.session.QueryGetSessionRequest.service_id": + return protoreflect.ValueOfString("") case "poktroll.session.QueryGetSessionRequest.block_height": return protoreflect.ValueOfInt64(int64(0)) default: @@ -1122,8 +1118,8 @@ func (x *fastReflection_QueryGetSessionRequest) ProtoMethods() *protoiface.Metho if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } - if x.Service != nil { - l = options.Size(x.Service) + l = len(x.ServiceId) + if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } if x.BlockHeight != 0 { @@ -1163,17 +1159,10 @@ func (x *fastReflection_QueryGetSessionRequest) ProtoMethods() *protoiface.Metho i-- dAtA[i] = 0x18 } - if x.Service != nil { - encoded, err := options.Marshal(x.Service) - if err != nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + if len(x.ServiceId) > 0 { + i -= len(x.ServiceId) + copy(dAtA[i:], x.ServiceId) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ServiceId))) i-- dAtA[i] = 0x12 } @@ -1267,9 +1256,9 @@ func (x *fastReflection_QueryGetSessionRequest) ProtoMethods() *protoiface.Metho iNdEx = postIndex case 2: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Service", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ServiceId", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -1279,27 +1268,23 @@ func (x *fastReflection_QueryGetSessionRequest) ProtoMethods() *protoiface.Metho } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } - postIndex := iNdEx + msglen + 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 } - if x.Service == nil { - x.Service = &shared.Service{} - } - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Service); err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } + x.ServiceId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 0 { @@ -1872,9 +1857,9 @@ type QueryGetSessionRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ApplicationAddress string `protobuf:"bytes,1,opt,name=application_address,json=applicationAddress,proto3" json:"application_address,omitempty"` // The Bech32 address of the application. - Service *shared.Service `protobuf:"bytes,2,opt,name=service,proto3" json:"service,omitempty"` // The service to query the session for - BlockHeight int64 `protobuf:"varint,3,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` // The block height to query the session for + ApplicationAddress string `protobuf:"bytes,1,opt,name=application_address,json=applicationAddress,proto3" json:"application_address,omitempty"` // The Bech32 address of the application. + ServiceId string `protobuf:"bytes,2,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` // The service ID to query the session for + BlockHeight int64 `protobuf:"varint,3,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` // The block height to query the session for } func (x *QueryGetSessionRequest) Reset() { @@ -1904,11 +1889,11 @@ func (x *QueryGetSessionRequest) GetApplicationAddress() string { return "" } -func (x *QueryGetSessionRequest) GetService() *shared.Service { +func (x *QueryGetSessionRequest) GetServiceId() string { if x != nil { - return x.Service + return x.ServiceId } - return nil + return "" } func (x *QueryGetSessionRequest) GetBlockHeight() int64 { @@ -1977,54 +1962,52 @@ var file_poktroll_session_query_proto_rawDesc = []byte{ 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, - 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0xba, 0x01, 0x0a, 0x16, 0x51, 0x75, 0x65, + 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0xa5, 0x01, 0x0a, 0x16, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x49, 0x0a, 0x13, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 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, 0x12, 0x61, 0x70, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x32, - 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x18, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, - 0x64, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x69, 0x67, - 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, - 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x4e, 0x0a, 0x17, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, - 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x33, 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x32, 0xa6, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, - 0x84, 0x01, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x24, 0x2e, 0x70, 0x6f, 0x6b, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1d, + 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x21, 0x0a, + 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, + 0x22, 0x4e, 0x0a, 0x17, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x07, 0x73, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, + 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x32, 0xa6, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x84, 0x01, 0x0a, 0x06, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x24, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x70, 0x6f, + 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, + 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x2d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x12, 0x25, 0x2f, 0x70, 0x6f, 0x6b, + 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, + 0x73, 0x12, 0x95, 0x01, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x12, 0x28, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, - 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x25, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x12, - 0x25, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2f, - 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x95, 0x01, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x28, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, - 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, - 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x29, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x32, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x2c, 0x12, 0x2a, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, - 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x2f, 0x67, 0x65, 0x74, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0xaa, - 0x01, 0xd8, 0xe2, 0x1e, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x0a, 0x51, 0x75, 0x65, - 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x21, 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, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xa2, 0x02, 0x03, 0x50, - 0x53, 0x58, 0xaa, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xca, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, - 0x5c, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xe2, 0x02, 0x1c, 0x50, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, - 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x32, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2c, 0x12, 0x2a, 0x2f, + 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x67, 0x65, + 0x74, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0xaa, 0x01, 0xd8, 0xe2, 0x1e, 0x01, + 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x21, 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, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x10, + 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0xca, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0xe2, 0x02, 0x1c, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0xea, 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2046,22 +2029,20 @@ var file_poktroll_session_query_proto_goTypes = []interface{}{ (*QueryGetSessionRequest)(nil), // 2: poktroll.session.QueryGetSessionRequest (*QueryGetSessionResponse)(nil), // 3: poktroll.session.QueryGetSessionResponse (*Params)(nil), // 4: poktroll.session.Params - (*shared.Service)(nil), // 5: poktroll.shared.Service - (*Session)(nil), // 6: poktroll.session.Session + (*Session)(nil), // 5: poktroll.session.Session } var file_poktroll_session_query_proto_depIdxs = []int32{ 4, // 0: poktroll.session.QueryParamsResponse.params:type_name -> poktroll.session.Params - 5, // 1: poktroll.session.QueryGetSessionRequest.service:type_name -> poktroll.shared.Service - 6, // 2: poktroll.session.QueryGetSessionResponse.session:type_name -> poktroll.session.Session - 0, // 3: poktroll.session.Query.Params:input_type -> poktroll.session.QueryParamsRequest - 2, // 4: poktroll.session.Query.GetSession:input_type -> poktroll.session.QueryGetSessionRequest - 1, // 5: poktroll.session.Query.Params:output_type -> poktroll.session.QueryParamsResponse - 3, // 6: poktroll.session.Query.GetSession:output_type -> poktroll.session.QueryGetSessionResponse - 5, // [5:7] is the sub-list for method output_type - 3, // [3:5] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 5, // 1: poktroll.session.QueryGetSessionResponse.session:type_name -> poktroll.session.Session + 0, // 2: poktroll.session.Query.Params:input_type -> poktroll.session.QueryParamsRequest + 2, // 3: poktroll.session.Query.GetSession:input_type -> poktroll.session.QueryGetSessionRequest + 1, // 4: poktroll.session.Query.Params:output_type -> poktroll.session.QueryParamsResponse + 3, // 5: poktroll.session.Query.GetSession:output_type -> poktroll.session.QueryGetSessionResponse + 4, // [4:6] is the sub-list for method output_type + 2, // [2:4] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_poktroll_session_query_proto_init() } diff --git a/api/poktroll/session/types.pulsar.go b/api/poktroll/session/types.pulsar.go index 26fe0eec6..0a9c92f0b 100644 --- a/api/poktroll/session/types.pulsar.go +++ b/api/poktroll/session/types.pulsar.go @@ -19,7 +19,7 @@ import ( var ( md_SessionHeader protoreflect.MessageDescriptor fd_SessionHeader_application_address protoreflect.FieldDescriptor - fd_SessionHeader_service protoreflect.FieldDescriptor + fd_SessionHeader_service_id protoreflect.FieldDescriptor fd_SessionHeader_session_id protoreflect.FieldDescriptor fd_SessionHeader_session_start_block_height protoreflect.FieldDescriptor fd_SessionHeader_session_end_block_height protoreflect.FieldDescriptor @@ -29,7 +29,7 @@ func init() { file_poktroll_session_types_proto_init() md_SessionHeader = File_poktroll_session_types_proto.Messages().ByName("SessionHeader") fd_SessionHeader_application_address = md_SessionHeader.Fields().ByName("application_address") - fd_SessionHeader_service = md_SessionHeader.Fields().ByName("service") + fd_SessionHeader_service_id = md_SessionHeader.Fields().ByName("service_id") fd_SessionHeader_session_id = md_SessionHeader.Fields().ByName("session_id") fd_SessionHeader_session_start_block_height = md_SessionHeader.Fields().ByName("session_start_block_height") fd_SessionHeader_session_end_block_height = md_SessionHeader.Fields().ByName("session_end_block_height") @@ -106,9 +106,9 @@ func (x *fastReflection_SessionHeader) Range(f func(protoreflect.FieldDescriptor return } } - if x.Service != nil { - value := protoreflect.ValueOfMessage(x.Service.ProtoReflect()) - if !f(fd_SessionHeader_service, value) { + if x.ServiceId != "" { + value := protoreflect.ValueOfString(x.ServiceId) + if !f(fd_SessionHeader_service_id, value) { return } } @@ -147,8 +147,8 @@ func (x *fastReflection_SessionHeader) Has(fd protoreflect.FieldDescriptor) bool switch fd.FullName() { case "poktroll.session.SessionHeader.application_address": return x.ApplicationAddress != "" - case "poktroll.session.SessionHeader.service": - return x.Service != nil + case "poktroll.session.SessionHeader.service_id": + return x.ServiceId != "" case "poktroll.session.SessionHeader.session_id": return x.SessionId != "" case "poktroll.session.SessionHeader.session_start_block_height": @@ -173,8 +173,8 @@ func (x *fastReflection_SessionHeader) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { case "poktroll.session.SessionHeader.application_address": x.ApplicationAddress = "" - case "poktroll.session.SessionHeader.service": - x.Service = nil + case "poktroll.session.SessionHeader.service_id": + x.ServiceId = "" case "poktroll.session.SessionHeader.session_id": x.SessionId = "" case "poktroll.session.SessionHeader.session_start_block_height": @@ -200,9 +200,9 @@ func (x *fastReflection_SessionHeader) Get(descriptor protoreflect.FieldDescript case "poktroll.session.SessionHeader.application_address": value := x.ApplicationAddress return protoreflect.ValueOfString(value) - case "poktroll.session.SessionHeader.service": - value := x.Service - return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "poktroll.session.SessionHeader.service_id": + value := x.ServiceId + return protoreflect.ValueOfString(value) case "poktroll.session.SessionHeader.session_id": value := x.SessionId return protoreflect.ValueOfString(value) @@ -234,8 +234,8 @@ func (x *fastReflection_SessionHeader) Set(fd protoreflect.FieldDescriptor, valu switch fd.FullName() { case "poktroll.session.SessionHeader.application_address": x.ApplicationAddress = value.Interface().(string) - case "poktroll.session.SessionHeader.service": - x.Service = value.Message().Interface().(*shared.Service) + case "poktroll.session.SessionHeader.service_id": + x.ServiceId = value.Interface().(string) case "poktroll.session.SessionHeader.session_id": x.SessionId = value.Interface().(string) case "poktroll.session.SessionHeader.session_start_block_height": @@ -262,13 +262,10 @@ func (x *fastReflection_SessionHeader) Set(fd protoreflect.FieldDescriptor, valu // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_SessionHeader) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.session.SessionHeader.service": - if x.Service == nil { - x.Service = new(shared.Service) - } - return protoreflect.ValueOfMessage(x.Service.ProtoReflect()) case "poktroll.session.SessionHeader.application_address": panic(fmt.Errorf("field application_address of message poktroll.session.SessionHeader is not mutable")) + case "poktroll.session.SessionHeader.service_id": + panic(fmt.Errorf("field service_id of message poktroll.session.SessionHeader is not mutable")) case "poktroll.session.SessionHeader.session_id": panic(fmt.Errorf("field session_id of message poktroll.session.SessionHeader is not mutable")) case "poktroll.session.SessionHeader.session_start_block_height": @@ -290,9 +287,8 @@ func (x *fastReflection_SessionHeader) NewField(fd protoreflect.FieldDescriptor) switch fd.FullName() { case "poktroll.session.SessionHeader.application_address": return protoreflect.ValueOfString("") - case "poktroll.session.SessionHeader.service": - m := new(shared.Service) - return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "poktroll.session.SessionHeader.service_id": + return protoreflect.ValueOfString("") case "poktroll.session.SessionHeader.session_id": return protoreflect.ValueOfString("") case "poktroll.session.SessionHeader.session_start_block_height": @@ -372,8 +368,8 @@ func (x *fastReflection_SessionHeader) ProtoMethods() *protoiface.Methods { if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } - if x.Service != nil { - l = options.Size(x.Service) + l = len(x.ServiceId) + if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } l = len(x.SessionId) @@ -432,17 +428,10 @@ func (x *fastReflection_SessionHeader) ProtoMethods() *protoiface.Methods { i-- dAtA[i] = 0x1a } - if x.Service != nil { - encoded, err := options.Marshal(x.Service) - if err != nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + if len(x.ServiceId) > 0 { + i -= len(x.ServiceId) + copy(dAtA[i:], x.ServiceId) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ServiceId))) i-- dAtA[i] = 0x12 } @@ -536,9 +525,9 @@ func (x *fastReflection_SessionHeader) ProtoMethods() *protoiface.Methods { iNdEx = postIndex case 2: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Service", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ServiceId", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -548,27 +537,23 @@ func (x *fastReflection_SessionHeader) ProtoMethods() *protoiface.Methods { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } - postIndex := iNdEx + msglen + 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 } - if x.Service == nil { - x.Service = &shared.Service{} - } - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Service); err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } + x.ServiceId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { @@ -1511,8 +1496,8 @@ type SessionHeader struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ApplicationAddress string `protobuf:"bytes,1,opt,name=application_address,json=applicationAddress,proto3" json:"application_address,omitempty"` // The Bech32 address of the application. - Service *shared.Service `protobuf:"bytes,2,opt,name=service,proto3" json:"service,omitempty"` // The service this session is for + ApplicationAddress string `protobuf:"bytes,1,opt,name=application_address,json=applicationAddress,proto3" json:"application_address,omitempty"` // The Bech32 address of the application. + ServiceId string `protobuf:"bytes,2,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` // The service id this session is for // NOTE: session_id can be derived from the above values using on-chain but is included in the header for convenience SessionId string `protobuf:"bytes,3,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` // A unique pseudoranom ID for this session SessionStartBlockHeight int64 `protobuf:"varint,4,opt,name=session_start_block_height,json=sessionStartBlockHeight,proto3" json:"session_start_block_height,omitempty"` // The height at which this session started @@ -1550,11 +1535,11 @@ func (x *SessionHeader) GetApplicationAddress() string { return "" } -func (x *SessionHeader) GetService() *shared.Service { +func (x *SessionHeader) GetServiceId() string { if x != nil { - return x.Service + return x.ServiceId } - return nil + return "" } func (x *SessionHeader) GetSessionId() string { @@ -1670,56 +1655,55 @@ var file_poktroll_session_types_proto_rawDesc = []byte{ 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0xa3, 0x02, 0x0a, 0x0d, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x48, 0x65, + 0x74, 0x6f, 0x22, 0x8e, 0x02, 0x0a, 0x0d, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x49, 0x0a, 0x13, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 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, 0x12, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, - 0x32, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x18, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, - 0x65, 0x64, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, - 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x49, 0x64, 0x12, 0x3b, 0x0a, 0x1a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, - 0x61, 0x72, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x17, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x53, - 0x74, 0x61, 0x72, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, - 0x37, 0x0a, 0x18, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x5f, 0x62, - 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x15, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x64, 0x42, 0x6c, 0x6f, - 0x63, 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0xbb, 0x02, 0x0a, 0x07, 0x53, 0x65, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x37, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, - 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x48, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x1d, 0x0a, - 0x0a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x25, 0x0a, 0x0e, - 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, - 0x62, 0x65, 0x72, 0x12, 0x33, 0x0a, 0x16, 0x6e, 0x75, 0x6d, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, - 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x13, 0x6e, 0x75, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x50, 0x65, - 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x43, 0x0a, 0x0b, 0x61, 0x70, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, - 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x0b, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x37, 0x0a, - 0x09, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x73, 0x18, 0x06, 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, 0x52, 0x09, 0x73, 0x75, 0x70, - 0x70, 0x6c, 0x69, 0x65, 0x72, 0x73, 0x42, 0xaa, 0x01, 0xd8, 0xe2, 0x1e, 0x01, 0x0a, 0x14, 0x63, - 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x42, 0x0a, 0x54, 0x79, 0x70, 0x65, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x21, 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, 0x65, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x10, 0x50, 0x6f, 0x6b, - 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xca, 0x02, 0x10, - 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0xe2, 0x02, 0x1c, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, - 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x1d, + 0x0a, 0x0a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x3b, 0x0a, + 0x1a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x17, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x37, 0x0a, 0x18, 0x73, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, + 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x15, 0x73, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x22, 0xbb, 0x02, 0x0a, 0x07, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x37, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1f, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x0d, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x33, + 0x0a, 0x16, 0x6e, 0x75, 0x6d, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x70, 0x65, 0x72, + 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x13, + 0x6e, 0x75, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x43, 0x0a, 0x0b, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, + 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x61, 0x70, 0x70, + 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x37, 0x0a, 0x09, 0x73, 0x75, 0x70, 0x70, + 0x6c, 0x69, 0x65, 0x72, 0x73, 0x18, 0x06, 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, 0x52, 0x09, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, + 0x73, 0x42, 0xaa, 0x01, 0xd8, 0xe2, 0x1e, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, + 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x0a, + 0x54, 0x79, 0x70, 0x65, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x21, 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, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xa2, + 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xca, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xe2, 0x02, 0x1c, 0x50, 0x6f, + 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x11, 0x50, 0x6f, 0x6b, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1738,20 +1722,18 @@ var file_poktroll_session_types_proto_msgTypes = make([]protoimpl.MessageInfo, 2 var file_poktroll_session_types_proto_goTypes = []interface{}{ (*SessionHeader)(nil), // 0: poktroll.session.SessionHeader (*Session)(nil), // 1: poktroll.session.Session - (*shared.Service)(nil), // 2: poktroll.shared.Service - (*application.Application)(nil), // 3: poktroll.application.Application - (*shared.Supplier)(nil), // 4: poktroll.shared.Supplier + (*application.Application)(nil), // 2: poktroll.application.Application + (*shared.Supplier)(nil), // 3: poktroll.shared.Supplier } var file_poktroll_session_types_proto_depIdxs = []int32{ - 2, // 0: poktroll.session.SessionHeader.service:type_name -> poktroll.shared.Service - 0, // 1: poktroll.session.Session.header:type_name -> poktroll.session.SessionHeader - 3, // 2: poktroll.session.Session.application:type_name -> poktroll.application.Application - 4, // 3: poktroll.session.Session.suppliers:type_name -> poktroll.shared.Supplier - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 0, // 0: poktroll.session.Session.header:type_name -> poktroll.session.SessionHeader + 2, // 1: poktroll.session.Session.application:type_name -> poktroll.application.Application + 3, // 2: poktroll.session.Session.suppliers:type_name -> poktroll.shared.Supplier + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_poktroll_session_types_proto_init() } diff --git a/api/poktroll/shared/service.pulsar.go b/api/poktroll/shared/service.pulsar.go index f5105800c..680123e30 100644 --- a/api/poktroll/shared/service.pulsar.go +++ b/api/poktroll/shared/service.pulsar.go @@ -613,14 +613,14 @@ func (x *fastReflection_Service) ProtoMethods() *protoiface.Methods { } var ( - md_ApplicationServiceConfig protoreflect.MessageDescriptor - fd_ApplicationServiceConfig_service protoreflect.FieldDescriptor + md_ApplicationServiceConfig protoreflect.MessageDescriptor + fd_ApplicationServiceConfig_service_id protoreflect.FieldDescriptor ) func init() { file_poktroll_shared_service_proto_init() md_ApplicationServiceConfig = File_poktroll_shared_service_proto.Messages().ByName("ApplicationServiceConfig") - fd_ApplicationServiceConfig_service = md_ApplicationServiceConfig.Fields().ByName("service") + fd_ApplicationServiceConfig_service_id = md_ApplicationServiceConfig.Fields().ByName("service_id") } var _ protoreflect.Message = (*fastReflection_ApplicationServiceConfig)(nil) @@ -688,9 +688,9 @@ func (x *fastReflection_ApplicationServiceConfig) Interface() protoreflect.Proto // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_ApplicationServiceConfig) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.Service != nil { - value := protoreflect.ValueOfMessage(x.Service.ProtoReflect()) - if !f(fd_ApplicationServiceConfig_service, value) { + if x.ServiceId != "" { + value := protoreflect.ValueOfString(x.ServiceId) + if !f(fd_ApplicationServiceConfig_service_id, value) { return } } @@ -709,8 +709,8 @@ func (x *fastReflection_ApplicationServiceConfig) Range(f func(protoreflect.Fiel // a repeated field is populated if it is non-empty. func (x *fastReflection_ApplicationServiceConfig) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.shared.ApplicationServiceConfig.service": - return x.Service != nil + case "poktroll.shared.ApplicationServiceConfig.service_id": + return x.ServiceId != "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ApplicationServiceConfig")) @@ -727,8 +727,8 @@ func (x *fastReflection_ApplicationServiceConfig) Has(fd protoreflect.FieldDescr // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_ApplicationServiceConfig) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.shared.ApplicationServiceConfig.service": - x.Service = nil + case "poktroll.shared.ApplicationServiceConfig.service_id": + x.ServiceId = "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ApplicationServiceConfig")) @@ -745,9 +745,9 @@ func (x *fastReflection_ApplicationServiceConfig) Clear(fd protoreflect.FieldDes // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_ApplicationServiceConfig) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "poktroll.shared.ApplicationServiceConfig.service": - value := x.Service - return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "poktroll.shared.ApplicationServiceConfig.service_id": + value := x.ServiceId + return protoreflect.ValueOfString(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ApplicationServiceConfig")) @@ -768,8 +768,8 @@ func (x *fastReflection_ApplicationServiceConfig) Get(descriptor protoreflect.Fi // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_ApplicationServiceConfig) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "poktroll.shared.ApplicationServiceConfig.service": - x.Service = value.Message().Interface().(*Service) + case "poktroll.shared.ApplicationServiceConfig.service_id": + x.ServiceId = value.Interface().(string) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ApplicationServiceConfig")) @@ -790,11 +790,8 @@ func (x *fastReflection_ApplicationServiceConfig) Set(fd protoreflect.FieldDescr // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_ApplicationServiceConfig) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.shared.ApplicationServiceConfig.service": - if x.Service == nil { - x.Service = new(Service) - } - return protoreflect.ValueOfMessage(x.Service.ProtoReflect()) + case "poktroll.shared.ApplicationServiceConfig.service_id": + panic(fmt.Errorf("field service_id of message poktroll.shared.ApplicationServiceConfig is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ApplicationServiceConfig")) @@ -808,9 +805,8 @@ func (x *fastReflection_ApplicationServiceConfig) Mutable(fd protoreflect.FieldD // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_ApplicationServiceConfig) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.shared.ApplicationServiceConfig.service": - m := new(Service) - return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "poktroll.shared.ApplicationServiceConfig.service_id": + return protoreflect.ValueOfString("") default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.ApplicationServiceConfig")) @@ -880,8 +876,8 @@ func (x *fastReflection_ApplicationServiceConfig) ProtoMethods() *protoiface.Met var n int var l int _ = l - if x.Service != nil { - l = options.Size(x.Service) + l = len(x.ServiceId) + if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } if x.unknownFields != nil { @@ -913,17 +909,10 @@ func (x *fastReflection_ApplicationServiceConfig) ProtoMethods() *protoiface.Met i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if x.Service != nil { - encoded, err := options.Marshal(x.Service) - if err != nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + if len(x.ServiceId) > 0 { + i -= len(x.ServiceId) + copy(dAtA[i:], x.ServiceId) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ServiceId))) i-- dAtA[i] = 0xa } @@ -978,9 +967,9 @@ func (x *fastReflection_ApplicationServiceConfig) ProtoMethods() *protoiface.Met switch fieldNum { case 1: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Service", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ServiceId", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -990,27 +979,23 @@ func (x *fastReflection_ApplicationServiceConfig) ProtoMethods() *protoiface.Met } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } - postIndex := iNdEx + msglen + 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 } - if x.Service == nil { - x.Service = &Service{} - } - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Service); err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } + x.ServiceId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1150,16 +1135,16 @@ func (x *_SupplierServiceConfig_3_list) IsValid() bool { } var ( - md_SupplierServiceConfig protoreflect.MessageDescriptor - fd_SupplierServiceConfig_service protoreflect.FieldDescriptor - fd_SupplierServiceConfig_endpoints protoreflect.FieldDescriptor - fd_SupplierServiceConfig_rev_share protoreflect.FieldDescriptor + md_SupplierServiceConfig protoreflect.MessageDescriptor + fd_SupplierServiceConfig_service_id protoreflect.FieldDescriptor + fd_SupplierServiceConfig_endpoints protoreflect.FieldDescriptor + fd_SupplierServiceConfig_rev_share protoreflect.FieldDescriptor ) func init() { file_poktroll_shared_service_proto_init() md_SupplierServiceConfig = File_poktroll_shared_service_proto.Messages().ByName("SupplierServiceConfig") - fd_SupplierServiceConfig_service = md_SupplierServiceConfig.Fields().ByName("service") + fd_SupplierServiceConfig_service_id = md_SupplierServiceConfig.Fields().ByName("service_id") fd_SupplierServiceConfig_endpoints = md_SupplierServiceConfig.Fields().ByName("endpoints") fd_SupplierServiceConfig_rev_share = md_SupplierServiceConfig.Fields().ByName("rev_share") } @@ -1229,9 +1214,9 @@ func (x *fastReflection_SupplierServiceConfig) Interface() protoreflect.ProtoMes // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_SupplierServiceConfig) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.Service != nil { - value := protoreflect.ValueOfMessage(x.Service.ProtoReflect()) - if !f(fd_SupplierServiceConfig_service, value) { + if x.ServiceId != "" { + value := protoreflect.ValueOfString(x.ServiceId) + if !f(fd_SupplierServiceConfig_service_id, value) { return } } @@ -1262,8 +1247,8 @@ func (x *fastReflection_SupplierServiceConfig) Range(f func(protoreflect.FieldDe // a repeated field is populated if it is non-empty. func (x *fastReflection_SupplierServiceConfig) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.shared.SupplierServiceConfig.service": - return x.Service != nil + case "poktroll.shared.SupplierServiceConfig.service_id": + return x.ServiceId != "" case "poktroll.shared.SupplierServiceConfig.endpoints": return len(x.Endpoints) != 0 case "poktroll.shared.SupplierServiceConfig.rev_share": @@ -1284,8 +1269,8 @@ func (x *fastReflection_SupplierServiceConfig) Has(fd protoreflect.FieldDescript // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_SupplierServiceConfig) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.shared.SupplierServiceConfig.service": - x.Service = nil + case "poktroll.shared.SupplierServiceConfig.service_id": + x.ServiceId = "" case "poktroll.shared.SupplierServiceConfig.endpoints": x.Endpoints = nil case "poktroll.shared.SupplierServiceConfig.rev_share": @@ -1306,9 +1291,9 @@ func (x *fastReflection_SupplierServiceConfig) Clear(fd protoreflect.FieldDescri // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_SupplierServiceConfig) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "poktroll.shared.SupplierServiceConfig.service": - value := x.Service - return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "poktroll.shared.SupplierServiceConfig.service_id": + value := x.ServiceId + return protoreflect.ValueOfString(value) case "poktroll.shared.SupplierServiceConfig.endpoints": if len(x.Endpoints) == 0 { return protoreflect.ValueOfList(&_SupplierServiceConfig_2_list{}) @@ -1341,8 +1326,8 @@ func (x *fastReflection_SupplierServiceConfig) Get(descriptor protoreflect.Field // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_SupplierServiceConfig) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "poktroll.shared.SupplierServiceConfig.service": - x.Service = value.Message().Interface().(*Service) + case "poktroll.shared.SupplierServiceConfig.service_id": + x.ServiceId = value.Interface().(string) case "poktroll.shared.SupplierServiceConfig.endpoints": lv := value.List() clv := lv.(*_SupplierServiceConfig_2_list) @@ -1371,11 +1356,6 @@ func (x *fastReflection_SupplierServiceConfig) Set(fd protoreflect.FieldDescript // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_SupplierServiceConfig) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.shared.SupplierServiceConfig.service": - if x.Service == nil { - x.Service = new(Service) - } - return protoreflect.ValueOfMessage(x.Service.ProtoReflect()) case "poktroll.shared.SupplierServiceConfig.endpoints": if x.Endpoints == nil { x.Endpoints = []*SupplierEndpoint{} @@ -1388,6 +1368,8 @@ func (x *fastReflection_SupplierServiceConfig) Mutable(fd protoreflect.FieldDesc } value := &_SupplierServiceConfig_3_list{list: &x.RevShare} return protoreflect.ValueOfList(value) + case "poktroll.shared.SupplierServiceConfig.service_id": + panic(fmt.Errorf("field service_id of message poktroll.shared.SupplierServiceConfig is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.SupplierServiceConfig")) @@ -1401,9 +1383,8 @@ func (x *fastReflection_SupplierServiceConfig) Mutable(fd protoreflect.FieldDesc // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_SupplierServiceConfig) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.shared.SupplierServiceConfig.service": - m := new(Service) - return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "poktroll.shared.SupplierServiceConfig.service_id": + return protoreflect.ValueOfString("") case "poktroll.shared.SupplierServiceConfig.endpoints": list := []*SupplierEndpoint{} return protoreflect.ValueOfList(&_SupplierServiceConfig_2_list{list: &list}) @@ -1479,8 +1460,8 @@ func (x *fastReflection_SupplierServiceConfig) ProtoMethods() *protoiface.Method var n int var l int _ = l - if x.Service != nil { - l = options.Size(x.Service) + l = len(x.ServiceId) + if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } if len(x.Endpoints) > 0 { @@ -1556,17 +1537,10 @@ func (x *fastReflection_SupplierServiceConfig) ProtoMethods() *protoiface.Method dAtA[i] = 0x12 } } - if x.Service != nil { - encoded, err := options.Marshal(x.Service) - if err != nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + if len(x.ServiceId) > 0 { + i -= len(x.ServiceId) + copy(dAtA[i:], x.ServiceId) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ServiceId))) i-- dAtA[i] = 0xa } @@ -1621,9 +1595,9 @@ func (x *fastReflection_SupplierServiceConfig) ProtoMethods() *protoiface.Method switch fieldNum { case 1: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Service", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ServiceId", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -1633,27 +1607,23 @@ func (x *fastReflection_SupplierServiceConfig) ProtoMethods() *protoiface.Method } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } - postIndex := iNdEx + msglen + 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 } - if x.Service == nil { - x.Service = &Service{} - } - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Service); err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } + x.ServiceId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -3488,8 +3458,7 @@ type ApplicationServiceConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // TODO_BETA: Avoid embedding the full Service because we just need the ID. - Service *Service `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` // The Service for which the application is configured + ServiceId string `protobuf:"bytes,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` // The Service ID for which the application is configured } func (x *ApplicationServiceConfig) Reset() { @@ -3512,11 +3481,11 @@ func (*ApplicationServiceConfig) Descriptor() ([]byte, []int) { return file_poktroll_shared_service_proto_rawDescGZIP(), []int{1} } -func (x *ApplicationServiceConfig) GetService() *Service { +func (x *ApplicationServiceConfig) GetServiceId() string { if x != nil { - return x.Service + return x.ServiceId } - return nil + return "" } // SupplierServiceConfig holds the service configuration the supplier stakes for @@ -3525,10 +3494,9 @@ type SupplierServiceConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // TODO_BETA: Avoid embedding the full Service because we just need the ID. - Service *Service `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` // The Service for which the supplier is configured - Endpoints []*SupplierEndpoint `protobuf:"bytes,2,rep,name=endpoints,proto3" json:"endpoints,omitempty"` // List of endpoints for the service - RevShare []*ServiceRevenueShare `protobuf:"bytes,3,rep,name=rev_share,json=revShare,proto3" json:"rev_share,omitempty"` // List of revenue share configurations for the service + ServiceId string `protobuf:"bytes,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` // The Service ID for which the supplier is configured + Endpoints []*SupplierEndpoint `protobuf:"bytes,2,rep,name=endpoints,proto3" json:"endpoints,omitempty"` // List of endpoints for the service + RevShare []*ServiceRevenueShare `protobuf:"bytes,3,rep,name=rev_share,json=revShare,proto3" json:"rev_share,omitempty"` // List of revenue share configurations for the service } func (x *SupplierServiceConfig) Reset() { @@ -3551,11 +3519,11 @@ func (*SupplierServiceConfig) Descriptor() ([]byte, []int) { return file_poktroll_shared_service_proto_rawDescGZIP(), []int{2} } -func (x *SupplierServiceConfig) GetService() *Service { +func (x *SupplierServiceConfig) GetServiceId() string { if x != nil { - return x.Service + return x.ServiceId } - return nil + return "" } func (x *SupplierServiceConfig) GetEndpoints() []*SupplierEndpoint { @@ -3731,67 +3699,64 @@ var file_poktroll_shared_service_proto_rawDesc = []byte{ 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 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, 0x0c, 0x6f, 0x77, 0x6e, 0x65, 0x72, - 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x4e, 0x0a, 0x18, 0x41, 0x70, 0x70, 0x6c, 0x69, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x39, 0x0a, 0x18, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x12, 0x32, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, - 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0xcf, 0x01, 0x0a, 0x15, 0x53, 0x75, 0x70, 0x70, - 0x6c, 0x69, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x12, 0x32, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, - 0x61, 0x72, 0x65, 0x64, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3f, 0x0a, 0x09, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, - 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 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, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x09, 0x65, 0x6e, 0x64, - 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x12, 0x41, 0x0a, 0x09, 0x72, 0x65, 0x76, 0x5f, 0x73, 0x68, - 0x61, 0x72, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x70, 0x6f, 0x6b, 0x74, - 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x75, 0x65, 0x53, 0x68, 0x61, 0x72, 0x65, 0x52, - 0x08, 0x72, 0x65, 0x76, 0x53, 0x68, 0x61, 0x72, 0x65, 0x22, 0x92, 0x01, 0x0a, 0x10, 0x53, 0x75, - 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x10, - 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, - 0x12, 0x33, 0x0a, 0x08, 0x72, 0x70, 0x63, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, - 0x61, 0x72, 0x65, 0x64, 0x2e, 0x52, 0x50, 0x43, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, 0x72, 0x70, - 0x63, 0x54, 0x79, 0x70, 0x65, 0x12, 0x37, 0x0a, 0x07, 0x63, 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, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x49, 0x64, 0x22, 0xba, 0x01, 0x0a, 0x15, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1d, 0x0a, 0x0a, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x3f, 0x0a, 0x09, 0x65, + 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, + 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, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, + 0x74, 0x52, 0x09, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x12, 0x41, 0x0a, 0x09, + 0x72, 0x65, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x24, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, + 0x64, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x75, 0x65, + 0x53, 0x68, 0x61, 0x72, 0x65, 0x52, 0x08, 0x72, 0x65, 0x76, 0x53, 0x68, 0x61, 0x72, 0x65, 0x22, + 0x92, 0x01, 0x0a, 0x10, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x45, 0x6e, 0x64, 0x70, + 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x33, 0x0a, 0x08, 0x72, 0x70, 0x63, 0x5f, 0x74, 0x79, + 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x52, 0x50, 0x43, 0x54, 0x79, + 0x70, 0x65, 0x52, 0x07, 0x72, 0x70, 0x63, 0x54, 0x79, 0x70, 0x65, 0x12, 0x37, 0x0a, 0x07, 0x63, + 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, } var ( @@ -3819,18 +3784,16 @@ var file_poktroll_shared_service_proto_goTypes = []interface{}{ (*ConfigOption)(nil), // 7: poktroll.shared.ConfigOption } var file_poktroll_shared_service_proto_depIdxs = []int32{ - 2, // 0: poktroll.shared.ApplicationServiceConfig.service:type_name -> poktroll.shared.Service - 2, // 1: poktroll.shared.SupplierServiceConfig.service:type_name -> poktroll.shared.Service - 5, // 2: poktroll.shared.SupplierServiceConfig.endpoints:type_name -> poktroll.shared.SupplierEndpoint - 6, // 3: poktroll.shared.SupplierServiceConfig.rev_share:type_name -> poktroll.shared.ServiceRevenueShare - 0, // 4: poktroll.shared.SupplierEndpoint.rpc_type:type_name -> poktroll.shared.RPCType - 7, // 5: poktroll.shared.SupplierEndpoint.configs:type_name -> poktroll.shared.ConfigOption - 1, // 6: poktroll.shared.ConfigOption.key:type_name -> poktroll.shared.ConfigOptions - 7, // [7:7] is the sub-list for method output_type - 7, // [7:7] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name + 5, // 0: poktroll.shared.SupplierServiceConfig.endpoints:type_name -> poktroll.shared.SupplierEndpoint + 6, // 1: poktroll.shared.SupplierServiceConfig.rev_share:type_name -> poktroll.shared.ServiceRevenueShare + 0, // 2: poktroll.shared.SupplierEndpoint.rpc_type:type_name -> poktroll.shared.RPCType + 7, // 3: poktroll.shared.SupplierEndpoint.configs:type_name -> poktroll.shared.ConfigOption + 1, // 4: poktroll.shared.ConfigOption.key:type_name -> poktroll.shared.ConfigOptions + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_poktroll_shared_service_proto_init() } diff --git a/config.yml b/config.yml index 747ab1d4a..fcdde93e8 100644 --- a/config.yml +++ b/config.yml @@ -169,12 +169,9 @@ genesis: - address: pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 delegatee_gateway_addresses: [] service_configs: - - service: - id: anvil - - service: - id: rest - - service: - id: ollama + - service_id: anvil + - service_id: rest + - service_id: ollama 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. @@ -183,12 +180,9 @@ genesis: - address: pokt1ad28jdap2zfanjd7hpkh984yveney6k9a42man delegatee_gateway_addresses: [] service_configs: - - service: - id: anvil - - service: - id: rest - - service: - id: ollama + - service_id: anvil + - service_id: rest + - service_id: ollama 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. @@ -199,8 +193,7 @@ genesis: - owner_address: pokt19a3t4yunp0dlpfjrp7qwnzwlrzd5fzs2gjaaaj operator_address: pokt19a3t4yunp0dlpfjrp7qwnzwlrzd5fzs2gjaaaj services: - - service: - id: anvil + - service_id: anvil endpoints: - configs: [] rpc_type: JSON_RPC @@ -208,8 +201,7 @@ genesis: rev_share: - address: pokt19a3t4yunp0dlpfjrp7qwnzwlrzd5fzs2gjaaaj rev_share_percentage: "100" - - service: - id: rest + - service_id: rest endpoints: - configs: [] rpc_type: REST @@ -217,8 +209,7 @@ genesis: rev_share: - address: pokt19a3t4yunp0dlpfjrp7qwnzwlrzd5fzs2gjaaaj rev_share_percentage: "100" - - service: - id: ollama + - service_id: ollama endpoints: - configs: [] rpc_type: REST diff --git a/e2e/tests/init_test.go b/e2e/tests/init_test.go index d02b6092c..afc4a72ba 100644 --- a/e2e/tests/init_test.go +++ b/e2e/tests/init_test.go @@ -388,7 +388,7 @@ func (s *suite) TheServiceRegisteredForApplicationHasAComputeUnitsPerRelayOf(ser // CHeck if the application is registered for the service isRegistered := false for _, serviceConfig := range app.ServiceConfigs { - if serviceConfig.Service.Id == serviceId { + if serviceConfig.ServiceId == serviceId { isRegistered = true break } @@ -415,7 +415,7 @@ func (s *suite) TheForAccountIsStakedWithUpokt(actorType, accName string, amount func (s *suite) TheApplicationIsStakedForService(appName string, serviceId string) { for _, serviceConfig := range accNameToAppMap[appName].ServiceConfigs { - if serviceConfig.Service.Id == serviceId { + if serviceConfig.ServiceId == serviceId { return } } @@ -424,7 +424,7 @@ func (s *suite) TheApplicationIsStakedForService(appName string, serviceId strin func (s *suite) TheSupplierIsStakedForService(supplierOperatorName string, serviceId string) { for _, serviceConfig := range operatorAccNameToSupplierMap[supplierOperatorName].Services { - if serviceConfig.Service.Id == serviceId { + if serviceConfig.ServiceId == serviceId { return } } diff --git a/e2e/tests/session_steps_test.go b/e2e/tests/session_steps_test.go index 079452d7b..e3c077850 100644 --- a/e2e/tests/session_steps_test.go +++ b/e2e/tests/session_steps_test.go @@ -161,7 +161,7 @@ func (s *suite) TheClaimCreatedBySupplierForServiceForApplicationShouldBeSuccess claim := claimSettledEvent.Claim require.Equal(s, app.Address, claim.SessionHeader.ApplicationAddress) require.Equal(s, supplier.OperatorAddress, claim.SupplierOperatorAddress) - require.Equal(s, serviceId, claim.SessionHeader.Service.Id) + require.Equal(s, serviceId, claim.SessionHeader.ServiceId) require.Greater(s, claimSettledEvent.NumComputeUnits, uint64(0), "compute units should be greater than 0") return true } diff --git a/go.mod b/go.mod index 15145a54c..9f47b177c 100644 --- a/go.mod +++ b/go.mod @@ -55,7 +55,7 @@ require ( // This is creating a circular dependency whereby exporting the protobufs into a separate // repo is the first obvious idea, but has to be carefully considered, automated, and is not // a hard blocker. - github.com/pokt-network/shannon-sdk v0.0.0-20240829123247-30d71ae84f4f + github.com/pokt-network/shannon-sdk v0.0.0-20240907012836-7172ed278f8b github.com/pokt-network/smt v0.13.0 github.com/pokt-network/smt/kvstore/pebble v0.0.0-20240822175047-21ea8639c188 github.com/prometheus/client_golang v1.19.0 diff --git a/go.sum b/go.sum index e357f2fb9..62dc61bb0 100644 --- a/go.sum +++ b/go.sum @@ -1001,8 +1001,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pokt-network/ring-go v0.1.0 h1:hF7mDR4VVCIqqDAsrloP8azM9y1mprc99YgnTjKSSwk= github.com/pokt-network/ring-go v0.1.0/go.mod h1:8NHPH7H3EwrPX3XHfpyRI6bz4gApkE3+fd0XZRbMWP0= -github.com/pokt-network/shannon-sdk v0.0.0-20240829123247-30d71ae84f4f h1:rS954qvNS61SVyDqwtJ6Dla4kc7Cjb/hsMpAFFqKJds= -github.com/pokt-network/shannon-sdk v0.0.0-20240829123247-30d71ae84f4f/go.mod h1:zLQZCtErH+bPOrFZ1PpYgcp+EfS+zMg/6JqG53apaWw= +github.com/pokt-network/shannon-sdk v0.0.0-20240907012836-7172ed278f8b h1:dTj9PG3p+72ycG1r7PqdZ04Iy42qoCydrveIjXIaMKA= +github.com/pokt-network/shannon-sdk v0.0.0-20240907012836-7172ed278f8b/go.mod h1:WznmqcNxQ7mdl/nACaf0faJbphX+5YtHcxHjCkhXbsc= github.com/pokt-network/smt v0.13.0 h1:C2F8FlJh34aU+DVeRU/Bt8BOkFXn4QjWMK+nbT9PUj4= github.com/pokt-network/smt v0.13.0/go.mod h1:S4Ho4OPkK2v2vUCHNtA49XDjqUC/OFYpBbynRVYmxvA= github.com/pokt-network/smt/kvstore/pebble v0.0.0-20240822175047-21ea8639c188 h1:QK1WmFKQ/OzNVob/br55Brh+EFbWhcdq41WGC8UMihM= diff --git a/load-testing/tests/relays_stress_helpers_test.go b/load-testing/tests/relays_stress_helpers_test.go index 7aef74565..4c034ba04 100644 --- a/load-testing/tests/relays_stress_helpers_test.go +++ b/load-testing/tests/relays_stress_helpers_test.go @@ -646,7 +646,7 @@ func (s *relaysSuite) addPendingStakeApplicationMsg(application *accountInfo) { application.addPendingMsg(apptypes.NewMsgStakeApplication( application.address, application.amountToStake, - []*sharedtypes.ApplicationServiceConfig{{Service: testedService}}, + []*sharedtypes.ApplicationServiceConfig{{ServiceId: testedServiceId}}, )) } @@ -793,7 +793,7 @@ func (s *relaysSuite) addPendingStakeSupplierMsg(supplier *accountInfo) { supplier.amountToStake, []*sharedtypes.SupplierServiceConfig{ { - Service: testedService, + ServiceId: testedServiceId, Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: s.suppliersUrls[supplier.address], @@ -1046,7 +1046,7 @@ func (s *relaysSuite) sendRelay(iteration uint64, relayPayload string) (appAddre gatewayUrl.RawQuery = query.Encode() // Use the pre-defined service ID that all application and suppliers are staking for. - gatewayUrl.Path = testedService.Id + gatewayUrl.Path = testedServiceId // TODO_MAINNET: Capture the relay response to check for failing relays. // Send the relay request within a goroutine to avoid blocking the test batches diff --git a/load-testing/tests/relays_stress_test.go b/load-testing/tests/relays_stress_test.go index 59f74c530..5aa7fbb65 100644 --- a/load-testing/tests/relays_stress_test.go +++ b/load-testing/tests/relays_stress_test.go @@ -83,9 +83,9 @@ var ( supplierStakeAmount sdk.Coin // gatewayStakeAmount is the amount of tokens to stake by gateways. gatewayStakeAmount sdk.Coin - // testedService is the service ID for that all applications and suppliers will + // testedServiceId is the service ID for that all applications and suppliers will // be using in this test. - testedService *sharedtypes.Service + testedServiceId string // blockDuration is the duration of a block in seconds. // NB: This value SHOULD be equal to `timeout_propose` in `config.yml`. blockDuration = int64(2) @@ -312,7 +312,7 @@ func (s *relaysSuite) LocalnetIsRunning() { loadTestParams := s.initializeLoadTestParams() // Set the tested service ID from the load test manifest. - testedService = &sharedtypes.Service{Id: loadTestParams.ServiceId} + testedServiceId = loadTestParams.ServiceId // If the test is run on a non-ephemeral chain, set the CometLocalTCPURL and // CometLocalWebsocketURL to the TestNetNode URL. These variables are used diff --git a/pkg/client/query/sessionquerier.go b/pkg/client/query/sessionquerier.go index 091bf6de0..7dba6e87c 100644 --- a/pkg/client/query/sessionquerier.go +++ b/pkg/client/query/sessionquerier.go @@ -8,7 +8,6 @@ import ( "github.com/pokt-network/poktroll/pkg/client" sessiontypes "github.com/pokt-network/poktroll/x/session/types" - sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) var _ client.SessionQueryClient = (*sessionQuerier)(nil) @@ -49,10 +48,9 @@ func (sessq *sessionQuerier) GetSession( serviceId string, blockHeight int64, ) (*sessiontypes.Session, error) { - service := &sharedtypes.Service{Id: serviceId} req := &sessiontypes.QueryGetSessionRequest{ ApplicationAddress: appAddress, - Service: service, + ServiceId: serviceId, BlockHeight: blockHeight, } res, err := sessq.sessionQuerier.GetSession(ctx, req) diff --git a/pkg/client/services.go b/pkg/client/services.go index 08fbaee03..3fcd9fe92 100644 --- a/pkg/client/services.go +++ b/pkg/client/services.go @@ -12,7 +12,7 @@ func NewTestApplicationServiceConfig(prefix string, count int) []*sharedtypes.Ap for i := range appSvcCfg { serviceId := fmt.Sprintf("%s%d", prefix, i) appSvcCfg[i] = &sharedtypes.ApplicationServiceConfig{ - Service: &sharedtypes.Service{Id: serviceId}, + ServiceId: serviceId, } } return appSvcCfg diff --git a/pkg/client/supplier/client.go b/pkg/client/supplier/client.go index 4e15bb648..018b751c8 100644 --- a/pkg/client/supplier/client.go +++ b/pkg/client/supplier/client.go @@ -100,7 +100,7 @@ func (sClient *supplierClient) SubmitProofs( "supplier_operator_addr": proofMsg.SupplierOperatorAddress, "app_addr": sessionHeader.ApplicationAddress, "session_id": sessionHeader.SessionId, - "service": sessionHeader.Service.Id, + "service_id": sessionHeader.ServiceId, }). Msg("submitted a new proof") } @@ -146,7 +146,7 @@ func (sClient *supplierClient) CreateClaims( "supplier_operator_addr": claimMsg.SupplierOperatorAddress, "app_addr": sessionHeader.ApplicationAddress, "session_id": sessionHeader.SessionId, - "service": sessionHeader.Service.Id, + "service_id": sessionHeader.ServiceId, }). Msg("created a new claim") } diff --git a/pkg/client/supplier/client_test.go b/pkg/client/supplier/client_test.go index 3eed55b5e..1a43b948f 100644 --- a/pkg/client/supplier/client_test.go +++ b/pkg/client/supplier/client_test.go @@ -19,7 +19,6 @@ import ( "github.com/pokt-network/poktroll/testutil/testclient/testtx" prooftypes "github.com/pokt-network/poktroll/x/proof/types" sessiontypes "github.com/pokt-network/poktroll/x/session/types" - sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) const ( @@ -107,9 +106,7 @@ func TestSupplierClient_CreateClaim(t *testing.T) { ApplicationAddress: testAppAddr.String(), SessionStartBlockHeight: 1, SessionId: "", - Service: &sharedtypes.Service{ - Id: testService, - }, + ServiceId: testService, } msgClaim := &prooftypes.MsgCreateClaim{ @@ -170,9 +167,7 @@ func TestSupplierClient_SubmitProof(t *testing.T) { ApplicationAddress: testAppAddr.String(), SessionStartBlockHeight: 1, SessionId: "", - Service: &sharedtypes.Service{ - Id: testService, - }, + ServiceId: testService, } kvStore, err := pebble.NewKVStore("") diff --git a/pkg/crypto/rings/client.go b/pkg/crypto/rings/client.go index e60da469e..62489792b 100644 --- a/pkg/crypto/rings/client.go +++ b/pkg/crypto/rings/client.go @@ -104,7 +104,7 @@ func (rc *ringClient) VerifyRelayRequestSignature( Fields(map[string]any{ "session_id": sessionHeader.GetSessionId(), "application_address": sessionHeader.GetApplicationAddress(), - "service_id": sessionHeader.GetService().GetId(), + "service_id": sessionHeader.GetServiceId(), }). Msg("verifying relay request signature") diff --git a/pkg/relayer/interface.go b/pkg/relayer/interface.go index 866772d38..7f4c953cf 100644 --- a/pkg/relayer/interface.go +++ b/pkg/relayer/interface.go @@ -13,7 +13,6 @@ import ( "github.com/pokt-network/poktroll/pkg/observable" servicetypes "github.com/pokt-network/poktroll/x/service/types" sessiontypes "github.com/pokt-network/poktroll/x/session/types" - sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) // RelaysObservable is an observable which is notified with Relay values. @@ -65,7 +64,7 @@ type RelayerProxy interface { VerifyRelayRequest( ctx context.Context, relayRequest *servicetypes.RelayRequest, - service *sharedtypes.Service, + serviceId string, ) error // SignRelayResponse is a shared method used by RelayServers to sign diff --git a/pkg/relayer/miner/gen/gen_fixtures.go b/pkg/relayer/miner/gen/gen_fixtures.go index ee4068bdd..01c91392b 100644 --- a/pkg/relayer/miner/gen/gen_fixtures.go +++ b/pkg/relayer/miner/gen/gen_fixtures.go @@ -24,7 +24,6 @@ import ( "github.com/pokt-network/poktroll/testutil/sample" servicetypes "github.com/pokt-network/poktroll/x/service/types" sessiontypes "github.com/pokt-network/poktroll/x/session/types" - sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) const ( @@ -158,10 +157,8 @@ func genRandomizedMinedRelayFixtures( Req: &servicetypes.RelayRequest{ Meta: servicetypes.RelayRequestMetadata{ SessionHeader: &sessiontypes.SessionHeader{ - ApplicationAddress: sample.AccAddress(), - Service: &sharedtypes.Service{ - Id: flagSvcID, - }, + ApplicationAddress: sample.AccAddress(), + ServiceId: flagSvcID, SessionId: "session_id", SessionStartBlockHeight: 1, SessionEndBlockHeight: 2, diff --git a/pkg/relayer/miner/miner.go b/pkg/relayer/miner/miner.go index bfa6a8dac..f22a85760 100644 --- a/pkg/relayer/miner/miner.go +++ b/pkg/relayer/miner/miner.go @@ -129,7 +129,7 @@ func (mnr *miner) getServiceRelayDifficultyTargetHash(ctx context.Context, req * return nil, fmt.Errorf("invalid session header: %w", err) } - serviceRelayDifficulty, err := mnr.tokenomicsQueryClient.GetServiceRelayDifficultyTargetHash(ctx, sessionHeader.Service.Id) + serviceRelayDifficulty, err := mnr.tokenomicsQueryClient.GetServiceRelayDifficultyTargetHash(ctx, sessionHeader.ServiceId) if err != nil { // TODO_IMPROVE: log the error and a message saying the default relay difficulty target hash // is being used. diff --git a/pkg/relayer/miner/relay_fixtures_test.go b/pkg/relayer/miner/relay_fixtures_test.go index ec4af0be0..85f130f16 100644 --- a/pkg/relayer/miner/relay_fixtures_test.go +++ b/pkg/relayer/miner/relay_fixtures_test.go @@ -9,15 +9,15 @@ var ( // marshaledMinableRelaysHex are the hex encoded strings of serialized // relayer.MinedRelays which have been pre-mined to difficulty 0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff (or greater) by // randomizing the application address and populating the signature with random bytes. - // The ID, starting block height, and ending block height of the session referenced in the relays. - // are hard-coded to "session_id", 1, and 2, respectively. + // The ID, starting block height, and ending block height of the session referenced + // in the relays are hard-coded to "session_id", 1, and 2, respectively. // The resulting slice of minable relays is intended for use in tests. marshaledMinableRelaysHex = []string{ - "0a5d0a5b0a470a2d636f736d6f73317a387336676d6335306e6a38306e71367138356e66376c3663723477636a766b61643779386812060a04737663311a0a73657373696f6e5f6964200128021210db053f9e0abf922e6cddc648678d0a88", - "0a5d0a5b0a470a2d636f736d6f7331646d7139646e3077777677307a3872673930706e737532786835676c3963676c6c77786d6d3812060a04737663311a0a73657373696f6e5f6964200128021210a2e27cad60751773b2468483a7aabee4", - "0a5d0a5b0a470a2d636f736d6f733130746772796737336438763979707a68763779616e636174346d6b6473686c347078397a613312060a04737663311a0a73657373696f6e5f696420012802121078522b759b6ed8c0d2891d21dcaf4d74", - "0a5d0a5b0a470a2d636f736d6f7331637968727463337a65656e7a63616872306c396a37646d3865687a6b30776e75616b3574347912060a04737663311a0a73657373696f6e5f6964200128021210139f82fd26920aa23dea91dda0ee5954", - "0a5d0a5b0a470a2d636f736d6f73317a64666874346d793264783779736336343638656565336a7a7165636865793733756d77337a12060a04737663311a0a73657373696f6e5f69642001280212102f525aa98228d86ec92eb090dda16418", + "0a5b0a590a450a2d636f736d6f73316b716875327a3530396461756b37753778396134673935723834787534717767736865727a611204737663311a0a73657373696f6e5f696420012802121045c9492b1d49c37206eb5d4bbc302015", + "0a5b0a590a450a2d636f736d6f73316e72777a787a687433387a33797a3865336163756a7230373034613537743730756e743933351204737663311a0a73657373696f6e5f69642001280212101f26304d5a6d4caca48761fd4710e1f6", + "0a5b0a590a450a2d636f736d6f7331687564747072687777747a643379743633746b767263706672306d39396d6c736d7533757a6e1204737663311a0a73657373696f6e5f696420012802121033950975d04001d0d049e2d46ad2e61e", + "0a5b0a590a450a2d636f736d6f73316b676b77787261386877367977667035703267616b3061386878723830756a387234613464371204737663311a0a73657373696f6e5f696420012802121083397fed963fa8dd77743089b9eba5af", + "0a5b0a590a450a2d636f736d6f733172336d6a763635323532666636397a7a37726e6539787a6638753368326c767376686d73686a1204737663311a0a73657373696f6e5f69642001280212103b46c9e9e9fc6a2cc0f687ae0cfdb898", } // marshaledUnminableRelaysHex are the hex encoded strings of serialized @@ -26,10 +26,10 @@ var ( // by populating the signature with random bytes. It is intended for use in // tests. marshaledUnminableRelaysHex = []string{ - "0a5d0a5b0a470a2d636f736d6f733173726775717a6e3366376435753933366d39356c6d7577757a636b7461706b726d743477783712060a04737663311a0a73657373696f6e5f696420012802121025329160fdc25be9d2f1747c1ffb4e78", - "0a5d0a5b0a470a2d636f736d6f73317433306d796d3033736463386e766479793936776b78346e6d7672713565666432786836797212060a04737663311a0a73657373696f6e5f696420012802121060f8483a9c8ec7e94d16afda952dccf9", - "0a5d0a5b0a470a2d636f736d6f733163686e30677972667a346664666a7a7573676d356376636868726371373770327767716d376312060a04737663311a0a73657373696f6e5f69642001280212100674c9bd3b43f1d7520e6e33a62430ac", - "0a5d0a5b0a470a2d636f736d6f7331656573687932386e63376d6b736573713366636d6a77356e333761333234677267743466393712060a04737663311a0a73657373696f6e5f6964200128021210d4d45eb1ba69be25ccb217f5bdc0ddf5", - "0a5d0a5b0a470a2d636f736d6f733137366a683337726c6c75376e73726d736c7072327332763476723532383075326e323338306c12060a04737663311a0a73657373696f6e5f6964200128021210ad8281326ac760bc40e3c71d48b2bf51", + "0a5b0a590a450a2d636f736d6f73317439666874767433656e75726a6b787776333576747278377333636876366d3463706a33776e1204737663311a0a73657373696f6e5f6964200128021210ec9f210d105fcc078a6c5078cf3fae37", + "0a5b0a590a450a2d636f736d6f7331793877756b79333064663063397675783937763838716578746733727066726e366c733961721204737663311a0a73657373696f6e5f696420012802121097521a1cb00a28cdfac68ebb240ad613", + "0a5b0a590a450a2d636f736d6f733130793537336e727663786d766372326830666c666679633737386335743236356b32743877731204737663311a0a73657373696f6e5f6964200128021210e4d547434751191ac8615d337f2687b2", + "0a5b0a590a450a2d636f736d6f733175326175346679706c766377376b38326432616e6b6e79757a75396c787033337737786371761204737663311a0a73657373696f6e5f696420012802121024bda679bd52292fda09763c815c9320", + "0a5b0a590a450a2d636f736d6f73316172396861743375777075346c35356538677664746c396663736a6c796630666167383563641204737663311a0a73657373696f6e5f6964200128021210c6ec58023ae1e96d7cfa2eb384494ab5", } ) diff --git a/pkg/relayer/proxy/error_reply.go b/pkg/relayer/proxy/error_reply.go index fbecb1117..fc1ec36f3 100644 --- a/pkg/relayer/proxy/error_reply.go +++ b/pkg/relayer/proxy/error_reply.go @@ -25,7 +25,7 @@ func (sync *synchronousRPCServer) replyWithError( // Fill in the needed missing fields of the RelayRequest with empty values. relayRequest = relayRequest.NullifyForObservability() - serviceId := relayRequest.Meta.SessionHeader.Service.Id + serviceId := relayRequest.Meta.SessionHeader.ServiceId errorLogger := sync.logger.With(). Error(). diff --git a/pkg/relayer/proxy/relay_verifier.go b/pkg/relayer/proxy/relay_verifier.go index 07f031c5e..d4888fbe7 100644 --- a/pkg/relayer/proxy/relay_verifier.go +++ b/pkg/relayer/proxy/relay_verifier.go @@ -5,7 +5,6 @@ import ( "github.com/pokt-network/poktroll/x/service/types" "github.com/pokt-network/poktroll/x/shared" - sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) // VerifyRelayRequest is a shared method used by RelayServers to check the relay @@ -13,7 +12,7 @@ import ( func (rp *relayerProxy) VerifyRelayRequest( ctx context.Context, relayRequest *types.RelayRequest, - supplierService *sharedtypes.Service, + supplierServiceId string, ) error { // Get the block height at which the relayRequest should be processed. // Check if the relayRequest is on time or within the session's grace period @@ -44,7 +43,7 @@ func (rp *relayerProxy) VerifyRelayRequest( Fields(map[string]any{ "session_id": sessionHeader.GetSessionId(), "application_address": appAddress, - "service_id": sessionHeader.GetService().GetId(), + "service_id": sessionHeader.GetServiceId(), "supplier_operator_address": meta.GetSupplierOperatorAddress(), }). Msg("verifying relay request session") @@ -54,7 +53,7 @@ func (rp *relayerProxy) VerifyRelayRequest( session, err := rp.sessionQuerier.GetSession( ctx, appAddress, - supplierService.Id, + supplierServiceId, sessionBlockHeight, ) if err != nil { diff --git a/pkg/relayer/proxy/server_builder.go b/pkg/relayer/proxy/server_builder.go index dd32bf564..b59b1d490 100644 --- a/pkg/relayer/proxy/server_builder.go +++ b/pkg/relayer/proxy/server_builder.go @@ -77,7 +77,7 @@ func (rp *relayerProxy) BuildProvidedServices(ctx context.Context) error { // Iterate over the server configs and check if `endpointUrl` is present // in any of the server config's suppliers' service's PubliclyExposedEndpoints for _, serverConfig := range rp.serverConfigs { - supplierService, ok := serverConfig.SupplierConfigsMap[service.Service.Id] + supplierService, ok := serverConfig.SupplierConfigsMap[service.ServiceId] hostname := endpointUrl.Hostname() if ok && slices.Contains(supplierService.PubliclyExposedEndpoints, hostname) { found = true diff --git a/pkg/relayer/proxy/synchronous.go b/pkg/relayer/proxy/synchronous.go index cba720ebc..e3767eef6 100644 --- a/pkg/relayer/proxy/synchronous.go +++ b/pkg/relayer/proxy/synchronous.go @@ -18,7 +18,6 @@ import ( "github.com/pokt-network/poktroll/pkg/relayer" "github.com/pokt-network/poktroll/pkg/relayer/config" "github.com/pokt-network/poktroll/x/service/types" - sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) var _ relayer.RelayServer = (*synchronousRPCServer)(nil) @@ -118,7 +117,7 @@ func (sync *synchronousRPCServer) ServeHTTP(writer http.ResponseWriter, request return } - supplierService := relayRequest.Meta.SessionHeader.Service + supplierServiceId := relayRequest.Meta.SessionHeader.ServiceId originHost := request.Host // When the proxy is behind a reverse proxy, or is getting its requests from @@ -158,7 +157,7 @@ func (sync *synchronousRPCServer) ServeHTTP(writer http.ResponseWriter, request // key so that we can get the service and serviceUrl in O(1) time. for _, supplierServiceConfig := range sync.serverConfig.SupplierConfigsMap { for _, host := range supplierServiceConfig.PubliclyExposedEndpoints { - if host == originHostUrl.Hostname() && supplierService.Id == supplierServiceConfig.ServiceId { + if host == originHostUrl.Hostname() && supplierServiceId == supplierServiceConfig.ServiceId { serviceConfig = supplierServiceConfig.ServiceConfig break } @@ -175,18 +174,18 @@ func (sync *synchronousRPCServer) ServeHTTP(writer http.ResponseWriter, request } // Increment the relays counter. - relaysTotal.With("service_id", supplierService.Id).Add(1) + relaysTotal.With("service_id", supplierServiceId).Add(1) defer func() { duration := time.Since(startTime).Seconds() // Capture the relay request duration metric. - relaysDurationSeconds.With("service_id", supplierService.Id).Observe(duration) + relaysDurationSeconds.With("service_id", supplierServiceId).Observe(duration) }() - relayRequestSizeBytes.With("service_id", supplierService.Id). + relayRequestSizeBytes.With("service_id", supplierServiceId). Observe(float64(relayRequest.Size())) - relay, err := sync.serveHTTP(ctx, serviceConfig, supplierService, relayRequest) + relay, err := sync.serveHTTP(ctx, serviceConfig, supplierServiceId, relayRequest) if err != nil { // Reply with an error if the relay could not be served. sync.replyWithError(err, relayRequest, writer) @@ -206,14 +205,14 @@ func (sync *synchronousRPCServer) ServeHTTP(writer http.ResponseWriter, request sync.logger.Info().Fields(map[string]any{ "application_address": relay.Res.Meta.SessionHeader.ApplicationAddress, - "service_id": relay.Res.Meta.SessionHeader.Service.Id, + "service_id": relay.Res.Meta.SessionHeader.ServiceId, "session_start_height": relay.Res.Meta.SessionHeader.SessionStartBlockHeight, "server_addr": sync.server.Addr, }).Msg("relay request served successfully") - relaysSuccessTotal.With("service_id", supplierService.Id).Add(1) + relaysSuccessTotal.With("service_id", supplierServiceId).Add(1) - relayResponseSizeBytes.With("service_id", supplierService.Id). + relayResponseSizeBytes.With("service_id", supplierServiceId). Observe(float64(relay.Res.Size())) // Emit the relay to the servedRelays observable. @@ -224,7 +223,7 @@ func (sync *synchronousRPCServer) ServeHTTP(writer http.ResponseWriter, request func (sync *synchronousRPCServer) serveHTTP( ctx context.Context, serviceConfig *config.RelayMinerSupplierServiceConfig, - supplierService *sharedtypes.Service, + supplierServiceId string, relayRequest *types.RelayRequest, ) (*types.Relay, error) { // Verify the relay request signature and session. @@ -234,7 +233,7 @@ func (sync *synchronousRPCServer) serveHTTP( // request signature verification, session verification, and response signature. // This would help in separating concerns and improving code maintainability. // See https://github.com/pokt-network/poktroll/issues/160 - if err := sync.relayerProxy.VerifyRelayRequest(ctx, relayRequest, supplierService); err != nil { + if err := sync.relayerProxy.VerifyRelayRequest(ctx, relayRequest, supplierServiceId); err != nil { return nil, err } diff --git a/pkg/relayer/session/service.go b/pkg/relayer/session/service.go index 6ecd1d0e1..33d8b57de 100644 --- a/pkg/relayer/session/service.go +++ b/pkg/relayer/session/service.go @@ -14,15 +14,11 @@ func (rs *relayerSessionsManager) getServiceComputeUnitsPerRelay( relayRequestMetadata *types.RelayRequestMetadata, ) (uint64, error) { sessionHeader := relayRequestMetadata.GetSessionHeader() - if sessionHeader.GetService() == nil { - return 0, ErrSessionRelayMetaHasNoServiceID - } - - service, err := rs.serviceQueryClient.GetService(ctx, sessionHeader.Service.Id) + service, err := rs.serviceQueryClient.GetService(ctx, sessionHeader.ServiceId) if err != nil { return 0, ErrSessionRelayMetaHasInvalidServiceID.Wrapf( "getServiceComputeUnitsPerRelay: could not get on-chain service %s: %v", - sessionHeader.Service.Id, + sessionHeader.ServiceId, err, ) } diff --git a/pkg/relayer/session/session_test.go b/pkg/relayer/session/session_test.go index e87f81576..44a52ffb3 100644 --- a/pkg/relayer/session/session_test.go +++ b/pkg/relayer/session/session_test.go @@ -61,7 +61,7 @@ func requireProofCountEqualsExpectedValueFromProofParams(t *testing.T, proofPara Header: &sessiontypes.SessionHeader{ SessionStartBlockHeight: 1, SessionEndBlockHeight: 2, - Service: &service, + ServiceId: service.Id, }, } sessionHeader := activeSession.GetHeader() diff --git a/proto/poktroll/session/query.proto b/proto/poktroll/session/query.proto index 09a479553..3be893a09 100644 --- a/proto/poktroll/session/query.proto +++ b/proto/poktroll/session/query.proto @@ -38,7 +38,7 @@ message QueryParamsResponse { message QueryGetSessionRequest { string application_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application. - poktroll.shared.Service service = 2; // The service to query the session for + string service_id = 2; // The service ID to query the session for int64 block_height = 3; // The block height to query the session for } diff --git a/proto/poktroll/session/types.proto b/proto/poktroll/session/types.proto index 1c205ec32..afbff35a4 100644 --- a/proto/poktroll/session/types.proto +++ b/proto/poktroll/session/types.proto @@ -21,7 +21,7 @@ import "gogoproto/gogo.proto"; // It is the minimal amount of data required to hydrate & retrieve all data relevant to the session. message SessionHeader { string application_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application. - poktroll.shared.Service service = 2; // The service this session is for + string service_id = 2; // The service id this session is for // NOTE: session_id can be derived from the above values using on-chain but is included in the header for convenience string session_id = 3; // A unique pseudoranom ID for this session int64 session_start_block_height = 4; // The height at which this session started diff --git a/proto/poktroll/shared/service.proto b/proto/poktroll/shared/service.proto index de5b563ff..4f8a4cfbf 100644 --- a/proto/poktroll/shared/service.proto +++ b/proto/poktroll/shared/service.proto @@ -32,8 +32,7 @@ message Service { // ApplicationServiceConfig holds the service configuration the application stakes for message ApplicationServiceConfig { - // TODO_BETA: Avoid embedding the full Service because we just need the ID. - Service service = 1; // The Service for which the application is configured + string service_id = 1; // The Service ID for which the application is configured // TODO_MAINNET: There is an opportunity for applications to advertise the max // they're willing to pay for a certain configuration/price, but this is outside of scope. @@ -42,8 +41,7 @@ message ApplicationServiceConfig { // SupplierServiceConfig holds the service configuration the supplier stakes for message SupplierServiceConfig { - // TODO_BETA: Avoid embedding the full Service because we just need the ID. - Service service = 1; // The Service for which the supplier is configured + string service_id = 1; // The Service ID for which the supplier is configured repeated SupplierEndpoint endpoints = 2; // List of endpoints for the service repeated ServiceRevenueShare rev_share = 3; // List of revenue share configurations for the service // TODO_MAINNET: There is an opportunity for supplier to advertise the min diff --git a/tests/integration/tokenomics/relay_mining_difficulty_test.go b/tests/integration/tokenomics/relay_mining_difficulty_test.go index 17ca9f174..6e7b86f2a 100644 --- a/tests/integration/tokenomics/relay_mining_difficulty_test.go +++ b/tests/integration/tokenomics/relay_mining_difficulty_test.go @@ -155,7 +155,7 @@ func getSession(t *testing.T, integrationApp *testutil.App) *sessiontypes.Sessio sessionQueryClient := sessiontypes.NewQueryClient(integrationApp.QueryHelper()) getSessionReq := sessiontypes.QueryGetSessionRequest{ ApplicationAddress: integrationApp.DefaultApplication.Address, - Service: integrationApp.DefaultService, + ServiceId: integrationApp.DefaultService.Id, BlockHeight: sdkCtx.BlockHeight(), } diff --git a/tests/integration/tokenomics/tokenomics_example_test.go b/tests/integration/tokenomics/tokenomics_example_test.go index 9d3a3b52e..fbd611e3e 100644 --- a/tests/integration/tokenomics/tokenomics_example_test.go +++ b/tests/integration/tokenomics/tokenomics_example_test.go @@ -63,7 +63,7 @@ func TestTokenomicsIntegrationExample(t *testing.T) { sessionQueryClient := sessiontypes.NewQueryClient(integrationApp.QueryHelper()) getSessionReq := sessiontypes.QueryGetSessionRequest{ ApplicationAddress: integrationApp.DefaultApplication.Address, - Service: integrationApp.DefaultService, + ServiceId: integrationApp.DefaultService.Id, BlockHeight: integrationApp.GetSdkCtx().BlockHeight(), } diff --git a/testutil/integration/app.go b/testutil/integration/app.go index f33edbbd2..0f68ccba9 100644 --- a/testutil/integration/app.go +++ b/testutil/integration/app.go @@ -547,7 +547,7 @@ func NewCompleteIntegrationApp(t *testing.T) *App { RevSharePercentage: 100, }, }, - Service: &defaultService, + ServiceId: defaultService.Id, }, }, } @@ -571,7 +571,7 @@ func NewCompleteIntegrationApp(t *testing.T) *App { Stake: &appStake, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ { - Service: &defaultService, + ServiceId: defaultService.Id, }, }, } diff --git a/testutil/keeper/proof.go b/testutil/keeper/proof.go index 74ef106c6..f8e8e3a7b 100644 --- a/testutil/keeper/proof.go +++ b/testutil/keeper/proof.go @@ -304,14 +304,14 @@ func (keepers *ProofModuleKeepers) AddServiceActors( keepers.SetSupplier(ctx, sharedtypes.Supplier{ OperatorAddress: supplierOperatorAddr, Services: []*sharedtypes.SupplierServiceConfig{ - {Service: service}, + {ServiceId: service.Id}, }, }) keepers.SetApplication(ctx, apptypes.Application{ Address: appAddr, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ - {Service: service}, + {ServiceId: service.Id}, }, }) @@ -333,7 +333,7 @@ func (keepers *ProofModuleKeepers) GetSessionHeader( ctx, &sessiontypes.QueryGetSessionRequest{ ApplicationAddress: appAddr, - Service: service, + ServiceId: service.Id, BlockHeight: blockHeight, }, ) diff --git a/testutil/keeper/session.go b/testutil/keeper/session.go index 1b32d2219..74ff98a07 100644 --- a/testutil/keeper/session.go +++ b/testutil/keeper/session.go @@ -45,13 +45,13 @@ var ( Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ { - Service: &sharedtypes.Service{Id: TestServiceId1}, + ServiceId: TestServiceId1, }, { - Service: &sharedtypes.Service{Id: TestServiceId11}, + ServiceId: TestServiceId11, }, { - Service: &sharedtypes.Service{Id: TestServiceId12}, + ServiceId: TestServiceId12, }, }, } @@ -62,13 +62,13 @@ var ( Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ { - Service: &sharedtypes.Service{Id: TestServiceId2}, + ServiceId: TestServiceId2, }, { - Service: &sharedtypes.Service{Id: TestServiceId22}, + ServiceId: TestServiceId22, }, { - Service: &sharedtypes.Service{Id: TestServiceId12}, + ServiceId: TestServiceId12, }, }, } @@ -80,7 +80,7 @@ var ( Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.SupplierServiceConfig{ { - Service: &sharedtypes.Service{Id: TestServiceId1}, + ServiceId: TestServiceId1, Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: TestSupplierUrl, @@ -90,7 +90,7 @@ var ( }, }, { - Service: &sharedtypes.Service{Id: TestServiceId2}, + ServiceId: TestServiceId2, Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: TestSupplierUrl, @@ -100,7 +100,7 @@ var ( }, }, { - Service: &sharedtypes.Service{Id: TestServiceId12}, + ServiceId: TestServiceId12, Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: TestSupplierUrl, diff --git a/testutil/keeper/tokenomics.go b/testutil/keeper/tokenomics.go index 0153a6b64..d9e9f7d4a 100644 --- a/testutil/keeper/tokenomics.go +++ b/testutil/keeper/tokenomics.go @@ -118,7 +118,7 @@ func TokenomicsKeeperWithActorAddrs(t testing.TB) ( application := apptypes.Application{ Address: sample.AccAddress(), Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100000)}, - ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{{Service: service}}, + ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{{ServiceId: service.Id}}, } // Prepare the test supplier. @@ -129,7 +129,7 @@ func TokenomicsKeeperWithActorAddrs(t testing.TB) ( Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100000)}, Services: []*sharedtypes.SupplierServiceConfig{ { - Service: service, + ServiceId: service.Id, RevShare: []*sharedtypes.ServiceRevenueShare{ { Address: supplierOwnerAddr, diff --git a/testutil/network/network.go b/testutil/network/network.go index 41d238129..b7cc1fa1c 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -94,7 +94,7 @@ func ApplicationModuleGenesisStateWithAddresses(t *testing.T, addresses []string Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(10000)}, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ { - Service: &sharedtypes.Service{Id: "svc1"}, + ServiceId: "svc1", }, }, } @@ -116,10 +116,10 @@ func DefaultApplicationModuleGenesisState(t *testing.T, n int) *apptypes.Genesis Stake: &stake, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ { - Service: &sharedtypes.Service{Id: fmt.Sprintf("svc%d", i)}, + ServiceId: fmt.Sprintf("svc%d", i), }, { - Service: &sharedtypes.Service{Id: fmt.Sprintf("svc%d%d", i, i)}, + ServiceId: fmt.Sprintf("svc%d%d", i, i), }, }, PendingUndelegations: map[uint64]apptypes.UndelegatingGatewayList{}, @@ -145,7 +145,7 @@ func DefaultSupplierModuleGenesisState(t *testing.T, n int) *suppliertypes.Genes Stake: &stake, Services: []*sharedtypes.SupplierServiceConfig{ { - Service: &sharedtypes.Service{Id: svcId}, + ServiceId: svcId, Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: fmt.Sprintf("http://localhost:%d", i), @@ -175,7 +175,7 @@ func SupplierModuleGenesisStateWithAddresses(t *testing.T, addresses []string) * Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(10000)}, Services: []*sharedtypes.SupplierServiceConfig{ { - Service: &sharedtypes.Service{Id: "svc1"}, + ServiceId: "svc1", Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: "http://localhost:1", diff --git a/testutil/proof/fixture_generators.go b/testutil/proof/fixture_generators.go index 5aff488df..9dc17a0cc 100644 --- a/testutil/proof/fixture_generators.go +++ b/testutil/proof/fixture_generators.go @@ -9,11 +9,9 @@ import ( "github.com/stretchr/testify/require" "github.com/pokt-network/poktroll/pkg/crypto/protocol" - "github.com/pokt-network/poktroll/testutil/sample" testsession "github.com/pokt-network/poktroll/testutil/session" prooftypes "github.com/pokt-network/poktroll/x/proof/types" sessiontypes "github.com/pokt-network/poktroll/x/session/types" - sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) const ( @@ -29,12 +27,8 @@ func BaseClaim(serviceId, appAddr, supplierOperatorAddr string, numRelays uint64 return prooftypes.Claim{ SupplierOperatorAddress: supplierOperatorAddr, SessionHeader: &sessiontypes.SessionHeader{ - ApplicationAddress: appAddr, - Service: &sharedtypes.Service{ - Id: serviceId, - ComputeUnitsPerRelay: computeUnitsPerRelay, - OwnerAddress: sample.AccAddress(), // This may need to be an input param in the future. - }, + ApplicationAddress: appAddr, + ServiceId: serviceId, SessionId: "session_id", SessionStartBlockHeight: 1, SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(1), diff --git a/testutil/testclient/testqueryclients/appquerier.go b/testutil/testclient/testqueryclients/appquerier.go index 9c0335b7a..e06753910 100644 --- a/testutil/testclient/testqueryclients/appquerier.go +++ b/testutil/testclient/testqueryclients/appquerier.go @@ -47,12 +47,7 @@ func NewTestApplicationQueryClient( Address: appAddress, Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ - { - Service: &sharedtypes.Service{ - Id: "svc1", - Name: "service one", - }, - }, + {ServiceId: "svc1"}, }, DelegateeGatewayAddresses: delegateeAddresses, }, nil diff --git a/testutil/testclient/testqueryclients/sessionquerier.go b/testutil/testclient/testqueryclients/sessionquerier.go index 7522380b4..abe39ca70 100644 --- a/testutil/testclient/testqueryclients/sessionquerier.go +++ b/testutil/testclient/testqueryclients/sessionquerier.go @@ -76,7 +76,7 @@ func AddToExistingSessions( session := sessiontypes.Session{ Header: &sessiontypes.SessionHeader{ - Service: &sharedtypes.Service{Id: serviceId}, + ServiceId: serviceId, ApplicationAddress: appAddress, SessionId: sessionId, SessionStartBlockHeight: testsession.GetSessionStartHeightWithDefaultParams(blockHeight), diff --git a/testutil/testclient/testqueryclients/supplierquerier.go b/testutil/testclient/testqueryclients/supplierquerier.go index 352916c67..7c20f8041 100644 --- a/testutil/testclient/testqueryclients/supplierquerier.go +++ b/testutil/testclient/testqueryclients/supplierquerier.go @@ -47,9 +47,7 @@ func NewTestSupplierQueryClient( for serviceId, providedService := range supplierProvidedServices { serviceConfig := &sharedtypes.SupplierServiceConfig{ - Service: &sharedtypes.Service{ - Id: serviceId, - }, + ServiceId: serviceId, Endpoints: []*sharedtypes.SupplierEndpoint{}, } diff --git a/testutil/testproxy/relayerproxy.go b/testutil/testproxy/relayerproxy.go index d16ce48e2..a105d1e72 100644 --- a/testutil/testproxy/relayerproxy.go +++ b/testutil/testproxy/relayerproxy.go @@ -429,7 +429,7 @@ func GenerateRelayRequest( SessionHeader: &sessiontypes.SessionHeader{ ApplicationAddress: appAddress, SessionId: string(sessionId[:]), - Service: &sharedtypes.Service{Id: serviceId}, + ServiceId: serviceId, SessionStartBlockHeight: testsession.GetSessionStartHeightWithDefaultParams(blockHeight), SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(blockHeight), }, diff --git a/x/application/keeper/msg_server_delegate_to_gateway_test.go b/x/application/keeper/msg_server_delegate_to_gateway_test.go index 23c4b53af..722fc8e39 100644 --- a/x/application/keeper/msg_server_delegate_to_gateway_test.go +++ b/x/application/keeper/msg_server_delegate_to_gateway_test.go @@ -33,7 +33,7 @@ func TestMsgServer_DelegateToGateway_SuccessfullyDelegate(t *testing.T) { Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.ApplicationServiceConfig{ { - Service: &sharedtypes.Service{Id: "svc1"}, + ServiceId: "svc1", }, }, } @@ -113,7 +113,7 @@ func TestMsgServer_DelegateToGateway_FailDuplicate(t *testing.T) { Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.ApplicationServiceConfig{ { - Service: &sharedtypes.Service{Id: "svc1"}, + ServiceId: "svc1", }, }, } @@ -182,7 +182,7 @@ func TestMsgServer_DelegateToGateway_FailGatewayNotStaked(t *testing.T) { Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.ApplicationServiceConfig{ { - Service: &sharedtypes.Service{Id: "svc1"}, + ServiceId: "svc1", }, }, } @@ -220,7 +220,7 @@ func TestMsgServer_DelegateToGateway_FailMaxReached(t *testing.T) { Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.ApplicationServiceConfig{ { - Service: &sharedtypes.Service{Id: "svc1"}, + ServiceId: "svc1", }, }, } diff --git a/x/application/keeper/msg_server_stake_application_test.go b/x/application/keeper/msg_server_stake_application_test.go index 1e97a4c80..81049bc59 100644 --- a/x/application/keeper/msg_server_stake_application_test.go +++ b/x/application/keeper/msg_server_stake_application_test.go @@ -30,9 +30,7 @@ func TestMsgServer_StakeApplication_SuccessfulCreateAndUpdate(t *testing.T) { Address: appAddr, Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.ApplicationServiceConfig{ - { - Service: &sharedtypes.Service{Id: "svc1"}, - }, + {ServiceId: "svc1"}, }, } @@ -46,19 +44,15 @@ func TestMsgServer_StakeApplication_SuccessfulCreateAndUpdate(t *testing.T) { require.Equal(t, appAddr, foundApp.Address) require.Equal(t, int64(100), foundApp.Stake.Amount.Int64()) require.Len(t, foundApp.ServiceConfigs, 1) - require.Equal(t, "svc1", foundApp.ServiceConfigs[0].Service.Id) + require.Equal(t, "svc1", foundApp.ServiceConfigs[0].ServiceId) // Prepare an updated application with a higher stake and another service updateStakeMsg := &types.MsgStakeApplication{ Address: appAddr, Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(200)}, Services: []*sharedtypes.ApplicationServiceConfig{ - { - Service: &sharedtypes.Service{Id: "svc1"}, - }, - { - Service: &sharedtypes.Service{Id: "svc2"}, - }, + {ServiceId: "svc1"}, + {ServiceId: "svc2"}, }, } @@ -69,8 +63,8 @@ func TestMsgServer_StakeApplication_SuccessfulCreateAndUpdate(t *testing.T) { require.True(t, isAppFound) require.Equal(t, int64(200), foundApp.Stake.Amount.Int64()) require.Len(t, foundApp.ServiceConfigs, 2) - require.Equal(t, "svc1", foundApp.ServiceConfigs[0].Service.Id) - require.Equal(t, "svc2", foundApp.ServiceConfigs[1].Service.Id) + require.Equal(t, "svc1", foundApp.ServiceConfigs[0].ServiceId) + require.Equal(t, "svc2", foundApp.ServiceConfigs[1].ServiceId) } func TestMsgServer_StakeApplication_FailRestakingDueToInvalidServices(t *testing.T) { @@ -84,9 +78,7 @@ func TestMsgServer_StakeApplication_FailRestakingDueToInvalidServices(t *testing Address: appAddr, Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.ApplicationServiceConfig{ - { - Service: &sharedtypes.Service{Id: "svc1"}, - }, + {ServiceId: "svc1"}, }, } @@ -110,16 +102,14 @@ func TestMsgServer_StakeApplication_FailRestakingDueToInvalidServices(t *testing require.True(t, isAppFound) require.Equal(t, appAddr, foundApp.Address) require.Len(t, foundApp.ServiceConfigs, 1) - require.Equal(t, "svc1", foundApp.ServiceConfigs[0].Service.Id) + require.Equal(t, "svc1", foundApp.ServiceConfigs[0].ServiceId) // Prepare the application stake message with an invalid service ID updateStakeMsg = &types.MsgStakeApplication{ Address: appAddr, Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.ApplicationServiceConfig{ - { - Service: &sharedtypes.Service{Id: "svc1 INVALID ! & *"}, - }, + {ServiceId: "svc1 INVALID ! & *"}, }, } @@ -132,7 +122,7 @@ func TestMsgServer_StakeApplication_FailRestakingDueToInvalidServices(t *testing require.True(t, isAppFound) require.Equal(t, appAddr, foundApp.Address) require.Len(t, foundApp.ServiceConfigs, 1) - require.Equal(t, "svc1", foundApp.ServiceConfigs[0].Service.Id) + require.Equal(t, "svc1", foundApp.ServiceConfigs[0].ServiceId) } func TestMsgServer_StakeApplication_FailLoweringStake(t *testing.T) { @@ -145,9 +135,7 @@ func TestMsgServer_StakeApplication_FailLoweringStake(t *testing.T) { Address: appAddr, Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.ApplicationServiceConfig{ - { - Service: &sharedtypes.Service{Id: "svc1"}, - }, + {ServiceId: "svc1"}, }, } @@ -162,9 +150,7 @@ func TestMsgServer_StakeApplication_FailLoweringStake(t *testing.T) { Address: appAddr, Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(50)}, Services: []*sharedtypes.ApplicationServiceConfig{ - { - Service: &sharedtypes.Service{Id: "svc1"}, - }, + {ServiceId: "svc1"}, }, } diff --git a/x/application/keeper/msg_server_undelegate_from_gateway_test.go b/x/application/keeper/msg_server_undelegate_from_gateway_test.go index e6be0fa9c..7f4785ace 100644 --- a/x/application/keeper/msg_server_undelegate_from_gateway_test.go +++ b/x/application/keeper/msg_server_undelegate_from_gateway_test.go @@ -41,9 +41,7 @@ func TestMsgServer_UndelegateFromGateway_SuccessfullyUndelegate(t *testing.T) { Address: appAddr, Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.ApplicationServiceConfig{ - { - Service: &sharedtypes.Service{Id: "svc1"}, - }, + {ServiceId: "svc1"}, }, } @@ -135,9 +133,7 @@ func TestMsgServer_UndelegateFromGateway_FailNotDelegated(t *testing.T) { Address: appAddr, Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.ApplicationServiceConfig{ - { - Service: &sharedtypes.Service{Id: "svc1"}, - }, + {ServiceId: "svc1"}, }, } @@ -212,9 +208,7 @@ func TestMsgServer_UndelegateFromGateway_SuccessfullyUndelegateFromUnstakedGatew Address: appAddr, Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.ApplicationServiceConfig{ - { - Service: &sharedtypes.Service{Id: "svc1"}, - }, + {ServiceId: "svc1"}, }, } @@ -522,9 +516,7 @@ func createAppStakeDelegateAndUndelegate( Address: appAddr, Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.ApplicationServiceConfig{ - { - Service: &sharedtypes.Service{Id: "svc1"}, - }, + {ServiceId: "svc1"}, }, } _, err := srv.StakeApplication(ctx, stakeMsg) diff --git a/x/application/keeper/msg_server_unstake_application_test.go b/x/application/keeper/msg_server_unstake_application_test.go index cc0a7ac10..442b65a98 100644 --- a/x/application/keeper/msg_server_unstake_application_test.go +++ b/x/application/keeper/msg_server_unstake_application_test.go @@ -189,9 +189,7 @@ func createAppStakeMsg(appAddr string, stakeAmount int64) *types.MsgStakeApplica Address: appAddr, Stake: &initialStake, Services: []*sharedtypes.ApplicationServiceConfig{ - { - Service: &sharedtypes.Service{Id: "svc1"}, - }, + {ServiceId: "svc1"}, }, } } diff --git a/x/application/module/config/application_configs_reader.go b/x/application/module/config/application_configs_reader.go index 143dff694..6ed449fac 100644 --- a/x/application/module/config/application_configs_reader.go +++ b/x/application/module/config/application_configs_reader.go @@ -77,7 +77,7 @@ func ParseApplicationConfigs(configContent []byte) (*ApplicationStakeConfig, err } appServiceConfig := &sharedtypes.ApplicationServiceConfig{ - Service: &sharedtypes.Service{Id: serviceId}, + ServiceId: serviceId, } applicationServiceConfig = append(applicationServiceConfig, appServiceConfig) diff --git a/x/application/module/config/application_configs_reader_test.go b/x/application/module/config/application_configs_reader_test.go index 571af114c..aa18d6265 100644 --- a/x/application/module/config/application_configs_reader_test.go +++ b/x/application/module/config/application_configs_reader_test.go @@ -37,12 +37,8 @@ func Test_ParseApplicationConfigs(t *testing.T) { expectedConfig: &config.ApplicationStakeConfig{ StakeAmount: sdk.NewCoin("upokt", math.NewInt(1000)), Services: []*sharedtypes.ApplicationServiceConfig{ - { - Service: &sharedtypes.Service{Id: "svc1"}, - }, - { - Service: &sharedtypes.Service{Id: "svc2"}, - }, + {ServiceId: "svc1"}, + {ServiceId: "svc2"}, }, }, }, @@ -134,7 +130,7 @@ func Test_ParseApplicationConfigs(t *testing.T) { t.Logf("serviceIds: %v", test.expectedConfig.Services) require.Equal(t, len(test.expectedConfig.Services), len(appServiceConfig.Services)) for i, expected := range test.expectedConfig.Services { - require.Equal(t, expected.Service.Id, appServiceConfig.Services[i].Service.Id) + require.Equal(t, expected.ServiceId, appServiceConfig.Services[i].ServiceId) } }) } diff --git a/x/application/module/genesis_test.go b/x/application/module/genesis_test.go index efc992dd0..e961ffa21 100644 --- a/x/application/module/genesis_test.go +++ b/x/application/module/genesis_test.go @@ -25,7 +25,7 @@ func TestGenesis(t *testing.T) { Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ { - Service: &sharedtypes.Service{Id: "svc1"}, + ServiceId: "svc1", }, }, }, @@ -33,9 +33,7 @@ func TestGenesis(t *testing.T) { Address: sample.AccAddress(), Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ - { - Service: &sharedtypes.Service{Id: "svc2"}, - }, + {ServiceId: "svc2"}, }, }, }, diff --git a/x/application/types/genesis_test.go b/x/application/types/genesis_test.go index ca27800cf..36d0f4e4f 100644 --- a/x/application/types/genesis_test.go +++ b/x/application/types/genesis_test.go @@ -15,15 +15,11 @@ import ( func TestGenesisState_Validate(t *testing.T) { addr1 := sample.AccAddress() stake1 := sdk.NewCoin("upokt", math.NewInt(100)) - svc1AppConfig := &sharedtypes.ApplicationServiceConfig{ - Service: &sharedtypes.Service{Id: "svc1"}, - } + svc1AppConfig := &sharedtypes.ApplicationServiceConfig{ServiceId: "svc1"} addr2 := sample.AccAddress() stake2 := sdk.NewCoin("upokt", math.NewInt(100)) - svc2AppConfig := &sharedtypes.ApplicationServiceConfig{ - Service: &sharedtypes.Service{Id: "svc2"}, - } + svc2AppConfig := &sharedtypes.ApplicationServiceConfig{ServiceId: "svc2"} emptyDelegatees := make([]string, 0) gatewayAddr1 := sample.AccAddress() @@ -315,29 +311,7 @@ func TestGenesisState_Validate(t *testing.T) { Address: addr1, Stake: &stake1, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ - {Service: &sharedtypes.Service{Id: "TooLongId1234567890"}}, - }, - DelegateeGatewayAddresses: emptyDelegatees, - }, - }, - }, - isValid: false, - }, - { - desc: "invalid - service name too long", - genState: &types.GenesisState{ - Params: types.Params{ - MaxDelegatedGateways: 7, - }, - ApplicationList: []types.Application{ - { - Address: addr1, - Stake: &stake1, - ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ - {Service: &sharedtypes.Service{ - Id: "123", - Name: "abcdefghijklmnopqrstuvwxyzab-abcdefghijklmnopqrstuvwxyzab", - }}, + {ServiceId: "TooLongId1234567890"}, }, DelegateeGatewayAddresses: emptyDelegatees, }, @@ -356,7 +330,7 @@ func TestGenesisState_Validate(t *testing.T) { Address: addr1, Stake: &stake1, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ - {Service: &sharedtypes.Service{Id: "12 45 !"}}, + {ServiceId: "12 45 !"}, }, DelegateeGatewayAddresses: emptyDelegatees, }, diff --git a/x/application/types/message_stake_application_test.go b/x/application/types/message_stake_application_test.go index b22f29b85..152ae71e7 100644 --- a/x/application/types/message_stake_application_test.go +++ b/x/application/types/message_stake_application_test.go @@ -24,7 +24,7 @@ func TestMsgStakeApplication_ValidateBasic(t *testing.T) { Address: "invalid_address", // Stake explicitly omitted Services: []*sharedtypes.ApplicationServiceConfig{ - {Service: &sharedtypes.Service{Id: "svc1"}}, + {ServiceId: "svc1"}, }, }, expectedErr: ErrAppInvalidAddress, @@ -37,7 +37,7 @@ func TestMsgStakeApplication_ValidateBasic(t *testing.T) { Address: sample.AccAddress(), // Stake explicitly omitted Services: []*sharedtypes.ApplicationServiceConfig{ - {Service: &sharedtypes.Service{Id: "svc1"}}, + {ServiceId: "svc1"}, }, }, expectedErr: ErrAppInvalidStake, @@ -47,7 +47,7 @@ func TestMsgStakeApplication_ValidateBasic(t *testing.T) { Address: sample.AccAddress(), Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.ApplicationServiceConfig{ - {Service: &sharedtypes.Service{Id: "svc1"}}, + {ServiceId: "svc1"}, }, }, }, { @@ -56,7 +56,7 @@ func TestMsgStakeApplication_ValidateBasic(t *testing.T) { Address: sample.AccAddress(), Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(0)}, Services: []*sharedtypes.ApplicationServiceConfig{ - {Service: &sharedtypes.Service{Id: "svc1"}}, + {ServiceId: "svc1"}, }, }, expectedErr: ErrAppInvalidStake, @@ -66,7 +66,7 @@ func TestMsgStakeApplication_ValidateBasic(t *testing.T) { Address: sample.AccAddress(), Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(-100)}, Services: []*sharedtypes.ApplicationServiceConfig{ - {Service: &sharedtypes.Service{Id: "svc1"}}, + {ServiceId: "svc1"}, }, }, expectedErr: ErrAppInvalidStake, @@ -76,7 +76,7 @@ func TestMsgStakeApplication_ValidateBasic(t *testing.T) { Address: sample.AccAddress(), Stake: &sdk.Coin{Denom: "invalid", Amount: math.NewInt(100)}, Services: []*sharedtypes.ApplicationServiceConfig{ - {Service: &sharedtypes.Service{Id: "svc1"}}, + {ServiceId: "svc1"}, }, }, expectedErr: ErrAppInvalidStake, @@ -86,7 +86,7 @@ func TestMsgStakeApplication_ValidateBasic(t *testing.T) { Address: sample.AccAddress(), Stake: &sdk.Coin{Denom: "", Amount: math.NewInt(100)}, Services: []*sharedtypes.ApplicationServiceConfig{ - {Service: &sharedtypes.Service{Id: "svc1"}}, + {ServiceId: "svc1"}, }, }, expectedErr: ErrAppInvalidStake, @@ -99,8 +99,8 @@ func TestMsgStakeApplication_ValidateBasic(t *testing.T) { Address: sample.AccAddress(), Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.ApplicationServiceConfig{ - {Service: &sharedtypes.Service{Id: "svc1"}}, - {Service: &sharedtypes.Service{Id: "svc2"}}, + {ServiceId: "svc1"}, + {ServiceId: "svc2"}, }, }, }, @@ -128,21 +128,7 @@ func TestMsgStakeApplication_ValidateBasic(t *testing.T) { Address: sample.AccAddress(), Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.ApplicationServiceConfig{ - {Service: &sharedtypes.Service{Id: "TooLongId1234567890"}}, - }, - }, - expectedErr: ErrAppInvalidServiceConfigs, - }, - { - desc: "invalid service configs - invalid service Name that's too long", - msg: MsgStakeApplication{ - Address: sample.AccAddress(), - Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, - Services: []*sharedtypes.ApplicationServiceConfig{ - {Service: &sharedtypes.Service{ - Id: "123", - Name: "abcdefghijklmnopqrstuvwxyzab-abcdefghijklmnopqrstuvwxyzab", - }}, + {ServiceId: "TooLongId1234567890"}, }, }, expectedErr: ErrAppInvalidServiceConfigs, @@ -153,7 +139,7 @@ func TestMsgStakeApplication_ValidateBasic(t *testing.T) { Address: sample.AccAddress(), Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.ApplicationServiceConfig{ - {Service: &sharedtypes.Service{Id: "12 45 !"}}, + {ServiceId: "12 45 !"}, }, }, expectedErr: ErrAppInvalidServiceConfigs, diff --git a/x/proof/keeper/msg_server_create_claim.go b/x/proof/keeper/msg_server_create_claim.go index 44a1a508a..d07514c1c 100644 --- a/x/proof/keeper/msg_server_create_claim.go +++ b/x/proof/keeper/msg_server_create_claim.go @@ -88,7 +88,7 @@ func (k msgServer) CreateClaim( // numClaimComputeUnits = numRelays * service.computeUnitsPerRelay // This is because for any specific service, every relay is worth the same. // However, this may change in the future. - serviceComputeUnitsPerRelay, err := k.getServiceComputeUnitsPerRelay(ctx, claim.SessionHeader.Service.Id) + serviceComputeUnitsPerRelay, err := k.getServiceComputeUnitsPerRelay(ctx, claim.SessionHeader.ServiceId) if err != nil { return nil, status.Error(codes.NotFound, types.ErrProofServiceNotFound.Wrapf("%v", err).Error()) } @@ -102,7 +102,7 @@ func (k msgServer) CreateClaim( numClaimComputeUnits, numRelays, serviceComputeUnitsPerRelay, - claim.SessionHeader.Service.Id, + claim.SessionHeader.ServiceId, ), ).Error(), ) diff --git a/x/proof/keeper/msg_server_create_claim_test.go b/x/proof/keeper/msg_server_create_claim_test.go index 8fe20d4f4..8a34f4fb7 100644 --- a/x/proof/keeper/msg_server_create_claim_test.go +++ b/x/proof/keeper/msg_server_create_claim_test.go @@ -109,14 +109,14 @@ func TestMsgServer_CreateClaim_Success(t *testing.T) { keepers.SetSupplier(ctx, sharedtypes.Supplier{ OperatorAddress: supplierOperatorAddr, Services: []*sharedtypes.SupplierServiceConfig{ - {Service: service}, + {ServiceId: service.Id}, }, }) keepers.SetApplication(ctx, apptypes.Application{ Address: appAddr, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ - {Service: service}, + {ServiceId: service.Id}, }, }) @@ -126,7 +126,7 @@ func TestMsgServer_CreateClaim_Success(t *testing.T) { ctx, &sessiontypes.QueryGetSessionRequest{ ApplicationAddress: appAddr, - Service: service, + ServiceId: service.Id, BlockHeight: blockHeight, }, ) @@ -205,14 +205,14 @@ func TestMsgServer_CreateClaim_Error_OutsideOfWindow(t *testing.T) { keepers.SetSupplier(ctx, sharedtypes.Supplier{ OperatorAddress: supplierOperatorAddr, Services: []*sharedtypes.SupplierServiceConfig{ - {Service: service}, + {ServiceId: service.Id}, }, }) keepers.SetApplication(ctx, apptypes.Application{ Address: appAddr, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ - {Service: service}, + {ServiceId: service.Id}, }, }) @@ -220,7 +220,7 @@ func TestMsgServer_CreateClaim_Error_OutsideOfWindow(t *testing.T) { ctx, &sessiontypes.QueryGetSessionRequest{ ApplicationAddress: appAddr, - Service: service, + ServiceId: service.Id, BlockHeight: 1, }, ) @@ -343,7 +343,7 @@ func TestMsgServer_CreateClaim_Error(t *testing.T) { supplierKeeper.SetSupplier(ctx, sharedtypes.Supplier{ OperatorAddress: supplierOperatorAddr, Services: []*sharedtypes.SupplierServiceConfig{ - {Service: service}, + {ServiceId: service.Id}, }, }) @@ -351,13 +351,7 @@ func TestMsgServer_CreateClaim_Error(t *testing.T) { supplierKeeper.SetSupplier(ctx, sharedtypes.Supplier{ OperatorAddress: wrongSupplierOperatorAddr, Services: []*sharedtypes.SupplierServiceConfig{ - { - Service: &sharedtypes.Service{ - Id: "nosvc1", - ComputeUnitsPerRelay: computeUnitsPerRelay, - OwnerAddress: sample.AccAddress(), - }, - }, + {ServiceId: "nosvc1"}, }, }) @@ -365,7 +359,7 @@ func TestMsgServer_CreateClaim_Error(t *testing.T) { appKeeper.SetApplication(ctx, apptypes.Application{ Address: appAddr, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ - {Service: service}, + {ServiceId: service.Id}, }, }) @@ -373,13 +367,7 @@ func TestMsgServer_CreateClaim_Error(t *testing.T) { appKeeper.SetApplication(ctx, apptypes.Application{ Address: wrongAppAddr, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ - { - Service: &sharedtypes.Service{ - Id: "nosvc1", - ComputeUnitsPerRelay: computeUnitsPerRelay, - OwnerAddress: sample.AccAddress(), - }, - }, + {ServiceId: "nosvc1"}, }, }) @@ -388,7 +376,7 @@ func TestMsgServer_CreateClaim_Error(t *testing.T) { ctx, &sessiontypes.QueryGetSessionRequest{ ApplicationAddress: appAddr, - Service: service, + ServiceId: service.Id, BlockHeight: 1, }, ) @@ -560,7 +548,7 @@ func TestMsgServer_CreateClaim_Error_ComputeUnitsMismatch(t *testing.T) { supplierKeeper.SetSupplier(ctx, sharedtypes.Supplier{ OperatorAddress: supplierAddr, Services: []*sharedtypes.SupplierServiceConfig{ - {Service: service}, + {ServiceId: service.Id}, }, }) @@ -571,7 +559,7 @@ func TestMsgServer_CreateClaim_Error_ComputeUnitsMismatch(t *testing.T) { appKeeper.SetApplication(ctx, apptypes.Application{ Address: appAddr, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ - {Service: service}, + {ServiceId: service.Id}, }, }) @@ -580,7 +568,7 @@ func TestMsgServer_CreateClaim_Error_ComputeUnitsMismatch(t *testing.T) { ctx, &sessiontypes.QueryGetSessionRequest{ ApplicationAddress: appAddr, - Service: service, + ServiceId: service.Id, BlockHeight: 1, }, ) @@ -628,7 +616,7 @@ func TestMsgServer_CreateClaim_Error_ComputeUnitsMismatch(t *testing.T) { testClaimNumComputeUnits, testClaimNumRelays, nonDefaultComputeUnitsPerRelay, - sessionHeader.Service.Id, + sessionHeader.ServiceId, ).Error(), ).Error(), ) @@ -657,7 +645,7 @@ func newTestClaimMsg( supplierOperatorAddr, &sessiontypes.SessionHeader{ ApplicationAddress: appAddr, - Service: service, + ServiceId: service.Id, SessionId: sessionId, SessionStartBlockHeight: sessionStartHeight, SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(sessionStartHeight), diff --git a/x/proof/keeper/proof_test.go b/x/proof/keeper/proof_test.go index d2bcc9c18..7657fce84 100644 --- a/x/proof/keeper/proof_test.go +++ b/x/proof/keeper/proof_test.go @@ -15,7 +15,6 @@ import ( "github.com/pokt-network/poktroll/x/proof/keeper" "github.com/pokt-network/poktroll/x/proof/types" sessiontypes "github.com/pokt-network/poktroll/x/session/types" - sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) const ( @@ -34,7 +33,7 @@ func createNProofs(keeper keeper.Keeper, ctx context.Context, n int) []types.Pro SupplierOperatorAddress: sample.AccAddress(), SessionHeader: &sessiontypes.SessionHeader{ ApplicationAddress: sample.AccAddress(), - Service: &sharedtypes.Service{Id: testServiceId}, + ServiceId: testServiceId, SessionId: fmt.Sprintf("session-%d", i), SessionStartBlockHeight: 1, SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(1), diff --git a/x/proof/keeper/proof_validation.go b/x/proof/keeper/proof_validation.go index 96ddab42a..0efab7437 100644 --- a/x/proof/keeper/proof_validation.go +++ b/x/proof/keeper/proof_validation.go @@ -167,7 +167,7 @@ func (k Keeper) EnsureValidProof( if err = validateRelayDifficulty( relayBz, relayDifficultyTargetHash, - sessionHeader.Service.Id, + sessionHeader.ServiceId, ); err != nil { return err } @@ -308,11 +308,11 @@ func (k Keeper) queryAndValidateClaimForProof( } // Ensure service IDs match. - if claimSessionHeader.GetService().GetId() != proofSessionHeader.GetService().GetId() { + if claimSessionHeader.GetServiceId() != proofSessionHeader.GetServiceId() { return nil, types.ErrProofInvalidService.Wrapf( "claim service ID %q does not match proof service ID %q", - claimSessionHeader.GetService().GetId(), - proofSessionHeader.GetService().GetId(), + claimSessionHeader.GetServiceId(), + proofSessionHeader.GetServiceId(), ) } @@ -333,20 +333,11 @@ func compareSessionHeaders(expectedSessionHeader, sessionHeader *sessiontypes.Se } // Compare the Service IDs. - if sessionHeader.GetService().GetId() != expectedSessionHeader.GetService().GetId() { + if sessionHeader.GetServiceId() != expectedSessionHeader.GetServiceId() { return types.ErrProofInvalidRelay.Wrapf( "session headers service IDs mismatch; expected: %q, got: %q", - expectedSessionHeader.GetService().GetId(), - sessionHeader.GetService().GetId(), - ) - } - - // Compare the Service names. - if sessionHeader.GetService().GetName() != expectedSessionHeader.GetService().GetName() { - return types.ErrProofInvalidRelay.Wrapf( - "sessionHeaders service names mismatch expect: %q, got: %q", - expectedSessionHeader.GetService().GetName(), - sessionHeader.GetService().GetName(), + expectedSessionHeader.GetServiceId(), + sessionHeader.GetServiceId(), ) } diff --git a/x/proof/keeper/proof_validation_test.go b/x/proof/keeper/proof_validation_test.go index 13df2e49a..ceb6f5801 100644 --- a/x/proof/keeper/proof_validation_test.go +++ b/x/proof/keeper/proof_validation_test.go @@ -619,7 +619,7 @@ func TestEnsureValidProof_Error(t *testing.T) { "the difficulty relay being proven is (%d), and is smaller than the target difficulty (%d) for service %s", validClosestRelayDifficultyBits, highExpectedTargetDifficulty, - validSessionHeader.Service.Id, + validSessionHeader.ServiceId, ), }, { diff --git a/x/proof/keeper/session.go b/x/proof/keeper/session.go index 5a51130f3..aa0edab43 100644 --- a/x/proof/keeper/session.go +++ b/x/proof/keeper/session.go @@ -23,7 +23,7 @@ func (k Keeper) queryAndValidateSessionHeader( sessionReq := &sessiontypes.QueryGetSessionRequest{ ApplicationAddress: sessionHeader.GetApplicationAddress(), - Service: sessionHeader.GetService(), + ServiceId: sessionHeader.GetServiceId(), BlockHeight: sessionHeader.GetSessionStartBlockHeight(), } diff --git a/x/proof/module/helpers_test.go b/x/proof/module/helpers_test.go index 3744f257f..7f983a1fc 100644 --- a/x/proof/module/helpers_test.go +++ b/x/proof/module/helpers_test.go @@ -163,7 +163,7 @@ func newTestClaim( SupplierOperatorAddress: supplierOperatorAddr, SessionHeader: &sessiontypes.SessionHeader{ ApplicationAddress: appAddr, - Service: &sharedtypes.Service{Id: testServiceId}, + ServiceId: testServiceId, SessionId: sessionId, SessionStartBlockHeight: sessionStartHeight, SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(sessionStartHeight), diff --git a/x/proof/types/message_create_claim_test.go b/x/proof/types/message_create_claim_test.go index 9aa06ef87..f35548758 100644 --- a/x/proof/types/message_create_claim_test.go +++ b/x/proof/types/message_create_claim_test.go @@ -7,7 +7,6 @@ import ( "github.com/pokt-network/poktroll/testutil/sample" sessiontypes "github.com/pokt-network/poktroll/x/session/types" - sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) func TestMsgCreateClaim_ValidateBasic(t *testing.T) { @@ -24,7 +23,7 @@ func TestMsgCreateClaim_ValidateBasic(t *testing.T) { SupplierOperatorAddress: "invalid_address", SessionHeader: &sessiontypes.SessionHeader{ ApplicationAddress: sample.AccAddress(), - Service: &sharedtypes.Service{Id: "svcId"}, + ServiceId: "svcId", SessionStartBlockHeight: 100, SessionEndBlockHeight: 101, SessionId: "valid_session_id", @@ -39,7 +38,7 @@ func TestMsgCreateClaim_ValidateBasic(t *testing.T) { SupplierOperatorAddress: sample.AccAddress(), SessionHeader: &sessiontypes.SessionHeader{ ApplicationAddress: sample.AccAddress(), - Service: &sharedtypes.Service{Id: "svcId"}, + ServiceId: "svcId", SessionStartBlockHeight: -1, SessionEndBlockHeight: 101, SessionId: "valid_session_id", @@ -54,7 +53,7 @@ func TestMsgCreateClaim_ValidateBasic(t *testing.T) { SupplierOperatorAddress: sample.AccAddress(), SessionHeader: &sessiontypes.SessionHeader{ ApplicationAddress: sample.AccAddress(), - Service: &sharedtypes.Service{Id: "svcId"}, + ServiceId: "svcId", SessionStartBlockHeight: 100, SessionEndBlockHeight: 101, SessionId: "", @@ -69,7 +68,7 @@ func TestMsgCreateClaim_ValidateBasic(t *testing.T) { SupplierOperatorAddress: sample.AccAddress(), SessionHeader: &sessiontypes.SessionHeader{ ApplicationAddress: sample.AccAddress(), - Service: &sharedtypes.Service{Id: "invalid service id"}, + ServiceId: "invalid service id", SessionStartBlockHeight: 100, SessionEndBlockHeight: 101, SessionId: "valid_session_id", @@ -84,7 +83,7 @@ func TestMsgCreateClaim_ValidateBasic(t *testing.T) { SupplierOperatorAddress: sample.AccAddress(), SessionHeader: &sessiontypes.SessionHeader{ ApplicationAddress: sample.AccAddress(), - Service: &sharedtypes.Service{Id: "svcId"}, + ServiceId: "svcId", SessionStartBlockHeight: 100, SessionEndBlockHeight: 101, SessionId: "valid_session_id", @@ -100,7 +99,7 @@ func TestMsgCreateClaim_ValidateBasic(t *testing.T) { SupplierOperatorAddress: sample.AccAddress(), SessionHeader: &sessiontypes.SessionHeader{ ApplicationAddress: sample.AccAddress(), - Service: &sharedtypes.Service{Id: "svcId"}, + ServiceId: "svcId", SessionStartBlockHeight: 100, SessionEndBlockHeight: 101, SessionId: "valid_session_id", diff --git a/x/proof/types/message_submit_proof_test.go b/x/proof/types/message_submit_proof_test.go index 972576b85..b4ff57bda 100644 --- a/x/proof/types/message_submit_proof_test.go +++ b/x/proof/types/message_submit_proof_test.go @@ -9,11 +9,11 @@ import ( "github.com/pokt-network/poktroll/testutil/sample" testsession "github.com/pokt-network/poktroll/testutil/session" sessiontypes "github.com/pokt-network/poktroll/x/session/types" - sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) +const testServiceId = "svc01" + func TestMsgSubmitProof_ValidateBasic(t *testing.T) { - testService := &sharedtypes.Service{Id: "svc01"} testClosestMerkleProof := []byte{1, 2, 3, 4} tests := []struct { @@ -27,7 +27,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { SupplierOperatorAddress: sample.AccAddress(), SessionHeader: &sessiontypes.SessionHeader{ ApplicationAddress: "not_a_bech32_address", - Service: testService, + ServiceId: testServiceId, SessionId: "mock_session_id", SessionStartBlockHeight: 1, SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(1), @@ -49,7 +49,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { SupplierOperatorAddress: "not_a_bech32_address", SessionHeader: &sessiontypes.SessionHeader{ ApplicationAddress: sample.AccAddress(), - Service: testService, + ServiceId: testServiceId, SessionId: "mock_session_id", SessionStartBlockHeight: 1, SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(1), @@ -70,7 +70,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { SupplierOperatorAddress: sample.AccAddress(), SessionHeader: &sessiontypes.SessionHeader{ ApplicationAddress: sample.AccAddress(), - Service: &sharedtypes.Service{Id: ""}, + ServiceId: "", SessionId: "mock_session_id", SessionStartBlockHeight: 1, SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(1), @@ -78,9 +78,8 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { Proof: testClosestMerkleProof, }, sessionHeaderToExpectedErrorFn: func(sh sessiontypes.SessionHeader) error { - serviceError := sharedtypes.ErrSharedInvalidService.Wrapf("ID: %q", sh.Service.Id) - sessionError := sessiontypes.ErrSessionInvalidService.Wrapf("%s", serviceError) - return ErrProofInvalidSessionHeader.Wrapf("%s", sessionError) + serviceError := sessiontypes.ErrSessionInvalidService.Wrapf("invalid service ID: %q", sh.ServiceId) + return ErrProofInvalidSessionHeader.Wrapf("%s", serviceError) }, }, { @@ -89,7 +88,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { SupplierOperatorAddress: sample.AccAddress(), SessionHeader: &sessiontypes.SessionHeader{ ApplicationAddress: sample.AccAddress(), - Service: testService, + ServiceId: testServiceId, SessionId: "mock_session_id", SessionStartBlockHeight: 1, SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(1), diff --git a/x/service/keeper/msg_server_add_service_test.go b/x/service/keeper/msg_server_add_service_test.go index 1f587a931..1e5ea62d3 100644 --- a/x/service/keeper/msg_server_add_service_test.go +++ b/x/service/keeper/msg_server_add_service_test.go @@ -141,7 +141,7 @@ func TestMsgServer_AddService(t *testing.T) { Name: "service 1", ComputeUnitsPerRelay: 0, }, - expectedErr: types.ErrServiceInvalidComputeUnitsPerRelay, + expectedErr: sharedtypes.ErrSharedInvalidComputeUnitsPerRelay, }, { desc: "invalid - no spendable coins", diff --git a/x/service/module/tx_add_service.go b/x/service/module/tx_add_service.go index 4e51bdad5..dc5b6c911 100644 --- a/x/service/module/tx_add_service.go +++ b/x/service/module/tx_add_service.go @@ -13,6 +13,7 @@ import ( "github.com/spf13/cobra" "github.com/pokt-network/poktroll/x/service/types" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) var _ = strconv.Itoa(0) @@ -46,7 +47,7 @@ $ poktrolld tx service add-service "svc1" "service_one" 1 --keyring-backend test if len(args) > 2 { computeUnitsPerRelay, err = strconv.ParseUint(args[2], 10, 64) if err != nil { - return types.ErrServiceInvalidComputeUnitsPerRelay.Wrapf("unable to parse as uint64: %s", args[2]) + return sharedtypes.ErrSharedInvalidComputeUnitsPerRelay.Wrapf("unable to parse as uint64: %s", args[2]) } } else { fmt.Printf("Using default compute_units_per_relay: %d\n", types.DefaultComputeUnitsPerRelay) diff --git a/x/service/types/errors.go b/x/service/types/errors.go index 4163d22ff..d593be500 100644 --- a/x/service/types/errors.go +++ b/x/service/types/errors.go @@ -6,20 +6,19 @@ import sdkerrors "cosmossdk.io/errors" // x/service module sentinel errors var ( - ErrServiceInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") - ErrServiceDuplicateIndex = sdkerrors.Register(ModuleName, 1101, "duplicate index when adding a new service") - ErrServiceInvalidAddress = sdkerrors.Register(ModuleName, 1102, "invalid address when adding a new service") - ErrServiceMissingID = sdkerrors.Register(ModuleName, 1103, "missing service ID") - ErrServiceMissingName = sdkerrors.Register(ModuleName, 1104, "missing service name") - ErrServiceAlreadyExists = sdkerrors.Register(ModuleName, 1105, "service already exists") - ErrServiceInvalidServiceFee = sdkerrors.Register(ModuleName, 1106, "invalid ServiceFee") - ErrServiceAccountNotFound = sdkerrors.Register(ModuleName, 1107, "account not found") - ErrServiceNotEnoughFunds = sdkerrors.Register(ModuleName, 1108, "not enough funds to add service") - ErrServiceFailedToDeductFee = sdkerrors.Register(ModuleName, 1109, "failed to deduct fee") - ErrServiceInvalidRelayResponse = sdkerrors.Register(ModuleName, 1110, "invalid relay response") - ErrServiceInvalidRelayRequest = sdkerrors.Register(ModuleName, 1111, "invalid relay request") - ErrServiceInvalidComputeUnitsPerRelay = sdkerrors.Register(ModuleName, 1112, "invalid compute units per relay") - ErrServiceInvalidOwnerAddress = sdkerrors.Register(ModuleName, 1113, "invalid owner address") - ErrServiceParamNameInvalid = sdkerrors.Register(ModuleName, 1114, "the provided param name is invalid") - ErrServiceParamInvalid = sdkerrors.Register(ModuleName, 1115, "the provided param is invalid") + ErrServiceInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") + ErrServiceDuplicateIndex = sdkerrors.Register(ModuleName, 1101, "duplicate index when adding a new service") + ErrServiceInvalidAddress = sdkerrors.Register(ModuleName, 1102, "invalid address when adding a new service") + ErrServiceMissingID = sdkerrors.Register(ModuleName, 1103, "missing service ID") + ErrServiceMissingName = sdkerrors.Register(ModuleName, 1104, "missing service name") + ErrServiceAlreadyExists = sdkerrors.Register(ModuleName, 1105, "service already exists") + ErrServiceInvalidServiceFee = sdkerrors.Register(ModuleName, 1106, "invalid ServiceFee") + ErrServiceAccountNotFound = sdkerrors.Register(ModuleName, 1107, "account not found") + ErrServiceNotEnoughFunds = sdkerrors.Register(ModuleName, 1108, "not enough funds to add service") + ErrServiceFailedToDeductFee = sdkerrors.Register(ModuleName, 1109, "failed to deduct fee") + ErrServiceInvalidRelayResponse = sdkerrors.Register(ModuleName, 1110, "invalid relay response") + ErrServiceInvalidRelayRequest = sdkerrors.Register(ModuleName, 1111, "invalid relay request") + ErrServiceInvalidOwnerAddress = sdkerrors.Register(ModuleName, 1113, "invalid owner address") + ErrServiceParamNameInvalid = sdkerrors.Register(ModuleName, 1114, "the provided param name is invalid") + ErrServiceParamInvalid = sdkerrors.Register(ModuleName, 1115, "the provided param is invalid") ) diff --git a/x/service/types/message_add_service.go b/x/service/types/message_add_service.go index 289e95ba5..90503deed 100644 --- a/x/service/types/message_add_service.go +++ b/x/service/types/message_add_service.go @@ -8,10 +8,6 @@ import ( const ( DefaultComputeUnitsPerRelay uint64 = 1 - // ComputeUnitsPerRelayMax is the maximum allowed compute_units_per_relay value when adding or updating a service. - // TODO_MAINNET: The reason we have a maximum is to account for potential integer overflows. - // Should we revisit all uint64 and convert them to BigInts? - ComputeUnitsPerRelayMax uint64 = 2 ^ 16 ) var _ sdk.Msg = (*MsgAddService)(nil) @@ -37,27 +33,9 @@ func (msg *MsgAddService) ValidateBasic() error { if msg.Service.OwnerAddress != msg.OwnerAddress { return ErrServiceInvalidOwnerAddress.Wrapf("service owner address %q does not match the signer address %q", msg.Service.OwnerAddress, msg.OwnerAddress) } - // TODO_BETA: Add a validate basic function to the `Service` object - if msg.Service.Id == "" { - return ErrServiceMissingID - } - if msg.Service.Name == "" { - return ErrServiceMissingName - } - if err := ValidateComputeUnitsPerRelay(msg.Service.ComputeUnitsPerRelay); err != nil { - return err - } - return nil -} - -// ValidateComputeUnitsPerRelay makes sure the compute units per relay is a valid value -func ValidateComputeUnitsPerRelay(computeUnitsPerRelay uint64) error { - if computeUnitsPerRelay == 0 { - return ErrServiceInvalidComputeUnitsPerRelay.Wrap("compute units per relay must be greater than 0") - } else if computeUnitsPerRelay > ComputeUnitsPerRelayMax { - return ErrServiceInvalidComputeUnitsPerRelay.Wrapf("compute units per relay must be less than %d", ComputeUnitsPerRelayMax) + if err := msg.Service.ValidateBasic(); err != nil { + return err } - return nil } diff --git a/x/service/types/message_add_service_test.go b/x/service/types/message_add_service_test.go index fc4a7b107..a578a7eaa 100644 --- a/x/service/types/message_add_service_test.go +++ b/x/service/types/message_add_service_test.go @@ -23,33 +23,47 @@ func TestMsgAddService_ValidateBasic(t *testing.T) { // Service: intentionally omitted, }, expectedErr: ErrServiceInvalidAddress, - }, { - desc: "valid service owner address - no service ID", + }, + { + desc: "no service ID", msg: MsgAddService{ OwnerAddress: serviceOwnerAddress, - Service: sharedtypes.Service{Name: "service name", OwnerAddress: serviceOwnerAddress}, // ID intentionally omitted + Service: sharedtypes.Service{ + // ID intentionally omitted + Name: "service name", + OwnerAddress: serviceOwnerAddress, + ComputeUnitsPerRelay: 1, + }, }, - expectedErr: ErrServiceMissingID, - }, { - desc: "valid service owner address - no service name", + expectedErr: sharedtypes.ErrSharedInvalidService.Wrapf("invalid service ID: %q", ""), + }, + { + desc: "no service name", msg: MsgAddService{ OwnerAddress: serviceOwnerAddress, - Service: sharedtypes.Service{Id: "svc1", OwnerAddress: serviceOwnerAddress}, // Name intentionally omitted + Service: sharedtypes.Service{ + Id: "svc1", + // Name intentionally omitted + OwnerAddress: serviceOwnerAddress, + ComputeUnitsPerRelay: 1, + }, }, - expectedErr: ErrServiceMissingName, - }, { - desc: "valid service owner address - zero compute units per relay", + expectedErr: nil, + }, + { + desc: "invalid service name", msg: MsgAddService{ OwnerAddress: serviceOwnerAddress, Service: sharedtypes.Service{ Id: "svc1", - Name: "service name", - ComputeUnitsPerRelay: 0, + Name: "service&name", OwnerAddress: serviceOwnerAddress, + ComputeUnitsPerRelay: 1, }, }, - expectedErr: ErrServiceInvalidComputeUnitsPerRelay, - }, { + expectedErr: sharedtypes.ErrSharedInvalidService.Wrapf("invalid service name: %q", "service&name"), + }, + { desc: "signer address does not equal service owner address", msg: MsgAddService{ OwnerAddress: serviceOwnerAddress, @@ -63,7 +77,35 @@ func TestMsgAddService_ValidateBasic(t *testing.T) { expectedErr: ErrServiceInvalidOwnerAddress, }, { - desc: "valid msg add service", + desc: "zero compute units per relay", + msg: MsgAddService{ + OwnerAddress: serviceOwnerAddress, + Service: sharedtypes.Service{ + Id: "svc1", + Name: "service name", + ComputeUnitsPerRelay: 0, + OwnerAddress: serviceOwnerAddress, + }, + }, + expectedErr: sharedtypes.ErrSharedInvalidService. + Wrapf("%s", sharedtypes.ErrSharedInvalidComputeUnitsPerRelay), + }, + { + desc: "compute units per relay greater than max", + msg: MsgAddService{ + OwnerAddress: serviceOwnerAddress, + Service: sharedtypes.Service{ + Id: "svc1", + Name: "service name", + ComputeUnitsPerRelay: sharedtypes.ComputeUnitsPerRelayMax + 1, + OwnerAddress: serviceOwnerAddress, + }, + }, + expectedErr: sharedtypes.ErrSharedInvalidService. + Wrapf("%s", sharedtypes.ErrSharedInvalidComputeUnitsPerRelay), + }, + { + desc: "min compute units per relay", msg: MsgAddService{ OwnerAddress: serviceOwnerAddress, Service: sharedtypes.Service{ @@ -75,48 +117,26 @@ func TestMsgAddService_ValidateBasic(t *testing.T) { }, expectedErr: nil, }, - } - for _, test := range tests { - t.Run(test.desc, func(t *testing.T) { - err := test.msg.ValidateBasic() - if test.expectedErr != nil { - require.ErrorIs(t, err, test.expectedErr) - return - } - require.NoError(t, err) - }) - } -} - -func TestValidateComputeUnitsPerRelay(t *testing.T) { - tests := []struct { - desc string - computeUnitsPerRelay uint64 - expectedErr error - }{ { - desc: "zero compute units per relay", - computeUnitsPerRelay: 0, - expectedErr: ErrServiceInvalidComputeUnitsPerRelay, - }, { - desc: "valid compute units per relay", - computeUnitsPerRelay: 1, - expectedErr: nil, - }, { - desc: "max compute units per relay", - computeUnitsPerRelay: ComputeUnitsPerRelayMax, - expectedErr: nil, - }, { - desc: "compute units per relay greater than max", - computeUnitsPerRelay: ComputeUnitsPerRelayMax + 1, - expectedErr: ErrServiceInvalidComputeUnitsPerRelay, + desc: "max compute units per relay", + msg: MsgAddService{ + OwnerAddress: serviceOwnerAddress, + Service: sharedtypes.Service{ + Id: "svc1", + Name: "service name", + ComputeUnitsPerRelay: sharedtypes.ComputeUnitsPerRelayMax, + OwnerAddress: serviceOwnerAddress, + }, + }, + expectedErr: nil, }, } for _, test := range tests { t.Run(test.desc, func(t *testing.T) { - err := ValidateComputeUnitsPerRelay(test.computeUnitsPerRelay) + err := test.msg.ValidateBasic() if test.expectedErr != nil { require.ErrorIs(t, err, test.expectedErr) + require.ErrorContains(t, err, test.expectedErr.Error()) return } require.NoError(t, err) diff --git a/x/service/types/relay.go b/x/service/types/relay.go index 5d9748032..1200c6697 100644 --- a/x/service/types/relay.go +++ b/x/service/types/relay.go @@ -5,7 +5,6 @@ import ( "github.com/pokt-network/poktroll/pkg/crypto/protocol" sessiontypes "github.com/pokt-network/poktroll/x/session/types" - sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) // GetHash returns the hash of the relay, which contains both the signed @@ -126,9 +125,7 @@ func (sourceRelayRequest *RelayRequest) NullifyForObservability() *RelayRequest emptyRelayRequest := &RelayRequest{ Meta: RelayRequestMetadata{ SessionHeader: &sessiontypes.SessionHeader{ - Service: &sharedtypes.Service{ - Id: "", - }, + ServiceId: "", }, }, Payload: []byte{}, @@ -143,9 +140,7 @@ func (sourceRelayRequest *RelayRequest) NullifyForObservability() *RelayRequest } if sourceRelayRequest.Meta.SessionHeader != nil { - if sourceRelayRequest.Meta.SessionHeader.Service != nil { - emptyRelayRequest.Meta.SessionHeader.Service = sourceRelayRequest.Meta.SessionHeader.Service - } + emptyRelayRequest.Meta.SessionHeader.ServiceId = sourceRelayRequest.Meta.SessionHeader.ServiceId } return emptyRelayRequest diff --git a/x/session/keeper/query_get_session.go b/x/session/keeper/query_get_session.go index 133d9e476..166c77d37 100644 --- a/x/session/keeper/query_get_session.go +++ b/x/session/keeper/query_get_session.go @@ -38,7 +38,7 @@ func (k Keeper) GetSession(ctx context.Context, req *types.QueryGetSessionReques k.Logger().Info(fmt.Sprintf("Getting session for height: %d", blockHeight)) - sessionHydrator := NewSessionHydrator(req.ApplicationAddress, req.Service.Id, blockHeight) + sessionHydrator := NewSessionHydrator(req.ApplicationAddress, req.ServiceId, blockHeight) session, err := k.HydrateSession(ctx, sessionHydrator) if err != nil { return nil, err diff --git a/x/session/keeper/query_get_session_test.go b/x/session/keeper/query_get_session_test.go index 2c2477c79..b683aed19 100644 --- a/x/session/keeper/query_get_session_test.go +++ b/x/session/keeper/query_get_session_test.go @@ -10,7 +10,6 @@ import ( keepertest "github.com/pokt-network/poktroll/testutil/keeper" "github.com/pokt-network/poktroll/testutil/sample" "github.com/pokt-network/poktroll/x/session/types" - sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) func init() { @@ -54,10 +53,8 @@ func TestSession_GetSession_Success(t *testing.T) { t.Run(test.desc, func(t *testing.T) { req := &types.QueryGetSessionRequest{ ApplicationAddress: test.appAddr, - Service: &sharedtypes.Service{ - Id: test.serviceId, - }, - BlockHeight: 1, + ServiceId: test.serviceId, + BlockHeight: 1, } response, err := keeper.GetSession(ctx, req) @@ -146,10 +143,8 @@ func TestSession_GetSession_Failure(t *testing.T) { t.Run(test.desc, func(t *testing.T) { req := &types.QueryGetSessionRequest{ ApplicationAddress: test.appAddr, - Service: &sharedtypes.Service{ - Id: test.serviceId, - }, - BlockHeight: test.blockHeight, + ServiceId: test.serviceId, + BlockHeight: test.blockHeight, } res, err := keeper.GetSession(ctx, req) diff --git a/x/session/keeper/session_hydrator.go b/x/session/keeper/session_hydrator.go index 914eb8210..2d66b5844 100644 --- a/x/session/keeper/session_hydrator.go +++ b/x/session/keeper/session_hydrator.go @@ -49,7 +49,7 @@ func NewSessionHydrator( ) *sessionHydrator { sessionHeader := &types.SessionHeader{ ApplicationAddress: appAddress, - Service: &sharedtypes.Service{Id: serviceId}, + ServiceId: serviceId, } return &sessionHydrator{ sessionHeader: sessionHeader, @@ -121,14 +121,14 @@ func (k Keeper) hydrateSessionID(ctx context.Context, sh *sessionHydrator) error // TODO_MAINNET: In the future, we will need to validate that the Service is // a valid service depending on whether or not its permissioned or permissionless - if err := sh.sessionHeader.Service.ValidateBasic(); err != nil { - return types.ErrSessionHydration.Wrapf("%s", err) + if !sharedtypes.IsValidServiceId(sh.sessionHeader.ServiceId) { + return types.ErrSessionHydration.Wrapf("invalid service ID: %s", sh.sessionHeader.ServiceId) } sh.sessionHeader.SessionId, sh.sessionIDBz = k.GetSessionId( ctx, sh.sessionHeader.ApplicationAddress, - sh.sessionHeader.Service.Id, + sh.sessionHeader.ServiceId, prevHashBz, sh.blockHeight, ) @@ -158,7 +158,7 @@ func (k Keeper) hydrateSessionApplication(ctx context.Context, sh *sessionHydrat } for _, appServiceConfig := range foundApp.ServiceConfigs { - if appServiceConfig.Service.Id == sh.sessionHeader.Service.Id { + if appServiceConfig.ServiceId == sh.sessionHeader.ServiceId { sh.session.Application = &foundApp return nil } @@ -167,7 +167,7 @@ func (k Keeper) hydrateSessionApplication(ctx context.Context, sh *sessionHydrat return types.ErrSessionAppNotStakedForService.Wrapf( "application %q not staked for service ID %q", sh.sessionHeader.ApplicationAddress, - sh.sessionHeader.Service.Id, + sh.sessionHeader.ServiceId, ) } @@ -181,7 +181,7 @@ func (k Keeper) hydrateSessionSuppliers(ctx context.Context, sh *sessionHydrator candidateSuppliers := make([]*sharedtypes.Supplier, 0) for _, s := range suppliers { // Exclude suppliers that are inactive (i.e. currently unbonding). - if !s.IsActive(uint64(sh.sessionHeader.SessionEndBlockHeight), sh.sessionHeader.Service.Id) { + if !s.IsActive(uint64(sh.sessionHeader.SessionEndBlockHeight), sh.sessionHeader.ServiceId) { continue } @@ -191,7 +191,7 @@ func (k Keeper) hydrateSessionSuppliers(ctx context.Context, sh *sessionHydrator supplier := s // TODO_OPTIMIZE: If `supplier.Services` was a map[string]struct{}, we could eliminate `slices.Contains()`'s loop for _, supplierServiceConfig := range supplier.Services { - if supplierServiceConfig.Service.Id == sh.sessionHeader.Service.Id { + if supplierServiceConfig.ServiceId == sh.sessionHeader.ServiceId { candidateSuppliers = append(candidateSuppliers, &supplier) break } @@ -202,7 +202,7 @@ func (k Keeper) hydrateSessionSuppliers(ctx context.Context, sh *sessionHydrator logger.Error("[ERROR] no suppliers found for session") return types.ErrSessionSuppliersNotFound.Wrapf( "could not find suppliers for service %s at height %d", - sh.sessionHeader.Service, + sh.sessionHeader.ServiceId, sh.sessionHeader.SessionStartBlockHeight, ) } diff --git a/x/session/keeper/session_hydrator_test.go b/x/session/keeper/session_hydrator_test.go index f0b3cf0ad..6f0994da3 100644 --- a/x/session/keeper/session_hydrator_test.go +++ b/x/session/keeper/session_hydrator_test.go @@ -25,8 +25,7 @@ func TestSession_HydrateSession_Success_BaseCase(t *testing.T) { // Check the header sessionHeader := session.Header require.Equal(t, keepertest.TestApp1Address, sessionHeader.ApplicationAddress) - require.Equal(t, keepertest.TestServiceId1, sessionHeader.Service.Id) - require.Equal(t, "", sessionHeader.Service.Name) + require.Equal(t, keepertest.TestServiceId1, sessionHeader.ServiceId) require.Equal(t, int64(9), sessionHeader.SessionStartBlockHeight) require.Equal(t, int64(12), sessionHeader.SessionEndBlockHeight) require.Equal(t, "fea5d6f7544ff6d8af5c22529b2ccf01ed7930b3d454d42dda5ccc0b65b6ebfd", sessionHeader.SessionId) diff --git a/x/session/module/query_get_session_test.go b/x/session/module/query_get_session_test.go index 2ef9789fc..9c7e6594c 100644 --- a/x/session/module/query_get_session_test.go +++ b/x/session/module/query_get_session_test.go @@ -41,10 +41,10 @@ $ go test -v -count=1 -run TestCLI_GetSession ./x/session/module/...`) require.Len(t, appSvc0.ServiceConfigs, 2) require.Len(t, appSvc1.ServiceConfigs, 2) - require.Equal(t, appSvc0.ServiceConfigs[0].Service.Id, "svc0") // svc0 has a supplier - require.Equal(t, appSvc0.ServiceConfigs[1].Service.Id, "svc00") // svc00 doesn't have a supplier - require.Equal(t, appSvc1.ServiceConfigs[0].Service.Id, "svc1") // svc1 has a supplier - require.Equal(t, appSvc1.ServiceConfigs[1].Service.Id, "svc11") // svc11 doesn't have a supplier + require.Equal(t, appSvc0.ServiceConfigs[0].ServiceId, "svc0") // svc0 has a supplier + require.Equal(t, appSvc0.ServiceConfigs[1].ServiceId, "svc00") // svc00 doesn't have a supplier + require.Equal(t, appSvc1.ServiceConfigs[0].ServiceId, "svc1") // svc1 has a supplier + require.Equal(t, appSvc1.ServiceConfigs[1].ServiceId, "svc11") // svc11 doesn't have a supplier // Sanity check the supplier configs are what we expect them to be supplierSvc0 := suppliers[0] // supplier for svc0 @@ -53,8 +53,8 @@ $ go test -v -count=1 -run TestCLI_GetSession ./x/session/module/...`) require.Len(t, supplierSvc0.Services, 1) require.Len(t, supplierSvc1.Services, 1) - require.Equal(t, supplierSvc0.Services[0].Service.Id, "svc0") - require.Equal(t, supplierSvc1.Services[0].Service.Id, "svc1") + require.Equal(t, supplierSvc0.Services[0].ServiceId, "svc0") + require.Equal(t, supplierSvc1.Services[0].ServiceId, "svc1") // Prepare the test cases tests := []struct { @@ -202,7 +202,7 @@ $ go test -v -count=1 -run TestCLI_GetSession ./x/session/module/...`) // Verify some data about the session require.Equal(t, test.appAddress, session.Application.Address) - require.Equal(t, test.serviceId, session.Header.Service.Id) + require.Equal(t, test.serviceId, session.Header.ServiceId) require.Len(t, session.Suppliers, test.expectedNumSuppliers) }) } diff --git a/x/session/types/query.pb.go b/x/session/types/query.pb.go index 311892c40..ca446e8de 100644 --- a/x/session/types/query.pb.go +++ b/x/session/types/query.pb.go @@ -11,7 +11,7 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - types "github.com/pokt-network/poktroll/x/shared/types" + _ "github.com/pokt-network/poktroll/x/shared/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -108,9 +108,9 @@ func (m *QueryParamsResponse) GetParams() Params { } type QueryGetSessionRequest struct { - ApplicationAddress string `protobuf:"bytes,1,opt,name=application_address,json=applicationAddress,proto3" json:"application_address,omitempty"` - Service *types.Service `protobuf:"bytes,2,opt,name=service,proto3" json:"service,omitempty"` - BlockHeight int64 `protobuf:"varint,3,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + ApplicationAddress string `protobuf:"bytes,1,opt,name=application_address,json=applicationAddress,proto3" json:"application_address,omitempty"` + ServiceId string `protobuf:"bytes,2,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` + BlockHeight int64 `protobuf:"varint,3,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` } func (m *QueryGetSessionRequest) Reset() { *m = QueryGetSessionRequest{} } @@ -149,11 +149,11 @@ func (m *QueryGetSessionRequest) GetApplicationAddress() string { return "" } -func (m *QueryGetSessionRequest) GetService() *types.Service { +func (m *QueryGetSessionRequest) GetServiceId() string { if m != nil { - return m.Service + return m.ServiceId } - return nil + return "" } func (m *QueryGetSessionRequest) GetBlockHeight() int64 { @@ -213,38 +213,38 @@ func init() { func init() { proto.RegisterFile("poktroll/session/query.proto", fileDescriptor_d59d2e9c0a875c89) } var fileDescriptor_d59d2e9c0a875c89 = []byte{ - // 486 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x31, 0x6f, 0x13, 0x31, - 0x14, 0x8e, 0x53, 0x11, 0x54, 0x97, 0x01, 0xdc, 0x08, 0xae, 0x51, 0x39, 0xca, 0x89, 0x8a, 0x50, - 0x91, 0x33, 0x4a, 0x47, 0x26, 0xb2, 0x00, 0x4b, 0x05, 0x97, 0x8d, 0x25, 0x72, 0x2e, 0xd6, 0xc5, - 0xca, 0xe5, 0xde, 0xd5, 0x76, 0x80, 0xae, 0x88, 0x1f, 0x80, 0x84, 0xf8, 0x0b, 0x88, 0x91, 0x81, - 0x89, 0x5f, 0xd0, 0xb1, 0x82, 0xa5, 0x13, 0x42, 0x09, 0x12, 0x7f, 0x03, 0xc5, 0xf6, 0x09, 0x8a, - 0x89, 0xca, 0x12, 0x39, 0xef, 0xfb, 0xbe, 0xf7, 0xbe, 0xf7, 0xd9, 0x87, 0xb7, 0x4b, 0x98, 0x68, - 0x09, 0x79, 0x4e, 0x15, 0x57, 0x4a, 0x40, 0x41, 0x0f, 0x67, 0x5c, 0x1e, 0xc5, 0xa5, 0x04, 0x0d, - 0xe4, 0x72, 0x85, 0xc6, 0x0e, 0x6d, 0x5d, 0x61, 0x53, 0x51, 0x00, 0x35, 0xbf, 0x96, 0xd4, 0x6a, - 0x66, 0x90, 0x81, 0x39, 0xd2, 0xe5, 0xc9, 0x55, 0xb7, 0x33, 0x80, 0x2c, 0xe7, 0x94, 0x95, 0x82, - 0xb2, 0xa2, 0x00, 0xcd, 0xb4, 0x80, 0x42, 0x39, 0x74, 0x2b, 0x05, 0x35, 0x05, 0x35, 0xb0, 0x32, - 0xfb, 0xc7, 0x41, 0xd7, 0x3d, 0x47, 0x25, 0x93, 0x6c, 0x5a, 0xc1, 0xbe, 0x61, 0x7d, 0x54, 0xf2, - 0x7f, 0x88, 0xc7, 0x4c, 0xf2, 0x11, 0x55, 0x5c, 0x3e, 0x17, 0x29, 0xb7, 0x70, 0xd4, 0xc4, 0xe4, - 0xe9, 0x72, 0xbd, 0x27, 0xa6, 0x63, 0xc2, 0x0f, 0x67, 0x5c, 0xe9, 0x28, 0xc1, 0x9b, 0x67, 0xaa, - 0xaa, 0x84, 0x42, 0x71, 0x72, 0x1f, 0x37, 0xec, 0xe4, 0x00, 0xed, 0xa0, 0xf6, 0x46, 0x37, 0x88, - 0xff, 0x4e, 0x23, 0xb6, 0x8a, 0xde, 0xfa, 0xf1, 0xb7, 0x1b, 0xb5, 0x0f, 0x3f, 0x3f, 0xee, 0xa1, - 0xc4, 0x49, 0xa2, 0xcf, 0x08, 0x5f, 0x35, 0x4d, 0x1f, 0x72, 0xdd, 0xb7, 0x6c, 0x37, 0x8e, 0x3c, - 0xc6, 0x9b, 0xac, 0x2c, 0x73, 0x91, 0x9a, 0x44, 0x06, 0x6c, 0x34, 0x92, 0x5c, 0xd9, 0x21, 0xeb, - 0xbd, 0xe0, 0xcb, 0xa7, 0x4e, 0xd3, 0xe5, 0xf1, 0xc0, 0x22, 0x7d, 0x2d, 0x45, 0x91, 0x25, 0xe4, - 0x0f, 0x91, 0x43, 0x48, 0x17, 0x5f, 0x74, 0x0b, 0x06, 0x75, 0xcf, 0xa3, 0x09, 0x20, 0xee, 0x5b, - 0x3c, 0xa9, 0x88, 0xe4, 0x26, 0xbe, 0x34, 0xcc, 0x21, 0x9d, 0x0c, 0xc6, 0x5c, 0x64, 0x63, 0x1d, - 0xac, 0xed, 0xa0, 0xf6, 0x5a, 0xb2, 0x61, 0x6a, 0x8f, 0x4c, 0x29, 0x3a, 0xc0, 0xd7, 0x3c, 0xef, - 0x2e, 0x94, 0xfd, 0xe5, 0x44, 0x53, 0x72, 0xa9, 0x6c, 0xf9, 0xa9, 0x54, 0x9a, 0x8a, 0xd9, 0x7d, - 0x5f, 0xc7, 0x17, 0x4c, 0x43, 0xf2, 0x1a, 0xe1, 0x86, 0x0d, 0x8d, 0xdc, 0xf2, 0x85, 0xfe, 0xdd, - 0xb4, 0x76, 0xcf, 0x61, 0x59, 0x5b, 0x51, 0xe7, 0xd5, 0xd7, 0x1f, 0x6f, 0xeb, 0xb7, 0xc9, 0x2e, - 0x5d, 0xd2, 0x3b, 0x05, 0xd7, 0x2f, 0x40, 0x4e, 0xe8, 0x8a, 0xa7, 0x44, 0xde, 0x21, 0x8c, 0x7f, - 0x2f, 0x47, 0xda, 0x2b, 0x86, 0x78, 0x77, 0xd7, 0xba, 0xf3, 0x1f, 0x4c, 0x67, 0xa9, 0x6b, 0x2c, - 0xdd, 0x25, 0x7b, 0xe7, 0x58, 0xca, 0xb8, 0x1e, 0xb8, 0x73, 0xef, 0xe0, 0x78, 0x1e, 0xa2, 0x93, - 0x79, 0x88, 0x4e, 0xe7, 0x21, 0xfa, 0x3e, 0x0f, 0xd1, 0x9b, 0x45, 0x58, 0x3b, 0x59, 0x84, 0xb5, - 0xd3, 0x45, 0x58, 0x7b, 0x76, 0x2f, 0x13, 0x7a, 0x3c, 0x1b, 0xc6, 0x29, 0x4c, 0x57, 0xf4, 0x7c, - 0x79, 0xf6, 0xa3, 0x18, 0x36, 0xcc, 0xb3, 0xdf, 0xff, 0x15, 0x00, 0x00, 0xff, 0xff, 0xcc, 0xcf, - 0x33, 0x26, 0xe6, 0x03, 0x00, 0x00, + // 485 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0xae, 0x3b, 0x51, 0x54, 0x8f, 0x03, 0x78, 0x15, 0x64, 0xd5, 0x16, 0x46, 0xc4, 0x44, 0x99, + 0x68, 0x8c, 0xba, 0x23, 0x27, 0x7a, 0x81, 0x5d, 0x26, 0xc8, 0x6e, 0x5c, 0x22, 0x37, 0xb1, 0x52, + 0xab, 0x69, 0x5e, 0x66, 0xbb, 0xc0, 0xae, 0x88, 0x1f, 0x80, 0x84, 0xf8, 0x09, 0x20, 0x8e, 0x1c, + 0xf8, 0x11, 0x3b, 0x4e, 0x70, 0xd9, 0x09, 0xa1, 0x16, 0x89, 0xbf, 0x81, 0x6a, 0xbb, 0x82, 0x11, + 0xaa, 0x72, 0x89, 0x9c, 0xf7, 0x7d, 0xdf, 0x7b, 0xdf, 0xfb, 0x6c, 0xbc, 0x55, 0xc2, 0x48, 0x4b, + 0xc8, 0x73, 0xaa, 0xb8, 0x52, 0x02, 0x0a, 0x7a, 0x3c, 0xe1, 0xf2, 0x24, 0x2c, 0x25, 0x68, 0x20, + 0x57, 0x17, 0x68, 0xe8, 0xd0, 0xf6, 0x35, 0x36, 0x16, 0x05, 0x50, 0xf3, 0xb5, 0xa4, 0x76, 0x2b, + 0x83, 0x0c, 0xcc, 0x91, 0xce, 0x4f, 0xae, 0xba, 0x95, 0x01, 0x64, 0x39, 0xa7, 0xac, 0x14, 0x94, + 0x15, 0x05, 0x68, 0xa6, 0x05, 0x14, 0xca, 0xa1, 0x9b, 0x09, 0xa8, 0x31, 0xa8, 0xd8, 0xca, 0xec, + 0x8f, 0x83, 0xb6, 0x2b, 0x8e, 0x4a, 0x26, 0xd9, 0x78, 0x01, 0x57, 0x0d, 0xeb, 0x93, 0x92, 0xff, + 0x43, 0x3c, 0x64, 0x92, 0xa7, 0x54, 0x71, 0xf9, 0x5c, 0x24, 0xdc, 0xc2, 0x41, 0x0b, 0x93, 0xa7, + 0xf3, 0xf5, 0x9e, 0x98, 0x8e, 0x11, 0x3f, 0x9e, 0x70, 0xa5, 0x83, 0x08, 0x6f, 0x5c, 0xa8, 0xaa, + 0x12, 0x0a, 0xc5, 0xc9, 0x03, 0xdc, 0xb0, 0x93, 0x3d, 0xb4, 0x83, 0x3a, 0xeb, 0x3d, 0x2f, 0xfc, + 0x3b, 0x8d, 0xd0, 0x2a, 0xfa, 0xcd, 0xd3, 0x6f, 0x37, 0x6b, 0x1f, 0x7f, 0x7e, 0xda, 0x43, 0x91, + 0x93, 0x04, 0xef, 0x11, 0xbe, 0x6e, 0x9a, 0x3e, 0xe2, 0xfa, 0xc8, 0xb2, 0xdd, 0x38, 0x72, 0x80, + 0x37, 0x58, 0x59, 0xe6, 0x22, 0x31, 0x89, 0xc4, 0x2c, 0x4d, 0x25, 0x57, 0x76, 0x48, 0xb3, 0xef, + 0x7d, 0xf9, 0xdc, 0x6d, 0xb9, 0x3c, 0x1e, 0x5a, 0xe4, 0x48, 0x4b, 0x51, 0x64, 0x11, 0xf9, 0x43, + 0xe4, 0x10, 0xb2, 0x8d, 0xb1, 0x5b, 0x30, 0x16, 0xa9, 0x57, 0x9f, 0x77, 0x88, 0x9a, 0xae, 0x72, + 0x90, 0x92, 0x5b, 0xf8, 0xca, 0x20, 0x87, 0x64, 0x14, 0x0f, 0xb9, 0xc8, 0x86, 0xda, 0x5b, 0xdb, + 0x41, 0x9d, 0xb5, 0x68, 0xdd, 0xd4, 0x1e, 0x9b, 0x52, 0x70, 0x88, 0x6f, 0x54, 0x6c, 0xba, 0xfd, + 0xf7, 0xf1, 0x65, 0xb7, 0xa7, 0x0b, 0x60, 0xb3, 0x1a, 0xc0, 0x42, 0xb3, 0x60, 0xf6, 0x3e, 0xd4, + 0xf1, 0x25, 0xd3, 0x90, 0xbc, 0x46, 0xb8, 0x61, 0xf3, 0x21, 0xb7, 0xab, 0xc2, 0xea, 0x35, 0xb4, + 0x77, 0x57, 0xb0, 0xac, 0xad, 0xa0, 0xfb, 0xea, 0xeb, 0x8f, 0xb7, 0xf5, 0x3b, 0x64, 0x97, 0xce, + 0xe9, 0xdd, 0x82, 0xeb, 0x17, 0x20, 0x47, 0x74, 0xc9, 0xab, 0x21, 0xef, 0x10, 0xc6, 0xbf, 0x97, + 0x23, 0x9d, 0x25, 0x43, 0x2a, 0xd7, 0xd4, 0xbe, 0xfb, 0x1f, 0x4c, 0x67, 0xa9, 0x67, 0x2c, 0xdd, + 0x23, 0x7b, 0x2b, 0x2c, 0x65, 0x5c, 0xc7, 0xee, 0xdc, 0x3f, 0x3c, 0x9d, 0xfa, 0xe8, 0x6c, 0xea, + 0xa3, 0xf3, 0xa9, 0x8f, 0xbe, 0x4f, 0x7d, 0xf4, 0x66, 0xe6, 0xd7, 0xce, 0x66, 0x7e, 0xed, 0x7c, + 0xe6, 0xd7, 0x9e, 0xdd, 0xcf, 0x84, 0x1e, 0x4e, 0x06, 0x61, 0x02, 0xe3, 0x25, 0x3d, 0x5f, 0x5e, + 0x7c, 0xff, 0x83, 0x86, 0x79, 0xe1, 0xfb, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x71, 0x8a, 0x02, + 0x58, 0xd1, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -448,15 +448,10 @@ func (m *QueryGetSessionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) i-- dAtA[i] = 0x18 } - if m.Service != nil { - { - size, err := m.Service.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } + if len(m.ServiceId) > 0 { + i -= len(m.ServiceId) + copy(dAtA[i:], m.ServiceId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ServiceId))) i-- dAtA[i] = 0x12 } @@ -546,8 +541,8 @@ func (m *QueryGetSessionRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.Service != nil { - l = m.Service.Size() + l = len(m.ServiceId) + if l > 0 { n += 1 + l + sovQuery(uint64(l)) } if m.BlockHeight != 0 { @@ -771,9 +766,9 @@ func (m *QueryGetSessionRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Service", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ServiceId", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -783,27 +778,23 @@ func (m *QueryGetSessionRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Service == nil { - m.Service = &types.Service{} - } - if err := m.Service.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.ServiceId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 0 { diff --git a/x/session/types/query_get_session_request.go b/x/session/types/query_get_session_request.go index da610ddfe..1b593880c 100644 --- a/x/session/types/query_get_session_request.go +++ b/x/session/types/query_get_session_request.go @@ -12,10 +12,8 @@ import ( func NewQueryGetSessionRequest(appAddress, serviceId string, blockHeight int64) *QueryGetSessionRequest { return &QueryGetSessionRequest{ ApplicationAddress: appAddress, - Service: &sharedtypes.Service{ - Id: serviceId, - }, - BlockHeight: blockHeight, + ServiceId: serviceId, + BlockHeight: blockHeight, } } @@ -26,8 +24,8 @@ func (query *QueryGetSessionRequest) ValidateBasic() error { } // Validate the Service ID - if err := query.Service.ValidateBasic(); err != nil { - return ErrSessionInvalidService.Wrapf("invalid service for session being retrieved %s; %s", query.Service, err) + if !sharedtypes.IsValidServiceId(query.GetServiceId()) { + return ErrSessionInvalidService.Wrapf("invalid service ID: %q", query.GetServiceId()) } // Validate the height for which a session is being retrieved diff --git a/x/session/types/session_header.go b/x/session/types/session_header.go index e0f842492..4ef71e63f 100644 --- a/x/session/types/session_header.go +++ b/x/session/types/session_header.go @@ -2,6 +2,8 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" + + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) // ValidateBasic performs basic stateless validation of a SessionHeader. @@ -16,13 +18,8 @@ func (sh *SessionHeader) ValidateBasic() error { return ErrSessionInvalidSessionId.Wrapf("%q", sh.SessionId) } - // Validate the service - if sh.Service == nil { - return ErrSessionInvalidService.Wrapf("missing service") - } - - if err := sh.Service.ValidateBasic(); err != nil { - return ErrSessionInvalidService.Wrapf("%s", err) + if !sharedtypes.IsValidServiceId(sh.GetServiceId()) { + return ErrSessionInvalidService.Wrapf("invalid service ID: %q", sh.GetServiceId()) } // Sessions can only start at height 1 diff --git a/x/session/types/session_header_test.go b/x/session/types/session_header_test.go index 02b99f882..ff64a0972 100644 --- a/x/session/types/session_header_test.go +++ b/x/session/types/session_header_test.go @@ -7,15 +7,11 @@ import ( "github.com/pokt-network/poktroll/testutil/sample" "github.com/pokt-network/poktroll/x/session/types" - sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) -func TestSessionHeader_ValidateBasic(t *testing.T) { - svc := sharedtypes.Service{ - Id: "svc_id", - Name: "svc_name", - } +const testServiceId = "svc_id" +func TestSessionHeader_ValidateBasic(t *testing.T) { tests := []struct { desc string sessionHeader types.SessionHeader @@ -26,7 +22,7 @@ func TestSessionHeader_ValidateBasic(t *testing.T) { sessionHeader: types.SessionHeader{ ApplicationAddress: "invalid_address", SessionId: "valid_session_id", - Service: &svc, + ServiceId: testServiceId, SessionStartBlockHeight: 100, SessionEndBlockHeight: 101, }, @@ -37,18 +33,18 @@ func TestSessionHeader_ValidateBasic(t *testing.T) { sessionHeader: types.SessionHeader{ ApplicationAddress: sample.AccAddress(), SessionId: "", - Service: &svc, + ServiceId: testServiceId, SessionStartBlockHeight: 100, SessionEndBlockHeight: 101, }, expectedErr: types.ErrSessionInvalidSessionId, }, { - desc: "invalid - nil service", + desc: "invalid - empty service id", sessionHeader: types.SessionHeader{ ApplicationAddress: sample.AccAddress(), SessionId: "valid_session_id", - Service: nil, + ServiceId: "", SessionStartBlockHeight: 100, SessionEndBlockHeight: 101, }, @@ -59,7 +55,7 @@ func TestSessionHeader_ValidateBasic(t *testing.T) { sessionHeader: types.SessionHeader{ ApplicationAddress: sample.AccAddress(), SessionId: "valid_session_id", - Service: &svc, + ServiceId: testServiceId, SessionStartBlockHeight: 0, SessionEndBlockHeight: 42, }, @@ -70,7 +66,7 @@ func TestSessionHeader_ValidateBasic(t *testing.T) { sessionHeader: types.SessionHeader{ ApplicationAddress: sample.AccAddress(), SessionId: "valid_session_id", - Service: &svc, + ServiceId: testServiceId, SessionStartBlockHeight: 100, SessionEndBlockHeight: 99, }, @@ -81,7 +77,7 @@ func TestSessionHeader_ValidateBasic(t *testing.T) { sessionHeader: types.SessionHeader{ ApplicationAddress: sample.AccAddress(), SessionId: "valid_session_id", - Service: &svc, + ServiceId: testServiceId, SessionStartBlockHeight: 100, SessionEndBlockHeight: 101, }, diff --git a/x/session/types/types.pb.go b/x/session/types/types.pb.go index 15401690c..2d12d8f47 100644 --- a/x/session/types/types.pb.go +++ b/x/session/types/types.pb.go @@ -8,8 +8,8 @@ import ( _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - types1 "github.com/pokt-network/poktroll/x/application/types" - types "github.com/pokt-network/poktroll/x/shared/types" + types "github.com/pokt-network/poktroll/x/application/types" + types1 "github.com/pokt-network/poktroll/x/shared/types" io "io" math "math" math_bits "math/bits" @@ -29,8 +29,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // SessionHeader is a lightweight header for a session that can be passed around. // It is the minimal amount of data required to hydrate & retrieve all data relevant to the session. type SessionHeader struct { - ApplicationAddress string `protobuf:"bytes,1,opt,name=application_address,json=applicationAddress,proto3" json:"application_address,omitempty"` - Service *types.Service `protobuf:"bytes,2,opt,name=service,proto3" json:"service,omitempty"` + ApplicationAddress string `protobuf:"bytes,1,opt,name=application_address,json=applicationAddress,proto3" json:"application_address,omitempty"` + ServiceId string `protobuf:"bytes,2,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` // NOTE: session_id can be derived from the above values using on-chain but is included in the header for convenience SessionId string `protobuf:"bytes,3,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` SessionStartBlockHeight int64 `protobuf:"varint,4,opt,name=session_start_block_height,json=sessionStartBlockHeight,proto3" json:"session_start_block_height,omitempty"` @@ -77,11 +77,11 @@ func (m *SessionHeader) GetApplicationAddress() string { return "" } -func (m *SessionHeader) GetService() *types.Service { +func (m *SessionHeader) GetServiceId() string { if m != nil { - return m.Service + return m.ServiceId } - return nil + return "" } func (m *SessionHeader) GetSessionId() string { @@ -108,12 +108,12 @@ func (m *SessionHeader) GetSessionEndBlockHeight() int64 { // Session is a fully hydrated session object that contains all the information for the Session // and its parcipants. type Session struct { - Header *SessionHeader `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` - SessionId string `protobuf:"bytes,2,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` - SessionNumber int64 `protobuf:"varint,3,opt,name=session_number,json=sessionNumber,proto3" json:"session_number,omitempty"` - NumBlocksPerSession int64 `protobuf:"varint,4,opt,name=num_blocks_per_session,json=numBlocksPerSession,proto3" json:"num_blocks_per_session,omitempty"` - Application *types1.Application `protobuf:"bytes,5,opt,name=application,proto3" json:"application,omitempty"` - Suppliers []*types.Supplier `protobuf:"bytes,6,rep,name=suppliers,proto3" json:"suppliers,omitempty"` + Header *SessionHeader `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` + SessionId string `protobuf:"bytes,2,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` + SessionNumber int64 `protobuf:"varint,3,opt,name=session_number,json=sessionNumber,proto3" json:"session_number,omitempty"` + NumBlocksPerSession int64 `protobuf:"varint,4,opt,name=num_blocks_per_session,json=numBlocksPerSession,proto3" json:"num_blocks_per_session,omitempty"` + Application *types.Application `protobuf:"bytes,5,opt,name=application,proto3" json:"application,omitempty"` + Suppliers []*types1.Supplier `protobuf:"bytes,6,rep,name=suppliers,proto3" json:"suppliers,omitempty"` } func (m *Session) Reset() { *m = Session{} } @@ -173,14 +173,14 @@ func (m *Session) GetNumBlocksPerSession() int64 { return 0 } -func (m *Session) GetApplication() *types1.Application { +func (m *Session) GetApplication() *types.Application { if m != nil { return m.Application } return nil } -func (m *Session) GetSuppliers() []*types.Supplier { +func (m *Session) GetSuppliers() []*types1.Supplier { if m != nil { return m.Suppliers } @@ -195,37 +195,37 @@ func init() { func init() { proto.RegisterFile("poktroll/session/types.proto", fileDescriptor_4b2d9db41a667008) } var fileDescriptor_4b2d9db41a667008 = []byte{ - // 479 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x93, 0xcf, 0x6e, 0x9b, 0x40, - 0x10, 0xc6, 0x8d, 0xdd, 0x3a, 0xf2, 0xa2, 0x54, 0xd5, 0x26, 0x6d, 0x89, 0xd5, 0x50, 0x1a, 0xa9, - 0x92, 0x2f, 0x81, 0x8a, 0x1c, 0x7c, 0xe8, 0x29, 0xae, 0x2a, 0x25, 0x97, 0xa8, 0xc2, 0xb7, 0x5e, - 0x10, 0x86, 0x15, 0x20, 0x9b, 0x5d, 0xb4, 0xbb, 0xf4, 0xcf, 0x5b, 0xf4, 0x1d, 0xfa, 0x0a, 0xbd, - 0xf5, 0x05, 0x7a, 0x8c, 0x7a, 0xca, 0xb1, 0xb2, 0x5f, 0x24, 0x62, 0x77, 0x08, 0x98, 0xdc, 0x96, - 0xf9, 0x7d, 0xb3, 0xf3, 0xcd, 0xec, 0x80, 0x5e, 0x97, 0x6c, 0x2d, 0x39, 0xdb, 0x6c, 0x3c, 0x41, - 0x84, 0xc8, 0x19, 0xf5, 0xe4, 0x8f, 0x92, 0x08, 0xb7, 0xe4, 0x4c, 0x32, 0xfc, 0xbc, 0xa1, 0x2e, - 0xd0, 0xe9, 0x49, 0xcc, 0x44, 0xc1, 0x44, 0xa8, 0xb8, 0xa7, 0x3f, 0xb4, 0x78, 0x7a, 0xda, 0x5e, - 0x95, 0x45, 0x9c, 0x24, 0x9e, 0x20, 0xfc, 0x6b, 0x1e, 0x13, 0xc0, 0xce, 0x03, 0x8e, 0xca, 0x72, - 0x93, 0xc7, 0x91, 0xec, 0x55, 0x9b, 0xda, 0x8f, 0x2e, 0xa8, 0x6a, 0x25, 0xe1, 0xc0, 0x8f, 0x53, - 0x96, 0x32, 0x5d, 0xb8, 0x3e, 0xe9, 0xe8, 0xd9, 0xaf, 0x21, 0x3a, 0x5c, 0x6a, 0x77, 0x57, 0x24, - 0x4a, 0x08, 0xc7, 0xd7, 0xe8, 0xa8, 0x53, 0x22, 0x8c, 0x92, 0x84, 0x13, 0x21, 0x2c, 0xc3, 0x31, - 0x66, 0x93, 0x85, 0xf5, 0xef, 0xf7, 0xf9, 0x31, 0xf8, 0xbe, 0xd4, 0x64, 0x29, 0x79, 0x4e, 0xd3, - 0x00, 0x77, 0x92, 0x80, 0x60, 0x1f, 0x1d, 0x40, 0x17, 0xd6, 0xd0, 0x31, 0x66, 0xa6, 0x6f, 0xb9, - 0xed, 0x48, 0x94, 0x49, 0x77, 0xa9, 0x79, 0xd0, 0x08, 0xf1, 0x29, 0x42, 0x30, 0xad, 0x30, 0x4f, - 0xac, 0x51, 0x5d, 0x35, 0x98, 0x40, 0xe4, 0x3a, 0xc1, 0x1f, 0xd0, 0xb4, 0xc1, 0x42, 0x46, 0x5c, - 0x86, 0xab, 0x0d, 0x8b, 0xd7, 0x61, 0x46, 0xf2, 0x34, 0x93, 0xd6, 0x13, 0xc7, 0x98, 0x8d, 0x82, - 0x57, 0xa0, 0x58, 0xd6, 0x82, 0x45, 0xcd, 0xaf, 0x14, 0xc6, 0x73, 0x64, 0x35, 0xc9, 0x84, 0x26, - 0xfb, 0xa9, 0x4f, 0x55, 0xea, 0x0b, 0xe0, 0x9f, 0x68, 0xd2, 0x49, 0x3c, 0xfb, 0x33, 0x44, 0x07, - 0x30, 0x25, 0x3c, 0x47, 0xe3, 0x4c, 0x4d, 0x4a, 0x8d, 0xc4, 0xf4, 0xdf, 0xb8, 0xfd, 0x67, 0x76, - 0xf7, 0x06, 0x1a, 0x80, 0xbc, 0xd7, 0xd9, 0xb0, 0xdf, 0xd9, 0x3b, 0xf4, 0xac, 0xc1, 0xb4, 0x2a, - 0x56, 0x84, 0xab, 0xe6, 0x47, 0xc1, 0x21, 0x44, 0x6f, 0x54, 0x10, 0x5f, 0xa0, 0x97, 0xb4, 0x2a, - 0xb4, 0x77, 0x11, 0x96, 0x84, 0x87, 0xc0, 0xa1, 0xf9, 0x23, 0x5a, 0x15, 0xca, 0xba, 0xf8, 0x4c, - 0x78, 0xe3, 0xf9, 0x23, 0x32, 0x3b, 0xcf, 0xa3, 0x7a, 0x35, 0xfd, 0xb7, 0xad, 0xf1, 0x0e, 0x74, - 0x2f, 0xdb, 0x73, 0xd0, 0xcd, 0xc2, 0x73, 0x34, 0x69, 0x56, 0x4a, 0x58, 0x63, 0x67, 0x34, 0x33, - 0xfd, 0x93, 0xc7, 0xef, 0x09, 0x8a, 0xa0, 0xd5, 0x2e, 0x6e, 0xfe, 0x6e, 0x6d, 0xe3, 0x76, 0x6b, - 0x1b, 0x77, 0x5b, 0xdb, 0xf8, 0xbf, 0xb5, 0x8d, 0x9f, 0x3b, 0x7b, 0x70, 0xbb, 0xb3, 0x07, 0x77, - 0x3b, 0x7b, 0xf0, 0xe5, 0x7d, 0x9a, 0xcb, 0xac, 0x5a, 0xb9, 0x31, 0x2b, 0xbc, 0xfa, 0xb6, 0x73, - 0x4a, 0xe4, 0x37, 0xc6, 0xd7, 0xde, 0xc3, 0x3e, 0x7f, 0xdf, 0xff, 0xbb, 0x56, 0x63, 0xb5, 0xba, - 0x17, 0xf7, 0x01, 0x00, 0x00, 0xff, 0xff, 0x20, 0x41, 0xa2, 0x7f, 0x7e, 0x03, 0x00, 0x00, + // 468 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x93, 0x4d, 0x6f, 0xd3, 0x30, + 0x18, 0xc7, 0x9b, 0x16, 0x8a, 0xea, 0x6a, 0x08, 0x79, 0x03, 0xb2, 0x8a, 0x99, 0x32, 0x09, 0xa9, + 0x97, 0x25, 0xa8, 0x3b, 0xf4, 0xc0, 0x69, 0x45, 0x48, 0xeb, 0x65, 0x42, 0xe9, 0x8d, 0x4b, 0x94, + 0xc4, 0x56, 0x12, 0x35, 0xb1, 0x23, 0xdb, 0xe1, 0xe5, 0x4b, 0x20, 0x3e, 0x0c, 0x37, 0xbe, 0x00, + 0xc7, 0x89, 0xd3, 0x8e, 0x28, 0xfd, 0x22, 0x28, 0xb6, 0xb3, 0xa4, 0xd9, 0xcd, 0x79, 0x7e, 0xff, + 0xe7, 0xe5, 0x6f, 0x3f, 0x01, 0xaf, 0x0a, 0xb6, 0x93, 0x9c, 0x65, 0x99, 0x2b, 0x88, 0x10, 0x29, + 0xa3, 0xae, 0xfc, 0x5e, 0x10, 0xe1, 0x14, 0x9c, 0x49, 0x06, 0x9f, 0x35, 0xd4, 0x31, 0x74, 0x76, + 0x1a, 0x31, 0x91, 0x33, 0xe1, 0x2b, 0xee, 0xea, 0x0f, 0x2d, 0x9e, 0x9d, 0xb5, 0xa5, 0x92, 0x80, + 0x13, 0xec, 0x0a, 0xc2, 0xbf, 0xa4, 0x11, 0x31, 0x78, 0x7e, 0x8f, 0x83, 0xa2, 0xc8, 0xd2, 0x28, + 0x90, 0xbd, 0x6e, 0x33, 0xf4, 0xa0, 0x40, 0x59, 0x2b, 0x09, 0x37, 0xfc, 0x24, 0x66, 0x31, 0xd3, + 0x8d, 0xeb, 0x93, 0x8e, 0x9e, 0xff, 0x18, 0x82, 0xa3, 0xad, 0x9e, 0xee, 0x9a, 0x04, 0x98, 0x70, + 0xb8, 0x01, 0xc7, 0x9d, 0x16, 0x7e, 0x80, 0x31, 0x27, 0x42, 0xd8, 0xd6, 0xdc, 0x5a, 0x4c, 0xd6, + 0xf6, 0xdf, 0x5f, 0x17, 0x27, 0x66, 0xee, 0x2b, 0x4d, 0xb6, 0x92, 0xa7, 0x34, 0xf6, 0x60, 0x27, + 0xc9, 0x10, 0x78, 0x06, 0x80, 0x71, 0xe1, 0xa7, 0xd8, 0x1e, 0xd6, 0x15, 0xbc, 0x89, 0x89, 0x6c, + 0xb0, 0xc6, 0xaa, 0x75, 0x8d, 0x47, 0x0d, 0x56, 0x91, 0x0d, 0x86, 0xef, 0xc1, 0xac, 0xc1, 0x42, + 0x06, 0x5c, 0xfa, 0x61, 0xc6, 0xa2, 0x9d, 0x9f, 0x90, 0x34, 0x4e, 0xa4, 0xfd, 0x68, 0x6e, 0x2d, + 0x46, 0xde, 0x4b, 0xa3, 0xd8, 0xd6, 0x82, 0x75, 0xcd, 0xaf, 0x15, 0x86, 0x2b, 0x60, 0x37, 0xc9, + 0x84, 0xe2, 0xc3, 0xd4, 0xc7, 0x2a, 0xf5, 0xb9, 0xe1, 0x1f, 0x29, 0xee, 0x24, 0x9e, 0xff, 0x1e, + 0x82, 0x27, 0xe6, 0x42, 0xe0, 0x0a, 0x8c, 0x13, 0x75, 0x29, 0xca, 0xfd, 0x74, 0xf9, 0xda, 0xe9, + 0xbf, 0xa8, 0x73, 0x70, 0x77, 0x9e, 0x91, 0xf7, 0x9c, 0x0d, 0xfb, 0xce, 0xde, 0x82, 0xa7, 0x0d, + 0xa6, 0x65, 0x1e, 0x12, 0xae, 0xcc, 0x8f, 0xbc, 0x23, 0x13, 0xbd, 0x51, 0x41, 0x78, 0x09, 0x5e, + 0xd0, 0x32, 0xd7, 0xb3, 0x0b, 0xbf, 0x20, 0xdc, 0x37, 0xdc, 0x98, 0x3f, 0xa6, 0x65, 0xae, 0x46, + 0x17, 0x9f, 0x08, 0x6f, 0x66, 0xfe, 0x00, 0xa6, 0x9d, 0x97, 0x50, 0x5e, 0xa7, 0xcb, 0x37, 0xed, + 0xe0, 0x1d, 0xe8, 0x5c, 0xb5, 0x67, 0xaf, 0x9b, 0x05, 0x57, 0x60, 0xd2, 0x6c, 0x8f, 0xb0, 0xc7, + 0xf3, 0xd1, 0x62, 0xba, 0x3c, 0xed, 0x78, 0x57, 0xfb, 0xe5, 0x6c, 0x8d, 0xc2, 0x6b, 0xb5, 0xeb, + 0x9b, 0x3f, 0x15, 0xb2, 0x6e, 0x2b, 0x64, 0xdd, 0x55, 0xc8, 0xfa, 0x57, 0x21, 0xeb, 0xe7, 0x1e, + 0x0d, 0x6e, 0xf7, 0x68, 0x70, 0xb7, 0x47, 0x83, 0xcf, 0xef, 0xe2, 0x54, 0x26, 0x65, 0xe8, 0x44, + 0x2c, 0x77, 0xeb, 0x6a, 0x17, 0x94, 0xc8, 0xaf, 0x8c, 0xef, 0xdc, 0xfb, 0xd5, 0xfd, 0x76, 0xf8, + 0x23, 0x85, 0x63, 0xb5, 0xa5, 0x97, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0xd5, 0x3f, 0x27, 0x80, + 0x69, 0x03, 0x00, 0x00, } func (m *SessionHeader) Marshal() (dAtA []byte, err error) { @@ -265,15 +265,10 @@ func (m *SessionHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if m.Service != nil { - { - size, err := m.Service.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } + if len(m.ServiceId) > 0 { + i -= len(m.ServiceId) + copy(dAtA[i:], m.ServiceId) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ServiceId))) i-- dAtA[i] = 0x12 } @@ -386,8 +381,8 @@ func (m *SessionHeader) Size() (n int) { if l > 0 { n += 1 + l + sovTypes(uint64(l)) } - if m.Service != nil { - l = m.Service.Size() + l = len(m.ServiceId) + if l > 0 { n += 1 + l + sovTypes(uint64(l)) } l = len(m.SessionId) @@ -505,9 +500,9 @@ func (m *SessionHeader) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Service", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ServiceId", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -517,27 +512,23 @@ func (m *SessionHeader) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Service == nil { - m.Service = &types.Service{} - } - if err := m.Service.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.ServiceId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { @@ -795,7 +786,7 @@ func (m *Session) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Application == nil { - m.Application = &types1.Application{} + m.Application = &types.Application{} } if err := m.Application.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -830,7 +821,7 @@ func (m *Session) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Suppliers = append(m.Suppliers, &types.Supplier{}) + m.Suppliers = append(m.Suppliers, &types1.Supplier{}) if err := m.Suppliers[len(m.Suppliers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/shared/helpers/service_configs.go b/x/shared/helpers/service_configs.go index 6d8dfe9bf..6e7a7a4b1 100644 --- a/x/shared/helpers/service_configs.go +++ b/x/shared/helpers/service_configs.go @@ -21,9 +21,9 @@ func ValidateAppServiceConfigs(services []*sharedtypes.ApplicationServiceConfig) if serviceConfig == nil { return fmt.Errorf("serviceConfig cannot be nil: %v", services) } - // Check the Service - if err := serviceConfig.Service.ValidateBasic(); err != nil { - return sharedtypes.ErrSharedInvalidService.Wrapf("%s", err) + // Check the Service ID + if !sharedtypes.IsValidServiceId(serviceConfig.GetServiceId()) { + return sharedtypes.ErrSharedInvalidService.Wrapf("invalid service ID: %q", serviceConfig.GetServiceId()) } } return nil @@ -39,9 +39,9 @@ func ValidateSupplierServiceConfigs(services []*sharedtypes.SupplierServiceConfi return fmt.Errorf("serviceConfig cannot be nil: %v", services) } - // Check the Service - if err := serviceConfig.Service.ValidateBasic(); err != nil { - return sharedtypes.ErrSharedInvalidService.Wrapf("%s", err) + // Check the Service ID + if !sharedtypes.IsValidServiceId(serviceConfig.GetServiceId()) { + return sharedtypes.ErrSharedInvalidService.Wrapf("invalid service ID: %s", serviceConfig.GetServiceId()) } // Check the Endpoints diff --git a/x/shared/helpers/service_test.go b/x/shared/helpers/service_test.go index b7f70c384..cdc742fe3 100644 --- a/x/shared/helpers/service_test.go +++ b/x/shared/helpers/service_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/require" + "github.com/pokt-network/poktroll/testutil/sample" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -70,8 +71,10 @@ func TestIsValidService(t *testing.T) { for _, test := range tests { t.Run(test.desc, func(t *testing.T) { service := &sharedtypes.Service{ - Id: test.serviceId, - Name: test.serviceName, + Id: test.serviceId, + Name: test.serviceName, + ComputeUnitsPerRelay: 1, + OwnerAddress: sample.AccAddress(), } err := service.ValidateBasic() if test.expectedIsValid { @@ -128,7 +131,12 @@ func TestIsValidServiceName(t *testing.T) { for _, test := range tests { t.Run(test.desc, func(t *testing.T) { - service := &sharedtypes.Service{Id: "svc", Name: test.serviceName} + service := &sharedtypes.Service{ + Id: "svc", + Name: test.serviceName, + ComputeUnitsPerRelay: 1, + OwnerAddress: sample.AccAddress(), + } err := service.ValidateBasic() if test.expectedIsValid { require.NoError(t, err) @@ -204,7 +212,11 @@ func TestIsValidServiceId(t *testing.T) { for _, test := range tests { t.Run(test.desc, func(t *testing.T) { - service := &sharedtypes.Service{Id: test.serviceId} + service := &sharedtypes.Service{ + Id: test.serviceId, + ComputeUnitsPerRelay: 1, + OwnerAddress: sample.AccAddress(), + } err := service.ValidateBasic() if test.expectedIsValid { require.NoError(t, err) diff --git a/x/shared/types/errors.go b/x/shared/types/errors.go index 0ef96d4f5..576ccd7dd 100644 --- a/x/shared/types/errors.go +++ b/x/shared/types/errors.go @@ -8,12 +8,13 @@ import ( // x/shared module sentinel errors var ( - ErrSharedInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") - ErrSharedInvalidAddress = sdkerrors.Register(ModuleName, 1101, "invalid address") - ErrSharedParamNameInvalid = sdkerrors.Register(ModuleName, 1102, "the provided param name is invalid") - ErrSharedParamInvalid = sdkerrors.Register(ModuleName, 1103, "the provided param is invalid") - ErrSharedEmitEvent = sdkerrors.Register(ModuleName, 1104, "failed to emit event") - ErrSharedUnauthorizedSupplierUpdate = sdkerrors.Register(ModuleName, 1105, "unauthorized supplier update") - ErrSharedInvalidRevShare = sdkerrors.Register(ModuleName, 1106, "invalid revenue share configuration") - ErrSharedInvalidService = sdkerrors.Register(ModuleName, 1107, "invalid service") + ErrSharedInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") + ErrSharedInvalidAddress = sdkerrors.Register(ModuleName, 1101, "invalid address") + ErrSharedParamNameInvalid = sdkerrors.Register(ModuleName, 1102, "the provided param name is invalid") + ErrSharedParamInvalid = sdkerrors.Register(ModuleName, 1103, "the provided param is invalid") + ErrSharedEmitEvent = sdkerrors.Register(ModuleName, 1104, "failed to emit event") + ErrSharedUnauthorizedSupplierUpdate = sdkerrors.Register(ModuleName, 1105, "unauthorized supplier update") + ErrSharedInvalidRevShare = sdkerrors.Register(ModuleName, 1106, "invalid revenue share configuration") + ErrSharedInvalidService = sdkerrors.Register(ModuleName, 1107, "invalid service") + ErrSharedInvalidComputeUnitsPerRelay = sdkerrors.Register(ModuleName, 1108, "invalid compute units per relay") ) diff --git a/x/shared/types/service.go b/x/shared/types/service.go index 46e1081e0..2c3ee27cf 100644 --- a/x/shared/types/service.go +++ b/x/shared/types/service.go @@ -3,9 +3,16 @@ package types import ( "net/url" "regexp" + + sdk "github.com/cosmos/cosmos-sdk/types" ) const ( + // ComputeUnitsPerRelayMax is the maximum allowed compute_units_per_relay value when adding or updating a service. + // TODO_MAINNET: The reason we have a maximum is to account for potential integer overflows. + // Should we revisit all uint64 and convert them to BigInts? + ComputeUnitsPerRelayMax uint64 = 2 ^ 16 // 65536 + maxServiceIdLength = 16 // Limiting all serviceIds to 16 characters maxServiceIdName = 42 // Limit the name of the service name to 42 characters @@ -27,23 +34,20 @@ func init() { // ValidateBasic performs basic stateless validation of a Service. func (s *Service) ValidateBasic() error { if !IsValidServiceId(s.Id) { - return ErrSharedInvalidService.Wrapf("ID: %q", s.Id) + return ErrSharedInvalidService.Wrapf("invalid service ID: %q", s.Id) } if !IsValidServiceName(s.Name) { - return ErrSharedInvalidService.Wrapf("name: %q", s.Name) + return ErrSharedInvalidService.Wrapf("invalid service name: %q", s.Name) } - // TODO_FOLLOWUP: Enabling these checks will break code where Service is created - // without OwnerAddress or ComputeUnitsPerRelay. - // Remove the comments in a follow-up PR where embedded Service is replaced by ServiceId. - //if _, err := sdk.AccAddressFromBech32(s.OwnerAddress); err != nil { - // return ErrSharedInvalidService.Wrapf("invalid owner address: %s", s.OwnerAddress) - //} + if _, err := sdk.AccAddressFromBech32(s.OwnerAddress); err != nil { + return ErrSharedInvalidService.Wrapf("invalid owner address: %s", s.OwnerAddress) + } - //if err := ValidateComputeUnitsPerRelay(s.ComputeUnitsPerRelay); err != nil { - // return ErrSharedInvalidService.Wrapf("%s", err) - //} + if err := ValidateComputeUnitsPerRelay(s.ComputeUnitsPerRelay); err != nil { + return ErrSharedInvalidService.Wrapf("%s", err) + } return nil } @@ -97,3 +101,13 @@ func IsValidEndpointUrl(endpoint string) bool { return true } + +// ValidateComputeUnitsPerRelay makes sure the compute units per relay is a valid value +func ValidateComputeUnitsPerRelay(computeUnitsPerRelay uint64) error { + if computeUnitsPerRelay == 0 { + return ErrSharedInvalidComputeUnitsPerRelay.Wrap("compute units per relay must be greater than 0") + } else if computeUnitsPerRelay > ComputeUnitsPerRelayMax { + return ErrSharedInvalidComputeUnitsPerRelay.Wrapf("compute units per relay must be less than %d", ComputeUnitsPerRelayMax) + } + return nil +} diff --git a/x/shared/types/service.pb.go b/x/shared/types/service.pb.go index eb6851347..1a2538f90 100644 --- a/x/shared/types/service.pb.go +++ b/x/shared/types/service.pb.go @@ -166,8 +166,7 @@ func (m *Service) GetOwnerAddress() string { // ApplicationServiceConfig holds the service configuration the application stakes for type ApplicationServiceConfig struct { - // TODO_BETA: Avoid embedding the full Service because we just need the ID. - Service *Service `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` + ServiceId string `protobuf:"bytes,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` } func (m *ApplicationServiceConfig) Reset() { *m = ApplicationServiceConfig{} } @@ -199,17 +198,16 @@ func (m *ApplicationServiceConfig) XXX_DiscardUnknown() { var xxx_messageInfo_ApplicationServiceConfig proto.InternalMessageInfo -func (m *ApplicationServiceConfig) GetService() *Service { +func (m *ApplicationServiceConfig) GetServiceId() string { if m != nil { - return m.Service + return m.ServiceId } - return nil + return "" } // SupplierServiceConfig holds the service configuration the supplier stakes for type SupplierServiceConfig struct { - // TODO_BETA: Avoid embedding the full Service because we just need the ID. - Service *Service `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` + ServiceId string `protobuf:"bytes,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` Endpoints []*SupplierEndpoint `protobuf:"bytes,2,rep,name=endpoints,proto3" json:"endpoints,omitempty"` RevShare []*ServiceRevenueShare `protobuf:"bytes,3,rep,name=rev_share,json=revShare,proto3" json:"rev_share,omitempty"` } @@ -243,11 +241,11 @@ func (m *SupplierServiceConfig) XXX_DiscardUnknown() { var xxx_messageInfo_SupplierServiceConfig proto.InternalMessageInfo -func (m *SupplierServiceConfig) GetService() *Service { +func (m *SupplierServiceConfig) GetServiceId() string { if m != nil { - return m.Service + return m.ServiceId } - return nil + return "" } func (m *SupplierServiceConfig) GetEndpoints() []*SupplierEndpoint { @@ -434,45 +432,45 @@ func init() { proto.RegisterFile("poktroll/shared/service.proto", fileDescriptor var fileDescriptor_302c2f793a11ae1e = []byte{ // 621 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xcf, 0x6e, 0xd3, 0x4e, - 0x10, 0xce, 0x26, 0xf9, 0xfd, 0x92, 0x4c, 0xda, 0xd4, 0x5a, 0x82, 0x30, 0x95, 0x6a, 0x95, 0x88, - 0x43, 0x55, 0xa9, 0x49, 0x95, 0x0a, 0x71, 0x42, 0xa8, 0x8d, 0x42, 0x55, 0xaa, 0x26, 0xd1, 0x3a, - 0xa5, 0x12, 0x17, 0xcb, 0xb5, 0x17, 0xd7, 0xaa, 0xe3, 0x5d, 0xad, 0xed, 0x94, 0x88, 0x97, 0x40, - 0xbc, 0x02, 0xaf, 0xc0, 0x43, 0x70, 0xa3, 0xe2, 0xd4, 0x23, 0x4a, 0x5f, 0x04, 0xad, 0xd7, 0x0e, - 0xd0, 0x16, 0x38, 0x70, 0x1b, 0xcf, 0xf7, 0xcd, 0xbf, 0x6f, 0xc7, 0x03, 0x6b, 0x9c, 0x9d, 0xc7, - 0x82, 0x05, 0x41, 0x27, 0x3a, 0xb3, 0x05, 0x75, 0x3b, 0x11, 0x15, 0x53, 0xdf, 0xa1, 0x6d, 0x2e, - 0x58, 0xcc, 0xf0, 0x4a, 0x0e, 0xb7, 0x15, 0xbc, 0xfa, 0xd0, 0x61, 0xd1, 0x84, 0x45, 0x56, 0x0a, - 0x77, 0xd4, 0x87, 0xe2, 0xae, 0x36, 0x3d, 0xe6, 0x31, 0xe5, 0x97, 0x96, 0xf2, 0xb6, 0x3e, 0x22, - 0xa8, 0x98, 0x2a, 0x27, 0x6e, 0x40, 0xd1, 0x77, 0x75, 0xb4, 0x8e, 0x36, 0x6a, 0xa4, 0xe8, 0xbb, - 0x18, 0x43, 0x39, 0xb4, 0x27, 0x54, 0x2f, 0xa6, 0x9e, 0xd4, 0xc6, 0x4f, 0xe0, 0x81, 0xc3, 0x26, - 0x3c, 0x89, 0xa9, 0x95, 0x84, 0x7e, 0x1c, 0x59, 0x9c, 0x0a, 0x4b, 0xd0, 0xc0, 0x9e, 0xe9, 0xa5, - 0x75, 0xb4, 0x51, 0x26, 0xcd, 0x0c, 0x3e, 0x96, 0xe8, 0x88, 0x0a, 0x22, 0x31, 0xfc, 0x0c, 0x96, - 0xd9, 0x45, 0x48, 0x85, 0x65, 0xbb, 0xae, 0xa0, 0x51, 0xa4, 0x97, 0x65, 0xce, 0x3d, 0xfd, 0xeb, - 0xa7, 0xad, 0x66, 0xd6, 0xe5, 0xae, 0x42, 0xcc, 0x58, 0xf8, 0xa1, 0x47, 0x96, 0x52, 0x7a, 0xe6, - 0x6b, 0x0d, 0x40, 0xdf, 0xe5, 0x3c, 0xf0, 0x1d, 0x3b, 0xf6, 0x59, 0x98, 0xf5, 0xdb, 0x63, 0xe1, - 0x1b, 0xdf, 0xc3, 0x5d, 0xa8, 0x64, 0xa2, 0xa4, 0xad, 0xd7, 0xbb, 0x7a, 0xfb, 0x86, 0x2a, 0xed, - 0x2c, 0x80, 0xe4, 0xc4, 0xd6, 0x17, 0x04, 0xf7, 0xcd, 0x44, 0x66, 0xa4, 0xe2, 0x9f, 0xb3, 0xe1, - 0xe7, 0x50, 0xa3, 0xa1, 0xcb, 0x99, 0x1f, 0xc6, 0x91, 0x5e, 0x5c, 0x2f, 0x6d, 0xd4, 0xbb, 0x8f, - 0x6e, 0x47, 0x65, 0xe5, 0xfa, 0x19, 0x93, 0xfc, 0x88, 0xc1, 0xbb, 0x50, 0x13, 0x74, 0x6a, 0xa5, - 0x4c, 0xbd, 0x94, 0x26, 0x78, 0xfc, 0xdb, 0xb2, 0x74, 0x4a, 0xc3, 0x84, 0x9a, 0xd2, 0x49, 0xaa, - 0x82, 0x4e, 0x53, 0xab, 0xf5, 0x01, 0x81, 0x76, 0xb3, 0x04, 0xd6, 0xa0, 0x94, 0x88, 0x20, 0x7b, - 0x51, 0x69, 0xe2, 0x1d, 0xa8, 0x0a, 0xee, 0x58, 0xf1, 0x8c, 0xab, 0x67, 0x6d, 0xdc, 0x31, 0x1f, - 0x19, 0xf5, 0xc6, 0x33, 0x4e, 0x49, 0x45, 0x70, 0x47, 0x1a, 0xf8, 0x29, 0x54, 0x9c, 0x54, 0x9d, - 0x28, 0x6b, 0x6e, 0xed, 0x56, 0x8c, 0x52, 0x6f, 0xc8, 0xe5, 0xf3, 0x90, 0x9c, 0xdd, 0x7a, 0x07, - 0xf7, 0xee, 0xe8, 0x5a, 0x6a, 0x9c, 0xaf, 0x01, 0xfa, 0xcb, 0x1a, 0xe4, 0x44, 0xbc, 0x0d, 0xcd, - 0x85, 0x44, 0x72, 0xe7, 0x1c, 0x1a, 0xc6, 0xb6, 0xa7, 0x86, 0x28, 0x12, 0x9c, 0xeb, 0x30, 0x5a, - 0x20, 0xad, 0x57, 0xb0, 0xf4, 0x73, 0x57, 0x78, 0x1b, 0x4a, 0xe7, 0x74, 0x96, 0x56, 0x6c, 0x74, - 0x8d, 0x3f, 0x4e, 0x10, 0x11, 0x49, 0xc5, 0x4d, 0xf8, 0x6f, 0x6a, 0x07, 0x49, 0xfe, 0x03, 0xa8, - 0x8f, 0xcd, 0x43, 0xa8, 0x64, 0x0a, 0xe1, 0x15, 0xa8, 0x1f, 0x0f, 0x0e, 0x07, 0xc3, 0x93, 0x81, - 0x45, 0x46, 0x3d, 0xad, 0x80, 0xab, 0x50, 0xde, 0x97, 0x16, 0xc2, 0xcb, 0x50, 0x3b, 0xe9, 0xef, - 0x99, 0xc3, 0xde, 0x61, 0x7f, 0xac, 0x15, 0xf1, 0x12, 0x54, 0x5f, 0x9a, 0x43, 0x45, 0x2b, 0x49, - 0x1a, 0xe9, 0x9b, 0x63, 0xad, 0xbc, 0xb9, 0x0d, 0xcb, 0xbf, 0x14, 0xc6, 0x18, 0x1a, 0x79, 0xca, - 0xde, 0x70, 0xf0, 0xe2, 0x60, 0x5f, 0x2b, 0xe0, 0x3a, 0x54, 0xc6, 0x07, 0x47, 0xfd, 0xe1, 0xf1, - 0x58, 0x43, 0x7b, 0x47, 0x9f, 0xe7, 0x06, 0xba, 0x9c, 0x1b, 0xe8, 0x6a, 0x6e, 0xa0, 0x6f, 0x73, - 0x03, 0xbd, 0xbf, 0x36, 0x0a, 0x97, 0xd7, 0x46, 0xe1, 0xea, 0xda, 0x28, 0xbc, 0xee, 0x78, 0x7e, - 0x7c, 0x96, 0x9c, 0xb6, 0x1d, 0x36, 0xe9, 0xc8, 0x09, 0xb7, 0x42, 0x1a, 0x5f, 0x30, 0x71, 0xde, - 0x59, 0xdc, 0x91, 0xb7, 0xf9, 0x25, 0x91, 0x3b, 0x10, 0x9d, 0xfe, 0x9f, 0x9e, 0x81, 0x9d, 0xef, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x73, 0x8b, 0x67, 0x7d, 0x69, 0x04, 0x00, 0x00, + 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, 0xb6, 0x53, 0x22, 0x7e, 0x02, 0xf1, + 0x0b, 0xfc, 0x02, 0x27, 0xbe, 0x80, 0x63, 0xc5, 0xa9, 0x47, 0x94, 0xfe, 0x08, 0x5a, 0xaf, 0x1d, + 0xa0, 0x41, 0x20, 0x6e, 0xe3, 0x79, 0x6f, 0x66, 0xde, 0xbe, 0x1d, 0x2f, 0xac, 0x07, 0xfc, 0x22, + 0x12, 0x7c, 0x34, 0x6a, 0x86, 0xe7, 0xb6, 0x60, 0x6e, 0x33, 0x64, 0x62, 0xe2, 0x39, 0xac, 0x11, + 0x08, 0x1e, 0x71, 0x5c, 0xcd, 0xe0, 0x86, 0x82, 0xd7, 0x1e, 0x3a, 0x3c, 0x1c, 0xf3, 0xd0, 0x4a, + 0xe0, 0xa6, 0xfa, 0x50, 0xdc, 0xb5, 0xda, 0x90, 0x0f, 0xb9, 0xca, 0xcb, 0x48, 0x65, 0xeb, 0x9f, + 0x08, 0x94, 0x4c, 0xd5, 0x13, 0xab, 0x90, 0xf7, 0x5c, 0x9d, 0x6c, 0x90, 0xcd, 0x0a, 0xcd, 0x7b, + 0x2e, 0x22, 0x14, 0x7d, 0x7b, 0xcc, 0xf4, 0x7c, 0x92, 0x49, 0x62, 0x7c, 0x02, 0x0f, 0x1c, 0x3e, + 0x0e, 0xe2, 0x88, 0x59, 0xb1, 0xef, 0x45, 0xa1, 0x15, 0x30, 0x61, 0x09, 0x36, 0xb2, 0xa7, 0x7a, + 0x61, 0x83, 0x6c, 0x16, 0x69, 0x2d, 0x85, 0x4f, 0x24, 0xda, 0x67, 0x82, 0x4a, 0x0c, 0x9f, 0xc3, + 0x0a, 0xbf, 0xf4, 0x99, 0xb0, 0x6c, 0xd7, 0x15, 0x2c, 0x0c, 0xf5, 0xa2, 0xec, 0xb9, 0xaf, 0x7f, + 0xfb, 0xbc, 0x5d, 0x4b, 0x55, 0xee, 0x29, 0xc4, 0x8c, 0x84, 0xe7, 0x0f, 0xe9, 0x72, 0x42, 0x4f, + 0x73, 0xf5, 0x67, 0xa0, 0xef, 0x05, 0xc1, 0xc8, 0x73, 0xec, 0xc8, 0xe3, 0x7e, 0xaa, 0xb7, 0xcd, + 0xfd, 0xb7, 0xde, 0x10, 0xd7, 0x01, 0x52, 0x53, 0xac, 0xb9, 0xfa, 0x4a, 0x9a, 0x39, 0x74, 0xeb, + 0x5f, 0x08, 0xdc, 0x37, 0x63, 0x59, 0xcc, 0xc4, 0xff, 0x14, 0xe2, 0x0b, 0xa8, 0x30, 0xdf, 0x0d, + 0xb8, 0xe7, 0x47, 0xa1, 0x9e, 0xdf, 0x28, 0x6c, 0x2e, 0xb5, 0x1e, 0x35, 0x6e, 0xf9, 0xdd, 0xc8, + 0x3a, 0x77, 0x52, 0x26, 0xfd, 0x59, 0x83, 0x7b, 0x50, 0x11, 0x6c, 0x62, 0x25, 0x4c, 0xbd, 0x90, + 0x34, 0x78, 0xbc, 0xd8, 0x40, 0xcd, 0xa3, 0x6c, 0xc2, 0xfc, 0x98, 0x99, 0x32, 0x49, 0xcb, 0x82, + 0x4d, 0x92, 0xa8, 0xfe, 0x91, 0x80, 0x76, 0x7b, 0x04, 0x6a, 0x50, 0x88, 0xc5, 0x28, 0x15, 0x2c, + 0x43, 0xdc, 0x85, 0xb2, 0x08, 0x1c, 0x2b, 0x9a, 0x06, 0xea, 0xb2, 0xaa, 0x2d, 0x7d, 0x61, 0x10, + 0xed, 0xb7, 0x07, 0xd3, 0x80, 0xd1, 0x92, 0x08, 0x1c, 0x19, 0xe0, 0x53, 0x28, 0x39, 0x89, 0x11, + 0x61, 0x2a, 0x6e, 0x7d, 0xa1, 0x46, 0x19, 0xd5, 0x0b, 0xa4, 0xe9, 0x34, 0x63, 0xd7, 0xdf, 0xc3, + 0xbd, 0x3f, 0xa8, 0xc6, 0x16, 0x94, 0xb2, 0xcb, 0x25, 0xff, 0xb8, 0xdc, 0x8c, 0x88, 0x3b, 0x50, + 0x9b, 0x5b, 0x24, 0x37, 0xc9, 0x61, 0x7e, 0x64, 0x0f, 0xd5, 0x21, 0xf2, 0x14, 0x33, 0x1f, 0xfa, + 0x73, 0xa4, 0xfe, 0x1a, 0x96, 0x7f, 0x55, 0x85, 0x3b, 0x50, 0xb8, 0x60, 0xd3, 0x64, 0x62, 0xb5, + 0x65, 0xfc, 0xf5, 0x04, 0x21, 0x95, 0x54, 0xac, 0xc1, 0x9d, 0x89, 0x3d, 0x8a, 0xb3, 0xb5, 0x56, + 0x1f, 0x5b, 0x47, 0x50, 0x4a, 0x1d, 0xc2, 0x55, 0x58, 0x3a, 0xe9, 0x1e, 0x75, 0x7b, 0xa7, 0x5d, + 0x8b, 0xf6, 0xdb, 0x5a, 0x0e, 0xcb, 0x50, 0x3c, 0x90, 0x11, 0xc1, 0x15, 0xa8, 0x9c, 0x76, 0xf6, + 0xcd, 0x5e, 0xfb, 0xa8, 0x33, 0xd0, 0xf2, 0xb8, 0x0c, 0xe5, 0x57, 0x66, 0x4f, 0xd1, 0x0a, 0x92, + 0x46, 0x3b, 0xe6, 0x40, 0x2b, 0x6e, 0xed, 0xc0, 0xca, 0x6f, 0x83, 0x11, 0xa1, 0x9a, 0xb5, 0x6c, + 0xf7, 0xba, 0x2f, 0x0f, 0x0f, 0xb4, 0x1c, 0x2e, 0x41, 0x69, 0x70, 0x78, 0xdc, 0xe9, 0x9d, 0x0c, + 0x34, 0xb2, 0x7f, 0xfc, 0x75, 0x66, 0x90, 0xab, 0x99, 0x41, 0xae, 0x67, 0x06, 0xf9, 0x3e, 0x33, + 0xc8, 0x87, 0x1b, 0x23, 0x77, 0x75, 0x63, 0xe4, 0xae, 0x6f, 0x8c, 0xdc, 0x9b, 0xe6, 0xd0, 0x8b, + 0xce, 0xe3, 0xb3, 0x86, 0xc3, 0xc7, 0x4d, 0x79, 0xc2, 0x6d, 0x9f, 0x45, 0x97, 0x5c, 0x5c, 0x34, + 0xe7, 0xaf, 0xc3, 0xbb, 0xec, 0x7d, 0x90, 0x3b, 0x10, 0x9e, 0xdd, 0x4d, 0x7e, 0xee, 0xdd, 0x1f, + 0x01, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x19, 0xf1, 0x60, 0x3f, 0x04, 0x00, 0x00, } func (m *Service) Marshal() (dAtA []byte, err error) { @@ -544,15 +542,10 @@ func (m *ApplicationServiceConfig) MarshalToSizedBuffer(dAtA []byte) (int, error _ = i var l int _ = l - if m.Service != nil { - { - size, err := m.Service.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } + if len(m.ServiceId) > 0 { + i -= len(m.ServiceId) + copy(dAtA[i:], m.ServiceId) + i = encodeVarintService(dAtA, i, uint64(len(m.ServiceId))) i-- dAtA[i] = 0xa } @@ -607,15 +600,10 @@ func (m *SupplierServiceConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x12 } } - if m.Service != nil { - { - size, err := m.Service.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintService(dAtA, i, uint64(size)) - } + if len(m.ServiceId) > 0 { + i -= len(m.ServiceId) + copy(dAtA[i:], m.ServiceId) + i = encodeVarintService(dAtA, i, uint64(len(m.ServiceId))) i-- dAtA[i] = 0xa } @@ -783,8 +771,8 @@ func (m *ApplicationServiceConfig) Size() (n int) { } var l int _ = l - if m.Service != nil { - l = m.Service.Size() + l = len(m.ServiceId) + if l > 0 { n += 1 + l + sovService(uint64(l)) } return n @@ -796,8 +784,8 @@ func (m *SupplierServiceConfig) Size() (n int) { } var l int _ = l - if m.Service != nil { - l = m.Service.Size() + l = len(m.ServiceId) + if l > 0 { n += 1 + l + sovService(uint64(l)) } if len(m.Endpoints) > 0 { @@ -1071,9 +1059,9 @@ func (m *ApplicationServiceConfig) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Service", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ServiceId", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowService @@ -1083,27 +1071,23 @@ func (m *ApplicationServiceConfig) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthService } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthService } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Service == nil { - m.Service = &Service{} - } - if err := m.Service.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.ServiceId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1157,9 +1141,9 @@ func (m *SupplierServiceConfig) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Service", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ServiceId", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowService @@ -1169,27 +1153,23 @@ func (m *SupplierServiceConfig) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthService } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthService } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Service == nil { - m.Service = &Service{} - } - if err := m.Service.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.ServiceId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { diff --git a/x/supplier/config/supplier_configs_reader.go b/x/supplier/config/supplier_configs_reader.go index 72859131a..fef39c69c 100644 --- a/x/supplier/config/supplier_configs_reader.go +++ b/x/supplier/config/supplier_configs_reader.go @@ -136,7 +136,7 @@ func ParseSupplierConfigs(ctx context.Context, configContent []byte) (*SupplierS // Create a supplied service config with the serviceId service := &sharedtypes.SupplierServiceConfig{ - Service: &sharedtypes.Service{Id: svc.ServiceId}, + ServiceId: svc.ServiceId, RevShare: []*sharedtypes.ServiceRevenueShare{}, Endpoints: []*sharedtypes.SupplierEndpoint{}, } diff --git a/x/supplier/config/supplier_configs_reader_test.go b/x/supplier/config/supplier_configs_reader_test.go index c2d711553..f5d557345 100644 --- a/x/supplier/config/supplier_configs_reader_test.go +++ b/x/supplier/config/supplier_configs_reader_test.go @@ -55,7 +55,7 @@ func Test_ParseSupplierConfigs_Services(t *testing.T) { StakeAmount: sdk.NewCoin("upokt", math.NewInt(1000)), Services: []*types.SupplierServiceConfig{ { - Service: &types.Service{Id: "svc"}, + ServiceId: "svc", Endpoints: []*types.SupplierEndpoint{ { Url: "http://pokt.network:8081", @@ -97,7 +97,7 @@ func Test_ParseSupplierConfigs_Services(t *testing.T) { StakeAmount: sdk.NewCoin("upokt", math.NewInt(1000)), Services: []*types.SupplierServiceConfig{ { - Service: &types.Service{Id: "svc"}, + ServiceId: "svc", Endpoints: []*types.SupplierEndpoint{ { Url: "http://pokt.network:8081", @@ -134,7 +134,7 @@ func Test_ParseSupplierConfigs_Services(t *testing.T) { StakeAmount: sdk.NewCoin("upokt", math.NewInt(1000)), Services: []*types.SupplierServiceConfig{ { - Service: &types.Service{Id: "svc"}, + ServiceId: "svc", Endpoints: []*types.SupplierEndpoint{ { Url: "http://pokt.network:8081", @@ -177,7 +177,7 @@ func Test_ParseSupplierConfigs_Services(t *testing.T) { StakeAmount: sdk.NewCoin("upokt", math.NewInt(1000)), Services: []*types.SupplierServiceConfig{ { - Service: &types.Service{Id: "svc"}, + ServiceId: "svc", Endpoints: []*types.SupplierEndpoint{ { Url: "http://pokt.network:8081", @@ -237,7 +237,7 @@ func Test_ParseSupplierConfigs_Services(t *testing.T) { StakeAmount: sdk.NewCoin("upokt", math.NewInt(1000)), Services: []*types.SupplierServiceConfig{ { - Service: &types.Service{Id: "svc1"}, + ServiceId: "svc1", Endpoints: []*types.SupplierEndpoint{ { Url: "http://pokt.network:8081", @@ -258,7 +258,7 @@ func Test_ParseSupplierConfigs_Services(t *testing.T) { }, }, { - Service: &types.Service{Id: "svc2"}, + ServiceId: "svc2", Endpoints: []*types.SupplierEndpoint{ { Url: "http://pokt.network:8081", @@ -312,7 +312,7 @@ func Test_ParseSupplierConfigs_Services(t *testing.T) { StakeAmount: sdk.NewCoin("upokt", math.NewInt(1000)), Services: []*types.SupplierServiceConfig{ { - Service: &types.Service{Id: "svc"}, + ServiceId: "svc", Endpoints: []*types.SupplierEndpoint{ { Url: "http://pokt.network:8081", @@ -331,7 +331,7 @@ func Test_ParseSupplierConfigs_Services(t *testing.T) { }, }, { - Service: &types.Service{Id: "svc2"}, + ServiceId: "svc2", Endpoints: []*types.SupplierEndpoint{ { Url: "http://pokt.network:8082", @@ -373,7 +373,7 @@ func Test_ParseSupplierConfigs_Services(t *testing.T) { StakeAmount: sdk.NewCoin("upokt", math.NewInt(1000)), Services: []*types.SupplierServiceConfig{ { - Service: &types.Service{Id: "svc"}, + ServiceId: "svc", Endpoints: []*types.SupplierEndpoint{ { Url: "http://pokt.network:8081", @@ -417,7 +417,7 @@ func Test_ParseSupplierConfigs_Services(t *testing.T) { StakeAmount: sdk.NewCoin("upokt", math.NewInt(1000)), Services: []*types.SupplierServiceConfig{ { - Service: &types.Service{Id: "svc"}, + ServiceId: "svc", Endpoints: []*types.SupplierEndpoint{ { Url: "http://pokt.network:8081", @@ -790,7 +790,7 @@ func Test_ParseSupplierConfigs_Services(t *testing.T) { for svcIdx, expectedService := range tt.expectedConfig.Services { service := supplierServiceConfig.Services[svcIdx] - require.Equal(t, expectedService.Service.Id, service.Service.Id) + require.Equal(t, expectedService.ServiceId, service.ServiceId) require.Equal(t, len(expectedService.Endpoints), len(service.Endpoints)) for endpointIdx, expectedEndpoint := range expectedService.Endpoints { diff --git a/x/supplier/keeper/msg_server_stake_supplier.go b/x/supplier/keeper/msg_server_stake_supplier.go index dada0e40c..b3da89899 100644 --- a/x/supplier/keeper/msg_server_stake_supplier.go +++ b/x/supplier/keeper/msg_server_stake_supplier.go @@ -31,9 +31,9 @@ func (k msgServer) StakeSupplier(ctx context.Context, msg *types.MsgStakeSupplie // Check if the services the supplier is staking for exist for _, serviceConfig := range msg.Services { - if _, serviceFound := k.serviceKeeper.GetService(ctx, serviceConfig.Service.Id); !serviceFound { - logger.Error(fmt.Sprintf("service %q does not exist", serviceConfig.Service.Id)) - return nil, types.ErrSupplierServiceNotFound.Wrapf("service %q does not exist", serviceConfig.Service.Id) + if _, serviceFound := k.serviceKeeper.GetService(ctx, serviceConfig.ServiceId); !serviceFound { + logger.Error(fmt.Sprintf("service %q does not exist", serviceConfig.ServiceId)) + return nil, types.ErrSupplierServiceNotFound.Wrapf("service %q does not exist", serviceConfig.ServiceId) } } @@ -140,7 +140,7 @@ func (k msgServer) createSupplier( // all services are activated at the end of the current session. servicesActivationHeightsMap := make(map[string]uint64) for _, serviceConfig := range msg.Services { - servicesActivationHeightsMap[serviceConfig.Service.Id] = uint64(nextSessionStartHeight) + servicesActivationHeightsMap[serviceConfig.ServiceId] = uint64(nextSessionStartHeight) } return sharedtypes.Supplier{ @@ -190,12 +190,12 @@ func (k msgServer) updateSupplier( // beginning of the next session. ServicesActivationHeightMap := make(map[string]uint64) for _, serviceConfig := range msg.Services { - ServicesActivationHeightMap[serviceConfig.Service.Id] = uint64(nextSessionStartHeight) + ServicesActivationHeightMap[serviceConfig.ServiceId] = uint64(nextSessionStartHeight) // If the service has already been staked for, keep its activation height. for _, existingServiceConfig := range supplier.Services { - if existingServiceConfig.Service.Id == serviceConfig.Service.Id { - existingServiceActivationHeight := supplier.ServicesActivationHeightsMap[serviceConfig.Service.Id] - ServicesActivationHeightMap[serviceConfig.Service.Id] = existingServiceActivationHeight + if existingServiceConfig.ServiceId == serviceConfig.ServiceId { + existingServiceActivationHeight := supplier.ServicesActivationHeightsMap[serviceConfig.ServiceId] + ServicesActivationHeightMap[serviceConfig.ServiceId] = existingServiceActivationHeight break } } diff --git a/x/supplier/keeper/msg_server_stake_supplier_test.go b/x/supplier/keeper/msg_server_stake_supplier_test.go index 743ee23ec..5c35f3625 100644 --- a/x/supplier/keeper/msg_server_stake_supplier_test.go +++ b/x/supplier/keeper/msg_server_stake_supplier_test.go @@ -40,7 +40,7 @@ func TestMsgServer_StakeSupplier_SuccessfulCreateAndUpdate(t *testing.T) { require.Equal(t, operatorAddr, foundSupplier.OperatorAddress) require.Equal(t, int64(100), foundSupplier.Stake.Amount.Int64()) require.Len(t, foundSupplier.Services, 1) - require.Equal(t, "svcId", foundSupplier.Services[0].Service.Id) + require.Equal(t, "svcId", foundSupplier.Services[0].ServiceId) require.Len(t, foundSupplier.Services[0].Endpoints, 1) require.Equal(t, "http://localhost:8080", foundSupplier.Services[0].Endpoints[0].Url) @@ -56,7 +56,7 @@ func TestMsgServer_StakeSupplier_SuccessfulCreateAndUpdate(t *testing.T) { require.True(t, isSupplierFound) require.Equal(t, int64(200), foundSupplier.Stake.Amount.Int64()) require.Len(t, foundSupplier.Services, 1) - require.Equal(t, "svcId2", foundSupplier.Services[0].Service.Id) + require.Equal(t, "svcId2", foundSupplier.Services[0].ServiceId) require.Len(t, foundSupplier.Services[0].Endpoints, 1) require.Equal(t, "http://localhost:8082", foundSupplier.Services[0].Endpoints[0].Url) } @@ -89,13 +89,13 @@ func TestMsgServer_StakeSupplier_FailRestakingDueToInvalidServices(t *testing.T) require.True(t, isSupplierFound) require.Equal(t, operatorAddr, supplierFound.OperatorAddress) require.Len(t, supplierFound.Services, 1) - require.Equal(t, "svcId", supplierFound.Services[0].Service.Id) + require.Equal(t, "svcId", supplierFound.Services[0].ServiceId) require.Len(t, supplierFound.Services[0].Endpoints, 1) require.Equal(t, "http://localhost:8080", supplierFound.Services[0].Endpoints[0].Url) // Prepare the supplier stake message with an invalid service ID updateStakeMsg = stakeSupplierForServicesMsg(ownerAddr, operatorAddr, 200, "svcId") - updateStakeMsg.Services[0].Service.Id = "svc1 INVALID ! & *" + updateStakeMsg.Services[0].ServiceId = "svc1 INVALID ! & *" // Fail updating the supplier when the list of services is empty _, err = srv.StakeSupplier(ctx, updateStakeMsg) @@ -106,7 +106,7 @@ func TestMsgServer_StakeSupplier_FailRestakingDueToInvalidServices(t *testing.T) require.True(t, isSupplierFound) require.Equal(t, operatorAddr, supplierFound.OperatorAddress) require.Len(t, supplierFound.Services, 1) - require.Equal(t, "svcId", supplierFound.Services[0].Service.Id) + require.Equal(t, "svcId", supplierFound.Services[0].ServiceId) require.Len(t, supplierFound.Services[0].Endpoints, 1) require.Equal(t, "http://localhost:8080", supplierFound.Services[0].Endpoints[0].Url) } @@ -338,7 +338,7 @@ func stakeSupplierForServicesMsg( services := make([]*sharedtypes.SupplierServiceConfig, 0, len(serviceIds)) for _, serviceId := range serviceIds { services = append(services, &sharedtypes.SupplierServiceConfig{ - Service: &sharedtypes.Service{Id: serviceId}, + ServiceId: serviceId, Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: "http://localhost:8080", diff --git a/x/supplier/keeper/msg_server_unstake_supplier_test.go b/x/supplier/keeper/msg_server_unstake_supplier_test.go index 73eb8e1c8..91d49ed7f 100644 --- a/x/supplier/keeper/msg_server_unstake_supplier_test.go +++ b/x/supplier/keeper/msg_server_unstake_supplier_test.go @@ -247,9 +247,7 @@ func createStakeMsg(supplierOwnerAddr string, stakeAmount int64) *types.MsgStake Stake: &initialStake, Services: []*sharedtypes.SupplierServiceConfig{ { - Service: &sharedtypes.Service{ - Id: "svcId", - }, + ServiceId: "svcId", Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: "http://localhost:8080", diff --git a/x/supplier/keeper/supplier_test.go b/x/supplier/keeper/supplier_test.go index 279fcd81b..8cbddd555 100644 --- a/x/supplier/keeper/supplier_test.go +++ b/x/supplier/keeper/supplier_test.go @@ -43,7 +43,7 @@ func createNSuppliers(keeper keeper.Keeper, ctx context.Context, n int) []shared supplier.Stake = &sdk.Coin{Denom: "upokt", Amount: math.NewInt(int64(i))} supplier.Services = []*sharedtypes.SupplierServiceConfig{ { - Service: &sharedtypes.Service{Id: fmt.Sprintf("svc%d", i)}, + ServiceId: fmt.Sprintf("svc%d", i), Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: fmt.Sprintf("http://localhost:%d", i), diff --git a/x/supplier/module/genesis_test.go b/x/supplier/module/genesis_test.go index 987492154..3c5180230 100644 --- a/x/supplier/module/genesis_test.go +++ b/x/supplier/module/genesis_test.go @@ -25,9 +25,7 @@ func TestGenesis(t *testing.T) { Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.SupplierServiceConfig{ { - Service: &sharedtypes.Service{ - Id: "svcId1", - }, + ServiceId: "svcId1", Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: "http://localhost:8081", @@ -44,9 +42,7 @@ func TestGenesis(t *testing.T) { Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.SupplierServiceConfig{ { - Service: &sharedtypes.Service{ - Id: "svcId2", - }, + ServiceId: "svcId2", Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: "http://localhost:8082", diff --git a/x/supplier/types/genesis_test.go b/x/supplier/types/genesis_test.go index 5d089f20c..0e4301e3e 100644 --- a/x/supplier/types/genesis_test.go +++ b/x/supplier/types/genesis_test.go @@ -16,9 +16,7 @@ func TestGenesisState_Validate(t *testing.T) { addr1 := sample.AccAddress() stake1 := sdk.NewCoin("upokt", math.NewInt(100)) serviceConfig1 := &sharedtypes.SupplierServiceConfig{ - Service: &sharedtypes.Service{ - Id: "svcId1", - }, + ServiceId: "svcId1", Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: "http://localhost:8081", @@ -38,9 +36,7 @@ func TestGenesisState_Validate(t *testing.T) { addr2 := sample.AccAddress() stake2 := sdk.NewCoin("upokt", math.NewInt(100)) serviceConfig2 := &sharedtypes.SupplierServiceConfig{ - Service: &sharedtypes.Service{ - Id: "svcId2", - }, + ServiceId: "svcId2", Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: "http://localhost:8082", @@ -284,9 +280,7 @@ func TestGenesisState_Validate(t *testing.T) { Stake: &stake2, Services: []*sharedtypes.SupplierServiceConfig{ { - Service: &sharedtypes.Service{ - Id: "svcId1", - }, + ServiceId: "svcId1", Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: "invalid URL", @@ -323,9 +317,7 @@ func TestGenesisState_Validate(t *testing.T) { Stake: &stake2, Services: []*sharedtypes.SupplierServiceConfig{ { - Service: &sharedtypes.Service{ - Id: "svcId1", - }, + ServiceId: "svcId1", Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: "http://localhost:8081", diff --git a/x/supplier/types/message_stake_supplier_test.go b/x/supplier/types/message_stake_supplier_test.go index e3ea40af4..54ab8abf0 100644 --- a/x/supplier/types/message_stake_supplier_test.go +++ b/x/supplier/types/message_stake_supplier_test.go @@ -18,9 +18,7 @@ import ( func TestMsgStakeSupplier_ValidateBasic(t *testing.T) { defaultServicesList := []*sharedtypes.SupplierServiceConfig{ { - Service: &sharedtypes.Service{ - Id: "svcId1", - }, + ServiceId: "svcId1", Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: "http://localhost:8081", @@ -229,9 +227,7 @@ func TestMsgStakeSupplier_ValidateBasic(t *testing.T) { Stake: &sdk.Coin{Denom: volatile.DenomuPOKT, Amount: math.NewInt(100)}, Services: []*sharedtypes.SupplierServiceConfig{ { - Service: &sharedtypes.Service{ - Id: "svcId1", - }, + ServiceId: "svcId1", Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: "http://localhost:8081", @@ -247,9 +243,7 @@ func TestMsgStakeSupplier_ValidateBasic(t *testing.T) { }, }, { - Service: &sharedtypes.Service{ - Id: "svcId2", - }, + ServiceId: "svcId2", Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: "http://localhost:8082", @@ -298,40 +292,7 @@ func TestMsgStakeSupplier_ValidateBasic(t *testing.T) { Stake: &sdk.Coin{Denom: volatile.DenomuPOKT, Amount: math.NewInt(100)}, Services: []*sharedtypes.SupplierServiceConfig{ { - Service: &sharedtypes.Service{ - Id: "TooLongId1234567890", - }, - Endpoints: []*sharedtypes.SupplierEndpoint{ - { - Url: "http://localhost:8080", - RpcType: sharedtypes.RPCType_JSON_RPC, - Configs: make([]*sharedtypes.ConfigOption, 0), - }, - }, - RevShare: []*sharedtypes.ServiceRevenueShare{ - { - Address: sample.AccAddress(), - RevSharePercentage: 100, - }, - }, - }, - }, - }, - expectedErr: ErrSupplierInvalidServiceConfig, - }, - { - desc: "invalid service configs - invalid service Name that's too long", - msg: MsgStakeSupplier{ - Signer: ownerAddress, - OwnerAddress: ownerAddress, - OperatorAddress: operatorAddress, - Stake: &sdk.Coin{Denom: volatile.DenomuPOKT, Amount: math.NewInt(100)}, - Services: []*sharedtypes.SupplierServiceConfig{ - { - Service: &sharedtypes.Service{ - Id: "123", - Name: "abcdefghijklmnopqrstuvwxyzab-abcdefghijklmnopqrstuvwxyzab", - }, + ServiceId: "TooLongId1234567890", Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: "http://localhost:8080", @@ -359,9 +320,7 @@ func TestMsgStakeSupplier_ValidateBasic(t *testing.T) { Stake: &sdk.Coin{Denom: volatile.DenomuPOKT, Amount: math.NewInt(100)}, Services: []*sharedtypes.SupplierServiceConfig{ { - Service: &sharedtypes.Service{ - Id: "12 45 !", - }, + ServiceId: "12 45 !", Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: "http://localhost:8080", @@ -389,10 +348,7 @@ func TestMsgStakeSupplier_ValidateBasic(t *testing.T) { Stake: &sdk.Coin{Denom: volatile.DenomuPOKT, Amount: math.NewInt(100)}, Services: []*sharedtypes.SupplierServiceConfig{ { - Service: &sharedtypes.Service{ - Id: "svcId", - Name: "name", - }, + ServiceId: "svcId", Endpoints: []*sharedtypes.SupplierEndpoint{ { // Url explicitly omitted @@ -420,10 +376,7 @@ func TestMsgStakeSupplier_ValidateBasic(t *testing.T) { Stake: &sdk.Coin{Denom: volatile.DenomuPOKT, Amount: math.NewInt(100)}, Services: []*sharedtypes.SupplierServiceConfig{ { - Service: &sharedtypes.Service{ - Id: "svcId", - Name: "name", - }, + ServiceId: "svcId", Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: "I am not a valid URL", @@ -451,10 +404,7 @@ func TestMsgStakeSupplier_ValidateBasic(t *testing.T) { Stake: &sdk.Coin{Denom: volatile.DenomuPOKT, Amount: math.NewInt(100)}, Services: []*sharedtypes.SupplierServiceConfig{ { - Service: &sharedtypes.Service{ - Id: "svcId", - Name: "name", - }, + ServiceId: "svcId", Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: "http://localhost:8080", @@ -482,10 +432,7 @@ func TestMsgStakeSupplier_ValidateBasic(t *testing.T) { Stake: &sdk.Coin{Denom: volatile.DenomuPOKT, Amount: math.NewInt(100)}, Services: []*sharedtypes.SupplierServiceConfig{ { - Service: &sharedtypes.Service{ - Id: "svcId", - Name: "name", - }, + ServiceId: "svcId", Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: "http://localhost:8080", @@ -508,10 +455,7 @@ func TestMsgStakeSupplier_ValidateBasic(t *testing.T) { Stake: &sdk.Coin{Denom: volatile.DenomuPOKT, Amount: math.NewInt(100)}, Services: []*sharedtypes.SupplierServiceConfig{ { - Service: &sharedtypes.Service{ - Id: "svcId", - Name: "name", - }, + ServiceId: "svcId", Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: "http://localhost:8080", diff --git a/x/tokenomics/keeper/keeper_settle_pending_claims_test.go b/x/tokenomics/keeper/keeper_settle_pending_claims_test.go index e748b4bc9..5f7376e94 100644 --- a/x/tokenomics/keeper/keeper_settle_pending_claims_test.go +++ b/x/tokenomics/keeper/keeper_settle_pending_claims_test.go @@ -102,7 +102,7 @@ func (s *TestSuite) SetupTest() { OperatorAddress: supplierOwnerAddr, Stake: &supplierStake, Services: []*sharedtypes.SupplierServiceConfig{{ - Service: &service, + ServiceId: testServiceId, RevShare: []*sharedtypes.ServiceRevenueShare{{ Address: supplierOwnerAddr, RevSharePercentage: 100, @@ -115,7 +115,7 @@ func (s *TestSuite) SetupTest() { app := apptypes.Application{ Address: appAddr, Stake: &appStake, - ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{{Service: &service}}, + ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{{ServiceId: testServiceId}}, } s.keepers.SetApplication(s.ctx, app) @@ -123,7 +123,7 @@ func (s *TestSuite) SetupTest() { // to be claimed and for which a valid proof would be accepted. sessionReq := &sessiontypes.QueryGetSessionRequest{ ApplicationAddress: appAddr, - Service: &service, + ServiceId: testServiceId, BlockHeight: 1, } sessionRes, err := s.keepers.GetSession(sdkCtx, sessionReq) @@ -529,7 +529,7 @@ func (s *TestSuite) TestSettlePendingClaims_ClaimPendingAfterSettlement() { // Add a second claim with a session header corresponding to the next session. sessionTwoClaim := testutilproof.BaseClaim( - sessionOneClaim.GetSessionHeader().GetService().Id, + sessionOneClaim.GetSessionHeader().GetServiceId(), sessionOneClaim.GetSessionHeader().GetApplicationAddress(), sessionOneClaim.GetSupplierOperatorAddress(), s.numRelays, @@ -541,7 +541,7 @@ func (s *TestSuite) TestSettlePendingClaims_ClaimPendingAfterSettlement() { sessionTwoClaim.SessionHeader = &sessiontypes.SessionHeader{ ApplicationAddress: sessionOneClaim.GetSessionHeader().GetApplicationAddress(), - Service: s.claim.GetSessionHeader().GetService(), + ServiceId: s.claim.GetSessionHeader().GetServiceId(), SessionId: "session_two_id", SessionStartBlockHeight: sessionTwoStartHeight, SessionEndBlockHeight: shared.GetSessionEndHeight(&sharedParams, sessionTwoStartHeight), diff --git a/x/tokenomics/keeper/settle_pending_claims.go b/x/tokenomics/keeper/settle_pending_claims.go index 48b434ef8..d378095f8 100644 --- a/x/tokenomics/keeper/settle_pending_claims.go +++ b/x/tokenomics/keeper/settle_pending_claims.go @@ -171,7 +171,7 @@ func (k Keeper) SettlePendingClaims(ctx sdk.Context) ( settledResult.NumClaims++ settledResult.NumRelays += numClaimRelays settledResult.NumComputeUnits += numClaimComputeUnits - settledResult.RelaysPerServiceMap[claim.SessionHeader.Service.Id] += numClaimRelays + settledResult.RelaysPerServiceMap[claim.SessionHeader.ServiceId] += numClaimRelays logger.Info(fmt.Sprintf("Successfully settled claim for session ID %q at block height %d", claim.SessionHeader.SessionId, blockHeight)) } diff --git a/x/tokenomics/keeper/token_logic_modules.go b/x/tokenomics/keeper/token_logic_modules.go index 7efe8f553..a6efb12d3 100644 --- a/x/tokenomics/keeper/token_logic_modules.go +++ b/x/tokenomics/keeper/token_logic_modules.go @@ -223,10 +223,9 @@ func (k Keeper) ProcessTokenLogicModules( return tokenomicstypes.ErrTokenomicsSupplierNotFound } - // Retrieve the service that the supplier is providing - service, isServiceFound := k.serviceKeeper.GetService(ctx, sessionHeader.Service.Id) + service, isServiceFound := k.serviceKeeper.GetService(ctx, sessionHeader.ServiceId) if !isServiceFound { - return tokenomicstypes.ErrTokenomicsServiceNotFound.Wrapf("service with ID %q not found", sessionHeader.Service.Id) + return tokenomicstypes.ErrTokenomicsServiceNotFound.Wrapf("service with ID %q not found", sessionHeader.ServiceId) } // Determine the total number of tokens being claimed (i.e. for the work completed) @@ -242,7 +241,7 @@ func (k Keeper) ProcessTokenLogicModules( "num_relays", numRelays, "claim_settlement_upokt", claimSettlementCoin.Amount, "session_id", sessionHeader.GetSessionId(), - "service_id", sessionHeader.GetService().Id, + "service_id", sessionHeader.GetServiceId(), "supplier_operator", supplier.OperatorAddress, "application", application.Address, ) @@ -594,7 +593,7 @@ func (k Keeper) distributeSupplierRewardsToShareHolders( var serviceRevShare []*sharedtypes.ServiceRevenueShare for _, svc := range supplier.Services { - if svc.Service.Id == serviceId { + if svc.ServiceId == serviceId { serviceRevShare = svc.RevShare break } diff --git a/x/tokenomics/keeper/token_logic_modules_test.go b/x/tokenomics/keeper/token_logic_modules_test.go index 3a0712c45..2f6d6bdfd 100644 --- a/x/tokenomics/keeper/token_logic_modules_test.go +++ b/x/tokenomics/keeper/token_logic_modules_test.go @@ -81,7 +81,7 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Valid(t *testing.T) { app := apptypes.Application{ Address: sample.AccAddress(), Stake: &appStake, - ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{{Service: service}}, + ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{{ServiceId: service.Id}}, } keepers.SetApplication(ctx, app) @@ -102,7 +102,10 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Valid(t *testing.T) { OwnerAddress: supplierRevShares[0].Address, OperatorAddress: supplierRevShares[0].Address, Stake: &supplierStake, - Services: []*sharedtypes.SupplierServiceConfig{{Service: service, RevShare: supplierRevShares}}, + Services: []*sharedtypes.SupplierServiceConfig{{ + ServiceId: service.Id, + RevShare: supplierRevShares, + }}, } keepers.SetSupplier(ctx, supplier) @@ -208,7 +211,7 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Invalid_SupplierExceedsMaxCl app := apptypes.Application{ Address: sample.AccAddress(), Stake: &appStake, - ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{{Service: service}}, + ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{{ServiceId: service.Id}}, } keepers.SetApplication(ctx, app) @@ -229,7 +232,10 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Invalid_SupplierExceedsMaxCl OwnerAddress: supplierRevShares[0].Address, OperatorAddress: supplierRevShares[0].Address, Stake: &supplierStake, - Services: []*sharedtypes.SupplierServiceConfig{{Service: service, RevShare: supplierRevShares}}, + Services: []*sharedtypes.SupplierServiceConfig{{ + ServiceId: service.Id, + RevShare: supplierRevShares, + }}, } keepers.SetSupplier(ctx, supplier) @@ -333,7 +339,7 @@ func TestProcessTokenLogicModules_TLMGlobalMint_Valid_MintDistributionCorrect(t app := apptypes.Application{ Address: sample.AccAddress(), Stake: &appStake, - ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{{Service: service}}, + ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{{ServiceId: service.Id}}, } keepers.SetApplication(ctx, app) @@ -354,7 +360,7 @@ func TestProcessTokenLogicModules_TLMGlobalMint_Valid_MintDistributionCorrect(t OwnerAddress: supplierRevShares[0].Address, OperatorAddress: supplierRevShares[0].Address, Stake: &supplierStake, - Services: []*sharedtypes.SupplierServiceConfig{{Service: service, RevShare: supplierRevShares}}, + Services: []*sharedtypes.SupplierServiceConfig{{ServiceId: service.Id, RevShare: supplierRevShares}}, } keepers.SetSupplier(ctx, supplier) @@ -429,7 +435,7 @@ func TestProcessTokenLogicModules_AppNotFound(t *testing.T) { SupplierOperatorAddress: supplierOperatorAddr, SessionHeader: &sessiontypes.SessionHeader{ ApplicationAddress: sample.AccAddress(), // Random address - Service: service, + ServiceId: service.Id, SessionId: "session_id", SessionStartBlockHeight: 1, SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(1), @@ -452,7 +458,7 @@ func TestProcessTokenLogicModules_ServiceNotFound(t *testing.T) { SupplierOperatorAddress: supplierOperatorAddr, SessionHeader: &sessiontypes.SessionHeader{ ApplicationAddress: appAddr, - Service: &sharedtypes.Service{Id: "non_existent_svc"}, + ServiceId: "non_existent_svc", SessionId: "session_id", SessionStartBlockHeight: 1, SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(1), @@ -642,7 +648,7 @@ func prepareTestClaim( SupplierOperatorAddress: supplier.OperatorAddress, SessionHeader: &sessiontypes.SessionHeader{ ApplicationAddress: app.Address, - Service: service, + ServiceId: service.Id, SessionId: "session_id", SessionStartBlockHeight: 1, SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(1), diff --git a/x/tokenomics/types/tx.pb.go b/x/tokenomics/types/tx.pb.go index 9f18a148c..e4fec264c 100644 --- a/x/tokenomics/types/tx.pb.go +++ b/x/tokenomics/types/tx.pb.go @@ -125,6 +125,7 @@ type MsgUpdateParam struct { // specified in the `Params` message in `proof/params.proto.` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // Types that are valid to be assigned to AsType: + // // *MsgUpdateParam_AsString // *MsgUpdateParam_AsInt64 // *MsgUpdateParam_AsBytes