diff --git a/api/poktroll/service/tx.pulsar.go b/api/poktroll/service/tx.pulsar.go index f6fd47f21..bbce384f9 100644 --- a/api/poktroll/service/tx.pulsar.go +++ b/api/poktroll/service/tx.pulsar.go @@ -873,15 +873,15 @@ func (x *fastReflection_MsgUpdateParamsResponse) ProtoMethods() *protoiface.Meth } var ( - md_MsgAddService protoreflect.MessageDescriptor - fd_MsgAddService_address protoreflect.FieldDescriptor - fd_MsgAddService_service protoreflect.FieldDescriptor + md_MsgAddService protoreflect.MessageDescriptor + fd_MsgAddService_owner_address protoreflect.FieldDescriptor + fd_MsgAddService_service protoreflect.FieldDescriptor ) func init() { file_poktroll_service_tx_proto_init() md_MsgAddService = File_poktroll_service_tx_proto.Messages().ByName("MsgAddService") - fd_MsgAddService_address = md_MsgAddService.Fields().ByName("address") + fd_MsgAddService_owner_address = md_MsgAddService.Fields().ByName("owner_address") fd_MsgAddService_service = md_MsgAddService.Fields().ByName("service") } @@ -950,9 +950,9 @@ func (x *fastReflection_MsgAddService) Interface() protoreflect.ProtoMessage { // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_MsgAddService) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.Address != "" { - value := protoreflect.ValueOfString(x.Address) - if !f(fd_MsgAddService_address, value) { + if x.OwnerAddress != "" { + value := protoreflect.ValueOfString(x.OwnerAddress) + if !f(fd_MsgAddService_owner_address, value) { return } } @@ -977,8 +977,8 @@ func (x *fastReflection_MsgAddService) Range(f func(protoreflect.FieldDescriptor // a repeated field is populated if it is non-empty. func (x *fastReflection_MsgAddService) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.service.MsgAddService.address": - return x.Address != "" + case "poktroll.service.MsgAddService.owner_address": + return x.OwnerAddress != "" case "poktroll.service.MsgAddService.service": return x.Service != nil default: @@ -997,8 +997,8 @@ func (x *fastReflection_MsgAddService) Has(fd protoreflect.FieldDescriptor) bool // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_MsgAddService) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.service.MsgAddService.address": - x.Address = "" + case "poktroll.service.MsgAddService.owner_address": + x.OwnerAddress = "" case "poktroll.service.MsgAddService.service": x.Service = nil default: @@ -1017,8 +1017,8 @@ func (x *fastReflection_MsgAddService) Clear(fd protoreflect.FieldDescriptor) { // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_MsgAddService) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "poktroll.service.MsgAddService.address": - value := x.Address + case "poktroll.service.MsgAddService.owner_address": + value := x.OwnerAddress return protoreflect.ValueOfString(value) case "poktroll.service.MsgAddService.service": value := x.Service @@ -1043,8 +1043,8 @@ func (x *fastReflection_MsgAddService) Get(descriptor protoreflect.FieldDescript // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_MsgAddService) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "poktroll.service.MsgAddService.address": - x.Address = value.Interface().(string) + case "poktroll.service.MsgAddService.owner_address": + x.OwnerAddress = value.Interface().(string) case "poktroll.service.MsgAddService.service": x.Service = value.Message().Interface().(*shared.Service) default: @@ -1072,8 +1072,8 @@ func (x *fastReflection_MsgAddService) Mutable(fd protoreflect.FieldDescriptor) x.Service = new(shared.Service) } return protoreflect.ValueOfMessage(x.Service.ProtoReflect()) - case "poktroll.service.MsgAddService.address": - panic(fmt.Errorf("field address of message poktroll.service.MsgAddService is not mutable")) + case "poktroll.service.MsgAddService.owner_address": + panic(fmt.Errorf("field owner_address of message poktroll.service.MsgAddService is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.MsgAddService")) @@ -1087,7 +1087,7 @@ func (x *fastReflection_MsgAddService) Mutable(fd protoreflect.FieldDescriptor) // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_MsgAddService) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.service.MsgAddService.address": + case "poktroll.service.MsgAddService.owner_address": return protoreflect.ValueOfString("") case "poktroll.service.MsgAddService.service": m := new(shared.Service) @@ -1161,7 +1161,7 @@ func (x *fastReflection_MsgAddService) ProtoMethods() *protoiface.Methods { var n int var l int _ = l - l = len(x.Address) + l = len(x.OwnerAddress) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } @@ -1212,10 +1212,10 @@ func (x *fastReflection_MsgAddService) ProtoMethods() *protoiface.Methods { i-- dAtA[i] = 0x12 } - if len(x.Address) > 0 { - i -= len(x.Address) - copy(dAtA[i:], x.Address) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Address))) + if len(x.OwnerAddress) > 0 { + i -= len(x.OwnerAddress) + copy(dAtA[i:], x.OwnerAddress) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.OwnerAddress))) i-- dAtA[i] = 0xa } @@ -1270,7 +1270,7 @@ func (x *fastReflection_MsgAddService) ProtoMethods() *protoiface.Methods { switch fieldNum { case 1: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field OwnerAddress", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1298,7 +1298,7 @@ func (x *fastReflection_MsgAddService) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.Address = string(dAtA[iNdEx:postIndex]) + x.OwnerAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -1824,8 +1824,8 @@ type MsgAddService struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the service supplier using cosmos' ScalarDescriptor - Service *shared.Service `protobuf:"bytes,2,opt,name=service,proto3" json:"service,omitempty"` // The Service for which the supplier is adding to the network + OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` // The Bech32 address of the service owner using cosmos' ScalarDescriptor + Service *shared.Service `protobuf:"bytes,2,opt,name=service,proto3" json:"service,omitempty"` // The Service being added to the network } func (x *MsgAddService) Reset() { @@ -1848,9 +1848,9 @@ func (*MsgAddService) Descriptor() ([]byte, []int) { return file_poktroll_service_tx_proto_rawDescGZIP(), []int{2} } -func (x *MsgAddService) GetAddress() string { +func (x *MsgAddService) GetOwnerAddress() string { if x != nil { - return x.Address + return x.OwnerAddress } return "" } @@ -1917,40 +1917,41 @@ var file_poktroll_service_tx_proto_rawDesc = []byte{ 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x19, 0x0a, 0x17, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x8b, 0x01, 0x0a, 0x0d, 0x4d, 0x73, 0x67, 0x41, 0x64, 0x64, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 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, 0x38, 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, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x3a, 0x0c, 0x82, 0xe7, 0xb0, 0x2a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x22, 0x17, 0x0a, 0x15, 0x4d, 0x73, 0x67, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xc2, 0x01, 0x0a, 0x03, 0x4d, - 0x73, 0x67, 0x12, 0x5c, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, - 0x6d, 0x73, 0x12, 0x21, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, - 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x29, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x56, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x1f, - 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x2e, 0x4d, 0x73, 0x67, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x1a, - 0x27, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x6e, 0x73, 0x65, 0x22, 0x9c, 0x01, 0x0a, 0x0d, 0x4d, 0x73, 0x67, 0x41, 0x64, 0x64, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3d, 0x0a, 0x0d, 0x6f, 0x77, 0x6e, 0x65, 0x72, 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, 0x0c, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x41, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x12, 0x38, 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, 0x42, + 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x3a, 0x12, + 0x82, 0xe7, 0xb0, 0x2a, 0x0d, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x22, 0x17, 0x0a, 0x15, 0x4d, 0x73, 0x67, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xc2, 0x01, 0x0a, 0x03, + 0x4d, 0x73, 0x67, 0x12, 0x5c, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, + 0x61, 0x6d, 0x73, 0x12, 0x21, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x29, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x56, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x1f, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4d, 0x73, 0x67, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, - 0xa3, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x07, 0x54, 0x78, 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, 0x72, 0x76, 0x69, 0x63, 0x65, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x10, 0x50, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0xca, - 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0xe2, 0x02, 0x1c, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 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, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x1a, 0x27, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2e, 0x4d, 0x73, 0x67, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, + 0x42, 0xa3, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x07, 0x54, 0x78, 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, 0x72, 0x76, 0x69, 0x63, 0x65, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x10, + 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0xca, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0xe2, 0x02, 0x1c, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 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, 0x72, 0x76, 0x69, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/poktroll/shared/service.pulsar.go b/api/poktroll/shared/service.pulsar.go index 363e474cc..f2be11c20 100644 --- a/api/poktroll/shared/service.pulsar.go +++ b/api/poktroll/shared/service.pulsar.go @@ -3,6 +3,7 @@ package shared import ( fmt "fmt" + _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -17,6 +18,7 @@ var ( fd_Service_id protoreflect.FieldDescriptor fd_Service_name protoreflect.FieldDescriptor fd_Service_compute_units_per_relay protoreflect.FieldDescriptor + fd_Service_owner_address protoreflect.FieldDescriptor ) func init() { @@ -25,6 +27,7 @@ func init() { fd_Service_id = md_Service.Fields().ByName("id") fd_Service_name = md_Service.Fields().ByName("name") fd_Service_compute_units_per_relay = md_Service.Fields().ByName("compute_units_per_relay") + fd_Service_owner_address = md_Service.Fields().ByName("owner_address") } var _ protoreflect.Message = (*fastReflection_Service)(nil) @@ -110,6 +113,12 @@ func (x *fastReflection_Service) Range(f func(protoreflect.FieldDescriptor, prot return } } + if x.OwnerAddress != "" { + value := protoreflect.ValueOfString(x.OwnerAddress) + if !f(fd_Service_owner_address, value) { + return + } + } } // Has reports whether a field is populated. @@ -131,6 +140,8 @@ func (x *fastReflection_Service) Has(fd protoreflect.FieldDescriptor) bool { return x.Name != "" case "poktroll.shared.Service.compute_units_per_relay": return x.ComputeUnitsPerRelay != uint64(0) + case "poktroll.shared.Service.owner_address": + return x.OwnerAddress != "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.Service")) @@ -153,6 +164,8 @@ func (x *fastReflection_Service) Clear(fd protoreflect.FieldDescriptor) { x.Name = "" case "poktroll.shared.Service.compute_units_per_relay": x.ComputeUnitsPerRelay = uint64(0) + case "poktroll.shared.Service.owner_address": + x.OwnerAddress = "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.Service")) @@ -178,6 +191,9 @@ func (x *fastReflection_Service) Get(descriptor protoreflect.FieldDescriptor) pr case "poktroll.shared.Service.compute_units_per_relay": value := x.ComputeUnitsPerRelay return protoreflect.ValueOfUint64(value) + case "poktroll.shared.Service.owner_address": + value := x.OwnerAddress + return protoreflect.ValueOfString(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.Service")) @@ -204,6 +220,8 @@ func (x *fastReflection_Service) Set(fd protoreflect.FieldDescriptor, value prot x.Name = value.Interface().(string) case "poktroll.shared.Service.compute_units_per_relay": x.ComputeUnitsPerRelay = value.Uint() + case "poktroll.shared.Service.owner_address": + x.OwnerAddress = value.Interface().(string) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.Service")) @@ -230,6 +248,8 @@ func (x *fastReflection_Service) Mutable(fd protoreflect.FieldDescriptor) protor panic(fmt.Errorf("field name of message poktroll.shared.Service is not mutable")) case "poktroll.shared.Service.compute_units_per_relay": panic(fmt.Errorf("field compute_units_per_relay of message poktroll.shared.Service is not mutable")) + case "poktroll.shared.Service.owner_address": + panic(fmt.Errorf("field owner_address of message poktroll.shared.Service is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.Service")) @@ -249,6 +269,8 @@ func (x *fastReflection_Service) NewField(fd protoreflect.FieldDescriptor) proto return protoreflect.ValueOfString("") case "poktroll.shared.Service.compute_units_per_relay": return protoreflect.ValueOfUint64(uint64(0)) + case "poktroll.shared.Service.owner_address": + return protoreflect.ValueOfString("") default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.Service")) @@ -329,6 +351,10 @@ func (x *fastReflection_Service) ProtoMethods() *protoiface.Methods { if x.ComputeUnitsPerRelay != 0 { n += 1 + runtime.Sov(uint64(x.ComputeUnitsPerRelay)) } + l = len(x.OwnerAddress) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -358,6 +384,13 @@ func (x *fastReflection_Service) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if len(x.OwnerAddress) > 0 { + i -= len(x.OwnerAddress) + copy(dAtA[i:], x.OwnerAddress) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.OwnerAddress))) + i-- + dAtA[i] = 0x22 + } if x.ComputeUnitsPerRelay != 0 { i = runtime.EncodeVarint(dAtA, i, uint64(x.ComputeUnitsPerRelay)) i-- @@ -509,6 +542,38 @@ func (x *fastReflection_Service) ProtoMethods() *protoiface.Methods { break } } + case 4: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field OwnerAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.OwnerAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -2758,6 +2823,11 @@ type Service struct { Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // (Optional) Semantic human readable name for the service // Used alongside the global 'compute_units_to_tokens_multipler' to calculate the cost of a relay for this service ComputeUnitsPerRelay uint64 `protobuf:"varint,3,opt,name=compute_units_per_relay,json=computeUnitsPerRelay,proto3" json:"compute_units_per_relay,omitempty"` // Compute units required per relay for this service + // The owner address that created the service. + // It is the address that receives rewards based on the Service's on-chain usage + // It is the only address that can update the service configuration (e.g. compute_units_per_relay), + // or make other updates to it. + OwnerAddress string `protobuf:"bytes,4,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` // The Bech32 address of the service owner / creator } func (x *Service) Reset() { @@ -2801,6 +2871,13 @@ func (x *Service) GetComputeUnitsPerRelay() uint64 { return 0 } +func (x *Service) GetOwnerAddress() string { + if x != nil { + return x.OwnerAddress + } + return "" +} + // ApplicationServiceConfig holds the service configuration the application stakes for type ApplicationServiceConfig struct { state protoimpl.MessageState @@ -2983,60 +3060,66 @@ var file_poktroll_shared_service_proto_rawDesc = []byte{ 0x0a, 0x1d, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, - 0x22, 0x64, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, - 0x35, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x5f, 0x75, 0x6e, 0x69, 0x74, 0x73, - 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x14, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x55, 0x6e, 0x69, 0x74, 0x73, 0x50, 0x65, - 0x72, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x22, 0x4e, 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, 0x8c, 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, 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, + 0x1a, 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa3, 0x01, 0x0a, 0x07, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x35, 0x0a, 0x17, 0x63, + 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x5f, 0x75, 0x6e, 0x69, 0x74, 0x73, 0x5f, 0x70, 0x65, 0x72, + 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x14, 0x63, 0x6f, + 0x6d, 0x70, 0x75, 0x74, 0x65, 0x55, 0x6e, 0x69, 0x74, 0x73, 0x50, 0x65, 0x72, 0x52, 0x65, 0x6c, + 0x61, 0x79, 0x12, 0x3d, 0x0a, 0x0d, 0x6f, 0x77, 0x6e, 0x65, 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, 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, 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, + 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x22, 0x8c, 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, + 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, 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, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 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, 0xa2, 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, + 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, 0xa2, 0x01, 0x0a, + 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, + 0x61, 0x72, 0x65, 0x64, 0x42, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, + 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, + 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x0f, 0x50, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0xca, 0x02, + 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, + 0xe2, 0x02, 0x1b, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, + 0x65, 0x64, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, + 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x68, 0x61, 0x72, 0x65, + 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/poktroll/service/tx.proto b/proto/poktroll/service/tx.proto index 2cd44a288..77f638d58 100644 --- a/proto/poktroll/service/tx.proto +++ b/proto/poktroll/service/tx.proto @@ -44,9 +44,9 @@ message MsgUpdateParamsResponse {} // permissionless. // TODO_BETA: Add Champions / Sources once its fully defined. message MsgAddService { - option (cosmos.msg.v1.signer) = "address"; // https://docs.cosmos.network/main/build/building-modules/messages-and-queries - string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the service supplier using cosmos' ScalarDescriptor - poktroll.shared.Service service = 2 [(gogoproto.nullable) = false]; // The Service for which the supplier is adding to the network + option (cosmos.msg.v1.signer) = "owner_address"; // https://docs.cosmos.network/main/build/building-modules/messages-and-queries + string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the service owner using cosmos' ScalarDescriptor + poktroll.shared.Service service = 2 [(gogoproto.nullable) = false]; // The Service being added to the network } message MsgAddServiceResponse {} diff --git a/proto/poktroll/shared/service.proto b/proto/poktroll/shared/service.proto index 9a80732dc..b0f32bdc3 100644 --- a/proto/poktroll/shared/service.proto +++ b/proto/poktroll/shared/service.proto @@ -4,6 +4,8 @@ syntax = "proto3"; // but rather a manually created package to resolve circular type dependencies. package poktroll.shared; +import "cosmos_proto/cosmos.proto"; + option go_package = "github.com/pokt-network/poktroll/x/shared/types"; // Service message to encapsulate unique and semantic identifiers for a service on the network @@ -16,6 +18,12 @@ message Service { // Used alongside the global 'compute_units_to_tokens_multipler' to calculate the cost of a relay for this service uint64 compute_units_per_relay = 3; // Compute units required per relay for this service + + // The owner address that created the service. + // It is the address that receives rewards based on the Service's on-chain usage + // It is the only address that can update the service configuration (e.g. compute_units_per_relay), + // or make other updates to it. + string owner_address = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the service owner / creator } // ApplicationServiceConfig holds the service configuration the application stakes for diff --git a/proto/poktroll/shared/tx.proto b/proto/poktroll/shared/tx.proto index 12f0bd6dd..5c2e4d7df 100644 --- a/proto/poktroll/shared/tx.proto +++ b/proto/poktroll/shared/tx.proto @@ -13,7 +13,7 @@ option go_package = "github.com/pokt-network/poktroll/x/shared/types"; // Msg defines the Msg service. service Msg { option (cosmos.msg.v1.service) = true; - + // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. rpc UpdateParams (MsgUpdateParams) returns (MsgUpdateParamsResponse); @@ -23,12 +23,12 @@ service Msg { message MsgUpdateParams { option (cosmos.msg.v1.signer) = "authority"; option (amino.name) = "poktroll/x/shared/MsgUpdateParams"; - + // authority is the address that controls the module (defaults to x/gov unless overwritten). string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // params defines the module parameters to update. - + // NOTE: All parameters must be supplied. Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } diff --git a/x/service/keeper/msg_server_add_service.go b/x/service/keeper/msg_server_add_service.go index c098e219f..4df23b94b 100644 --- a/x/service/keeper/msg_server_add_service.go +++ b/x/service/keeper/msg_server_add_service.go @@ -38,26 +38,33 @@ func (k msgServer) AddService( } // Check if the service already exists or not. - if _, found := k.GetService(ctx, msg.Service.Id); found { - logger.Error(fmt.Sprintf("Service already exists: %v", msg.Service)) + foundService, found := k.GetService(ctx, msg.Service.Id) + if found { + if foundService.OwnerAddress != msg.Service.OwnerAddress { + logger.Error(fmt.Sprintf("Owner address of existing service (%q) does not match the owner address %q", foundService.OwnerAddress, msg.OwnerAddress)) + return nil, types.ErrServiceInvalidOwnerAddress.Wrapf( + "existing owner address %q does not match the new owner address %q", + foundService.OwnerAddress, msg.Service.OwnerAddress, + ) + } return nil, types.ErrServiceAlreadyExists.Wrapf( - "duplicate service ID: %s", msg.Service.Id, + "TODO(@adshmh): This is an ephemeral state of the code. Once we s/AddService/UpdateService/g, add the business logic here for updates here.", ) } - // Retrieve the address of the actor adding the service. - accAddr, err := sdk.AccAddressFromBech32(msg.Address) + // Retrieve the address of the actor adding the service; the owner of the service. + serviceOwnerAddr, err := sdk.AccAddressFromBech32(msg.OwnerAddress) if err != nil { - logger.Error(fmt.Sprintf("could not parse address %s", msg.Address)) + logger.Error(fmt.Sprintf("could not parse address %s", msg.OwnerAddress)) return nil, types.ErrServiceInvalidAddress.Wrapf( - "%s is not in Bech32 format", msg.Address, + "%s is not in Bech32 format", msg.OwnerAddress, ) } // Check the actor has sufficient funds to pay for the add service fee. - accCoins := k.bankKeeper.SpendableCoins(ctx, accAddr) + accCoins := k.bankKeeper.SpendableCoins(ctx, serviceOwnerAddr) if accCoins.Len() == 0 { - logger.Error(fmt.Sprintf("%s doesn't have any funds to add service: %v", msg.Address, err)) + logger.Error(fmt.Sprintf("%s doesn't have any funds to add service: %v", serviceOwnerAddr, err)) return nil, types.ErrServiceNotEnoughFunds.Wrapf( "account has no spendable coins", ) @@ -67,7 +74,7 @@ func (k msgServer) AddService( accBalance := accCoins.AmountOf("upokt") addServiceFee := math.NewIntFromUint64(k.GetParams(ctx).AddServiceFee) if accBalance.LTE(addServiceFee) { - logger.Error(fmt.Sprintf("%s doesn't have enough funds to add service: %v", msg.Address, err)) + logger.Error(fmt.Sprintf("%s doesn't have enough funds to add service: %v", serviceOwnerAddr, err)) return nil, types.ErrServiceNotEnoughFunds.Wrapf( "account has %d uPOKT, but the service fee is %d uPOKT", accBalance.Uint64(), k.GetParams(ctx).AddServiceFee, @@ -76,7 +83,7 @@ func (k msgServer) AddService( // Deduct the service fee from the actor's balance. serviceFee := sdk.Coins{sdk.NewCoin("upokt", addServiceFee)} - err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, accAddr, types.ModuleName, serviceFee) + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, serviceOwnerAddr, types.ModuleName, serviceFee) if err != nil { logger.Error(fmt.Sprintf("Failed to deduct service fee from actor's balance: %v", err)) return nil, types.ErrServiceFailedToDeductFee.Wrapf( diff --git a/x/service/keeper/msg_server_add_service_test.go b/x/service/keeper/msg_server_add_service_test.go index 961fb9912..962689710 100644 --- a/x/service/keeper/msg_server_add_service_test.go +++ b/x/service/keeper/msg_server_add_service_test.go @@ -19,39 +19,39 @@ func TestMsgServer_AddService(t *testing.T) { k, ctx := keepertest.ServiceKeeper(t) srv := keeper.NewMsgServerImpl(k) - // Declare test services - svc1 := sharedtypes.Service{ - Id: "svc1", - Name: "service 1", + oldServiceOwnerAddr := sample.AccAddress() + newServiceOwnerAddr := sample.AccAddress() + + // Pre-existing service + oldService := sharedtypes.Service{ + Id: "svc0", + Name: "service 0", ComputeUnitsPerRelay: 1, + OwnerAddress: oldServiceOwnerAddr, } - preExistingService := sharedtypes.Service{ - Id: "svc2", - Name: "service 2", + // Declare new test service to be added + newService := sharedtypes.Service{ + Id: "svc1", + Name: "service 1", ComputeUnitsPerRelay: 1, + OwnerAddress: newServiceOwnerAddr, } - // Generate a valid address - addr := sample.AccAddress() - // Mock adding a balance to the account - keepertest.AddAccToAccMapCoins(t, addr, "upokt", oneUPOKTGreaterThanFee) + keepertest.AddAccToAccMapCoins(t, oldServiceOwnerAddr, "upokt", oneUPOKTGreaterThanFee) // Add the service to the store _, err := srv.AddService(ctx, &types.MsgAddService{ - Address: addr, - Service: preExistingService, + OwnerAddress: oldServiceOwnerAddr, + Service: oldService, }) require.NoError(t, err) // Validate the service was added - serviceFound, found := k.GetService(ctx, preExistingService.Id) + serviceFound, found := k.GetService(ctx, oldService.Id) require.True(t, found) - require.Equal(t, preExistingService, serviceFound) - - validAddr1 := sample.AccAddress() - validAddr2 := sample.AccAddress() + require.Equal(t, oldService, serviceFound) tests := []struct { desc string @@ -64,14 +64,14 @@ func TestMsgServer_AddService(t *testing.T) { desc: "valid - service added successfully", setup: func(t *testing.T) { // Add 10000000001 upokt to the account - keepertest.AddAccToAccMapCoins(t, validAddr1, "upokt", oneUPOKTGreaterThanFee) + keepertest.AddAccToAccMapCoins(t, newServiceOwnerAddr, "upokt", oneUPOKTGreaterThanFee) }, - address: validAddr1, - service: svc1, + address: newServiceOwnerAddr, + service: newService, expectedErr: nil, }, { - desc: "invalid - service supplier address is empty", + desc: "invalid - service owner address is empty", setup: func(t *testing.T) {}, address: "", // explicitly set to empty string service: sharedtypes.Service{ @@ -81,122 +81,122 @@ func TestMsgServer_AddService(t *testing.T) { expectedErr: types.ErrServiceInvalidAddress, }, { - desc: "invalid - invalid service supplier address", + desc: "invalid - invalid service owner address", setup: func(t *testing.T) {}, address: "invalid address", - service: svc1, + service: newService, expectedErr: types.ErrServiceInvalidAddress, }, { desc: "invalid - missing service ID", setup: func(t *testing.T) {}, - address: sample.AccAddress(), + address: newServiceOwnerAddr, service: sharedtypes.Service{ // Explicitly omitting Id field - Name: "service 1", + Name: "service 1", + OwnerAddress: newServiceOwnerAddr, }, expectedErr: types.ErrServiceMissingID, }, { desc: "invalid - empty service ID", setup: func(t *testing.T) {}, - address: sample.AccAddress(), + address: newServiceOwnerAddr, service: sharedtypes.Service{ - Id: "", // explicitly set to empty string - Name: "service 1", + Id: "", // explicitly set to empty string + Name: "service 1", + OwnerAddress: newServiceOwnerAddr, }, expectedErr: types.ErrServiceMissingID, }, { desc: "invalid - missing service name", setup: func(t *testing.T) {}, - address: sample.AccAddress(), + address: newServiceOwnerAddr, service: sharedtypes.Service{ Id: "svc1", // Explicitly omitting Name field + OwnerAddress: newServiceOwnerAddr, }, expectedErr: types.ErrServiceMissingName, }, { desc: "invalid - empty service name", setup: func(t *testing.T) {}, - address: sample.AccAddress(), + address: newServiceOwnerAddr, service: sharedtypes.Service{ - Id: "svc1", - Name: "", // explicitly set to empty string + Id: "svc1", + Name: "", // explicitly set to empty string + OwnerAddress: newServiceOwnerAddr, }, expectedErr: types.ErrServiceMissingName, }, { desc: "invalid - zero compute units per relay", setup: func(t *testing.T) {}, - address: sample.AccAddress(), + address: newServiceOwnerAddr, service: sharedtypes.Service{ Id: "svc1", Name: "service 1", ComputeUnitsPerRelay: 0, }, - expectedErr: types.ErrServiceInvalidComputUnitsPerRelay, - }, - { - desc: "invalid - service already exists (same service supplier)", - setup: func(t *testing.T) {}, - address: addr, - service: preExistingService, - expectedErr: types.ErrServiceAlreadyExists, - }, - { - desc: "invalid - service already exists (different service supplier)", - setup: func(t *testing.T) {}, - address: sample.AccAddress(), - service: preExistingService, - expectedErr: types.ErrServiceAlreadyExists, + expectedErr: types.ErrServiceInvalidComputeUnitsPerRelay, }, { desc: "invalid - no spendable coins", setup: func(t *testing.T) {}, - address: sample.AccAddress(), - service: svc1, + address: newServiceOwnerAddr, + service: newService, expectedErr: types.ErrServiceNotEnoughFunds, }, { desc: "invalid - insufficient upokt balance", setup: func(t *testing.T) { // Add 999999999 upokt to the account (one less than AddServiceFee) - keepertest.AddAccToAccMapCoins(t, validAddr2, "upokt", oneUPOKTGreaterThanFee-2) + keepertest.AddAccToAccMapCoins(t, newServiceOwnerAddr, "upokt", oneUPOKTGreaterThanFee-2) }, - address: validAddr2, - service: svc1, + address: newServiceOwnerAddr, + service: newService, expectedErr: types.ErrServiceNotEnoughFunds, }, { desc: "invalid - account has exactly AddServiceFee", setup: func(t *testing.T) { // Add the exact fee in upokt to the account - keepertest.AddAccToAccMapCoins(t, validAddr2, "upokt", types.DefaultAddServiceFee) + keepertest.AddAccToAccMapCoins(t, newServiceOwnerAddr, "upokt", types.DefaultAddServiceFee) }, - address: validAddr2, - service: svc1, + address: newServiceOwnerAddr, + service: newService, expectedErr: types.ErrServiceNotEnoughFunds, }, { desc: "invalid - sufficient balance of different denom", setup: func(t *testing.T) { // Adds 10000000001 wrong coins to the account - keepertest.AddAccToAccMapCoins(t, validAddr2, "wrong", oneUPOKTGreaterThanFee) + keepertest.AddAccToAccMapCoins(t, newServiceOwnerAddr, "not_upokt", oneUPOKTGreaterThanFee) }, - address: validAddr2, - service: svc1, + address: newServiceOwnerAddr, + service: newService, expectedErr: types.ErrServiceNotEnoughFunds, }, + { + desc: "invalid - existing service owner address does match new service address", + setup: func(t *testing.T) {}, + address: newServiceOwnerAddr, + service: oldService, + expectedErr: types.ErrServiceInvalidOwnerAddress, + }, + // { + // desc: "TODO(@adshmh): valid - update compute_units_pre_relay if the owner is correct", + // }, } for _, test := range tests { t.Run(test.desc, func(t *testing.T) { test.setup(t) _, err := srv.AddService(ctx, &types.MsgAddService{ - Address: test.address, - Service: test.service, + OwnerAddress: test.address, + Service: test.service, }) if test.expectedErr != nil { // Using ErrorAs as wrapping the error sometimes gives errors with ErrorIs diff --git a/x/service/module/tx_add_service.go b/x/service/module/tx_add_service.go index 435d47c88..3fe8cd4a3 100644 --- a/x/service/module/tx_add_service.go +++ b/x/service/module/tx_add_service.go @@ -42,14 +42,15 @@ $ 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.ErrServiceInvalidComputUnitsPerRelay.Wrapf("unable to parse as uint64: %s", args[2]) + return types.ErrServiceInvalidComputeUnitsPerRelay.Wrapf("unable to parse as uint64: %s", args[2]) } } else { fmt.Printf("Using default compute_units_per_relay: %d\n", types.DefaultComputeUnitsPerRelay) } + serviceOwnerAddress := clientCtx.GetFromAddress().String() msg := types.NewMsgAddService( - clientCtx.GetFromAddress().String(), + serviceOwnerAddress, serviceIdStr, serviceNameStr, computeUnitsPerRelay, diff --git a/x/service/module/tx_add_service_test.go b/x/service/module/tx_add_service_test.go index 4c2d4dd60..575f19d6b 100644 --- a/x/service/module/tx_add_service_test.go +++ b/x/service/module/tx_add_service_test.go @@ -74,19 +74,19 @@ func TestCLI_AddService(t *testing.T) { require.NoError(t, err) tests := []struct { - desc string - supplierAddress string - service sharedtypes.Service - expectedErr *sdkerrors.Error + desc string + ownerAddress string + service sharedtypes.Service + expectedErr *sdkerrors.Error }{ { - desc: "valid - add new service", - supplierAddress: account.Address.String(), - service: svc1, + desc: "valid - add new service", + ownerAddress: account.Address.String(), + service: svc1, }, { - desc: "valid - add new service without specifying compute units per relay so that it uses the default", - supplierAddress: account.Address.String(), + desc: "valid - add new service without specifying compute units per relay so that it uses the default", + ownerAddress: account.Address.String(), service: sharedtypes.Service{ Id: svc1.Id, Name: svc1.Name, @@ -94,28 +94,28 @@ func TestCLI_AddService(t *testing.T) { }, }, { - desc: "invalid - missing service id", - supplierAddress: account.Address.String(), - service: sharedtypes.Service{Name: "service name"}, // ID intentionally omitted - expectedErr: types.ErrServiceMissingID, + desc: "invalid - missing service id", + ownerAddress: account.Address.String(), + service: sharedtypes.Service{Name: "service name"}, // ID intentionally omitted + expectedErr: types.ErrServiceMissingID, }, { - desc: "invalid - missing service name", - supplierAddress: account.Address.String(), - service: sharedtypes.Service{Id: "svc1"}, // Name intentionally omitted - expectedErr: types.ErrServiceMissingName, + desc: "invalid - missing service name", + ownerAddress: account.Address.String(), + service: sharedtypes.Service{Id: "svc1"}, // Name intentionally omitted + expectedErr: types.ErrServiceMissingName, }, { - desc: "invalid - invalid supplier address", - supplierAddress: "invalid address", - service: svc1, - expectedErr: types.ErrServiceInvalidAddress, + desc: "invalid - invalid owner address", + ownerAddress: "invalid address", + service: svc1, + expectedErr: types.ErrServiceInvalidAddress, }, { - desc: "invalid - service already staked", - supplierAddress: account.Address.String(), - service: svc2, - expectedErr: types.ErrServiceAlreadyExists, + desc: "invalid - service already staked", + ownerAddress: account.Address.String(), + service: svc2, + expectedErr: types.ErrServiceAlreadyExists, }, } @@ -134,7 +134,7 @@ func TestCLI_AddService(t *testing.T) { // Only include compute units per relay argument if provided argsAndFlags = append(argsAndFlags, strconv.FormatUint(test.service.ComputeUnitsPerRelay, 10)) } - argsAndFlags = append(argsAndFlags, fmt.Sprintf("--%s=%s", flags.FlagFrom, test.supplierAddress)) + argsAndFlags = append(argsAndFlags, fmt.Sprintf("--%s=%s", flags.FlagFrom, test.ownerAddress)) args := append(argsAndFlags, commonArgs...) diff --git a/x/service/simulation/add_service.go b/x/service/simulation/add_service.go index d7647d639..dc9a13c30 100644 --- a/x/service/simulation/add_service.go +++ b/x/service/simulation/add_service.go @@ -20,7 +20,7 @@ func SimulateMsgAddService( ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { simAccount, _ := simtypes.RandomAcc(r, accs) msg := &types.MsgAddService{ - Address: simAccount.Address.String(), + OwnerAddress: simAccount.Address.String(), } // TODO: Handling the AddService simulation diff --git a/x/service/types/errors.go b/x/service/types/errors.go index 862ae0edc..d0c52965a 100644 --- a/x/service/types/errors.go +++ b/x/service/types/errors.go @@ -6,17 +6,18 @@ 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") - ErrServiceInvalidComputUnitsPerRelay = sdkerrors.Register(ModuleName, 1112, "invalid compute units per relay") + 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") ) diff --git a/x/service/types/message_add_service.go b/x/service/types/message_add_service.go index d14ada7f4..09552f4df 100644 --- a/x/service/types/message_add_service.go +++ b/x/service/types/message_add_service.go @@ -2,7 +2,8 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/pokt-network/poktroll/x/shared/types" + + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) const ( @@ -15,21 +16,26 @@ const ( var _ sdk.Msg = (*MsgAddService)(nil) -func NewMsgAddService(address, serviceId, serviceName string, computeUnitsPerRelay uint64) *MsgAddService { +func NewMsgAddService(serviceOwnerAddr, serviceId, serviceName string, computeUnitsPerRelay uint64) *MsgAddService { return &MsgAddService{ - Address: address, - Service: *types.NewService( - serviceId, - serviceName, - computeUnitsPerRelay, - ), + OwnerAddress: serviceOwnerAddr, + Service: sharedtypes.Service{ + Id: serviceId, + Name: serviceName, + ComputeUnitsPerRelay: computeUnitsPerRelay, + OwnerAddress: serviceOwnerAddr, + }, } } // ValidateBasic performs basic validation of the message and its fields func (msg *MsgAddService) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Address); err != nil { - return ErrServiceInvalidAddress.Wrapf("invalid supplier address %s; (%v)", msg.Address, err) + if _, err := sdk.AccAddressFromBech32(msg.OwnerAddress); err != nil { + return ErrServiceInvalidAddress.Wrapf("invalid signer address %s; (%v)", msg.OwnerAddress, err) + } + // Ensure that the signer of the add_service message is the owner of the service. + 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 == "" { @@ -47,9 +53,9 @@ func (msg *MsgAddService) ValidateBasic() error { // ValidateComputeUnitsPerRelay makes sure the compute units per relay is a valid value func ValidateComputeUnitsPerRelay(computeUnitsPerRelay uint64) error { if computeUnitsPerRelay == 0 { - return ErrServiceInvalidComputUnitsPerRelay.Wrap("compute units per relay must be greater than 0") + return ErrServiceInvalidComputeUnitsPerRelay.Wrap("compute units per relay must be greater than 0") } else if computeUnitsPerRelay > ComputeUnitsPerRelayMax { - return ErrServiceInvalidComputUnitsPerRelay.Wrapf("compute units per relay must be less than %d", ComputeUnitsPerRelayMax) + return ErrServiceInvalidComputeUnitsPerRelay.Wrapf("compute units per relay must be less than %d", ComputeUnitsPerRelayMax) } return nil } diff --git a/x/service/types/message_add_service_test.go b/x/service/types/message_add_service_test.go index b187ea89f..fc4a7b107 100644 --- a/x/service/types/message_add_service_test.go +++ b/x/service/types/message_add_service_test.go @@ -10,44 +10,68 @@ import ( ) func TestMsgAddService_ValidateBasic(t *testing.T) { + serviceOwnerAddress := sample.AccAddress() tests := []struct { desc string msg MsgAddService expectedErr error }{ { - desc: "invalid service supplier address - no service", + desc: "invalid service owner address - no service", msg: MsgAddService{ - Address: "invalid_address", + OwnerAddress: "invalid_address", // Service: intentionally omitted, }, expectedErr: ErrServiceInvalidAddress, }, { - desc: "valid service supplier address - no service ID", + desc: "valid service owner address - no service ID", msg: MsgAddService{ - Address: sample.AccAddress(), - Service: sharedtypes.Service{Name: "service name"}, // ID intentionally omitted + OwnerAddress: serviceOwnerAddress, + Service: sharedtypes.Service{Name: "service name", OwnerAddress: serviceOwnerAddress}, // ID intentionally omitted }, expectedErr: ErrServiceMissingID, }, { - desc: "valid service supplier address - no service name", + desc: "valid service owner address - no service name", msg: MsgAddService{ - Address: sample.AccAddress(), - Service: sharedtypes.Service{Id: "svc1"}, // Name intentionally omitted + OwnerAddress: serviceOwnerAddress, + Service: sharedtypes.Service{Id: "svc1", OwnerAddress: serviceOwnerAddress}, // Name intentionally omitted }, expectedErr: ErrServiceMissingName, }, { - desc: "valid service supplier address - zero compute units per relay", + desc: "valid service owner address - zero compute units per relay", msg: MsgAddService{ - Address: sample.AccAddress(), - Service: sharedtypes.Service{Id: "svc1", Name: "service name", ComputeUnitsPerRelay: 0}, + OwnerAddress: serviceOwnerAddress, + Service: sharedtypes.Service{ + Id: "svc1", + Name: "service name", + ComputeUnitsPerRelay: 0, + OwnerAddress: serviceOwnerAddress, + }, }, - expectedErr: ErrServiceInvalidComputUnitsPerRelay, + expectedErr: ErrServiceInvalidComputeUnitsPerRelay, }, { - desc: "valid service supplier address and service", + desc: "signer address does not equal service owner address", msg: MsgAddService{ - Address: sample.AccAddress(), - Service: sharedtypes.Service{Id: "svc1", Name: "service name", ComputeUnitsPerRelay: 1}, + OwnerAddress: serviceOwnerAddress, + Service: sharedtypes.Service{ + Id: "svc1", + Name: "service name", + ComputeUnitsPerRelay: 1, + OwnerAddress: sample.AccAddress(), // Random address that does not equal serviceOwnerAddress + }, + }, + expectedErr: ErrServiceInvalidOwnerAddress, + }, + { + desc: "valid msg add service", + msg: MsgAddService{ + OwnerAddress: serviceOwnerAddress, + Service: sharedtypes.Service{ + Id: "svc1", + Name: "service name", + ComputeUnitsPerRelay: 1, + OwnerAddress: serviceOwnerAddress, + }, }, expectedErr: nil, }, @@ -73,7 +97,7 @@ func TestValidateComputeUnitsPerRelay(t *testing.T) { { desc: "zero compute units per relay", computeUnitsPerRelay: 0, - expectedErr: ErrServiceInvalidComputUnitsPerRelay, + expectedErr: ErrServiceInvalidComputeUnitsPerRelay, }, { desc: "valid compute units per relay", computeUnitsPerRelay: 1, @@ -85,7 +109,7 @@ func TestValidateComputeUnitsPerRelay(t *testing.T) { }, { desc: "compute units per relay greater than max", computeUnitsPerRelay: ComputeUnitsPerRelayMax + 1, - expectedErr: ErrServiceInvalidComputUnitsPerRelay, + expectedErr: ErrServiceInvalidComputeUnitsPerRelay, }, } for _, test := range tests { diff --git a/x/service/types/tx.pb.go b/x/service/types/tx.pb.go index 9fed7d7e2..cc1c369db 100644 --- a/x/service/types/tx.pb.go +++ b/x/service/types/tx.pb.go @@ -131,8 +131,8 @@ var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo // permissionless. // TODO_BETA: Add Champions / Sources once its fully defined. type MsgAddService struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - Service types.Service `protobuf:"bytes,2,opt,name=service,proto3" json:"service"` + OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` + Service types.Service `protobuf:"bytes,2,opt,name=service,proto3" json:"service"` } func (m *MsgAddService) Reset() { *m = MsgAddService{} } @@ -168,9 +168,9 @@ func (m *MsgAddService) XXX_DiscardUnknown() { var xxx_messageInfo_MsgAddService proto.InternalMessageInfo -func (m *MsgAddService) GetAddress() string { +func (m *MsgAddService) GetOwnerAddress() string { if m != nil { - return m.Address + return m.OwnerAddress } return "" } @@ -228,7 +228,7 @@ func init() { func init() { proto.RegisterFile("poktroll/service/tx.proto", fileDescriptor_31ba9559706e649e) } var fileDescriptor_31ba9559706e649e = []byte{ - // 438 bytes of a gzipped FileDescriptorProto + // 447 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0xc8, 0xcf, 0x2e, 0x29, 0xca, 0xcf, 0xc9, 0xd1, 0x2f, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0xd5, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x80, 0x49, 0xe9, 0x41, 0xa5, 0xa4, 0x04, 0x13, 0x73, @@ -244,19 +244,19 @@ var fileDescriptor_31ba9559706e649e = []byte{ 0x21, 0xa1, 0x07, 0xb1, 0xc1, 0x89, 0xf3, 0xc4, 0x3d, 0x79, 0x86, 0x15, 0xcf, 0x37, 0x68, 0x31, 0x06, 0x41, 0xb5, 0x58, 0x99, 0x36, 0x3d, 0xdf, 0xa0, 0x85, 0x30, 0xac, 0xeb, 0xf9, 0x06, 0x2d, 0x25, 0xb8, 0xd3, 0x2b, 0xe0, 0x7e, 0x43, 0x73, 0xab, 0x92, 0x24, 0x97, 0x38, 0x9a, 0x50, 0x50, - 0x6a, 0x71, 0x41, 0x7e, 0x5e, 0x71, 0xaa, 0x52, 0x37, 0x23, 0x17, 0xaf, 0x6f, 0x71, 0xba, 0x63, - 0x4a, 0x4a, 0x30, 0x44, 0xb3, 0x90, 0x11, 0x17, 0x7b, 0x22, 0xc4, 0xf1, 0x04, 0xbd, 0x05, 0x53, - 0x28, 0x64, 0xc1, 0xc5, 0x0e, 0xb5, 0x1b, 0x8b, 0xaf, 0xc0, 0x21, 0xaa, 0x07, 0x35, 0xde, 0x89, - 0x05, 0xe4, 0xab, 0x20, 0x98, 0x72, 0x2b, 0x1e, 0x90, 0x8f, 0x60, 0xe6, 0x28, 0x89, 0x73, 0x89, - 0xa2, 0x38, 0x06, 0xe6, 0x4c, 0xa3, 0x43, 0x8c, 0x5c, 0xcc, 0xbe, 0xc5, 0xe9, 0x42, 0x31, 0x5c, - 0x3c, 0x28, 0xb1, 0xa0, 0x88, 0x19, 0x7a, 0x68, 0x3e, 0x95, 0xd2, 0x24, 0xa8, 0x04, 0x66, 0x8b, - 0x50, 0x18, 0x17, 0x17, 0x52, 0x40, 0xc8, 0x63, 0xd5, 0x88, 0x50, 0x20, 0xa5, 0x4e, 0x40, 0x01, - 0xcc, 0x5c, 0x29, 0xd6, 0x06, 0x50, 0x2c, 0x3a, 0x79, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, - 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, - 0xb1, 0x1c, 0x43, 0x94, 0x41, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, - 0xc8, 0x4c, 0xdd, 0xbc, 0xd4, 0x92, 0xf2, 0xfc, 0xa2, 0x6c, 0x7d, 0x2c, 0x91, 0x5b, 0x52, 0x59, - 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x4e, 0x99, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x57, 0x39, - 0xa8, 0x07, 0x63, 0x03, 0x00, 0x00, + 0x6a, 0x71, 0x41, 0x7e, 0x5e, 0x71, 0xaa, 0xd2, 0x1c, 0x46, 0x2e, 0x5e, 0xdf, 0xe2, 0x74, 0xc7, + 0x94, 0x94, 0x60, 0x88, 0x66, 0x21, 0x5b, 0x2e, 0xde, 0xfc, 0xf2, 0xbc, 0xd4, 0xa2, 0xf8, 0x44, + 0x88, 0x17, 0x08, 0x7a, 0x8e, 0x07, 0xac, 0x1c, 0x2a, 0x26, 0x64, 0xc1, 0xc5, 0x0e, 0x75, 0x06, + 0x16, 0x0f, 0x82, 0x03, 0x57, 0x0f, 0x6a, 0x93, 0x13, 0x0b, 0xc8, 0x83, 0x41, 0x30, 0xe5, 0x56, + 0x42, 0x20, 0xcf, 0xa1, 0xda, 0xad, 0x24, 0xce, 0x25, 0x8a, 0xe2, 0x3a, 0x98, 0xbb, 0x8d, 0x0e, + 0x31, 0x72, 0x31, 0xfb, 0x16, 0xa7, 0x0b, 0xc5, 0x70, 0xf1, 0xa0, 0x44, 0x8b, 0x22, 0x66, 0x70, + 0xa2, 0x79, 0x5d, 0x4a, 0x93, 0xa0, 0x12, 0x98, 0x2d, 0x42, 0x61, 0x5c, 0x5c, 0x48, 0x21, 0x23, + 0x8f, 0x55, 0x23, 0x42, 0x81, 0x94, 0x3a, 0x01, 0x05, 0x30, 0x73, 0xa5, 0x58, 0x1b, 0x40, 0xd1, + 0xea, 0xe4, 0x75, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, + 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x06, 0xe9, 0x99, + 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x20, 0x33, 0x75, 0xf3, 0x52, 0x4b, 0xca, + 0xf3, 0x8b, 0xb2, 0xf5, 0xb1, 0xc4, 0x76, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0xa9, + 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x24, 0x8c, 0x9b, 0xaa, 0x74, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -472,10 +472,10 @@ func (m *MsgAddService) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x12 - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + if len(m.OwnerAddress) > 0 { + i -= len(m.OwnerAddress) + copy(dAtA[i:], m.OwnerAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.OwnerAddress))) i-- dAtA[i] = 0xa } @@ -546,7 +546,7 @@ func (m *MsgAddService) Size() (n int) { } var l int _ = l - l = len(m.Address) + l = len(m.OwnerAddress) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -766,7 +766,7 @@ func (m *MsgAddService) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field OwnerAddress", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -794,7 +794,7 @@ func (m *MsgAddService) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.OwnerAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { diff --git a/x/shared/types/service.go b/x/shared/types/service.go deleted file mode 100644 index e05aa2711..000000000 --- a/x/shared/types/service.go +++ /dev/null @@ -1,10 +0,0 @@ -package types - -// NewService creates a new Service instance -func NewService(id string, name string, computeUnitsPerRelay uint64) *Service { - return &Service{ - Id: id, - Name: name, - ComputeUnitsPerRelay: computeUnitsPerRelay, - } -} diff --git a/x/shared/types/service.pb.go b/x/shared/types/service.pb.go index 4a5a0201a..6de23f323 100644 --- a/x/shared/types/service.pb.go +++ b/x/shared/types/service.pb.go @@ -8,6 +8,7 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/cosmos-proto" proto "github.com/cosmos/gogoproto/proto" io "io" math "math" @@ -95,6 +96,11 @@ type Service struct { Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // Used alongside the global 'compute_units_to_tokens_multipler' to calculate the cost of a relay for this service ComputeUnitsPerRelay uint64 `protobuf:"varint,3,opt,name=compute_units_per_relay,json=computeUnitsPerRelay,proto3" json:"compute_units_per_relay,omitempty"` + // The owner address that created the service. + // It is the address that receives rewards based on the Service's on-chain usage + // It is the only address that can update the service configuration (e.g. compute_units_per_relay), + // or make other updates to it. + OwnerAddress string `protobuf:"bytes,4,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` } func (m *Service) Reset() { *m = Service{} } @@ -151,6 +157,13 @@ func (m *Service) GetComputeUnitsPerRelay() uint64 { return 0 } +func (m *Service) GetOwnerAddress() string { + if m != nil { + return m.OwnerAddress + } + return "" +} + // ApplicationServiceConfig holds the service configuration the application stakes for type ApplicationServiceConfig struct { Service *Service `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` @@ -376,38 +389,41 @@ func init() { func init() { proto.RegisterFile("poktroll/shared/service.proto", fileDescriptor_302c2f793a11ae1e) } var fileDescriptor_302c2f793a11ae1e = []byte{ - // 484 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0x4d, 0x6f, 0xd3, 0x40, - 0x10, 0xcd, 0xc6, 0x01, 0x27, 0x93, 0x36, 0xb5, 0x56, 0x45, 0xf8, 0x52, 0x2b, 0xe4, 0x14, 0x55, - 0x22, 0xa9, 0x52, 0x21, 0x8e, 0x88, 0x46, 0xa6, 0x0a, 0x11, 0x76, 0xb4, 0x76, 0xa8, 0xc4, 0xc5, - 0x72, 0xed, 0xa5, 0xb5, 0xe2, 0x78, 0x57, 0x6b, 0xbb, 0x90, 0xff, 0xc0, 0x01, 0xf1, 0xab, 0x38, - 0xf6, 0xc8, 0x11, 0x25, 0x7f, 0x04, 0xad, 0x3f, 0xf8, 0x68, 0x11, 0x17, 0x6e, 0x63, 0xbf, 0x37, - 0xef, 0xbd, 0x19, 0x7b, 0xe0, 0x88, 0xb3, 0x55, 0x26, 0x58, 0x1c, 0x8f, 0xd3, 0x6b, 0x5f, 0xd0, - 0x70, 0x9c, 0x52, 0x71, 0x13, 0x05, 0x74, 0xc4, 0x05, 0xcb, 0x18, 0x3e, 0xa8, 0xe1, 0x51, 0x09, - 0x0f, 0x42, 0x50, 0x9d, 0x92, 0x81, 0x7b, 0xd0, 0x8c, 0x42, 0x1d, 0xf5, 0xd1, 0xb0, 0x43, 0x9a, - 0x51, 0x88, 0x31, 0xb4, 0x12, 0x7f, 0x4d, 0xf5, 0x66, 0xf1, 0xa6, 0xa8, 0xf1, 0x33, 0x78, 0x1c, - 0xb0, 0x35, 0xcf, 0x33, 0xea, 0xe5, 0x49, 0x94, 0xa5, 0x1e, 0xa7, 0xc2, 0x13, 0x34, 0xf6, 0x37, - 0xba, 0xd2, 0x47, 0xc3, 0x16, 0x39, 0xac, 0xe0, 0xa5, 0x44, 0x17, 0x54, 0x10, 0x89, 0x0d, 0x2c, - 0xd0, 0x5f, 0x72, 0x1e, 0x47, 0x81, 0x9f, 0x45, 0x2c, 0xa9, 0x0c, 0xa7, 0x2c, 0x79, 0x1f, 0x5d, - 0xe1, 0x09, 0xa8, 0x55, 0xc6, 0xc2, 0xbb, 0x3b, 0xd1, 0x47, 0x77, 0x42, 0x8e, 0xaa, 0x06, 0x52, - 0x13, 0x07, 0x9f, 0x10, 0x3c, 0x72, 0x72, 0xa9, 0x48, 0xc5, 0x7f, 0xab, 0xe1, 0x17, 0xd0, 0xa1, - 0x49, 0xc8, 0x59, 0x94, 0x64, 0xa9, 0xde, 0xec, 0x2b, 0xc3, 0xee, 0xe4, 0xc9, 0xfd, 0xae, 0xca, - 0xce, 0xac, 0x98, 0xe4, 0x57, 0xcf, 0xe0, 0x0b, 0x02, 0xed, 0x2e, 0x8e, 0x35, 0x50, 0x72, 0x11, - 0x57, 0xfb, 0x94, 0x25, 0x3e, 0x85, 0xb6, 0xe0, 0x81, 0x97, 0x6d, 0x78, 0xb9, 0xd4, 0xde, 0x5f, - 0xc2, 0x91, 0xc5, 0xd4, 0xdd, 0x70, 0x4a, 0x54, 0xc1, 0x03, 0x59, 0xe0, 0xe7, 0xa0, 0x06, 0xc5, - 0x68, 0xa9, 0xae, 0x14, 0xd1, 0x8e, 0xee, 0xf5, 0x94, 0xa3, 0xdb, 0x5c, 0xee, 0x96, 0xd4, 0xec, - 0xc1, 0x5b, 0xd8, 0xfb, 0x1d, 0xc0, 0x27, 0xa0, 0xac, 0xe8, 0xa6, 0xc8, 0xd3, 0x9b, 0x18, 0xff, - 0x14, 0x49, 0x89, 0xa4, 0xe2, 0x43, 0x78, 0x70, 0xe3, 0xc7, 0x79, 0xfd, 0x07, 0x94, 0x0f, 0xc7, - 0x73, 0x50, 0xab, 0x90, 0xf8, 0x00, 0xba, 0x4b, 0x6b, 0x6e, 0xd9, 0x17, 0x96, 0x47, 0x16, 0x53, - 0xad, 0x81, 0xdb, 0xd0, 0x3a, 0x97, 0x15, 0xc2, 0xfb, 0xd0, 0xb9, 0x30, 0xcf, 0x1c, 0x7b, 0x3a, - 0x37, 0x5d, 0xad, 0x89, 0xf7, 0xa0, 0xfd, 0xda, 0xb1, 0x4b, 0x9a, 0x22, 0x69, 0xc4, 0x74, 0x5c, - 0xad, 0x75, 0x7c, 0x02, 0xfb, 0x7f, 0x18, 0x63, 0x0c, 0xbd, 0x5a, 0x72, 0x6a, 0x5b, 0xaf, 0x66, - 0xe7, 0x5a, 0x03, 0x77, 0x41, 0x75, 0x67, 0x6f, 0x4c, 0x7b, 0xe9, 0x6a, 0xe8, 0x6c, 0xf6, 0x75, - 0x6b, 0xa0, 0xdb, 0xad, 0x81, 0xbe, 0x6f, 0x0d, 0xf4, 0x79, 0x67, 0x34, 0x6e, 0x77, 0x46, 0xe3, - 0xdb, 0xce, 0x68, 0xbc, 0x1b, 0x5f, 0x45, 0xd9, 0x75, 0x7e, 0x39, 0x0a, 0xd8, 0x7a, 0x2c, 0xa7, - 0x7b, 0x9a, 0xd0, 0xec, 0x03, 0x13, 0xab, 0xf1, 0xcf, 0x93, 0xf8, 0x58, 0x1f, 0x85, 0xfc, 0x04, - 0xe9, 0xe5, 0xc3, 0xe2, 0x26, 0x4e, 0x7f, 0x04, 0x00, 0x00, 0xff, 0xff, 0xd2, 0xa4, 0x5d, 0x3a, - 0x34, 0x03, 0x00, 0x00, + // 542 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0xcd, 0x6e, 0xd3, 0x4c, + 0x14, 0x8d, 0xe3, 0x7c, 0x9f, 0x9b, 0x9b, 0x9f, 0x5a, 0xa3, 0x20, 0x0c, 0x52, 0xad, 0x90, 0x55, + 0x54, 0xa9, 0x71, 0x95, 0x0a, 0xb1, 0x42, 0xa8, 0x89, 0x42, 0x15, 0x22, 0xe2, 0x68, 0x9c, 0x50, + 0x89, 0x8d, 0xe5, 0xda, 0x43, 0x6a, 0xc5, 0xf1, 0x8c, 0xc6, 0x76, 0x4b, 0xde, 0x81, 0x05, 0xe2, + 0x15, 0x78, 0x05, 0x1e, 0x82, 0x65, 0xc5, 0x8a, 0x25, 0x4a, 0x5e, 0x04, 0x8d, 0x7f, 0xf8, 0x69, + 0x11, 0x1b, 0x76, 0x77, 0xe6, 0x9c, 0x7b, 0xe6, 0x1c, 0x5f, 0x5f, 0x38, 0x60, 0x74, 0x15, 0x73, + 0x1a, 0x04, 0x46, 0x74, 0xe9, 0x70, 0xe2, 0x19, 0x11, 0xe1, 0x57, 0xbe, 0x4b, 0x7a, 0x8c, 0xd3, + 0x98, 0xa2, 0xfd, 0x02, 0xee, 0x65, 0xf0, 0xc3, 0x07, 0x2e, 0x8d, 0xd6, 0x34, 0xb2, 0x53, 0xd8, + 0xc8, 0x0e, 0x19, 0xb7, 0xf3, 0x51, 0x02, 0xc5, 0xca, 0xba, 0x51, 0x13, 0xca, 0xbe, 0xa7, 0x49, + 0x6d, 0xa9, 0x5b, 0xc5, 0x65, 0xdf, 0x43, 0x08, 0x2a, 0xa1, 0xb3, 0x26, 0x5a, 0x39, 0xbd, 0x49, + 0x6b, 0xf4, 0x18, 0xee, 0xbb, 0x74, 0xcd, 0x92, 0x98, 0xd8, 0x49, 0xe8, 0xc7, 0x91, 0xcd, 0x08, + 0xb7, 0x39, 0x09, 0x9c, 0x8d, 0x26, 0xb7, 0xa5, 0x6e, 0x05, 0xb7, 0x72, 0x78, 0x21, 0xd0, 0x19, + 0xe1, 0x58, 0x60, 0xe8, 0x29, 0x34, 0xe8, 0x75, 0x48, 0xb8, 0xed, 0x78, 0x1e, 0x27, 0x51, 0xa4, + 0x55, 0x84, 0xe6, 0x40, 0xfb, 0xf2, 0xe9, 0xa8, 0x95, 0xfb, 0x39, 0xcd, 0x10, 0x2b, 0xe6, 0x7e, + 0xb8, 0xc4, 0xf5, 0x94, 0x9e, 0xdf, 0x75, 0xa6, 0xa0, 0x9d, 0x32, 0x16, 0xf8, 0xae, 0x13, 0xfb, + 0x34, 0xcc, 0xfd, 0x0e, 0x69, 0xf8, 0xc6, 0x5f, 0xa2, 0x3e, 0x28, 0x79, 0xfc, 0xd4, 0x7a, 0xad, + 0xaf, 0xf5, 0x6e, 0xe5, 0xef, 0xe5, 0x0d, 0xb8, 0x20, 0x76, 0xde, 0x49, 0x70, 0xcf, 0x4a, 0x84, + 0x22, 0xe1, 0xff, 0xac, 0x86, 0x9e, 0x41, 0x95, 0x84, 0x1e, 0xa3, 0x7e, 0x18, 0x47, 0x5a, 0xb9, + 0x2d, 0x77, 0x6b, 0xfd, 0x47, 0x77, 0xbb, 0xf2, 0xe7, 0x46, 0x39, 0x13, 0xff, 0xec, 0xe9, 0x7c, + 0x90, 0x40, 0xbd, 0x8d, 0x23, 0x15, 0xe4, 0x84, 0x07, 0xf9, 0x38, 0x44, 0x89, 0x4e, 0x60, 0x8f, + 0x33, 0xd7, 0x8e, 0x37, 0x2c, 0x9b, 0x49, 0xf3, 0x0f, 0xe6, 0xf0, 0x6c, 0x38, 0xdf, 0x30, 0x82, + 0x15, 0xce, 0x5c, 0x51, 0xa0, 0x27, 0xa0, 0xb8, 0x69, 0xb4, 0x48, 0x93, 0x53, 0x6b, 0x07, 0x77, + 0x7a, 0xb2, 0xe8, 0x26, 0x13, 0xdf, 0x16, 0x17, 0xec, 0xce, 0x2b, 0xa8, 0xff, 0x0a, 0xa0, 0x63, + 0x90, 0x57, 0x64, 0x93, 0xfa, 0x69, 0xf6, 0xf5, 0xbf, 0x8a, 0x44, 0x58, 0x50, 0x51, 0x0b, 0xfe, + 0xbb, 0x72, 0x82, 0xa4, 0xf8, 0x81, 0xb2, 0xc3, 0xe1, 0x04, 0x94, 0xdc, 0x24, 0xda, 0x87, 0xda, + 0x62, 0x3a, 0x99, 0x9a, 0xe7, 0x53, 0x1b, 0xcf, 0x86, 0x6a, 0x09, 0xed, 0x41, 0xe5, 0x4c, 0x54, + 0x12, 0x6a, 0x40, 0xf5, 0x7c, 0x34, 0xb0, 0xcc, 0xe1, 0x64, 0x34, 0x57, 0xcb, 0xa8, 0x0e, 0x7b, + 0x2f, 0x2c, 0x33, 0xa3, 0xc9, 0x82, 0x86, 0x47, 0xd6, 0x5c, 0xad, 0x1c, 0x1e, 0x43, 0xe3, 0xb7, + 0x87, 0x11, 0x82, 0x66, 0x21, 0x39, 0x34, 0xa7, 0xcf, 0xc7, 0x67, 0x6a, 0x09, 0xd5, 0x40, 0x99, + 0x8f, 0x5f, 0x8e, 0xcc, 0xc5, 0x5c, 0x95, 0x06, 0xe3, 0xcf, 0x5b, 0x5d, 0xba, 0xd9, 0xea, 0xd2, + 0xb7, 0xad, 0x2e, 0xbd, 0xdf, 0xe9, 0xa5, 0x9b, 0x9d, 0x5e, 0xfa, 0xba, 0xd3, 0x4b, 0xaf, 0x8d, + 0xa5, 0x1f, 0x5f, 0x26, 0x17, 0x3d, 0x97, 0xae, 0x0d, 0x91, 0xee, 0x28, 0x24, 0xf1, 0x35, 0xe5, + 0x2b, 0xe3, 0xc7, 0xb6, 0xbd, 0x2d, 0xf6, 0x4d, 0x8c, 0x20, 0xba, 0xf8, 0x3f, 0x5d, 0xa1, 0x93, + 0xef, 0x01, 0x00, 0x00, 0xff, 0xff, 0x03, 0x0b, 0xf3, 0xdc, 0x8f, 0x03, 0x00, 0x00, } func (m *Service) Marshal() (dAtA []byte, err error) { @@ -430,6 +446,13 @@ func (m *Service) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.OwnerAddress) > 0 { + i -= len(m.OwnerAddress) + copy(dAtA[i:], m.OwnerAddress) + i = encodeVarintService(dAtA, i, uint64(len(m.OwnerAddress))) + i-- + dAtA[i] = 0x22 + } if m.ComputeUnitsPerRelay != 0 { i = encodeVarintService(dAtA, i, uint64(m.ComputeUnitsPerRelay)) i-- @@ -648,6 +671,10 @@ func (m *Service) Size() (n int) { if m.ComputeUnitsPerRelay != 0 { n += 1 + sovService(uint64(m.ComputeUnitsPerRelay)) } + l = len(m.OwnerAddress) + if l > 0 { + n += 1 + l + sovService(uint64(l)) + } return n } @@ -839,6 +866,38 @@ func (m *Service) Unmarshal(dAtA []byte) error { break } } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OwnerAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OwnerAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipService(dAtA[iNdEx:]) diff --git a/x/tokenomics/keeper/settle_session_accounting_test.go b/x/tokenomics/keeper/settle_session_accounting_test.go index 6bcf240c0..8e55c77e9 100644 --- a/x/tokenomics/keeper/settle_session_accounting_test.go +++ b/x/tokenomics/keeper/settle_session_accounting_test.go @@ -33,11 +33,12 @@ func TestSettleSessionAccounting_HandleAppGoingIntoDebt(t *testing.T) { keepers, ctx := testkeeper.NewTokenomicsModuleKeepers(t, nil) // Create a service that can be registered in the application and used in the claims - service := sharedtypes.NewService( - "svc1", - "svcName1", - 1, - ) + service := &sharedtypes.Service{ + Id: "svc1", + Name: "svcName1", + ComputeUnitsPerRelay: 1, + OwnerAddress: sample.AccAddress(), + } // Add a new application appStake := cosmostypes.NewCoin("upokt", math.NewInt(1000000)) @@ -91,11 +92,12 @@ func TestSettleSessionAccounting_ValidAccounting(t *testing.T) { require.NoError(t, err) // Create a service that can be registered in the application and used in the claims - service := sharedtypes.NewService( - "svc1", - "svcName1", - 1, - ) + service := &sharedtypes.Service{ + Id: "svc1", + Name: "svcName1", + ComputeUnitsPerRelay: 1, + OwnerAddress: sample.AccAddress(), + } // Add a new application appStake := cosmostypes.NewCoin("upokt", math.NewInt(1000000)) // NB: Ensure a non-zero app stake end balance to assert against. @@ -196,11 +198,12 @@ func TestSettleSessionAccounting_AppStakeTooLow(t *testing.T) { require.NoError(t, err) // Create a service that can be registered in the application and used in the claims - service := sharedtypes.NewService( - "svc1", - "svcName1", - 1, - ) + service := &sharedtypes.Service{ + Id: "svc1", + Name: "svcName1", + ComputeUnitsPerRelay: 1, + OwnerAddress: sample.AccAddress(), + } // Add a new application appStake := cosmostypes.NewCoin("upokt", math.NewInt(40000)) expectedAppEndStakeZeroAmount := cosmostypes.NewCoin("upokt", math.NewInt(0)) @@ -307,11 +310,12 @@ func TestSettleSessionAccounting_AppStakeTooLow(t *testing.T) { func TestSettleSessionAccounting_AppNotFound(t *testing.T) { - service := sharedtypes.NewService( - "svc1", - "svcName1", - 1, - ) + service := &sharedtypes.Service{ + Id: "svc1", + Name: "svcName1", + ComputeUnitsPerRelay: 1, + OwnerAddress: sample.AccAddress(), + } keeper, ctx, _, supplierAddr := testkeeper.TokenomicsKeeperWithActorAddrs(t, service) @@ -338,11 +342,12 @@ func TestSettleSessionAccounting_AppNotFound(t *testing.T) { func TestSettleSessionAccounting_InvalidRoot(t *testing.T) { // Create a service that can be registered in the application and used in the claims - service := sharedtypes.NewService( - "svc1", - "svcName1", - 1, - ) + service := &sharedtypes.Service{ + Id: "svc1", + Name: "svcName1", + ComputeUnitsPerRelay: 1, + OwnerAddress: sample.AccAddress(), + } keeper, ctx, appAddr, supplierAddr := testkeeper.TokenomicsKeeperWithActorAddrs(t, service) @@ -413,13 +418,13 @@ func TestSettleSessionAccounting_InvalidRoot(t *testing.T) { } func TestSettleSessionAccounting_InvalidClaim(t *testing.T) { - // Create a service that can be registered in the application and used in the claims - service := sharedtypes.NewService( - "svc1", - "svcName1", - 1, - ) + service := &sharedtypes.Service{ + Id: "svc1", + Name: "svcName1", + ComputeUnitsPerRelay: 1, + OwnerAddress: sample.AccAddress(), + } keeper, ctx, appAddr, supplierAddr := testkeeper.TokenomicsKeeperWithActorAddrs(t, service)