From a18ba420dec0dd87ffc20dd0c5139e193cb46aab Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Tue, 30 Jul 2024 18:33:13 +0200 Subject: [PATCH 01/14] feat: Implement non-custodial staking --- api/poktroll/shared/supplier.pulsar.go | 190 ++++++--- api/poktroll/supplier/tx.pulsar.go | 391 ++++++++++++++---- .../tests/relays_stress_helpers_test.go | 1 + proto/poktroll/shared/supplier.proto | 18 +- proto/poktroll/supplier/tx.proto | 16 +- testutil/integration/app.go | 2 + testutil/keeper/tokenomics.go | 6 + x/shared/types/supplier.pb.go | 124 ++++-- x/supplier/config/errors.go | 1 + x/supplier/config/supplier_configs_reader.go | 28 +- .../keeper/msg_server_stake_supplier.go | 89 +++- .../keeper/msg_server_unstake_supplier.go | 10 + x/supplier/keeper/unbond_suppliers.go | 13 +- x/supplier/module/tx_stake_supplier.go | 19 +- x/supplier/module/tx_unstake_supplier.go | 12 +- x/supplier/types/message_stake_supplier.go | 15 +- x/supplier/types/message_unstake_supplier.go | 10 +- x/supplier/types/tx.pb.go | 242 +++++++++-- x/tokenomics/keeper/keeper.go | 2 + .../keeper/settle_session_accounting.go | 16 +- x/tokenomics/module/module.go | 6 + x/tokenomics/types/errors.go | 2 + x/tokenomics/types/expected_keepers.go | 2 +- x/tokenomics/types/tx.pb.go | 3 +- 24 files changed, 958 insertions(+), 260 deletions(-) diff --git a/api/poktroll/shared/supplier.pulsar.go b/api/poktroll/shared/supplier.pulsar.go index bc0dae789..2777fbbec 100644 --- a/api/poktroll/shared/supplier.pulsar.go +++ b/api/poktroll/shared/supplier.pulsar.go @@ -14,59 +14,60 @@ import ( sync "sync" ) -var _ protoreflect.List = (*_Supplier_3_list)(nil) +var _ protoreflect.List = (*_Supplier_4_list)(nil) -type _Supplier_3_list struct { +type _Supplier_4_list struct { list *[]*SupplierServiceConfig } -func (x *_Supplier_3_list) Len() int { +func (x *_Supplier_4_list) Len() int { if x.list == nil { return 0 } return len(*x.list) } -func (x *_Supplier_3_list) Get(i int) protoreflect.Value { +func (x *_Supplier_4_list) Get(i int) protoreflect.Value { return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) } -func (x *_Supplier_3_list) Set(i int, value protoreflect.Value) { +func (x *_Supplier_4_list) Set(i int, value protoreflect.Value) { valueUnwrapped := value.Message() concreteValue := valueUnwrapped.Interface().(*SupplierServiceConfig) (*x.list)[i] = concreteValue } -func (x *_Supplier_3_list) Append(value protoreflect.Value) { +func (x *_Supplier_4_list) Append(value protoreflect.Value) { valueUnwrapped := value.Message() concreteValue := valueUnwrapped.Interface().(*SupplierServiceConfig) *x.list = append(*x.list, concreteValue) } -func (x *_Supplier_3_list) AppendMutable() protoreflect.Value { +func (x *_Supplier_4_list) AppendMutable() protoreflect.Value { v := new(SupplierServiceConfig) *x.list = append(*x.list, v) return protoreflect.ValueOfMessage(v.ProtoReflect()) } -func (x *_Supplier_3_list) Truncate(n int) { +func (x *_Supplier_4_list) Truncate(n int) { for i := n; i < len(*x.list); i++ { (*x.list)[i] = nil } *x.list = (*x.list)[:n] } -func (x *_Supplier_3_list) NewElement() protoreflect.Value { +func (x *_Supplier_4_list) NewElement() protoreflect.Value { v := new(SupplierServiceConfig) return protoreflect.ValueOfMessage(v.ProtoReflect()) } -func (x *_Supplier_3_list) IsValid() bool { +func (x *_Supplier_4_list) IsValid() bool { return x.list != nil } var ( md_Supplier protoreflect.MessageDescriptor + fd_Supplier_owner_address protoreflect.FieldDescriptor fd_Supplier_address protoreflect.FieldDescriptor fd_Supplier_stake protoreflect.FieldDescriptor fd_Supplier_services protoreflect.FieldDescriptor @@ -76,6 +77,7 @@ var ( func init() { file_poktroll_shared_supplier_proto_init() md_Supplier = File_poktroll_shared_supplier_proto.Messages().ByName("Supplier") + fd_Supplier_owner_address = md_Supplier.Fields().ByName("owner_address") fd_Supplier_address = md_Supplier.Fields().ByName("address") fd_Supplier_stake = md_Supplier.Fields().ByName("stake") fd_Supplier_services = md_Supplier.Fields().ByName("services") @@ -147,6 +149,12 @@ func (x *fastReflection_Supplier) Interface() protoreflect.ProtoMessage { // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_Supplier) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.OwnerAddress != "" { + value := protoreflect.ValueOfString(x.OwnerAddress) + if !f(fd_Supplier_owner_address, value) { + return + } + } if x.Address != "" { value := protoreflect.ValueOfString(x.Address) if !f(fd_Supplier_address, value) { @@ -160,7 +168,7 @@ func (x *fastReflection_Supplier) Range(f func(protoreflect.FieldDescriptor, pro } } if len(x.Services) != 0 { - value := protoreflect.ValueOfList(&_Supplier_3_list{list: &x.Services}) + value := protoreflect.ValueOfList(&_Supplier_4_list{list: &x.Services}) if !f(fd_Supplier_services, value) { return } @@ -186,6 +194,8 @@ func (x *fastReflection_Supplier) Range(f func(protoreflect.FieldDescriptor, pro // a repeated field is populated if it is non-empty. func (x *fastReflection_Supplier) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { + case "poktroll.shared.Supplier.owner_address": + return x.OwnerAddress != "" case "poktroll.shared.Supplier.address": return x.Address != "" case "poktroll.shared.Supplier.stake": @@ -210,6 +220,8 @@ func (x *fastReflection_Supplier) Has(fd protoreflect.FieldDescriptor) bool { // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Supplier) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { + case "poktroll.shared.Supplier.owner_address": + x.OwnerAddress = "" case "poktroll.shared.Supplier.address": x.Address = "" case "poktroll.shared.Supplier.stake": @@ -234,6 +246,9 @@ func (x *fastReflection_Supplier) Clear(fd protoreflect.FieldDescriptor) { // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_Supplier) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { + case "poktroll.shared.Supplier.owner_address": + value := x.OwnerAddress + return protoreflect.ValueOfString(value) case "poktroll.shared.Supplier.address": value := x.Address return protoreflect.ValueOfString(value) @@ -242,9 +257,9 @@ func (x *fastReflection_Supplier) Get(descriptor protoreflect.FieldDescriptor) p return protoreflect.ValueOfMessage(value.ProtoReflect()) case "poktroll.shared.Supplier.services": if len(x.Services) == 0 { - return protoreflect.ValueOfList(&_Supplier_3_list{}) + return protoreflect.ValueOfList(&_Supplier_4_list{}) } - listValue := &_Supplier_3_list{list: &x.Services} + listValue := &_Supplier_4_list{list: &x.Services} return protoreflect.ValueOfList(listValue) case "poktroll.shared.Supplier.unstake_session_end_height": value := x.UnstakeSessionEndHeight @@ -269,13 +284,15 @@ func (x *fastReflection_Supplier) Get(descriptor protoreflect.FieldDescriptor) p // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Supplier) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { + case "poktroll.shared.Supplier.owner_address": + x.OwnerAddress = value.Interface().(string) case "poktroll.shared.Supplier.address": x.Address = value.Interface().(string) case "poktroll.shared.Supplier.stake": x.Stake = value.Message().Interface().(*v1beta1.Coin) case "poktroll.shared.Supplier.services": lv := value.List() - clv := lv.(*_Supplier_3_list) + clv := lv.(*_Supplier_4_list) x.Services = *clv.list case "poktroll.shared.Supplier.unstake_session_end_height": x.UnstakeSessionEndHeight = value.Uint() @@ -308,8 +325,10 @@ func (x *fastReflection_Supplier) Mutable(fd protoreflect.FieldDescriptor) proto if x.Services == nil { x.Services = []*SupplierServiceConfig{} } - value := &_Supplier_3_list{list: &x.Services} + value := &_Supplier_4_list{list: &x.Services} return protoreflect.ValueOfList(value) + case "poktroll.shared.Supplier.owner_address": + panic(fmt.Errorf("field owner_address of message poktroll.shared.Supplier is not mutable")) case "poktroll.shared.Supplier.address": panic(fmt.Errorf("field address of message poktroll.shared.Supplier is not mutable")) case "poktroll.shared.Supplier.unstake_session_end_height": @@ -327,6 +346,8 @@ func (x *fastReflection_Supplier) Mutable(fd protoreflect.FieldDescriptor) proto // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_Supplier) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "poktroll.shared.Supplier.owner_address": + return protoreflect.ValueOfString("") case "poktroll.shared.Supplier.address": return protoreflect.ValueOfString("") case "poktroll.shared.Supplier.stake": @@ -334,7 +355,7 @@ func (x *fastReflection_Supplier) NewField(fd protoreflect.FieldDescriptor) prot return protoreflect.ValueOfMessage(m.ProtoReflect()) case "poktroll.shared.Supplier.services": list := []*SupplierServiceConfig{} - return protoreflect.ValueOfList(&_Supplier_3_list{list: &list}) + return protoreflect.ValueOfList(&_Supplier_4_list{list: &list}) case "poktroll.shared.Supplier.unstake_session_end_height": return protoreflect.ValueOfUint64(uint64(0)) default: @@ -406,6 +427,10 @@ func (x *fastReflection_Supplier) ProtoMethods() *protoiface.Methods { var n int var l int _ = l + l = len(x.OwnerAddress) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } l = len(x.Address) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) @@ -455,7 +480,7 @@ func (x *fastReflection_Supplier) ProtoMethods() *protoiface.Methods { if x.UnstakeSessionEndHeight != 0 { i = runtime.EncodeVarint(dAtA, i, uint64(x.UnstakeSessionEndHeight)) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x28 } if len(x.Services) > 0 { for iNdEx := len(x.Services) - 1; iNdEx >= 0; iNdEx-- { @@ -470,7 +495,7 @@ func (x *fastReflection_Supplier) ProtoMethods() *protoiface.Methods { copy(dAtA[i:], encoded) i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } } if x.Stake != nil { @@ -485,13 +510,20 @@ func (x *fastReflection_Supplier) ProtoMethods() *protoiface.Methods { copy(dAtA[i:], encoded) i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } if len(x.Address) > 0 { i -= len(x.Address) copy(dAtA[i:], x.Address) i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Address))) i-- + dAtA[i] = 0x12 + } + 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 } if input.Buf != nil { @@ -544,6 +576,38 @@ func (x *fastReflection_Supplier) 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 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 + case 2: if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } @@ -575,7 +639,7 @@ func (x *fastReflection_Supplier) ProtoMethods() *protoiface.Methods { } x.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Stake", wireType) } @@ -611,7 +675,7 @@ func (x *fastReflection_Supplier) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Services", wireType) } @@ -645,7 +709,7 @@ func (x *fastReflection_Supplier) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex - case 4: + case 5: if wireType != 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field UnstakeSessionEndHeight", wireType) } @@ -718,12 +782,21 @@ type Supplier struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the supplier using cosmos' ScalarDescriptor to ensure deterministic encoding - Stake *v1beta1.Coin `protobuf:"bytes,2,opt,name=stake,proto3" json:"stake,omitempty"` // The total amount of uPOKT the supplier has staked - Services []*SupplierServiceConfig `protobuf:"bytes,3,rep,name=services,proto3" json:"services,omitempty"` // The service configs this supplier can support + // The Bech32 address of the owner (i.e. custodial, staker) using cosmos' + // ScalarDescriptor to ensure deterministic encoding. + // This is the address that owns the funds for staking and is the one that + // receives the rewards. + OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` + // The Bech32 address of the operator (i.e. provider, non-custodial) using cosmos' + // ScalarDescriptor to ensure deterministic encoding. + // The operator address can update all the supplier's configurations, excluding + // the owner_address. + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + Stake *v1beta1.Coin `protobuf:"bytes,3,opt,name=stake,proto3" json:"stake,omitempty"` // The total amount of uPOKT the supplier has staked + Services []*SupplierServiceConfig `protobuf:"bytes,4,rep,name=services,proto3" json:"services,omitempty"` // The service configs this supplier can support // The session end height at which an actively unbonding supplier unbonds its stake. // If the supplier did not unstake, this value will be 0. - UnstakeSessionEndHeight uint64 `protobuf:"varint,4,opt,name=unstake_session_end_height,json=unstakeSessionEndHeight,proto3" json:"unstake_session_end_height,omitempty"` + UnstakeSessionEndHeight uint64 `protobuf:"varint,5,opt,name=unstake_session_end_height,json=unstakeSessionEndHeight,proto3" json:"unstake_session_end_height,omitempty"` } func (x *Supplier) Reset() { @@ -746,6 +819,13 @@ func (*Supplier) Descriptor() ([]byte, []int) { return file_poktroll_shared_supplier_proto_rawDescGZIP(), []int{0} } +func (x *Supplier) GetOwnerAddress() string { + if x != nil { + return x.OwnerAddress + } + return "" +} + func (x *Supplier) GetAddress() string { if x != nil { return x.Address @@ -785,33 +865,37 @@ var file_poktroll_shared_supplier_proto_rawDesc = []byte{ 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x63, 0x6f, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 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, 0x22, 0xf0, 0x01, 0x0a, 0x08, - 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 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, 0x2f, 0x0a, 0x05, - 0x73, 0x74, 0x61, 0x6b, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x52, 0x05, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x12, 0x42, 0x0a, - 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x26, 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, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x12, 0x3b, 0x0a, 0x1a, 0x75, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x5f, 0x73, 0x65, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x17, 0x75, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x64, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x42, 0xa3, - 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, - 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x42, 0x0d, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, - 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, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xaf, 0x02, 0x0a, 0x08, + 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 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, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x18, 0x02, 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, 0x2f, 0x0a, 0x05, 0x73, + 0x74, 0x61, 0x6b, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x52, 0x05, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x12, 0x42, 0x0a, 0x08, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, + 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, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, + 0x12, 0x3b, 0x0a, 0x1a, 0x75, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x5f, 0x73, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x17, 0x75, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x64, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x42, 0xa3, 0x01, + 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, + 0x68, 0x61, 0x72, 0x65, 0x64, 0x42, 0x0d, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, + 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, + 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, + 0xca, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, + 0x65, 0x64, 0xe2, 0x02, 0x1b, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x68, + 0x61, 0x72, 0x65, 0x64, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0xea, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x68, 0x61, + 0x72, 0x65, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/poktroll/supplier/tx.pulsar.go b/api/poktroll/supplier/tx.pulsar.go index d35e3f491..bf92b079a 100644 --- a/api/poktroll/supplier/tx.pulsar.go +++ b/api/poktroll/supplier/tx.pulsar.go @@ -873,67 +873,71 @@ func (x *fastReflection_MsgUpdateParamsResponse) ProtoMethods() *protoiface.Meth } } -var _ protoreflect.List = (*_MsgStakeSupplier_3_list)(nil) +var _ protoreflect.List = (*_MsgStakeSupplier_5_list)(nil) -type _MsgStakeSupplier_3_list struct { +type _MsgStakeSupplier_5_list struct { list *[]*shared.SupplierServiceConfig } -func (x *_MsgStakeSupplier_3_list) Len() int { +func (x *_MsgStakeSupplier_5_list) Len() int { if x.list == nil { return 0 } return len(*x.list) } -func (x *_MsgStakeSupplier_3_list) Get(i int) protoreflect.Value { +func (x *_MsgStakeSupplier_5_list) Get(i int) protoreflect.Value { return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) } -func (x *_MsgStakeSupplier_3_list) Set(i int, value protoreflect.Value) { +func (x *_MsgStakeSupplier_5_list) Set(i int, value protoreflect.Value) { valueUnwrapped := value.Message() concreteValue := valueUnwrapped.Interface().(*shared.SupplierServiceConfig) (*x.list)[i] = concreteValue } -func (x *_MsgStakeSupplier_3_list) Append(value protoreflect.Value) { +func (x *_MsgStakeSupplier_5_list) Append(value protoreflect.Value) { valueUnwrapped := value.Message() concreteValue := valueUnwrapped.Interface().(*shared.SupplierServiceConfig) *x.list = append(*x.list, concreteValue) } -func (x *_MsgStakeSupplier_3_list) AppendMutable() protoreflect.Value { +func (x *_MsgStakeSupplier_5_list) AppendMutable() protoreflect.Value { v := new(shared.SupplierServiceConfig) *x.list = append(*x.list, v) return protoreflect.ValueOfMessage(v.ProtoReflect()) } -func (x *_MsgStakeSupplier_3_list) Truncate(n int) { +func (x *_MsgStakeSupplier_5_list) Truncate(n int) { for i := n; i < len(*x.list); i++ { (*x.list)[i] = nil } *x.list = (*x.list)[:n] } -func (x *_MsgStakeSupplier_3_list) NewElement() protoreflect.Value { +func (x *_MsgStakeSupplier_5_list) NewElement() protoreflect.Value { v := new(shared.SupplierServiceConfig) return protoreflect.ValueOfMessage(v.ProtoReflect()) } -func (x *_MsgStakeSupplier_3_list) IsValid() bool { +func (x *_MsgStakeSupplier_5_list) IsValid() bool { return x.list != nil } var ( - md_MsgStakeSupplier protoreflect.MessageDescriptor - fd_MsgStakeSupplier_address protoreflect.FieldDescriptor - fd_MsgStakeSupplier_stake protoreflect.FieldDescriptor - fd_MsgStakeSupplier_services protoreflect.FieldDescriptor + md_MsgStakeSupplier protoreflect.MessageDescriptor + fd_MsgStakeSupplier_sender protoreflect.FieldDescriptor + fd_MsgStakeSupplier_owner_address protoreflect.FieldDescriptor + fd_MsgStakeSupplier_address protoreflect.FieldDescriptor + fd_MsgStakeSupplier_stake protoreflect.FieldDescriptor + fd_MsgStakeSupplier_services protoreflect.FieldDescriptor ) func init() { file_poktroll_supplier_tx_proto_init() md_MsgStakeSupplier = File_poktroll_supplier_tx_proto.Messages().ByName("MsgStakeSupplier") + fd_MsgStakeSupplier_sender = md_MsgStakeSupplier.Fields().ByName("sender") + fd_MsgStakeSupplier_owner_address = md_MsgStakeSupplier.Fields().ByName("owner_address") fd_MsgStakeSupplier_address = md_MsgStakeSupplier.Fields().ByName("address") fd_MsgStakeSupplier_stake = md_MsgStakeSupplier.Fields().ByName("stake") fd_MsgStakeSupplier_services = md_MsgStakeSupplier.Fields().ByName("services") @@ -1004,6 +1008,18 @@ func (x *fastReflection_MsgStakeSupplier) Interface() protoreflect.ProtoMessage // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_MsgStakeSupplier) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Sender != "" { + value := protoreflect.ValueOfString(x.Sender) + if !f(fd_MsgStakeSupplier_sender, value) { + return + } + } + if x.OwnerAddress != "" { + value := protoreflect.ValueOfString(x.OwnerAddress) + if !f(fd_MsgStakeSupplier_owner_address, value) { + return + } + } if x.Address != "" { value := protoreflect.ValueOfString(x.Address) if !f(fd_MsgStakeSupplier_address, value) { @@ -1017,7 +1033,7 @@ func (x *fastReflection_MsgStakeSupplier) Range(f func(protoreflect.FieldDescrip } } if len(x.Services) != 0 { - value := protoreflect.ValueOfList(&_MsgStakeSupplier_3_list{list: &x.Services}) + value := protoreflect.ValueOfList(&_MsgStakeSupplier_5_list{list: &x.Services}) if !f(fd_MsgStakeSupplier_services, value) { return } @@ -1037,6 +1053,10 @@ func (x *fastReflection_MsgStakeSupplier) Range(f func(protoreflect.FieldDescrip // a repeated field is populated if it is non-empty. func (x *fastReflection_MsgStakeSupplier) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { + case "poktroll.supplier.MsgStakeSupplier.sender": + return x.Sender != "" + case "poktroll.supplier.MsgStakeSupplier.owner_address": + return x.OwnerAddress != "" case "poktroll.supplier.MsgStakeSupplier.address": return x.Address != "" case "poktroll.supplier.MsgStakeSupplier.stake": @@ -1059,6 +1079,10 @@ func (x *fastReflection_MsgStakeSupplier) Has(fd protoreflect.FieldDescriptor) b // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_MsgStakeSupplier) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { + case "poktroll.supplier.MsgStakeSupplier.sender": + x.Sender = "" + case "poktroll.supplier.MsgStakeSupplier.owner_address": + x.OwnerAddress = "" case "poktroll.supplier.MsgStakeSupplier.address": x.Address = "" case "poktroll.supplier.MsgStakeSupplier.stake": @@ -1081,6 +1105,12 @@ func (x *fastReflection_MsgStakeSupplier) Clear(fd protoreflect.FieldDescriptor) // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_MsgStakeSupplier) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { + case "poktroll.supplier.MsgStakeSupplier.sender": + value := x.Sender + return protoreflect.ValueOfString(value) + case "poktroll.supplier.MsgStakeSupplier.owner_address": + value := x.OwnerAddress + return protoreflect.ValueOfString(value) case "poktroll.supplier.MsgStakeSupplier.address": value := x.Address return protoreflect.ValueOfString(value) @@ -1089,9 +1119,9 @@ func (x *fastReflection_MsgStakeSupplier) Get(descriptor protoreflect.FieldDescr return protoreflect.ValueOfMessage(value.ProtoReflect()) case "poktroll.supplier.MsgStakeSupplier.services": if len(x.Services) == 0 { - return protoreflect.ValueOfList(&_MsgStakeSupplier_3_list{}) + return protoreflect.ValueOfList(&_MsgStakeSupplier_5_list{}) } - listValue := &_MsgStakeSupplier_3_list{list: &x.Services} + listValue := &_MsgStakeSupplier_5_list{list: &x.Services} return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { @@ -1113,13 +1143,17 @@ func (x *fastReflection_MsgStakeSupplier) Get(descriptor protoreflect.FieldDescr // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_MsgStakeSupplier) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { + case "poktroll.supplier.MsgStakeSupplier.sender": + x.Sender = value.Interface().(string) + case "poktroll.supplier.MsgStakeSupplier.owner_address": + x.OwnerAddress = value.Interface().(string) case "poktroll.supplier.MsgStakeSupplier.address": x.Address = value.Interface().(string) case "poktroll.supplier.MsgStakeSupplier.stake": x.Stake = value.Message().Interface().(*v1beta1.Coin) case "poktroll.supplier.MsgStakeSupplier.services": lv := value.List() - clv := lv.(*_MsgStakeSupplier_3_list) + clv := lv.(*_MsgStakeSupplier_5_list) x.Services = *clv.list default: if fd.IsExtension() { @@ -1150,8 +1184,12 @@ func (x *fastReflection_MsgStakeSupplier) Mutable(fd protoreflect.FieldDescripto if x.Services == nil { x.Services = []*shared.SupplierServiceConfig{} } - value := &_MsgStakeSupplier_3_list{list: &x.Services} + value := &_MsgStakeSupplier_5_list{list: &x.Services} return protoreflect.ValueOfList(value) + case "poktroll.supplier.MsgStakeSupplier.sender": + panic(fmt.Errorf("field sender of message poktroll.supplier.MsgStakeSupplier is not mutable")) + case "poktroll.supplier.MsgStakeSupplier.owner_address": + panic(fmt.Errorf("field owner_address of message poktroll.supplier.MsgStakeSupplier is not mutable")) case "poktroll.supplier.MsgStakeSupplier.address": panic(fmt.Errorf("field address of message poktroll.supplier.MsgStakeSupplier is not mutable")) default: @@ -1167,6 +1205,10 @@ func (x *fastReflection_MsgStakeSupplier) Mutable(fd protoreflect.FieldDescripto // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_MsgStakeSupplier) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "poktroll.supplier.MsgStakeSupplier.sender": + return protoreflect.ValueOfString("") + case "poktroll.supplier.MsgStakeSupplier.owner_address": + return protoreflect.ValueOfString("") case "poktroll.supplier.MsgStakeSupplier.address": return protoreflect.ValueOfString("") case "poktroll.supplier.MsgStakeSupplier.stake": @@ -1174,7 +1216,7 @@ func (x *fastReflection_MsgStakeSupplier) NewField(fd protoreflect.FieldDescript return protoreflect.ValueOfMessage(m.ProtoReflect()) case "poktroll.supplier.MsgStakeSupplier.services": list := []*shared.SupplierServiceConfig{} - return protoreflect.ValueOfList(&_MsgStakeSupplier_3_list{list: &list}) + return protoreflect.ValueOfList(&_MsgStakeSupplier_5_list{list: &list}) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.supplier.MsgStakeSupplier")) @@ -1244,6 +1286,14 @@ func (x *fastReflection_MsgStakeSupplier) ProtoMethods() *protoiface.Methods { var n int var l int _ = l + l = len(x.Sender) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.OwnerAddress) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } l = len(x.Address) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) @@ -1300,7 +1350,7 @@ func (x *fastReflection_MsgStakeSupplier) ProtoMethods() *protoiface.Methods { copy(dAtA[i:], encoded) i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x2a } } if x.Stake != nil { @@ -1315,13 +1365,27 @@ func (x *fastReflection_MsgStakeSupplier) ProtoMethods() *protoiface.Methods { copy(dAtA[i:], encoded) i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x22 } if len(x.Address) > 0 { i -= len(x.Address) copy(dAtA[i:], x.Address) i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Address))) i-- + dAtA[i] = 0x1a + } + 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] = 0x12 + } + if len(x.Sender) > 0 { + i -= len(x.Sender) + copy(dAtA[i:], x.Sender) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Sender))) + i-- dAtA[i] = 0xa } if input.Buf != nil { @@ -1374,6 +1438,70 @@ func (x *fastReflection_MsgStakeSupplier) 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 Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 + case 3: if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } @@ -1405,7 +1533,7 @@ func (x *fastReflection_MsgStakeSupplier) ProtoMethods() *protoiface.Methods { } x.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 4: if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Stake", wireType) } @@ -1441,7 +1569,7 @@ func (x *fastReflection_MsgStakeSupplier) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex - case 3: + case 5: if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Services", wireType) } @@ -1867,13 +1995,15 @@ func (x *fastReflection_MsgStakeSupplierResponse) ProtoMethods() *protoiface.Met } var ( - md_MsgUnstakeSupplier protoreflect.MessageDescriptor - fd_MsgUnstakeSupplier_address protoreflect.FieldDescriptor + md_MsgUnstakeSupplier protoreflect.MessageDescriptor + fd_MsgUnstakeSupplier_owner_address protoreflect.FieldDescriptor + fd_MsgUnstakeSupplier_address protoreflect.FieldDescriptor ) func init() { file_poktroll_supplier_tx_proto_init() md_MsgUnstakeSupplier = File_poktroll_supplier_tx_proto.Messages().ByName("MsgUnstakeSupplier") + fd_MsgUnstakeSupplier_owner_address = md_MsgUnstakeSupplier.Fields().ByName("owner_address") fd_MsgUnstakeSupplier_address = md_MsgUnstakeSupplier.Fields().ByName("address") } @@ -1942,6 +2072,12 @@ func (x *fastReflection_MsgUnstakeSupplier) Interface() protoreflect.ProtoMessag // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_MsgUnstakeSupplier) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.OwnerAddress != "" { + value := protoreflect.ValueOfString(x.OwnerAddress) + if !f(fd_MsgUnstakeSupplier_owner_address, value) { + return + } + } if x.Address != "" { value := protoreflect.ValueOfString(x.Address) if !f(fd_MsgUnstakeSupplier_address, value) { @@ -1963,6 +2099,8 @@ func (x *fastReflection_MsgUnstakeSupplier) Range(f func(protoreflect.FieldDescr // a repeated field is populated if it is non-empty. func (x *fastReflection_MsgUnstakeSupplier) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { + case "poktroll.supplier.MsgUnstakeSupplier.owner_address": + return x.OwnerAddress != "" case "poktroll.supplier.MsgUnstakeSupplier.address": return x.Address != "" default: @@ -1981,6 +2119,8 @@ func (x *fastReflection_MsgUnstakeSupplier) Has(fd protoreflect.FieldDescriptor) // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_MsgUnstakeSupplier) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { + case "poktroll.supplier.MsgUnstakeSupplier.owner_address": + x.OwnerAddress = "" case "poktroll.supplier.MsgUnstakeSupplier.address": x.Address = "" default: @@ -1999,6 +2139,9 @@ func (x *fastReflection_MsgUnstakeSupplier) Clear(fd protoreflect.FieldDescripto // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_MsgUnstakeSupplier) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { + case "poktroll.supplier.MsgUnstakeSupplier.owner_address": + value := x.OwnerAddress + return protoreflect.ValueOfString(value) case "poktroll.supplier.MsgUnstakeSupplier.address": value := x.Address return protoreflect.ValueOfString(value) @@ -2022,6 +2165,8 @@ func (x *fastReflection_MsgUnstakeSupplier) Get(descriptor protoreflect.FieldDes // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_MsgUnstakeSupplier) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { + case "poktroll.supplier.MsgUnstakeSupplier.owner_address": + x.OwnerAddress = value.Interface().(string) case "poktroll.supplier.MsgUnstakeSupplier.address": x.Address = value.Interface().(string) default: @@ -2044,6 +2189,8 @@ func (x *fastReflection_MsgUnstakeSupplier) Set(fd protoreflect.FieldDescriptor, // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_MsgUnstakeSupplier) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "poktroll.supplier.MsgUnstakeSupplier.owner_address": + panic(fmt.Errorf("field owner_address of message poktroll.supplier.MsgUnstakeSupplier is not mutable")) case "poktroll.supplier.MsgUnstakeSupplier.address": panic(fmt.Errorf("field address of message poktroll.supplier.MsgUnstakeSupplier is not mutable")) default: @@ -2059,6 +2206,8 @@ func (x *fastReflection_MsgUnstakeSupplier) Mutable(fd protoreflect.FieldDescrip // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_MsgUnstakeSupplier) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "poktroll.supplier.MsgUnstakeSupplier.owner_address": + return protoreflect.ValueOfString("") case "poktroll.supplier.MsgUnstakeSupplier.address": return protoreflect.ValueOfString("") default: @@ -2130,6 +2279,10 @@ func (x *fastReflection_MsgUnstakeSupplier) ProtoMethods() *protoiface.Methods { var n int var l int _ = l + l = len(x.OwnerAddress) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } l = len(x.Address) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) @@ -2168,6 +2321,13 @@ func (x *fastReflection_MsgUnstakeSupplier) ProtoMethods() *protoiface.Methods { copy(dAtA[i:], x.Address) i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Address))) i-- + dAtA[i] = 0x12 + } + 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 } if input.Buf != nil { @@ -2220,6 +2380,38 @@ func (x *fastReflection_MsgUnstakeSupplier) 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 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 + case 2: if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } @@ -2735,9 +2927,11 @@ type MsgStakeSupplier struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the supplier using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding - Stake *v1beta1.Coin `protobuf:"bytes,2,opt,name=stake,proto3" json:"stake,omitempty"` // The total amount of uPOKT the supplier has staked. Must be ≥ to the current amount that the supplier has staked (if any) - Services []*shared.SupplierServiceConfig `protobuf:"bytes,3,rep,name=services,proto3" json:"services,omitempty"` // The list of services this supplier is staked to provide service for + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` // The Bech32 address of the message sender (i.e. owner or operator) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + OwnerAddress string `protobuf:"bytes,2,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` // The Bech32 address of the owner (i.e. custodial, staker) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the operator (i.e. provider, non-custodial) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + Stake *v1beta1.Coin `protobuf:"bytes,4,opt,name=stake,proto3" json:"stake,omitempty"` // The total amount of uPOKT the supplier has staked. Must be ≥ to the current amount that the supplier has staked (if any) + Services []*shared.SupplierServiceConfig `protobuf:"bytes,5,rep,name=services,proto3" json:"services,omitempty"` // The list of services this supplier is staked to provide service for } func (x *MsgStakeSupplier) Reset() { @@ -2760,6 +2954,20 @@ func (*MsgStakeSupplier) Descriptor() ([]byte, []int) { return file_poktroll_supplier_tx_proto_rawDescGZIP(), []int{2} } +func (x *MsgStakeSupplier) GetSender() string { + if x != nil { + return x.Sender + } + return "" +} + +func (x *MsgStakeSupplier) GetOwnerAddress() string { + if x != nil { + return x.OwnerAddress + } + return "" +} + func (x *MsgStakeSupplier) GetAddress() string { if x != nil { return x.Address @@ -2812,7 +3020,8 @@ type MsgUnstakeSupplier struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the supplier using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` // The Bech32 address of the owner (i.e. custodial, staker) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the operator (i.e. provider, non-custodial) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding } func (x *MsgUnstakeSupplier) Reset() { @@ -2835,6 +3044,13 @@ func (*MsgUnstakeSupplier) Descriptor() ([]byte, []int) { return file_poktroll_supplier_tx_proto_rawDescGZIP(), []int{4} } +func (x *MsgUnstakeSupplier) GetOwnerAddress() string { + if x != nil { + return x.OwnerAddress + } + return "" +} + func (x *MsgUnstakeSupplier) GetAddress() string { if x != nil { return x.Address @@ -2899,60 +3115,71 @@ var file_poktroll_supplier_tx_proto_rawDesc = []byte{ 0x6c, 0x6c, 0x2f, 0x78, 0x2f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 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, 0xc9, 0x01, 0x0a, 0x10, 0x4d, 0x73, 0x67, - 0x53, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 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, 0x2f, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, - 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x52, 0x05, 0x73, 0x74, 0x61, - 0x6b, 0x65, 0x12, 0x42, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 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, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3a, 0x0c, 0x82, 0xe7, 0xb0, 0x2a, 0x07, 0x61, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x22, 0x1a, 0x0a, 0x18, 0x4d, 0x73, 0x67, 0x53, 0x74, 0x61, 0x6b, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xb9, 0x02, 0x0a, 0x10, 0x4d, 0x73, 0x67, + 0x53, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x12, 0x30, 0x0a, + 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 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, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, + 0x3d, 0x0a, 0x0d, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x18, 0x02, 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, 0x32, + 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 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, 0x2f, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x52, 0x05, 0x73, 0x74, + 0x61, 0x6b, 0x65, 0x12, 0x42, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, + 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 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, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3a, 0x0b, 0x82, 0xe7, 0xb0, 0x2a, 0x06, 0x73, 0x65, + 0x6e, 0x64, 0x65, 0x72, 0x22, 0x1a, 0x0a, 0x18, 0x4d, 0x73, 0x67, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x56, 0x0a, 0x12, 0x4d, 0x73, 0x67, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, - 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 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, + 0x22, 0x9b, 0x01, 0x0a, 0x12, 0x4d, 0x73, 0x67, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x53, + 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 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, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x18, 0x02, 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, 0x3a, 0x0c, 0x82, 0xe7, 0xb0, 0x2a, - 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x1c, 0x0a, 0x1a, 0x4d, 0x73, 0x67, 0x55, - 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xb8, 0x02, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x5e, - 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x22, - 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, - 0x65, 0x72, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, - 0x6d, 0x73, 0x1a, 0x2a, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, - 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 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, 0x61, - 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x12, - 0x23, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, - 0x69, 0x65, 0x72, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, - 0x6c, 0x69, 0x65, 0x72, 0x1a, 0x2b, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, - 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x74, 0x61, 0x6b, - 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x67, 0x0a, 0x0f, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, - 0x6c, 0x69, 0x65, 0x72, 0x12, 0x25, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, - 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x6e, 0x73, 0x74, - 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x1a, 0x2d, 0x2e, 0x70, 0x6f, - 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, - 0x4d, 0x73, 0x67, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, - 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, - 0x01, 0x42, 0xa9, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, - 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x42, 0x07, 0x54, 0x78, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x22, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, - 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, - 0x6c, 0x2f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, - 0xaa, 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x75, 0x70, 0x70, - 0x6c, 0x69, 0x65, 0x72, 0xca, 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, - 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0xe2, 0x02, 0x1d, 0x50, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x5c, 0x47, 0x50, 0x42, - 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x12, 0x50, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x3a, 0x12, 0x82, 0xe7, 0xb0, 0x2a, + 0x0d, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x1c, + 0x0a, 0x1a, 0x4d, 0x73, 0x67, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, + 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xb8, 0x02, 0x0a, + 0x03, 0x4d, 0x73, 0x67, 0x12, 0x5e, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x12, 0x22, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, + 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x2a, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 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, 0x61, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, + 0x70, 0x6c, 0x69, 0x65, 0x72, 0x12, 0x23, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x74, 0x61, + 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x1a, 0x2b, 0x2e, 0x70, 0x6f, 0x6b, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x4d, + 0x73, 0x67, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x67, 0x0a, 0x0f, 0x55, 0x6e, 0x73, 0x74, 0x61, + 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x12, 0x25, 0x2e, 0x70, 0x6f, 0x6b, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x4d, + 0x73, 0x67, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, + 0x72, 0x1a, 0x2d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, + 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, + 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0xa9, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, + 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, + 0x72, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x22, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, + 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x2e, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0xca, 0x02, 0x11, 0x50, 0x6f, 0x6b, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0xe2, 0x02, + 0x1d, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, + 0x65, 0x72, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, + 0x12, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x75, 0x70, 0x70, 0x6c, + 0x69, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/load-testing/tests/relays_stress_helpers_test.go b/load-testing/tests/relays_stress_helpers_test.go index c03b8f47a..c00f01341 100644 --- a/load-testing/tests/relays_stress_helpers_test.go +++ b/load-testing/tests/relays_stress_helpers_test.go @@ -785,6 +785,7 @@ func (s *relaysSuite) addActor(actorAddress string, actorStakeAmount sdk.Coin) * // messages in a single supplier transaction. func (s *relaysSuite) addPendingStakeSupplierMsg(supplier *accountInfo) { supplier.addPendingMsg(suppliertypes.NewMsgStakeSupplier( + supplier.address, supplier.address, supplier.amountToStake, []*sharedtypes.SupplierServiceConfig{ diff --git a/proto/poktroll/shared/supplier.proto b/proto/poktroll/shared/supplier.proto index aa632c511..8964ec5f1 100644 --- a/proto/poktroll/shared/supplier.proto +++ b/proto/poktroll/shared/supplier.proto @@ -10,11 +10,19 @@ import "poktroll/shared/service.proto"; // Supplier is the type defining the actor in Pocket Network that provides RPC services. message Supplier { - string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the supplier using cosmos' ScalarDescriptor to ensure deterministic encoding - cosmos.base.v1beta1.Coin stake = 2; // The total amount of uPOKT the supplier has staked - repeated SupplierServiceConfig services = 3; // The service configs this supplier can support + // The Bech32 address of the owner (i.e. custodial, staker) using cosmos' + // ScalarDescriptor to ensure deterministic encoding. + // This is the address that owns the funds for staking and is the one that + // receives the rewards. + string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // The Bech32 address of the operator (i.e. provider, non-custodial) using cosmos' + // ScalarDescriptor to ensure deterministic encoding. + // The operator address can update all the supplier's configurations, excluding + // the owner_address. + string address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + cosmos.base.v1beta1.Coin stake = 3; // The total amount of uPOKT the supplier has staked + repeated SupplierServiceConfig services = 4; // The service configs this supplier can support // The session end height at which an actively unbonding supplier unbonds its stake. // If the supplier did not unstake, this value will be 0. - uint64 unstake_session_end_height = 4; + uint64 unstake_session_end_height = 5; } - diff --git a/proto/poktroll/supplier/tx.proto b/proto/poktroll/supplier/tx.proto index ef75baa2f..bcf5e97ef 100644 --- a/proto/poktroll/supplier/tx.proto +++ b/proto/poktroll/supplier/tx.proto @@ -45,17 +45,21 @@ message MsgUpdateParams { message MsgUpdateParamsResponse {} message MsgStakeSupplier { - 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 supplier using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding - cosmos.base.v1beta1.Coin stake = 2; // The total amount of uPOKT the supplier has staked. Must be ≥ to the current amount that the supplier has staked (if any) - repeated poktroll.shared.SupplierServiceConfig services = 3; // The list of services this supplier is staked to provide service for + option (cosmos.msg.v1.signer) = "sender"; // https://docs.cosmos.network/main/build/building-modules/messages-and-queries + + string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the message sender (i.e. owner or operator) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + string owner_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the owner (i.e. custodial, staker) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + string address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the operator (i.e. provider, non-custodial) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + cosmos.base.v1beta1.Coin stake = 4; // The total amount of uPOKT the supplier has staked. Must be ≥ to the current amount that the supplier has staked (if any) + repeated poktroll.shared.SupplierServiceConfig services = 5; // The list of services this supplier is staked to provide service for } message MsgStakeSupplierResponse {} message MsgUnstakeSupplier { - option (cosmos.msg.v1.signer) = "address"; - string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the supplier using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + option (cosmos.msg.v1.signer) = "owner_address"; + string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the owner (i.e. custodial, staker) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + string address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the operator (i.e. provider, non-custodial) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding } message MsgUnstakeSupplierResponse {} diff --git a/testutil/integration/app.go b/testutil/integration/app.go index a1b1273e2..b7f567baa 100644 --- a/testutil/integration/app.go +++ b/testutil/integration/app.go @@ -397,12 +397,14 @@ func NewCompleteIntegrationApp(t *testing.T) *App { proofKeeper, sharedKeeper, sessionKeeper, + supplierKeeper, ) tokenomicsModule := tokenomics.NewAppModule( cdc, tokenomicsKeeper, accountKeeper, bankKeeper, + supplierKeeper, ) // Prepare the message & query routers diff --git a/testutil/keeper/tokenomics.go b/testutil/keeper/tokenomics.go index 5ad06f56b..e2578d34d 100644 --- a/testutil/keeper/tokenomics.go +++ b/testutil/keeper/tokenomics.go @@ -168,6 +168,10 @@ func TokenomicsKeeperWithActorAddrs(t testing.TB, service *sharedtypes.Service) mockSharedKeeper := mocks.NewMockSharedKeeper(ctrl) mockSharedKeeper.EXPECT().GetProofWindowCloseHeight(gomock.Any(), gomock.Any()).AnyTimes() + // Mock the supplier keeper + mockSupplierKeeper := mocks.NewMockSupplierKeeper(ctrl) + mockSupplierKeeper.EXPECT().GetSupplier(gomock.Any(), gomock.Any()).AnyTimes() + // Mock the session keeper mockSessionKeeper := mocks.NewMockSessionKeeper(ctrl) @@ -182,6 +186,7 @@ func TokenomicsKeeperWithActorAddrs(t testing.TB, service *sharedtypes.Service) mockProofKeeper, mockSharedKeeper, mockSessionKeeper, + mockSupplierKeeper, ) sdkCtx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger()) @@ -362,6 +367,7 @@ func NewTokenomicsModuleKeepers( proofKeeper, sharedKeeper, sessionKeeper, + supplierKeeper, ) require.NoError(t, tokenomicsKeeper.SetParams(ctx, tokenomicstypes.DefaultParams())) diff --git a/x/shared/types/supplier.pb.go b/x/shared/types/supplier.pb.go index 3e19ef0ea..72987c04b 100644 --- a/x/shared/types/supplier.pb.go +++ b/x/shared/types/supplier.pb.go @@ -26,12 +26,21 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Supplier is the type defining the actor in Pocket Network that provides RPC services. type Supplier struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - Stake *types.Coin `protobuf:"bytes,2,opt,name=stake,proto3" json:"stake,omitempty"` - Services []*SupplierServiceConfig `protobuf:"bytes,3,rep,name=services,proto3" json:"services,omitempty"` + // The Bech32 address of the owner (i.e. custodial, staker) using cosmos' + // ScalarDescriptor to ensure deterministic encoding. + // This is the address that owns the funds for staking and is the one that + // receives the rewards. + OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` + // The Bech32 address of the operator (i.e. provider, non-custodial) using cosmos' + // ScalarDescriptor to ensure deterministic encoding. + // The operator address can update all the supplier's configurations, excluding + // the owner_address. + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + Stake *types.Coin `protobuf:"bytes,3,opt,name=stake,proto3" json:"stake,omitempty"` + Services []*SupplierServiceConfig `protobuf:"bytes,4,rep,name=services,proto3" json:"services,omitempty"` // The session end height at which an actively unbonding supplier unbonds its stake. // If the supplier did not unstake, this value will be 0. - UnstakeSessionEndHeight uint64 `protobuf:"varint,4,opt,name=unstake_session_end_height,json=unstakeSessionEndHeight,proto3" json:"unstake_session_end_height,omitempty"` + UnstakeSessionEndHeight uint64 `protobuf:"varint,5,opt,name=unstake_session_end_height,json=unstakeSessionEndHeight,proto3" json:"unstake_session_end_height,omitempty"` } func (m *Supplier) Reset() { *m = Supplier{} } @@ -67,6 +76,13 @@ func (m *Supplier) XXX_DiscardUnknown() { var xxx_messageInfo_Supplier proto.InternalMessageInfo +func (m *Supplier) GetOwnerAddress() string { + if m != nil { + return m.OwnerAddress + } + return "" +} + func (m *Supplier) GetAddress() string { if m != nil { return m.Address @@ -102,28 +118,29 @@ func init() { func init() { proto.RegisterFile("poktroll/shared/supplier.proto", fileDescriptor_4a189b52ba503cf2) } var fileDescriptor_4a189b52ba503cf2 = []byte{ - // 326 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x90, 0x3f, 0x4e, 0xc3, 0x30, - 0x18, 0xc5, 0x6b, 0x5a, 0xa0, 0xa4, 0x03, 0x52, 0x84, 0x44, 0x5a, 0x09, 0x2b, 0x62, 0x40, 0x59, - 0x6a, 0xab, 0x65, 0x64, 0xa2, 0x15, 0x12, 0xac, 0xc9, 0xc6, 0x12, 0xe5, 0x8f, 0x49, 0xac, 0xb6, - 0x76, 0xe4, 0xcf, 0x2d, 0x70, 0x0b, 0x0e, 0xc3, 0x21, 0x18, 0x2b, 0x26, 0x46, 0xd4, 0x5e, 0x80, - 0x23, 0xa0, 0xc6, 0x4e, 0x07, 0x18, 0x3f, 0xfd, 0x7e, 0xc9, 0x7b, 0x7e, 0x0e, 0xae, 0xe4, 0x4c, - 0x2b, 0x39, 0x9f, 0x53, 0x28, 0x13, 0xc5, 0x72, 0x0a, 0xcb, 0xaa, 0x9a, 0x73, 0xa6, 0x48, 0xa5, - 0xa4, 0x96, 0xee, 0x69, 0xc3, 0x89, 0xe1, 0x83, 0x7e, 0x26, 0x61, 0x21, 0x21, 0xae, 0x31, 0x35, - 0x87, 0x71, 0x07, 0xd8, 0x5c, 0x34, 0x4d, 0x80, 0xd1, 0xd5, 0x28, 0x65, 0x3a, 0x19, 0xd1, 0x4c, - 0x72, 0x61, 0xf9, 0xc5, 0xbf, 0x2c, 0xa6, 0x56, 0x3c, 0x63, 0x06, 0x5f, 0xfe, 0x20, 0xa7, 0x1b, - 0xd9, 0x74, 0x77, 0xec, 0x1c, 0x27, 0x79, 0xae, 0x18, 0x80, 0x87, 0x7c, 0x14, 0x9c, 0x4c, 0xbc, - 0xcf, 0xf7, 0xe1, 0x99, 0x8d, 0xbb, 0x35, 0x24, 0xd2, 0x8a, 0x8b, 0x22, 0x6c, 0x44, 0x97, 0x3a, - 0x87, 0xa0, 0x93, 0x19, 0xf3, 0x0e, 0x7c, 0x14, 0xf4, 0xc6, 0x7d, 0x62, 0xf5, 0x5d, 0x1f, 0x62, - 0xfb, 0x90, 0xa9, 0xe4, 0x22, 0x34, 0x9e, 0x3b, 0x71, 0xba, 0xb6, 0x02, 0x78, 0x6d, 0xbf, 0x1d, - 0xf4, 0xc6, 0x57, 0xe4, 0xcf, 0x7b, 0x49, 0xd3, 0x28, 0x32, 0xe2, 0x54, 0x8a, 0x27, 0x5e, 0x84, - 0xfb, 0xef, 0xdc, 0x1b, 0x67, 0xb0, 0x14, 0xf5, 0xef, 0x62, 0x60, 0x00, 0x5c, 0x8a, 0x98, 0x89, - 0x3c, 0x2e, 0x19, 0x2f, 0x4a, 0xed, 0x75, 0x7c, 0x14, 0x74, 0xc2, 0x73, 0x6b, 0x44, 0x46, 0xb8, - 0x13, 0xf9, 0x7d, 0x8d, 0x27, 0x0f, 0x1f, 0x1b, 0x8c, 0xd6, 0x1b, 0x8c, 0xbe, 0x37, 0x18, 0xbd, - 0x6d, 0x71, 0x6b, 0xbd, 0xc5, 0xad, 0xaf, 0x2d, 0x6e, 0x3d, 0xd2, 0x82, 0xeb, 0x72, 0x99, 0x92, - 0x4c, 0x2e, 0xe8, 0xae, 0xd2, 0x50, 0x30, 0xfd, 0x2c, 0xd5, 0x8c, 0xee, 0x37, 0x7c, 0x69, 0x56, - 0xd4, 0xaf, 0x15, 0x83, 0xf4, 0xa8, 0x1e, 0xf1, 0xfa, 0x37, 0x00, 0x00, 0xff, 0xff, 0x7d, 0x97, - 0x5a, 0x2e, 0xd1, 0x01, 0x00, 0x00, + // 350 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xbd, 0x4e, 0xeb, 0x30, + 0x14, 0xc7, 0x9b, 0x7e, 0xdc, 0xdb, 0x9b, 0xde, 0xab, 0x2b, 0x45, 0x48, 0xa4, 0x95, 0xb0, 0x22, + 0x06, 0x94, 0xa5, 0xb6, 0x5a, 0x46, 0xc4, 0x40, 0x2b, 0x24, 0x58, 0x93, 0x8d, 0x25, 0xca, 0xc7, + 0x21, 0xb1, 0xda, 0xda, 0x91, 0xed, 0xb6, 0xf0, 0x16, 0xbc, 0x09, 0x0b, 0x0f, 0xc1, 0x58, 0x31, + 0x31, 0xa2, 0xf6, 0x45, 0x50, 0x63, 0xa7, 0x03, 0x0c, 0x8c, 0xc7, 0xbf, 0xdf, 0xf1, 0xf1, 0xdf, + 0xc7, 0x46, 0x25, 0x9f, 0x29, 0xc1, 0xe7, 0x73, 0x22, 0x8b, 0x58, 0x40, 0x46, 0xe4, 0xb2, 0x2c, + 0xe7, 0x14, 0x04, 0x2e, 0x05, 0x57, 0xdc, 0xf9, 0x5f, 0x73, 0xac, 0xf9, 0xa0, 0x9f, 0x72, 0xb9, + 0xe0, 0x32, 0xaa, 0x30, 0xd1, 0x85, 0x76, 0x07, 0x48, 0x57, 0x24, 0x89, 0x25, 0x90, 0xd5, 0x28, + 0x01, 0x15, 0x8f, 0x48, 0xca, 0x29, 0x33, 0xfc, 0xe4, 0xdb, 0x2c, 0x10, 0x2b, 0x9a, 0x82, 0xc6, + 0xa7, 0xcf, 0x4d, 0xbb, 0x1b, 0x9a, 0xe9, 0xce, 0xa5, 0xfd, 0x8f, 0xaf, 0x19, 0x88, 0x28, 0xce, + 0x32, 0x01, 0x52, 0xba, 0x96, 0x67, 0xf9, 0x7f, 0x26, 0xee, 0xdb, 0xcb, 0xf0, 0xc8, 0x0c, 0xbd, + 0xd2, 0x24, 0x54, 0x82, 0xb2, 0x3c, 0xf8, 0x5b, 0xe9, 0xe6, 0xcc, 0x19, 0xdb, 0xbf, 0xeb, 0xc6, + 0xe6, 0x0f, 0x8d, 0xb5, 0xe8, 0x10, 0xbb, 0x23, 0x55, 0x3c, 0x03, 0xb7, 0xe5, 0x59, 0x7e, 0x6f, + 0xdc, 0xc7, 0x46, 0xdf, 0xc7, 0xc1, 0x26, 0x0e, 0x9e, 0x72, 0xca, 0x02, 0xed, 0x39, 0x13, 0xbb, + 0x6b, 0x12, 0x48, 0xb7, 0xed, 0xb5, 0xfc, 0xde, 0xf8, 0x0c, 0x7f, 0xf9, 0x2e, 0x5c, 0x07, 0x0a, + 0xb5, 0x38, 0xe5, 0xec, 0x9e, 0xe6, 0xc1, 0xa1, 0xcf, 0xb9, 0xb0, 0x07, 0x4b, 0x56, 0x5d, 0x17, + 0x49, 0x90, 0x92, 0x72, 0x16, 0x01, 0xcb, 0xa2, 0x02, 0x68, 0x5e, 0x28, 0xb7, 0xe3, 0x59, 0x7e, + 0x3b, 0x38, 0x36, 0x46, 0xa8, 0x85, 0x6b, 0x96, 0xdd, 0x54, 0x78, 0x72, 0xfb, 0xba, 0x45, 0xd6, + 0x66, 0x8b, 0xac, 0x8f, 0x2d, 0xb2, 0x9e, 0x76, 0xa8, 0xb1, 0xd9, 0xa1, 0xc6, 0xfb, 0x0e, 0x35, + 0xee, 0x48, 0x4e, 0x55, 0xb1, 0x4c, 0x70, 0xca, 0x17, 0x64, 0xff, 0xa4, 0x21, 0x03, 0xb5, 0xe6, + 0x62, 0x46, 0x0e, 0x2b, 0x78, 0xa8, 0x97, 0xa0, 0x1e, 0x4b, 0x90, 0xc9, 0xaf, 0x6a, 0x07, 0xe7, + 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x9f, 0xaa, 0x28, 0x18, 0x10, 0x02, 0x00, 0x00, } func (m *Supplier) Marshal() (dAtA []byte, err error) { @@ -149,7 +166,7 @@ func (m *Supplier) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.UnstakeSessionEndHeight != 0 { i = encodeVarintSupplier(dAtA, i, uint64(m.UnstakeSessionEndHeight)) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x28 } if len(m.Services) > 0 { for iNdEx := len(m.Services) - 1; iNdEx >= 0; iNdEx-- { @@ -162,7 +179,7 @@ func (m *Supplier) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintSupplier(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } } if m.Stake != nil { @@ -175,13 +192,20 @@ func (m *Supplier) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintSupplier(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } if len(m.Address) > 0 { i -= len(m.Address) copy(dAtA[i:], m.Address) i = encodeVarintSupplier(dAtA, i, uint64(len(m.Address))) i-- + dAtA[i] = 0x12 + } + if len(m.OwnerAddress) > 0 { + i -= len(m.OwnerAddress) + copy(dAtA[i:], m.OwnerAddress) + i = encodeVarintSupplier(dAtA, i, uint64(len(m.OwnerAddress))) + i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -204,6 +228,10 @@ func (m *Supplier) Size() (n int) { } var l int _ = l + l = len(m.OwnerAddress) + if l > 0 { + n += 1 + l + sovSupplier(uint64(l)) + } l = len(m.Address) if l > 0 { n += 1 + l + sovSupplier(uint64(l)) @@ -260,6 +288,38 @@ func (m *Supplier) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + 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 ErrIntOverflowSupplier + } + 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 ErrInvalidLengthSupplier + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSupplier + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OwnerAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } @@ -291,7 +351,7 @@ func (m *Supplier) Unmarshal(dAtA []byte) error { } m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Stake", wireType) } @@ -327,7 +387,7 @@ func (m *Supplier) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Services", wireType) } @@ -361,7 +421,7 @@ func (m *Supplier) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field UnstakeSessionEndHeight", wireType) } diff --git a/x/supplier/config/errors.go b/x/supplier/config/errors.go index 80be44969..78bb14f4a 100644 --- a/x/supplier/config/errors.go +++ b/x/supplier/config/errors.go @@ -15,4 +15,5 @@ var ( ErrSupplierConfigInvalidURL = sdkerrors.Register(types.ModuleName, 2105, "invalid endpoint url in supplier config") ErrSupplierConfigEmptyContent = sdkerrors.Register(types.ModuleName, 2106, "empty supplier config content") ErrSupplierConfigInvalidStake = sdkerrors.Register(types.ModuleName, 2107, "invalid stake amount in supplier config") + ErrSupplierConfigInvalidOwnerAddress = sdkerrors.Register(types.ModuleName, 2108, "missing owner address in supplier config") ) diff --git a/x/supplier/config/supplier_configs_reader.go b/x/supplier/config/supplier_configs_reader.go index 7275ed97d..e83be1fdf 100644 --- a/x/supplier/config/supplier_configs_reader.go +++ b/x/supplier/config/supplier_configs_reader.go @@ -13,8 +13,10 @@ import ( // YAMLStakeConfig is the structure describing the supplier stake config file. type YAMLStakeConfig struct { - StakeAmount string `yaml:"stake_amount"` - Services []*YAMLStakeService `yaml:"services"` + OwnerAddress string `yaml:"owner_address"` + OperatorAddress string `yaml:"operator_address"` + StakeAmount string `yaml:"stake_amount"` + Services []*YAMLStakeService `yaml:"services"` } // YAMLStakeService is the structure describing a single service entry in the @@ -34,8 +36,10 @@ type YAMLServiceEndpoint struct { // SupplierStakeConfig is the structure describing the parsed supplier stake config. type SupplierStakeConfig struct { - StakeAmount sdk.Coin - Services []*sharedtypes.SupplierServiceConfig + OwnerAddress string + OperatorAddress string + StakeAmount sdk.Coin + Services []*sharedtypes.SupplierServiceConfig } // ParseSupplierServiceConfig parses the stake config file into a SupplierServiceConfig. @@ -51,6 +55,16 @@ func ParseSupplierConfigs(configContent []byte) (*SupplierStakeConfig, error) { return nil, ErrSupplierConfigUnmarshalYAML.Wrapf("%s", err) } + // Validate required owner address. + if _, err := sdk.AccAddressFromBech32(stakeConfig.OwnerAddress); err != nil { + return nil, ErrSupplierConfigInvalidOwnerAddress.Wrap("invalid owner address") + } + + // If the operator address is not set, default it to the owner address. + if stakeConfig.OperatorAddress == "" { + stakeConfig.OperatorAddress = stakeConfig.OwnerAddress + } + // Validate the stake amount if len(stakeConfig.StakeAmount) == 0 { return nil, ErrSupplierConfigInvalidStake.Wrap("stake amount cannot be empty") @@ -113,8 +127,10 @@ func ParseSupplierConfigs(configContent []byte) (*SupplierStakeConfig, error) { } return &SupplierStakeConfig{ - StakeAmount: stakeAmount, - Services: supplierServiceConfig, + OwnerAddress: stakeConfig.OwnerAddress, + OperatorAddress: stakeConfig.OperatorAddress, + StakeAmount: stakeAmount, + Services: supplierServiceConfig, }, nil } diff --git a/x/supplier/keeper/msg_server_stake_supplier.go b/x/supplier/keeper/msg_server_stake_supplier.go index 093937d93..6afc0c401 100644 --- a/x/supplier/keeper/msg_server_stake_supplier.go +++ b/x/supplier/keeper/msg_server_stake_supplier.go @@ -40,13 +40,38 @@ func (k msgServer) StakeSupplier(ctx context.Context, msg *types.MsgStakeSupplie var coinsToEscrow sdk.Coin supplier, isSupplierFound := k.GetSupplier(ctx, msg.Address) + // Retain the previous operator address to check whether it changes after updating the supplier + var previousOperatorAddr string if !isSupplierFound { logger.Info(fmt.Sprintf("Supplier not found. Creating new supplier for address %q", msg.Address)) + // Ensure that only supplier owner is able to stake. + if err := ensureMsgSenderIsSupplierOwner(msg); err != nil { + logger.Error(fmt.Sprintf( + "owner address %q in the message does not match the msg sender address %q", + msg.OwnerAddress, + msg.Sender, + )) + + return nil, err + } supplier = k.createSupplier(ctx, msg) coinsToEscrow = *msg.Stake } else { logger.Info(fmt.Sprintf("Supplier found. About to try updating supplier with address %q", msg.Address)) + + // Only the owner can update the supplier's owner and operator addresses. + if ownerOrOperatorAddressesChanged(msg, &supplier) { + if err := ensureMsgSenderIsSupplierOwner(msg); err != nil { + logger.Error("only the owner can update the supplier's owner and operator addresses") + + return nil, err + } + } + currSupplierStake := *supplier.Stake + // Get the previous operator address to update the store by deleting the old + // key if it has been changed. + previousOperatorAddr = supplier.Address if err = k.updateSupplier(ctx, &supplier, msg); err != nil { logger.Error(fmt.Sprintf("could not update supplier for address %q due to error %v", msg.Address, err)) return nil, err @@ -67,21 +92,25 @@ func (k msgServer) StakeSupplier(ctx context.Context, msg *types.MsgStakeSupplie return nil, types.ErrSupplierInvalidStake.Wrapf("supplier %q must escrow more than 0 additional coins", msg.Address) } - // Retrieve the address of the supplier - supplierAddress, err := sdk.AccAddressFromBech32(msg.Address) + // Retrieve the account address of the supplier owner + supplierOwnerAddress, err := sdk.AccAddressFromBech32(msg.OwnerAddress) if err != nil { - logger.Error(fmt.Sprintf("could not parse address %q", msg.Address)) + logger.Error(fmt.Sprintf("could not parse address %q", msg.OwnerAddress)) return nil, err } // Send the coins from the supplier to the staked supplier pool - err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, supplierAddress, types.ModuleName, []sdk.Coin{coinsToEscrow}) + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, supplierOwnerAddress, types.ModuleName, []sdk.Coin{coinsToEscrow}) if err != nil { - logger.Error(fmt.Sprintf("could not send %v coins from %q to %q module account due to %v", coinsToEscrow, supplierAddress, types.ModuleName, err)) + logger.Error(fmt.Sprintf("could not send %v coins from %q to %q module account due to %v", coinsToEscrow, supplierOwnerAddress, types.ModuleName, err)) return nil, err } - logger.Info(fmt.Sprintf("Successfully escrowed %v coins from %q to %q module account", coinsToEscrow, supplierAddress, types.ModuleName)) + logger.Info(fmt.Sprintf("Successfully escrowed %v coins from %q to %q module account", coinsToEscrow, supplierOwnerAddress, types.ModuleName)) + // Remove the previous supplier key if the operator address has changed + if hasDifferentOperatorAddr(previousOperatorAddr, &supplier) { + k.RemoveSupplier(ctx, previousOperatorAddr) + } // Update the Supplier in the store k.SetSupplier(ctx, supplier) logger.Info(fmt.Sprintf("Successfully updated supplier stake for supplier: %+v", supplier)) @@ -90,33 +119,40 @@ func (k msgServer) StakeSupplier(ctx context.Context, msg *types.MsgStakeSupplie return &types.MsgStakeSupplierResponse{}, nil } +// createSupplier creates a new supplier from the given message. func (k msgServer) createSupplier( _ context.Context, msg *types.MsgStakeSupplier, ) sharedtypes.Supplier { return sharedtypes.Supplier{ - Address: msg.Address, - Stake: msg.Stake, - Services: msg.Services, + OwnerAddress: msg.OwnerAddress, + Address: msg.Address, + Stake: msg.Stake, + Services: msg.Services, } } +// updateSupplier updates the given supplier with the given message. func (k msgServer) updateSupplier( _ context.Context, supplier *sharedtypes.Supplier, msg *types.MsgStakeSupplier, ) error { - // Checks if the the msg address is the same as the current owner - if msg.Address != supplier.Address { - return types.ErrSupplierUnauthorized.Wrapf("msg Address %q != supplier address %q", msg.Address, supplier.Address) + // Check if the the msg owner address is the same as the current owner + if msg.OwnerAddress != supplier.OwnerAddress { + return types.ErrSupplierUnauthorized.Wrapf("msg OwnerAddress %q != supplier owner address %q", msg.OwnerAddress, supplier.OwnerAddress) } + // Operator address should be already validated in `msg.ValidateBasic`. + // TODO_CONSIDERATION: Delay the operator address change until the next session. + supplier.Address = msg.Address + // Validate that the stake is not being lowered if msg.Stake == nil { return types.ErrSupplierInvalidStake.Wrapf("stake amount cannot be nil") } - if msg.Stake.IsLTE(*supplier.Stake) { + if msg.Stake.IsLTE(*supplier.Stake) { return types.ErrSupplierInvalidStake.Wrapf("stake amount %v must be higher than previous stake amount %v", msg.Stake, supplier.Stake) } supplier.Stake = msg.Stake @@ -130,3 +166,30 @@ func (k msgServer) updateSupplier( return nil } + +// hasDifferentOperatorAddr checks if the new operator address differs from the old one. +func hasDifferentOperatorAddr(oldOperatorAddress string, supplier *sharedtypes.Supplier) bool { + if oldOperatorAddress == "" { + return false + } + + return oldOperatorAddress != supplier.Address +} + +// ensureMsgSenderIsSupplierOwner returns an error if the message sender is not the supplier owner. +func ensureMsgSenderIsSupplierOwner(msg *types.MsgStakeSupplier) error { + if msg.OwnerAddress == msg.Sender { + types.ErrSupplierUnauthorized.Wrapf( + "owner address %q in the message does not match the msg sender address %q", + msg.OwnerAddress, + msg.Sender, + ) + } + + return nil +} + +// ownerOrOperatorAddressesChanged checks if the owner or operator addresses have changed. +func ownerOrOperatorAddressesChanged(msg *types.MsgStakeSupplier, supplier *sharedtypes.Supplier) bool { + return msg.OwnerAddress != supplier.OwnerAddress || msg.Address != supplier.Address +} diff --git a/x/supplier/keeper/msg_server_unstake_supplier.go b/x/supplier/keeper/msg_server_unstake_supplier.go index c11b1892b..ea54dfef6 100644 --- a/x/supplier/keeper/msg_server_unstake_supplier.go +++ b/x/supplier/keeper/msg_server_unstake_supplier.go @@ -36,6 +36,16 @@ func (k msgServer) UnstakeSupplier( logger.Info(fmt.Sprintf("Supplier not found. Cannot unstake address %s", msg.Address)) return nil, types.ErrSupplierNotFound } + + // Ensure that the message sender is the supplier owner. + if supplier.OwnerAddress != msg.OwnerAddress { + logger.Error(fmt.Sprintf( + "owner address %q in the message does not match the supplier's owner address %q", + msg.OwnerAddress, + supplier.OwnerAddress, + )) + } + logger.Info(fmt.Sprintf("Supplier found. Unstaking supplier for address %s", msg.Address)) // Check if the supplier has already initiated the unstake action. diff --git a/x/supplier/keeper/unbond_suppliers.go b/x/supplier/keeper/unbond_suppliers.go index 63c08a3c4..7dead36df 100644 --- a/x/supplier/keeper/unbond_suppliers.go +++ b/x/supplier/keeper/unbond_suppliers.go @@ -34,20 +34,27 @@ func (k Keeper) EndBlockerUnbondSuppliers(ctx context.Context) error { continue } + // Retrieve the owner address of the supplier. + ownerAddress, err := cosmostypes.AccAddressFromBech32(supplier.OwnerAddress) + if err != nil { + logger.Error(fmt.Sprintf("could not parse the owner address %s", supplier.OwnerAddress)) + return err + } + // Retrieve the address of the supplier. supplierAddress, err := cosmostypes.AccAddressFromBech32(supplier.Address) if err != nil { - logger.Error(fmt.Sprintf("could not parse address %s", supplier.Address)) + logger.Error(fmt.Sprintf("could not parse the operator address %s", supplier.Address)) return err } // Send the coins from the supplier pool back to the supplier. if err = k.bankKeeper.SendCoinsFromModuleToAccount( - ctx, types.ModuleName, supplierAddress, []cosmostypes.Coin{*supplier.Stake}, + ctx, types.ModuleName, ownerAddress, []cosmostypes.Coin{*supplier.Stake}, ); err != nil { logger.Error(fmt.Sprintf( "could not send %s coins from %s module to %s account due to %s", - supplier.Stake.String(), supplierAddress, types.ModuleName, err, + supplier.Stake.String(), ownerAddress, types.ModuleName, err, )) return err } diff --git a/x/supplier/module/tx_stake_supplier.go b/x/supplier/module/tx_stake_supplier.go index a9dd920cf..fcc2c247f 100644 --- a/x/supplier/module/tx_stake_supplier.go +++ b/x/supplier/module/tx_stake_supplier.go @@ -27,7 +27,7 @@ func CmdStakeSupplier() *cobra.Command { will stake the tokens and associate them with the supplier specified by the 'from' address. Example: -$ poktrolld tx supplier stake-supplier --config stake_config.yaml --keyring-backend test --from $(APP) --node $(POCKET_NODE) --home $(POKTROLLD_HOME)`, +$ poktrolld tx supplier stake-supplier --config stake_config.yaml --keyring-backend test --node $(POCKET_NODE) --home $(POKTROLLD_HOME)`, Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, _ []string) (err error) { @@ -41,13 +41,28 @@ $ poktrolld tx supplier stake-supplier --config stake_config.yaml --keyring-back return err } + // Ensure the --from flag is set before getting the client context. + if cmd.Flag(flags.FlagFrom) == nil { + cmd.Flags().Set(flags.FlagFrom, supplierStakeConfigs.OwnerAddress) + } + clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } + // Ensure the from address is the same as the owner address in the stake config file. + if clientCtx.GetFromAddress().String() != supplierStakeConfigs.OwnerAddress { + return types.ErrSupplierInvalidAddress.Wrapf( + "operator address %q in the stake config file does not match the operator address %q in the message", + supplierStakeConfigs.OperatorAddress, + clientCtx.GetFromAddress().String(), + ) + } + msg := types.NewMsgStakeSupplier( - clientCtx.GetFromAddress().String(), + supplierStakeConfigs.OwnerAddress, + supplierStakeConfigs.OperatorAddress, supplierStakeConfigs.StakeAmount, supplierStakeConfigs.Services, ) diff --git a/x/supplier/module/tx_unstake_supplier.go b/x/supplier/module/tx_unstake_supplier.go index 9c5fa8633..d89e15e7e 100644 --- a/x/supplier/module/tx_unstake_supplier.go +++ b/x/supplier/module/tx_unstake_supplier.go @@ -12,13 +12,13 @@ import ( func CmdUnstakeSupplier() *cobra.Command { // fromAddress & signature is retrieved via `flags.FlagFrom` in the `clientCtx` cmd := &cobra.Command{ - Use: "unstake-supplier", + Use: "unstake-supplier ", Short: "Unstake a supplier", - Long: `Unstake an supplier with the provided parameters. This is a broadcast operation that will unstake the supplier specified by the 'from' address. + Long: `Unstake an supplier with the provided parameters. This is a broadcast operation that will unstake the supplier specified by the and owned by 'from' address. Example: -$ poktrolld --home=$(POKTROLLD_HOME) tx supplier unstake-supplier --keyring-backend test --from $(SUPPLIER) --node $(POCKET_NODE)`, - Args: cobra.ExactArgs(0), +$ poktrolld --home=$(POKTROLLD_HOME) tx supplier unstake-supplier $(OPERATOR_ADDRESS) --keyring-backend test --from $(SUPPLIER) --node $(POCKET_NODE)`, + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) @@ -26,8 +26,12 @@ $ poktrolld --home=$(POKTROLLD_HOME) tx supplier unstake-supplier --keyring-back return err } + // address is the operator address of the supplier + address := args[0] + msg := types.NewMsgUnstakeSupplier( clientCtx.GetFromAddress().String(), + address, ) if err := msg.ValidateBasic(); err != nil { return err diff --git a/x/supplier/types/message_stake_supplier.go b/x/supplier/types/message_stake_supplier.go index 1c9ef498b..7bcca9d3b 100644 --- a/x/supplier/types/message_stake_supplier.go +++ b/x/supplier/types/message_stake_supplier.go @@ -12,18 +12,25 @@ const TypeMsgStakeSupplier = "stake_supplier" var _ sdk.Msg = (*MsgStakeSupplier)(nil) func NewMsgStakeSupplier( - address string, + ownerAddress string, + supplierAddress string, stake sdk.Coin, services []*sharedtypes.SupplierServiceConfig, ) *MsgStakeSupplier { return &MsgStakeSupplier{ - Address: address, - Stake: &stake, - Services: services, + OwnerAddress: ownerAddress, + Address: supplierAddress, + Stake: &stake, + Services: services, } } func (msg *MsgStakeSupplier) ValidateBasic() error { + // Validate the owner address + if _, err := sdk.AccAddressFromBech32(msg.OwnerAddress); err != nil { + return ErrSupplierInvalidAddress.Wrapf("invalid owner address %s; (%v)", msg.OwnerAddress, err) + } + // Validate the address if _, err := sdk.AccAddressFromBech32(msg.Address); err != nil { return ErrSupplierInvalidAddress.Wrapf("invalid supplier address %s; (%v)", msg.Address, err) diff --git a/x/supplier/types/message_unstake_supplier.go b/x/supplier/types/message_unstake_supplier.go index 245317ebf..affecdb4b 100644 --- a/x/supplier/types/message_unstake_supplier.go +++ b/x/supplier/types/message_unstake_supplier.go @@ -6,15 +6,21 @@ const TypeMsgUnstakeSupplier = "unstake_supplier" var _ sdk.Msg = (*MsgUnstakeSupplier)(nil) -func NewMsgUnstakeSupplier(address string) *MsgUnstakeSupplier { +func NewMsgUnstakeSupplier(ownerAddress, address string) *MsgUnstakeSupplier { return &MsgUnstakeSupplier{ - Address: address, + OwnerAddress: ownerAddress, + Address: address, } } func (msg *MsgUnstakeSupplier) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.OwnerAddress); err != nil { + return ErrSupplierInvalidAddress.Wrapf("invalid address address (%s)", err) + } + if _, err := sdk.AccAddressFromBech32(msg.Address); err != nil { return ErrSupplierInvalidAddress.Wrapf("invalid address address (%s)", err) } + return nil } diff --git a/x/supplier/types/tx.pb.go b/x/supplier/types/tx.pb.go index ce0018a0f..019041ce8 100644 --- a/x/supplier/types/tx.pb.go +++ b/x/supplier/types/tx.pb.go @@ -128,9 +128,11 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo type MsgStakeSupplier struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - Stake *types.Coin `protobuf:"bytes,2,opt,name=stake,proto3" json:"stake,omitempty"` - Services []*types1.SupplierServiceConfig `protobuf:"bytes,3,rep,name=services,proto3" json:"services,omitempty"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + OwnerAddress string `protobuf:"bytes,2,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` + Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` + Stake *types.Coin `protobuf:"bytes,4,opt,name=stake,proto3" json:"stake,omitempty"` + Services []*types1.SupplierServiceConfig `protobuf:"bytes,5,rep,name=services,proto3" json:"services,omitempty"` } func (m *MsgStakeSupplier) Reset() { *m = MsgStakeSupplier{} } @@ -166,6 +168,20 @@ func (m *MsgStakeSupplier) XXX_DiscardUnknown() { var xxx_messageInfo_MsgStakeSupplier proto.InternalMessageInfo +func (m *MsgStakeSupplier) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgStakeSupplier) GetOwnerAddress() string { + if m != nil { + return m.OwnerAddress + } + return "" +} + func (m *MsgStakeSupplier) GetAddress() string { if m != nil { return m.Address @@ -224,7 +240,8 @@ func (m *MsgStakeSupplierResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgStakeSupplierResponse proto.InternalMessageInfo type MsgUnstakeSupplier struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` } func (m *MsgUnstakeSupplier) Reset() { *m = MsgUnstakeSupplier{} } @@ -260,6 +277,13 @@ func (m *MsgUnstakeSupplier) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUnstakeSupplier proto.InternalMessageInfo +func (m *MsgUnstakeSupplier) GetOwnerAddress() string { + if m != nil { + return m.OwnerAddress + } + return "" +} + func (m *MsgUnstakeSupplier) GetAddress() string { if m != nil { return m.Address @@ -315,41 +339,44 @@ func init() { func init() { proto.RegisterFile("poktroll/supplier/tx.proto", fileDescriptor_63b974929807ef57) } var fileDescriptor_63b974929807ef57 = []byte{ - // 538 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0xb1, 0x6f, 0xd3, 0x4e, - 0x18, 0x8d, 0x1b, 0xb5, 0xbf, 0x5f, 0xae, 0x45, 0xa5, 0x56, 0xa5, 0x3a, 0x16, 0x98, 0xc8, 0x15, - 0x28, 0x0a, 0x8a, 0x4f, 0x09, 0x52, 0x87, 0x8a, 0x85, 0x74, 0x44, 0x91, 0x90, 0x23, 0x18, 0x18, - 0x40, 0x97, 0xe4, 0xb8, 0x58, 0x89, 0x7d, 0xd6, 0xdd, 0x25, 0xb4, 0x1b, 0x62, 0x64, 0xe2, 0xcf, - 0x60, 0xcc, 0xc0, 0xc0, 0xc6, 0x5a, 0xb6, 0x8a, 0x89, 0x09, 0xa1, 0x64, 0xc8, 0xbf, 0x81, 0xec, - 0xbb, 0x73, 0x88, 0x13, 0xd4, 0x4a, 0x2c, 0x89, 0x7d, 0xef, 0x7d, 0xdf, 0x7b, 0xef, 0xfb, 0x7c, - 0xc0, 0x8e, 0xe9, 0x50, 0x30, 0x3a, 0x1a, 0x41, 0x3e, 0x8e, 0xe3, 0x51, 0x80, 0x19, 0x14, 0xe7, - 0x5e, 0xcc, 0xa8, 0xa0, 0xe6, 0x81, 0xc6, 0x3c, 0x8d, 0xd9, 0x07, 0x28, 0x0c, 0x22, 0x0a, 0xd3, - 0x5f, 0xc9, 0xb2, 0x8f, 0x7a, 0x94, 0x87, 0x94, 0xc3, 0x90, 0x13, 0x38, 0x69, 0x24, 0x7f, 0x0a, - 0x28, 0x4b, 0xe0, 0x75, 0xfa, 0x06, 0xe5, 0x8b, 0x82, 0x0e, 0x09, 0x25, 0x54, 0x9e, 0x27, 0x4f, - 0xea, 0xd4, 0x51, 0x9d, 0xba, 0x88, 0x63, 0x38, 0x69, 0x74, 0xb1, 0x40, 0x0d, 0xd8, 0xa3, 0x41, - 0xa4, 0xf1, 0x75, 0xaf, 0x31, 0x62, 0x28, 0xd4, 0x5d, 0xef, 0x2e, 0xf1, 0x01, 0x62, 0xb8, 0x0f, - 0x39, 0x66, 0x93, 0xa0, 0x87, 0x25, 0xec, 0x7e, 0x35, 0xc0, 0x7e, 0x9b, 0x93, 0xe7, 0x71, 0x1f, - 0x09, 0xfc, 0x2c, 0x2d, 0x34, 0x4f, 0x40, 0x09, 0x8d, 0xc5, 0x80, 0xb2, 0x40, 0x5c, 0x58, 0x46, - 0xc5, 0xa8, 0x96, 0x5a, 0xd6, 0xf7, 0xcf, 0xf5, 0x43, 0xe5, 0xf6, 0x49, 0xbf, 0xcf, 0x30, 0xe7, - 0x1d, 0xc1, 0x82, 0x88, 0xf8, 0x4b, 0xaa, 0xf9, 0x18, 0xec, 0x48, 0x69, 0x6b, 0xab, 0x62, 0x54, - 0x77, 0x9b, 0x65, 0x6f, 0x6d, 0x56, 0x9e, 0x94, 0x68, 0x95, 0x2e, 0x7f, 0xde, 0x2b, 0x7c, 0x5a, - 0x4c, 0x6b, 0x86, 0xaf, 0x6a, 0x4e, 0x4f, 0xde, 0x2f, 0xa6, 0xb5, 0x65, 0xb7, 0x0f, 0x8b, 0x69, - 0xed, 0x38, 0xf3, 0x7e, 0xbe, 0x4c, 0x97, 0x73, 0xeb, 0x96, 0xc1, 0x51, 0xee, 0xc8, 0xc7, 0x3c, - 0xa6, 0x11, 0xc7, 0xee, 0x37, 0x03, 0xdc, 0x6e, 0x73, 0xd2, 0x11, 0x68, 0x88, 0x3b, 0xaa, 0xde, - 0x6c, 0x82, 0xff, 0x90, 0x4c, 0x70, 0x6d, 0x36, 0x4d, 0x34, 0x21, 0xd8, 0xe6, 0x49, 0x93, 0x2c, - 0x98, 0xa2, 0x27, 0x4b, 0xf1, 0xd4, 0x52, 0xbc, 0x33, 0x1a, 0x44, 0xbe, 0xe4, 0x99, 0x2d, 0xf0, - 0xbf, 0x9a, 0x33, 0xb7, 0x8a, 0x95, 0x62, 0x75, 0xb7, 0xf9, 0xe0, 0x8f, 0x61, 0xa4, 0x8b, 0xf0, - 0xb4, 0xa3, 0x8e, 0x24, 0x9e, 0xd1, 0xe8, 0x4d, 0x40, 0xfc, 0xac, 0xee, 0x74, 0x2f, 0x19, 0x88, - 0xb6, 0xe0, 0xda, 0xc0, 0xca, 0x47, 0xc9, 0x72, 0xbe, 0x00, 0x66, 0x32, 0x82, 0x88, 0xff, 0x6b, - 0xd0, 0x9c, 0xe6, 0x1d, 0x60, 0xaf, 0xf7, 0xd5, 0xaa, 0xcd, 0x2f, 0x5b, 0xa0, 0xd8, 0xe6, 0xc4, - 0x7c, 0x05, 0xf6, 0x56, 0x3e, 0x1f, 0x77, 0xc3, 0xda, 0x73, 0x1b, 0xb2, 0x6b, 0xd7, 0x73, 0xb4, - 0x8e, 0x89, 0xc0, 0xad, 0xd5, 0x0d, 0x1e, 0x6f, 0x2e, 0x5e, 0x21, 0xd9, 0x0f, 0x6f, 0x40, 0xca, - 0x24, 0x08, 0xd8, 0xcf, 0x4f, 0xef, 0xfe, 0x5f, 0x1c, 0xae, 0xd2, 0xec, 0xfa, 0x8d, 0x68, 0x5a, - 0xc8, 0xde, 0x7e, 0x97, 0x7c, 0xf3, 0xad, 0xa7, 0x97, 0x33, 0xc7, 0xb8, 0x9a, 0x39, 0xc6, 0xaf, - 0x99, 0x63, 0x7c, 0x9c, 0x3b, 0x85, 0xab, 0xb9, 0x53, 0xf8, 0x31, 0x77, 0x0a, 0x2f, 0x1b, 0x24, - 0x10, 0x83, 0x71, 0xd7, 0xeb, 0xd1, 0x10, 0x26, 0x9d, 0xeb, 0x11, 0x16, 0x6f, 0x29, 0x1b, 0xc2, - 0x4d, 0x57, 0x41, 0x5c, 0xc4, 0x98, 0x77, 0x77, 0xd2, 0x9b, 0xfc, 0xe8, 0x77, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x5d, 0x53, 0x46, 0x3c, 0xb6, 0x04, 0x00, 0x00, + // 584 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x31, 0x8f, 0x12, 0x41, + 0x18, 0x65, 0x39, 0x41, 0x19, 0xee, 0x72, 0xde, 0xe4, 0x92, 0x5b, 0x36, 0xba, 0x92, 0xbd, 0x68, + 0x08, 0x86, 0x1d, 0xc1, 0xe4, 0x0a, 0xa2, 0x85, 0x5c, 0x69, 0x48, 0x0c, 0xc4, 0xc6, 0xc2, 0xcb, + 0x00, 0xe3, 0xb2, 0x01, 0x76, 0x36, 0x33, 0x03, 0x77, 0xd7, 0x19, 0x4b, 0x2b, 0x7b, 0xff, 0x80, + 0x25, 0x85, 0x85, 0x56, 0xb6, 0x57, 0x5e, 0xac, 0xac, 0x8c, 0x81, 0x82, 0xbf, 0x61, 0x76, 0x77, + 0x06, 0x5c, 0x40, 0x21, 0x36, 0xc0, 0xce, 0x7b, 0x6f, 0xbe, 0xf7, 0xbd, 0xef, 0x5b, 0x80, 0xe1, + 0xd3, 0x9e, 0x60, 0xb4, 0xdf, 0x47, 0x7c, 0xe8, 0xfb, 0x7d, 0x97, 0x30, 0x24, 0x2e, 0x6c, 0x9f, + 0x51, 0x41, 0xe1, 0x81, 0xc2, 0x6c, 0x85, 0x19, 0x07, 0x78, 0xe0, 0x7a, 0x14, 0x85, 0x9f, 0x11, + 0xcb, 0x38, 0x6a, 0x53, 0x3e, 0xa0, 0x1c, 0x0d, 0xb8, 0x83, 0x46, 0xe5, 0xe0, 0x4b, 0x02, 0xb9, + 0x08, 0x38, 0x0b, 0x9f, 0x50, 0xf4, 0x20, 0xa1, 0x43, 0x87, 0x3a, 0x34, 0x3a, 0x0f, 0x7e, 0xc9, + 0x53, 0x53, 0xde, 0xd4, 0xc2, 0x9c, 0xa0, 0x51, 0xb9, 0x45, 0x04, 0x2e, 0xa3, 0x36, 0x75, 0x3d, + 0x85, 0xaf, 0x7a, 0xf5, 0x31, 0xc3, 0x03, 0x75, 0xeb, 0xdd, 0x05, 0xde, 0xc5, 0x8c, 0x74, 0x10, + 0x27, 0x6c, 0xe4, 0xb6, 0x49, 0x04, 0x5b, 0xdf, 0x34, 0xb0, 0x5f, 0xe7, 0xce, 0x4b, 0xbf, 0x83, + 0x05, 0x79, 0x11, 0x0a, 0xe1, 0x09, 0xc8, 0xe0, 0xa1, 0xe8, 0x52, 0xe6, 0x8a, 0x4b, 0x5d, 0xcb, + 0x6b, 0x85, 0x4c, 0x4d, 0xff, 0xfe, 0xb9, 0x74, 0x28, 0xdd, 0x3e, 0xeb, 0x74, 0x18, 0xe1, 0xbc, + 0x29, 0x98, 0xeb, 0x39, 0x8d, 0x05, 0x15, 0x3e, 0x01, 0xe9, 0xa8, 0xb4, 0x9e, 0xcc, 0x6b, 0x85, + 0x6c, 0x25, 0x67, 0xaf, 0x64, 0x65, 0x47, 0x25, 0x6a, 0x99, 0xab, 0x9f, 0xf7, 0x12, 0x9f, 0x66, + 0xe3, 0xa2, 0xd6, 0x90, 0x9a, 0xea, 0xc9, 0xbb, 0xd9, 0xb8, 0xb8, 0xb8, 0xed, 0xfd, 0x6c, 0x5c, + 0x3c, 0x9e, 0x7b, 0xbf, 0x58, 0x74, 0xb7, 0xe4, 0xd6, 0xca, 0x81, 0xa3, 0xa5, 0xa3, 0x06, 0xe1, + 0x3e, 0xf5, 0x38, 0xb1, 0xbe, 0x26, 0xc1, 0xed, 0x3a, 0x77, 0x9a, 0x02, 0xf7, 0x48, 0x53, 0xea, + 0xe1, 0x23, 0x90, 0xe6, 0xc4, 0xeb, 0x10, 0xb6, 0xb1, 0x35, 0xc9, 0x83, 0x4f, 0xc1, 0x1e, 0x3d, + 0xf7, 0x08, 0x3b, 0xc3, 0x11, 0x1c, 0xb6, 0xf7, 0x2f, 0xe1, 0x6e, 0x48, 0x97, 0x67, 0xb0, 0x02, + 0x6e, 0x2a, 0xe1, 0xce, 0x06, 0xa1, 0x22, 0x42, 0x04, 0x52, 0x3c, 0x70, 0xad, 0xdf, 0x90, 0x49, + 0x4a, 0x7a, 0xb0, 0x05, 0xb6, 0xdc, 0x02, 0xfb, 0x94, 0xba, 0x5e, 0x23, 0xe2, 0xc1, 0x1a, 0xb8, + 0x25, 0x07, 0xcb, 0xf5, 0x54, 0x7e, 0xa7, 0x90, 0xad, 0x3c, 0xf8, 0x23, 0xfd, 0x70, 0xf2, 0xb6, + 0x8a, 0xa0, 0x19, 0x11, 0x4f, 0xa9, 0xf7, 0xc6, 0x75, 0x1a, 0x73, 0x5d, 0x35, 0x1b, 0x4c, 0x40, + 0x36, 0x6d, 0x19, 0x40, 0x5f, 0x8e, 0x6e, 0x9e, 0xeb, 0x47, 0x0d, 0xc0, 0x20, 0x73, 0x8f, 0xc7, + 0x92, 0x5d, 0xc9, 0x49, 0xfb, 0xdf, 0x9c, 0x92, 0x5b, 0xe6, 0x54, 0x85, 0x81, 0xe5, 0x78, 0x55, + 0xeb, 0x0e, 0x30, 0x56, 0xcd, 0x29, 0xef, 0x95, 0x2f, 0x49, 0xb0, 0x53, 0xe7, 0x0e, 0x7c, 0x0d, + 0x76, 0x63, 0x4b, 0x6f, 0xad, 0x59, 0xd6, 0xa5, 0xbd, 0x32, 0x8a, 0x9b, 0x39, 0xaa, 0x0e, 0xc4, + 0x60, 0x2f, 0xbe, 0x77, 0xc7, 0xeb, 0xc5, 0x31, 0x92, 0xf1, 0x70, 0x0b, 0xd2, 0xbc, 0x84, 0x03, + 0xf6, 0x97, 0x47, 0x70, 0xff, 0x2f, 0x0e, 0xe3, 0x34, 0xa3, 0xb4, 0x15, 0x4d, 0x15, 0x32, 0x52, + 0x6f, 0x83, 0x37, 0xb5, 0xf6, 0xfc, 0x6a, 0x62, 0x6a, 0xd7, 0x13, 0x53, 0xfb, 0x35, 0x31, 0xb5, + 0x0f, 0x53, 0x33, 0x71, 0x3d, 0x35, 0x13, 0x3f, 0xa6, 0x66, 0xe2, 0x55, 0xd9, 0x71, 0x45, 0x77, + 0xd8, 0xb2, 0xdb, 0x74, 0x80, 0x82, 0x9b, 0x4b, 0x1e, 0x11, 0xe7, 0x94, 0xf5, 0xd0, 0xba, 0x17, + 0x58, 0x5c, 0xfa, 0x84, 0xb7, 0xd2, 0xe1, 0xff, 0xcf, 0xe3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, + 0xb9, 0x89, 0x76, 0x77, 0x6c, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -602,7 +629,7 @@ func (m *MsgStakeSupplier) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x2a } } if m.Stake != nil { @@ -615,13 +642,27 @@ func (m *MsgStakeSupplier) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x22 } if len(m.Address) > 0 { i -= len(m.Address) copy(dAtA[i:], m.Address) i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) i-- + dAtA[i] = 0x1a + } + 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] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -675,6 +716,13 @@ func (m *MsgUnstakeSupplier) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Address) i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) i-- + dAtA[i] = 0x12 + } + 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 } return len(dAtA) - i, nil @@ -744,6 +792,14 @@ func (m *MsgStakeSupplier) Size() (n int) { } var l int _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.OwnerAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } l = len(m.Address) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -776,6 +832,10 @@ func (m *MsgUnstakeSupplier) Size() (n int) { } var l int _ = l + l = len(m.OwnerAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } l = len(m.Address) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -993,6 +1053,70 @@ func (m *MsgStakeSupplier) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OwnerAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } @@ -1024,7 +1148,7 @@ func (m *MsgStakeSupplier) Unmarshal(dAtA []byte) error { } m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Stake", wireType) } @@ -1060,7 +1184,7 @@ func (m *MsgStakeSupplier) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Services", wireType) } @@ -1195,6 +1319,38 @@ func (m *MsgUnstakeSupplier) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OwnerAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } diff --git a/x/tokenomics/keeper/keeper.go b/x/tokenomics/keeper/keeper.go index 8952a9e0a..f6c63d2cd 100644 --- a/x/tokenomics/keeper/keeper.go +++ b/x/tokenomics/keeper/keeper.go @@ -29,6 +29,7 @@ type Keeper struct { proofKeeper types.ProofKeeper sharedKeeper types.SharedKeeper sessionKeeper types.SessionKeeper + supplierKeeper types.SupplierKeeper sharedQuerier client.SharedQueryClient } @@ -45,6 +46,7 @@ func NewKeeper( proofKeeper types.ProofKeeper, sharedKeeper types.SharedKeeper, sessionKeeper types.SessionKeeper, + supplierKeeper types.SupplierKeeper, ) Keeper { if _, err := sdk.AccAddressFromBech32(authority); err != nil { panic(fmt.Sprintf("invalid authority address: %s", authority)) diff --git a/x/tokenomics/keeper/settle_session_accounting.go b/x/tokenomics/keeper/settle_session_accounting.go index 6f4f12763..ec3a73aea 100644 --- a/x/tokenomics/keeper/settle_session_accounting.go +++ b/x/tokenomics/keeper/settle_session_accounting.go @@ -69,6 +69,16 @@ func (k Keeper) SettleSessionAccounting( return tokenomicstypes.ErrTokenomicsSupplierAddressInvalid } + supplier, supplierFound := k.supplierKeeper.GetSupplier(ctx, supplierAddr.String()) + if !supplierFound { + return tokenomicstypes.ErrTokenomicsSupplierNotFound + } + + supplierOwnerAddr, err := cosmostypes.AccAddressFromBech32(supplier.OwnerAddress) + if err != nil || supplierOwnerAddr == nil { + return tokenomicstypes.ErrTokenomicsSupplierOwnerAddressInvalid + } + applicationAddress, err := cosmostypes.AccAddressFromBech32(sessionHeader.GetApplicationAddress()) if err != nil || applicationAddress == nil { return tokenomicstypes.ErrTokenomicsApplicationAddressInvalid @@ -151,16 +161,16 @@ func (k Keeper) SettleSessionAccounting( // Send the newley minted uPOKT from the supplier module account // to the supplier's account. if err = k.bankKeeper.SendCoinsFromModuleToAccount( - ctx, suppliertypes.ModuleName, supplierAddr, settlementCoins, + ctx, suppliertypes.ModuleName, supplierOwnerAddr, settlementCoins, ); err != nil { return tokenomicstypes.ErrTokenomicsSupplierModuleMintFailed.Wrapf( "sending %s to supplier with address %s: %v", settlementCoin, - supplierAddr, + supplierOwnerAddr, err, ) } - logger.Info(fmt.Sprintf("sent %s from the supplier module to the supplier account with address %q", settlementCoin, supplierAddr)) + logger.Info(fmt.Sprintf("sent %s from the supplier module to the supplier owner account with address %q", settlementCoin, supplierOwnerAddr)) // Verify that the application has enough uPOKT to pay for the services it consumed if application.GetStake().IsLT(settlementCoin) { diff --git a/x/tokenomics/module/module.go b/x/tokenomics/module/module.go index 2e857d5fd..b52a372cb 100644 --- a/x/tokenomics/module/module.go +++ b/x/tokenomics/module/module.go @@ -97,6 +97,7 @@ type AppModule struct { tokenomicsKeeper keeper.Keeper accountKeeper types.AccountKeeper bankKeeper types.BankKeeper + supplierKeeper types.SupplierKeeper } func NewAppModule( @@ -104,12 +105,14 @@ func NewAppModule( tokenomicsKeeper keeper.Keeper, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, + supplierKeeper types.SupplierKeeper, ) AppModule { return AppModule{ AppModuleBasic: NewAppModuleBasic(cdc), tokenomicsKeeper: tokenomicsKeeper, accountKeeper: accountKeeper, bankKeeper: bankKeeper, + supplierKeeper: supplierKeeper, } } @@ -183,6 +186,7 @@ type ModuleInputs struct { ProofKeeper types.ProofKeeper SharedKeeper types.SharedKeeper SessionKeeper types.SessionKeeper + SupplierKeeper types.SupplierKeeper } type ModuleOutputs struct { @@ -209,12 +213,14 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { in.ProofKeeper, in.SharedKeeper, in.SessionKeeper, + in.SupplierKeeper, ) m := NewAppModule( in.Cdc, k, in.AccountKeeper, in.BankKeeper, + in.SupplierKeeper, ) return ModuleOutputs{TokenomicsKeeper: k, Module: m} diff --git a/x/tokenomics/types/errors.go b/x/tokenomics/types/errors.go index 812b3746a..c887c15e3 100644 --- a/x/tokenomics/types/errors.go +++ b/x/tokenomics/types/errors.go @@ -27,4 +27,6 @@ var ( ErrTokenomicsDuplicateIndex = sdkerrors.Register(ModuleName, 1119, "cannot have a duplicate index") ErrTokenomicsMissingRelayMiningDifficulty = sdkerrors.Register(ModuleName, 1120, "missing relay mining difficulty") ErrTokenomicsApplicationOverserviced = sdkerrors.Register(ModuleName, 1121, "application was overserviced") + ErrTokenomicsSupplierNotFound = sdkerrors.Register(ModuleName, 1122, "supplier not found") + ErrTokenomicsSupplierOwnerAddressInvalid = sdkerrors.Register(ModuleName, 1123, "the supplier owner address is not a valid bech32 address") ) diff --git a/x/tokenomics/types/expected_keepers.go b/x/tokenomics/types/expected_keepers.go index 26babd982..4de0e7e97 100644 --- a/x/tokenomics/types/expected_keepers.go +++ b/x/tokenomics/types/expected_keepers.go @@ -1,4 +1,4 @@ -//go:generate mockgen -destination ../../../testutil/tokenomics/mocks/expected_keepers_mock.go -package mocks . AccountKeeper,BankKeeper,ApplicationKeeper,ProofKeeper,SharedKeeper,SessionKeeper +//go:generate mockgen -destination ../../../testutil/tokenomics/mocks/expected_keepers_mock.go -package mocks . AccountKeeper,BankKeeper,ApplicationKeeper,ProofKeeper,SharedKeeper,SessionKeeper,SupplierKeeper package types diff --git a/x/tokenomics/types/tx.pb.go b/x/tokenomics/types/tx.pb.go index 03eea41a6..6a9db5288 100644 --- a/x/tokenomics/types/tx.pb.go +++ b/x/tokenomics/types/tx.pb.go @@ -130,9 +130,10 @@ type MsgUpdateParam struct { // authority is the address that controls the module (defaults to x/gov unless overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` // The (name, as_type) tuple must match the corresponding name and type as - // specified in the `Params`` message in `proof/params.proto.` + // 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 From 676c2c48d2178af4609e2b9889049b9a4745608b Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Fri, 2 Aug 2024 01:26:53 +0200 Subject: [PATCH 02/14] chore: Address review change requests --- api/poktroll/shared/supplier.pulsar.go | 19 +++-- api/poktroll/supplier/tx.pulsar.go | 11 ++- proto/poktroll/shared/supplier.proto | 21 ++--- proto/poktroll/supplier/tx.proto | 13 ++- x/shared/types/errors.go | 11 +-- x/shared/types/supplier.go | 26 ++++++ x/shared/types/supplier.pb.go | 17 ++-- x/supplier/config/errors.go | 2 +- x/supplier/config/supplier_configs_reader.go | 21 ++++- .../keeper/msg_server_stake_supplier.go | 84 +++++++------------ .../keeper/msg_server_unstake_supplier.go | 4 +- x/supplier/module/tx_stake_supplier.go | 16 ++-- x/supplier/module/tx_unstake_supplier.go | 2 +- x/supplier/types/errors.go | 19 ++--- x/supplier/types/tx.pb.go | 11 ++- 15 files changed, 162 insertions(+), 115 deletions(-) diff --git a/api/poktroll/shared/supplier.pulsar.go b/api/poktroll/shared/supplier.pulsar.go index 2777fbbec..b9d982090 100644 --- a/api/poktroll/shared/supplier.pulsar.go +++ b/api/poktroll/shared/supplier.pulsar.go @@ -782,15 +782,16 @@ type Supplier struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The Bech32 address of the owner (i.e. custodial, staker) using cosmos' - // ScalarDescriptor to ensure deterministic encoding. - // This is the address that owns the funds for staking and is the one that - // receives the rewards. - OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` - // The Bech32 address of the operator (i.e. provider, non-custodial) using cosmos' - // ScalarDescriptor to ensure deterministic encoding. - // The operator address can update all the supplier's configurations, excluding - // the owner_address. + // The address of the owner (i.e. staker, custodial) that owns the funds for staking. + // By default, this address is the one that receives all the rewards unless owtherwise specified. + // The owner can initially stake the supplier and unstake it. + // All other configurations are managed by the operator. + OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` // Bech32 cosmos address + // The operator address of the supplier that operates it. + // The operator address can update the supplier's configurations excluding the owner + // and operator addresses which do not change over the supplier's lifespan. + // TODO(red-0ne): Rename this to `operator_address` include all downstream + // variables, comments, docs, tests, etc... Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` Stake *v1beta1.Coin `protobuf:"bytes,3,opt,name=stake,proto3" json:"stake,omitempty"` // The total amount of uPOKT the supplier has staked Services []*SupplierServiceConfig `protobuf:"bytes,4,rep,name=services,proto3" json:"services,omitempty"` // The service configs this supplier can support diff --git a/api/poktroll/supplier/tx.pulsar.go b/api/poktroll/supplier/tx.pulsar.go index bf92b079a..e22a38e40 100644 --- a/api/poktroll/supplier/tx.pulsar.go +++ b/api/poktroll/supplier/tx.pulsar.go @@ -3020,8 +3020,17 @@ type MsgUnstakeSupplier struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // The address of the owner (i.e. staker, custodial) that owns the funds for staking. + // By default, this address is the one that receives all the rewards unless owtherwise specified. + // The owner can initially stake the supplier and unstake it. + // All other configurations are managed by the operator. OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` // The Bech32 address of the owner (i.e. custodial, staker) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the operator (i.e. provider, non-custodial) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + // The operator address of the supplier that operates it. + // The operator address can update the supplier's configurations excluding the owner + // and operator addresses which do not change over the supplier's lifespan. + // TODO(red-0ne): Rename this to `operator_address` include all downstream + // variables, comments, docs, tests, etc... + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the operator (i.e. provider, non-custodial) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding } func (x *MsgUnstakeSupplier) Reset() { diff --git a/proto/poktroll/shared/supplier.proto b/proto/poktroll/shared/supplier.proto index 8964ec5f1..9d15703f1 100644 --- a/proto/poktroll/shared/supplier.proto +++ b/proto/poktroll/shared/supplier.proto @@ -10,16 +10,17 @@ import "poktroll/shared/service.proto"; // Supplier is the type defining the actor in Pocket Network that provides RPC services. message Supplier { - // The Bech32 address of the owner (i.e. custodial, staker) using cosmos' - // ScalarDescriptor to ensure deterministic encoding. - // This is the address that owns the funds for staking and is the one that - // receives the rewards. - string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // The Bech32 address of the operator (i.e. provider, non-custodial) using cosmos' - // ScalarDescriptor to ensure deterministic encoding. - // The operator address can update all the supplier's configurations, excluding - // the owner_address. - string address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // The address of the owner (i.e. staker, custodial) that owns the funds for staking. + // By default, this address is the one that receives all the rewards unless owtherwise specified. + // The owner can initially stake the supplier and unstake it. + // All other configurations are managed by the operator. + string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // Bech32 cosmos address + // The operator address of the supplier that operates it. + // The operator address can update the supplier's configurations excluding the owner + // and operator addresses which do not change over the supplier's lifespan. + // TODO(red-0ne): Rename this to `operator_address` include all downstream + // variables, comments, docs, tests, etc... + string address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // Bech32 cosmos address cosmos.base.v1beta1.Coin stake = 3; // The total amount of uPOKT the supplier has staked repeated SupplierServiceConfig services = 4; // The service configs this supplier can support // The session end height at which an actively unbonding supplier unbonds its stake. diff --git a/proto/poktroll/supplier/tx.proto b/proto/poktroll/supplier/tx.proto index bcf5e97ef..9b1a079ce 100644 --- a/proto/poktroll/supplier/tx.proto +++ b/proto/poktroll/supplier/tx.proto @@ -58,8 +58,17 @@ message MsgStakeSupplierResponse {} message MsgUnstakeSupplier { option (cosmos.msg.v1.signer) = "owner_address"; - string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the owner (i.e. custodial, staker) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding - string address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the operator (i.e. provider, non-custodial) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + // The address of the owner (i.e. staker, custodial) that owns the funds for staking. + // By default, this address is the one that receives all the rewards unless owtherwise specified. + // The owner can initially stake the supplier and unstake it. + // All other configurations are managed by the operator. + string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address + // The operator address of the supplier that operates it. + // The operator address can update the supplier's configurations excluding the owner + // and operator addresses which do not change over the supplier's lifespan. + // TODO(red-0ne): Rename this to `operator_address` include all downstream + // variables, comments, docs, tests, etc... + string address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address } message MsgUnstakeSupplierResponse {} diff --git a/x/shared/types/errors.go b/x/shared/types/errors.go index df55eb100..c4e129a1c 100644 --- a/x/shared/types/errors.go +++ b/x/shared/types/errors.go @@ -8,9 +8,10 @@ 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") + 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") ) diff --git a/x/shared/types/supplier.go b/x/shared/types/supplier.go index ac6fe4782..9f37a342b 100644 --- a/x/shared/types/supplier.go +++ b/x/shared/types/supplier.go @@ -21,3 +21,29 @@ func (s *Supplier) IsActive(queryHeight int64) bool { // will also need to be updated to reflect sessions when the supplier is not active. return !s.IsUnbonding() || uint64(queryHeight) <= s.UnstakeSessionEndHeight } + +// EnsureOwner returns an error if the given address does not match supplier's owner address. +func (s *Supplier) EnsureOwner(ownerAddress string) error { + if s.OwnerAddress != ownerAddress { + return ErrSharedUnauthorizedSupplierUpdate.Wrapf( + "msg.OwnerAddress %q != provided address %q", + s.OwnerAddress, + ownerAddress, + ) + } + + return nil +} + +// EnsureOperator returns an error if the given address does not match supplier's operator address. +func (s *Supplier) EnsureOperator(operatorAddress string) error { + if s.Address != operatorAddress { + return ErrSharedUnauthorizedSupplierUpdate.Wrapf( + "msg.OperatorAddress %q != provided address %q", + s.OwnerAddress, + operatorAddress, + ) + } + + return nil +} diff --git a/x/shared/types/supplier.pb.go b/x/shared/types/supplier.pb.go index 72987c04b..9b4eed160 100644 --- a/x/shared/types/supplier.pb.go +++ b/x/shared/types/supplier.pb.go @@ -26,15 +26,16 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Supplier is the type defining the actor in Pocket Network that provides RPC services. type Supplier struct { - // The Bech32 address of the owner (i.e. custodial, staker) using cosmos' - // ScalarDescriptor to ensure deterministic encoding. - // This is the address that owns the funds for staking and is the one that - // receives the rewards. + // The address of the owner (i.e. staker, custodial) that owns the funds for staking. + // By default, this address is the one that receives all the rewards unless owtherwise specified. + // The owner can initially stake the supplier and unstake it. + // All other configurations are managed by the operator. OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` - // The Bech32 address of the operator (i.e. provider, non-custodial) using cosmos' - // ScalarDescriptor to ensure deterministic encoding. - // The operator address can update all the supplier's configurations, excluding - // the owner_address. + // The operator address of the supplier that operates it. + // The operator address can update the supplier's configurations excluding the owner + // and operator addresses which do not change over the supplier's lifespan. + // TODO(red-0ne): Rename this to `operator_address` include all downstream + // variables, comments, docs, tests, etc... Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` Stake *types.Coin `protobuf:"bytes,3,opt,name=stake,proto3" json:"stake,omitempty"` Services []*SupplierServiceConfig `protobuf:"bytes,4,rep,name=services,proto3" json:"services,omitempty"` diff --git a/x/supplier/config/errors.go b/x/supplier/config/errors.go index 78bb14f4a..bfa46177b 100644 --- a/x/supplier/config/errors.go +++ b/x/supplier/config/errors.go @@ -15,5 +15,5 @@ var ( ErrSupplierConfigInvalidURL = sdkerrors.Register(types.ModuleName, 2105, "invalid endpoint url in supplier config") ErrSupplierConfigEmptyContent = sdkerrors.Register(types.ModuleName, 2106, "empty supplier config content") ErrSupplierConfigInvalidStake = sdkerrors.Register(types.ModuleName, 2107, "invalid stake amount in supplier config") - ErrSupplierConfigInvalidOwnerAddress = sdkerrors.Register(types.ModuleName, 2108, "missing owner address in supplier config") + ErrSupplierConfigInvalidAddress = sdkerrors.Register(types.ModuleName, 2108, "missing owner address in supplier config") ) diff --git a/x/supplier/config/supplier_configs_reader.go b/x/supplier/config/supplier_configs_reader.go index e83be1fdf..d9ee8fe47 100644 --- a/x/supplier/config/supplier_configs_reader.go +++ b/x/supplier/config/supplier_configs_reader.go @@ -9,6 +9,7 @@ import ( sharedhelpers "github.com/pokt-network/poktroll/x/shared/helpers" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" + "github.com/pokt-network/poktroll/x/supplier/types" ) // YAMLStakeConfig is the structure describing the supplier stake config file. @@ -42,6 +43,19 @@ type SupplierStakeConfig struct { Services []*sharedtypes.SupplierServiceConfig } +// EnsureOwner ensures that the config owner address matches the provided address. +func (cfg *SupplierStakeConfig) EnsureOwner(ownerAddress string) error { + if cfg.OwnerAddress != ownerAddress { + return types.ErrSupplierInvalidAddress.Wrapf( + "owner address %q in the stake config file does not match the address provided %q", + cfg.OperatorAddress, + ownerAddress, + ) + } + + return nil +} + // ParseSupplierServiceConfig parses the stake config file into a SupplierServiceConfig. func ParseSupplierConfigs(configContent []byte) (*SupplierStakeConfig, error) { var stakeConfig *YAMLStakeConfig @@ -57,7 +71,7 @@ func ParseSupplierConfigs(configContent []byte) (*SupplierStakeConfig, error) { // Validate required owner address. if _, err := sdk.AccAddressFromBech32(stakeConfig.OwnerAddress); err != nil { - return nil, ErrSupplierConfigInvalidOwnerAddress.Wrap("invalid owner address") + return nil, ErrSupplierConfigInvalidAddress.Wrap("invalid owner address") } // If the operator address is not set, default it to the owner address. @@ -65,6 +79,11 @@ func ParseSupplierConfigs(configContent []byte) (*SupplierStakeConfig, error) { stakeConfig.OperatorAddress = stakeConfig.OwnerAddress } + // Validate operator address. + if _, err := sdk.AccAddressFromBech32(stakeConfig.OperatorAddress); err != nil { + return nil, ErrSupplierConfigInvalidAddress.Wrap("invalid operator address") + } + // Validate the stake amount if len(stakeConfig.StakeAmount) == 0 { return nil, ErrSupplierConfigInvalidStake.Wrap("stake amount cannot be empty") diff --git a/x/supplier/keeper/msg_server_stake_supplier.go b/x/supplier/keeper/msg_server_stake_supplier.go index 6afc0c401..e37ccbac8 100644 --- a/x/supplier/keeper/msg_server_stake_supplier.go +++ b/x/supplier/keeper/msg_server_stake_supplier.go @@ -40,12 +40,12 @@ func (k msgServer) StakeSupplier(ctx context.Context, msg *types.MsgStakeSupplie var coinsToEscrow sdk.Coin supplier, isSupplierFound := k.GetSupplier(ctx, msg.Address) - // Retain the previous operator address to check whether it changes after updating the supplier - var previousOperatorAddr string if !isSupplierFound { logger.Info(fmt.Sprintf("Supplier not found. Creating new supplier for address %q", msg.Address)) - // Ensure that only supplier owner is able to stake. - if err := ensureMsgSenderIsSupplierOwner(msg); err != nil { + supplier = k.createSupplier(ctx, msg) + + // Ensure that only the owner can stake a new supplier. + if err := supplier.EnsureOwner(msg.Sender); err != nil { logger.Error(fmt.Sprintf( "owner address %q in the message does not match the msg sender address %q", msg.OwnerAddress, @@ -54,24 +54,36 @@ func (k msgServer) StakeSupplier(ctx context.Context, msg *types.MsgStakeSupplie return nil, err } - supplier = k.createSupplier(ctx, msg) + coinsToEscrow = *msg.Stake } else { logger.Info(fmt.Sprintf("Supplier found. About to try updating supplier with address %q", msg.Address)) - // Only the owner can update the supplier's owner and operator addresses. - if ownerOrOperatorAddressesChanged(msg, &supplier) { - if err := ensureMsgSenderIsSupplierOwner(msg); err != nil { - logger.Error("only the owner can update the supplier's owner and operator addresses") + // Ensure that only the operator can update the supplier info. + if err := supplier.EnsureOperator(msg.Sender); err != nil { + logger.Error(fmt.Sprintf( + "operator address %q in the message does not match the msg sender address %q", + msg.Address, + msg.Sender, + )) + return nil, err + } + + // Ensure that the owner addresses is not changed. + if err := supplier.EnsureOwner(msg.OwnerAddress); err != nil { + logger.Error("updating the supplier's owner address forbidden") - return nil, err - } + return nil, err + } + + // Ensure that the operator addresses is not changed. + if err := supplier.EnsureOperator(msg.Address); err != nil { + logger.Error("updating the supplier's operator address forbidden") + + return nil, err } currSupplierStake := *supplier.Stake - // Get the previous operator address to update the store by deleting the old - // key if it has been changed. - previousOperatorAddr = supplier.Address if err = k.updateSupplier(ctx, &supplier, msg); err != nil { logger.Error(fmt.Sprintf("could not update supplier for address %q due to error %v", msg.Address, err)) return nil, err @@ -93,9 +105,9 @@ func (k msgServer) StakeSupplier(ctx context.Context, msg *types.MsgStakeSupplie } // Retrieve the account address of the supplier owner - supplierOwnerAddress, err := sdk.AccAddressFromBech32(msg.OwnerAddress) + supplierOwnerAddress, err := sdk.AccAddressFromBech32(supplier.OwnerAddress) if err != nil { - logger.Error(fmt.Sprintf("could not parse address %q", msg.OwnerAddress)) + logger.Error(fmt.Sprintf("could not parse address %q", supplier.OwnerAddress)) return nil, err } @@ -107,10 +119,6 @@ func (k msgServer) StakeSupplier(ctx context.Context, msg *types.MsgStakeSupplie } logger.Info(fmt.Sprintf("Successfully escrowed %v coins from %q to %q module account", coinsToEscrow, supplierOwnerAddress, types.ModuleName)) - // Remove the previous supplier key if the operator address has changed - if hasDifferentOperatorAddr(previousOperatorAddr, &supplier) { - k.RemoveSupplier(ctx, previousOperatorAddr) - } // Update the Supplier in the store k.SetSupplier(ctx, supplier) logger.Info(fmt.Sprintf("Successfully updated supplier stake for supplier: %+v", supplier)) @@ -138,15 +146,6 @@ func (k msgServer) updateSupplier( supplier *sharedtypes.Supplier, msg *types.MsgStakeSupplier, ) error { - // Check if the the msg owner address is the same as the current owner - if msg.OwnerAddress != supplier.OwnerAddress { - return types.ErrSupplierUnauthorized.Wrapf("msg OwnerAddress %q != supplier owner address %q", msg.OwnerAddress, supplier.OwnerAddress) - } - - // Operator address should be already validated in `msg.ValidateBasic`. - // TODO_CONSIDERATION: Delay the operator address change until the next session. - supplier.Address = msg.Address - // Validate that the stake is not being lowered if msg.Stake == nil { return types.ErrSupplierInvalidStake.Wrapf("stake amount cannot be nil") @@ -166,30 +165,3 @@ func (k msgServer) updateSupplier( return nil } - -// hasDifferentOperatorAddr checks if the new operator address differs from the old one. -func hasDifferentOperatorAddr(oldOperatorAddress string, supplier *sharedtypes.Supplier) bool { - if oldOperatorAddress == "" { - return false - } - - return oldOperatorAddress != supplier.Address -} - -// ensureMsgSenderIsSupplierOwner returns an error if the message sender is not the supplier owner. -func ensureMsgSenderIsSupplierOwner(msg *types.MsgStakeSupplier) error { - if msg.OwnerAddress == msg.Sender { - types.ErrSupplierUnauthorized.Wrapf( - "owner address %q in the message does not match the msg sender address %q", - msg.OwnerAddress, - msg.Sender, - ) - } - - return nil -} - -// ownerOrOperatorAddressesChanged checks if the owner or operator addresses have changed. -func ownerOrOperatorAddressesChanged(msg *types.MsgStakeSupplier, supplier *sharedtypes.Supplier) bool { - return msg.OwnerAddress != supplier.OwnerAddress || msg.Address != supplier.Address -} diff --git a/x/supplier/keeper/msg_server_unstake_supplier.go b/x/supplier/keeper/msg_server_unstake_supplier.go index ea54dfef6..65e109deb 100644 --- a/x/supplier/keeper/msg_server_unstake_supplier.go +++ b/x/supplier/keeper/msg_server_unstake_supplier.go @@ -38,12 +38,14 @@ func (k msgServer) UnstakeSupplier( } // Ensure that the message sender is the supplier owner. - if supplier.OwnerAddress != msg.OwnerAddress { + if err := supplier.EnsureOwner(msg.OwnerAddress); err != nil { logger.Error(fmt.Sprintf( "owner address %q in the message does not match the supplier's owner address %q", msg.OwnerAddress, supplier.OwnerAddress, )) + + return nil, err } logger.Info(fmt.Sprintf("Supplier found. Unstaking supplier for address %s", msg.Address)) diff --git a/x/supplier/module/tx_stake_supplier.go b/x/supplier/module/tx_stake_supplier.go index fcc2c247f..843a4fe14 100644 --- a/x/supplier/module/tx_stake_supplier.go +++ b/x/supplier/module/tx_stake_supplier.go @@ -27,7 +27,7 @@ func CmdStakeSupplier() *cobra.Command { will stake the tokens and associate them with the supplier specified by the 'from' address. Example: -$ poktrolld tx supplier stake-supplier --config stake_config.yaml --keyring-backend test --node $(POCKET_NODE) --home $(POKTROLLD_HOME)`, +$ poktrolld tx supplier stake-supplier --config stake_config.yaml --keyring-backend test --from $(OWNER_ADDRESS) --node $(POCKET_NODE) --home $(POKTROLLD_HOME)`, Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, _ []string) (err error) { @@ -43,7 +43,9 @@ $ poktrolld tx supplier stake-supplier --config stake_config.yaml --keyring-back // Ensure the --from flag is set before getting the client context. if cmd.Flag(flags.FlagFrom) == nil { - cmd.Flags().Set(flags.FlagFrom, supplierStakeConfigs.OwnerAddress) + if err = cmd.Flags().Set(flags.FlagFrom, supplierStakeConfigs.OwnerAddress); err != nil { + return err + } } clientCtx, err := client.GetClientTxContext(cmd) @@ -51,13 +53,9 @@ $ poktrolld tx supplier stake-supplier --config stake_config.yaml --keyring-back return err } - // Ensure the from address is the same as the owner address in the stake config file. - if clientCtx.GetFromAddress().String() != supplierStakeConfigs.OwnerAddress { - return types.ErrSupplierInvalidAddress.Wrapf( - "operator address %q in the stake config file does not match the operator address %q in the message", - supplierStakeConfigs.OperatorAddress, - clientCtx.GetFromAddress().String(), - ) + // Ensure the from flag address is the same as the owner address in the stake config file. + if err := supplierStakeConfigs.EnsureOwner(clientCtx.GetFromAddress().String()); err != nil { + return nil } msg := types.NewMsgStakeSupplier( diff --git a/x/supplier/module/tx_unstake_supplier.go b/x/supplier/module/tx_unstake_supplier.go index d89e15e7e..ed13b35cd 100644 --- a/x/supplier/module/tx_unstake_supplier.go +++ b/x/supplier/module/tx_unstake_supplier.go @@ -17,7 +17,7 @@ func CmdUnstakeSupplier() *cobra.Command { Long: `Unstake an supplier with the provided parameters. This is a broadcast operation that will unstake the supplier specified by the and owned by 'from' address. Example: -$ poktrolld --home=$(POKTROLLD_HOME) tx supplier unstake-supplier $(OPERATOR_ADDRESS) --keyring-backend test --from $(SUPPLIER) --node $(POCKET_NODE)`, +$ poktrolld tx supplier unstake-supplier $(OPERATOR_ADDRESS) --keyring-backend test --from $(OWNER_ADDRESS) --node $(POCKET_NODE) --home=$(POKTROLLD_HOME)`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { diff --git a/x/supplier/types/errors.go b/x/supplier/types/errors.go index ce2675285..622d7ed00 100644 --- a/x/supplier/types/errors.go +++ b/x/supplier/types/errors.go @@ -9,14 +9,13 @@ var ( ErrSupplierInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") ErrSupplierInvalidStake = sdkerrors.Register(ModuleName, 1101, "invalid supplier stake") ErrSupplierInvalidAddress = sdkerrors.Register(ModuleName, 1102, "invalid address") - ErrSupplierUnauthorized = sdkerrors.Register(ModuleName, 1103, "unauthorized supplier signer") - ErrSupplierNotFound = sdkerrors.Register(ModuleName, 1104, "supplier not found") - ErrSupplierInvalidServiceConfig = sdkerrors.Register(ModuleName, 1105, "invalid service config") - ErrSupplierInvalidSessionStartHeight = sdkerrors.Register(ModuleName, 1106, "invalid session start height") - ErrSupplierInvalidSessionId = sdkerrors.Register(ModuleName, 1107, "invalid session ID") - ErrSupplierInvalidService = sdkerrors.Register(ModuleName, 1108, "invalid service in supplier") - ErrSupplierInvalidSessionEndHeight = sdkerrors.Register(ModuleName, 1109, "invalid session ending height") - ErrSupplierIsUnstaking = sdkerrors.Register(ModuleName, 1110, "supplier is in unbonding period") - ErrSupplierParamsInvalid = sdkerrors.Register(ModuleName, 1111, "invalid supplier params") - ErrSupplierServiceNotFound = sdkerrors.Register(ModuleName, 1112, "service not found") + ErrSupplierNotFound = sdkerrors.Register(ModuleName, 1103, "supplier not found") + ErrSupplierInvalidServiceConfig = sdkerrors.Register(ModuleName, 1104, "invalid service config") + ErrSupplierInvalidSessionStartHeight = sdkerrors.Register(ModuleName, 1105, "invalid session start height") + ErrSupplierInvalidSessionId = sdkerrors.Register(ModuleName, 1106, "invalid session ID") + ErrSupplierInvalidService = sdkerrors.Register(ModuleName, 1107, "invalid service in supplier") + ErrSupplierInvalidSessionEndHeight = sdkerrors.Register(ModuleName, 1108, "invalid session ending height") + ErrSupplierIsUnstaking = sdkerrors.Register(ModuleName, 1109, "supplier is in unbonding period") + ErrSupplierParamsInvalid = sdkerrors.Register(ModuleName, 1110, "invalid supplier params") + ErrSupplierServiceNotFound = sdkerrors.Register(ModuleName, 1111, "service not found") ) diff --git a/x/supplier/types/tx.pb.go b/x/supplier/types/tx.pb.go index 019041ce8..9d53fc189 100644 --- a/x/supplier/types/tx.pb.go +++ b/x/supplier/types/tx.pb.go @@ -240,8 +240,17 @@ func (m *MsgStakeSupplierResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgStakeSupplierResponse proto.InternalMessageInfo type MsgUnstakeSupplier struct { + // The address of the owner (i.e. staker, custodial) that owns the funds for staking. + // By default, this address is the one that receives all the rewards unless owtherwise specified. + // The owner can initially stake the supplier and unstake it. + // All other configurations are managed by the operator. OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + // The operator address of the supplier that operates it. + // The operator address can update the supplier's configurations excluding the owner + // and operator addresses which do not change over the supplier's lifespan. + // TODO(red-0ne): Rename this to `operator_address` include all downstream + // variables, comments, docs, tests, etc... + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` } func (m *MsgUnstakeSupplier) Reset() { *m = MsgUnstakeSupplier{} } From b33a013c7799f5f04e480f3e6201d8b69d922b83 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Sat, 3 Aug 2024 04:10:00 +0200 Subject: [PATCH 03/14] fix: Add missing sender address --- x/supplier/module/tx_stake_supplier.go | 6 +----- x/supplier/types/message_stake_supplier.go | 12 ++++++++++++ x/tokenomics/keeper/keeper.go | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/x/supplier/module/tx_stake_supplier.go b/x/supplier/module/tx_stake_supplier.go index 843a4fe14..e2ad337b6 100644 --- a/x/supplier/module/tx_stake_supplier.go +++ b/x/supplier/module/tx_stake_supplier.go @@ -53,12 +53,8 @@ $ poktrolld tx supplier stake-supplier --config stake_config.yaml --keyring-back return err } - // Ensure the from flag address is the same as the owner address in the stake config file. - if err := supplierStakeConfigs.EnsureOwner(clientCtx.GetFromAddress().String()); err != nil { - return nil - } - msg := types.NewMsgStakeSupplier( + clientCtx.GetFromAddress().String(), supplierStakeConfigs.OwnerAddress, supplierStakeConfigs.OperatorAddress, supplierStakeConfigs.StakeAmount, diff --git a/x/supplier/types/message_stake_supplier.go b/x/supplier/types/message_stake_supplier.go index 7bcca9d3b..954d30245 100644 --- a/x/supplier/types/message_stake_supplier.go +++ b/x/supplier/types/message_stake_supplier.go @@ -12,12 +12,14 @@ const TypeMsgStakeSupplier = "stake_supplier" var _ sdk.Msg = (*MsgStakeSupplier)(nil) func NewMsgStakeSupplier( + senderAddress string, ownerAddress string, supplierAddress string, stake sdk.Coin, services []*sharedtypes.SupplierServiceConfig, ) *MsgStakeSupplier { return &MsgStakeSupplier{ + Sender: senderAddress, OwnerAddress: ownerAddress, Address: supplierAddress, Stake: &stake, @@ -31,6 +33,16 @@ func (msg *MsgStakeSupplier) ValidateBasic() error { return ErrSupplierInvalidAddress.Wrapf("invalid owner address %s; (%v)", msg.OwnerAddress, err) } + // Ensure the sender address matches the owner address or the operator address. + if msg.Sender != msg.OwnerAddress && msg.Sender != msg.Address { + return ErrSupplierInvalidAddress.Wrapf( + "sender address %s does not match owner address %s or supplier address %s", + msg.Sender, + msg.OwnerAddress, + msg.Address, + ) + } + // Validate the address if _, err := sdk.AccAddressFromBech32(msg.Address); err != nil { return ErrSupplierInvalidAddress.Wrapf("invalid supplier address %s; (%v)", msg.Address, err) diff --git a/x/tokenomics/keeper/keeper.go b/x/tokenomics/keeper/keeper.go index f6c63d2cd..5f23bea12 100644 --- a/x/tokenomics/keeper/keeper.go +++ b/x/tokenomics/keeper/keeper.go @@ -66,6 +66,7 @@ func NewKeeper( proofKeeper: proofKeeper, sharedKeeper: sharedKeeper, sessionKeeper: sessionKeeper, + supplierKeeper: supplierKeeper, sharedQuerier: sharedQuerier, } From 604224df2cbeb1c5ce4a006c584a2f6b967a2181 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Sat, 3 Aug 2024 04:16:41 +0200 Subject: [PATCH 04/14] fix: Enfore sender to be owner or operator --- x/supplier/types/message_stake_supplier.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/x/supplier/types/message_stake_supplier.go b/x/supplier/types/message_stake_supplier.go index 954d30245..c91fc6a66 100644 --- a/x/supplier/types/message_stake_supplier.go +++ b/x/supplier/types/message_stake_supplier.go @@ -48,6 +48,16 @@ func (msg *MsgStakeSupplier) ValidateBasic() error { return ErrSupplierInvalidAddress.Wrapf("invalid supplier address %s; (%v)", msg.Address, err) } + // Ensure the sender address matches the owner address or the operator address. + if msg.Sender != msg.OwnerAddress && msg.Sender != msg.Address { + return ErrSupplierInvalidAddress.Wrapf( + "sender address %s does not match owner address %s or supplier address %s", + msg.Sender, + msg.OwnerAddress, + msg.Address, + ) + } + // TODO_MAINNET: Centralize stake related verification and share across different // parts of the source code // Validate the stake amount From 473e047676b9a9455e55ad3e206e1806080e851a Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Tue, 6 Aug 2024 17:41:08 +0200 Subject: [PATCH 05/14] fix: Err var shadowing --- x/supplier/keeper/msg_server_stake_supplier.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/x/supplier/keeper/msg_server_stake_supplier.go b/x/supplier/keeper/msg_server_stake_supplier.go index 2bba194ba..9fad11d9b 100644 --- a/x/supplier/keeper/msg_server_stake_supplier.go +++ b/x/supplier/keeper/msg_server_stake_supplier.go @@ -46,7 +46,7 @@ func (k msgServer) StakeSupplier(ctx context.Context, msg *types.MsgStakeSupplie supplier = k.createSupplier(ctx, msg) // Ensure that only the owner can stake a new supplier. - if err := supplier.EnsureOwner(msg.Sender); err != nil { + if err = supplier.EnsureOwner(msg.Sender); err != nil { logger.Error(fmt.Sprintf( "owner address %q in the message does not match the msg sender address %q", msg.OwnerAddress, @@ -61,7 +61,7 @@ func (k msgServer) StakeSupplier(ctx context.Context, msg *types.MsgStakeSupplie logger.Info(fmt.Sprintf("Supplier found. About to try updating supplier with address %q", msg.Address)) // Ensure that only the operator can update the supplier info. - if err := supplier.EnsureOperator(msg.Sender); err != nil { + if err = supplier.EnsureOperator(msg.Sender); err != nil { logger.Error(fmt.Sprintf( "operator address %q in the message does not match the msg sender address %q", msg.Address, @@ -71,14 +71,14 @@ func (k msgServer) StakeSupplier(ctx context.Context, msg *types.MsgStakeSupplie } // Ensure that the owner addresses is not changed. - if err := supplier.EnsureOwner(msg.OwnerAddress); err != nil { + if err = supplier.EnsureOwner(msg.OwnerAddress); err != nil { logger.Error("updating the supplier's owner address forbidden") return nil, err } // Ensure that the operator addresses is not changed. - if err := supplier.EnsureOperator(msg.Address); err != nil { + if err = supplier.EnsureOperator(msg.Address); err != nil { logger.Error("updating the supplier's operator address forbidden") return nil, err From 088e6750a42b0f886155feb1a28d078c067aac82 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Tue, 6 Aug 2024 17:49:19 +0200 Subject: [PATCH 06/14] chore: Log default operator address fallback --- x/supplier/config/supplier_configs_reader.go | 7 ++++++- x/supplier/module/tx_stake_supplier.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/x/supplier/config/supplier_configs_reader.go b/x/supplier/config/supplier_configs_reader.go index d9ee8fe47..947024759 100644 --- a/x/supplier/config/supplier_configs_reader.go +++ b/x/supplier/config/supplier_configs_reader.go @@ -1,12 +1,14 @@ package config import ( + "context" "net/url" "strings" sdk "github.com/cosmos/cosmos-sdk/types" "gopkg.in/yaml.v2" + "github.com/pokt-network/poktroll/pkg/polylog" sharedhelpers "github.com/pokt-network/poktroll/x/shared/helpers" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" "github.com/pokt-network/poktroll/x/supplier/types" @@ -57,9 +59,11 @@ func (cfg *SupplierStakeConfig) EnsureOwner(ownerAddress string) error { } // ParseSupplierServiceConfig parses the stake config file into a SupplierServiceConfig. -func ParseSupplierConfigs(configContent []byte) (*SupplierStakeConfig, error) { +func ParseSupplierConfigs(ctx context.Context, configContent []byte) (*SupplierStakeConfig, error) { var stakeConfig *YAMLStakeConfig + logger := polylog.Ctx(ctx) + if len(configContent) == 0 { return nil, ErrSupplierConfigEmptyContent } @@ -77,6 +81,7 @@ func ParseSupplierConfigs(configContent []byte) (*SupplierStakeConfig, error) { // If the operator address is not set, default it to the owner address. if stakeConfig.OperatorAddress == "" { stakeConfig.OperatorAddress = stakeConfig.OwnerAddress + logger.Info().Msg("operator address not set, defaulting to owner address") } // Validate operator address. diff --git a/x/supplier/module/tx_stake_supplier.go b/x/supplier/module/tx_stake_supplier.go index e2ad337b6..4628882ec 100644 --- a/x/supplier/module/tx_stake_supplier.go +++ b/x/supplier/module/tx_stake_supplier.go @@ -36,7 +36,7 @@ $ poktrolld tx supplier stake-supplier --config stake_config.yaml --keyring-back return err } - supplierStakeConfigs, err := config.ParseSupplierConfigs(configContent) + supplierStakeConfigs, err := config.ParseSupplierConfigs(cmd.Context(), configContent) if err != nil { return err } From 20e8ed5b41dd1630a4ba45f8ba8966670def887e Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Thu, 8 Aug 2024 05:52:17 +0200 Subject: [PATCH 07/14] fix: Address review changes, mimic Morse behavior --- .../application/application.pulsar.go | 2 +- api/poktroll/application/event.pulsar.go | 4 +- api/poktroll/application/tx.pulsar.go | 10 +- api/poktroll/gateway/event.pulsar.go | 2 +- api/poktroll/service/relay.pulsar.go | 2 +- api/poktroll/service/tx.pulsar.go | 2 +- api/poktroll/session/query.pulsar.go | 2 +- api/poktroll/session/session.pulsar.go | 2 +- api/poktroll/shared/supplier.pulsar.go | 12 +- api/poktroll/supplier/tx.pulsar.go | 214 +++++++++--------- .../tests/relays_stress_helpers_test.go | 1 + proto/poktroll/application/application.proto | 2 +- proto/poktroll/application/event.proto | 4 +- proto/poktroll/application/tx.proto | 10 +- proto/poktroll/gateway/event.proto | 2 +- proto/poktroll/service/relay.proto | 4 +- proto/poktroll/service/tx.proto | 2 +- proto/poktroll/session/query.proto | 2 +- proto/poktroll/session/session.proto | 2 +- proto/poktroll/shared/supplier.proto | 12 +- proto/poktroll/supplier/tx.proto | 24 +- x/shared/types/supplier.go | 28 +-- x/shared/types/supplier.pb.go | 12 +- x/supplier/config/supplier_configs_reader.go | 1 + .../config/supplier_configs_reader_test.go | 5 +- .../keeper/msg_server_stake_supplier.go | 43 ++-- .../keeper/msg_server_unstake_supplier.go | 18 +- x/supplier/module/tx_unstake_supplier.go | 8 +- x/supplier/types/message_stake_supplier.go | 24 +- x/supplier/types/message_unstake_supplier.go | 8 +- x/supplier/types/tx.pb.go | 130 +++++------ x/tokenomics/types/tx.pb.go | 3 +- 32 files changed, 271 insertions(+), 326 deletions(-) diff --git a/api/poktroll/application/application.pulsar.go b/api/poktroll/application/application.pulsar.go index 04b8048c5..71e0126ee 100644 --- a/api/poktroll/application/application.pulsar.go +++ b/api/poktroll/application/application.pulsar.go @@ -1589,7 +1589,7 @@ type Application struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic encoding + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the application. Stake *v1beta1.Coin `protobuf:"bytes,2,opt,name=stake,proto3" json:"stake,omitempty"` // The total amount of uPOKT the application has staked ServiceConfigs []*shared.ApplicationServiceConfig `protobuf:"bytes,3,rep,name=service_configs,json=serviceConfigs,proto3" json:"service_configs,omitempty"` // The list of services this appliccation is configured to request service for // TODO_BETA: Rename `delegatee_gateway_addresses` to `gateway_addresses_delegated_to`. diff --git a/api/poktroll/application/event.pulsar.go b/api/poktroll/application/event.pulsar.go index 6f5701306..49421e4b7 100644 --- a/api/poktroll/application/event.pulsar.go +++ b/api/poktroll/application/event.pulsar.go @@ -518,8 +518,8 @@ type EventRedelegation struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - AppAddress string `protobuf:"bytes,1,opt,name=app_address,json=appAddress,proto3" json:"app_address,omitempty"` // The Bech32 address of the application, using cosmos' ScalarDescriptor to ensure deterministic encoding - GatewayAddress string `protobuf:"bytes,2,opt,name=gateway_address,json=gatewayAddress,proto3" json:"gateway_address,omitempty"` // The Bech32 address of the gateway the application has changed their delegation of, using cosmos' ScalarDescriptor to ensure deterministic encoding + AppAddress string `protobuf:"bytes,1,opt,name=app_address,json=appAddress,proto3" json:"app_address,omitempty"` // The Bech32 address of the application. + GatewayAddress string `protobuf:"bytes,2,opt,name=gateway_address,json=gatewayAddress,proto3" json:"gateway_address,omitempty"` // The Bech32 address of the gateway the application has changed their delegation of. } func (x *EventRedelegation) Reset() { diff --git a/api/poktroll/application/tx.pulsar.go b/api/poktroll/application/tx.pulsar.go index 001bc03ec..957934846 100644 --- a/api/poktroll/application/tx.pulsar.go +++ b/api/poktroll/application/tx.pulsar.go @@ -4415,7 +4415,7 @@ type MsgStakeApplication struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic encoding + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the application. Stake *v1beta1.Coin `protobuf:"bytes,2,opt,name=stake,proto3" json:"stake,omitempty"` // The total amount of uPOKT the application has staked. Must be ≥ to the current amount that the application has staked (if any) Services []*shared.ApplicationServiceConfig `protobuf:"bytes,3,rep,name=services,proto3" json:"services,omitempty"` // The list of services this application is staked to request service for } @@ -4553,8 +4553,8 @@ type MsgDelegateToGateway struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - AppAddress string `protobuf:"bytes,1,opt,name=app_address,json=appAddress,proto3" json:"app_address,omitempty"` // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding - GatewayAddress string `protobuf:"bytes,2,opt,name=gateway_address,json=gatewayAddress,proto3" json:"gateway_address,omitempty"` // The Bech32 address of the gateway the application wants to delegate to using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + AppAddress string `protobuf:"bytes,1,opt,name=app_address,json=appAddress,proto3" json:"app_address,omitempty"` // The Bech32 address of the application. + GatewayAddress string `protobuf:"bytes,2,opt,name=gateway_address,json=gatewayAddress,proto3" json:"gateway_address,omitempty"` // The Bech32 address of the gateway the application wants to delegate to. } func (x *MsgDelegateToGateway) Reset() { @@ -4622,8 +4622,8 @@ type MsgUndelegateFromGateway struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - AppAddress string `protobuf:"bytes,1,opt,name=app_address,json=appAddress,proto3" json:"app_address,omitempty"` // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding - GatewayAddress string `protobuf:"bytes,2,opt,name=gateway_address,json=gatewayAddress,proto3" json:"gateway_address,omitempty"` // The Bech32 address of the gateway the application wants to undelegate from using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + AppAddress string `protobuf:"bytes,1,opt,name=app_address,json=appAddress,proto3" json:"app_address,omitempty"` // The Bech32 address of the application. + GatewayAddress string `protobuf:"bytes,2,opt,name=gateway_address,json=gatewayAddress,proto3" json:"gateway_address,omitempty"` // The Bech32 address of the gateway the application wants to undelegate from. } func (x *MsgUndelegateFromGateway) Reset() { diff --git a/api/poktroll/gateway/event.pulsar.go b/api/poktroll/gateway/event.pulsar.go index 37846aee9..2eef09840 100644 --- a/api/poktroll/gateway/event.pulsar.go +++ b/api/poktroll/gateway/event.pulsar.go @@ -452,7 +452,7 @@ type EventGatewayUnstaked struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the gateway the application has changed their delegation of, using cosmos' ScalarDescriptor to ensure deterministic encoding + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the gateway the application has changed their delegation of. } func (x *EventGatewayUnstaked) Reset() { diff --git a/api/poktroll/service/relay.pulsar.go b/api/poktroll/service/relay.pulsar.go index c8a3d78da..19b2cb531 100644 --- a/api/poktroll/service/relay.pulsar.go +++ b/api/poktroll/service/relay.pulsar.go @@ -2672,7 +2672,7 @@ type RelayRequestMetadata struct { // // The supplier address the relay is sent to. It is being used on the RelayMiner to // route to the correct supplier. - SupplierAddress string `protobuf:"bytes,3,opt,name=supplier_address,json=supplierAddress,proto3" json:"supplier_address,omitempty"` // The Bech32 address of the application, using cosmos' ScalarDescriptor to ensure deterministic encoding + SupplierAddress string `protobuf:"bytes,3,opt,name=supplier_address,json=supplierAddress,proto3" json:"supplier_address,omitempty"` // The Bech32 address of the application. } func (x *RelayRequestMetadata) Reset() { diff --git a/api/poktroll/service/tx.pulsar.go b/api/poktroll/service/tx.pulsar.go index bbce384f9..e082fb32b 100644 --- a/api/poktroll/service/tx.pulsar.go +++ b/api/poktroll/service/tx.pulsar.go @@ -1824,7 +1824,7 @@ type MsgAddService struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - 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 + OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` // The Bech32 address of the service owner. Service *shared.Service `protobuf:"bytes,2,opt,name=service,proto3" json:"service,omitempty"` // The Service being added to the network } diff --git a/api/poktroll/session/query.pulsar.go b/api/poktroll/session/query.pulsar.go index dc8b2cf41..95db86dc5 100644 --- a/api/poktroll/session/query.pulsar.go +++ b/api/poktroll/session/query.pulsar.go @@ -1873,7 +1873,7 @@ 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 using cosmos' ScalarDescriptor to ensure deterministic encoding + 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 } diff --git a/api/poktroll/session/session.pulsar.go b/api/poktroll/session/session.pulsar.go index b4fad060b..1178c0f5a 100644 --- a/api/poktroll/session/session.pulsar.go +++ b/api/poktroll/session/session.pulsar.go @@ -1506,7 +1506,7 @@ 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 using cosmos' ScalarDescriptor to ensure deterministic encoding + 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 // 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 diff --git a/api/poktroll/shared/supplier.pulsar.go b/api/poktroll/shared/supplier.pulsar.go index 04a13b750..38ab0d90c 100644 --- a/api/poktroll/shared/supplier.pulsar.go +++ b/api/poktroll/shared/supplier.pulsar.go @@ -1073,13 +1073,13 @@ type Supplier struct { // The address of the owner (i.e. staker, custodial) that owns the funds for staking. // By default, this address is the one that receives all the rewards unless owtherwise specified. - // The owner can initially stake the supplier and unstake it. - // All other configurations are managed by the operator. + // This property cannot be updated by the operator. OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` // Bech32 cosmos address - // The operator address of the supplier that operates it. - // The operator address can update the supplier's configurations excluding the owner - // and operator addresses which do not change over the supplier's lifespan. - // TODO(red-0ne): Rename this to `operator_address` include all downstream + // The address of the supplier operator (i.e. the one managing the off-chain server). + // The operator address can update the supplier's configurations excluding the owner address. + // This property do not change over the supplier's lifespan, the supplier must be usnaked + // and staked again to update this value. + // TODO(#722): Rename this to `operator_address` include all downstream // variables, comments, docs, tests, etc... Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` // Bech32 cosmos address Stake *v1beta1.Coin `protobuf:"bytes,3,opt,name=stake,proto3" json:"stake,omitempty"` // The total amount of uPOKT the supplier has staked diff --git a/api/poktroll/supplier/tx.pulsar.go b/api/poktroll/supplier/tx.pulsar.go index 6f63cc907..8c74573e5 100644 --- a/api/poktroll/supplier/tx.pulsar.go +++ b/api/poktroll/supplier/tx.pulsar.go @@ -926,7 +926,7 @@ func (x *_MsgStakeSupplier_5_list) IsValid() bool { var ( md_MsgStakeSupplier protoreflect.MessageDescriptor - fd_MsgStakeSupplier_sender protoreflect.FieldDescriptor + fd_MsgStakeSupplier_signer protoreflect.FieldDescriptor fd_MsgStakeSupplier_owner_address protoreflect.FieldDescriptor fd_MsgStakeSupplier_address protoreflect.FieldDescriptor fd_MsgStakeSupplier_stake protoreflect.FieldDescriptor @@ -936,7 +936,7 @@ var ( func init() { file_poktroll_supplier_tx_proto_init() md_MsgStakeSupplier = File_poktroll_supplier_tx_proto.Messages().ByName("MsgStakeSupplier") - fd_MsgStakeSupplier_sender = md_MsgStakeSupplier.Fields().ByName("sender") + fd_MsgStakeSupplier_signer = md_MsgStakeSupplier.Fields().ByName("signer") fd_MsgStakeSupplier_owner_address = md_MsgStakeSupplier.Fields().ByName("owner_address") fd_MsgStakeSupplier_address = md_MsgStakeSupplier.Fields().ByName("address") fd_MsgStakeSupplier_stake = md_MsgStakeSupplier.Fields().ByName("stake") @@ -1008,9 +1008,9 @@ func (x *fastReflection_MsgStakeSupplier) Interface() protoreflect.ProtoMessage // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_MsgStakeSupplier) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.Sender != "" { - value := protoreflect.ValueOfString(x.Sender) - if !f(fd_MsgStakeSupplier_sender, value) { + if x.Signer != "" { + value := protoreflect.ValueOfString(x.Signer) + if !f(fd_MsgStakeSupplier_signer, value) { return } } @@ -1053,8 +1053,8 @@ func (x *fastReflection_MsgStakeSupplier) Range(f func(protoreflect.FieldDescrip // a repeated field is populated if it is non-empty. func (x *fastReflection_MsgStakeSupplier) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.supplier.MsgStakeSupplier.sender": - return x.Sender != "" + case "poktroll.supplier.MsgStakeSupplier.signer": + return x.Signer != "" case "poktroll.supplier.MsgStakeSupplier.owner_address": return x.OwnerAddress != "" case "poktroll.supplier.MsgStakeSupplier.address": @@ -1079,8 +1079,8 @@ func (x *fastReflection_MsgStakeSupplier) Has(fd protoreflect.FieldDescriptor) b // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_MsgStakeSupplier) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.supplier.MsgStakeSupplier.sender": - x.Sender = "" + case "poktroll.supplier.MsgStakeSupplier.signer": + x.Signer = "" case "poktroll.supplier.MsgStakeSupplier.owner_address": x.OwnerAddress = "" case "poktroll.supplier.MsgStakeSupplier.address": @@ -1105,8 +1105,8 @@ func (x *fastReflection_MsgStakeSupplier) Clear(fd protoreflect.FieldDescriptor) // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_MsgStakeSupplier) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "poktroll.supplier.MsgStakeSupplier.sender": - value := x.Sender + case "poktroll.supplier.MsgStakeSupplier.signer": + value := x.Signer return protoreflect.ValueOfString(value) case "poktroll.supplier.MsgStakeSupplier.owner_address": value := x.OwnerAddress @@ -1143,8 +1143,8 @@ func (x *fastReflection_MsgStakeSupplier) Get(descriptor protoreflect.FieldDescr // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_MsgStakeSupplier) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "poktroll.supplier.MsgStakeSupplier.sender": - x.Sender = value.Interface().(string) + case "poktroll.supplier.MsgStakeSupplier.signer": + x.Signer = value.Interface().(string) case "poktroll.supplier.MsgStakeSupplier.owner_address": x.OwnerAddress = value.Interface().(string) case "poktroll.supplier.MsgStakeSupplier.address": @@ -1186,8 +1186,8 @@ func (x *fastReflection_MsgStakeSupplier) Mutable(fd protoreflect.FieldDescripto } value := &_MsgStakeSupplier_5_list{list: &x.Services} return protoreflect.ValueOfList(value) - case "poktroll.supplier.MsgStakeSupplier.sender": - panic(fmt.Errorf("field sender of message poktroll.supplier.MsgStakeSupplier is not mutable")) + case "poktroll.supplier.MsgStakeSupplier.signer": + panic(fmt.Errorf("field signer of message poktroll.supplier.MsgStakeSupplier is not mutable")) case "poktroll.supplier.MsgStakeSupplier.owner_address": panic(fmt.Errorf("field owner_address of message poktroll.supplier.MsgStakeSupplier is not mutable")) case "poktroll.supplier.MsgStakeSupplier.address": @@ -1205,7 +1205,7 @@ func (x *fastReflection_MsgStakeSupplier) Mutable(fd protoreflect.FieldDescripto // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_MsgStakeSupplier) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.supplier.MsgStakeSupplier.sender": + case "poktroll.supplier.MsgStakeSupplier.signer": return protoreflect.ValueOfString("") case "poktroll.supplier.MsgStakeSupplier.owner_address": return protoreflect.ValueOfString("") @@ -1286,7 +1286,7 @@ func (x *fastReflection_MsgStakeSupplier) ProtoMethods() *protoiface.Methods { var n int var l int _ = l - l = len(x.Sender) + l = len(x.Signer) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } @@ -1381,10 +1381,10 @@ func (x *fastReflection_MsgStakeSupplier) ProtoMethods() *protoiface.Methods { i-- dAtA[i] = 0x12 } - if len(x.Sender) > 0 { - i -= len(x.Sender) - copy(dAtA[i:], x.Sender) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Sender))) + if len(x.Signer) > 0 { + i -= len(x.Signer) + copy(dAtA[i:], x.Signer) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Signer))) i-- dAtA[i] = 0xa } @@ -1439,7 +1439,7 @@ func (x *fastReflection_MsgStakeSupplier) 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 Sender", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1467,7 +1467,7 @@ func (x *fastReflection_MsgStakeSupplier) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.Sender = string(dAtA[iNdEx:postIndex]) + x.Signer = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -1995,15 +1995,15 @@ func (x *fastReflection_MsgStakeSupplierResponse) ProtoMethods() *protoiface.Met } var ( - md_MsgUnstakeSupplier protoreflect.MessageDescriptor - fd_MsgUnstakeSupplier_owner_address protoreflect.FieldDescriptor - fd_MsgUnstakeSupplier_address protoreflect.FieldDescriptor + md_MsgUnstakeSupplier protoreflect.MessageDescriptor + fd_MsgUnstakeSupplier_signer protoreflect.FieldDescriptor + fd_MsgUnstakeSupplier_address protoreflect.FieldDescriptor ) func init() { file_poktroll_supplier_tx_proto_init() md_MsgUnstakeSupplier = File_poktroll_supplier_tx_proto.Messages().ByName("MsgUnstakeSupplier") - fd_MsgUnstakeSupplier_owner_address = md_MsgUnstakeSupplier.Fields().ByName("owner_address") + fd_MsgUnstakeSupplier_signer = md_MsgUnstakeSupplier.Fields().ByName("signer") fd_MsgUnstakeSupplier_address = md_MsgUnstakeSupplier.Fields().ByName("address") } @@ -2072,9 +2072,9 @@ func (x *fastReflection_MsgUnstakeSupplier) Interface() protoreflect.ProtoMessag // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_MsgUnstakeSupplier) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.OwnerAddress != "" { - value := protoreflect.ValueOfString(x.OwnerAddress) - if !f(fd_MsgUnstakeSupplier_owner_address, value) { + if x.Signer != "" { + value := protoreflect.ValueOfString(x.Signer) + if !f(fd_MsgUnstakeSupplier_signer, value) { return } } @@ -2099,8 +2099,8 @@ func (x *fastReflection_MsgUnstakeSupplier) Range(f func(protoreflect.FieldDescr // a repeated field is populated if it is non-empty. func (x *fastReflection_MsgUnstakeSupplier) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.supplier.MsgUnstakeSupplier.owner_address": - return x.OwnerAddress != "" + case "poktroll.supplier.MsgUnstakeSupplier.signer": + return x.Signer != "" case "poktroll.supplier.MsgUnstakeSupplier.address": return x.Address != "" default: @@ -2119,8 +2119,8 @@ func (x *fastReflection_MsgUnstakeSupplier) Has(fd protoreflect.FieldDescriptor) // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_MsgUnstakeSupplier) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.supplier.MsgUnstakeSupplier.owner_address": - x.OwnerAddress = "" + case "poktroll.supplier.MsgUnstakeSupplier.signer": + x.Signer = "" case "poktroll.supplier.MsgUnstakeSupplier.address": x.Address = "" default: @@ -2139,8 +2139,8 @@ func (x *fastReflection_MsgUnstakeSupplier) Clear(fd protoreflect.FieldDescripto // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_MsgUnstakeSupplier) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "poktroll.supplier.MsgUnstakeSupplier.owner_address": - value := x.OwnerAddress + case "poktroll.supplier.MsgUnstakeSupplier.signer": + value := x.Signer return protoreflect.ValueOfString(value) case "poktroll.supplier.MsgUnstakeSupplier.address": value := x.Address @@ -2165,8 +2165,8 @@ func (x *fastReflection_MsgUnstakeSupplier) Get(descriptor protoreflect.FieldDes // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_MsgUnstakeSupplier) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "poktroll.supplier.MsgUnstakeSupplier.owner_address": - x.OwnerAddress = value.Interface().(string) + case "poktroll.supplier.MsgUnstakeSupplier.signer": + x.Signer = value.Interface().(string) case "poktroll.supplier.MsgUnstakeSupplier.address": x.Address = value.Interface().(string) default: @@ -2189,8 +2189,8 @@ func (x *fastReflection_MsgUnstakeSupplier) Set(fd protoreflect.FieldDescriptor, // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_MsgUnstakeSupplier) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.supplier.MsgUnstakeSupplier.owner_address": - panic(fmt.Errorf("field owner_address of message poktroll.supplier.MsgUnstakeSupplier is not mutable")) + case "poktroll.supplier.MsgUnstakeSupplier.signer": + panic(fmt.Errorf("field signer of message poktroll.supplier.MsgUnstakeSupplier is not mutable")) case "poktroll.supplier.MsgUnstakeSupplier.address": panic(fmt.Errorf("field address of message poktroll.supplier.MsgUnstakeSupplier is not mutable")) default: @@ -2206,7 +2206,7 @@ func (x *fastReflection_MsgUnstakeSupplier) Mutable(fd protoreflect.FieldDescrip // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_MsgUnstakeSupplier) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.supplier.MsgUnstakeSupplier.owner_address": + case "poktroll.supplier.MsgUnstakeSupplier.signer": return protoreflect.ValueOfString("") case "poktroll.supplier.MsgUnstakeSupplier.address": return protoreflect.ValueOfString("") @@ -2279,7 +2279,7 @@ func (x *fastReflection_MsgUnstakeSupplier) ProtoMethods() *protoiface.Methods { var n int var l int _ = l - l = len(x.OwnerAddress) + l = len(x.Signer) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } @@ -2321,12 +2321,12 @@ func (x *fastReflection_MsgUnstakeSupplier) ProtoMethods() *protoiface.Methods { copy(dAtA[i:], x.Address) i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Address))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } - if len(x.OwnerAddress) > 0 { - i -= len(x.OwnerAddress) - copy(dAtA[i:], x.OwnerAddress) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.OwnerAddress))) + if len(x.Signer) > 0 { + i -= len(x.Signer) + copy(dAtA[i:], x.Signer) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Signer))) i-- dAtA[i] = 0xa } @@ -2381,7 +2381,7 @@ func (x *fastReflection_MsgUnstakeSupplier) 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 OwnerAddress", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2409,9 +2409,9 @@ func (x *fastReflection_MsgUnstakeSupplier) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.OwnerAddress = string(dAtA[iNdEx:postIndex]) + x.Signer = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } @@ -2927,9 +2927,9 @@ type MsgStakeSupplier struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` // The Bech32 address of the message sender (i.e. owner or operator) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding - OwnerAddress string `protobuf:"bytes,2,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` // The Bech32 address of the owner (i.e. custodial, staker) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding - Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the operator (i.e. provider, non-custodial) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` // The Bech32 address of the message signer (i.e. owner or operator) + OwnerAddress string `protobuf:"bytes,2,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` // The Bech32 address of the owner (i.e. custodial, staker) + Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the operator (i.e. provider, non-custodial) Stake *v1beta1.Coin `protobuf:"bytes,4,opt,name=stake,proto3" json:"stake,omitempty"` // The total amount of uPOKT the supplier has staked. Must be ≥ to the current amount that the supplier has staked (if any) Services []*shared.SupplierServiceConfig `protobuf:"bytes,5,rep,name=services,proto3" json:"services,omitempty"` // The list of services this supplier is staked to provide service for } @@ -2954,9 +2954,9 @@ func (*MsgStakeSupplier) Descriptor() ([]byte, []int) { return file_poktroll_supplier_tx_proto_rawDescGZIP(), []int{2} } -func (x *MsgStakeSupplier) GetSender() string { +func (x *MsgStakeSupplier) GetSigner() string { if x != nil { - return x.Sender + return x.Signer } return "" } @@ -3020,17 +3020,8 @@ type MsgUnstakeSupplier struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The address of the owner (i.e. staker, custodial) that owns the funds for staking. - // By default, this address is the one that receives all the rewards unless owtherwise specified. - // The owner can initially stake the supplier and unstake it. - // All other configurations are managed by the operator. - OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` // The Bech32 address - // The operator address of the supplier that operates it. - // The operator address can update the supplier's configurations excluding the owner - // and operator addresses which do not change over the supplier's lifespan. - // TODO(red-0ne): Rename this to `operator_address` include all downstream - // variables, comments, docs, tests, etc... - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` // The Bech32 address of the message signer (i.e. owner or operator) + Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` // The Bech32 address of the operator (i.e. provider, non-custodial) } func (x *MsgUnstakeSupplier) Reset() { @@ -3053,9 +3044,9 @@ func (*MsgUnstakeSupplier) Descriptor() ([]byte, []int) { return file_poktroll_supplier_tx_proto_rawDescGZIP(), []int{4} } -func (x *MsgUnstakeSupplier) GetOwnerAddress() string { +func (x *MsgUnstakeSupplier) GetSigner() string { if x != nil { - return x.OwnerAddress + return x.Signer } return "" } @@ -3126,9 +3117,9 @@ var file_poktroll_supplier_tx_proto_rawDesc = []byte{ 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, 0xb9, 0x02, 0x0a, 0x10, 0x4d, 0x73, 0x67, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x12, 0x30, 0x0a, - 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, + 0x06, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 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, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, + 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x12, 0x3d, 0x0a, 0x0d, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 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, @@ -3143,52 +3134,51 @@ var file_poktroll_supplier_tx_proto_rawDesc = []byte{ 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 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, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3a, 0x0b, 0x82, 0xe7, 0xb0, 0x2a, 0x06, 0x73, 0x65, - 0x6e, 0x64, 0x65, 0x72, 0x22, 0x1a, 0x0a, 0x18, 0x4d, 0x73, 0x67, 0x53, 0x74, 0x61, 0x6b, 0x65, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3a, 0x0b, 0x82, 0xe7, 0xb0, 0x2a, 0x06, 0x73, 0x69, + 0x67, 0x6e, 0x65, 0x72, 0x22, 0x1a, 0x0a, 0x18, 0x4d, 0x73, 0x67, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x9b, 0x01, 0x0a, 0x12, 0x4d, 0x73, 0x67, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x53, - 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 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, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, + 0x22, 0x87, 0x01, 0x0a, 0x12, 0x4d, 0x73, 0x67, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x53, + 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x12, 0x30, 0x0a, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x65, + 0x72, 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, 0x3a, 0x12, 0x82, 0xe7, 0xb0, 0x2a, - 0x0d, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x1c, - 0x0a, 0x1a, 0x4d, 0x73, 0x67, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, - 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xb8, 0x02, 0x0a, - 0x03, 0x4d, 0x73, 0x67, 0x12, 0x5e, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, - 0x72, 0x61, 0x6d, 0x73, 0x12, 0x22, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, + 0x67, 0x52, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 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, 0x3a, 0x0b, 0x82, + 0xe7, 0xb0, 0x2a, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x22, 0x1c, 0x0a, 0x1a, 0x4d, 0x73, + 0x67, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xb8, 0x02, 0x0a, 0x03, 0x4d, 0x73, 0x67, + 0x12, 0x5e, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x12, 0x22, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, + 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x2a, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x2a, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 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, 0x61, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, - 0x70, 0x6c, 0x69, 0x65, 0x72, 0x12, 0x23, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, - 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x74, 0x61, - 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x1a, 0x2b, 0x2e, 0x70, 0x6f, 0x6b, - 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x4d, - 0x73, 0x67, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x67, 0x0a, 0x0f, 0x55, 0x6e, 0x73, 0x74, 0x61, - 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x12, 0x25, 0x2e, 0x70, 0x6f, 0x6b, - 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x4d, - 0x73, 0x67, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, - 0x72, 0x1a, 0x2d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, - 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, - 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0xa9, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, + 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x61, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, + 0x72, 0x12, 0x23, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, + 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, + 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x1a, 0x2b, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x74, + 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x67, 0x0a, 0x0f, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, + 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x12, 0x25, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x6e, + 0x73, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x1a, 0x2d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, - 0x72, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x22, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, - 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, - 0x6c, 0x2e, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0xca, 0x02, 0x11, 0x50, 0x6f, 0x6b, - 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0xe2, 0x02, - 0x1d, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, - 0x65, 0x72, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, - 0x12, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x75, 0x70, 0x70, 0x6c, - 0x69, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x70, + 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, + 0xb0, 0x2a, 0x01, 0x42, 0xa9, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, + 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x42, 0x07, 0x54, + 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x22, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0xa2, 0x02, 0x03, 0x50, + 0x53, 0x58, 0xaa, 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x75, + 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0xca, 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x5c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0xe2, 0x02, 0x1d, 0x50, 0x6f, 0x6b, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x12, 0x50, 0x6f, 0x6b, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/load-testing/tests/relays_stress_helpers_test.go b/load-testing/tests/relays_stress_helpers_test.go index c00f01341..37f2e5254 100644 --- a/load-testing/tests/relays_stress_helpers_test.go +++ b/load-testing/tests/relays_stress_helpers_test.go @@ -785,6 +785,7 @@ func (s *relaysSuite) addActor(actorAddress string, actorStakeAmount sdk.Coin) * // messages in a single supplier transaction. func (s *relaysSuite) addPendingStakeSupplierMsg(supplier *accountInfo) { supplier.addPendingMsg(suppliertypes.NewMsgStakeSupplier( + supplier.address, supplier.address, supplier.address, supplier.amountToStake, diff --git a/proto/poktroll/application/application.proto b/proto/poktroll/application/application.proto index 013d3080e..3d99314d9 100644 --- a/proto/poktroll/application/application.proto +++ b/proto/poktroll/application/application.proto @@ -11,7 +11,7 @@ import "poktroll/shared/service.proto"; // Application defines the type used to store an on-chain definition and state for an application message Application { - string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic encoding + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application. cosmos.base.v1beta1.Coin stake = 2; // The total amount of uPOKT the application has staked repeated poktroll.shared.ApplicationServiceConfig service_configs = 3; // The list of services this appliccation is configured to request service for // TODO_BETA: Rename `delegatee_gateway_addresses` to `gateway_addresses_delegated_to`. diff --git a/proto/poktroll/application/event.proto b/proto/poktroll/application/event.proto index 16d70a795..84e714619 100644 --- a/proto/poktroll/application/event.proto +++ b/proto/poktroll/application/event.proto @@ -9,6 +9,6 @@ import "cosmos_proto/cosmos.proto"; // delegatee gateways on chain. This is in response to both a DelegateToGateway // and UndelegateFromGateway message. message EventRedelegation { - string app_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application, using cosmos' ScalarDescriptor to ensure deterministic encoding - string gateway_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway the application has changed their delegation of, using cosmos' ScalarDescriptor to ensure deterministic encoding + string app_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application. + string gateway_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway the application has changed their delegation of. } \ No newline at end of file diff --git a/proto/poktroll/application/tx.proto b/proto/poktroll/application/tx.proto index f76eaa8af..1108eb21f 100644 --- a/proto/poktroll/application/tx.proto +++ b/proto/poktroll/application/tx.proto @@ -49,7 +49,7 @@ message MsgUpdateParamsResponse {} message MsgStakeApplication { option (cosmos.msg.v1.signer) = "address"; - string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic encoding + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application. cosmos.base.v1beta1.Coin stake = 2; // The total amount of uPOKT the application has staked. Must be ≥ to the current amount that the application has staked (if any) repeated poktroll.shared.ApplicationServiceConfig services = 3; // The list of services this application is staked to request service for } @@ -65,8 +65,8 @@ message MsgUnstakeApplicationResponse {} message MsgDelegateToGateway { option (cosmos.msg.v1.signer) = "app_address"; // https://docs.cosmos.network/main/build/building-modules/messages-and-queries - string app_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding - string gateway_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway the application wants to delegate to using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + string app_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application. + string gateway_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway the application wants to delegate to. } @@ -74,8 +74,8 @@ message MsgDelegateToGatewayResponse {} message MsgUndelegateFromGateway { option (cosmos.msg.v1.signer) = "app_address"; // https://docs.cosmos.network/main/build/building-modules/messages-and-queries - string app_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding - string gateway_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway the application wants to undelegate from using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + string app_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application. + string gateway_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway the application wants to undelegate from. } message MsgUndelegateFromGatewayResponse {} diff --git a/proto/poktroll/gateway/event.proto b/proto/poktroll/gateway/event.proto index fe6d59312..18737bdc3 100644 --- a/proto/poktroll/gateway/event.proto +++ b/proto/poktroll/gateway/event.proto @@ -7,5 +7,5 @@ import "cosmos_proto/cosmos.proto"; // GatewayStaked defines the event emitted when a gateway has been unstaked. message EventGatewayUnstaked { - string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway the application has changed their delegation of, using cosmos' ScalarDescriptor to ensure deterministic encoding + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway the application has changed their delegation of. } \ No newline at end of file diff --git a/proto/poktroll/service/relay.proto b/proto/poktroll/service/relay.proto index cffd71ae3..6874a3f61 100644 --- a/proto/poktroll/service/relay.proto +++ b/proto/poktroll/service/relay.proto @@ -26,10 +26,10 @@ message RelayRequestMetadata { // TODO_MAINNET: make sure we're checking/verifying this address on-chain (if needed). // Relevant conversation: https://github.com/pokt-network/poktroll/pull/567#discussion_r1628722168 - // + // // The supplier address the relay is sent to. It is being used on the RelayMiner to // route to the correct supplier. - string supplier_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application, using cosmos' ScalarDescriptor to ensure deterministic encoding + string supplier_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application. } // RelayRequest holds the request details for a relay. diff --git a/proto/poktroll/service/tx.proto b/proto/poktroll/service/tx.proto index 77f638d58..e9ef6634c 100644 --- a/proto/poktroll/service/tx.proto +++ b/proto/poktroll/service/tx.proto @@ -45,7 +45,7 @@ message MsgUpdateParamsResponse {} // TODO_BETA: Add Champions / Sources once its fully defined. message MsgAddService { 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 + string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the service owner. poktroll.shared.Service service = 2 [(gogoproto.nullable) = false]; // The Service being added to the network } diff --git a/proto/poktroll/session/query.proto b/proto/poktroll/session/query.proto index f695a5fc6..0e7b6141b 100644 --- a/proto/poktroll/session/query.proto +++ b/proto/poktroll/session/query.proto @@ -36,7 +36,7 @@ message QueryParamsResponse { } message QueryGetSessionRequest { - string application_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic encoding + 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 int64 block_height = 3; // The block height to query the session for } diff --git a/proto/poktroll/session/session.proto b/proto/poktroll/session/session.proto index 4049fb72c..c75cb713a 100644 --- a/proto/poktroll/session/session.proto +++ b/proto/poktroll/session/session.proto @@ -14,7 +14,7 @@ import "poktroll/shared/supplier.proto"; // 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. message SessionHeader { - string application_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic encoding + 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 // 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 diff --git a/proto/poktroll/shared/supplier.proto b/proto/poktroll/shared/supplier.proto index 5324c6e7c..a09001190 100644 --- a/proto/poktroll/shared/supplier.proto +++ b/proto/poktroll/shared/supplier.proto @@ -12,13 +12,13 @@ import "poktroll/shared/service.proto"; message Supplier { // The address of the owner (i.e. staker, custodial) that owns the funds for staking. // By default, this address is the one that receives all the rewards unless owtherwise specified. - // The owner can initially stake the supplier and unstake it. - // All other configurations are managed by the operator. + // This property cannot be updated by the operator. string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // Bech32 cosmos address - // The operator address of the supplier that operates it. - // The operator address can update the supplier's configurations excluding the owner - // and operator addresses which do not change over the supplier's lifespan. - // TODO(red-0ne): Rename this to `operator_address` include all downstream + // The address of the supplier operator (i.e. the one managing the off-chain server). + // The operator address can update the supplier's configurations excluding the owner address. + // This property do not change over the supplier's lifespan, the supplier must be usnaked + // and staked again to update this value. + // TODO(#722): Rename this to `operator_address` include all downstream // variables, comments, docs, tests, etc... string address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // Bech32 cosmos address cosmos.base.v1beta1.Coin stake = 3; // The total amount of uPOKT the supplier has staked diff --git a/proto/poktroll/supplier/tx.proto b/proto/poktroll/supplier/tx.proto index 9b1a079ce..ee44679b2 100644 --- a/proto/poktroll/supplier/tx.proto +++ b/proto/poktroll/supplier/tx.proto @@ -45,11 +45,11 @@ message MsgUpdateParams { message MsgUpdateParamsResponse {} message MsgStakeSupplier { - option (cosmos.msg.v1.signer) = "sender"; // https://docs.cosmos.network/main/build/building-modules/messages-and-queries + option (cosmos.msg.v1.signer) = "signer"; // https://docs.cosmos.network/main/build/building-modules/messages-and-queries - string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the message sender (i.e. owner or operator) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding - string owner_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the owner (i.e. custodial, staker) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding - string address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the operator (i.e. provider, non-custodial) using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the message signer (i.e. owner or operator) + string owner_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the owner (i.e. custodial, staker) + string address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the operator (i.e. provider, non-custodial) cosmos.base.v1beta1.Coin stake = 4; // The total amount of uPOKT the supplier has staked. Must be ≥ to the current amount that the supplier has staked (if any) repeated poktroll.shared.SupplierServiceConfig services = 5; // The list of services this supplier is staked to provide service for } @@ -57,18 +57,10 @@ message MsgStakeSupplier { message MsgStakeSupplierResponse {} message MsgUnstakeSupplier { - option (cosmos.msg.v1.signer) = "owner_address"; - // The address of the owner (i.e. staker, custodial) that owns the funds for staking. - // By default, this address is the one that receives all the rewards unless owtherwise specified. - // The owner can initially stake the supplier and unstake it. - // All other configurations are managed by the operator. - string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address - // The operator address of the supplier that operates it. - // The operator address can update the supplier's configurations excluding the owner - // and operator addresses which do not change over the supplier's lifespan. - // TODO(red-0ne): Rename this to `operator_address` include all downstream - // variables, comments, docs, tests, etc... - string address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address + option (cosmos.msg.v1.signer) = "signer"; + + string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the message signer (i.e. owner or operator) + string address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the operator (i.e. provider, non-custodial) } message MsgUnstakeSupplierResponse {} diff --git a/x/shared/types/supplier.go b/x/shared/types/supplier.go index d8a14a18d..1632de314 100644 --- a/x/shared/types/supplier.go +++ b/x/shared/types/supplier.go @@ -32,28 +32,12 @@ func (s *Supplier) IsActive(queryHeight uint64, serviceId string) bool { return true } -// EnsureOwner returns an error if the given address does not match supplier's owner address. -func (s *Supplier) EnsureOwner(ownerAddress string) error { - if s.OwnerAddress != ownerAddress { - return ErrSharedUnauthorizedSupplierUpdate.Wrapf( - "msg.OwnerAddress %q != provided address %q", - s.OwnerAddress, - ownerAddress, - ) - } - - return nil +// HasOwner returns whether the given address is the supplier's owner address. +func (s *Supplier) HasOwner(address string) bool { + return s.OwnerAddress == address } -// EnsureOperator returns an error if the given address does not match supplier's operator address. -func (s *Supplier) EnsureOperator(operatorAddress string) error { - if s.Address != operatorAddress { - return ErrSharedUnauthorizedSupplierUpdate.Wrapf( - "msg.OperatorAddress %q != provided address %q", - s.OwnerAddress, - operatorAddress, - ) - } - - return nil +// HasOperator returns whether the given address is the supplier's operator address. +func (s *Supplier) HasOperator(address string) bool { + return s.Address == address } diff --git a/x/shared/types/supplier.pb.go b/x/shared/types/supplier.pb.go index 6ae7c77f0..8ee46d960 100644 --- a/x/shared/types/supplier.pb.go +++ b/x/shared/types/supplier.pb.go @@ -28,13 +28,13 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Supplier struct { // The address of the owner (i.e. staker, custodial) that owns the funds for staking. // By default, this address is the one that receives all the rewards unless owtherwise specified. - // The owner can initially stake the supplier and unstake it. - // All other configurations are managed by the operator. + // This property cannot be updated by the operator. OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` - // The operator address of the supplier that operates it. - // The operator address can update the supplier's configurations excluding the owner - // and operator addresses which do not change over the supplier's lifespan. - // TODO(red-0ne): Rename this to `operator_address` include all downstream + // The address of the supplier operator (i.e. the one managing the off-chain server). + // The operator address can update the supplier's configurations excluding the owner address. + // This property do not change over the supplier's lifespan, the supplier must be usnaked + // and staked again to update this value. + // TODO(#722): Rename this to `operator_address` include all downstream // variables, comments, docs, tests, etc... Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` Stake *types.Coin `protobuf:"bytes,3,opt,name=stake,proto3" json:"stake,omitempty"` diff --git a/x/supplier/config/supplier_configs_reader.go b/x/supplier/config/supplier_configs_reader.go index 947024759..018cc324b 100644 --- a/x/supplier/config/supplier_configs_reader.go +++ b/x/supplier/config/supplier_configs_reader.go @@ -9,6 +9,7 @@ import ( "gopkg.in/yaml.v2" "github.com/pokt-network/poktroll/pkg/polylog" + _ "github.com/pokt-network/poktroll/pkg/polylog/polyzero" sharedhelpers "github.com/pokt-network/poktroll/x/shared/helpers" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" "github.com/pokt-network/poktroll/x/supplier/types" diff --git a/x/supplier/config/supplier_configs_reader_test.go b/x/supplier/config/supplier_configs_reader_test.go index 90ff18a03..a2a51d04d 100644 --- a/x/supplier/config/supplier_configs_reader_test.go +++ b/x/supplier/config/supplier_configs_reader_test.go @@ -1,6 +1,7 @@ package config_test import ( + "context" "testing" sdkerrors "cosmossdk.io/errors" @@ -365,10 +366,12 @@ func Test_ParseSupplierConfigs_Services(t *testing.T) { }, } + ctx := context.Background() + for _, tt := range tests { t.Run(tt.desc, func(t *testing.T) { normalizedConfig := yaml.NormalizeYAMLIndentation(tt.inputConfig) - supplierServiceConfig, err := config.ParseSupplierConfigs([]byte(normalizedConfig)) + supplierServiceConfig, err := config.ParseSupplierConfigs(ctx, []byte(normalizedConfig)) if tt.expectedError != nil { require.Error(t, err) diff --git a/x/supplier/keeper/msg_server_stake_supplier.go b/x/supplier/keeper/msg_server_stake_supplier.go index 9fad11d9b..002d437e4 100644 --- a/x/supplier/keeper/msg_server_stake_supplier.go +++ b/x/supplier/keeper/msg_server_stake_supplier.go @@ -23,6 +23,7 @@ func (k msgServer) StakeSupplier(ctx context.Context, msg *types.MsgStakeSupplie logger := k.Logger().With("method", "StakeSupplier") logger.Info(fmt.Sprintf("About to stake supplier with msg: %v", msg)) + // ValidateBasic also validates that the msg signer is the owner or operator of the supplier if err := msg.ValidateBasic(); err != nil { logger.Error(fmt.Sprintf("invalid MsgStakeSupplier: %v", msg)) return nil, err @@ -45,43 +46,29 @@ func (k msgServer) StakeSupplier(ctx context.Context, msg *types.MsgStakeSupplie logger.Info(fmt.Sprintf("Supplier not found. Creating new supplier for address %q", msg.Address)) supplier = k.createSupplier(ctx, msg) - // Ensure that only the owner can stake a new supplier. - if err = supplier.EnsureOwner(msg.Sender); err != nil { - logger.Error(fmt.Sprintf( - "owner address %q in the message does not match the msg sender address %q", - msg.OwnerAddress, - msg.Sender, - )) - - return nil, err - } - coinsToEscrow = *msg.Stake } else { logger.Info(fmt.Sprintf("Supplier found. About to try updating supplier with address %q", msg.Address)) - // Ensure that only the operator can update the supplier info. - if err = supplier.EnsureOperator(msg.Sender); err != nil { - logger.Error(fmt.Sprintf( - "operator address %q in the message does not match the msg sender address %q", - msg.Address, - msg.Sender, - )) - return nil, err - } - - // Ensure that the owner addresses is not changed. - if err = supplier.EnsureOwner(msg.OwnerAddress); err != nil { - logger.Error("updating the supplier's owner address forbidden") + // Ensure that only the owner can change the OwnerAddress. + // (i.e. fail if owner address changed and the owner is not the msg signer) + if !supplier.HasOwner(msg.OwnerAddress) && !msg.IsSigner(supplier.OwnerAddress) { + logger.Error("only the supplier owner is allowed to update the owner address") - return nil, err + return nil, sharedtypes.ErrSharedUnauthorizedSupplierUpdate.Wrapf( + "signer %q is not allowed to update the owner address %q", + msg.Signer, + supplier.OwnerAddress, + ) } - // Ensure that the operator addresses is not changed. - if err = supplier.EnsureOperator(msg.Address); err != nil { + // Ensure that the operator addresses cannot be changed. + if !supplier.HasOperator(msg.Address) { logger.Error("updating the supplier's operator address forbidden") - return nil, err + return nil, sharedtypes.ErrSharedUnauthorizedSupplierUpdate.Wrap( + "updating the operator address is forbidden, unstake then stake again in order to change the operator address", + ) } currSupplierStake := *supplier.Stake diff --git a/x/supplier/keeper/msg_server_unstake_supplier.go b/x/supplier/keeper/msg_server_unstake_supplier.go index 65e109deb..8e7527c1b 100644 --- a/x/supplier/keeper/msg_server_unstake_supplier.go +++ b/x/supplier/keeper/msg_server_unstake_supplier.go @@ -8,6 +8,7 @@ import ( "github.com/pokt-network/poktroll/telemetry" "github.com/pokt-network/poktroll/x/shared" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" "github.com/pokt-network/poktroll/x/supplier/types" ) @@ -37,15 +38,14 @@ func (k msgServer) UnstakeSupplier( return nil, types.ErrSupplierNotFound } - // Ensure that the message sender is the supplier owner. - if err := supplier.EnsureOwner(msg.OwnerAddress); err != nil { - logger.Error(fmt.Sprintf( - "owner address %q in the message does not match the supplier's owner address %q", - msg.OwnerAddress, - supplier.OwnerAddress, - )) - - return nil, err + // Ensure the singer address matches the owner address or the operator address. + if !supplier.HasOperator(msg.Signer) && supplier.HasOwner(msg.Signer) { + logger.Error("only the supplier owner or operator is allowed to unstake the supplier") + return nil, sharedtypes.ErrSharedUnauthorizedSupplierUpdate.Wrapf( + "signer %q is not allowed to unstake supplier %v", + msg.Signer, + supplier, + ) } logger.Info(fmt.Sprintf("Supplier found. Unstaking supplier for address %s", msg.Address)) diff --git a/x/supplier/module/tx_unstake_supplier.go b/x/supplier/module/tx_unstake_supplier.go index ed13b35cd..f104e05fc 100644 --- a/x/supplier/module/tx_unstake_supplier.go +++ b/x/supplier/module/tx_unstake_supplier.go @@ -17,7 +17,7 @@ func CmdUnstakeSupplier() *cobra.Command { Long: `Unstake an supplier with the provided parameters. This is a broadcast operation that will unstake the supplier specified by the and owned by 'from' address. Example: -$ poktrolld tx supplier unstake-supplier $(OPERATOR_ADDRESS) --keyring-backend test --from $(OWNER_ADDRESS) --node $(POCKET_NODE) --home=$(POKTROLLD_HOME)`, +$ poktrolld tx supplier unstake-supplier $(OPERATOR_ADDRESS) --keyring-backend test --from $(SIGNER_ADDRESS) --node $(POCKET_NODE) --home $(POKTROLLD_HOME)`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { @@ -26,11 +26,13 @@ $ poktrolld tx supplier unstake-supplier $(OPERATOR_ADDRESS) --keyring-backend t return err } - // address is the operator address of the supplier + // address is the must be the owner or operator address of the supplier address := args[0] + signerAddress := clientCtx.GetFromAddress().String() + msg := types.NewMsgUnstakeSupplier( - clientCtx.GetFromAddress().String(), + signerAddress, address, ) if err := msg.ValidateBasic(); err != nil { diff --git a/x/supplier/types/message_stake_supplier.go b/x/supplier/types/message_stake_supplier.go index c91fc6a66..e60ddd785 100644 --- a/x/supplier/types/message_stake_supplier.go +++ b/x/supplier/types/message_stake_supplier.go @@ -12,14 +12,14 @@ const TypeMsgStakeSupplier = "stake_supplier" var _ sdk.Msg = (*MsgStakeSupplier)(nil) func NewMsgStakeSupplier( - senderAddress string, + signerAddress string, ownerAddress string, supplierAddress string, stake sdk.Coin, services []*sharedtypes.SupplierServiceConfig, ) *MsgStakeSupplier { return &MsgStakeSupplier{ - Sender: senderAddress, + Signer: signerAddress, OwnerAddress: ownerAddress, Address: supplierAddress, Stake: &stake, @@ -33,26 +33,16 @@ func (msg *MsgStakeSupplier) ValidateBasic() error { return ErrSupplierInvalidAddress.Wrapf("invalid owner address %s; (%v)", msg.OwnerAddress, err) } - // Ensure the sender address matches the owner address or the operator address. - if msg.Sender != msg.OwnerAddress && msg.Sender != msg.Address { - return ErrSupplierInvalidAddress.Wrapf( - "sender address %s does not match owner address %s or supplier address %s", - msg.Sender, - msg.OwnerAddress, - msg.Address, - ) - } - // Validate the address if _, err := sdk.AccAddressFromBech32(msg.Address); err != nil { return ErrSupplierInvalidAddress.Wrapf("invalid supplier address %s; (%v)", msg.Address, err) } // Ensure the sender address matches the owner address or the operator address. - if msg.Sender != msg.OwnerAddress && msg.Sender != msg.Address { - return ErrSupplierInvalidAddress.Wrapf( + if msg.Signer != msg.OwnerAddress && msg.Signer != msg.Address { + return sharedtypes.ErrSharedUnauthorizedSupplierUpdate.Wrapf( "sender address %s does not match owner address %s or supplier address %s", - msg.Sender, + msg.Signer, msg.OwnerAddress, msg.Address, ) @@ -85,3 +75,7 @@ func (msg *MsgStakeSupplier) ValidateBasic() error { return nil } + +func (msg *MsgStakeSupplier) IsSigner(address string) bool { + return address == msg.Signer +} diff --git a/x/supplier/types/message_unstake_supplier.go b/x/supplier/types/message_unstake_supplier.go index affecdb4b..b0e42dbed 100644 --- a/x/supplier/types/message_unstake_supplier.go +++ b/x/supplier/types/message_unstake_supplier.go @@ -6,15 +6,15 @@ const TypeMsgUnstakeSupplier = "unstake_supplier" var _ sdk.Msg = (*MsgUnstakeSupplier)(nil) -func NewMsgUnstakeSupplier(ownerAddress, address string) *MsgUnstakeSupplier { +func NewMsgUnstakeSupplier(signerAddress, address string) *MsgUnstakeSupplier { return &MsgUnstakeSupplier{ - OwnerAddress: ownerAddress, - Address: address, + Signer: signerAddress, + Address: address, } } func (msg *MsgUnstakeSupplier) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.OwnerAddress); err != nil { + if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { return ErrSupplierInvalidAddress.Wrapf("invalid address address (%s)", err) } diff --git a/x/supplier/types/tx.pb.go b/x/supplier/types/tx.pb.go index 9d53fc189..45cb59c25 100644 --- a/x/supplier/types/tx.pb.go +++ b/x/supplier/types/tx.pb.go @@ -128,7 +128,7 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo type MsgStakeSupplier struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` OwnerAddress string `protobuf:"bytes,2,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` Stake *types.Coin `protobuf:"bytes,4,opt,name=stake,proto3" json:"stake,omitempty"` @@ -168,9 +168,9 @@ func (m *MsgStakeSupplier) XXX_DiscardUnknown() { var xxx_messageInfo_MsgStakeSupplier proto.InternalMessageInfo -func (m *MsgStakeSupplier) GetSender() string { +func (m *MsgStakeSupplier) GetSigner() string { if m != nil { - return m.Sender + return m.Signer } return "" } @@ -240,17 +240,8 @@ func (m *MsgStakeSupplierResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgStakeSupplierResponse proto.InternalMessageInfo type MsgUnstakeSupplier struct { - // The address of the owner (i.e. staker, custodial) that owns the funds for staking. - // By default, this address is the one that receives all the rewards unless owtherwise specified. - // The owner can initially stake the supplier and unstake it. - // All other configurations are managed by the operator. - OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` - // The operator address of the supplier that operates it. - // The operator address can update the supplier's configurations excluding the owner - // and operator addresses which do not change over the supplier's lifespan. - // TODO(red-0ne): Rename this to `operator_address` include all downstream - // variables, comments, docs, tests, etc... - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` + Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` } func (m *MsgUnstakeSupplier) Reset() { *m = MsgUnstakeSupplier{} } @@ -286,9 +277,9 @@ func (m *MsgUnstakeSupplier) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUnstakeSupplier proto.InternalMessageInfo -func (m *MsgUnstakeSupplier) GetOwnerAddress() string { +func (m *MsgUnstakeSupplier) GetSigner() string { if m != nil { - return m.OwnerAddress + return m.Signer } return "" } @@ -348,44 +339,43 @@ func init() { func init() { proto.RegisterFile("poktroll/supplier/tx.proto", fileDescriptor_63b974929807ef57) } var fileDescriptor_63b974929807ef57 = []byte{ - // 584 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x31, 0x8f, 0x12, 0x41, - 0x18, 0x65, 0x39, 0x41, 0x19, 0xee, 0x72, 0xde, 0xe4, 0x92, 0x5b, 0x36, 0xba, 0x92, 0xbd, 0x68, - 0x08, 0x86, 0x1d, 0xc1, 0xe4, 0x0a, 0xa2, 0x85, 0x5c, 0x69, 0x48, 0x0c, 0xc4, 0xc6, 0xc2, 0xcb, - 0x00, 0xe3, 0xb2, 0x01, 0x76, 0x36, 0x33, 0x03, 0x77, 0xd7, 0x19, 0x4b, 0x2b, 0x7b, 0xff, 0x80, - 0x25, 0x85, 0x85, 0x56, 0xb6, 0x57, 0x5e, 0xac, 0xac, 0x8c, 0x81, 0x82, 0xbf, 0x61, 0x76, 0x77, - 0x06, 0x5c, 0x40, 0x21, 0x36, 0xc0, 0xce, 0x7b, 0x6f, 0xbe, 0xf7, 0xbd, 0xef, 0x5b, 0x80, 0xe1, - 0xd3, 0x9e, 0x60, 0xb4, 0xdf, 0x47, 0x7c, 0xe8, 0xfb, 0x7d, 0x97, 0x30, 0x24, 0x2e, 0x6c, 0x9f, - 0x51, 0x41, 0xe1, 0x81, 0xc2, 0x6c, 0x85, 0x19, 0x07, 0x78, 0xe0, 0x7a, 0x14, 0x85, 0x9f, 0x11, - 0xcb, 0x38, 0x6a, 0x53, 0x3e, 0xa0, 0x1c, 0x0d, 0xb8, 0x83, 0x46, 0xe5, 0xe0, 0x4b, 0x02, 0xb9, - 0x08, 0x38, 0x0b, 0x9f, 0x50, 0xf4, 0x20, 0xa1, 0x43, 0x87, 0x3a, 0x34, 0x3a, 0x0f, 0x7e, 0xc9, - 0x53, 0x53, 0xde, 0xd4, 0xc2, 0x9c, 0xa0, 0x51, 0xb9, 0x45, 0x04, 0x2e, 0xa3, 0x36, 0x75, 0x3d, - 0x85, 0xaf, 0x7a, 0xf5, 0x31, 0xc3, 0x03, 0x75, 0xeb, 0xdd, 0x05, 0xde, 0xc5, 0x8c, 0x74, 0x10, - 0x27, 0x6c, 0xe4, 0xb6, 0x49, 0x04, 0x5b, 0xdf, 0x34, 0xb0, 0x5f, 0xe7, 0xce, 0x4b, 0xbf, 0x83, - 0x05, 0x79, 0x11, 0x0a, 0xe1, 0x09, 0xc8, 0xe0, 0xa1, 0xe8, 0x52, 0xe6, 0x8a, 0x4b, 0x5d, 0xcb, - 0x6b, 0x85, 0x4c, 0x4d, 0xff, 0xfe, 0xb9, 0x74, 0x28, 0xdd, 0x3e, 0xeb, 0x74, 0x18, 0xe1, 0xbc, - 0x29, 0x98, 0xeb, 0x39, 0x8d, 0x05, 0x15, 0x3e, 0x01, 0xe9, 0xa8, 0xb4, 0x9e, 0xcc, 0x6b, 0x85, - 0x6c, 0x25, 0x67, 0xaf, 0x64, 0x65, 0x47, 0x25, 0x6a, 0x99, 0xab, 0x9f, 0xf7, 0x12, 0x9f, 0x66, - 0xe3, 0xa2, 0xd6, 0x90, 0x9a, 0xea, 0xc9, 0xbb, 0xd9, 0xb8, 0xb8, 0xb8, 0xed, 0xfd, 0x6c, 0x5c, - 0x3c, 0x9e, 0x7b, 0xbf, 0x58, 0x74, 0xb7, 0xe4, 0xd6, 0xca, 0x81, 0xa3, 0xa5, 0xa3, 0x06, 0xe1, - 0x3e, 0xf5, 0x38, 0xb1, 0xbe, 0x26, 0xc1, 0xed, 0x3a, 0x77, 0x9a, 0x02, 0xf7, 0x48, 0x53, 0xea, - 0xe1, 0x23, 0x90, 0xe6, 0xc4, 0xeb, 0x10, 0xb6, 0xb1, 0x35, 0xc9, 0x83, 0x4f, 0xc1, 0x1e, 0x3d, - 0xf7, 0x08, 0x3b, 0xc3, 0x11, 0x1c, 0xb6, 0xf7, 0x2f, 0xe1, 0x6e, 0x48, 0x97, 0x67, 0xb0, 0x02, - 0x6e, 0x2a, 0xe1, 0xce, 0x06, 0xa1, 0x22, 0x42, 0x04, 0x52, 0x3c, 0x70, 0xad, 0xdf, 0x90, 0x49, - 0x4a, 0x7a, 0xb0, 0x05, 0xb6, 0xdc, 0x02, 0xfb, 0x94, 0xba, 0x5e, 0x23, 0xe2, 0xc1, 0x1a, 0xb8, - 0x25, 0x07, 0xcb, 0xf5, 0x54, 0x7e, 0xa7, 0x90, 0xad, 0x3c, 0xf8, 0x23, 0xfd, 0x70, 0xf2, 0xb6, - 0x8a, 0xa0, 0x19, 0x11, 0x4f, 0xa9, 0xf7, 0xc6, 0x75, 0x1a, 0x73, 0x5d, 0x35, 0x1b, 0x4c, 0x40, - 0x36, 0x6d, 0x19, 0x40, 0x5f, 0x8e, 0x6e, 0x9e, 0xeb, 0x47, 0x0d, 0xc0, 0x20, 0x73, 0x8f, 0xc7, - 0x92, 0x5d, 0xc9, 0x49, 0xfb, 0xdf, 0x9c, 0x92, 0x5b, 0xe6, 0x54, 0x85, 0x81, 0xe5, 0x78, 0x55, - 0xeb, 0x0e, 0x30, 0x56, 0xcd, 0x29, 0xef, 0x95, 0x2f, 0x49, 0xb0, 0x53, 0xe7, 0x0e, 0x7c, 0x0d, - 0x76, 0x63, 0x4b, 0x6f, 0xad, 0x59, 0xd6, 0xa5, 0xbd, 0x32, 0x8a, 0x9b, 0x39, 0xaa, 0x0e, 0xc4, - 0x60, 0x2f, 0xbe, 0x77, 0xc7, 0xeb, 0xc5, 0x31, 0x92, 0xf1, 0x70, 0x0b, 0xd2, 0xbc, 0x84, 0x03, - 0xf6, 0x97, 0x47, 0x70, 0xff, 0x2f, 0x0e, 0xe3, 0x34, 0xa3, 0xb4, 0x15, 0x4d, 0x15, 0x32, 0x52, - 0x6f, 0x83, 0x37, 0xb5, 0xf6, 0xfc, 0x6a, 0x62, 0x6a, 0xd7, 0x13, 0x53, 0xfb, 0x35, 0x31, 0xb5, - 0x0f, 0x53, 0x33, 0x71, 0x3d, 0x35, 0x13, 0x3f, 0xa6, 0x66, 0xe2, 0x55, 0xd9, 0x71, 0x45, 0x77, - 0xd8, 0xb2, 0xdb, 0x74, 0x80, 0x82, 0x9b, 0x4b, 0x1e, 0x11, 0xe7, 0x94, 0xf5, 0xd0, 0xba, 0x17, - 0x58, 0x5c, 0xfa, 0x84, 0xb7, 0xd2, 0xe1, 0xff, 0xcf, 0xe3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, - 0xb9, 0x89, 0x76, 0x77, 0x6c, 0x05, 0x00, 0x00, + // 574 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xbf, 0x8f, 0x12, 0x41, + 0x18, 0x65, 0x41, 0x50, 0x86, 0xbb, 0x9c, 0x37, 0xb9, 0xe4, 0x96, 0x8d, 0xae, 0x84, 0x8b, 0x86, + 0x60, 0xd8, 0x11, 0x4c, 0xae, 0xb8, 0x68, 0x21, 0x57, 0x1a, 0x12, 0x03, 0xb1, 0xb1, 0xf0, 0x32, + 0xc0, 0x38, 0x6c, 0x80, 0x9d, 0xcd, 0xcc, 0xc0, 0xdd, 0x75, 0xc6, 0xc6, 0xc4, 0xca, 0x3f, 0xc3, + 0x92, 0xc2, 0x42, 0x2b, 0xdb, 0x2b, 0x2f, 0x56, 0x56, 0xc6, 0x40, 0xc1, 0xbf, 0x61, 0x76, 0x77, + 0x06, 0xe4, 0x87, 0x72, 0xf1, 0x1a, 0x60, 0xe7, 0xbd, 0xf7, 0x7d, 0xef, 0x7b, 0xf3, 0x2d, 0xc0, + 0xf2, 0x59, 0x57, 0x72, 0xd6, 0xeb, 0x21, 0x31, 0xf0, 0xfd, 0x9e, 0x4b, 0x38, 0x92, 0x67, 0x8e, + 0xcf, 0x99, 0x64, 0x70, 0x57, 0x63, 0x8e, 0xc6, 0xac, 0x5d, 0xdc, 0x77, 0x3d, 0x86, 0xc2, 0xcf, + 0x88, 0x65, 0xed, 0xb7, 0x98, 0xe8, 0x33, 0x81, 0xfa, 0x82, 0xa2, 0x61, 0x39, 0xf8, 0x52, 0x40, + 0x36, 0x02, 0x4e, 0xc2, 0x27, 0x14, 0x3d, 0x28, 0x68, 0x8f, 0x32, 0xca, 0xa2, 0xf3, 0xe0, 0x97, + 0x3a, 0xb5, 0x55, 0xa5, 0x26, 0x16, 0x04, 0x0d, 0xcb, 0x4d, 0x22, 0x71, 0x19, 0xb5, 0x98, 0xeb, + 0x69, 0x7c, 0xd5, 0xab, 0x8f, 0x39, 0xee, 0xeb, 0xaa, 0x77, 0xe7, 0x78, 0x07, 0x73, 0xd2, 0x46, + 0x82, 0xf0, 0xa1, 0xdb, 0x22, 0x11, 0x9c, 0xff, 0x66, 0x80, 0x9d, 0x9a, 0xa0, 0x2f, 0xfd, 0x36, + 0x96, 0xe4, 0x45, 0x28, 0x84, 0x87, 0x20, 0x8d, 0x07, 0xb2, 0xc3, 0xb8, 0x2b, 0xcf, 0x4d, 0x23, + 0x67, 0x14, 0xd2, 0x55, 0xf3, 0xfb, 0xe7, 0xd2, 0x9e, 0x72, 0xfb, 0xac, 0xdd, 0xe6, 0x44, 0x88, + 0x86, 0xe4, 0xae, 0x47, 0xeb, 0x73, 0x2a, 0x7c, 0x02, 0x52, 0x51, 0x6b, 0x33, 0x9e, 0x33, 0x0a, + 0x99, 0x4a, 0xd6, 0x59, 0xc9, 0xca, 0x89, 0x5a, 0x54, 0xd3, 0x17, 0x3f, 0xef, 0xc5, 0x3e, 0x4d, + 0x47, 0x45, 0xa3, 0xae, 0x34, 0x47, 0x87, 0xef, 0xa6, 0xa3, 0xe2, 0xbc, 0xda, 0x87, 0xe9, 0xa8, + 0x78, 0x30, 0xf3, 0x7e, 0x36, 0x9f, 0x6e, 0xc9, 0x6d, 0x3e, 0x0b, 0xf6, 0x97, 0x8e, 0xea, 0x44, + 0xf8, 0xcc, 0x13, 0x24, 0xff, 0x35, 0x0e, 0x6e, 0xd7, 0x04, 0x6d, 0x48, 0xdc, 0x25, 0x0d, 0xa5, + 0x87, 0x8f, 0x40, 0x4a, 0xb8, 0xd4, 0x23, 0x7c, 0xe3, 0x68, 0x8a, 0x07, 0x9f, 0x82, 0x6d, 0x76, + 0xea, 0x11, 0x7e, 0x82, 0x23, 0x38, 0x1c, 0xef, 0x5f, 0xc2, 0xad, 0x90, 0xae, 0xce, 0x60, 0x05, + 0xdc, 0xd4, 0xc2, 0xc4, 0x06, 0xa1, 0x26, 0x42, 0x04, 0x92, 0x22, 0x70, 0x6d, 0xde, 0x50, 0x49, + 0x2a, 0x7a, 0xb0, 0x05, 0x8e, 0xda, 0x02, 0xe7, 0x98, 0xb9, 0x5e, 0x3d, 0xe2, 0xc1, 0x2a, 0xb8, + 0xa5, 0x2e, 0x56, 0x98, 0xc9, 0x5c, 0xa2, 0x90, 0xa9, 0x3c, 0xf8, 0x23, 0xfd, 0xf0, 0xe6, 0x1d, + 0x1d, 0x41, 0x23, 0x22, 0x1e, 0x33, 0xef, 0x8d, 0x4b, 0xeb, 0x33, 0xdd, 0x51, 0x26, 0xb8, 0x01, + 0x35, 0x74, 0xde, 0x02, 0xe6, 0x72, 0x74, 0xb3, 0x5c, 0xdf, 0x1b, 0x00, 0x06, 0x99, 0x7b, 0xe2, + 0x9a, 0xc9, 0xfe, 0x47, 0x34, 0x8b, 0x2e, 0xef, 0x00, 0x6b, 0xd5, 0x88, 0xf6, 0x59, 0xf9, 0x12, + 0x07, 0x89, 0x9a, 0xa0, 0xf0, 0x35, 0xd8, 0x5a, 0x58, 0xf0, 0xfc, 0x9a, 0xc5, 0x5c, 0xda, 0x21, + 0xab, 0xb8, 0x99, 0xa3, 0xfb, 0x40, 0x0c, 0xb6, 0x17, 0x77, 0xec, 0x60, 0xbd, 0x78, 0x81, 0x64, + 0x3d, 0xbc, 0x02, 0x69, 0xd6, 0x82, 0x82, 0x9d, 0xe5, 0xb8, 0xef, 0xff, 0xc5, 0xe1, 0x22, 0xcd, + 0x2a, 0x5d, 0x89, 0xa6, 0x1b, 0x59, 0xc9, 0xb7, 0xc1, 0x5b, 0x59, 0x7d, 0x7e, 0x31, 0xb6, 0x8d, + 0xcb, 0xb1, 0x6d, 0xfc, 0x1a, 0xdb, 0xc6, 0xc7, 0x89, 0x1d, 0xbb, 0x9c, 0xd8, 0xb1, 0x1f, 0x13, + 0x3b, 0xf6, 0xaa, 0x4c, 0x5d, 0xd9, 0x19, 0x34, 0x9d, 0x16, 0xeb, 0xa3, 0xa0, 0x72, 0xc9, 0x23, + 0xf2, 0x94, 0xf1, 0x2e, 0x5a, 0xf7, 0xb2, 0xca, 0x73, 0x9f, 0x88, 0x66, 0x2a, 0xfc, 0xaf, 0x79, + 0xfc, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x5c, 0x81, 0xd3, 0xc0, 0x58, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -667,10 +657,10 @@ func (m *MsgStakeSupplier) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- dAtA[i] = 0xa } @@ -725,12 +715,12 @@ func (m *MsgUnstakeSupplier) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Address) i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } - if len(m.OwnerAddress) > 0 { - i -= len(m.OwnerAddress) - copy(dAtA[i:], m.OwnerAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.OwnerAddress))) + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- dAtA[i] = 0xa } @@ -801,7 +791,7 @@ func (m *MsgStakeSupplier) Size() (n int) { } var l int _ = l - l = len(m.Sender) + l = len(m.Signer) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -841,7 +831,7 @@ func (m *MsgUnstakeSupplier) Size() (n int) { } var l int _ = l - l = len(m.OwnerAddress) + l = len(m.Signer) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1063,7 +1053,7 @@ func (m *MsgStakeSupplier) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1091,7 +1081,7 @@ func (m *MsgStakeSupplier) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Sender = string(dAtA[iNdEx:postIndex]) + m.Signer = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -1329,7 +1319,7 @@ func (m *MsgUnstakeSupplier) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OwnerAddress", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1357,9 +1347,9 @@ func (m *MsgUnstakeSupplier) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.OwnerAddress = string(dAtA[iNdEx:postIndex]) + m.Signer = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } diff --git a/x/tokenomics/types/tx.pb.go b/x/tokenomics/types/tx.pb.go index 03eea41a6..6a9db5288 100644 --- a/x/tokenomics/types/tx.pb.go +++ b/x/tokenomics/types/tx.pb.go @@ -130,9 +130,10 @@ type MsgUpdateParam struct { // authority is the address that controls the module (defaults to x/gov unless overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` // The (name, as_type) tuple must match the corresponding name and type as - // specified in the `Params`` message in `proof/params.proto.` + // 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 From fdfd9b9d62987caecf1bed19a5fdac8888762a05 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Thu, 8 Aug 2024 06:05:53 +0200 Subject: [PATCH 08/14] fix: Duplicate supplierKeeper declaration --- testutil/integration/app.go | 1 - testutil/keeper/tokenomics.go | 6 ------ x/tokenomics/keeper/keeper.go | 3 --- x/tokenomics/module/module.go | 2 -- x/tokenomics/types/errors.go | 1 + 5 files changed, 1 insertion(+), 12 deletions(-) diff --git a/testutil/integration/app.go b/testutil/integration/app.go index 76920088f..999949d9a 100644 --- a/testutil/integration/app.go +++ b/testutil/integration/app.go @@ -416,7 +416,6 @@ func NewCompleteIntegrationApp(t *testing.T) *App { sharedKeeper, sessionKeeper, serviceKeeper, - supplierKeeper, ) tokenomicsModule := tokenomics.NewAppModule( cdc, diff --git a/testutil/keeper/tokenomics.go b/testutil/keeper/tokenomics.go index bfa71e149..a86f20c27 100644 --- a/testutil/keeper/tokenomics.go +++ b/testutil/keeper/tokenomics.go @@ -186,10 +186,6 @@ func TokenomicsKeeperWithActorAddrs(t testing.TB) ( mockSharedKeeper := mocks.NewMockSharedKeeper(ctrl) mockSharedKeeper.EXPECT().GetProofWindowCloseHeight(gomock.Any(), gomock.Any()).AnyTimes() - // Mock the supplier keeper - mockSupplierKeeper := mocks.NewMockSupplierKeeper(ctrl) - mockSupplierKeeper.EXPECT().GetSupplier(gomock.Any(), gomock.Any()).AnyTimes() - // Mock the session keeper mockSessionKeeper := mocks.NewMockSessionKeeper(ctrl) @@ -218,7 +214,6 @@ func TokenomicsKeeperWithActorAddrs(t testing.TB) ( mockSharedKeeper, mockSessionKeeper, mockServiceKeeper, - mockSupplierKeeper, ) sdkCtx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger()) @@ -416,7 +411,6 @@ func NewTokenomicsModuleKeepers( sharedKeeper, sessionKeeper, serviceKeeper, - supplierKeeper, ) require.NoError(t, tokenomicsKeeper.SetParams(sdkCtx, tokenomicstypes.DefaultParams())) diff --git a/x/tokenomics/keeper/keeper.go b/x/tokenomics/keeper/keeper.go index a9cedaea5..c21be050f 100644 --- a/x/tokenomics/keeper/keeper.go +++ b/x/tokenomics/keeper/keeper.go @@ -31,7 +31,6 @@ type Keeper struct { sharedKeeper types.SharedKeeper sessionKeeper types.SessionKeeper serviceKeeper types.ServiceKeeper - supplierKeeper types.SupplierKeeper sharedQuerier client.SharedQueryClient } @@ -50,7 +49,6 @@ func NewKeeper( sharedKeeper types.SharedKeeper, sessionKeeper types.SessionKeeper, serviceKeeper types.ServiceKeeper, - supplierKeeper types.SupplierKeeper, ) Keeper { if _, err := sdk.AccAddressFromBech32(authority); err != nil { panic(fmt.Sprintf("invalid authority address: %s", authority)) @@ -72,7 +70,6 @@ func NewKeeper( sharedKeeper: sharedKeeper, sessionKeeper: sessionKeeper, serviceKeeper: serviceKeeper, - supplierKeeper: supplierKeeper, sharedQuerier: sharedQuerier, } diff --git a/x/tokenomics/module/module.go b/x/tokenomics/module/module.go index dcceeb7e9..d6c79ce91 100644 --- a/x/tokenomics/module/module.go +++ b/x/tokenomics/module/module.go @@ -188,7 +188,6 @@ type ModuleInputs struct { SharedKeeper types.SharedKeeper SessionKeeper types.SessionKeeper ServiceKeeper types.ServiceKeeper - SupplierKeeper types.SupplierKeeper } type ModuleOutputs struct { @@ -218,7 +217,6 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { in.SharedKeeper, in.SessionKeeper, in.ServiceKeeper, - in.SupplierKeeper, ) m := NewAppModule( in.Cdc, diff --git a/x/tokenomics/types/errors.go b/x/tokenomics/types/errors.go index 4f02c5d44..5538516aa 100644 --- a/x/tokenomics/types/errors.go +++ b/x/tokenomics/types/errors.go @@ -30,4 +30,5 @@ var ( ErrTokenomicsModuleMintFailed = sdkerrors.Register(ModuleName, 1121, "failed to mint uPOKT to tokenomics module account") ErrTokenomicsSendingMindRewards = sdkerrors.Register(ModuleName, 1122, "failed to send minted rewards") ErrTokenomicsSupplierModuleMintFailed = sdkerrors.Register(ModuleName, 1123, "failed to mint uPOKT to supplier module account") + ErrTokenomicsSupplierOwnerAddressInvalid = sdkerrors.Register(ModuleName, 1124, "the supplier owner address in the claim is not a valid bech32 address") ) From 095571af4eb9dae8014505e563fc8f405a0afe56 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Thu, 8 Aug 2024 06:55:40 +0200 Subject: [PATCH 09/14] fix: Reward the owner instead of the operator --- x/tokenomics/keeper/token_logic_modules.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x/tokenomics/keeper/token_logic_modules.go b/x/tokenomics/keeper/token_logic_modules.go index c0a10ebbe..25794f7f4 100644 --- a/x/tokenomics/keeper/token_logic_modules.go +++ b/x/tokenomics/keeper/token_logic_modules.go @@ -252,7 +252,7 @@ func (k Keeper) TokenLogicModuleRelayBurnEqualsMint( ) error { logger := k.Logger().With("method", "TokenLogicModuleRelayBurnEqualsMint") - supplierAddr, err := cosmostypes.AccAddressFromBech32(supplier.Address) + ownerAddr, err := cosmostypes.AccAddressFromBech32(supplier.OwnerAddress) if err != nil { return err } @@ -278,7 +278,7 @@ func (k Keeper) TokenLogicModuleRelayBurnEqualsMint( // Send the newley minted uPOKT from the supplier module account // to the supplier's account. if err = k.bankKeeper.SendCoinsFromModuleToAccount( - ctx, suppliertypes.ModuleName, supplierAddr, sdk.NewCoins(settlementCoins), + ctx, suppliertypes.ModuleName, ownerAddr, sdk.NewCoins(settlementCoins), ); err != nil { return tokenomicstypes.ErrTokenomicsSupplierModuleSendFailed.Wrapf( "sending (%s) to supplier with address %s: %v", @@ -357,7 +357,7 @@ func (k Keeper) TokenLogicModuleGlobalMint( logger.Debug(fmt.Sprintf("sent (%v) newley minted coins from the tokenomics module to the application with address %q", appCoins, application.Address)) // Send a portion of the rewards to the supplier - supplierCoins, err := k.sendRewardsToAccount(ctx, supplier.Address, newMintAmtFloat, MintAllocationSupplier) + supplierCoins, err := k.sendRewardsToAccount(ctx, supplier.OwnerAddress, newMintAmtFloat, MintAllocationSupplier) if err != nil { return tokenomictypes.ErrTokenomicsSendingMindRewards.Wrapf("sending rewards to supplier: %v", err) } From 910c85bc91ef7a4836277ac15ac62dcb00a5ae81 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Fri, 9 Aug 2024 05:32:14 +0200 Subject: [PATCH 10/14] fix: Allow owner to change its aaddress --- .../keeper/msg_server_stake_supplier.go | 30 +++++++++++++------ x/supplier/types/message_stake_supplier.go | 11 ++----- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/x/supplier/keeper/msg_server_stake_supplier.go b/x/supplier/keeper/msg_server_stake_supplier.go index ef099c758..74ffc90d7 100644 --- a/x/supplier/keeper/msg_server_stake_supplier.go +++ b/x/supplier/keeper/msg_server_stake_supplier.go @@ -50,6 +50,16 @@ func (k msgServer) StakeSupplier(ctx context.Context, msg *types.MsgStakeSupplie } else { logger.Info(fmt.Sprintf("Supplier found. About to try updating supplier with address %q", msg.Address)) + // Ensure the signer is either the owner or the operator of the supplier. + if !msg.IsSigner(supplier.OwnerAddress) && !msg.IsSigner(supplier.Address) { + return nil, sharedtypes.ErrSharedUnauthorizedSupplierUpdate.Wrapf( + "signer address %s does not match owner address %s or supplier address %s", + msg.Signer, + msg.OwnerAddress, + msg.Address, + ) + } + // Ensure that only the owner can change the OwnerAddress. // (i.e. fail if owner address changed and the owner is not the msg signer) if !supplier.HasOwner(msg.OwnerAddress) && !msg.IsSigner(supplier.OwnerAddress) { @@ -89,24 +99,24 @@ func (k msgServer) StakeSupplier(ctx context.Context, msg *types.MsgStakeSupplie // Must always stake or upstake (> 0 delta) if coinsToEscrow.IsZero() { - logger.Warn(fmt.Sprintf("Supplier %q must escrow more than 0 additional coins", msg.Address)) - return nil, types.ErrSupplierInvalidStake.Wrapf("supplier %q must escrow more than 0 additional coins", msg.Address) + logger.Warn(fmt.Sprintf("Signer %q must escrow more than 0 additional coins", msg.Signer)) + return nil, types.ErrSupplierInvalidStake.Wrapf("Signer %q must escrow more than 0 additional coins", msg.Signer) } - // Retrieve the account address of the supplier owner - supplierOwnerAddress, err := sdk.AccAddressFromBech32(supplier.OwnerAddress) + // Retrieve the account address of the message signer + msgSignerAddress, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { - logger.Error(fmt.Sprintf("could not parse address %q", supplier.OwnerAddress)) + logger.Error(fmt.Sprintf("could not parse address %q", msg.Signer)) return nil, err } - // Send the coins from the supplier to the staked supplier pool - err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, supplierOwnerAddress, types.ModuleName, []sdk.Coin{coinsToEscrow}) + // Send the coins from the message signer account to the staked supplier pool + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, msgSignerAddress, types.ModuleName, []sdk.Coin{coinsToEscrow}) if err != nil { - logger.Error(fmt.Sprintf("could not send %v coins from %q to %q module account due to %v", coinsToEscrow, supplierOwnerAddress, types.ModuleName, err)) + logger.Error(fmt.Sprintf("could not send %v coins from %q to %q module account due to %v", coinsToEscrow, msgSignerAddress, types.ModuleName, err)) return nil, err } - logger.Info(fmt.Sprintf("Successfully escrowed %v coins from %q to %q module account", coinsToEscrow, supplierOwnerAddress, types.ModuleName)) + logger.Info(fmt.Sprintf("Successfully escrowed %v coins from %q to %q module account", coinsToEscrow, msgSignerAddress, types.ModuleName)) // Update the Supplier in the store k.SetSupplier(ctx, supplier) @@ -158,6 +168,8 @@ func (k msgServer) updateSupplier( } supplier.Stake = msg.Stake + supplier.OwnerAddress = msg.OwnerAddress + // Validate that the service configs maintain at least one service. // Additional validation is done in `msg.ValidateBasic` above. if len(msg.Services) == 0 { diff --git a/x/supplier/types/message_stake_supplier.go b/x/supplier/types/message_stake_supplier.go index e60ddd785..1c67891a3 100644 --- a/x/supplier/types/message_stake_supplier.go +++ b/x/supplier/types/message_stake_supplier.go @@ -38,14 +38,9 @@ func (msg *MsgStakeSupplier) ValidateBasic() error { return ErrSupplierInvalidAddress.Wrapf("invalid supplier address %s; (%v)", msg.Address, err) } - // Ensure the sender address matches the owner address or the operator address. - if msg.Signer != msg.OwnerAddress && msg.Signer != msg.Address { - return sharedtypes.ErrSharedUnauthorizedSupplierUpdate.Wrapf( - "sender address %s does not match owner address %s or supplier address %s", - msg.Signer, - msg.OwnerAddress, - msg.Address, - ) + // Validate the signer address + if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { + return ErrSupplierInvalidAddress.Wrapf("invalid supplier address %s; (%v)", msg.Address, err) } // TODO_MAINNET: Centralize stake related verification and share across different From 1f26789c276feb24c880128b6940788595fcc3d3 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Fri, 9 Aug 2024 05:42:49 +0200 Subject: [PATCH 11/14] fix: Stake auth contidional --- x/supplier/keeper/msg_server_unstake_supplier.go | 2 +- x/supplier/types/message_stake_supplier.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x/supplier/keeper/msg_server_unstake_supplier.go b/x/supplier/keeper/msg_server_unstake_supplier.go index 8e7527c1b..0cdc0821c 100644 --- a/x/supplier/keeper/msg_server_unstake_supplier.go +++ b/x/supplier/keeper/msg_server_unstake_supplier.go @@ -39,7 +39,7 @@ func (k msgServer) UnstakeSupplier( } // Ensure the singer address matches the owner address or the operator address. - if !supplier.HasOperator(msg.Signer) && supplier.HasOwner(msg.Signer) { + if !supplier.HasOperator(msg.Signer) && !supplier.HasOwner(msg.Signer) { logger.Error("only the supplier owner or operator is allowed to unstake the supplier") return nil, sharedtypes.ErrSharedUnauthorizedSupplierUpdate.Wrapf( "signer %q is not allowed to unstake supplier %v", diff --git a/x/supplier/types/message_stake_supplier.go b/x/supplier/types/message_stake_supplier.go index 1c67891a3..399799742 100644 --- a/x/supplier/types/message_stake_supplier.go +++ b/x/supplier/types/message_stake_supplier.go @@ -35,12 +35,12 @@ func (msg *MsgStakeSupplier) ValidateBasic() error { // Validate the address if _, err := sdk.AccAddressFromBech32(msg.Address); err != nil { - return ErrSupplierInvalidAddress.Wrapf("invalid supplier address %s; (%v)", msg.Address, err) + return ErrSupplierInvalidAddress.Wrapf("invalid operator address %s; (%v)", msg.Address, err) } // Validate the signer address if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { - return ErrSupplierInvalidAddress.Wrapf("invalid supplier address %s; (%v)", msg.Address, err) + return ErrSupplierInvalidAddress.Wrapf("invalid signer address %s; (%v)", msg.Address, err) } // TODO_MAINNET: Centralize stake related verification and share across different From 8060f4614ea1fd46ebcca09cf5f66f97bbe9ae09 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Tue, 13 Aug 2024 20:36:17 +0200 Subject: [PATCH 12/14] chore: Address review change requests --- api/poktroll/shared/supplier.pulsar.go | 6 +++--- proto/poktroll/shared/supplier.proto | 6 +++--- x/shared/types/supplier.pb.go | 6 +++--- x/supplier/config/errors.go | 19 ++++++++++--------- x/supplier/config/supplier_configs_reader.go | 4 ++-- .../keeper/msg_server_stake_supplier.go | 2 +- 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/api/poktroll/shared/supplier.pulsar.go b/api/poktroll/shared/supplier.pulsar.go index 38ab0d90c..5037ddf52 100644 --- a/api/poktroll/shared/supplier.pulsar.go +++ b/api/poktroll/shared/supplier.pulsar.go @@ -1077,9 +1077,9 @@ type Supplier struct { OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` // Bech32 cosmos address // The address of the supplier operator (i.e. the one managing the off-chain server). // The operator address can update the supplier's configurations excluding the owner address. - // This property do not change over the supplier's lifespan, the supplier must be usnaked - // and staked again to update this value. - // TODO(#722): Rename this to `operator_address` include all downstream + // This property does not change over the supplier's lifespan, the supplier must be unstaked + // and re-staked to effectively update this value. + // TODO(#722): Rename this to `operator_address` including all downstream // variables, comments, docs, tests, etc... Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` // Bech32 cosmos address Stake *v1beta1.Coin `protobuf:"bytes,3,opt,name=stake,proto3" json:"stake,omitempty"` // The total amount of uPOKT the supplier has staked diff --git a/proto/poktroll/shared/supplier.proto b/proto/poktroll/shared/supplier.proto index a09001190..919f49efd 100644 --- a/proto/poktroll/shared/supplier.proto +++ b/proto/poktroll/shared/supplier.proto @@ -16,9 +16,9 @@ message Supplier { string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // Bech32 cosmos address // The address of the supplier operator (i.e. the one managing the off-chain server). // The operator address can update the supplier's configurations excluding the owner address. - // This property do not change over the supplier's lifespan, the supplier must be usnaked - // and staked again to update this value. - // TODO(#722): Rename this to `operator_address` include all downstream + // This property does not change over the supplier's lifespan, the supplier must be unstaked + // and re-staked to effectively update this value. + // TODO(#722): Rename this to `operator_address` including all downstream // variables, comments, docs, tests, etc... string address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // Bech32 cosmos address cosmos.base.v1beta1.Coin stake = 3; // The total amount of uPOKT the supplier has staked diff --git a/x/shared/types/supplier.pb.go b/x/shared/types/supplier.pb.go index 8ee46d960..868e01a6e 100644 --- a/x/shared/types/supplier.pb.go +++ b/x/shared/types/supplier.pb.go @@ -32,9 +32,9 @@ type Supplier struct { OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` // The address of the supplier operator (i.e. the one managing the off-chain server). // The operator address can update the supplier's configurations excluding the owner address. - // This property do not change over the supplier's lifespan, the supplier must be usnaked - // and staked again to update this value. - // TODO(#722): Rename this to `operator_address` include all downstream + // This property does not change over the supplier's lifespan, the supplier must be unstaked + // and re-staked to effectively update this value. + // TODO(#722): Rename this to `operator_address` including all downstream // variables, comments, docs, tests, etc... Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` Stake *types.Coin `protobuf:"bytes,3,opt,name=stake,proto3" json:"stake,omitempty"` diff --git a/x/supplier/config/errors.go b/x/supplier/config/errors.go index bfa46177b..5ae803128 100644 --- a/x/supplier/config/errors.go +++ b/x/supplier/config/errors.go @@ -7,13 +7,14 @@ import ( ) var ( - ErrSupplierConfigUnmarshalYAML = sdkerrors.Register(types.ModuleName, 2100, "config reader cannot unmarshal yaml content") - ErrSupplierConfigInvalidServiceId = sdkerrors.Register(types.ModuleName, 2101, "invalid serviceId in supplier config") - ErrSupplierConfigNoEndpoints = sdkerrors.Register(types.ModuleName, 2102, "no endpoints defined for serviceId in supplier config") - ErrSupplierConfigInvalidEndpointConfig = sdkerrors.Register(types.ModuleName, 2103, "invalid endpoint config in supplier config") - ErrSupplierConfigInvalidRPCType = sdkerrors.Register(types.ModuleName, 2104, "invalid rpc type in supplier config") - ErrSupplierConfigInvalidURL = sdkerrors.Register(types.ModuleName, 2105, "invalid endpoint url in supplier config") - ErrSupplierConfigEmptyContent = sdkerrors.Register(types.ModuleName, 2106, "empty supplier config content") - ErrSupplierConfigInvalidStake = sdkerrors.Register(types.ModuleName, 2107, "invalid stake amount in supplier config") - ErrSupplierConfigInvalidAddress = sdkerrors.Register(types.ModuleName, 2108, "missing owner address in supplier config") + ErrSupplierConfigUnmarshalYAML = sdkerrors.Register(types.ModuleName, 2100, "config reader cannot unmarshal yaml content") + ErrSupplierConfigInvalidServiceId = sdkerrors.Register(types.ModuleName, 2101, "invalid serviceId in supplier config") + ErrSupplierConfigNoEndpoints = sdkerrors.Register(types.ModuleName, 2102, "no endpoints defined for serviceId in supplier config") + ErrSupplierConfigInvalidEndpointConfig = sdkerrors.Register(types.ModuleName, 2103, "invalid endpoint config in supplier config") + ErrSupplierConfigInvalidRPCType = sdkerrors.Register(types.ModuleName, 2104, "invalid rpc type in supplier config") + ErrSupplierConfigInvalidURL = sdkerrors.Register(types.ModuleName, 2105, "invalid endpoint url in supplier config") + ErrSupplierConfigEmptyContent = sdkerrors.Register(types.ModuleName, 2106, "empty supplier config content") + ErrSupplierConfigInvalidStake = sdkerrors.Register(types.ModuleName, 2107, "invalid stake amount in supplier config") + ErrSupplierConfigInvalidOwnerAddress = sdkerrors.Register(types.ModuleName, 2108, "invalid owner address in supplier config") + ErrSupplierConfigInvalidOperatorAddress = sdkerrors.Register(types.ModuleName, 2108, "invalid operator address in supplier config") ) diff --git a/x/supplier/config/supplier_configs_reader.go b/x/supplier/config/supplier_configs_reader.go index 018cc324b..5f4fea0c0 100644 --- a/x/supplier/config/supplier_configs_reader.go +++ b/x/supplier/config/supplier_configs_reader.go @@ -76,7 +76,7 @@ func ParseSupplierConfigs(ctx context.Context, configContent []byte) (*SupplierS // Validate required owner address. if _, err := sdk.AccAddressFromBech32(stakeConfig.OwnerAddress); err != nil { - return nil, ErrSupplierConfigInvalidAddress.Wrap("invalid owner address") + return nil, ErrSupplierConfigInvalidOwnerAddress.Wrap("invalid owner address") } // If the operator address is not set, default it to the owner address. @@ -87,7 +87,7 @@ func ParseSupplierConfigs(ctx context.Context, configContent []byte) (*SupplierS // Validate operator address. if _, err := sdk.AccAddressFromBech32(stakeConfig.OperatorAddress); err != nil { - return nil, ErrSupplierConfigInvalidAddress.Wrap("invalid operator address") + return nil, ErrSupplierConfigInvalidOperatorAddress.Wrap("invalid operator address") } // Validate the stake amount diff --git a/x/supplier/keeper/msg_server_stake_supplier.go b/x/supplier/keeper/msg_server_stake_supplier.go index 74ffc90d7..31d0087b2 100644 --- a/x/supplier/keeper/msg_server_stake_supplier.go +++ b/x/supplier/keeper/msg_server_stake_supplier.go @@ -78,7 +78,7 @@ func (k msgServer) StakeSupplier(ctx context.Context, msg *types.MsgStakeSupplie logger.Error("updating the supplier's operator address forbidden") return nil, sharedtypes.ErrSharedUnauthorizedSupplierUpdate.Wrap( - "updating the operator address is forbidden, unstake then stake again in order to change the operator address", + "updating the operator address is forbidden, unstake then re-stake with the updated operator address", ) } From b887a0c4615d9fd5cf5566b6766dba9ead38722e Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Tue, 13 Aug 2024 20:51:44 +0200 Subject: [PATCH 13/14] fix: Error sequence --- x/supplier/config/errors.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/supplier/config/errors.go b/x/supplier/config/errors.go index 5ae803128..23b486c2b 100644 --- a/x/supplier/config/errors.go +++ b/x/supplier/config/errors.go @@ -16,5 +16,5 @@ var ( ErrSupplierConfigEmptyContent = sdkerrors.Register(types.ModuleName, 2106, "empty supplier config content") ErrSupplierConfigInvalidStake = sdkerrors.Register(types.ModuleName, 2107, "invalid stake amount in supplier config") ErrSupplierConfigInvalidOwnerAddress = sdkerrors.Register(types.ModuleName, 2108, "invalid owner address in supplier config") - ErrSupplierConfigInvalidOperatorAddress = sdkerrors.Register(types.ModuleName, 2108, "invalid operator address in supplier config") + ErrSupplierConfigInvalidOperatorAddress = sdkerrors.Register(types.ModuleName, 2109, "invalid operator address in supplier config") ) From 812171923da6d334ef283089c071b4aba7903ad8 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Tue, 13 Aug 2024 20:56:46 +0200 Subject: [PATCH 14/14] chore: Remove unused method --- x/supplier/config/supplier_configs_reader.go | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/x/supplier/config/supplier_configs_reader.go b/x/supplier/config/supplier_configs_reader.go index 5f4fea0c0..7f18fb035 100644 --- a/x/supplier/config/supplier_configs_reader.go +++ b/x/supplier/config/supplier_configs_reader.go @@ -12,7 +12,6 @@ import ( _ "github.com/pokt-network/poktroll/pkg/polylog/polyzero" sharedhelpers "github.com/pokt-network/poktroll/x/shared/helpers" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" - "github.com/pokt-network/poktroll/x/supplier/types" ) // YAMLStakeConfig is the structure describing the supplier stake config file. @@ -46,19 +45,6 @@ type SupplierStakeConfig struct { Services []*sharedtypes.SupplierServiceConfig } -// EnsureOwner ensures that the config owner address matches the provided address. -func (cfg *SupplierStakeConfig) EnsureOwner(ownerAddress string) error { - if cfg.OwnerAddress != ownerAddress { - return types.ErrSupplierInvalidAddress.Wrapf( - "owner address %q in the stake config file does not match the address provided %q", - cfg.OperatorAddress, - ownerAddress, - ) - } - - return nil -} - // ParseSupplierServiceConfig parses the stake config file into a SupplierServiceConfig. func ParseSupplierConfigs(ctx context.Context, configContent []byte) (*SupplierStakeConfig, error) { var stakeConfig *YAMLStakeConfig