From 9d089e7ba20adc712678df3e5ac8d341ee246701 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Tue, 28 May 2024 12:24:34 -0700 Subject: [PATCH 1/5] [Relay Mining] Scaffold the RelayMiningDifficulty type (#548) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Scaffold the `RelayMiningDifficulty` type. 1. I ran the following command: ```bash ignite scaffold map --module tokenomics --no-message relay-mining-difficulty block_height:int num_relays_ema:uint hash_target:string --index service_id --yes ``` 2. Manually update some naming and types 3. Fix some imports 4. Auto-save to format files ⚠️ `proto/poktroll/tokenomics/relay_mining_difficulty.proto` is the most imporant file to review ⚠️ --- api/poktroll/tokenomics/genesis.pulsar.go | 215 +- api/poktroll/tokenomics/query.pulsar.go | 2235 ++++++++++++++++- api/poktroll/tokenomics/query_grpc.pb.go | 78 +- .../relay_mining_difficulty.pulsar.go | 774 ++++++ proto/poktroll/tokenomics/genesis.proto | 8 +- proto/poktroll/tokenomics/query.proto | 41 +- .../tokenomics/relay_mining_difficulty.proto | 30 + testutil/keeper/tokenomics.go | 10 +- x/tokenomics/keeper/msg_server_test.go | 2 +- x/tokenomics/keeper/msg_update_params_test.go | 2 +- x/tokenomics/keeper/query_params_test.go | 4 +- .../keeper/query_relay_mining_difficulty.go | 56 + .../query_relay_mining_difficulty_test.go | 124 + .../keeper/relay_mining_difficulty.go | 83 + .../keeper/relay_mining_difficulty_test.go | 64 + .../keeper/settle_session_accounting_test.go | 6 +- x/tokenomics/module/autocli.go | 13 +- x/tokenomics/module/genesis.go | 5 + x/tokenomics/module/genesis_test.go | 11 +- x/tokenomics/module/module.go | 3 +- x/tokenomics/types/errors.go | 2 + x/tokenomics/types/genesis.go | 13 +- x/tokenomics/types/genesis.pb.go | 88 +- x/tokenomics/types/genesis_test.go | 25 +- .../types/key_relay_mining_difficulty.go | 23 + x/tokenomics/types/query.pb.go | 898 ++++++- x/tokenomics/types/query.pb.gw.go | 184 ++ .../types/relay_mining_difficulty.pb.go | 458 ++++ 28 files changed, 5331 insertions(+), 124 deletions(-) create mode 100644 api/poktroll/tokenomics/relay_mining_difficulty.pulsar.go create mode 100644 proto/poktroll/tokenomics/relay_mining_difficulty.proto create mode 100644 x/tokenomics/keeper/query_relay_mining_difficulty.go create mode 100644 x/tokenomics/keeper/query_relay_mining_difficulty_test.go create mode 100644 x/tokenomics/keeper/relay_mining_difficulty.go create mode 100644 x/tokenomics/keeper/relay_mining_difficulty_test.go create mode 100644 x/tokenomics/types/key_relay_mining_difficulty.go create mode 100644 x/tokenomics/types/relay_mining_difficulty.pb.go diff --git a/api/poktroll/tokenomics/genesis.pulsar.go b/api/poktroll/tokenomics/genesis.pulsar.go index be0862e09..8c7e27c60 100644 --- a/api/poktroll/tokenomics/genesis.pulsar.go +++ b/api/poktroll/tokenomics/genesis.pulsar.go @@ -14,15 +14,68 @@ import ( sync "sync" ) +var _ protoreflect.List = (*_GenesisState_2_list)(nil) + +type _GenesisState_2_list struct { + list *[]*RelayMiningDifficulty +} + +func (x *_GenesisState_2_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_GenesisState_2_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_GenesisState_2_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*RelayMiningDifficulty) + (*x.list)[i] = concreteValue +} + +func (x *_GenesisState_2_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*RelayMiningDifficulty) + *x.list = append(*x.list, concreteValue) +} + +func (x *_GenesisState_2_list) AppendMutable() protoreflect.Value { + v := new(RelayMiningDifficulty) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_GenesisState_2_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_GenesisState_2_list) NewElement() protoreflect.Value { + v := new(RelayMiningDifficulty) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_GenesisState_2_list) IsValid() bool { + return x.list != nil +} + var ( - md_GenesisState protoreflect.MessageDescriptor - fd_GenesisState_params protoreflect.FieldDescriptor + md_GenesisState protoreflect.MessageDescriptor + fd_GenesisState_params protoreflect.FieldDescriptor + fd_GenesisState_relayMiningDifficultyList protoreflect.FieldDescriptor ) func init() { file_poktroll_tokenomics_genesis_proto_init() md_GenesisState = File_poktroll_tokenomics_genesis_proto.Messages().ByName("GenesisState") fd_GenesisState_params = md_GenesisState.Fields().ByName("params") + fd_GenesisState_relayMiningDifficultyList = md_GenesisState.Fields().ByName("relayMiningDifficultyList") } var _ protoreflect.Message = (*fastReflection_GenesisState)(nil) @@ -96,6 +149,12 @@ func (x *fastReflection_GenesisState) Range(f func(protoreflect.FieldDescriptor, return } } + if len(x.RelayMiningDifficultyList) != 0 { + value := protoreflect.ValueOfList(&_GenesisState_2_list{list: &x.RelayMiningDifficultyList}) + if !f(fd_GenesisState_relayMiningDifficultyList, value) { + return + } + } } // Has reports whether a field is populated. @@ -113,6 +172,8 @@ func (x *fastReflection_GenesisState) Has(fd protoreflect.FieldDescriptor) bool switch fd.FullName() { case "poktroll.tokenomics.GenesisState.params": return x.Params != nil + case "poktroll.tokenomics.GenesisState.relayMiningDifficultyList": + return len(x.RelayMiningDifficultyList) != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.GenesisState")) @@ -131,6 +192,8 @@ func (x *fastReflection_GenesisState) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { case "poktroll.tokenomics.GenesisState.params": x.Params = nil + case "poktroll.tokenomics.GenesisState.relayMiningDifficultyList": + x.RelayMiningDifficultyList = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.GenesisState")) @@ -150,6 +213,12 @@ func (x *fastReflection_GenesisState) Get(descriptor protoreflect.FieldDescripto case "poktroll.tokenomics.GenesisState.params": value := x.Params return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "poktroll.tokenomics.GenesisState.relayMiningDifficultyList": + if len(x.RelayMiningDifficultyList) == 0 { + return protoreflect.ValueOfList(&_GenesisState_2_list{}) + } + listValue := &_GenesisState_2_list{list: &x.RelayMiningDifficultyList} + return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.GenesisState")) @@ -172,6 +241,10 @@ func (x *fastReflection_GenesisState) Set(fd protoreflect.FieldDescriptor, value switch fd.FullName() { case "poktroll.tokenomics.GenesisState.params": x.Params = value.Message().Interface().(*Params) + case "poktroll.tokenomics.GenesisState.relayMiningDifficultyList": + lv := value.List() + clv := lv.(*_GenesisState_2_list) + x.RelayMiningDifficultyList = *clv.list default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.GenesisState")) @@ -197,6 +270,12 @@ func (x *fastReflection_GenesisState) Mutable(fd protoreflect.FieldDescriptor) p x.Params = new(Params) } return protoreflect.ValueOfMessage(x.Params.ProtoReflect()) + case "poktroll.tokenomics.GenesisState.relayMiningDifficultyList": + if x.RelayMiningDifficultyList == nil { + x.RelayMiningDifficultyList = []*RelayMiningDifficulty{} + } + value := &_GenesisState_2_list{list: &x.RelayMiningDifficultyList} + return protoreflect.ValueOfList(value) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.GenesisState")) @@ -213,6 +292,9 @@ func (x *fastReflection_GenesisState) NewField(fd protoreflect.FieldDescriptor) case "poktroll.tokenomics.GenesisState.params": m := new(Params) return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "poktroll.tokenomics.GenesisState.relayMiningDifficultyList": + list := []*RelayMiningDifficulty{} + return protoreflect.ValueOfList(&_GenesisState_2_list{list: &list}) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.GenesisState")) @@ -286,6 +368,12 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods { l = options.Size(x.Params) n += 1 + l + runtime.Sov(uint64(l)) } + if len(x.RelayMiningDifficultyList) > 0 { + for _, e := range x.RelayMiningDifficultyList { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -315,6 +403,22 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if len(x.RelayMiningDifficultyList) > 0 { + for iNdEx := len(x.RelayMiningDifficultyList) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.RelayMiningDifficultyList[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x12 + } + } if x.Params != nil { encoded, err := options.Marshal(x.Params) if err != nil { @@ -414,6 +518,40 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field RelayMiningDifficultyList", wireType) + } + var msglen int + 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++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + 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.RelayMiningDifficultyList = append(x.RelayMiningDifficultyList, &RelayMiningDifficulty{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.RelayMiningDifficultyList[len(x.RelayMiningDifficultyList)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -469,7 +607,8 @@ type GenesisState struct { unknownFields protoimpl.UnknownFields // params defines all the parameters of the module. - Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` + Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` + RelayMiningDifficultyList []*RelayMiningDifficulty `protobuf:"bytes,2,rep,name=relayMiningDifficultyList,proto3" json:"relayMiningDifficultyList,omitempty"` } func (x *GenesisState) Reset() { @@ -499,6 +638,13 @@ func (x *GenesisState) GetParams() *Params { return nil } +func (x *GenesisState) GetRelayMiningDifficultyList() []*RelayMiningDifficulty { + if x != nil { + return x.RelayMiningDifficultyList + } + return nil +} + var File_poktroll_tokenomics_genesis_proto protoreflect.FileDescriptor var file_poktroll_tokenomics_genesis_proto_rawDesc = []byte{ @@ -510,24 +656,34 @@ var file_poktroll_tokenomics_genesis_proto_rawDesc = []byte{ 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0x4e, 0x0a, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x12, 0x3e, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, - 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, - 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x70, 0x61, 0x72, - 0x61, 0x6d, 0x73, 0x42, 0xba, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, - 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x42, - 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x24, 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, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xa2, 0x02, 0x03, 0x50, 0x54, 0x58, 0xaa, 0x02, 0x13, 0x50, 0x6f, - 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, - 0x73, 0xca, 0x02, 0x13, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x54, 0x6f, 0x6b, - 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xe2, 0x02, 0x1f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, - 0x6c, 0x6c, 0x5c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x5c, 0x47, 0x50, - 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x50, 0x6f, 0x6b, 0x74, - 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x74, 0x6f, 0x1a, 0x31, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x74, 0x6f, + 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x5f, 0x6d, + 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbe, 0x01, 0x0a, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, + 0x69, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x3e, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, + 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2e, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, + 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x6e, 0x0a, 0x19, 0x72, 0x65, 0x6c, 0x61, 0x79, + 0x4d, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, + 0x4c, 0x69, 0x73, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x70, 0x6f, 0x6b, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, + 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, + 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x19, 0x72, 0x65, + 0x6c, 0x61, 0x79, 0x4d, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, + 0x6c, 0x74, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x42, 0xba, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, + 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, + 0x69, 0x63, 0x73, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, + 0x6f, 0x50, 0x01, 0x5a, 0x24, 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, 0x74, + 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xa2, 0x02, 0x03, 0x50, 0x54, 0x58, 0xaa, + 0x02, 0x13, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, + 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xca, 0x02, 0x13, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x5c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xe2, 0x02, 0x1f, 0x50, 0x6f, + 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, + 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, + 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, + 0x6d, 0x69, 0x63, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -544,16 +700,18 @@ func file_poktroll_tokenomics_genesis_proto_rawDescGZIP() []byte { var file_poktroll_tokenomics_genesis_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_poktroll_tokenomics_genesis_proto_goTypes = []interface{}{ - (*GenesisState)(nil), // 0: poktroll.tokenomics.GenesisState - (*Params)(nil), // 1: poktroll.tokenomics.Params + (*GenesisState)(nil), // 0: poktroll.tokenomics.GenesisState + (*Params)(nil), // 1: poktroll.tokenomics.Params + (*RelayMiningDifficulty)(nil), // 2: poktroll.tokenomics.RelayMiningDifficulty } var file_poktroll_tokenomics_genesis_proto_depIdxs = []int32{ 1, // 0: poktroll.tokenomics.GenesisState.params:type_name -> poktroll.tokenomics.Params - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 2, // 1: poktroll.tokenomics.GenesisState.relayMiningDifficultyList:type_name -> poktroll.tokenomics.RelayMiningDifficulty + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_poktroll_tokenomics_genesis_proto_init() } @@ -562,6 +720,7 @@ func file_poktroll_tokenomics_genesis_proto_init() { return } file_poktroll_tokenomics_params_proto_init() + file_poktroll_tokenomics_relay_mining_difficulty_proto_init() if !protoimpl.UnsafeEnabled { file_poktroll_tokenomics_genesis_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GenesisState); i { diff --git a/api/poktroll/tokenomics/query.pulsar.go b/api/poktroll/tokenomics/query.pulsar.go index e55219bc1..b3abf4133 100644 --- a/api/poktroll/tokenomics/query.pulsar.go +++ b/api/poktroll/tokenomics/query.pulsar.go @@ -3,7 +3,10 @@ package tokenomics import ( _ "cosmossdk.io/api/amino" + v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" + _ "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" + _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" @@ -806,6 +809,1869 @@ func (x *fastReflection_QueryParamsResponse) ProtoMethods() *protoiface.Methods } } +var ( + md_QueryGetRelayMiningDifficultyRequest protoreflect.MessageDescriptor + fd_QueryGetRelayMiningDifficultyRequest_serviceId protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_tokenomics_query_proto_init() + md_QueryGetRelayMiningDifficultyRequest = File_poktroll_tokenomics_query_proto.Messages().ByName("QueryGetRelayMiningDifficultyRequest") + fd_QueryGetRelayMiningDifficultyRequest_serviceId = md_QueryGetRelayMiningDifficultyRequest.Fields().ByName("serviceId") +} + +var _ protoreflect.Message = (*fastReflection_QueryGetRelayMiningDifficultyRequest)(nil) + +type fastReflection_QueryGetRelayMiningDifficultyRequest QueryGetRelayMiningDifficultyRequest + +func (x *QueryGetRelayMiningDifficultyRequest) ProtoReflect() protoreflect.Message { + return (*fastReflection_QueryGetRelayMiningDifficultyRequest)(x) +} + +func (x *QueryGetRelayMiningDifficultyRequest) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_tokenomics_query_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_QueryGetRelayMiningDifficultyRequest_messageType fastReflection_QueryGetRelayMiningDifficultyRequest_messageType +var _ protoreflect.MessageType = fastReflection_QueryGetRelayMiningDifficultyRequest_messageType{} + +type fastReflection_QueryGetRelayMiningDifficultyRequest_messageType struct{} + +func (x fastReflection_QueryGetRelayMiningDifficultyRequest_messageType) Zero() protoreflect.Message { + return (*fastReflection_QueryGetRelayMiningDifficultyRequest)(nil) +} +func (x fastReflection_QueryGetRelayMiningDifficultyRequest_messageType) New() protoreflect.Message { + return new(fastReflection_QueryGetRelayMiningDifficultyRequest) +} +func (x fastReflection_QueryGetRelayMiningDifficultyRequest_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_QueryGetRelayMiningDifficultyRequest +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_QueryGetRelayMiningDifficultyRequest) Descriptor() protoreflect.MessageDescriptor { + return md_QueryGetRelayMiningDifficultyRequest +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_QueryGetRelayMiningDifficultyRequest) Type() protoreflect.MessageType { + return _fastReflection_QueryGetRelayMiningDifficultyRequest_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_QueryGetRelayMiningDifficultyRequest) New() protoreflect.Message { + return new(fastReflection_QueryGetRelayMiningDifficultyRequest) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_QueryGetRelayMiningDifficultyRequest) Interface() protoreflect.ProtoMessage { + return (*QueryGetRelayMiningDifficultyRequest)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_QueryGetRelayMiningDifficultyRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.ServiceId != "" { + value := protoreflect.ValueOfString(x.ServiceId) + if !f(fd_QueryGetRelayMiningDifficultyRequest_serviceId, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_QueryGetRelayMiningDifficultyRequest) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest.serviceId": + return x.ServiceId != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryGetRelayMiningDifficultyRequest) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest.serviceId": + x.ServiceId = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_QueryGetRelayMiningDifficultyRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest.serviceId": + value := x.ServiceId + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryGetRelayMiningDifficultyRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest.serviceId": + x.ServiceId = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryGetRelayMiningDifficultyRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest.serviceId": + panic(fmt.Errorf("field serviceId of message poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_QueryGetRelayMiningDifficultyRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest.serviceId": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_QueryGetRelayMiningDifficultyRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_QueryGetRelayMiningDifficultyRequest) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryGetRelayMiningDifficultyRequest) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_QueryGetRelayMiningDifficultyRequest) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_QueryGetRelayMiningDifficultyRequest) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*QueryGetRelayMiningDifficultyRequest) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.ServiceId) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*QueryGetRelayMiningDifficultyRequest) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.ServiceId) > 0 { + i -= len(x.ServiceId) + copy(dAtA[i:], x.ServiceId) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ServiceId))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*QueryGetRelayMiningDifficultyRequest) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire 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++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryGetRelayMiningDifficultyRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryGetRelayMiningDifficultyRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ServiceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.ServiceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_QueryGetRelayMiningDifficultyResponse protoreflect.MessageDescriptor + fd_QueryGetRelayMiningDifficultyResponse_relayMiningDifficulty protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_tokenomics_query_proto_init() + md_QueryGetRelayMiningDifficultyResponse = File_poktroll_tokenomics_query_proto.Messages().ByName("QueryGetRelayMiningDifficultyResponse") + fd_QueryGetRelayMiningDifficultyResponse_relayMiningDifficulty = md_QueryGetRelayMiningDifficultyResponse.Fields().ByName("relayMiningDifficulty") +} + +var _ protoreflect.Message = (*fastReflection_QueryGetRelayMiningDifficultyResponse)(nil) + +type fastReflection_QueryGetRelayMiningDifficultyResponse QueryGetRelayMiningDifficultyResponse + +func (x *QueryGetRelayMiningDifficultyResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_QueryGetRelayMiningDifficultyResponse)(x) +} + +func (x *QueryGetRelayMiningDifficultyResponse) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_tokenomics_query_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_QueryGetRelayMiningDifficultyResponse_messageType fastReflection_QueryGetRelayMiningDifficultyResponse_messageType +var _ protoreflect.MessageType = fastReflection_QueryGetRelayMiningDifficultyResponse_messageType{} + +type fastReflection_QueryGetRelayMiningDifficultyResponse_messageType struct{} + +func (x fastReflection_QueryGetRelayMiningDifficultyResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_QueryGetRelayMiningDifficultyResponse)(nil) +} +func (x fastReflection_QueryGetRelayMiningDifficultyResponse_messageType) New() protoreflect.Message { + return new(fastReflection_QueryGetRelayMiningDifficultyResponse) +} +func (x fastReflection_QueryGetRelayMiningDifficultyResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_QueryGetRelayMiningDifficultyResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_QueryGetRelayMiningDifficultyResponse) Descriptor() protoreflect.MessageDescriptor { + return md_QueryGetRelayMiningDifficultyResponse +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_QueryGetRelayMiningDifficultyResponse) Type() protoreflect.MessageType { + return _fastReflection_QueryGetRelayMiningDifficultyResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_QueryGetRelayMiningDifficultyResponse) New() protoreflect.Message { + return new(fastReflection_QueryGetRelayMiningDifficultyResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_QueryGetRelayMiningDifficultyResponse) Interface() protoreflect.ProtoMessage { + return (*QueryGetRelayMiningDifficultyResponse)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_QueryGetRelayMiningDifficultyResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.RelayMiningDifficulty != nil { + value := protoreflect.ValueOfMessage(x.RelayMiningDifficulty.ProtoReflect()) + if !f(fd_QueryGetRelayMiningDifficultyResponse_relayMiningDifficulty, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_QueryGetRelayMiningDifficultyResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse.relayMiningDifficulty": + return x.RelayMiningDifficulty != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryGetRelayMiningDifficultyResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse.relayMiningDifficulty": + x.RelayMiningDifficulty = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_QueryGetRelayMiningDifficultyResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse.relayMiningDifficulty": + value := x.RelayMiningDifficulty + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryGetRelayMiningDifficultyResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse.relayMiningDifficulty": + x.RelayMiningDifficulty = value.Message().Interface().(*RelayMiningDifficulty) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryGetRelayMiningDifficultyResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse.relayMiningDifficulty": + if x.RelayMiningDifficulty == nil { + x.RelayMiningDifficulty = new(RelayMiningDifficulty) + } + return protoreflect.ValueOfMessage(x.RelayMiningDifficulty.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_QueryGetRelayMiningDifficultyResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse.relayMiningDifficulty": + m := new(RelayMiningDifficulty) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_QueryGetRelayMiningDifficultyResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_QueryGetRelayMiningDifficultyResponse) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryGetRelayMiningDifficultyResponse) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_QueryGetRelayMiningDifficultyResponse) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_QueryGetRelayMiningDifficultyResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*QueryGetRelayMiningDifficultyResponse) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.RelayMiningDifficulty != nil { + l = options.Size(x.RelayMiningDifficulty) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*QueryGetRelayMiningDifficultyResponse) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.RelayMiningDifficulty != nil { + encoded, err := options.Marshal(x.RelayMiningDifficulty) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*QueryGetRelayMiningDifficultyResponse) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire 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++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryGetRelayMiningDifficultyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryGetRelayMiningDifficultyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field RelayMiningDifficulty", wireType) + } + var msglen int + 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++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.RelayMiningDifficulty == nil { + x.RelayMiningDifficulty = &RelayMiningDifficulty{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.RelayMiningDifficulty); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_QueryAllRelayMiningDifficultyRequest protoreflect.MessageDescriptor + fd_QueryAllRelayMiningDifficultyRequest_pagination protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_tokenomics_query_proto_init() + md_QueryAllRelayMiningDifficultyRequest = File_poktroll_tokenomics_query_proto.Messages().ByName("QueryAllRelayMiningDifficultyRequest") + fd_QueryAllRelayMiningDifficultyRequest_pagination = md_QueryAllRelayMiningDifficultyRequest.Fields().ByName("pagination") +} + +var _ protoreflect.Message = (*fastReflection_QueryAllRelayMiningDifficultyRequest)(nil) + +type fastReflection_QueryAllRelayMiningDifficultyRequest QueryAllRelayMiningDifficultyRequest + +func (x *QueryAllRelayMiningDifficultyRequest) ProtoReflect() protoreflect.Message { + return (*fastReflection_QueryAllRelayMiningDifficultyRequest)(x) +} + +func (x *QueryAllRelayMiningDifficultyRequest) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_tokenomics_query_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_QueryAllRelayMiningDifficultyRequest_messageType fastReflection_QueryAllRelayMiningDifficultyRequest_messageType +var _ protoreflect.MessageType = fastReflection_QueryAllRelayMiningDifficultyRequest_messageType{} + +type fastReflection_QueryAllRelayMiningDifficultyRequest_messageType struct{} + +func (x fastReflection_QueryAllRelayMiningDifficultyRequest_messageType) Zero() protoreflect.Message { + return (*fastReflection_QueryAllRelayMiningDifficultyRequest)(nil) +} +func (x fastReflection_QueryAllRelayMiningDifficultyRequest_messageType) New() protoreflect.Message { + return new(fastReflection_QueryAllRelayMiningDifficultyRequest) +} +func (x fastReflection_QueryAllRelayMiningDifficultyRequest_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_QueryAllRelayMiningDifficultyRequest +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_QueryAllRelayMiningDifficultyRequest) Descriptor() protoreflect.MessageDescriptor { + return md_QueryAllRelayMiningDifficultyRequest +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_QueryAllRelayMiningDifficultyRequest) Type() protoreflect.MessageType { + return _fastReflection_QueryAllRelayMiningDifficultyRequest_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_QueryAllRelayMiningDifficultyRequest) New() protoreflect.Message { + return new(fastReflection_QueryAllRelayMiningDifficultyRequest) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_QueryAllRelayMiningDifficultyRequest) Interface() protoreflect.ProtoMessage { + return (*QueryAllRelayMiningDifficultyRequest)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_QueryAllRelayMiningDifficultyRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Pagination != nil { + value := protoreflect.ValueOfMessage(x.Pagination.ProtoReflect()) + if !f(fd_QueryAllRelayMiningDifficultyRequest_pagination, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_QueryAllRelayMiningDifficultyRequest) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest.pagination": + return x.Pagination != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryAllRelayMiningDifficultyRequest) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest.pagination": + x.Pagination = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_QueryAllRelayMiningDifficultyRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest.pagination": + value := x.Pagination + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryAllRelayMiningDifficultyRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest.pagination": + x.Pagination = value.Message().Interface().(*v1beta1.PageRequest) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryAllRelayMiningDifficultyRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest.pagination": + if x.Pagination == nil { + x.Pagination = new(v1beta1.PageRequest) + } + return protoreflect.ValueOfMessage(x.Pagination.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_QueryAllRelayMiningDifficultyRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest.pagination": + m := new(v1beta1.PageRequest) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_QueryAllRelayMiningDifficultyRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_QueryAllRelayMiningDifficultyRequest) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryAllRelayMiningDifficultyRequest) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_QueryAllRelayMiningDifficultyRequest) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_QueryAllRelayMiningDifficultyRequest) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*QueryAllRelayMiningDifficultyRequest) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.Pagination != nil { + l = options.Size(x.Pagination) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*QueryAllRelayMiningDifficultyRequest) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Pagination != nil { + encoded, err := options.Marshal(x.Pagination) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*QueryAllRelayMiningDifficultyRequest) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire 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++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryAllRelayMiningDifficultyRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryAllRelayMiningDifficultyRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + 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++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Pagination == nil { + x.Pagination = &v1beta1.PageRequest{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Pagination); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var _ protoreflect.List = (*_QueryAllRelayMiningDifficultyResponse_1_list)(nil) + +type _QueryAllRelayMiningDifficultyResponse_1_list struct { + list *[]*RelayMiningDifficulty +} + +func (x *_QueryAllRelayMiningDifficultyResponse_1_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_QueryAllRelayMiningDifficultyResponse_1_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_QueryAllRelayMiningDifficultyResponse_1_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*RelayMiningDifficulty) + (*x.list)[i] = concreteValue +} + +func (x *_QueryAllRelayMiningDifficultyResponse_1_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*RelayMiningDifficulty) + *x.list = append(*x.list, concreteValue) +} + +func (x *_QueryAllRelayMiningDifficultyResponse_1_list) AppendMutable() protoreflect.Value { + v := new(RelayMiningDifficulty) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_QueryAllRelayMiningDifficultyResponse_1_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_QueryAllRelayMiningDifficultyResponse_1_list) NewElement() protoreflect.Value { + v := new(RelayMiningDifficulty) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_QueryAllRelayMiningDifficultyResponse_1_list) IsValid() bool { + return x.list != nil +} + +var ( + md_QueryAllRelayMiningDifficultyResponse protoreflect.MessageDescriptor + fd_QueryAllRelayMiningDifficultyResponse_relayMiningDifficulty protoreflect.FieldDescriptor + fd_QueryAllRelayMiningDifficultyResponse_pagination protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_tokenomics_query_proto_init() + md_QueryAllRelayMiningDifficultyResponse = File_poktroll_tokenomics_query_proto.Messages().ByName("QueryAllRelayMiningDifficultyResponse") + fd_QueryAllRelayMiningDifficultyResponse_relayMiningDifficulty = md_QueryAllRelayMiningDifficultyResponse.Fields().ByName("relayMiningDifficulty") + fd_QueryAllRelayMiningDifficultyResponse_pagination = md_QueryAllRelayMiningDifficultyResponse.Fields().ByName("pagination") +} + +var _ protoreflect.Message = (*fastReflection_QueryAllRelayMiningDifficultyResponse)(nil) + +type fastReflection_QueryAllRelayMiningDifficultyResponse QueryAllRelayMiningDifficultyResponse + +func (x *QueryAllRelayMiningDifficultyResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_QueryAllRelayMiningDifficultyResponse)(x) +} + +func (x *QueryAllRelayMiningDifficultyResponse) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_tokenomics_query_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_QueryAllRelayMiningDifficultyResponse_messageType fastReflection_QueryAllRelayMiningDifficultyResponse_messageType +var _ protoreflect.MessageType = fastReflection_QueryAllRelayMiningDifficultyResponse_messageType{} + +type fastReflection_QueryAllRelayMiningDifficultyResponse_messageType struct{} + +func (x fastReflection_QueryAllRelayMiningDifficultyResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_QueryAllRelayMiningDifficultyResponse)(nil) +} +func (x fastReflection_QueryAllRelayMiningDifficultyResponse_messageType) New() protoreflect.Message { + return new(fastReflection_QueryAllRelayMiningDifficultyResponse) +} +func (x fastReflection_QueryAllRelayMiningDifficultyResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_QueryAllRelayMiningDifficultyResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_QueryAllRelayMiningDifficultyResponse) Descriptor() protoreflect.MessageDescriptor { + return md_QueryAllRelayMiningDifficultyResponse +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_QueryAllRelayMiningDifficultyResponse) Type() protoreflect.MessageType { + return _fastReflection_QueryAllRelayMiningDifficultyResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_QueryAllRelayMiningDifficultyResponse) New() protoreflect.Message { + return new(fastReflection_QueryAllRelayMiningDifficultyResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_QueryAllRelayMiningDifficultyResponse) Interface() protoreflect.ProtoMessage { + return (*QueryAllRelayMiningDifficultyResponse)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_QueryAllRelayMiningDifficultyResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.RelayMiningDifficulty) != 0 { + value := protoreflect.ValueOfList(&_QueryAllRelayMiningDifficultyResponse_1_list{list: &x.RelayMiningDifficulty}) + if !f(fd_QueryAllRelayMiningDifficultyResponse_relayMiningDifficulty, value) { + return + } + } + if x.Pagination != nil { + value := protoreflect.ValueOfMessage(x.Pagination.ProtoReflect()) + if !f(fd_QueryAllRelayMiningDifficultyResponse_pagination, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_QueryAllRelayMiningDifficultyResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse.relayMiningDifficulty": + return len(x.RelayMiningDifficulty) != 0 + case "poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse.pagination": + return x.Pagination != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryAllRelayMiningDifficultyResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse.relayMiningDifficulty": + x.RelayMiningDifficulty = nil + case "poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse.pagination": + x.Pagination = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_QueryAllRelayMiningDifficultyResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse.relayMiningDifficulty": + if len(x.RelayMiningDifficulty) == 0 { + return protoreflect.ValueOfList(&_QueryAllRelayMiningDifficultyResponse_1_list{}) + } + listValue := &_QueryAllRelayMiningDifficultyResponse_1_list{list: &x.RelayMiningDifficulty} + return protoreflect.ValueOfList(listValue) + case "poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse.pagination": + value := x.Pagination + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryAllRelayMiningDifficultyResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse.relayMiningDifficulty": + lv := value.List() + clv := lv.(*_QueryAllRelayMiningDifficultyResponse_1_list) + x.RelayMiningDifficulty = *clv.list + case "poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse.pagination": + x.Pagination = value.Message().Interface().(*v1beta1.PageResponse) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryAllRelayMiningDifficultyResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse.relayMiningDifficulty": + if x.RelayMiningDifficulty == nil { + x.RelayMiningDifficulty = []*RelayMiningDifficulty{} + } + value := &_QueryAllRelayMiningDifficultyResponse_1_list{list: &x.RelayMiningDifficulty} + return protoreflect.ValueOfList(value) + case "poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse.pagination": + if x.Pagination == nil { + x.Pagination = new(v1beta1.PageResponse) + } + return protoreflect.ValueOfMessage(x.Pagination.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_QueryAllRelayMiningDifficultyResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse.relayMiningDifficulty": + list := []*RelayMiningDifficulty{} + return protoreflect.ValueOfList(&_QueryAllRelayMiningDifficultyResponse_1_list{list: &list}) + case "poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse.pagination": + m := new(v1beta1.PageResponse) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse")) + } + panic(fmt.Errorf("message poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_QueryAllRelayMiningDifficultyResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_QueryAllRelayMiningDifficultyResponse) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryAllRelayMiningDifficultyResponse) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_QueryAllRelayMiningDifficultyResponse) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_QueryAllRelayMiningDifficultyResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*QueryAllRelayMiningDifficultyResponse) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if len(x.RelayMiningDifficulty) > 0 { + for _, e := range x.RelayMiningDifficulty { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if x.Pagination != nil { + l = options.Size(x.Pagination) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*QueryAllRelayMiningDifficultyResponse) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Pagination != nil { + encoded, err := options.Marshal(x.Pagination) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x12 + } + if len(x.RelayMiningDifficulty) > 0 { + for iNdEx := len(x.RelayMiningDifficulty) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.RelayMiningDifficulty[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0xa + } + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*QueryAllRelayMiningDifficultyResponse) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire 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++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryAllRelayMiningDifficultyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryAllRelayMiningDifficultyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field RelayMiningDifficulty", wireType) + } + var msglen int + 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++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + 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.RelayMiningDifficulty = append(x.RelayMiningDifficulty, &RelayMiningDifficulty{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.RelayMiningDifficulty[len(x.RelayMiningDifficulty)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + 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++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Pagination == nil { + x.Pagination = &v1beta1.PageResponse{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Pagination); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.0 @@ -883,6 +2749,154 @@ func (x *QueryParamsResponse) GetParams() *Params { return nil } +type QueryGetRelayMiningDifficultyRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ServiceId string `protobuf:"bytes,1,opt,name=serviceId,proto3" json:"serviceId,omitempty"` +} + +func (x *QueryGetRelayMiningDifficultyRequest) Reset() { + *x = QueryGetRelayMiningDifficultyRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_tokenomics_query_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryGetRelayMiningDifficultyRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryGetRelayMiningDifficultyRequest) ProtoMessage() {} + +// Deprecated: Use QueryGetRelayMiningDifficultyRequest.ProtoReflect.Descriptor instead. +func (*QueryGetRelayMiningDifficultyRequest) Descriptor() ([]byte, []int) { + return file_poktroll_tokenomics_query_proto_rawDescGZIP(), []int{2} +} + +func (x *QueryGetRelayMiningDifficultyRequest) GetServiceId() string { + if x != nil { + return x.ServiceId + } + return "" +} + +type QueryGetRelayMiningDifficultyResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RelayMiningDifficulty *RelayMiningDifficulty `protobuf:"bytes,1,opt,name=relayMiningDifficulty,proto3" json:"relayMiningDifficulty,omitempty"` +} + +func (x *QueryGetRelayMiningDifficultyResponse) Reset() { + *x = QueryGetRelayMiningDifficultyResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_tokenomics_query_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryGetRelayMiningDifficultyResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryGetRelayMiningDifficultyResponse) ProtoMessage() {} + +// Deprecated: Use QueryGetRelayMiningDifficultyResponse.ProtoReflect.Descriptor instead. +func (*QueryGetRelayMiningDifficultyResponse) Descriptor() ([]byte, []int) { + return file_poktroll_tokenomics_query_proto_rawDescGZIP(), []int{3} +} + +func (x *QueryGetRelayMiningDifficultyResponse) GetRelayMiningDifficulty() *RelayMiningDifficulty { + if x != nil { + return x.RelayMiningDifficulty + } + return nil +} + +type QueryAllRelayMiningDifficultyRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Pagination *v1beta1.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (x *QueryAllRelayMiningDifficultyRequest) Reset() { + *x = QueryAllRelayMiningDifficultyRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_tokenomics_query_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryAllRelayMiningDifficultyRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryAllRelayMiningDifficultyRequest) ProtoMessage() {} + +// Deprecated: Use QueryAllRelayMiningDifficultyRequest.ProtoReflect.Descriptor instead. +func (*QueryAllRelayMiningDifficultyRequest) Descriptor() ([]byte, []int) { + return file_poktroll_tokenomics_query_proto_rawDescGZIP(), []int{4} +} + +func (x *QueryAllRelayMiningDifficultyRequest) GetPagination() *v1beta1.PageRequest { + if x != nil { + return x.Pagination + } + return nil +} + +type QueryAllRelayMiningDifficultyResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RelayMiningDifficulty []*RelayMiningDifficulty `protobuf:"bytes,1,rep,name=relayMiningDifficulty,proto3" json:"relayMiningDifficulty,omitempty"` + Pagination *v1beta1.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (x *QueryAllRelayMiningDifficultyResponse) Reset() { + *x = QueryAllRelayMiningDifficultyResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_tokenomics_query_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryAllRelayMiningDifficultyResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryAllRelayMiningDifficultyResponse) ProtoMessage() {} + +// Deprecated: Use QueryAllRelayMiningDifficultyResponse.ProtoReflect.Descriptor instead. +func (*QueryAllRelayMiningDifficultyResponse) Descriptor() ([]byte, []int) { + return file_poktroll_tokenomics_query_proto_rawDescGZIP(), []int{5} +} + +func (x *QueryAllRelayMiningDifficultyResponse) GetRelayMiningDifficulty() []*RelayMiningDifficulty { + if x != nil { + return x.RelayMiningDifficulty + } + return nil +} + +func (x *QueryAllRelayMiningDifficultyResponse) GetPagination() *v1beta1.PageResponse { + if x != nil { + return x.Pagination + } + return nil +} + var File_poktroll_tokenomics_query_proto protoreflect.FileDescriptor var file_poktroll_tokenomics_query_proto_rawDesc = []byte{ @@ -893,38 +2907,109 @@ var file_poktroll_tokenomics_query_proto_rawDesc = []byte{ 0x69, 0x6e, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, - 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x70, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, - 0x63, 0x73, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0x14, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x55, 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, - 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x06, - 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, - 0x63, 0x73, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, - 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x32, 0x97, 0x01, 0x0a, - 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x8d, 0x01, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x12, 0x27, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, - 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, - 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x70, 0x6f, 0x6b, - 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, - 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x30, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2a, 0x12, 0x28, 0x2f, 0x70, + 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x2f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x63, 0x6f, 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, 0x20, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x74, + 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x31, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x2f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2f, 0x72, 0x65, 0x6c, 0x61, + 0x79, 0x5f, 0x6d, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, + 0x6c, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x14, 0x0a, 0x12, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, + 0x55, 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2e, 0x50, 0x61, 0x72, + 0x61, 0x6d, 0x73, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x44, 0x0a, 0x24, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, + 0x65, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, + 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, + 0x0a, 0x09, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x22, 0x8f, 0x01, 0x0a, + 0x25, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x69, + 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x66, 0x0a, 0x15, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x4d, + 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2e, 0x52, 0x65, 0x6c, 0x61, + 0x79, 0x4d, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, + 0x79, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x15, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x69, + 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x22, 0x6e, + 0x0a, 0x24, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x4d, + 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x46, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xd8, + 0x01, 0x0a, 0x25, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x61, 0x79, + 0x4d, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x66, 0x0a, 0x15, 0x72, 0x65, 0x6c, 0x61, + 0x79, 0x4d, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, + 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2e, 0x52, 0x65, + 0x6c, 0x61, 0x79, 0x4d, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, + 0x6c, 0x74, 0x79, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x15, 0x72, 0x65, 0x6c, 0x61, 0x79, + 0x4d, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, + 0x12, 0x47, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, + 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0a, 0x70, + 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0xce, 0x04, 0x0a, 0x05, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x12, 0x8d, 0x01, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x27, + 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, + 0x6d, 0x69, 0x63, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2e, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x30, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2a, 0x12, 0x28, 0x2f, 0x70, 0x6f, 0x6b, 0x74, + 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x2f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2f, 0x70, 0x61, 0x72, + 0x61, 0x6d, 0x73, 0x12, 0xdd, 0x01, 0x0a, 0x15, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x69, 0x6e, + 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x12, 0x39, 0x2e, + 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, + 0x69, 0x63, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x52, 0x65, 0x6c, 0x61, + 0x79, 0x4d, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, + 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3a, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2e, 0x51, + 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x69, 0x6e, 0x69, + 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x4d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x47, 0x12, 0x45, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2f, - 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xb8, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x70, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, - 0x63, 0x73, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x24, 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, 0x74, 0x6f, 0x6b, 0x65, - 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xa2, 0x02, 0x03, 0x50, 0x54, 0x58, 0xaa, 0x02, 0x13, 0x50, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, - 0x63, 0x73, 0xca, 0x02, 0x13, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x54, 0x6f, - 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xe2, 0x02, 0x1f, 0x50, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x5c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x5c, 0x47, - 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x50, 0x6f, 0x6b, - 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, - 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x65, 0x6c, 0x61, 0x79, 0x5f, 0x6d, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x69, 0x66, + 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x2f, 0x7b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x49, 0x64, 0x7d, 0x12, 0xd4, 0x01, 0x0a, 0x18, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x69, 0x6e, + 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x41, 0x6c, 0x6c, + 0x12, 0x39, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, + 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x52, + 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, + 0x75, 0x6c, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3a, 0x2e, 0x70, 0x6f, + 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, + 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x4d, + 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x41, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x3b, 0x12, + 0x39, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, + 0x63, 0x73, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x5f, 0x6d, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x5f, + 0x64, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x42, 0xb8, 0x01, 0x0a, 0x17, 0x63, + 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, + 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x24, 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, + 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xa2, 0x02, 0x03, 0x50, 0x54, 0x58, + 0xaa, 0x02, 0x13, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x54, 0x6f, 0x6b, 0x65, + 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xca, 0x02, 0x13, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x5c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xe2, 0x02, 0x1f, 0x50, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, + 0x63, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, + 0x14, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x54, 0x6f, 0x6b, 0x65, 0x6e, + 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -939,21 +3024,36 @@ func file_poktroll_tokenomics_query_proto_rawDescGZIP() []byte { return file_poktroll_tokenomics_query_proto_rawDescData } -var file_poktroll_tokenomics_query_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_poktroll_tokenomics_query_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_poktroll_tokenomics_query_proto_goTypes = []interface{}{ - (*QueryParamsRequest)(nil), // 0: poktroll.tokenomics.QueryParamsRequest - (*QueryParamsResponse)(nil), // 1: poktroll.tokenomics.QueryParamsResponse - (*Params)(nil), // 2: poktroll.tokenomics.Params + (*QueryParamsRequest)(nil), // 0: poktroll.tokenomics.QueryParamsRequest + (*QueryParamsResponse)(nil), // 1: poktroll.tokenomics.QueryParamsResponse + (*QueryGetRelayMiningDifficultyRequest)(nil), // 2: poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest + (*QueryGetRelayMiningDifficultyResponse)(nil), // 3: poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse + (*QueryAllRelayMiningDifficultyRequest)(nil), // 4: poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest + (*QueryAllRelayMiningDifficultyResponse)(nil), // 5: poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse + (*Params)(nil), // 6: poktroll.tokenomics.Params + (*RelayMiningDifficulty)(nil), // 7: poktroll.tokenomics.RelayMiningDifficulty + (*v1beta1.PageRequest)(nil), // 8: cosmos.base.query.v1beta1.PageRequest + (*v1beta1.PageResponse)(nil), // 9: cosmos.base.query.v1beta1.PageResponse } var file_poktroll_tokenomics_query_proto_depIdxs = []int32{ - 2, // 0: poktroll.tokenomics.QueryParamsResponse.params:type_name -> poktroll.tokenomics.Params - 0, // 1: poktroll.tokenomics.Query.Params:input_type -> poktroll.tokenomics.QueryParamsRequest - 1, // 2: poktroll.tokenomics.Query.Params:output_type -> poktroll.tokenomics.QueryParamsResponse - 2, // [2:3] is the sub-list for method output_type - 1, // [1:2] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 6, // 0: poktroll.tokenomics.QueryParamsResponse.params:type_name -> poktroll.tokenomics.Params + 7, // 1: poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse.relayMiningDifficulty:type_name -> poktroll.tokenomics.RelayMiningDifficulty + 8, // 2: poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest.pagination:type_name -> cosmos.base.query.v1beta1.PageRequest + 7, // 3: poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse.relayMiningDifficulty:type_name -> poktroll.tokenomics.RelayMiningDifficulty + 9, // 4: poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse.pagination:type_name -> cosmos.base.query.v1beta1.PageResponse + 0, // 5: poktroll.tokenomics.Query.Params:input_type -> poktroll.tokenomics.QueryParamsRequest + 2, // 6: poktroll.tokenomics.Query.RelayMiningDifficulty:input_type -> poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest + 4, // 7: poktroll.tokenomics.Query.RelayMiningDifficultyAll:input_type -> poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest + 1, // 8: poktroll.tokenomics.Query.Params:output_type -> poktroll.tokenomics.QueryParamsResponse + 3, // 9: poktroll.tokenomics.Query.RelayMiningDifficulty:output_type -> poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse + 5, // 10: poktroll.tokenomics.Query.RelayMiningDifficultyAll:output_type -> poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse + 8, // [8:11] is the sub-list for method output_type + 5, // [5:8] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_poktroll_tokenomics_query_proto_init() } @@ -962,6 +3062,7 @@ func file_poktroll_tokenomics_query_proto_init() { return } file_poktroll_tokenomics_params_proto_init() + file_poktroll_tokenomics_relay_mining_difficulty_proto_init() if !protoimpl.UnsafeEnabled { file_poktroll_tokenomics_query_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*QueryParamsRequest); i { @@ -987,6 +3088,54 @@ func file_poktroll_tokenomics_query_proto_init() { return nil } } + file_poktroll_tokenomics_query_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryGetRelayMiningDifficultyRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_poktroll_tokenomics_query_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryGetRelayMiningDifficultyResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_poktroll_tokenomics_query_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryAllRelayMiningDifficultyRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_poktroll_tokenomics_query_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryAllRelayMiningDifficultyResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -994,7 +3143,7 @@ func file_poktroll_tokenomics_query_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_poktroll_tokenomics_query_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 6, NumExtensions: 0, NumServices: 1, }, diff --git a/api/poktroll/tokenomics/query_grpc.pb.go b/api/poktroll/tokenomics/query_grpc.pb.go index deecd528b..fb5c4bc7c 100644 --- a/api/poktroll/tokenomics/query_grpc.pb.go +++ b/api/poktroll/tokenomics/query_grpc.pb.go @@ -19,7 +19,9 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - Query_Params_FullMethodName = "/poktroll.tokenomics.Query/Params" + Query_Params_FullMethodName = "/poktroll.tokenomics.Query/Params" + Query_RelayMiningDifficulty_FullMethodName = "/poktroll.tokenomics.Query/RelayMiningDifficulty" + Query_RelayMiningDifficultyAll_FullMethodName = "/poktroll.tokenomics.Query/RelayMiningDifficultyAll" ) // QueryClient is the client API for Query service. @@ -28,6 +30,9 @@ const ( type QueryClient interface { // Parameters queries the parameters of the module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Queries a list of RelayMiningDifficulty items. + RelayMiningDifficulty(ctx context.Context, in *QueryGetRelayMiningDifficultyRequest, opts ...grpc.CallOption) (*QueryGetRelayMiningDifficultyResponse, error) + RelayMiningDifficultyAll(ctx context.Context, in *QueryAllRelayMiningDifficultyRequest, opts ...grpc.CallOption) (*QueryAllRelayMiningDifficultyResponse, error) } type queryClient struct { @@ -47,12 +52,33 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } +func (c *queryClient) RelayMiningDifficulty(ctx context.Context, in *QueryGetRelayMiningDifficultyRequest, opts ...grpc.CallOption) (*QueryGetRelayMiningDifficultyResponse, error) { + out := new(QueryGetRelayMiningDifficultyResponse) + err := c.cc.Invoke(ctx, Query_RelayMiningDifficulty_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) RelayMiningDifficultyAll(ctx context.Context, in *QueryAllRelayMiningDifficultyRequest, opts ...grpc.CallOption) (*QueryAllRelayMiningDifficultyResponse, error) { + out := new(QueryAllRelayMiningDifficultyResponse) + err := c.cc.Invoke(ctx, Query_RelayMiningDifficultyAll_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. // All implementations must embed UnimplementedQueryServer // for forward compatibility type QueryServer interface { // Parameters queries the parameters of the module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Queries a list of RelayMiningDifficulty items. + RelayMiningDifficulty(context.Context, *QueryGetRelayMiningDifficultyRequest) (*QueryGetRelayMiningDifficultyResponse, error) + RelayMiningDifficultyAll(context.Context, *QueryAllRelayMiningDifficultyRequest) (*QueryAllRelayMiningDifficultyResponse, error) mustEmbedUnimplementedQueryServer() } @@ -63,6 +89,12 @@ type UnimplementedQueryServer struct { func (UnimplementedQueryServer) Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } +func (UnimplementedQueryServer) RelayMiningDifficulty(context.Context, *QueryGetRelayMiningDifficultyRequest) (*QueryGetRelayMiningDifficultyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RelayMiningDifficulty not implemented") +} +func (UnimplementedQueryServer) RelayMiningDifficultyAll(context.Context, *QueryAllRelayMiningDifficultyRequest) (*QueryAllRelayMiningDifficultyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RelayMiningDifficultyAll not implemented") +} func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {} // UnsafeQueryServer may be embedded to opt out of forward compatibility for this service. @@ -94,6 +126,42 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_RelayMiningDifficulty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetRelayMiningDifficultyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RelayMiningDifficulty(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Query_RelayMiningDifficulty_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RelayMiningDifficulty(ctx, req.(*QueryGetRelayMiningDifficultyRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_RelayMiningDifficultyAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllRelayMiningDifficultyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RelayMiningDifficultyAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Query_RelayMiningDifficultyAll_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RelayMiningDifficultyAll(ctx, req.(*QueryAllRelayMiningDifficultyRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Query_ServiceDesc is the grpc.ServiceDesc for Query service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -105,6 +173,14 @@ var Query_ServiceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, + { + MethodName: "RelayMiningDifficulty", + Handler: _Query_RelayMiningDifficulty_Handler, + }, + { + MethodName: "RelayMiningDifficultyAll", + Handler: _Query_RelayMiningDifficultyAll_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "poktroll/tokenomics/query.proto", diff --git a/api/poktroll/tokenomics/relay_mining_difficulty.pulsar.go b/api/poktroll/tokenomics/relay_mining_difficulty.pulsar.go new file mode 100644 index 000000000..f0c614cda --- /dev/null +++ b/api/poktroll/tokenomics/relay_mining_difficulty.pulsar.go @@ -0,0 +1,774 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package tokenomics + +import ( + fmt "fmt" + runtime "github.com/cosmos/cosmos-proto/runtime" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoiface "google.golang.org/protobuf/runtime/protoiface" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" +) + +var ( + md_RelayMiningDifficulty protoreflect.MessageDescriptor + fd_RelayMiningDifficulty_service_id protoreflect.FieldDescriptor + fd_RelayMiningDifficulty_block_height protoreflect.FieldDescriptor + fd_RelayMiningDifficulty_num_relays_ema protoreflect.FieldDescriptor + fd_RelayMiningDifficulty_target_hash protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_tokenomics_relay_mining_difficulty_proto_init() + md_RelayMiningDifficulty = File_poktroll_tokenomics_relay_mining_difficulty_proto.Messages().ByName("RelayMiningDifficulty") + fd_RelayMiningDifficulty_service_id = md_RelayMiningDifficulty.Fields().ByName("service_id") + fd_RelayMiningDifficulty_block_height = md_RelayMiningDifficulty.Fields().ByName("block_height") + fd_RelayMiningDifficulty_num_relays_ema = md_RelayMiningDifficulty.Fields().ByName("num_relays_ema") + fd_RelayMiningDifficulty_target_hash = md_RelayMiningDifficulty.Fields().ByName("target_hash") +} + +var _ protoreflect.Message = (*fastReflection_RelayMiningDifficulty)(nil) + +type fastReflection_RelayMiningDifficulty RelayMiningDifficulty + +func (x *RelayMiningDifficulty) ProtoReflect() protoreflect.Message { + return (*fastReflection_RelayMiningDifficulty)(x) +} + +func (x *RelayMiningDifficulty) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_tokenomics_relay_mining_difficulty_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_RelayMiningDifficulty_messageType fastReflection_RelayMiningDifficulty_messageType +var _ protoreflect.MessageType = fastReflection_RelayMiningDifficulty_messageType{} + +type fastReflection_RelayMiningDifficulty_messageType struct{} + +func (x fastReflection_RelayMiningDifficulty_messageType) Zero() protoreflect.Message { + return (*fastReflection_RelayMiningDifficulty)(nil) +} +func (x fastReflection_RelayMiningDifficulty_messageType) New() protoreflect.Message { + return new(fastReflection_RelayMiningDifficulty) +} +func (x fastReflection_RelayMiningDifficulty_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_RelayMiningDifficulty +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_RelayMiningDifficulty) Descriptor() protoreflect.MessageDescriptor { + return md_RelayMiningDifficulty +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_RelayMiningDifficulty) Type() protoreflect.MessageType { + return _fastReflection_RelayMiningDifficulty_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_RelayMiningDifficulty) New() protoreflect.Message { + return new(fastReflection_RelayMiningDifficulty) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_RelayMiningDifficulty) Interface() protoreflect.ProtoMessage { + return (*RelayMiningDifficulty)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_RelayMiningDifficulty) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.ServiceId != "" { + value := protoreflect.ValueOfString(x.ServiceId) + if !f(fd_RelayMiningDifficulty_service_id, value) { + return + } + } + if x.BlockHeight != int64(0) { + value := protoreflect.ValueOfInt64(x.BlockHeight) + if !f(fd_RelayMiningDifficulty_block_height, value) { + return + } + } + if x.NumRelaysEma != uint64(0) { + value := protoreflect.ValueOfUint64(x.NumRelaysEma) + if !f(fd_RelayMiningDifficulty_num_relays_ema, value) { + return + } + } + if len(x.TargetHash) != 0 { + value := protoreflect.ValueOfBytes(x.TargetHash) + if !f(fd_RelayMiningDifficulty_target_hash, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_RelayMiningDifficulty) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.tokenomics.RelayMiningDifficulty.service_id": + return x.ServiceId != "" + case "poktroll.tokenomics.RelayMiningDifficulty.block_height": + return x.BlockHeight != int64(0) + case "poktroll.tokenomics.RelayMiningDifficulty.num_relays_ema": + return x.NumRelaysEma != uint64(0) + case "poktroll.tokenomics.RelayMiningDifficulty.target_hash": + return len(x.TargetHash) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.RelayMiningDifficulty")) + } + panic(fmt.Errorf("message poktroll.tokenomics.RelayMiningDifficulty does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_RelayMiningDifficulty) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.tokenomics.RelayMiningDifficulty.service_id": + x.ServiceId = "" + case "poktroll.tokenomics.RelayMiningDifficulty.block_height": + x.BlockHeight = int64(0) + case "poktroll.tokenomics.RelayMiningDifficulty.num_relays_ema": + x.NumRelaysEma = uint64(0) + case "poktroll.tokenomics.RelayMiningDifficulty.target_hash": + x.TargetHash = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.RelayMiningDifficulty")) + } + panic(fmt.Errorf("message poktroll.tokenomics.RelayMiningDifficulty does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_RelayMiningDifficulty) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.tokenomics.RelayMiningDifficulty.service_id": + value := x.ServiceId + return protoreflect.ValueOfString(value) + case "poktroll.tokenomics.RelayMiningDifficulty.block_height": + value := x.BlockHeight + return protoreflect.ValueOfInt64(value) + case "poktroll.tokenomics.RelayMiningDifficulty.num_relays_ema": + value := x.NumRelaysEma + return protoreflect.ValueOfUint64(value) + case "poktroll.tokenomics.RelayMiningDifficulty.target_hash": + value := x.TargetHash + return protoreflect.ValueOfBytes(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.RelayMiningDifficulty")) + } + panic(fmt.Errorf("message poktroll.tokenomics.RelayMiningDifficulty does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_RelayMiningDifficulty) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.tokenomics.RelayMiningDifficulty.service_id": + x.ServiceId = value.Interface().(string) + case "poktroll.tokenomics.RelayMiningDifficulty.block_height": + x.BlockHeight = value.Int() + case "poktroll.tokenomics.RelayMiningDifficulty.num_relays_ema": + x.NumRelaysEma = value.Uint() + case "poktroll.tokenomics.RelayMiningDifficulty.target_hash": + x.TargetHash = value.Bytes() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.RelayMiningDifficulty")) + } + panic(fmt.Errorf("message poktroll.tokenomics.RelayMiningDifficulty does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_RelayMiningDifficulty) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.tokenomics.RelayMiningDifficulty.service_id": + panic(fmt.Errorf("field service_id of message poktroll.tokenomics.RelayMiningDifficulty is not mutable")) + case "poktroll.tokenomics.RelayMiningDifficulty.block_height": + panic(fmt.Errorf("field block_height of message poktroll.tokenomics.RelayMiningDifficulty is not mutable")) + case "poktroll.tokenomics.RelayMiningDifficulty.num_relays_ema": + panic(fmt.Errorf("field num_relays_ema of message poktroll.tokenomics.RelayMiningDifficulty is not mutable")) + case "poktroll.tokenomics.RelayMiningDifficulty.target_hash": + panic(fmt.Errorf("field target_hash of message poktroll.tokenomics.RelayMiningDifficulty is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.RelayMiningDifficulty")) + } + panic(fmt.Errorf("message poktroll.tokenomics.RelayMiningDifficulty does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_RelayMiningDifficulty) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.tokenomics.RelayMiningDifficulty.service_id": + return protoreflect.ValueOfString("") + case "poktroll.tokenomics.RelayMiningDifficulty.block_height": + return protoreflect.ValueOfInt64(int64(0)) + case "poktroll.tokenomics.RelayMiningDifficulty.num_relays_ema": + return protoreflect.ValueOfUint64(uint64(0)) + case "poktroll.tokenomics.RelayMiningDifficulty.target_hash": + return protoreflect.ValueOfBytes(nil) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.RelayMiningDifficulty")) + } + panic(fmt.Errorf("message poktroll.tokenomics.RelayMiningDifficulty does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_RelayMiningDifficulty) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.tokenomics.RelayMiningDifficulty", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_RelayMiningDifficulty) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_RelayMiningDifficulty) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_RelayMiningDifficulty) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_RelayMiningDifficulty) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*RelayMiningDifficulty) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.ServiceId) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.BlockHeight != 0 { + n += 1 + runtime.Sov(uint64(x.BlockHeight)) + } + if x.NumRelaysEma != 0 { + n += 1 + runtime.Sov(uint64(x.NumRelaysEma)) + } + l = len(x.TargetHash) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*RelayMiningDifficulty) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.TargetHash) > 0 { + i -= len(x.TargetHash) + copy(dAtA[i:], x.TargetHash) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.TargetHash))) + i-- + dAtA[i] = 0x22 + } + if x.NumRelaysEma != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.NumRelaysEma)) + i-- + dAtA[i] = 0x18 + } + if x.BlockHeight != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.BlockHeight)) + i-- + dAtA[i] = 0x10 + } + if len(x.ServiceId) > 0 { + i -= len(x.ServiceId) + copy(dAtA[i:], x.ServiceId) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ServiceId))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*RelayMiningDifficulty) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire 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++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: RelayMiningDifficulty: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: RelayMiningDifficulty: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ServiceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.ServiceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) + } + x.BlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.BlockHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field NumRelaysEma", wireType) + } + x.NumRelaysEma = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.NumRelaysEma |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field TargetHash", wireType) + } + var byteLen int + 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++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + 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.TargetHash = append(x.TargetHash[:0], dAtA[iNdEx:postIndex]...) + if x.TargetHash == nil { + x.TargetHash = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: poktroll/tokenomics/relay_mining_difficulty.proto + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// RelayMiningDifficulty is a message used to store the on-chain Relay Mining +// difficulty associated with a specific service ID. +type RelayMiningDifficulty struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The service ID the the relay mining difficulty is associated with. + ServiceId string `protobuf:"bytes,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` + // The block height at which this relay mining difficulty was computed. + // This is needed to determine how much time has passed since the last time + // the exponential moving average was computed. + BlockHeight int64 `protobuf:"varint,2,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + // The exponential moving average of the number of relays for this service. + NumRelaysEma uint64 `protobuf:"varint,3,opt,name=num_relays_ema,json=numRelaysEma,proto3" json:"num_relays_ema,omitempty"` + // The target hash determining the difficulty to mine relays for this service. + // For example, if we use sha256 to hash the (RelayRequest,ReqlayResponse) tuple, + // and the difficulty has 4 leading zero bits, then the target hash would be: + // 0b0000111... (until 32 bytes are filled up). + TargetHash []byte `protobuf:"bytes,4,opt,name=target_hash,json=targetHash,proto3" json:"target_hash,omitempty"` +} + +func (x *RelayMiningDifficulty) Reset() { + *x = RelayMiningDifficulty{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_tokenomics_relay_mining_difficulty_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RelayMiningDifficulty) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RelayMiningDifficulty) ProtoMessage() {} + +// Deprecated: Use RelayMiningDifficulty.ProtoReflect.Descriptor instead. +func (*RelayMiningDifficulty) Descriptor() ([]byte, []int) { + return file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDescGZIP(), []int{0} +} + +func (x *RelayMiningDifficulty) GetServiceId() string { + if x != nil { + return x.ServiceId + } + return "" +} + +func (x *RelayMiningDifficulty) GetBlockHeight() int64 { + if x != nil { + return x.BlockHeight + } + return 0 +} + +func (x *RelayMiningDifficulty) GetNumRelaysEma() uint64 { + if x != nil { + return x.NumRelaysEma + } + return 0 +} + +func (x *RelayMiningDifficulty) GetTargetHash() []byte { + if x != nil { + return x.TargetHash + } + return nil +} + +var File_poktroll_tokenomics_relay_mining_difficulty_proto protoreflect.FileDescriptor + +var file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDesc = []byte{ + 0x0a, 0x31, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, + 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x5f, 0x6d, 0x69, 0x6e, 0x69, + 0x6e, 0x67, 0x5f, 0x64, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x13, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, + 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x22, 0xa0, 0x01, 0x0a, 0x15, 0x52, 0x65, 0x6c, + 0x61, 0x79, 0x4d, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, + 0x74, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, + 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, + 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, + 0x69, 0x67, 0x68, 0x74, 0x12, 0x24, 0x0a, 0x0e, 0x6e, 0x75, 0x6d, 0x5f, 0x72, 0x65, 0x6c, 0x61, + 0x79, 0x73, 0x5f, 0x65, 0x6d, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x6e, 0x75, + 0x6d, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x73, 0x45, 0x6d, 0x61, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x0a, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x48, 0x61, 0x73, 0x68, 0x42, 0xc8, 0x01, 0x0a, 0x17, + 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, + 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x42, 0x1a, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x69, + 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x24, 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, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xa2, 0x02, 0x03, 0x50, 0x54, + 0x58, 0xaa, 0x02, 0x13, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x54, 0x6f, 0x6b, + 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xca, 0x02, 0x13, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x5c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xe2, 0x02, 0x1f, + 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, + 0x69, 0x63, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, + 0x02, 0x14, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x54, 0x6f, 0x6b, 0x65, + 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDescOnce sync.Once + file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDescData = file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDesc +) + +func file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDescGZIP() []byte { + file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDescOnce.Do(func() { + file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDescData = protoimpl.X.CompressGZIP(file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDescData) + }) + return file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDescData +} + +var file_poktroll_tokenomics_relay_mining_difficulty_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_poktroll_tokenomics_relay_mining_difficulty_proto_goTypes = []interface{}{ + (*RelayMiningDifficulty)(nil), // 0: poktroll.tokenomics.RelayMiningDifficulty +} +var file_poktroll_tokenomics_relay_mining_difficulty_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_poktroll_tokenomics_relay_mining_difficulty_proto_init() } +func file_poktroll_tokenomics_relay_mining_difficulty_proto_init() { + if File_poktroll_tokenomics_relay_mining_difficulty_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_poktroll_tokenomics_relay_mining_difficulty_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RelayMiningDifficulty); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_poktroll_tokenomics_relay_mining_difficulty_proto_goTypes, + DependencyIndexes: file_poktroll_tokenomics_relay_mining_difficulty_proto_depIdxs, + MessageInfos: file_poktroll_tokenomics_relay_mining_difficulty_proto_msgTypes, + }.Build() + File_poktroll_tokenomics_relay_mining_difficulty_proto = out.File + file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDesc = nil + file_poktroll_tokenomics_relay_mining_difficulty_proto_goTypes = nil + file_poktroll_tokenomics_relay_mining_difficulty_proto_depIdxs = nil +} diff --git a/proto/poktroll/tokenomics/genesis.proto b/proto/poktroll/tokenomics/genesis.proto index 03f190e28..51a9f4be1 100644 --- a/proto/poktroll/tokenomics/genesis.proto +++ b/proto/poktroll/tokenomics/genesis.proto @@ -1,15 +1,19 @@ syntax = "proto3"; + package poktroll.tokenomics; option go_package = "github.com/pokt-network/poktroll/x/tokenomics/types"; import "amino/amino.proto"; import "gogoproto/gogo.proto"; - import "poktroll/tokenomics/params.proto"; +import "poktroll/tokenomics/relay_mining_difficulty.proto"; // GenesisState defines the tokenomics module's genesis state. message GenesisState { + // params defines all the parameters of the module. - Params params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + Params params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + repeated RelayMiningDifficulty relayMiningDifficultyList = 2 [(gogoproto.nullable) = false] ; } + diff --git a/proto/poktroll/tokenomics/query.proto b/proto/poktroll/tokenomics/query.proto index 9c3df7a62..31b0277ca 100644 --- a/proto/poktroll/tokenomics/query.proto +++ b/proto/poktroll/tokenomics/query.proto @@ -1,4 +1,5 @@ syntax = "proto3"; + package poktroll.tokenomics; option go_package = "github.com/pokt-network/poktroll/x/tokenomics/types"; @@ -6,22 +7,56 @@ option go_package = "github.com/pokt-network/poktroll/x/tokenomics/types"; import "amino/amino.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "cosmos/base/v1beta1/coin.proto"; import "poktroll/tokenomics/params.proto"; +import "poktroll/tokenomics/relay_mining_difficulty.proto"; // Query defines the gRPC querier service. service Query { + // Parameters queries the parameters of the module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + rpc Params (QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/pokt-network/poktroll/tokenomics/params"; + } -} + // Queries a list of RelayMiningDifficulty items. + rpc RelayMiningDifficulty (QueryGetRelayMiningDifficultyRequest) returns (QueryGetRelayMiningDifficultyResponse) { + option (google.api.http).get = "/pokt-network/poktroll/tokenomics/relay_mining_difficulty/{serviceId}"; + + } + rpc RelayMiningDifficultyAll (QueryAllRelayMiningDifficultyRequest) returns (QueryAllRelayMiningDifficultyResponse) { + option (google.api.http).get = "/pokt-network/poktroll/tokenomics/relay_mining_difficulty"; + + } +} // QueryParamsRequest is request type for the Query/Params RPC method. message QueryParamsRequest {} // QueryParamsResponse is response type for the Query/Params RPC method. message QueryParamsResponse { + // params holds all the parameters of this module. Params params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; -} \ No newline at end of file +} + +message QueryGetRelayMiningDifficultyRequest { + string serviceId = 1; +} + +message QueryGetRelayMiningDifficultyResponse { + RelayMiningDifficulty relayMiningDifficulty = 1 [(gogoproto.nullable) = false]; +} + +message QueryAllRelayMiningDifficultyRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +message QueryAllRelayMiningDifficultyResponse { + repeated RelayMiningDifficulty relayMiningDifficulty = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + diff --git a/proto/poktroll/tokenomics/relay_mining_difficulty.proto b/proto/poktroll/tokenomics/relay_mining_difficulty.proto new file mode 100644 index 000000000..599e881ad --- /dev/null +++ b/proto/poktroll/tokenomics/relay_mining_difficulty.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; +package poktroll.tokenomics; + +option go_package = "github.com/pokt-network/poktroll/x/tokenomics/types"; + +// RelayMiningDifficulty is a message used to store the on-chain Relay Mining +// difficulty associated with a specific service ID. +message RelayMiningDifficulty { + // The service ID the the relay mining difficulty is associated with. + string service_id = 1; + + // The block height at which this relay mining difficulty was computed. + // This is needed to determine how much time has passed since the last time + // the exponential moving average was computed. + int64 block_height = 2; + + // The exponential moving average of the number of relays for this service. + uint64 num_relays_ema = 3; + + // The target hash determining the difficulty to mine relays for this service. + // For example, if we use sha256 to hash the (RelayRequest,ReqlayResponse) tuple, + // and the difficulty has 4 leading zero bits, then the target hash would be: + // 0b0000111... (until 32 bytes are filled up). + bytes target_hash = 4; + + // TODO_BLOCKER_BETA(@Olshansk): Add a `hash_algorithm` field either in this + // structure or elsewhere so we can support changing it over time. There should + // be one source of truth, somewhere on chain, to stay in sync with the SMT + // configuration. +} diff --git a/testutil/keeper/tokenomics.go b/testutil/keeper/tokenomics.go index 1ef241ac6..da1ebd131 100644 --- a/testutil/keeper/tokenomics.go +++ b/testutil/keeper/tokenomics.go @@ -65,7 +65,15 @@ type TokenomicsModuleKeepers struct { // and tokenomics keepers during construction of the aggregation. type TokenomicsKeepersOpt func(context.Context, *TokenomicsModuleKeepers) context.Context -func TokenomicsKeeper(t testing.TB) ( +func TokenomicsKeeper(t testing.TB) (tokenomicsKeeper tokenomicskeeper.Keeper, ctx context.Context) { + t.Helper() + k, ctx, _, _ := TokenomicsKeeperWithActorAddrs(t) + return k, ctx +} + +// TODO_TECHDEBT: Have the callers use the keepers to find `appAddr` and `supplierAddr` +// rather than returning them explicitly. +func TokenomicsKeeperWithActorAddrs(t testing.TB) ( tokenomicsKeeper tokenomicskeeper.Keeper, ctx context.Context, appAddr string, diff --git a/x/tokenomics/keeper/msg_server_test.go b/x/tokenomics/keeper/msg_server_test.go index 2990f89d1..9329a3b79 100644 --- a/x/tokenomics/keeper/msg_server_test.go +++ b/x/tokenomics/keeper/msg_server_test.go @@ -14,7 +14,7 @@ import ( func setupMsgServer(t testing.TB) (keeper.Keeper, types.MsgServer, context.Context) { t.Helper() - k, ctx, _, _ := testkeeper.TokenomicsKeeper(t) + k, ctx, _, _ := testkeeper.TokenomicsKeeperWithActorAddrs(t) return k, keeper.NewMsgServerImpl(k), ctx } diff --git a/x/tokenomics/keeper/msg_update_params_test.go b/x/tokenomics/keeper/msg_update_params_test.go index c1b53c902..71f3f1436 100644 --- a/x/tokenomics/keeper/msg_update_params_test.go +++ b/x/tokenomics/keeper/msg_update_params_test.go @@ -92,7 +92,7 @@ func TestMsgUpdateParams(t *testing.T) { } func TestUpdateParams_ComputeUnitsToTokensMultiplier(t *testing.T) { - tokenomicsKeeper, ctx, _, _ := testkeeper.TokenomicsKeeper(t) + tokenomicsKeeper, ctx, _, _ := testkeeper.TokenomicsKeeperWithActorAddrs(t) srv := keeper.NewMsgServerImpl(tokenomicsKeeper) // Set the default params diff --git a/x/tokenomics/keeper/query_params_test.go b/x/tokenomics/keeper/query_params_test.go index 9d4daf427..34381a7f3 100644 --- a/x/tokenomics/keeper/query_params_test.go +++ b/x/tokenomics/keeper/query_params_test.go @@ -10,7 +10,7 @@ import ( ) func TestGetParams(t *testing.T) { - k, ctx, _, _ := testkeeper.TokenomicsKeeper(t) + k, ctx, _, _ := testkeeper.TokenomicsKeeperWithActorAddrs(t) // TODO_INVESTIGATE(#394): Params tests don't assert initial state. params := types.DefaultParams() @@ -20,7 +20,7 @@ func TestGetParams(t *testing.T) { } func TestParamsQuery(t *testing.T) { - keeper, ctx, _, _ := testkeeper.TokenomicsKeeper(t) + keeper, ctx, _, _ := testkeeper.TokenomicsKeeperWithActorAddrs(t) params := types.DefaultParams() require.NoError(t, keeper.SetParams(ctx, params)) diff --git a/x/tokenomics/keeper/query_relay_mining_difficulty.go b/x/tokenomics/keeper/query_relay_mining_difficulty.go new file mode 100644 index 000000000..6b7b2f36d --- /dev/null +++ b/x/tokenomics/keeper/query_relay_mining_difficulty.go @@ -0,0 +1,56 @@ +package keeper + +import ( + "context" + + "cosmossdk.io/store/prefix" + "github.com/cosmos/cosmos-sdk/runtime" + "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/pokt-network/poktroll/x/tokenomics/types" +) + +func (k Keeper) RelayMiningDifficultyAll(ctx context.Context, req *types.QueryAllRelayMiningDifficultyRequest) (*types.QueryAllRelayMiningDifficultyResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + var relayMiningDifficulties []types.RelayMiningDifficulty + + store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + relayMiningDifficultyStore := prefix.NewStore(store, types.KeyPrefix(types.RelayMiningDifficultyKeyPrefix)) + + pageRes, err := query.Paginate(relayMiningDifficultyStore, req.Pagination, func(key []byte, value []byte) error { + var relayMiningDifficulty types.RelayMiningDifficulty + if err := k.cdc.Unmarshal(value, &relayMiningDifficulty); err != nil { + return err + } + + relayMiningDifficulties = append(relayMiningDifficulties, relayMiningDifficulty) + return nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryAllRelayMiningDifficultyResponse{RelayMiningDifficulty: relayMiningDifficulties, Pagination: pageRes}, nil +} + +func (k Keeper) RelayMiningDifficulty(ctx context.Context, req *types.QueryGetRelayMiningDifficultyRequest) (*types.QueryGetRelayMiningDifficultyResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + difficulty, found := k.GetRelayMiningDifficulty( + ctx, + req.ServiceId, + ) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryGetRelayMiningDifficultyResponse{RelayMiningDifficulty: difficulty}, nil +} diff --git a/x/tokenomics/keeper/query_relay_mining_difficulty_test.go b/x/tokenomics/keeper/query_relay_mining_difficulty_test.go new file mode 100644 index 000000000..7146cfdb3 --- /dev/null +++ b/x/tokenomics/keeper/query_relay_mining_difficulty_test.go @@ -0,0 +1,124 @@ +package keeper_test + +import ( + "strconv" + "testing" + + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + keepertest "github.com/pokt-network/poktroll/testutil/keeper" + "github.com/pokt-network/poktroll/testutil/nullify" + "github.com/pokt-network/poktroll/x/tokenomics/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestRelayMiningDifficultyQuerySingle(t *testing.T) { + keeper, ctx := keepertest.TokenomicsKeeper(t) + msgs := createNRelayMiningDifficulty(keeper, ctx, 2) + tests := []struct { + desc string + request *types.QueryGetRelayMiningDifficultyRequest + response *types.QueryGetRelayMiningDifficultyResponse + expectedErr error + }{ + { + desc: "First", + request: &types.QueryGetRelayMiningDifficultyRequest{ + ServiceId: msgs[0].ServiceId, + }, + response: &types.QueryGetRelayMiningDifficultyResponse{RelayMiningDifficulty: msgs[0]}, + }, + { + desc: "Second", + request: &types.QueryGetRelayMiningDifficultyRequest{ + ServiceId: msgs[1].ServiceId, + }, + response: &types.QueryGetRelayMiningDifficultyResponse{RelayMiningDifficulty: msgs[1]}, + }, + { + desc: "KeyNotFound", + request: &types.QueryGetRelayMiningDifficultyRequest{ + ServiceId: strconv.Itoa(100000), + }, + expectedErr: status.Error(codes.NotFound, "not found"), + }, + { + desc: "InvalidRequest", + expectedErr: status.Error(codes.InvalidArgument, "invalid request"), + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.RelayMiningDifficulty(ctx, tc.request) + if tc.expectedErr != nil { + require.ErrorIs(t, err, tc.expectedErr) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} + +func TestRelayMiningDifficultyQueryPaginated(t *testing.T) { + keeper, ctx := keepertest.TokenomicsKeeper(t) + msgs := createNRelayMiningDifficulty(keeper, ctx, 5) + + request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllRelayMiningDifficultyRequest { + return &types.QueryAllRelayMiningDifficultyRequest{ + Pagination: &query.PageRequest{ + Key: next, + Offset: offset, + Limit: limit, + CountTotal: total, + }, + } + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(msgs); i += step { + resp, err := keeper.RelayMiningDifficultyAll(ctx, request(nil, uint64(i), uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.RelayMiningDifficulty), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.RelayMiningDifficulty), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(msgs); i += step { + resp, err := keeper.RelayMiningDifficultyAll(ctx, request(next, 0, uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.RelayMiningDifficulty), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.RelayMiningDifficulty), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + resp, err := keeper.RelayMiningDifficultyAll(ctx, request(nil, 0, 0, true)) + require.NoError(t, err) + require.Equal(t, len(msgs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(msgs), + nullify.Fill(resp.RelayMiningDifficulty), + ) + }) + t.Run("InvalidRequest", func(t *testing.T) { + _, err := keeper.RelayMiningDifficultyAll(ctx, nil) + require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + }) +} diff --git a/x/tokenomics/keeper/relay_mining_difficulty.go b/x/tokenomics/keeper/relay_mining_difficulty.go new file mode 100644 index 000000000..efb9210bd --- /dev/null +++ b/x/tokenomics/keeper/relay_mining_difficulty.go @@ -0,0 +1,83 @@ +package keeper + +import ( + "context" + "fmt" + + "cosmossdk.io/store/prefix" + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/runtime" + + "github.com/pokt-network/poktroll/x/tokenomics/types" +) + +// SetRelayMiningDifficulty set a specific relayMiningDifficulty in the store from its index +func (k Keeper) SetRelayMiningDifficulty(ctx context.Context, relayMiningDifficulty types.RelayMiningDifficulty) { + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.RelayMiningDifficultyKeyPrefix)) + difficultyBz := k.cdc.MustMarshal(&relayMiningDifficulty) + store.Set(types.RelayMiningDifficultyKey( + relayMiningDifficulty.ServiceId, + ), difficultyBz) +} + +// GetRelayMiningDifficulty returns a relayMiningDifficulty from its index +func (k Keeper) GetRelayMiningDifficulty( + ctx context.Context, + serviceId string, + +) (difficulty types.RelayMiningDifficulty, found bool) { + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.RelayMiningDifficultyKeyPrefix)) + + difficultyBz := store.Get(types.RelayMiningDifficultyKey( + serviceId, + )) + if difficultyBz == nil { + difficulty.ServiceId = serviceId + return difficulty, false + } + + k.cdc.MustUnmarshal(difficultyBz, &difficulty) + return difficulty, true +} + +// RemoveRelayMiningDifficulty removes a relayMiningDifficulty from the store +func (k Keeper) RemoveRelayMiningDifficulty( + ctx context.Context, + serviceId string, +) { + logger := k.Logger().With("method", "RemoveRelayMiningDifficulty") + + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.RelayMiningDifficultyKeyPrefix)) + difficultyKey := types.RelayMiningDifficultyKey( + serviceId, + ) + + if !store.Has(difficultyKey) { + logger.Warn(fmt.Sprintf("trying to delete a non-existing relayMiningDifficulty for service: %s", serviceId)) + return + } + + store.Delete(types.RelayMiningDifficultyKey( + serviceId, + )) +} + +// GetAllRelayMiningDifficulty returns all relayMiningDifficulty +func (k Keeper) GetAllRelayMiningDifficulty(ctx context.Context) (list []types.RelayMiningDifficulty) { + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.RelayMiningDifficultyKeyPrefix)) + iterator := storetypes.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.RelayMiningDifficulty + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/tokenomics/keeper/relay_mining_difficulty_test.go b/x/tokenomics/keeper/relay_mining_difficulty_test.go new file mode 100644 index 000000000..3644fe4c8 --- /dev/null +++ b/x/tokenomics/keeper/relay_mining_difficulty_test.go @@ -0,0 +1,64 @@ +package keeper_test + +import ( + "context" + "strconv" + "testing" + + "github.com/stretchr/testify/require" + + keepertest "github.com/pokt-network/poktroll/testutil/keeper" + "github.com/pokt-network/poktroll/testutil/nullify" + "github.com/pokt-network/poktroll/x/tokenomics/keeper" + "github.com/pokt-network/poktroll/x/tokenomics/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func createNRelayMiningDifficulty(keeper keeper.Keeper, ctx context.Context, n int) []types.RelayMiningDifficulty { + difficulties := make([]types.RelayMiningDifficulty, n) + for idx := range difficulties { + difficulties[idx].ServiceId = strconv.Itoa(idx) + + keeper.SetRelayMiningDifficulty(ctx, difficulties[idx]) + } + return difficulties +} + +func TestRelayMiningDifficultyGet(t *testing.T) { + keeper, ctx := keepertest.TokenomicsKeeper(t) + difficulties := createNRelayMiningDifficulty(keeper, ctx, 10) + for _, difficulty := range difficulties { + rst, found := keeper.GetRelayMiningDifficulty(ctx, + difficulty.ServiceId, + ) + require.True(t, found) + require.Equal(t, + nullify.Fill(&difficulty), + nullify.Fill(&rst), + ) + } +} +func TestRelayMiningDifficultyRemove(t *testing.T) { + keeper, ctx := keepertest.TokenomicsKeeper(t) + difficulties := createNRelayMiningDifficulty(keeper, ctx, 10) + for _, difficulty := range difficulties { + keeper.RemoveRelayMiningDifficulty(ctx, + difficulty.ServiceId, + ) + _, found := keeper.GetRelayMiningDifficulty(ctx, + difficulty.ServiceId, + ) + require.False(t, found) + } +} + +func TestRelayMiningDifficultyGetAll(t *testing.T) { + keeper, ctx := keepertest.TokenomicsKeeper(t) + difficulties := createNRelayMiningDifficulty(keeper, ctx, 10) + require.ElementsMatch(t, + nullify.Fill(difficulties), + nullify.Fill(keeper.GetAllRelayMiningDifficulty(ctx)), + ) +} diff --git a/x/tokenomics/keeper/settle_session_accounting_test.go b/x/tokenomics/keeper/settle_session_accounting_test.go index 51f135b17..c96934128 100644 --- a/x/tokenomics/keeper/settle_session_accounting_test.go +++ b/x/tokenomics/keeper/settle_session_accounting_test.go @@ -80,7 +80,7 @@ func TestSettleSessionAccounting_AppStakeTooLow(t *testing.T) { } func TestSettleSessionAccounting_AppNotFound(t *testing.T) { - keeper, ctx, _, supplierAddr := testkeeper.TokenomicsKeeper(t) + keeper, ctx, _, supplierAddr := testkeeper.TokenomicsKeeperWithActorAddrs(t) // The base claim whose root will be customized for testing purposes claim := prooftypes.Claim{ @@ -104,7 +104,7 @@ func TestSettleSessionAccounting_AppNotFound(t *testing.T) { } func TestSettleSessionAccounting_InvalidRoot(t *testing.T) { - keeper, ctx, appAddr, supplierAddr := testkeeper.TokenomicsKeeper(t) + keeper, ctx, appAddr, supplierAddr := testkeeper.TokenomicsKeeperWithActorAddrs(t) // Define test cases tests := []struct { @@ -189,7 +189,7 @@ func TestSettleSessionAccounting_InvalidRoot(t *testing.T) { } func TestSettleSessionAccounting_InvalidClaim(t *testing.T) { - keeper, ctx, appAddr, supplierAddr := testkeeper.TokenomicsKeeper(t) + keeper, ctx, appAddr, supplierAddr := testkeeper.TokenomicsKeeperWithActorAddrs(t) // Define test cases tests := []struct { diff --git a/x/tokenomics/module/autocli.go b/x/tokenomics/module/autocli.go index e246b275d..758d76ed4 100644 --- a/x/tokenomics/module/autocli.go +++ b/x/tokenomics/module/autocli.go @@ -10,7 +10,7 @@ import ( func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { return &autocliv1.ModuleOptions{ Query: &autocliv1.ServiceCommandDescriptor{ - Service: modulev1.Query_ServiceDesc.ServiceName, + Service: modulev1.Query_ServiceDesc.ServiceName, RpcCommandOptions: []*autocliv1.RpcCommandOptions{ // { // RpcMethod: "Params", @@ -21,6 +21,17 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { // Example: // $ poktrolld q tokenomics params --node $(POCKET_NODE) --home $(POKTROLLD_HOME)`, // }, + { + RpcMethod: "RelayMiningDifficultyAll", + Use: "list-relay-mining-difficulty", + Short: "List all relay-mining-difficulty", + }, + { + RpcMethod: "RelayMiningDifficulty", + Use: "show-relay-mining-difficulty [id]", + Short: "Shows a relay-mining-difficulty", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "serviceId"}}, + }, // this line is used by ignite scaffolding # autocli/query }, }, diff --git a/x/tokenomics/module/genesis.go b/x/tokenomics/module/genesis.go index c877263d1..e4e09b61d 100644 --- a/x/tokenomics/module/genesis.go +++ b/x/tokenomics/module/genesis.go @@ -9,6 +9,10 @@ import ( // InitGenesis initializes the module's state from a provided genesis state. func InitGenesis(ctx context.Context, k keeper.Keeper, genState types.GenesisState) { + // Set all the relayMiningDifficulty + for _, difficulty := range genState.RelayMiningDifficultyList { + k.SetRelayMiningDifficulty(ctx, difficulty) + } // this line is used by starport scaffolding # genesis/module/init if err := k.SetParams(ctx, genState.Params); err != nil { panic(err) @@ -20,6 +24,7 @@ func ExportGenesis(ctx context.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.Params = k.GetParams(ctx) + genesis.RelayMiningDifficultyList = k.GetAllRelayMiningDifficulty(ctx) // this line is used by starport scaffolding # genesis/module/export return genesis diff --git a/x/tokenomics/module/genesis_test.go b/x/tokenomics/module/genesis_test.go index 60f0b969f..ebe89fa4e 100644 --- a/x/tokenomics/module/genesis_test.go +++ b/x/tokenomics/module/genesis_test.go @@ -15,10 +15,18 @@ func TestGenesis(t *testing.T) { genesisState := types.GenesisState{ Params: types.DefaultParams(), + RelayMiningDifficultyList: []types.RelayMiningDifficulty{ + { + ServiceId: "0", + }, + { + ServiceId: "1", + }, + }, // this line is used by starport scaffolding # genesis/test/state } - k, ctx, _, _ := keepertest.TokenomicsKeeper(t) + k, ctx, _, _ := keepertest.TokenomicsKeeperWithActorAddrs(t) tokenomics.InitGenesis(ctx, k, genesisState) got := tokenomics.ExportGenesis(ctx, k) require.NotNil(t, got) @@ -26,5 +34,6 @@ func TestGenesis(t *testing.T) { nullify.Fill(&genesisState) nullify.Fill(got) + require.ElementsMatch(t, genesisState.RelayMiningDifficultyList, got.RelayMiningDifficultyList) // this line is used by starport scaffolding # genesis/test/assert } diff --git a/x/tokenomics/module/module.go b/x/tokenomics/module/module.go index 46b88cc52..95b7bb152 100644 --- a/x/tokenomics/module/module.go +++ b/x/tokenomics/module/module.go @@ -3,7 +3,6 @@ package tokenomics import ( "context" "encoding/json" - "fmt" // this line is used by starport scaffolding # 1 @@ -75,7 +74,7 @@ func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { var genState types.GenesisState if err := cdc.UnmarshalJSON(bz, &genState); err != nil { - return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + return types.ErrTokenomicsUnmarshalInvalid.Wrapf("invalid genesis state: %v", err) } return genState.Validate() } diff --git a/x/tokenomics/types/errors.go b/x/tokenomics/types/errors.go index 2f5a8bbc9..a9a6dfe7e 100644 --- a/x/tokenomics/types/errors.go +++ b/x/tokenomics/types/errors.go @@ -22,4 +22,6 @@ var ( ErrTokenomicsApplicationNewStakeInvalid = sdkerrors.Register(ModuleName, 1115, "application stake cannot be reduced to a -ve amount") ErrTokenomicsParamNameInvalid = sdkerrors.Register(ModuleName, 1116, "the provided param name is invalid") ErrTokenomicsParamInvalid = sdkerrors.Register(ModuleName, 1117, "the provided param is invalid") + ErrTokenomicsUnmarshalInvalid = sdkerrors.Register(ModuleName, 1118, "failed to unmarshal the provided bytes") + ErrTokenomicsDuplicateIndex = sdkerrors.Register(ModuleName, 1119, "cannot have a duplicate index") ) diff --git a/x/tokenomics/types/genesis.go b/x/tokenomics/types/genesis.go index 60d614ce4..2d38fc760 100644 --- a/x/tokenomics/types/genesis.go +++ b/x/tokenomics/types/genesis.go @@ -1,10 +1,9 @@ package types -// this line is used by starport scaffolding # genesis/types/import - // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ + RelayMiningDifficultyList: []RelayMiningDifficulty{}, // this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), } @@ -13,6 +12,16 @@ func DefaultGenesis() *GenesisState { // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { + // Check for duplicated index in relayMiningDifficulty + relayMiningDifficultyIndexMap := make(map[string]struct{}) + + for _, elem := range gs.RelayMiningDifficultyList { + index := string(RelayMiningDifficultyKey(elem.ServiceId)) + if _, ok := relayMiningDifficultyIndexMap[index]; ok { + return ErrTokenomicsDuplicateIndex.Wrapf("duplicated index for relayMiningDifficulty: %s", index) + } + relayMiningDifficultyIndexMap[index] = struct{}{} + } // this line is used by starport scaffolding # genesis/types/validate return gs.Params.ValidateBasic() diff --git a/x/tokenomics/types/genesis.pb.go b/x/tokenomics/types/genesis.pb.go index dc98580aa..f7a21c331 100644 --- a/x/tokenomics/types/genesis.pb.go +++ b/x/tokenomics/types/genesis.pb.go @@ -27,7 +27,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the tokenomics module's genesis state. type GenesisState struct { // params defines all the parameters of the module. - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + RelayMiningDifficultyList []RelayMiningDifficulty `protobuf:"bytes,2,rep,name=relayMiningDifficultyList,proto3" json:"relayMiningDifficultyList"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -70,6 +71,13 @@ func (m *GenesisState) GetParams() Params { return Params{} } +func (m *GenesisState) GetRelayMiningDifficultyList() []RelayMiningDifficulty { + if m != nil { + return m.RelayMiningDifficultyList + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "poktroll.tokenomics.GenesisState") } @@ -77,21 +85,25 @@ func init() { func init() { proto.RegisterFile("poktroll/tokenomics/genesis.proto", fileDescriptor_a4de321d172b0811) } var fileDescriptor_a4de321d172b0811 = []byte{ - // 216 bytes of a gzipped FileDescriptorProto + // 285 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2c, 0xc8, 0xcf, 0x2e, 0x29, 0xca, 0xcf, 0xc9, 0xd1, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0xcb, 0xcf, 0xcd, 0x4c, 0x2e, 0xd6, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0x29, 0xd1, 0x43, 0x28, 0x91, 0x12, 0x4c, 0xcc, 0xcd, 0xcc, 0xcb, 0xd7, 0x07, 0x93, 0x10, 0x75, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0xa6, 0x3e, 0x88, 0x05, 0x15, 0x55, 0xc0, 0x66, 0x41, - 0x41, 0x62, 0x51, 0x62, 0x2e, 0xd4, 0x7c, 0x25, 0x3f, 0x2e, 0x1e, 0x77, 0x88, 0x85, 0xc1, 0x25, - 0x89, 0x25, 0xa9, 0x42, 0x76, 0x5c, 0x6c, 0x10, 0x79, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x6e, 0x23, - 0x69, 0x3d, 0x2c, 0x0e, 0xd0, 0x0b, 0x00, 0x2b, 0x71, 0xe2, 0x3c, 0x71, 0x4f, 0x9e, 0x61, 0xc5, - 0xf3, 0x0d, 0x5a, 0x8c, 0x41, 0x50, 0x5d, 0x4e, 0xbe, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, - 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, - 0x2c, 0xc7, 0x10, 0x65, 0x9c, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, - 0x32, 0x53, 0x37, 0x2f, 0xb5, 0xa4, 0x3c, 0xbf, 0x28, 0x5b, 0x1f, 0xee, 0xc6, 0x0a, 0x64, 0x57, - 0x96, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x5d, 0x69, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, - 0xd5, 0xe3, 0x60, 0x8d, 0x2a, 0x01, 0x00, 0x00, + 0x41, 0x62, 0x51, 0x62, 0x2e, 0xd4, 0x7c, 0x29, 0x43, 0x6c, 0x2a, 0x8a, 0x52, 0x73, 0x12, 0x2b, + 0xe3, 0x73, 0x33, 0xf3, 0x32, 0xf3, 0xd2, 0xe3, 0x53, 0x32, 0xd3, 0xd2, 0x32, 0x93, 0x4b, 0x73, + 0x4a, 0x2a, 0x21, 0x5a, 0x94, 0xf6, 0x31, 0x72, 0xf1, 0xb8, 0x43, 0x1c, 0x19, 0x5c, 0x92, 0x58, + 0x92, 0x2a, 0x64, 0xc7, 0xc5, 0x06, 0x31, 0x53, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x5a, + 0x0f, 0x8b, 0xa3, 0xf5, 0x02, 0xc0, 0x4a, 0x9c, 0x38, 0x4f, 0xdc, 0x93, 0x67, 0x58, 0xf1, 0x7c, + 0x83, 0x16, 0x63, 0x10, 0x54, 0x97, 0x50, 0x1e, 0x97, 0x24, 0xd8, 0x46, 0x5f, 0xb0, 0x85, 0x2e, + 0x70, 0xfb, 0x7c, 0x32, 0x8b, 0x4b, 0x24, 0x98, 0x14, 0x98, 0x35, 0xb8, 0x8d, 0xb4, 0xb0, 0x1a, + 0x19, 0x84, 0x4d, 0x97, 0x13, 0x0b, 0xc8, 0x86, 0x20, 0xdc, 0x46, 0x3a, 0xf9, 0x9e, 0x78, 0x24, + 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, + 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x71, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, + 0x72, 0x7e, 0xae, 0x3e, 0xc8, 0x42, 0xdd, 0xbc, 0xd4, 0x92, 0xf2, 0xfc, 0xa2, 0x6c, 0x7d, 0x78, + 0x28, 0x55, 0x20, 0x87, 0x53, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x58, 0x8c, 0x01, + 0x01, 0x00, 0x00, 0xff, 0xff, 0xfa, 0xe8, 0x52, 0xb6, 0xce, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -114,6 +126,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.RelayMiningDifficultyList) > 0 { + for iNdEx := len(m.RelayMiningDifficultyList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RelayMiningDifficultyList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } { size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -146,6 +172,12 @@ func (m *GenesisState) Size() (n int) { _ = l l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) + if len(m.RelayMiningDifficultyList) > 0 { + for _, e := range m.RelayMiningDifficultyList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -217,6 +249,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RelayMiningDifficultyList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RelayMiningDifficultyList = append(m.RelayMiningDifficultyList, RelayMiningDifficulty{}) + if err := m.RelayMiningDifficultyList[len(m.RelayMiningDifficultyList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/tokenomics/types/genesis_test.go b/x/tokenomics/types/genesis_test.go index 5994a3b52..4c8d30f84 100644 --- a/x/tokenomics/types/genesis_test.go +++ b/x/tokenomics/types/genesis_test.go @@ -3,8 +3,9 @@ package types_test import ( "testing" - "github.com/pokt-network/poktroll/x/tokenomics/types" "github.com/stretchr/testify/require" + + "github.com/pokt-network/poktroll/x/tokenomics/types" ) func TestGenesisState_Validate(t *testing.T) { @@ -24,6 +25,14 @@ func TestGenesisState_Validate(t *testing.T) { Params: types.Params{ ComputeUnitsToTokensMultiplier: 1, }, + RelayMiningDifficultyList: []types.RelayMiningDifficulty{ + { + ServiceId: "0", + }, + { + ServiceId: "1", + }, + }, // this line is used by starport scaffolding # types/genesis/validField }, isValid: true, @@ -38,6 +47,20 @@ func TestGenesisState_Validate(t *testing.T) { }, isValid: false, }, + { + desc: "duplicated relayMiningDifficulty", + genState: &types.GenesisState{ + RelayMiningDifficultyList: []types.RelayMiningDifficulty{ + { + ServiceId: "0", + }, + { + ServiceId: "0", + }, + }, + }, + isValid: false, + }, // this line is used by starport scaffolding # types/genesis/testcase } for _, test := range tests { diff --git a/x/tokenomics/types/key_relay_mining_difficulty.go b/x/tokenomics/types/key_relay_mining_difficulty.go new file mode 100644 index 000000000..ca7626471 --- /dev/null +++ b/x/tokenomics/types/key_relay_mining_difficulty.go @@ -0,0 +1,23 @@ +package types + +import "encoding/binary" + +var _ binary.ByteOrder + +const ( + // RelayMiningDifficultyKeyPrefix is the prefix to retrieve all RelayMiningDifficulty + RelayMiningDifficultyKeyPrefix = "RelayMiningDifficulty/value/" +) + +// RelayMiningDifficultyKey returns the store key to retrieve a RelayMiningDifficulty from the index fields +func RelayMiningDifficultyKey( + serviceId string, +) []byte { + var key []byte + + serviceIdBz := []byte(serviceId) + key = append(key, serviceIdBz...) + key = append(key, []byte("/")...) + + return key +} diff --git a/x/tokenomics/types/query.pb.go b/x/tokenomics/types/query.pb.go index 483412a0f..e83334bce 100644 --- a/x/tokenomics/types/query.pb.go +++ b/x/tokenomics/types/query.pb.go @@ -6,6 +6,9 @@ package types import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types" + query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -113,34 +116,239 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } +type QueryGetRelayMiningDifficultyRequest struct { + ServiceId string `protobuf:"bytes,1,opt,name=serviceId,proto3" json:"serviceId,omitempty"` +} + +func (m *QueryGetRelayMiningDifficultyRequest) Reset() { *m = QueryGetRelayMiningDifficultyRequest{} } +func (m *QueryGetRelayMiningDifficultyRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetRelayMiningDifficultyRequest) ProtoMessage() {} +func (*QueryGetRelayMiningDifficultyRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_19d6daded0c54373, []int{2} +} +func (m *QueryGetRelayMiningDifficultyRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetRelayMiningDifficultyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetRelayMiningDifficultyRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetRelayMiningDifficultyRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetRelayMiningDifficultyRequest.Merge(m, src) +} +func (m *QueryGetRelayMiningDifficultyRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetRelayMiningDifficultyRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetRelayMiningDifficultyRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetRelayMiningDifficultyRequest proto.InternalMessageInfo + +func (m *QueryGetRelayMiningDifficultyRequest) GetServiceId() string { + if m != nil { + return m.ServiceId + } + return "" +} + +type QueryGetRelayMiningDifficultyResponse struct { + RelayMiningDifficulty RelayMiningDifficulty `protobuf:"bytes,1,opt,name=relayMiningDifficulty,proto3" json:"relayMiningDifficulty"` +} + +func (m *QueryGetRelayMiningDifficultyResponse) Reset() { *m = QueryGetRelayMiningDifficultyResponse{} } +func (m *QueryGetRelayMiningDifficultyResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetRelayMiningDifficultyResponse) ProtoMessage() {} +func (*QueryGetRelayMiningDifficultyResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_19d6daded0c54373, []int{3} +} +func (m *QueryGetRelayMiningDifficultyResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetRelayMiningDifficultyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetRelayMiningDifficultyResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetRelayMiningDifficultyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetRelayMiningDifficultyResponse.Merge(m, src) +} +func (m *QueryGetRelayMiningDifficultyResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetRelayMiningDifficultyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetRelayMiningDifficultyResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetRelayMiningDifficultyResponse proto.InternalMessageInfo + +func (m *QueryGetRelayMiningDifficultyResponse) GetRelayMiningDifficulty() RelayMiningDifficulty { + if m != nil { + return m.RelayMiningDifficulty + } + return RelayMiningDifficulty{} +} + +type QueryAllRelayMiningDifficultyRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllRelayMiningDifficultyRequest) Reset() { *m = QueryAllRelayMiningDifficultyRequest{} } +func (m *QueryAllRelayMiningDifficultyRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllRelayMiningDifficultyRequest) ProtoMessage() {} +func (*QueryAllRelayMiningDifficultyRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_19d6daded0c54373, []int{4} +} +func (m *QueryAllRelayMiningDifficultyRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllRelayMiningDifficultyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllRelayMiningDifficultyRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllRelayMiningDifficultyRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllRelayMiningDifficultyRequest.Merge(m, src) +} +func (m *QueryAllRelayMiningDifficultyRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllRelayMiningDifficultyRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllRelayMiningDifficultyRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllRelayMiningDifficultyRequest proto.InternalMessageInfo + +func (m *QueryAllRelayMiningDifficultyRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryAllRelayMiningDifficultyResponse struct { + RelayMiningDifficulty []RelayMiningDifficulty `protobuf:"bytes,1,rep,name=relayMiningDifficulty,proto3" json:"relayMiningDifficulty"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllRelayMiningDifficultyResponse) Reset() { *m = QueryAllRelayMiningDifficultyResponse{} } +func (m *QueryAllRelayMiningDifficultyResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllRelayMiningDifficultyResponse) ProtoMessage() {} +func (*QueryAllRelayMiningDifficultyResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_19d6daded0c54373, []int{5} +} +func (m *QueryAllRelayMiningDifficultyResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllRelayMiningDifficultyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllRelayMiningDifficultyResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllRelayMiningDifficultyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllRelayMiningDifficultyResponse.Merge(m, src) +} +func (m *QueryAllRelayMiningDifficultyResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllRelayMiningDifficultyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllRelayMiningDifficultyResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllRelayMiningDifficultyResponse proto.InternalMessageInfo + +func (m *QueryAllRelayMiningDifficultyResponse) GetRelayMiningDifficulty() []RelayMiningDifficulty { + if m != nil { + return m.RelayMiningDifficulty + } + return nil +} + +func (m *QueryAllRelayMiningDifficultyResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "poktroll.tokenomics.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "poktroll.tokenomics.QueryParamsResponse") + proto.RegisterType((*QueryGetRelayMiningDifficultyRequest)(nil), "poktroll.tokenomics.QueryGetRelayMiningDifficultyRequest") + proto.RegisterType((*QueryGetRelayMiningDifficultyResponse)(nil), "poktroll.tokenomics.QueryGetRelayMiningDifficultyResponse") + proto.RegisterType((*QueryAllRelayMiningDifficultyRequest)(nil), "poktroll.tokenomics.QueryAllRelayMiningDifficultyRequest") + proto.RegisterType((*QueryAllRelayMiningDifficultyResponse)(nil), "poktroll.tokenomics.QueryAllRelayMiningDifficultyResponse") } func init() { proto.RegisterFile("poktroll/tokenomics/query.proto", fileDescriptor_19d6daded0c54373) } var fileDescriptor_19d6daded0c54373 = []byte{ - // 296 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2f, 0xc8, 0xcf, 0x2e, - 0x29, 0xca, 0xcf, 0xc9, 0xd1, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0xcb, 0xcf, 0xcd, 0x4c, 0x2e, 0xd6, - 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0x29, 0xd0, - 0x43, 0x28, 0x90, 0x12, 0x4c, 0xcc, 0xcd, 0xcc, 0xcb, 0xd7, 0x07, 0x93, 0x10, 0x75, 0x52, 0x22, - 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0xa6, 0x3e, 0x88, 0x05, 0x15, 0x95, 0x49, 0xcf, 0xcf, 0x4f, 0xcf, - 0x49, 0xd5, 0x4f, 0x2c, 0xc8, 0xd4, 0x4f, 0xcc, 0xcb, 0xcb, 0x2f, 0x49, 0x2c, 0xc9, 0xcc, 0xcf, - 0x2b, 0x86, 0xca, 0x2a, 0x60, 0xb3, 0xbc, 0x20, 0xb1, 0x28, 0x31, 0x17, 0xaa, 0x42, 0x49, 0x84, - 0x4b, 0x28, 0x10, 0xe4, 0x98, 0x00, 0xb0, 0x60, 0x50, 0x6a, 0x61, 0x69, 0x6a, 0x71, 0x89, 0x52, - 0x28, 0x97, 0x30, 0x8a, 0x68, 0x71, 0x41, 0x7e, 0x5e, 0x71, 0xaa, 0x90, 0x1d, 0x17, 0x1b, 0x44, - 0xb3, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0xb4, 0x1e, 0x16, 0xb7, 0xeb, 0x41, 0x34, 0x39, - 0x71, 0x9e, 0xb8, 0x27, 0xcf, 0xb0, 0xe2, 0xf9, 0x06, 0x2d, 0xc6, 0x20, 0xa8, 0x2e, 0xa3, 0xe9, - 0x8c, 0x5c, 0xac, 0x60, 0x73, 0x85, 0x7a, 0x19, 0xb9, 0xd8, 0x20, 0xea, 0x84, 0xd4, 0xb1, 0x1a, - 0x82, 0xe9, 0x28, 0x29, 0x0d, 0xc2, 0x0a, 0x21, 0xee, 0x54, 0x32, 0x68, 0xba, 0xfc, 0x64, 0x32, - 0x93, 0x96, 0x90, 0x86, 0x3e, 0x48, 0x87, 0x6e, 0x5e, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0xb6, 0x3e, - 0xee, 0xc0, 0x70, 0xf2, 0x3d, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, - 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xe3, - 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x1c, 0xa6, 0x55, 0x20, 0x9b, 0x57, - 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x5c, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, - 0xe7, 0x8d, 0x14, 0xf2, 0xfd, 0x01, 0x00, 0x00, + // 572 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x41, 0x6b, 0x13, 0x41, + 0x14, 0xc7, 0xb3, 0xb5, 0x06, 0x32, 0x9e, 0x9c, 0xb6, 0x50, 0x63, 0xd9, 0x96, 0x45, 0x6d, 0x08, + 0xb8, 0x63, 0xda, 0x53, 0x15, 0x84, 0x84, 0x6a, 0xf0, 0x10, 0xa8, 0x0b, 0x5e, 0xbc, 0x84, 0xc9, + 0x76, 0xb2, 0x0e, 0xd9, 0x9d, 0xd9, 0xee, 0x4e, 0xaa, 0x41, 0xbc, 0x78, 0x17, 0x05, 0xbf, 0x84, + 0x47, 0x3f, 0x46, 0x4f, 0x52, 0xd0, 0x43, 0x2f, 0x8a, 0x24, 0x82, 0x5f, 0x43, 0x76, 0x66, 0xd2, + 0xa4, 0x38, 0x9b, 0x85, 0xd2, 0xcb, 0xb2, 0x3b, 0xf3, 0xde, 0xfb, 0xff, 0x7f, 0x6f, 0xde, 0x0e, + 0xd8, 0x8c, 0xf9, 0x40, 0x24, 0x3c, 0x0c, 0x91, 0xe0, 0x03, 0xc2, 0x78, 0x44, 0xfd, 0x14, 0x1d, + 0x0d, 0x49, 0x32, 0x72, 0xe3, 0x84, 0x0b, 0x0e, 0x57, 0xa6, 0x01, 0xee, 0x2c, 0xa0, 0x7a, 0x13, + 0x47, 0x94, 0x71, 0x24, 0x9f, 0x2a, 0xae, 0xba, 0x1a, 0xf0, 0x80, 0xcb, 0x57, 0x94, 0xbd, 0xe9, + 0xd5, 0x8d, 0x80, 0xf3, 0x20, 0x24, 0x08, 0xc7, 0x14, 0x61, 0xc6, 0xb8, 0xc0, 0x82, 0x72, 0x96, + 0xea, 0xdd, 0x5b, 0x3e, 0x4f, 0x23, 0x9e, 0x76, 0x55, 0x9a, 0xfa, 0xd0, 0x5b, 0x75, 0xf5, 0x85, + 0x7a, 0x38, 0x25, 0xca, 0x0f, 0x3a, 0x6e, 0xf4, 0x88, 0xc0, 0x0d, 0x14, 0xe3, 0x80, 0x32, 0x59, + 0x47, 0xc7, 0xda, 0xf3, 0xb1, 0xd3, 0x28, 0x9f, 0xd3, 0xe9, 0xfe, 0x96, 0x89, 0x31, 0xc6, 0x09, + 0x8e, 0xa6, 0x6a, 0x0d, 0x53, 0x44, 0x42, 0x42, 0x3c, 0xea, 0x46, 0x94, 0x51, 0x16, 0x74, 0x0f, + 0x69, 0xbf, 0x4f, 0xfd, 0x61, 0x28, 0x74, 0x5f, 0x9c, 0x55, 0x00, 0x9f, 0x67, 0xb6, 0x0e, 0x64, + 0x1d, 0x8f, 0x1c, 0x0d, 0x49, 0x2a, 0x9c, 0x17, 0x60, 0xe5, 0xc2, 0x6a, 0x1a, 0x73, 0x96, 0x12, + 0xf8, 0x18, 0x94, 0x95, 0xde, 0xba, 0xb5, 0x65, 0xd5, 0x6e, 0xec, 0xdc, 0x76, 0x0d, 0x5d, 0x75, + 0x55, 0x52, 0xab, 0x72, 0xf2, 0x6b, 0xb3, 0xf4, 0xe5, 0xef, 0xd7, 0xba, 0xe5, 0xe9, 0x2c, 0x67, + 0x1f, 0xdc, 0x91, 0x65, 0xdb, 0x44, 0x78, 0x99, 0xab, 0x8e, 0x34, 0xb5, 0x7f, 0xee, 0x49, 0xcb, + 0xc3, 0x0d, 0x50, 0x49, 0x49, 0x72, 0x4c, 0x7d, 0xf2, 0xec, 0x50, 0x4a, 0x55, 0xbc, 0xd9, 0x82, + 0xf3, 0xd1, 0x02, 0x77, 0x0b, 0xca, 0x68, 0xbf, 0x7d, 0xb0, 0x96, 0x98, 0x02, 0xb4, 0xfd, 0xba, + 0xd1, 0xbe, 0xb1, 0x64, 0x6b, 0x39, 0xa3, 0xf1, 0xcc, 0xe5, 0x1c, 0xa6, 0xb9, 0x9a, 0x61, 0xb8, + 0x90, 0xeb, 0x29, 0x00, 0xb3, 0x53, 0xd7, 0x26, 0xee, 0xb9, 0x7a, 0x60, 0xb2, 0x63, 0x77, 0xd5, + 0xc8, 0xea, 0xc3, 0x77, 0x0f, 0x70, 0x40, 0x74, 0xae, 0x37, 0x97, 0xe9, 0x9c, 0x4d, 0x3b, 0x90, + 0x2f, 0x58, 0xdc, 0x81, 0x6b, 0x57, 0xd8, 0x01, 0xd8, 0xbe, 0x40, 0xb6, 0x24, 0xc9, 0xb6, 0x0b, + 0xc9, 0x94, 0xc9, 0x79, 0xb4, 0x9d, 0x6f, 0xcb, 0xe0, 0xba, 0x44, 0x83, 0x1f, 0x2c, 0x50, 0x56, + 0xa3, 0x04, 0xb7, 0x8d, 0x36, 0xff, 0x9f, 0xdb, 0x6a, 0xad, 0x38, 0x50, 0x69, 0x3a, 0x0f, 0xde, + 0x7f, 0xff, 0xf3, 0x79, 0xa9, 0x0e, 0x6b, 0x28, 0xcb, 0xb8, 0xcf, 0x88, 0x78, 0xcd, 0x93, 0x01, + 0xca, 0xff, 0xc5, 0xe0, 0x4f, 0x0b, 0xac, 0x19, 0x3b, 0x03, 0xf7, 0xf2, 0x55, 0x0b, 0x26, 0xbd, + 0xfa, 0xf0, 0x32, 0xa9, 0x1a, 0xa1, 0x23, 0x11, 0xda, 0xf0, 0x49, 0x31, 0x42, 0xce, 0x1d, 0x80, + 0xde, 0x9e, 0xff, 0x55, 0xef, 0xe0, 0x0f, 0x0b, 0xac, 0x1b, 0x05, 0x9b, 0x61, 0xb8, 0x08, 0xb1, + 0x60, 0xe8, 0x17, 0x21, 0x16, 0x8d, 0xaf, 0xd3, 0x94, 0x88, 0x8f, 0xe0, 0xde, 0xa5, 0x11, 0x5b, + 0x9d, 0x93, 0xb1, 0x6d, 0x9d, 0x8e, 0x6d, 0xeb, 0xf7, 0xd8, 0xb6, 0x3e, 0x4d, 0xec, 0xd2, 0xe9, + 0xc4, 0x2e, 0x9d, 0x4d, 0xec, 0xd2, 0xcb, 0xdd, 0x80, 0x8a, 0x57, 0xc3, 0x9e, 0xeb, 0xf3, 0x28, + 0xa7, 0xfc, 0x9b, 0x79, 0x01, 0x31, 0x8a, 0x49, 0xda, 0x2b, 0xcb, 0x6b, 0x73, 0xf7, 0x5f, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x64, 0x2d, 0x35, 0xad, 0x71, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -157,6 +365,9 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Parameters queries the parameters of the module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Queries a list of RelayMiningDifficulty items. + RelayMiningDifficulty(ctx context.Context, in *QueryGetRelayMiningDifficultyRequest, opts ...grpc.CallOption) (*QueryGetRelayMiningDifficultyResponse, error) + RelayMiningDifficultyAll(ctx context.Context, in *QueryAllRelayMiningDifficultyRequest, opts ...grpc.CallOption) (*QueryAllRelayMiningDifficultyResponse, error) } type queryClient struct { @@ -176,10 +387,31 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } +func (c *queryClient) RelayMiningDifficulty(ctx context.Context, in *QueryGetRelayMiningDifficultyRequest, opts ...grpc.CallOption) (*QueryGetRelayMiningDifficultyResponse, error) { + out := new(QueryGetRelayMiningDifficultyResponse) + err := c.cc.Invoke(ctx, "/poktroll.tokenomics.Query/RelayMiningDifficulty", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) RelayMiningDifficultyAll(ctx context.Context, in *QueryAllRelayMiningDifficultyRequest, opts ...grpc.CallOption) (*QueryAllRelayMiningDifficultyResponse, error) { + out := new(QueryAllRelayMiningDifficultyResponse) + err := c.cc.Invoke(ctx, "/poktroll.tokenomics.Query/RelayMiningDifficultyAll", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Queries a list of RelayMiningDifficulty items. + RelayMiningDifficulty(context.Context, *QueryGetRelayMiningDifficultyRequest) (*QueryGetRelayMiningDifficultyResponse, error) + RelayMiningDifficultyAll(context.Context, *QueryAllRelayMiningDifficultyRequest) (*QueryAllRelayMiningDifficultyResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -189,6 +421,12 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } +func (*UnimplementedQueryServer) RelayMiningDifficulty(ctx context.Context, req *QueryGetRelayMiningDifficultyRequest) (*QueryGetRelayMiningDifficultyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RelayMiningDifficulty not implemented") +} +func (*UnimplementedQueryServer) RelayMiningDifficultyAll(ctx context.Context, req *QueryAllRelayMiningDifficultyRequest) (*QueryAllRelayMiningDifficultyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RelayMiningDifficultyAll not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -212,6 +450,42 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_RelayMiningDifficulty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetRelayMiningDifficultyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RelayMiningDifficulty(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/poktroll.tokenomics.Query/RelayMiningDifficulty", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RelayMiningDifficulty(ctx, req.(*QueryGetRelayMiningDifficultyRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_RelayMiningDifficultyAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllRelayMiningDifficultyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RelayMiningDifficultyAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/poktroll.tokenomics.Query/RelayMiningDifficultyAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RelayMiningDifficultyAll(ctx, req.(*QueryAllRelayMiningDifficultyRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "poktroll.tokenomics.Query", HandlerType: (*QueryServer)(nil), @@ -220,6 +494,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, + { + MethodName: "RelayMiningDifficulty", + Handler: _Query_RelayMiningDifficulty_Handler, + }, + { + MethodName: "RelayMiningDifficultyAll", + Handler: _Query_RelayMiningDifficultyAll_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "poktroll/tokenomics/query.proto", @@ -281,6 +563,153 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryGetRelayMiningDifficultyRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetRelayMiningDifficultyRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetRelayMiningDifficultyRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ServiceId) > 0 { + i -= len(m.ServiceId) + copy(dAtA[i:], m.ServiceId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ServiceId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGetRelayMiningDifficultyResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGetRelayMiningDifficultyResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetRelayMiningDifficultyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.RelayMiningDifficulty.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryAllRelayMiningDifficultyRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllRelayMiningDifficultyRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllRelayMiningDifficultyRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAllRelayMiningDifficultyResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllRelayMiningDifficultyResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllRelayMiningDifficultyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.RelayMiningDifficulty) > 0 { + for iNdEx := len(m.RelayMiningDifficulty) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RelayMiningDifficulty[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -312,7 +741,63 @@ func (m *QueryParamsResponse) Size() (n int) { return n } -func sovQuery(x uint64) (n int) { +func (m *QueryGetRelayMiningDifficultyRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ServiceId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetRelayMiningDifficultyResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.RelayMiningDifficulty.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAllRelayMiningDifficultyRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllRelayMiningDifficultyResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.RelayMiningDifficulty) > 0 { + for _, e := range m.RelayMiningDifficulty { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } func sozQuery(x uint64) (n int) { @@ -451,6 +936,377 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryGetRelayMiningDifficultyRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetRelayMiningDifficultyRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetRelayMiningDifficultyRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ServiceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ServiceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetRelayMiningDifficultyResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetRelayMiningDifficultyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetRelayMiningDifficultyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RelayMiningDifficulty", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RelayMiningDifficulty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllRelayMiningDifficultyRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllRelayMiningDifficultyRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllRelayMiningDifficultyRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllRelayMiningDifficultyResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllRelayMiningDifficultyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllRelayMiningDifficultyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RelayMiningDifficulty", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RelayMiningDifficulty = append(m.RelayMiningDifficulty, RelayMiningDifficulty{}) + if err := m.RelayMiningDifficulty[len(m.RelayMiningDifficulty)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/tokenomics/types/query.pb.gw.go b/x/tokenomics/types/query.pb.gw.go index 08c31f3c5..15d7f5446 100644 --- a/x/tokenomics/types/query.pb.gw.go +++ b/x/tokenomics/types/query.pb.gw.go @@ -51,6 +51,96 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +func request_Query_RelayMiningDifficulty_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetRelayMiningDifficultyRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["serviceId"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "serviceId") + } + + protoReq.ServiceId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "serviceId", err) + } + + msg, err := client.RelayMiningDifficulty(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RelayMiningDifficulty_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetRelayMiningDifficultyRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["serviceId"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "serviceId") + } + + protoReq.ServiceId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "serviceId", err) + } + + msg, err := server.RelayMiningDifficulty(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_RelayMiningDifficultyAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_RelayMiningDifficultyAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllRelayMiningDifficultyRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RelayMiningDifficultyAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.RelayMiningDifficultyAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RelayMiningDifficultyAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllRelayMiningDifficultyRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RelayMiningDifficultyAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.RelayMiningDifficultyAll(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -80,6 +170,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_RelayMiningDifficulty_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_RelayMiningDifficulty_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RelayMiningDifficulty_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RelayMiningDifficultyAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_RelayMiningDifficultyAll_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RelayMiningDifficultyAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -141,13 +277,61 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_RelayMiningDifficulty_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_RelayMiningDifficulty_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RelayMiningDifficulty_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RelayMiningDifficultyAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_RelayMiningDifficultyAll_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RelayMiningDifficultyAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"pokt-network", "poktroll", "tokenomics", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_RelayMiningDifficulty_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"pokt-network", "poktroll", "tokenomics", "relay_mining_difficulty", "serviceId"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_RelayMiningDifficultyAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"pokt-network", "poktroll", "tokenomics", "relay_mining_difficulty"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_RelayMiningDifficulty_0 = runtime.ForwardResponseMessage + + forward_Query_RelayMiningDifficultyAll_0 = runtime.ForwardResponseMessage ) diff --git a/x/tokenomics/types/relay_mining_difficulty.pb.go b/x/tokenomics/types/relay_mining_difficulty.pb.go new file mode 100644 index 000000000..a60e69e05 --- /dev/null +++ b/x/tokenomics/types/relay_mining_difficulty.pb.go @@ -0,0 +1,458 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: poktroll/tokenomics/relay_mining_difficulty.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// RelayMiningDifficulty is a message used to store the on-chain Relay Mining +// difficulty associated with a specific service ID. +type RelayMiningDifficulty struct { + // The service ID the the relay mining difficulty is associated with. + ServiceId string `protobuf:"bytes,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` + // The block height at which this relay mining difficulty was computed. + // This is needed to determine how much time has passed since the last time + // the exponential moving average was computed. + BlockHeight int64 `protobuf:"varint,2,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + // The exponential moving average of the number of relays for this service. + NumRelaysEma uint64 `protobuf:"varint,3,opt,name=num_relays_ema,json=numRelaysEma,proto3" json:"num_relays_ema,omitempty"` + // The target hash determining the difficulty to mine relays for this service. + // For example, if we use sha256 to hash the (RelayRequest,ReqlayResponse) tuple, + // and the difficulty has 4 leading zero bits, then the target hash would be: + // 0b0000111... (until 32 bytes are filled up). + TargetHash []byte `protobuf:"bytes,4,opt,name=target_hash,json=targetHash,proto3" json:"target_hash,omitempty"` +} + +func (m *RelayMiningDifficulty) Reset() { *m = RelayMiningDifficulty{} } +func (m *RelayMiningDifficulty) String() string { return proto.CompactTextString(m) } +func (*RelayMiningDifficulty) ProtoMessage() {} +func (*RelayMiningDifficulty) Descriptor() ([]byte, []int) { + return fileDescriptor_1777fca7cd39aaea, []int{0} +} +func (m *RelayMiningDifficulty) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RelayMiningDifficulty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RelayMiningDifficulty.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RelayMiningDifficulty) XXX_Merge(src proto.Message) { + xxx_messageInfo_RelayMiningDifficulty.Merge(m, src) +} +func (m *RelayMiningDifficulty) XXX_Size() int { + return m.Size() +} +func (m *RelayMiningDifficulty) XXX_DiscardUnknown() { + xxx_messageInfo_RelayMiningDifficulty.DiscardUnknown(m) +} + +var xxx_messageInfo_RelayMiningDifficulty proto.InternalMessageInfo + +func (m *RelayMiningDifficulty) GetServiceId() string { + if m != nil { + return m.ServiceId + } + return "" +} + +func (m *RelayMiningDifficulty) GetBlockHeight() int64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + +func (m *RelayMiningDifficulty) GetNumRelaysEma() uint64 { + if m != nil { + return m.NumRelaysEma + } + return 0 +} + +func (m *RelayMiningDifficulty) GetTargetHash() []byte { + if m != nil { + return m.TargetHash + } + return nil +} + +func init() { + proto.RegisterType((*RelayMiningDifficulty)(nil), "poktroll.tokenomics.RelayMiningDifficulty") +} + +func init() { + proto.RegisterFile("poktroll/tokenomics/relay_mining_difficulty.proto", fileDescriptor_1777fca7cd39aaea) +} + +var fileDescriptor_1777fca7cd39aaea = []byte{ + // 274 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0x3f, 0x4e, 0xf3, 0x30, + 0x18, 0x87, 0xe3, 0xaf, 0xd5, 0x27, 0xd5, 0x8d, 0x18, 0x82, 0x90, 0xb2, 0x60, 0x02, 0x62, 0xc8, + 0x42, 0x22, 0xd4, 0x1b, 0x20, 0x90, 0xca, 0xd0, 0x25, 0x23, 0x8b, 0xe5, 0x24, 0x6e, 0x6c, 0xc5, + 0x7f, 0x22, 0xdb, 0x01, 0x72, 0x0b, 0x8e, 0xc0, 0x71, 0x18, 0x3b, 0x32, 0xa2, 0xe4, 0x22, 0xa8, + 0x06, 0x0a, 0xeb, 0x23, 0x3d, 0x7a, 0xdf, 0xdf, 0x03, 0xaf, 0x3b, 0xdd, 0x3a, 0xa3, 0x85, 0xc8, + 0x9d, 0x6e, 0xa9, 0xd2, 0x92, 0x57, 0x36, 0x37, 0x54, 0x90, 0x01, 0x4b, 0xae, 0xb8, 0x6a, 0x70, + 0xcd, 0xb7, 0x5b, 0x5e, 0xf5, 0xc2, 0x0d, 0x59, 0x67, 0xb4, 0xd3, 0xd1, 0xf1, 0x8f, 0x92, 0xfd, + 0x2a, 0x17, 0xaf, 0x00, 0x9e, 0x14, 0x7b, 0x6d, 0xe3, 0xad, 0xdb, 0x83, 0x14, 0x9d, 0x42, 0x68, + 0xa9, 0x79, 0xe4, 0x15, 0xc5, 0xbc, 0x8e, 0x41, 0x02, 0xd2, 0x45, 0xb1, 0xf8, 0x26, 0xf7, 0x75, + 0x74, 0x0e, 0xc3, 0x52, 0xe8, 0xaa, 0xc5, 0x8c, 0xf2, 0x86, 0xb9, 0xf8, 0x5f, 0x02, 0xd2, 0x59, + 0xb1, 0xf4, 0x6c, 0xed, 0x51, 0x74, 0x09, 0x8f, 0x54, 0x2f, 0xb1, 0xff, 0xca, 0x62, 0x2a, 0x49, + 0x3c, 0x4b, 0x40, 0x3a, 0x2f, 0x42, 0xd5, 0x4b, 0x7f, 0xd3, 0xde, 0x49, 0x12, 0x9d, 0xc1, 0xa5, + 0x23, 0xa6, 0xa1, 0x0e, 0x33, 0x62, 0x59, 0x3c, 0x4f, 0x40, 0x1a, 0x16, 0xf0, 0x0b, 0xad, 0x89, + 0x65, 0x37, 0x9b, 0xb7, 0x11, 0x81, 0xdd, 0x88, 0xc0, 0xc7, 0x88, 0xc0, 0xcb, 0x84, 0x82, 0xdd, + 0x84, 0x82, 0xf7, 0x09, 0x05, 0x0f, 0xab, 0x86, 0x3b, 0xd6, 0x97, 0x59, 0xa5, 0x65, 0xbe, 0x1f, + 0x77, 0xa5, 0xa8, 0x7b, 0xd2, 0xa6, 0xcd, 0x0f, 0x71, 0x9e, 0xff, 0xe6, 0x71, 0x43, 0x47, 0x6d, + 0xf9, 0xdf, 0xd7, 0x58, 0x7d, 0x06, 0x00, 0x00, 0xff, 0xff, 0x07, 0xd6, 0x20, 0xbb, 0x42, 0x01, + 0x00, 0x00, +} + +func (m *RelayMiningDifficulty) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RelayMiningDifficulty) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RelayMiningDifficulty) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TargetHash) > 0 { + i -= len(m.TargetHash) + copy(dAtA[i:], m.TargetHash) + i = encodeVarintRelayMiningDifficulty(dAtA, i, uint64(len(m.TargetHash))) + i-- + dAtA[i] = 0x22 + } + if m.NumRelaysEma != 0 { + i = encodeVarintRelayMiningDifficulty(dAtA, i, uint64(m.NumRelaysEma)) + i-- + dAtA[i] = 0x18 + } + if m.BlockHeight != 0 { + i = encodeVarintRelayMiningDifficulty(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x10 + } + if len(m.ServiceId) > 0 { + i -= len(m.ServiceId) + copy(dAtA[i:], m.ServiceId) + i = encodeVarintRelayMiningDifficulty(dAtA, i, uint64(len(m.ServiceId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintRelayMiningDifficulty(dAtA []byte, offset int, v uint64) int { + offset -= sovRelayMiningDifficulty(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *RelayMiningDifficulty) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ServiceId) + if l > 0 { + n += 1 + l + sovRelayMiningDifficulty(uint64(l)) + } + if m.BlockHeight != 0 { + n += 1 + sovRelayMiningDifficulty(uint64(m.BlockHeight)) + } + if m.NumRelaysEma != 0 { + n += 1 + sovRelayMiningDifficulty(uint64(m.NumRelaysEma)) + } + l = len(m.TargetHash) + if l > 0 { + n += 1 + l + sovRelayMiningDifficulty(uint64(l)) + } + return n +} + +func sovRelayMiningDifficulty(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozRelayMiningDifficulty(x uint64) (n int) { + return sovRelayMiningDifficulty(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *RelayMiningDifficulty) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRelayMiningDifficulty + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RelayMiningDifficulty: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RelayMiningDifficulty: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ServiceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRelayMiningDifficulty + } + 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 ErrInvalidLengthRelayMiningDifficulty + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRelayMiningDifficulty + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ServiceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) + } + m.BlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRelayMiningDifficulty + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumRelaysEma", wireType) + } + m.NumRelaysEma = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRelayMiningDifficulty + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumRelaysEma |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TargetHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRelayMiningDifficulty + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthRelayMiningDifficulty + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthRelayMiningDifficulty + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TargetHash = append(m.TargetHash[:0], dAtA[iNdEx:postIndex]...) + if m.TargetHash == nil { + m.TargetHash = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRelayMiningDifficulty(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRelayMiningDifficulty + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipRelayMiningDifficulty(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowRelayMiningDifficulty + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowRelayMiningDifficulty + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowRelayMiningDifficulty + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthRelayMiningDifficulty + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupRelayMiningDifficulty + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthRelayMiningDifficulty + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthRelayMiningDifficulty = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowRelayMiningDifficulty = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupRelayMiningDifficulty = fmt.Errorf("proto: unexpected end of group") +) From 6f2fe5b6ecb2db74572ecc32e8fbd6e3b9dc2461 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Tue, 28 May 2024 13:46:17 -0700 Subject: [PATCH 2/5] [Relay Mining] Relay Mining math helpers (#549) Baseline for the math behind relay mining. Adding the following two files: ```bash x/tokenomics/keeper/update_relay_mining_difficulty.go x/tokenomics/keeper/update_relay_mining_difficulty_test.go ``` Also adding an experimental `.prompts` file based on this - https://docs.continue.dev/walkthroughs/prompt-files - https://marketplace.visualstudio.com/items?itemName=Continue.continue --- Co-authored-by: Redouane Lakrache --- .prompts/test_suggestions.prompt | 15 + .prompts/unit_tests.prompt | 17 ++ e2e/tests/update_params.feature | 18 +- .../keeper/update_relay_mining_difficulty.go | 153 ++++++++++ .../update_relay_mining_difficulty_test.go | 288 ++++++++++++++++++ x/tokenomics/types/errors.go | 37 +-- 6 files changed, 502 insertions(+), 26 deletions(-) create mode 100644 .prompts/test_suggestions.prompt create mode 100644 .prompts/unit_tests.prompt create mode 100644 x/tokenomics/keeper/update_relay_mining_difficulty.go create mode 100644 x/tokenomics/keeper/update_relay_mining_difficulty_test.go diff --git a/.prompts/test_suggestions.prompt b/.prompts/test_suggestions.prompt new file mode 100644 index 000000000..b5eeb78e3 --- /dev/null +++ b/.prompts/test_suggestions.prompt @@ -0,0 +1,15 @@ +temperature: 0.5 +maxTokens: 4096 +--- + +You are a principal software engineer. + + +{{{ input }}} + +You have been provided two files: +1. A source code file +2. A unit test file + +Please provide a list of unit test names/descriptions that you believe +are still missing. Do not actually implement them. \ No newline at end of file diff --git a/.prompts/unit_tests.prompt b/.prompts/unit_tests.prompt new file mode 100644 index 000000000..e089d6441 --- /dev/null +++ b/.prompts/unit_tests.prompt @@ -0,0 +1,17 @@ +temperature: 0.5 +maxTokens: 4096 +--- + +You are a principal software engineer. + + +{{{ input }}} + +Write unit tests for the code selected., following each of these instructions: +- Follow the best and latests practices of golang +- Where appropriate use `github.com/stretchr/testify/require` +- If necessary, create a tests struct to iterate over: `tests := []struct { +- Include at least 2 edge cases and 5 core cases +- The tests should be complete and sophisticated +- Give the tests just as chat output, don't edit any file +- Just give the code, no need for an explanation \ No newline at end of file diff --git a/e2e/tests/update_params.feature b/e2e/tests/update_params.feature index b7a43547d..57499f3a2 100644 --- a/e2e/tests/update_params.feature +++ b/e2e/tests/update_params.feature @@ -1,14 +1,16 @@ Feature: Params Namespace # TODO_DOCUMENT(@Olshansk): Document all of the on-chain governance parameters. - Scenario: An unauthorized user cannot update a module params - Given the user has the pocketd binary installed - And all "tokenomics" module params are set to their default values - And an authz grant from the "gov" "module" account to the "pnf" "user" account for the "/poktroll.tokenomics.MsgUpdateParams" message exists - When the "unauthorized" account sends an authz exec message to update all "tokenomics" module params - | name | value | type | - | compute_units_to_tokens_multiplier | 666 | int64 | - Then all "tokenomics" module params should be set to their default values + Background: + + Scenario: An unauthorized user cannot update a module params + Given the user has the pocketd binary installed + And all "tokenomics" module params are set to their default values + And an authz grant from the "gov" "module" account to the "pnf" "user" account for the "/poktroll.tokenomics.MsgUpdateParams" message exists + When the "unauthorized" account sends an authz exec message to update all "tokenomics" module params + | name | value | type | + | compute_units_to_tokens_multiplier | 666 | int64 | + Then all "tokenomics" module params should be set to their default values # NB: If you are reading this and the tokenomics module has parameters # that are not being updated in this test, please update the test. diff --git a/x/tokenomics/keeper/update_relay_mining_difficulty.go b/x/tokenomics/keeper/update_relay_mining_difficulty.go new file mode 100644 index 000000000..07ca79319 --- /dev/null +++ b/x/tokenomics/keeper/update_relay_mining_difficulty.go @@ -0,0 +1,153 @@ +package keeper + +import ( + "context" + "fmt" + "math" + + sdk "github.com/cosmos/cosmos-sdk/types" + + proofkeeper "github.com/pokt-network/poktroll/x/proof/keeper" + prooftypes "github.com/pokt-network/poktroll/x/proof/types" + "github.com/pokt-network/poktroll/x/tokenomics/types" +) + +const ( + // Exponential moving average (ema) smoothing factor, commonly known as alpha. + // Usually, alpha = 2 / (N+1), where N is the number of periods. + // Large alpha -> more weight on recent data; less smoothing and fast response. + // Small alpha -> more weight on past data; more smoothing and slow response. + emaSmoothingFactor = float64(0.1) + + // The target number of relays we want the network to mine for a specific + // service across all applications & suppliers per session. + // This number determines the total number of leafs to be created across in + // the off-chain SMTs, across all suppliers, for each service. + // It indirectly drives the off-chain resource requirements of the network + // in additional to playing a critical role in Relay Mining. + // TODO_UPNEXT(#542, @Olshansk): Make this a governance parameter. + TargetNumRelays = uint64(10e4) +) + +// UpdateRelayMiningDifficulty updates the on-chain relay mining difficulty +// based on the amount of on-chain relays for each service, given a map of serviceId->numRelays. +func (k Keeper) UpdateRelayMiningDifficulty( + ctx context.Context, + relaysPerServiceMap map[string]uint64, +) error { + logger := k.Logger().With("method", "UpdateRelayMiningDifficulty") + sdkCtx := sdk.UnwrapSDKContext(ctx) + + for serviceId, numRelays := range relaysPerServiceMap { + prevDifficulty, found := k.GetRelayMiningDifficulty(ctx, serviceId) + if !found { + types.ErrTokenomicsMissingRelayMiningDifficulty.Wrapf("No previous relay mining difficulty found for service %s. Initializing with default difficulty %v", serviceId, prevDifficulty.TargetHash) + // If a previous difficulty for the service is not found, we initialize + // it with a default. + prevDifficulty = types.RelayMiningDifficulty{ + ServiceId: serviceId, + BlockHeight: sdkCtx.BlockHeight(), + NumRelaysEma: numRelays, + TargetHash: defaultDifficultyTargetHash(), + } + } + + // TODO_CONSIDERATION: We could potentially compute the smoothing factor + // using a common formula, such as alpha = 2 / (N+1), where N is the number + // of periods. + // N := ctx.BlockHeight() - prevDifficulty.BlockHeight + // alpha := 2 / (1 + N) + alpha := emaSmoothingFactor + + // Compute the updated EMA of the number of relays. + prevRelaysEma := prevDifficulty.NumRelaysEma + newRelaysEma := computeEma(alpha, prevRelaysEma, numRelays) + difficultyHash := ComputeNewDifficultyTargetHash(TargetNumRelays, newRelaysEma) + newDifficulty := types.RelayMiningDifficulty{ + ServiceId: serviceId, + BlockHeight: sdkCtx.BlockHeight(), + NumRelaysEma: newRelaysEma, + TargetHash: difficultyHash, + } + k.SetRelayMiningDifficulty(ctx, newDifficulty) + + // TODO_UPNEXT(#542, @Olshansk): Emit an event for the updated difficulty. + logger.Info(fmt.Sprintf("Updated relay mining difficulty for service %s at height %d from %v to %v", serviceId, sdkCtx.BlockHeight(), prevDifficulty.TargetHash, newDifficulty.TargetHash)) + + } + return nil +} + +// ComputeNewDifficultyTargetHash computes the new difficulty target hash based +// on the target number of relays we want the network to mine and the new EMA of +// the number of relays. +// NB: Exported for testing purposes only. +func ComputeNewDifficultyTargetHash(targetNumRelays, newRelaysEma uint64) []byte { + // The target number of relays we want the network to mine is greater than + // the actual on-chain relays, so we don't need to scale to anything above + // the default. + if targetNumRelays > newRelaysEma { + return defaultDifficultyTargetHash() + } + + log2 := func(x float64) float64 { + return math.Log(x) / math.Ln2 + } + + // We are dealing with a bitwise binary distribution, and are trying to convert + // the proportion of an off-chain relay (i.e. relayEMA) to an + // on-chain relay (i.e. target) based on the probability of x leading zeros + // in the target hash. + // + // In other words, the probability of an off-chain relay moving into the tree + // should equal (approximately) the probability of having x leading zeroes + // in the target hash. + // + // The construction is as follows: + // (0.5)^num_leading_zeroes = (num_target_relay / num_total_relays) + // (0.5)^x = (T/R) + // x = -ln2(T/R) + numLeadingZeroBits := int(-log2(float64(targetNumRelays) / float64(newRelaysEma))) + numBytes := proofkeeper.SmtSpec.PathHasherSize() + return LeadingZeroBitsToTargetDifficultyHash(numLeadingZeroBits, numBytes) +} + +// defaultDifficultyTargetHash returns the default difficulty target hash with +// the default number of leading zero bits. +func defaultDifficultyTargetHash() []byte { + numBytes := proofkeeper.SmtSpec.PathHasherSize() + numDefaultLeadingZeroBits := int(prooftypes.DefaultMinRelayDifficultyBits) + return LeadingZeroBitsToTargetDifficultyHash(numDefaultLeadingZeroBits, numBytes) +} + +// computeEma computes the EMA at time t, given the EMA at time t-1, the raw +// data revealed at time t, and the smoothing factor α. +// Src: https://en.wikipedia.org/wiki/Exponential_smoothing +func computeEma(alpha float64, prevEma, currValue uint64) uint64 { + return uint64(alpha*float64(currValue) + (1-alpha)*float64(prevEma)) +} + +// LeadingZeroBitsToTargetDifficultyHash generates a slice of bytes with the specified number of leading zero bits +// NB: Exported for testing purposes only. +func LeadingZeroBitsToTargetDifficultyHash(numLeadingZeroBits int, numBytes int) []byte { + targetDifficultyHah := make([]byte, numBytes) + + // Set everything to 1s initially + for i := range targetDifficultyHah { + targetDifficultyHah[i] = 0xff + } + + // Set full zero bytes + fullZeroBytes := numLeadingZeroBits / 8 + for i := 0; i < fullZeroBytes; i++ { + targetDifficultyHah[i] = 0 + } + + // Set remaining bits in the next byte + remainingZeroBits := numLeadingZeroBits % 8 + if remainingZeroBits > 0 { + targetDifficultyHah[fullZeroBytes] = byte(0xff >> remainingZeroBits) + } + + return targetDifficultyHah +} diff --git a/x/tokenomics/keeper/update_relay_mining_difficulty_test.go b/x/tokenomics/keeper/update_relay_mining_difficulty_test.go new file mode 100644 index 000000000..1c89e2b74 --- /dev/null +++ b/x/tokenomics/keeper/update_relay_mining_difficulty_test.go @@ -0,0 +1,288 @@ +package keeper_test + +import ( + "bytes" + "testing" + + "github.com/stretchr/testify/require" + + keepertest "github.com/pokt-network/poktroll/testutil/keeper" + "github.com/pokt-network/poktroll/x/tokenomics/keeper" + tokenomicskeeper "github.com/pokt-network/poktroll/x/tokenomics/keeper" + "github.com/pokt-network/poktroll/x/tokenomics/types" +) + +func TestUpdateRelayMiningDifficulty_General(t *testing.T) { + keeper, ctx := keepertest.TokenomicsKeeper(t) + + // Introduce svc1 for the first time + relaysPerServiceMap := map[string]uint64{ + "svc1": 1e3, // new service + } + err := keeper.UpdateRelayMiningDifficulty(ctx, relaysPerServiceMap) + require.NoError(t, err) + + // The first time svc1 difficulty is updated, the relay EMA will be equal + // to the first value provided. + difficultySvc11, found := keeper.GetRelayMiningDifficulty(ctx, "svc1") + require.True(t, found) + require.Equal(t, uint64(1e3), difficultySvc11.NumRelaysEma) + + // Update svc1 and introduce svc2 for the first time + relaysPerServiceMap = map[string]uint64{ + "svc1": 1e10, // higher than the first value above + "svc2": 1e5, // new service + } + err = keeper.UpdateRelayMiningDifficulty(ctx, relaysPerServiceMap) + require.NoError(t, err) + + difficultySvc12, found := keeper.GetRelayMiningDifficulty(ctx, "svc1") + require.True(t, found) + // Verify that the svc1 relay ema is strictly higher than the first value + // above, but strictly lower than the second value because of the rolling average. + require.Greater(t, difficultySvc12.NumRelaysEma, difficultySvc11.NumRelaysEma) + require.Less(t, difficultySvc12.NumRelaysEma, uint64(1e10)) + // Because the number of relays went up, there are more leading zeroes in the + // target hash, so the number is lower than it was before. + require.Less(t, difficultySvc12.TargetHash, difficultySvc11.TargetHash) + + // The first time svc2 difficulty is updated, so the num relays ema is + // equal to the first value provided. + difficultySvc21, found := keeper.GetRelayMiningDifficulty(ctx, "svc2") + require.True(t, found) + require.Equal(t, uint64(1e5), difficultySvc21.NumRelaysEma) + + // Update svc1 and svc2 and introduce svc3 for the first time + relaysPerServiceMap = map[string]uint64{ + "svc1": 1e12, // higher than the second value above + "svc2": 1e2, // lower than the first value above + "svc3": 1e10, // new service + } + err = keeper.UpdateRelayMiningDifficulty(ctx, relaysPerServiceMap) + require.NoError(t, err) + + // svc1 relays went up so the target hash is now a smaller number (more leading zeroes) + // because the difficulty is higher. + difficultySvc13, found := keeper.GetRelayMiningDifficulty(ctx, "svc1") + require.True(t, found) + require.Greater(t, difficultySvc13.NumRelaysEma, difficultySvc12.NumRelaysEma) + require.Less(t, difficultySvc13.TargetHash, difficultySvc12.TargetHash) + + // svc2 relay ema went down so the target hash is now a larger number (less leading zeroes) + difficultySvc22, found := keeper.GetRelayMiningDifficulty(ctx, "svc2") + require.True(t, found) + require.Less(t, difficultySvc22.NumRelaysEma, difficultySvc21.NumRelaysEma) + // Since the relays EMA is lower than the target, the difficulty hash is all 1s + require.Less(t, difficultySvc22.NumRelaysEma, tokenomicskeeper.TargetNumRelays) + require.Equal(t, difficultySvc22.TargetHash, makeBytesFullOfOnes(32)) + + // svc3 is new so the relay ema is equal to the first value provided + difficultySvc31, found := keeper.GetRelayMiningDifficulty(ctx, "svc3") + require.True(t, found) + require.Equal(t, uint64(1e10), difficultySvc31.NumRelaysEma) +} + +func TestUpdateRelayMiningDifficulty_FirstDifficulty(t *testing.T) { + tests := []struct { + desc string + numRelays uint64 + expectedRelayMiningDifficulty types.RelayMiningDifficulty + }{ + { + desc: "First Difficulty way below target", + numRelays: keeper.TargetNumRelays / 1e3, + expectedRelayMiningDifficulty: types.RelayMiningDifficulty{ + ServiceId: "svc1", + BlockHeight: 1, + NumRelaysEma: keeper.TargetNumRelays / 1e3, + TargetHash: defaultDifficulty(), // default difficulty without any leading 0 bits + }, + }, { + desc: "First Difficulty equal to target", + numRelays: keeper.TargetNumRelays, + expectedRelayMiningDifficulty: types.RelayMiningDifficulty{ + ServiceId: "svc1", + BlockHeight: 1, + NumRelaysEma: keeper.TargetNumRelays, + TargetHash: defaultDifficulty(), // default difficulty without any leading 0 bits + }, + }, { + desc: "First Difficulty way above target", + numRelays: keeper.TargetNumRelays * 1e3, + expectedRelayMiningDifficulty: types.RelayMiningDifficulty{ + ServiceId: "svc1", + BlockHeight: 1, + NumRelaysEma: keeper.TargetNumRelays * 1e3, + TargetHash: append( + []byte{0b00000000, 0b01111111}, // 9 leading 0 bits + makeBytesFullOfOnes(30)..., + ), + }, + }, + } + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + keeper, ctx := keepertest.TokenomicsKeeper(t) + relaysPerServiceMap := map[string]uint64{ + "svc1": tt.numRelays, + } + err := keeper.UpdateRelayMiningDifficulty(ctx, relaysPerServiceMap) + require.NoError(t, err) + + difficulty, found := keeper.GetRelayMiningDifficulty(ctx, "svc1") + require.True(t, found) + + require.Equal(t, difficulty.NumRelaysEma, tt.numRelays) + require.Equal(t, difficulty.NumRelaysEma, tt.expectedRelayMiningDifficulty.NumRelaysEma) + + require.Equal(t, difficulty.TargetHash, tt.expectedRelayMiningDifficulty.TargetHash) + }) + } +} + +func TestComputeNewDifficultyHash(t *testing.T) { + tests := []struct { + desc string + numRelaysTarget uint64 + relaysEma uint64 + expectedDifficultyHash []byte + }{ + { + desc: "Relays Target > Relays EMA", + numRelaysTarget: 100, + relaysEma: 50, + expectedDifficultyHash: defaultDifficulty(), + }, + { + desc: "Relays Target == Relays EMA", + numRelaysTarget: 100, + relaysEma: 100, + expectedDifficultyHash: defaultDifficulty(), + }, + { + desc: "Relays Target < Relays EMA", + numRelaysTarget: 50, + relaysEma: 100, + expectedDifficultyHash: append( + []byte{0b01111111}, + makeBytesFullOfOnes(31)..., + ), + }, + { + desc: "Relays Target << Relays EMA", + numRelaysTarget: 50, + relaysEma: 200, + expectedDifficultyHash: append( + []byte{0b00111111}, + makeBytesFullOfOnes(31)..., + ), + }, + { + desc: "Relays Target << Relays EMA", + numRelaysTarget: 50, + relaysEma: 1000, + expectedDifficultyHash: append( + []byte{0b00001111}, + makeBytesFullOfOnes(31)..., + ), + }, + { + desc: "Relays Target << Relays EMA", + numRelaysTarget: 50, + relaysEma: 10000, + expectedDifficultyHash: append( + []byte{0b00000001}, + makeBytesFullOfOnes(31)..., + ), + }, + } + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + result := keeper.ComputeNewDifficultyTargetHash(tt.numRelaysTarget, tt.relaysEma) + require.Equal(t, result, tt.expectedDifficultyHash) + }) + } +} + +func TestLeadingZeroBitsToTargetDifficultyHash(t *testing.T) { + tests := []struct { + desc string + numLeadingZeroBits int + numBytes int + expectedDifficultyHash []byte + }{ + { + desc: "0 leading 0 bits in 1 byte", + numLeadingZeroBits: 0, + numBytes: 1, + expectedDifficultyHash: []byte{0b11111111}, + }, + { + desc: "full zero bytes (16 leading 0 bits in 32 bytes)", + numLeadingZeroBits: 16, + numBytes: 32, + expectedDifficultyHash: append( + []byte{0b00000000, 0b00000000}, + makeBytesFullOfOnes(30)..., + ), + }, + { + desc: "partial byte (20 leading 0 bits in 32 bytes)", + numLeadingZeroBits: 20, + numBytes: 32, + expectedDifficultyHash: append( + []byte{0b00000000, 0b00000000, 0b00001111}, + makeBytesFullOfOnes(29)..., + ), + }, + { + desc: "another partial byte (10 leading 0 bits in 32 bytes)", + numLeadingZeroBits: 10, + numBytes: 32, + expectedDifficultyHash: append( + []byte{0b00000000, 0b00111111}, + makeBytesFullOfOnes(30)..., + ), + }, + { + desc: "edge case 1 bit (1 leading 0 bits in 32 bytes)", + numLeadingZeroBits: 1, + numBytes: 32, + expectedDifficultyHash: append( + []byte{0b01111111}, + makeBytesFullOfOnes(31)..., + ), + }, + { + desc: "exact byte boundary (24 leading 0 bits in 32 bytes)", + numLeadingZeroBits: 24, + numBytes: 32, + expectedDifficultyHash: append( + []byte{0b00000000, 0b00000000, 0b00000000}, + makeBytesFullOfOnes(29)..., + ), + }, + } + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + result := keeper.LeadingZeroBitsToTargetDifficultyHash(tt.numLeadingZeroBits, tt.numBytes) + if !bytes.Equal(result, tt.expectedDifficultyHash) { + t.Errorf("got %x, expected %x", result, tt.expectedDifficultyHash) + } + }) + } +} + +func makeBytesFullOfOnes(length int) []byte { + result := make([]byte, length) + for i := range result { + result[i] = 0b11111111 + } + return result +} + +func defaultDifficulty() []byte { + return makeBytesFullOfOnes(32) +} diff --git a/x/tokenomics/types/errors.go b/x/tokenomics/types/errors.go index a9a6dfe7e..d2f45037c 100644 --- a/x/tokenomics/types/errors.go +++ b/x/tokenomics/types/errors.go @@ -6,22 +6,23 @@ import sdkerrors "cosmossdk.io/errors" // x/tokenomics module sentinel errors var ( - ErrTokenomicsInvalidSigner = sdkerrors.Register(ModuleName, 1100, "the provided authority address does not match the on-chain governance address") - ErrTokenomicsAddressInvalid = sdkerrors.Register(ModuleName, 1101, "the provided authority address is not a valid bech32 address") - ErrTokenomicsClaimNil = sdkerrors.Register(ModuleName, 1102, "provided claim is nil") - ErrTokenomicsSessionHeaderNil = sdkerrors.Register(ModuleName, 1103, "provided claim's session header is nil") - ErrTokenomicsSessionHeaderInvalid = sdkerrors.Register(ModuleName, 1104, "provided claim's session header is invalid") - ErrTokenomicsSupplierModuleMintFailed = sdkerrors.Register(ModuleName, 1105, "failed to mint uPOKT to supplier module account") - ErrTokenomicsSupplierRewardFailed = sdkerrors.Register(ModuleName, 1106, "failed to send uPOKT from supplier module account to supplier") - ErrTokenomicsSupplierAddressInvalid = sdkerrors.Register(ModuleName, 1107, "the supplier address in the claim is not a valid bech32 address") - ErrTokenomicsApplicationNotFound = sdkerrors.Register(ModuleName, 1108, "application not found") - ErrTokenomicsApplicationModuleBurn = sdkerrors.Register(ModuleName, 1109, "failed to burn uPOKT from application module account") - ErrTokenomicsApplicationAddressInvalid = sdkerrors.Register(ModuleName, 1112, "the application address in the claim is not a valid bech32 address") - ErrTokenomicsParamsInvalid = sdkerrors.Register(ModuleName, 1113, "provided params are invalid") - ErrTokenomicsRootHashInvalid = sdkerrors.Register(ModuleName, 1114, "the root hash in the claim is invalid") - ErrTokenomicsApplicationNewStakeInvalid = sdkerrors.Register(ModuleName, 1115, "application stake cannot be reduced to a -ve amount") - ErrTokenomicsParamNameInvalid = sdkerrors.Register(ModuleName, 1116, "the provided param name is invalid") - ErrTokenomicsParamInvalid = sdkerrors.Register(ModuleName, 1117, "the provided param is invalid") - ErrTokenomicsUnmarshalInvalid = sdkerrors.Register(ModuleName, 1118, "failed to unmarshal the provided bytes") - ErrTokenomicsDuplicateIndex = sdkerrors.Register(ModuleName, 1119, "cannot have a duplicate index") + ErrTokenomicsInvalidSigner = sdkerrors.Register(ModuleName, 1100, "the provided authority address does not match the on-chain governance address") + ErrTokenomicsAddressInvalid = sdkerrors.Register(ModuleName, 1101, "the provided authority address is not a valid bech32 address") + ErrTokenomicsClaimNil = sdkerrors.Register(ModuleName, 1102, "provided claim is nil") + ErrTokenomicsSessionHeaderNil = sdkerrors.Register(ModuleName, 1103, "provided claim's session header is nil") + ErrTokenomicsSessionHeaderInvalid = sdkerrors.Register(ModuleName, 1104, "provided claim's session header is invalid") + ErrTokenomicsSupplierModuleMintFailed = sdkerrors.Register(ModuleName, 1105, "failed to mint uPOKT to supplier module account") + ErrTokenomicsSupplierRewardFailed = sdkerrors.Register(ModuleName, 1106, "failed to send uPOKT from supplier module account to supplier") + ErrTokenomicsSupplierAddressInvalid = sdkerrors.Register(ModuleName, 1107, "the supplier address in the claim is not a valid bech32 address") + ErrTokenomicsApplicationNotFound = sdkerrors.Register(ModuleName, 1108, "application not found") + ErrTokenomicsApplicationModuleBurn = sdkerrors.Register(ModuleName, 1109, "failed to burn uPOKT from application module account") + ErrTokenomicsApplicationAddressInvalid = sdkerrors.Register(ModuleName, 1112, "the application address in the claim is not a valid bech32 address") + ErrTokenomicsParamsInvalid = sdkerrors.Register(ModuleName, 1113, "provided params are invalid") + ErrTokenomicsRootHashInvalid = sdkerrors.Register(ModuleName, 1114, "the root hash in the claim is invalid") + ErrTokenomicsApplicationNewStakeInvalid = sdkerrors.Register(ModuleName, 1115, "application stake cannot be reduced to a -ve amount") + ErrTokenomicsParamNameInvalid = sdkerrors.Register(ModuleName, 1116, "the provided param name is invalid") + ErrTokenomicsParamInvalid = sdkerrors.Register(ModuleName, 1117, "the provided param is invalid") + ErrTokenomicsUnmarshalInvalid = sdkerrors.Register(ModuleName, 1118, "failed to unmarshal the provided bytes") + ErrTokenomicsDuplicateIndex = sdkerrors.Register(ModuleName, 1119, "cannot have a duplicate index") + ErrTokenomicsMissingRelayMiningDifficulty = sdkerrors.Register(ModuleName, 1120, "missing relay mining difficulty") ) From a58e5534b5d1e60ec86a810f6c1692a57c881160 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 29 May 2024 09:41:22 +0200 Subject: [PATCH 3/5] refactor: rename methods which use default shared params with suffix `WithDefaultParams` --- .../tests/relays_stress_helpers_test.go | 10 +++---- pkg/crypto/rings/client.go | 2 +- testutil/keeper/application.go | 2 +- .../testqueryclients/sessionquerier.go | 6 ++-- testutil/testproxy/relayerproxy.go | 4 +-- ...msg_server_undelegate_from_gateway_test.go | 16 +++++----- .../keeper/msg_server_create_claim_test.go | 2 +- x/proof/keeper/proof_test.go | 2 +- x/proof/module/helpers_test.go | 6 ++-- x/proof/types/message_submit_proof_test.go | 8 ++--- x/session/keeper/session_hydrator.go | 8 ++--- x/shared/session.go | 30 ++++++++++--------- x/tokenomics/keeper/keeper_test.go | 2 +- .../keeper/settle_session_accounting_test.go | 6 ++-- 14 files changed, 53 insertions(+), 51 deletions(-) diff --git a/load-testing/tests/relays_stress_helpers_test.go b/load-testing/tests/relays_stress_helpers_test.go index 7461c4a05..8acb4dc42 100644 --- a/load-testing/tests/relays_stress_helpers_test.go +++ b/load-testing/tests/relays_stress_helpers_test.go @@ -173,9 +173,9 @@ func (s *relaysSuite) mapSessionInfoForLoadTestDurationFn( sessionInfo := &sessionInfoNotif{ blockHeight: blockHeight, - sessionNumber: shared.GetDefaultSessionNumber(blockHeight), - sessionStartBlockHeight: shared.GetDefaultSessionStartHeight(blockHeight), - sessionEndBlockHeight: shared.GetDefaultSessionEndHeight(blockHeight), + sessionNumber: shared.GetSessionNumberWithDefaultParams(blockHeight), + sessionStartBlockHeight: shared.GetSessionStartHeightWithDefaultParams(blockHeight), + sessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(blockHeight), } infoLogger := logger.Info(). @@ -720,7 +720,7 @@ func (plan *actorLoadTestIncrementPlan) shouldIncrementActorCount( return false } - initialSessionNumber := shared.GetDefaultSessionNumber(startBlockHeight) + initialSessionNumber := shared.GetSessionNumberWithDefaultParams(startBlockHeight) // TODO_TECHDEBT(#21): replace with gov param query when available. actorSessionIncRate := plan.blocksPerIncrement / shared.NumBlocksPerSession nextSessionNumber := sessionInfo.sessionNumber + 1 - initialSessionNumber @@ -746,7 +746,7 @@ func (plan *actorLoadTestIncrementPlan) shouldIncrementSupplierCount( return false } - initialSessionNumber := shared.GetDefaultSessionNumber(startBlockHeight) + initialSessionNumber := shared.GetSessionNumberWithDefaultParams(startBlockHeight) // TODO_TECHDEBT(#21): replace with gov param query when available. supplierSessionIncRate := plan.blocksPerIncrement / shared.NumBlocksPerSession nextSessionNumber := sessionInfo.sessionNumber + 1 - initialSessionNumber diff --git a/pkg/crypto/rings/client.go b/pkg/crypto/rings/client.go index f1ae648c9..b494c4892 100644 --- a/pkg/crypto/rings/client.go +++ b/pkg/crypto/rings/client.go @@ -265,7 +265,7 @@ func (rc *ringClient) getRingPointsForAddressAtHeight( // gateways that have been undelegated after the target session end height. func GetRingAddressesAtBlock(app *apptypes.Application, blockHeight int64) []string { // Get the target session end height at which we want to get the active delegations. - targetSessionEndHeight := uint64(shared.GetDefaultSessionEndHeight(blockHeight)) + targetSessionEndHeight := uint64(shared.GetSessionEndHeightWithDefaultParams(blockHeight)) // Get the current active delegations for the application and use them as a base. activeDelegationsAtHeight := app.DelegateeGatewayAddresses diff --git a/testutil/keeper/application.go b/testutil/keeper/application.go index 55a3ed501..6680497d3 100644 --- a/testutil/keeper/application.go +++ b/testutil/keeper/application.go @@ -77,7 +77,7 @@ func ApplicationKeeper(t testing.TB) (keeper.Keeper, context.Context) { AnyTimes() mockSharedKeeper.EXPECT().GetSessionEndHeight(gomock.Any(), gomock.Any()). DoAndReturn(func(_ context.Context, queryHeight int64) int64 { - return shared.GetDefaultSessionEndHeight(queryHeight) + return shared.GetSessionEndHeightWithDefaultParams(queryHeight) }). AnyTimes() diff --git a/testutil/testclient/testqueryclients/sessionquerier.go b/testutil/testclient/testqueryclients/sessionquerier.go index 1960d5a99..1b0c3c992 100644 --- a/testutil/testclient/testqueryclients/sessionquerier.go +++ b/testutil/testclient/testqueryclients/sessionquerier.go @@ -80,11 +80,11 @@ func AddToExistingSessions( Service: &sharedtypes.Service{Id: serviceId}, ApplicationAddress: appAddress, SessionId: sessionId, - SessionStartBlockHeight: shared.GetDefaultSessionStartHeight(blockHeight), - SessionEndBlockHeight: shared.GetDefaultSessionEndHeight(blockHeight), + SessionStartBlockHeight: shared.GetSessionStartHeightWithDefaultParams(blockHeight), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(blockHeight), }, NumBlocksPerSession: shared.NumBlocksPerSession, - SessionNumber: shared.GetDefaultSessionNumber(blockHeight), + SessionNumber: shared.GetSessionNumberWithDefaultParams(blockHeight), SessionId: sessionId, Suppliers: []*sharedtypes.Supplier{}, } diff --git a/testutil/testproxy/relayerproxy.go b/testutil/testproxy/relayerproxy.go index c6ef9efb1..19eaa905d 100644 --- a/testutil/testproxy/relayerproxy.go +++ b/testutil/testproxy/relayerproxy.go @@ -409,8 +409,8 @@ func GenerateRelayRequest( ApplicationAddress: appAddress, SessionId: string(sessionId[:]), Service: &sharedtypes.Service{Id: serviceId}, - SessionStartBlockHeight: shared.GetDefaultSessionStartHeight(blockHeight), - SessionEndBlockHeight: shared.GetDefaultSessionEndHeight(blockHeight), + SessionStartBlockHeight: shared.GetSessionStartHeightWithDefaultParams(blockHeight), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(blockHeight), }, // The returned relay is unsigned and must be signed elsewhere for functionality Signature: []byte(""), diff --git a/x/application/keeper/msg_server_undelegate_from_gateway_test.go b/x/application/keeper/msg_server_undelegate_from_gateway_test.go index b6030cd2c..224b8f3c9 100644 --- a/x/application/keeper/msg_server_undelegate_from_gateway_test.go +++ b/x/application/keeper/msg_server_undelegate_from_gateway_test.go @@ -316,7 +316,7 @@ func TestMsgServer_UndelegateFromGateway_DelegationIsActiveUntilNextSession(t *t // Verify that the gateway is added to the pending undelegation list with the // right sessionEndHeight as the map key. - sessionEndHeight := uint64(shared.GetDefaultSessionEndHeight(undelegationHeight)) + sessionEndHeight := uint64(shared.GetSessionEndHeightWithDefaultParams(undelegationHeight)) require.Contains(t, app.PendingUndelegations[sessionEndHeight].GatewayAddresses, pendingUndelegateFromAddr, @@ -384,7 +384,7 @@ func TestMsgServer_UndelegateFromGateway_DelegationIsPrunedAfterRetentionPeriod( // Verify that the the pending undelegation map no longer contains the // sessionEndHeight key. - sessionEndHeight := uint64(shared.GetDefaultSessionEndHeight(undelegationHeight)) + sessionEndHeight := uint64(shared.GetSessionEndHeightWithDefaultParams(undelegationHeight)) require.Empty(t, app.PendingUndelegations[sessionEndHeight]) // Verify that the reconstructed delegatee gateway list can no longer include @@ -423,7 +423,7 @@ func TestMsgServer_UndelegateFromGateway_RedelegationAfterUndelegationAtTheSameS // Verify that the gateway is also present in the pending undelegation list with the // right sessionEndHeight as the map key. - sessionEndHeight := uint64(shared.GetDefaultSessionEndHeight(undelegationHeight)) + sessionEndHeight := uint64(shared.GetSessionEndHeightWithDefaultParams(undelegationHeight)) require.Contains(t, app.PendingUndelegations[sessionEndHeight].GatewayAddresses, gatewayAddrToRedelegate, @@ -533,15 +533,15 @@ func createAppStakeDelegateAndUndelegate( // getUndelegationPruningBlockHeight returns the block height at which undelegations // should be pruned for a given undlegation block height. func getUndelegationPruningBlockHeight(blockHeight int64) (pruningHeihgt int64) { - nextSessionStartHeight := shared.GetDefaultSessionEndHeight(blockHeight) + 1 + nextSessionStartHeight := shared.GetSessionEndHeightWithDefaultParams(blockHeight) + 1 - return nextSessionStartHeight + getDefaultNumBlocksUndelegationRetention() + return nextSessionStartHeight + getNumBlocksUndelegationRetentionWithDefaultParams() } -// getNumBlocksUndelegationRetention returns the number of blocks for which -// undelegations should be kept before being pruned, given the default shared +// getNumBlocksUndelegationRetentionWithDefaultParams returns the number of blocks for +// which undelegations should be kept before being pruned, given the default shared // module parameters. -func getDefaultNumBlocksUndelegationRetention() int64 { +func getNumBlocksUndelegationRetentionWithDefaultParams() int64 { sharedParams := sharedtypes.DefaultParams() return keeper.GetNumBlocksUndelegationRetention(&sharedParams) } diff --git a/x/proof/keeper/msg_server_create_claim_test.go b/x/proof/keeper/msg_server_create_claim_test.go index bb6a303ae..170f6cbd1 100644 --- a/x/proof/keeper/msg_server_create_claim_test.go +++ b/x/proof/keeper/msg_server_create_claim_test.go @@ -300,7 +300,7 @@ func newTestClaimMsg( Service: service, SessionId: sessionId, SessionStartBlockHeight: sessionStartHeight, - SessionEndBlockHeight: shared.GetDefaultSessionEndHeight(sessionStartHeight), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(sessionStartHeight), }, merkleRoot, ) diff --git a/x/proof/keeper/proof_test.go b/x/proof/keeper/proof_test.go index 82aab9aa3..13c578f82 100644 --- a/x/proof/keeper/proof_test.go +++ b/x/proof/keeper/proof_test.go @@ -37,7 +37,7 @@ func createNProofs(keeper keeper.Keeper, ctx context.Context, n int) []types.Pro Service: &sharedtypes.Service{Id: testServiceId}, SessionId: fmt.Sprintf("session-%d", i), SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetDefaultSessionEndHeight(1), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), }, ClosestMerkleProof: nil, } diff --git a/x/proof/module/helpers_test.go b/x/proof/module/helpers_test.go index 8e4ae15a9..3e2dd6045 100644 --- a/x/proof/module/helpers_test.go +++ b/x/proof/module/helpers_test.go @@ -130,7 +130,7 @@ func networkWithClaimObjects( claim := createClaim( t, net, ctx, supplierAcct.Address.String(), - shared.GetDefaultSessionStartHeight(blockHeight), + shared.GetSessionStartHeightWithDefaultParams(blockHeight), appAcct.Address.String(), ) claims = append(claims, *claim) @@ -160,7 +160,7 @@ func encodeSessionHeader( Service: &sharedtypes.Service{Id: testServiceId}, SessionId: sessionId, SessionStartBlockHeight: sessionStartHeight, - SessionEndBlockHeight: shared.GetDefaultSessionEndHeight(sessionStartHeight), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(sessionStartHeight), } cdc := codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) sessionHeaderBz := cdc.MustMarshalJSON(sessionHeader) @@ -210,7 +210,7 @@ func createClaim( Service: &sharedtypes.Service{Id: testServiceId}, SessionId: sessionId, SessionStartBlockHeight: sessionStartHeight, - SessionEndBlockHeight: shared.GetDefaultSessionEndHeight(sessionStartHeight), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(sessionStartHeight), }, RootHash: rootHash, } diff --git a/x/proof/types/message_submit_proof_test.go b/x/proof/types/message_submit_proof_test.go index a3737a176..00558bb93 100644 --- a/x/proof/types/message_submit_proof_test.go +++ b/x/proof/types/message_submit_proof_test.go @@ -30,7 +30,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { Service: testService, SessionId: "mock_session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetDefaultSessionEndHeight(1), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), }, Proof: testClosestMerkleProof, }, @@ -49,7 +49,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { Service: testService, SessionId: "mock_session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetDefaultSessionEndHeight(1), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), }, Proof: testClosestMerkleProof, }, @@ -68,7 +68,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { Service: &sharedtypes.Service{Id: ""}, SessionId: "mock_session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetDefaultSessionEndHeight(1), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), }, Proof: testClosestMerkleProof, }, @@ -83,7 +83,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { Service: testService, SessionId: "mock_session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetDefaultSessionEndHeight(1), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), }, Proof: testClosestMerkleProof, }, diff --git a/x/session/keeper/session_hydrator.go b/x/session/keeper/session_hydrator.go index 54bc444e5..0e397ccd8 100644 --- a/x/session/keeper/session_hydrator.go +++ b/x/session/keeper/session_hydrator.go @@ -103,10 +103,10 @@ func (k Keeper) hydrateSessionMetadata(ctx context.Context, sh *sessionHydrator) // parameters instead of their corresponding constant stand-ins. sh.session.NumBlocksPerSession = shared.NumBlocksPerSession - sh.session.SessionNumber = shared.GetDefaultSessionNumber(sh.blockHeight) + sh.session.SessionNumber = shared.GetSessionNumberWithDefaultParams(sh.blockHeight) - sh.sessionHeader.SessionStartBlockHeight = shared.GetDefaultSessionStartHeight(sh.blockHeight) - sh.sessionHeader.SessionEndBlockHeight = shared.GetDefaultSessionEndHeight(sh.blockHeight) + sh.sessionHeader.SessionStartBlockHeight = shared.GetSessionStartHeightWithDefaultParams(sh.blockHeight) + sh.sessionHeader.SessionEndBlockHeight = shared.GetSessionEndHeightWithDefaultParams(sh.blockHeight) return nil } @@ -294,7 +294,7 @@ func GetSessionId( // getSessionStartBlockHeightBz returns the bytes representation of the session // start block height given the block height. func getSessionStartBlockHeightBz(blockHeight int64) []byte { - sessionStartBlockHeight := shared.GetDefaultSessionStartHeight(blockHeight) + sessionStartBlockHeight := shared.GetSessionStartHeightWithDefaultParams(blockHeight) sessionStartBlockHeightBz := make([]byte, 8) binary.LittleEndian.PutUint64(sessionStartBlockHeightBz, uint64(sessionStartBlockHeight)) return sessionStartBlockHeightBz diff --git a/x/shared/session.go b/x/shared/session.go index 17b1346da..ece8bfc5e 100644 --- a/x/shared/session.go +++ b/x/shared/session.go @@ -16,19 +16,20 @@ const NumBlocksPerSession = 4 // governance parameter is implemented. const SessionGracePeriodBlocks = 4 -// GetDefaultSessionStartHeight returns the block height at which the session starts -// given the default shared on-chain parameters. +// GetSessionStartHeightWithDefaultParams returns the block height at which the +// session containing queryHeight starts, given the default shared on-chain +// parameters. // Returns 0 if the block height is not a consensus produced block. // Example: If NumBlocksPerSession == 4, sessions start at blocks 1, 5, 9, etc. // // TODO_TECHDEBT(#517): Move this function to shared testutils. -func GetDefaultSessionStartHeight(queryHeight int64) int64 { +func GetSessionStartHeightWithDefaultParams(queryHeight int64) int64 { sharedParams := sharedtypes.DefaultParams() return GetSessionStartHeight(&sharedParams, queryHeight) } -// GetSessionStartHeight returns the block height at which the session starts given -// the passed shared on-chain parameters. +// GetSessionStartHeight returns the block height at which the session containing +// queryHeight starts, given the passed shared on-chain parameters. // Returns 0 if the block height is not a consensus produced block. // Example: If NumBlocksPerSession == 4, sessions start at blocks 1, 5, 9, etc. func GetSessionStartHeight(sharedParams *sharedtypes.Params, queryHeight int64) int64 { @@ -43,19 +44,19 @@ func GetSessionStartHeight(sharedParams *sharedtypes.Params, queryHeight int64) return queryHeight - ((queryHeight - 1) % numBlocksPerSession) } -// GetDefaultSessionEndHeight returns the block height at which the session ends, -// given the default shared on-chain parameters. +// GetSessionEndHeightWithDefaultParams returns the block height at which the session +// containing queryHeight ends, given the default shared on-chain parameters. // Returns 0 if the block height is not a consensus produced block. // Example: If NumBlocksPerSession == 4, sessions end at blocks 4, 8, 11, etc. // // TODO_TECHDEBT(#517): Move this function to shared testutils. -func GetDefaultSessionEndHeight(queryHeight int64) int64 { +func GetSessionEndHeightWithDefaultParams(queryHeight int64) int64 { sharedParams := sharedtypes.DefaultParams() return GetSessionEndHeight(&sharedParams, queryHeight) } -// GetSessionEndHeight returns the block height at which the session ends -// given the passed shared on-chain parameters. +// GetSessionEndHeight returns the block height at which the session containing +// queryHeight ends, given the passed shared on-chain parameters. // Returns 0 if the block height is not a consensus produced block. // Example: If NumBlocksPerSession == 4, sessions end at blocks 4, 8, 11, etc. func GetSessionEndHeight(sharedParams *sharedtypes.Params, queryHeight int64) int64 { @@ -68,19 +69,20 @@ func GetSessionEndHeight(sharedParams *sharedtypes.Params, queryHeight int64) in return GetSessionStartHeight(sharedParams, queryHeight) + numBlocksPerSession - 1 } -// GetDefaultSessionNumber returns the session number given the block height given the -// default on-chain shared parameters. +// GetSessionNumberWithDefaultParams returns the session number of the session +// containing queryHeight, given the default on-chain shared parameters. // Returns session number 0 if the block height is not a consensus produced block. // Returns session number 1 for block 1 to block NumBlocksPerSession - 1 (inclusive). // i.e. If NubBlocksPerSession == 4, session == 1 for [1, 4], session == 2 for [5, 8], etc. // // TODO_TECHDEBT(#517): Move this function to shared testutils. -func GetDefaultSessionNumber(queryHeight int64) int64 { +func GetSessionNumberWithDefaultParams(queryHeight int64) int64 { sharedParams := sharedtypes.DefaultParams() return GetSessionNumber(&sharedParams, queryHeight) } -// GetSessionNumber returns the session number given the block height given the passed +// GetSessionNumber returns the session number of the session containing queryHeight, +// given the passed on-chain shared parameters. // shared on-chain parameters. // Returns session number 0 if the block height is not a consensus produced block. // Returns session number 1 for block 1 to block NumBlocksPerSession - 1 (inclusive). diff --git a/x/tokenomics/keeper/keeper_test.go b/x/tokenomics/keeper/keeper_test.go index 94bf6a37b..6103694a6 100644 --- a/x/tokenomics/keeper/keeper_test.go +++ b/x/tokenomics/keeper/keeper_test.go @@ -60,7 +60,7 @@ func (s *TestSuite) SetupTest() { Service: &sharedtypes.Service{Id: testServiceId}, SessionId: "session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetDefaultSessionEndHeight(1), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), }, RootHash: smstRootWithSum(69), } diff --git a/x/tokenomics/keeper/settle_session_accounting_test.go b/x/tokenomics/keeper/settle_session_accounting_test.go index bf5f7142f..c1f992fa2 100644 --- a/x/tokenomics/keeper/settle_session_accounting_test.go +++ b/x/tokenomics/keeper/settle_session_accounting_test.go @@ -52,7 +52,7 @@ func TestSettleSessionAccounting_HandleAppGoingIntoDebt(t *testing.T) { }, SessionId: "session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetDefaultSessionEndHeight(1), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), }, RootHash: smstRootWithSum(appStake.Amount.Uint64() + 1), // More than the app stake } @@ -93,7 +93,7 @@ func TestSettleSessionAccounting_AppNotFound(t *testing.T) { }, SessionId: "session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetDefaultSessionEndHeight(1), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), }, RootHash: smstRootWithSum(42), } @@ -297,7 +297,7 @@ func baseClaim(appAddr, supplierAddr string, sum uint64) prooftypes.Claim { }, SessionId: "session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetDefaultSessionEndHeight(1), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), }, RootHash: smstRootWithSum(sum), } From a3b7abbb25686657cb099efd9619dc7972d47b5f Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 29 May 2024 09:44:45 +0200 Subject: [PATCH 4/5] chore: udpate comments --- x/shared/keeper/session.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/x/shared/keeper/session.go b/x/shared/keeper/session.go index fd4d29f09..c0d414c5f 100644 --- a/x/shared/keeper/session.go +++ b/x/shared/keeper/session.go @@ -6,8 +6,8 @@ import ( "github.com/pokt-network/poktroll/x/shared" ) -// GetSessionStartHeight returns the block height at which the session starts given -// the passed shared on-chain parameters. +// GetSessionStartHeight returns the block height at which the session containing +// queryHeight starts, given the current shared on-chain parameters. // Returns 0 if the block height is not a consensus produced block. // Example: If NumBlocksPerSession == 4, sessions start at blocks 1, 5, 9, etc. func (k Keeper) GetSessionStartHeight(ctx context.Context, queryHeight int64) int64 { @@ -15,8 +15,8 @@ func (k Keeper) GetSessionStartHeight(ctx context.Context, queryHeight int64) in return shared.GetSessionStartHeight(&sharedParams, queryHeight) } -// GetSessionEndHeight returns the block height at which the session ends -// given the passed shared on-chain parameters. +// GetSessionEndHeight returns the block height at which the session containing +// queryHeight ends, given the current shared on-chain parameters. // Returns 0 if the block height is not a consensus produced block. // Example: If NumBlocksPerSession == 4, sessions end at blocks 4, 8, 11, etc. func (k Keeper) GetSessionEndHeight(ctx context.Context, queryHeight int64) int64 { @@ -24,8 +24,8 @@ func (k Keeper) GetSessionEndHeight(ctx context.Context, queryHeight int64) int6 return shared.GetSessionEndHeight(&sharedParams, queryHeight) } -// GetSessionNumber returns the session number given the block height given the passed -// shared on-chain parameters. +// GetSessionNumber returns the session number for the session containing queryHeight, +// given the current shared on-chain parameters. // Returns session number 0 if the block height is not a consensus produced block. // Returns session number 1 for block 1 to block NumBlocksPerSession - 1 (inclusive). // i.e. If NubBlocksPerSession == 4, session == 1 for [1, 4], session == 2 for [5, 8], etc. From 7507dc5f2ae8398d0c01b1c2af5fb7a458c7f1e3 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 29 May 2024 09:45:51 +0200 Subject: [PATCH 5/5] [Relayminer] Query for on-chain session param `num_blocks_per_session` (#538) Co-authored-by: Daniel Olshansky --- .../tests/relays_stress_helpers_test.go | 27 ++++---- pkg/client/interface.go | 8 +++ pkg/client/query/errors.go | 1 + pkg/client/query/sessionquerier.go | 2 +- pkg/client/query/sharedquerier.go | 55 ++++++++++++++++ pkg/crypto/rings/client.go | 6 +- pkg/deps/config/suppliers.go | 20 +++++- pkg/relayer/cmd/cmd.go | 1 + pkg/relayer/proxy/proxy.go | 5 +- pkg/relayer/proxy/proxy_test.go | 12 ++-- pkg/relayer/proxy/relay_verifier.go | 4 +- pkg/relayer/session/claim.go | 11 +++- pkg/relayer/session/proof.go | 16 +++-- pkg/relayer/session/session.go | 44 +++++++------ pkg/relayer/session/session_test.go | 9 ++- .../testqueryclients/sessionquerier.go | 9 +-- .../testqueryclients/sharedquerier.go | 26 ++++++++ testutil/testproxy/relayerproxy.go | 11 ++-- .../msg_server_undelegate_from_gateway.go | 4 +- ...msg_server_undelegate_from_gateway_test.go | 13 ++-- x/application/keeper/prune_undelegations.go | 6 +- .../keeper/msg_server_create_claim_test.go | 4 +- x/proof/keeper/msg_server_submit_proof.go | 9 ++- .../keeper/msg_server_submit_proof_test.go | 4 +- x/proof/keeper/proof_test.go | 4 +- x/proof/module/helpers_test.go | 8 +-- x/proof/module/query_claim_test.go | 8 +-- x/proof/types/message_submit_proof_test.go | 10 +-- x/session/keeper/session_hydrator.go | 55 ++-------------- x/shared/session.go | 65 +++++++++++++++++++ x/shared/types/types.go | 2 + x/tokenomics/keeper/keeper_test.go | 4 +- x/tokenomics/keeper/settle_pending_claims.go | 4 +- .../keeper/settle_session_accounting_test.go | 8 +-- 34 files changed, 313 insertions(+), 162 deletions(-) create mode 100644 pkg/client/query/sharedquerier.go create mode 100644 testutil/testclient/testqueryclients/sharedquerier.go create mode 100644 x/shared/session.go diff --git a/load-testing/tests/relays_stress_helpers_test.go b/load-testing/tests/relays_stress_helpers_test.go index 5bd17d127..a78d42ac7 100644 --- a/load-testing/tests/relays_stress_helpers_test.go +++ b/load-testing/tests/relays_stress_helpers_test.go @@ -39,7 +39,7 @@ import ( "github.com/pokt-network/poktroll/testutil/testclient/testeventsquery" apptypes "github.com/pokt-network/poktroll/x/application/types" gatewaytypes "github.com/pokt-network/poktroll/x/gateway/types" - "github.com/pokt-network/poktroll/x/session/keeper" + "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" suppliertypes "github.com/pokt-network/poktroll/x/supplier/types" ) @@ -173,9 +173,9 @@ func (s *relaysSuite) mapSessionInfoForLoadTestDurationFn( sessionInfo := &sessionInfoNotif{ blockHeight: blockHeight, - sessionNumber: keeper.GetSessionNumber(blockHeight), - sessionStartBlockHeight: keeper.GetSessionStartBlockHeight(blockHeight), - sessionEndBlockHeight: keeper.GetSessionEndBlockHeight(blockHeight), + sessionNumber: shared.GetSessionNumber(blockHeight), + sessionStartBlockHeight: shared.GetSessionStartBlockHeight(blockHeight), + sessionEndBlockHeight: shared.GetSessionEndBlockHeight(blockHeight), } infoLogger := logger.Info(). @@ -330,15 +330,15 @@ func (plans *actorLoadTestIncrementPlans) validateAppSupplierPermutations(t gocu // Otherwise, the expected baseline for several metrics will be periodically skewed. func (plans *actorLoadTestIncrementPlans) validateIncrementRates(t gocuke.TestingT) { require.Truef(t, - plans.gateways.blocksPerIncrement%keeper.NumBlocksPerSession == 0, + plans.gateways.blocksPerIncrement%shared.NumBlocksPerSession == 0, "gateway increment rate must be a multiple of the session length", ) require.Truef(t, - plans.suppliers.blocksPerIncrement%keeper.NumBlocksPerSession == 0, + plans.suppliers.blocksPerIncrement%shared.NumBlocksPerSession == 0, "supplier increment rate must be a multiple of the session length", ) require.Truef(t, - plans.apps.blocksPerIncrement%keeper.NumBlocksPerSession == 0, + plans.apps.blocksPerIncrement%shared.NumBlocksPerSession == 0, "app increment rate must be a multiple of the session length", ) } @@ -369,12 +369,11 @@ func (plans *actorLoadTestIncrementPlans) totalDurationBlocks() int64 { // last increment duration (i.e. **after** maxActorCount actors are activated). blocksToLastSessionEnd := plans.maxActorBlocksToFinalIncrementEnd() - sessionGracePeriodBlocks := keeper.GetSessionGracePeriodBlockCount() - blocksToLastProofWindowEnd := blocksToLastSessionEnd + sessionGracePeriodBlocks + blocksToLastProofWindowEnd := blocksToLastSessionEnd + shared.SessionGracePeriodBlocks // Add one session length so that the duration is inclusive of the block which // commits the last session's proof. - return blocksToLastProofWindowEnd + keeper.NumBlocksPerSession + return blocksToLastProofWindowEnd + shared.NumBlocksPerSession } // blocksToFinalIncrementStart returns the number of blocks that will have @@ -721,9 +720,9 @@ func (plan *actorLoadTestIncrementPlan) shouldIncrementActorCount( return false } - initialSessionNumber := keeper.GetSessionNumber(startBlockHeight) + initialSessionNumber := shared.GetSessionNumber(startBlockHeight) // TODO_TECHDEBT(#21): replace with gov param query when available. - actorSessionIncRate := plan.blocksPerIncrement / keeper.NumBlocksPerSession + actorSessionIncRate := plan.blocksPerIncrement / shared.NumBlocksPerSession nextSessionNumber := sessionInfo.sessionNumber + 1 - initialSessionNumber isSessionStartHeight := sessionInfo.blockHeight == sessionInfo.sessionStartBlockHeight isActorIncrementHeight := nextSessionNumber%actorSessionIncRate == 0 @@ -747,9 +746,9 @@ func (plan *actorLoadTestIncrementPlan) shouldIncrementSupplierCount( return false } - initialSessionNumber := keeper.GetSessionNumber(startBlockHeight) + initialSessionNumber := shared.GetSessionNumber(startBlockHeight) // TODO_TECHDEBT(#21): replace with gov param query when available. - supplierSessionIncRate := plan.blocksPerIncrement / keeper.NumBlocksPerSession + supplierSessionIncRate := plan.blocksPerIncrement / shared.NumBlocksPerSession nextSessionNumber := sessionInfo.sessionNumber + 1 - initialSessionNumber isSessionEndHeight := sessionInfo.blockHeight == sessionInfo.sessionEndBlockHeight isActorIncrementHeight := nextSessionNumber%supplierSessionIncRate == 0 diff --git a/pkg/client/interface.go b/pkg/client/interface.go index 77484c454..3f801bf6b 100644 --- a/pkg/client/interface.go +++ b/pkg/client/interface.go @@ -7,6 +7,7 @@ //go:generate mockgen -destination=../../testutil/mockclient/application_query_client_mock.go -package=mockclient . ApplicationQueryClient //go:generate mockgen -destination=../../testutil/mockclient/supplier_query_client_mock.go -package=mockclient . SupplierQueryClient //go:generate mockgen -destination=../../testutil/mockclient/session_query_client_mock.go -package=mockclient . SessionQueryClient +//go:generate mockgen -destination=../../testutil/mockclient/shared_query_client_mock.go -package=mockclient . SharedQueryClient //go:generate mockgen -destination=../../testutil/mockclient/cosmos_tx_builder_mock.go -package=mockclient github.com/cosmos/cosmos-sdk/client TxBuilder //go:generate mockgen -destination=../../testutil/mockclient/cosmos_keyring_mock.go -package=mockclient github.com/cosmos/cosmos-sdk/crypto/keyring Keyring //go:generate mockgen -destination=../../testutil/mockclient/cosmos_client_mock.go -package=mockclient github.com/cosmos/cosmos-sdk/client AccountRetriever @@ -275,3 +276,10 @@ type SessionQueryClient interface { blockHeight int64, ) (*sessiontypes.Session, error) } + +// SharedQueryClient defines an interface that enables the querying of the +// on-chain shared module information. +type SharedQueryClient interface { + // GetParams queries the chain for the current shared module parameters. + GetParams(ctx context.Context) (*sharedtypes.Params, error) +} diff --git a/pkg/client/query/errors.go b/pkg/client/query/errors.go index 352e56ce3..487b79734 100644 --- a/pkg/client/query/errors.go +++ b/pkg/client/query/errors.go @@ -8,4 +8,5 @@ var ( ErrQueryUnableToDeserializeAccount = sdkerrors.Register(codespace, 2, "unable to deserialize account") ErrQueryRetrieveSession = sdkerrors.Register(codespace, 3, "error while trying to retrieve a session") ErrQueryPubKeyNotFound = sdkerrors.Register(codespace, 4, "account pub key not found") + ErrQuerySessionParams = sdkerrors.Register(codespace, 5, "unable to query session params") ) diff --git a/pkg/client/query/sessionquerier.go b/pkg/client/query/sessionquerier.go index 6a86205fe..a08d49f16 100644 --- a/pkg/client/query/sessionquerier.go +++ b/pkg/client/query/sessionquerier.go @@ -4,7 +4,7 @@ import ( "context" "cosmossdk.io/depinject" - grpc "github.com/cosmos/gogoproto/grpc" + "github.com/cosmos/gogoproto/grpc" "github.com/pokt-network/poktroll/pkg/client" sessiontypes "github.com/pokt-network/poktroll/x/session/types" diff --git a/pkg/client/query/sharedquerier.go b/pkg/client/query/sharedquerier.go new file mode 100644 index 000000000..2c4ac4abb --- /dev/null +++ b/pkg/client/query/sharedquerier.go @@ -0,0 +1,55 @@ +package query + +import ( + "context" + + "cosmossdk.io/depinject" + "github.com/cosmos/gogoproto/grpc" + + "github.com/pokt-network/poktroll/pkg/client" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" +) + +var _ client.SharedQueryClient = (*sharedQuerier)(nil) + +// sharedQuerier is a wrapper around the sharedtypes.QueryClient that enables the +// querying of on-chain shared information through a single exposed method +// which returns an sharedtypes.Session struct +type sharedQuerier struct { + clientConn grpc.ClientConn + sharedQuerier sharedtypes.QueryClient +} + +// NewSharedQuerier returns a new instance of a client.SharedQueryClient by +// injecting the dependecies provided by the depinject.Config. +// +// Required dependencies: +// - clientCtx +func NewSharedQuerier(deps depinject.Config) (client.SharedQueryClient, error) { + querier := &sharedQuerier{} + + if err := depinject.Inject( + deps, + &querier.clientConn, + ); err != nil { + return nil, err + } + + querier.sharedQuerier = sharedtypes.NewQueryClient(querier.clientConn) + + return querier, nil +} + +// GetParams queries & returns the shared module on-chain parameters. +// +// TODO_TECHDEBT(#543): We don't really want to have to query the params for every method call. +// Once `ModuleParamsClient` is implemented, use its replay observable's `#Last()` method +// to get the most recently (asynchronously) observed (and cached) value. +func (sq *sharedQuerier) GetParams(ctx context.Context) (*sharedtypes.Params, error) { + req := &sharedtypes.QueryParamsRequest{} + res, err := sq.sharedQuerier.Params(ctx, req) + if err != nil { + return nil, ErrQuerySessionParams.Wrapf("[%v]", err) + } + return &res.Params, nil +} diff --git a/pkg/crypto/rings/client.go b/pkg/crypto/rings/client.go index b7eb1f104..9e8560833 100644 --- a/pkg/crypto/rings/client.go +++ b/pkg/crypto/rings/client.go @@ -9,14 +9,14 @@ import ( ring_secp256k1 "github.com/athanorlabs/go-dleq/secp256k1" ringtypes "github.com/athanorlabs/go-dleq/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - ring "github.com/noot/ring-go" + "github.com/noot/ring-go" "github.com/pokt-network/poktroll/pkg/client" "github.com/pokt-network/poktroll/pkg/crypto" "github.com/pokt-network/poktroll/pkg/polylog" apptypes "github.com/pokt-network/poktroll/x/application/types" "github.com/pokt-network/poktroll/x/service/types" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" + "github.com/pokt-network/poktroll/x/shared" ) var _ crypto.RingClient = (*ringClient)(nil) @@ -265,7 +265,7 @@ func (rc *ringClient) getRingPointsForAddressAtHeight( // gateways that have been undelegated after the target session end height. func GetRingAddressesAtBlock(app *apptypes.Application, blockHeight int64) []string { // Get the target session end height at which we want to get the active delegations. - targetSessionEndHeight := uint64(sessionkeeper.GetSessionEndBlockHeight(blockHeight)) + targetSessionEndHeight := uint64(shared.GetSessionEndBlockHeight(blockHeight)) // Get the current active delegations for the application and use them as a base. activeDelegationsAtHeight := app.DelegateeGatewayAddresses diff --git a/pkg/deps/config/suppliers.go b/pkg/deps/config/suppliers.go index 80fa4a0e9..d96ec6d74 100644 --- a/pkg/deps/config/suppliers.go +++ b/pkg/deps/config/suppliers.go @@ -378,7 +378,7 @@ func NewSupplyPOKTRollSDKFn(signingKeyName string) SupplierFn { } } -// newSupplyBlockQueryClientFn returns a function which constructs a +// NewSupplyBlockQueryClientFn returns a function which constructs a // BlockQueryClient instance and returns a new depinject.Config which // is supplied with the given deps and the new BlockQueryClient. func NewSupplyBlockQueryClientFn(queryNodeRPCUrl *url.URL) SupplierFn { @@ -395,3 +395,21 @@ func NewSupplyBlockQueryClientFn(queryNodeRPCUrl *url.URL) SupplierFn { return depinject.Configs(deps, depinject.Supply(blockQueryClient)), nil } } + +// NewSupplySharedQueryClientFn returns a function which constructs a +// SharedQueryClient instance and returns a new depinject.Config which +// is supplied with the given deps and the new SharedQueryClient. +func NewSupplySharedQueryClientFn() SupplierFn { + return func( + _ context.Context, + deps depinject.Config, + _ *cobra.Command, + ) (depinject.Config, error) { + sharedQuerier, err := query.NewSharedQuerier(deps) + if err != nil { + return nil, err + } + + return depinject.Configs(deps, depinject.Supply(sharedQuerier)), nil + } +} diff --git a/pkg/relayer/cmd/cmd.go b/pkg/relayer/cmd/cmd.go index 60830763e..03a870b78 100644 --- a/pkg/relayer/cmd/cmd.go +++ b/pkg/relayer/cmd/cmd.go @@ -195,6 +195,7 @@ func setupRelayerDependencies( supplyMiner, // leaf config.NewSupplyTxClientContextFn(queryNodeGRPCUrl, txNodeRPCUrl), // leaf config.NewSupplyDelegationClientFn(), // leaf + config.NewSupplySharedQueryClientFn(), // leaf config.NewSupplyAccountQuerierFn(), config.NewSupplyApplicationQuerierFn(), config.NewSupplySupplierQuerierFn(), diff --git a/pkg/relayer/proxy/proxy.go b/pkg/relayer/proxy/proxy.go index 8e8f8b0fa..c3417c3f9 100644 --- a/pkg/relayer/proxy/proxy.go +++ b/pkg/relayer/proxy/proxy.go @@ -38,8 +38,9 @@ type relayerProxy struct { // which contains the supported services, RPC types, and endpoints, etc... supplierQuerier client.SupplierQueryClient - // sessionQuerier is the querier used to get the current session from the blockchain, - // which is needed to check if the relay proxy should be serving an incoming relay request. + // sessionQuerier is the query client used to get the current session & session params + // from the blockchain, which are needed to check if the relay proxy should be serving an + // incoming relay request. sessionQuerier client.SessionQueryClient // servers is a map of listenAddress -> RelayServer provided by the relayer proxy, diff --git a/pkg/relayer/proxy/proxy_test.go b/pkg/relayer/proxy/proxy_test.go index 2ed0f7415..15a5d9866 100644 --- a/pkg/relayer/proxy/proxy_test.go +++ b/pkg/relayer/proxy/proxy_test.go @@ -17,7 +17,7 @@ import ( "github.com/pokt-network/poktroll/pkg/relayer/config" "github.com/pokt-network/poktroll/pkg/relayer/proxy" "github.com/pokt-network/poktroll/testutil/testproxy" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" + "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -346,14 +346,14 @@ func TestRelayerProxy_Relays(t *testing.T) { // blockOutsideSessionGracePeriod is the block height that is after the first // session's grace period and within the second session's grace period, // meaning a relay should not be handled at this block height. - blockOutsideSessionGracePeriod := blockHeight + - sessionkeeper.NumBlocksPerSession + - sessionkeeper.GetSessionGracePeriodBlockCount() + blockOutsideSessionGracePeriod := int64(blockHeight + + shared.NumBlocksPerSession + + shared.SessionGracePeriodBlocks) // blockWithinSessionGracePeriod is the block height that is after the first // session but within its session's grace period, meaning a relay should be // handled at this block height. - blockWithinSessionGracePeriod := blockHeight + sessionkeeper.GetSessionGracePeriodBlockCount() + blockWithinSessionGracePeriod := int64(blockHeight + shared.SessionGracePeriodBlocks) tests := []struct { desc string @@ -656,7 +656,7 @@ func sendRequestWithDifferentSession( test *testproxy.TestBehavior, ) (errCode int32, errorMessage string) { // Use a block height that generates a different session ID - blockHeightAfterSessionGracePeriod := blockHeight + sessionkeeper.GetSessionGracePeriodBlockCount() + blockHeightAfterSessionGracePeriod := int64(blockHeight + shared.SessionGracePeriodBlocks) req := testproxy.GenerateRelayRequest( test, appPrivateKey, diff --git a/pkg/relayer/proxy/relay_verifier.go b/pkg/relayer/proxy/relay_verifier.go index 011b1b293..11cba8b7d 100644 --- a/pkg/relayer/proxy/relay_verifier.go +++ b/pkg/relayer/proxy/relay_verifier.go @@ -3,8 +3,8 @@ package proxy import ( "context" - sessiontypes "github.com/pokt-network/poktroll/pkg/relayer/session" "github.com/pokt-network/poktroll/x/service/types" + "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -99,7 +99,7 @@ func (rp *relayerProxy) getTargetSessionBlockHeight( if sessionEndblockHeight < currentBlockHeight { // Do not process the `RelayRequest` if the session has expired and the current // block height is outside the session's grace period. - if sessiontypes.IsWithinGracePeriod(sessionEndblockHeight, currentBlockHeight) { + if !shared.IsGracePeriodElapsed(sessionEndblockHeight, currentBlockHeight) { // The RelayRequest's session has expired but is still within the // grace period so process it as if the session is still active. return sessionEndblockHeight, nil diff --git a/pkg/relayer/session/claim.go b/pkg/relayer/session/claim.go index f9be2455d..1f5761a88 100644 --- a/pkg/relayer/session/claim.go +++ b/pkg/relayer/session/claim.go @@ -11,7 +11,7 @@ import ( "github.com/pokt-network/poktroll/pkg/observable/logging" "github.com/pokt-network/poktroll/pkg/relayer" "github.com/pokt-network/poktroll/pkg/relayer/protocol" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" + "github.com/pokt-network/poktroll/x/shared" ) // createClaims maps over the sessionsToClaimObs observable. For each claim batch, it: @@ -42,6 +42,10 @@ func (rs *relayerSessionsManager) createClaims( ) // TODO_TECHDEBT: pass failed create claim sessions to some retry mechanism. + // TODO_IMPROVE: It may be useful for the retry mechanism which consumes the + // observable which corresponds to failSubmitProofsSessionsCh to have a + // reference to the error which caused the proof submission to fail. + // In this case, the error may not be persistent. _ = failedCreateClaimSessionsObs logging.LogErrors(ctx, filter.EitherError(ctx, eitherClaimedSessionsObs)) @@ -82,11 +86,12 @@ func (rs *relayerSessionsManager) waitForEarliestCreateClaimsHeight( // first one from the group to calculate the earliest height for claim creation. sessionEndHeight := sessionTrees[0].GetSessionHeader().GetSessionEndBlockHeight() - // TODO_TECHDEBT(@red-0ne): Centralize the business logic that involves taking + // TODO_TECHDEBT(#516): Centralize the business logic that involves taking // into account the heights, windows and grace periods into helper functions. // An additional block is added to permit to relays arriving at the last block // of the session to be included in the claim before the smt is closed. - createClaimsWindowStartHeight := sessionEndHeight + sessionkeeper.GetSessionGracePeriodBlockCount() + 1 + sessionGracePeriodEndHeight := shared.GetSessionGracePeriodEndHeight(sessionEndHeight) + createClaimsWindowStartHeight := sessionGracePeriodEndHeight + 1 // TODO_BLOCKER: query the on-chain governance parameter once available. // + claimproofparams.GovCreateClaimWindowStartHeightOffset diff --git a/pkg/relayer/session/proof.go b/pkg/relayer/session/proof.go index 52e3e8e69..9acb77803 100644 --- a/pkg/relayer/session/proof.go +++ b/pkg/relayer/session/proof.go @@ -12,7 +12,7 @@ import ( "github.com/pokt-network/poktroll/pkg/relayer" "github.com/pokt-network/poktroll/pkg/relayer/protocol" proofkeeper "github.com/pokt-network/poktroll/x/proof/keeper" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" + "github.com/pokt-network/poktroll/x/shared" ) // submitProofs maps over the given claimedSessions observable. @@ -79,12 +79,16 @@ func (rs *relayerSessionsManager) waitForEarliestSubmitProofsHeightAndGeneratePr // first one from the group to calculate the earliest height for proof submission. sessionEndHeight := sessionTrees[0].GetSessionHeader().GetSessionEndBlockHeight() - sessionGracePeriodEndHeight := sessionkeeper.GetSessionGracePeriodBlockCount() + sessionEndHeight - // TODO_TECHDEBT(#516): Centralize the business logic that involves taking // into account the heights, windows and grace periods into helper functions. - // TODO_BLOCKER(#516): The proof submission window SHOULD NOT overlap with the claim window. - submitProofsWindowStartHeight := sessionGracePeriodEndHeight + 1 + // TODO_BLOCKER(#516): The proof submission window SHOULD NOT overlap with the + // claim window. The proof submission window start SHOULD be relative to the + // claim window end. + sessionGracePeriodEndHeight := shared.GetSessionGracePeriodEndHeight(sessionEndHeight) + // An additional block is added to permit to relays arriving at the last block + // of the session to be included in the claim before the smt is closed. + createClaimsWindowStartHeight := sessionGracePeriodEndHeight + 1 + submitProofsWindowStartHeight := createClaimsWindowStartHeight // TODO_BLOCKER(#516): query the on-chain governance parameter once available. // + claimproofparams.GovSubmitProofWindowStartHeightOffset @@ -95,7 +99,7 @@ func (rs *relayerSessionsManager) waitForEarliestSubmitProofsHeightAndGeneratePr // TODO_BLOCKER(@bryanchriswhite): The block that'll be used as a source of entropy for // which branch(es) to prove should be deterministic and use on-chain governance params. - // submitProofWindowStartBlock is the block that will have its hash used as the + // sessionPathBlock is the block that will have its hash used as the // source of entropy for all the session trees in that batch, waiting for it to // be received before proceeding. sessionPathBlock := rs.waitForBlock(ctx, sessionGracePeriodEndHeight) diff --git a/pkg/relayer/session/session.go b/pkg/relayer/session/session.go index 84d786eed..531c1208e 100644 --- a/pkg/relayer/session/session.go +++ b/pkg/relayer/session/session.go @@ -12,8 +12,8 @@ import ( "github.com/pokt-network/poktroll/pkg/observable/logging" "github.com/pokt-network/poktroll/pkg/polylog" "github.com/pokt-network/poktroll/pkg/relayer" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" + "github.com/pokt-network/poktroll/x/shared" ) var _ relayer.RelayerSessionsManager = (*relayerSessionsManager)(nil) @@ -48,6 +48,9 @@ type relayerSessionsManager struct { // storesDirectory points to a path on disk where KVStore data files are created. storesDirectory string + + // sharedQueryClient is used to query shared module parameters. + sharedQueryClient client.SharedQueryClient } // NewRelayerSessions creates a new relayerSessions. @@ -73,6 +76,7 @@ func NewRelayerSessions( deps, &rs.blockClient, &rs.supplierClient, + &rs.sharedQueryClient, ); err != nil { return nil, err } @@ -164,8 +168,9 @@ func (rs *relayerSessionsManager) ensureSessionTree(sessionHeader *sessiontypes. // TODO_IMPROVE: Add the ability for the process to resume where it left off in // case the process is restarted or the connection is dropped and reconnected. func (rs *relayerSessionsManager) mapBlockToSessionsToClaim( - _ context.Context, block client.Block, -) ([]relayer.SessionTree, bool) { + ctx context.Context, + block client.Block, +) (sessionTrees []relayer.SessionTree, skip bool) { rs.sessionsTreesMu.Lock() defer rs.sessionsTreesMu.Unlock() @@ -174,18 +179,31 @@ func (rs *relayerSessionsManager) mapBlockToSessionsToClaim( // They will be emitted last, after all the late sessions have been emitted. var onTimeSessions []relayer.SessionTree + // TODO_TECHDEBT(#543): We don't really want to have to query the params for every method call. + // Once `ModuleParamsClient` is implemented, use its replay observable's `#Last()` method + // to get the most recently (asynchronously) observed (and cached) value. + sharedParams, err := rs.sharedQueryClient.GetParams(ctx) + if err != nil { + rs.logger.Error().Err(err).Msg("unable to query shared module params") + return nil, true + } + + numBlocksPerSession := sharedParams.NumBlocksPerSession + // Check if there are sessions that need to enter the claim/proof phase as their // end block height was the one before the last committed block or earlier. // Iterate over the sessionsTrees map to get the ones that end at a block height // lower than the current block height. - for endBlockHeight, sessionsTreesEndingAtBlockHeight := range rs.sessionsTrees { + for sessionEndHeight, sessionsTreesEndingAtBlockHeight := range rs.sessionsTrees { // Late sessions are the ones that have their session grace period elapsed // and should already have been claimed. // Group them by their end block height and emit each group separately // before emitting the on-time sessions. var lateSessions []relayer.SessionTree - // !IsWithinGracePeriod is checking for sessions to claim with <= operator, + sessionGracePeriodEndHeight := shared.GetSessionGracePeriodEndHeight(sessionEndHeight) + + // Checking for sessions to claim with <= operator, // which means that it would include sessions that were supposed to be // claimed in previous block heights too. // These late sessions might have their create claim window closed and are @@ -194,7 +212,7 @@ func (rs *relayerSessionsManager) mapBlockToSessionsToClaim( // downstream at the waitForEarliestCreateClaimsHeight step. // TODO_BLOCKER: Introduce governance claim and proof window durations, // implement off-chain window closing and on-chain window checks. - if !IsWithinGracePeriod(endBlockHeight, block.Height()) { + if sessionGracePeriodEndHeight <= block.Height() { // Iterate over the sessionsTrees that have grace period ending at this // block height and add them to the list of sessionTrees to be published. for _, sessionTree := range sessionsTreesEndingAtBlockHeight { @@ -211,7 +229,7 @@ func (rs *relayerSessionsManager) mapBlockToSessionsToClaim( // Separate the sessions that are on-time from the ones that are late. // If the session is past its grace period, it is considered late, // otherwise it is on time and will be emitted last. - if IsPastGracePeriod(endBlockHeight, block.Height()) { + if sessionGracePeriodEndHeight+int64(numBlocksPerSession) < block.Height() { lateSessions = append(lateSessions, sessionTree) } else { onTimeSessions = append(onTimeSessions, sessionTree) @@ -318,15 +336,3 @@ func (rs *relayerSessionsManager) mapAddMinedRelayToSessionTree( // Skip because this map function only outputs errors. return nil, true } - -// IsWithinGracePeriod checks if the grace period for the session has ended -// and signals whether it is time to create a claim for it. -func IsWithinGracePeriod(sessionEndBlockHeight, currentBlockHeight int64) bool { - return currentBlockHeight <= sessionEndBlockHeight+sessionkeeper.GetSessionGracePeriodBlockCount() -} - -// IsPastGracePeriod checks if the grace period for the session, given its end -// block height, has ended. -func IsPastGracePeriod(sessionEndBlockHeight, currentBlockHeight int64) bool { - return currentBlockHeight > sessionEndBlockHeight+sessionkeeper.GetSessionGracePeriodBlockCount() -} diff --git a/pkg/relayer/session/session_test.go b/pkg/relayer/session/session_test.go index 0d681076c..5444bee9d 100644 --- a/pkg/relayer/session/session_test.go +++ b/pkg/relayer/session/session_test.go @@ -20,10 +20,11 @@ import ( "github.com/pokt-network/poktroll/pkg/relayer/session" "github.com/pokt-network/poktroll/testutil/mockclient" "github.com/pokt-network/poktroll/testutil/testclient/testblock" + "github.com/pokt-network/poktroll/testutil/testclient/testqueryclients" "github.com/pokt-network/poktroll/testutil/testclient/testsupplier" "github.com/pokt-network/poktroll/testutil/testpolylog" "github.com/pokt-network/poktroll/testutil/testrelayer" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" + "github.com/pokt-network/poktroll/x/shared" ) func TestRelayerSessionsManager_Start(t *testing.T) { @@ -71,7 +72,9 @@ func TestRelayerSessionsManager_Start(t *testing.T) { ). AnyTimes() - deps := depinject.Supply(blockClient, blockQueryClientMock, supplierClient) + sharedQueryClientMock := testqueryclients.NewTestSharedQueryClient(t) + + deps := depinject.Supply(blockClient, blockQueryClientMock, supplierClient, sharedQueryClientMock) storesDirectoryOpt := testrelayer.WithTempStoresDirectory(t) // Create a new relayer sessions manager. @@ -101,7 +104,7 @@ func TestRelayerSessionsManager_Start(t *testing.T) { // Calculate the session grace period end block height to emit that block height // to the blockPublishCh to trigger claim creation for the session. - sessionGracePeriodEndBlockHeight := int64(sessionEndHeight + sessionkeeper.GetSessionGracePeriodBlockCount()) + sessionGracePeriodEndBlockHeight := int64(sessionEndHeight + shared.SessionGracePeriodBlocks) // Publish a block to the blockPublishCh to trigger claim creation for the session. // TODO_TECHDEBT: assumes claiming at sessionGracePeriodEndBlockHeight is valid. diff --git a/testutil/testclient/testqueryclients/sessionquerier.go b/testutil/testclient/testqueryclients/sessionquerier.go index c8c24770a..552e66969 100644 --- a/testutil/testclient/testqueryclients/sessionquerier.go +++ b/testutil/testclient/testqueryclients/sessionquerier.go @@ -11,6 +11,7 @@ import ( "github.com/pokt-network/poktroll/testutil/mockclient" sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" + "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -79,11 +80,11 @@ func AddToExistingSessions( Service: &sharedtypes.Service{Id: serviceId}, ApplicationAddress: appAddress, SessionId: sessionId, - SessionStartBlockHeight: sessionkeeper.GetSessionStartBlockHeight(blockHeight), - SessionEndBlockHeight: sessionkeeper.GetSessionEndBlockHeight(blockHeight), + SessionStartBlockHeight: shared.GetSessionStartBlockHeight(blockHeight), + SessionEndBlockHeight: shared.GetSessionEndBlockHeight(blockHeight), }, - NumBlocksPerSession: sessionkeeper.NumBlocksPerSession, - SessionNumber: sessionkeeper.GetSessionNumber(blockHeight), + NumBlocksPerSession: shared.NumBlocksPerSession, + SessionNumber: shared.GetSessionNumber(blockHeight), SessionId: sessionId, Suppliers: []*sharedtypes.Supplier{}, } diff --git a/testutil/testclient/testqueryclients/sharedquerier.go b/testutil/testclient/testqueryclients/sharedquerier.go new file mode 100644 index 000000000..82ffa88f2 --- /dev/null +++ b/testutil/testclient/testqueryclients/sharedquerier.go @@ -0,0 +1,26 @@ +package testqueryclients + +import ( + "testing" + + "github.com/golang/mock/gomock" + + "github.com/pokt-network/poktroll/testutil/mockclient" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" +) + +// NewTestSharedQueryClient creates a mock of the SharedQueryClient. +func NewTestSharedQueryClient( + t *testing.T, +) *mockclient.MockSharedQueryClient { + ctrl := gomock.NewController(t) + + sharedQuerier := mockclient.NewMockSharedQueryClient(ctrl) + params := sharedtypes.DefaultParams() + + sharedQuerier.EXPECT().GetParams(gomock.Any()). + Return(¶ms, nil). + AnyTimes() + + return sharedQuerier +} diff --git a/testutil/testproxy/relayerproxy.go b/testutil/testproxy/relayerproxy.go index 152d1df56..1e1363063 100644 --- a/testutil/testproxy/relayerproxy.go +++ b/testutil/testproxy/relayerproxy.go @@ -15,7 +15,7 @@ import ( ring_secp256k1 "github.com/athanorlabs/go-dleq/secp256k1" ringtypes "github.com/athanorlabs/go-dleq/types" keyringtypes "github.com/cosmos/cosmos-sdk/crypto/keyring" - secp256k1 "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/types/bech32" "github.com/noot/ring-go" @@ -28,12 +28,13 @@ import ( "github.com/pokt-network/poktroll/pkg/signer" "github.com/pokt-network/poktroll/testutil/testclient/testblock" "github.com/pokt-network/poktroll/testutil/testclient/testdelegation" - testkeyring "github.com/pokt-network/poktroll/testutil/testclient/testkeyring" + "github.com/pokt-network/poktroll/testutil/testclient/testkeyring" "github.com/pokt-network/poktroll/testutil/testclient/testqueryclients" testrings "github.com/pokt-network/poktroll/testutil/testcrypto/rings" servicetypes "github.com/pokt-network/poktroll/x/service/types" sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" + "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -270,7 +271,7 @@ func WithSuccessiveSessions( test.t, appAddress, serviceId, - sessionkeeper.NumBlocksPerSession*int64(i), + shared.NumBlocksPerSession*int64(i), sessionSuppliers, ) } @@ -408,8 +409,8 @@ func GenerateRelayRequest( ApplicationAddress: appAddress, SessionId: string(sessionId[:]), Service: &sharedtypes.Service{Id: serviceId}, - SessionStartBlockHeight: sessionkeeper.GetSessionStartBlockHeight(blockHeight), - SessionEndBlockHeight: sessionkeeper.GetSessionEndBlockHeight(blockHeight), + SessionStartBlockHeight: shared.GetSessionStartBlockHeight(blockHeight), + SessionEndBlockHeight: shared.GetSessionEndBlockHeight(blockHeight), }, // The returned relay is unsigned and must be signed elsewhere for functionality Signature: []byte(""), diff --git a/x/application/keeper/msg_server_undelegate_from_gateway.go b/x/application/keeper/msg_server_undelegate_from_gateway.go index 3a782e36b..f5a0345da 100644 --- a/x/application/keeper/msg_server_undelegate_from_gateway.go +++ b/x/application/keeper/msg_server_undelegate_from_gateway.go @@ -9,7 +9,7 @@ import ( "github.com/pokt-network/poktroll/telemetry" "github.com/pokt-network/poktroll/x/application/types" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" + "github.com/pokt-network/poktroll/x/shared" ) func (k msgServer) UndelegateFromGateway(ctx context.Context, msg *types.MsgUndelegateFromGateway) (*types.MsgUndelegateFromGatewayResponse, error) { @@ -80,7 +80,7 @@ func (k Keeper) recordPendingUndelegation( gatewayAddress string, currentBlockHeight int64, ) { - sessionEndHeight := uint64(sessionkeeper.GetSessionEndBlockHeight(currentBlockHeight)) + sessionEndHeight := uint64(shared.GetSessionEndBlockHeight(currentBlockHeight)) undelegatingGatewayListAtBlock := app.PendingUndelegations[sessionEndHeight] // Add the gateway address to the undelegated gateways list if it's not already there. diff --git a/x/application/keeper/msg_server_undelegate_from_gateway_test.go b/x/application/keeper/msg_server_undelegate_from_gateway_test.go index 682340ab6..c5d80977d 100644 --- a/x/application/keeper/msg_server_undelegate_from_gateway_test.go +++ b/x/application/keeper/msg_server_undelegate_from_gateway_test.go @@ -14,7 +14,7 @@ import ( "github.com/pokt-network/poktroll/testutil/sample" "github.com/pokt-network/poktroll/x/application/keeper" "github.com/pokt-network/poktroll/x/application/types" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" + "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -316,7 +316,7 @@ func TestMsgServer_UndelegateFromGateway_DelegationIsActiveUntilNextSession(t *t // Verify that the gateway is added to the pending undelegation list with the // right sessionEndHeight as the map key. - sessionEndHeight := uint64(sessionkeeper.GetSessionEndBlockHeight(undelegationHeight)) + sessionEndHeight := uint64(shared.GetSessionEndBlockHeight(undelegationHeight)) require.Contains(t, app.PendingUndelegations[sessionEndHeight].GatewayAddresses, pendingUndelegateFromAddr, @@ -347,8 +347,7 @@ func TestMsgServer_UndelegateFromGateway_DelegationIsActiveUntilNextSession(t *t // Increment the block height past the tested session's grace period and run // the pruning undelegations logic again. - sessionGracePeriodBlockCount := uint64(sessionkeeper.GetSessionGracePeriodBlockCount()) - afterSessionGracePeriodHeight := int64(sessionEndHeight + sessionGracePeriodBlockCount + 1) + afterSessionGracePeriodHeight := int64(sessionEndHeight + shared.SessionGracePeriodBlocks + 1) sdkCtx = sdkCtx.WithBlockHeight(afterSessionGracePeriodHeight) k.EndBlockerPruneAppToGatewayPendingUndelegation(sdkCtx) @@ -385,7 +384,7 @@ func TestMsgServer_UndelegateFromGateway_DelegationIsPrunedAfterRetentionPeriod( // Verify that the the pending undelegation map no longer contains the // sessionEndHeight key. - sessionEndHeight := uint64(sessionkeeper.GetSessionEndBlockHeight(undelegationHeight)) + sessionEndHeight := uint64(shared.GetSessionEndBlockHeight(undelegationHeight)) require.Empty(t, app.PendingUndelegations[sessionEndHeight]) // Verify that the reconstructed delegatee gateway list can no longer include @@ -424,7 +423,7 @@ func TestMsgServer_UndelegateFromGateway_RedelegationAfterUndelegationAtTheSameS // Verify that the gateway is also present in the pending undelegation list with the // right sessionEndHeight as the map key. - sessionEndHeight := uint64(sessionkeeper.GetSessionEndBlockHeight(undelegationHeight)) + sessionEndHeight := uint64(shared.GetSessionEndBlockHeight(undelegationHeight)) require.Contains(t, app.PendingUndelegations[sessionEndHeight].GatewayAddresses, gatewayAddrToRedelegate, @@ -534,7 +533,7 @@ func createAppStakeDelegateAndUndelegate( // getUndelegationPruningBlockHeight returns the block height at which undelegations // should be pruned for a given undlegation block height. func getUndelegationPruningBlockHeight(blockHeight int64) (pruningHeihgt int64) { - nextSessionStartHeight := sessionkeeper.GetSessionEndBlockHeight(blockHeight) + 1 + nextSessionStartHeight := shared.GetSessionEndBlockHeight(blockHeight) + 1 return nextSessionStartHeight + keeper.GetNumBlocksUndelegationRetention() } diff --git a/x/application/keeper/prune_undelegations.go b/x/application/keeper/prune_undelegations.go index 77aae88da..2cf10aa47 100644 --- a/x/application/keeper/prune_undelegations.go +++ b/x/application/keeper/prune_undelegations.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" + "github.com/pokt-network/poktroll/x/shared" ) // NumSessionsAppToGatewayUndelegationRetention is the number of sessions for which @@ -45,6 +45,6 @@ func (k Keeper) EndBlockerPruneAppToGatewayPendingUndelegation(ctx sdk.Context) // GetNumBlocksUndelegationRetention returns the number of blocks for which // undelegations should be kept before being pruned. func GetNumBlocksUndelegationRetention() int64 { - return sessionkeeper.GetSessionGracePeriodBlockCount() + - (sessionkeeper.NumBlocksPerSession * NumSessionsAppToGatewayUndelegationRetention) + return shared.SessionGracePeriodBlocks + + (shared.NumBlocksPerSession * NumSessionsAppToGatewayUndelegationRetention) } diff --git a/x/proof/keeper/msg_server_create_claim_test.go b/x/proof/keeper/msg_server_create_claim_test.go index 371a763d5..5f7da9c31 100644 --- a/x/proof/keeper/msg_server_create_claim_test.go +++ b/x/proof/keeper/msg_server_create_claim_test.go @@ -13,8 +13,8 @@ import ( apptypes "github.com/pokt-network/poktroll/x/application/types" "github.com/pokt-network/poktroll/x/proof/keeper" "github.com/pokt-network/poktroll/x/proof/types" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" + "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -300,7 +300,7 @@ func newTestClaimMsg( Service: service, SessionId: sessionId, SessionStartBlockHeight: sessionStartHeight, - SessionEndBlockHeight: sessionkeeper.GetSessionEndBlockHeight(sessionStartHeight), + SessionEndBlockHeight: shared.GetSessionEndBlockHeight(sessionStartHeight), }, merkleRoot, ) diff --git a/x/proof/keeper/msg_server_submit_proof.go b/x/proof/keeper/msg_server_submit_proof.go index 20c4f96fb..b7d05a439 100644 --- a/x/proof/keeper/msg_server_submit_proof.go +++ b/x/proof/keeper/msg_server_submit_proof.go @@ -19,8 +19,8 @@ import ( "github.com/pokt-network/poktroll/telemetry" "github.com/pokt-network/poktroll/x/proof/types" servicetypes "github.com/pokt-network/poktroll/x/service/types" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" + "github.com/pokt-network/poktroll/x/shared" ) // SMT specification used for the proof verification. @@ -440,13 +440,12 @@ func (k msgServer) validateClosestPath( // into account the heights, windows and grace periods into helper functions. // TODO_BLOCKER@(#516): Update `blockHeight` to be the value of when the `ProofWindow` // opens once the variable is added. - sessionEndBlockHeightWithGracePeriod := sessionHeader.GetSessionEndBlockHeight() + - sessionkeeper.GetSessionGracePeriodBlockCount() - blockHash := k.sessionKeeper.GetBlockHash(ctx, sessionEndBlockHeightWithGracePeriod) + sessionGracePeriodEndHeight := shared.GetSessionGracePeriodEndHeight(sessionHeader.GetSessionEndBlockHeight()) + blockHash := k.sessionKeeper.GetBlockHash(ctx, sessionGracePeriodEndHeight) // TODO: Investigate "proof for the path provided does not match one expected by the on-chain protocol" // error that may occur due to block height differing from the off-chain part. - fmt.Println("E2E_DEBUG: height for block hash when verifying the proof", sessionEndBlockHeightWithGracePeriod, sessionHeader.GetSessionId()) + fmt.Println("E2E_DEBUG: height for block hash when verifying the proof", sessionGracePeriodEndHeight, sessionHeader.GetSessionId()) expectedProofPath := GetPathForProof(blockHash, sessionHeader.GetSessionId()) if !bytes.Equal(proof.Path, expectedProofPath) { diff --git a/x/proof/keeper/msg_server_submit_proof_test.go b/x/proof/keeper/msg_server_submit_proof_test.go index 569c18c6e..dcad1c395 100644 --- a/x/proof/keeper/msg_server_submit_proof_test.go +++ b/x/proof/keeper/msg_server_submit_proof_test.go @@ -33,8 +33,8 @@ import ( "github.com/pokt-network/poktroll/x/proof/keeper" "github.com/pokt-network/poktroll/x/proof/types" servicetypes "github.com/pokt-network/poktroll/x/service/types" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" + "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -1066,7 +1066,7 @@ func createClaimAndStoreBlockHash( // into account the heights, windows and grace periods into helper functions. proofSubmissionHeight := claimMsg.GetSessionHeader().GetSessionEndBlockHeight() + - sessionkeeper.GetSessionGracePeriodBlockCount() + shared.SessionGracePeriodBlocks // Set block height to be after the session grace period. blockHeightCtx := keepertest.SetBlockHeight(ctx, proofSubmissionHeight) diff --git a/x/proof/keeper/proof_test.go b/x/proof/keeper/proof_test.go index fb893c5d3..c72f32bbe 100644 --- a/x/proof/keeper/proof_test.go +++ b/x/proof/keeper/proof_test.go @@ -13,8 +13,8 @@ import ( "github.com/pokt-network/poktroll/testutil/sample" "github.com/pokt-network/poktroll/x/proof/keeper" "github.com/pokt-network/poktroll/x/proof/types" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" + "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -37,7 +37,7 @@ func createNProofs(keeper keeper.Keeper, ctx context.Context, n int) []types.Pro Service: &sharedtypes.Service{Id: testServiceId}, SessionId: fmt.Sprintf("session-%d", i), SessionStartBlockHeight: 1, - SessionEndBlockHeight: sessionkeeper.GetSessionEndBlockHeight(1), + SessionEndBlockHeight: shared.GetSessionEndBlockHeight(1), }, ClosestMerkleProof: nil, } diff --git a/x/proof/module/helpers_test.go b/x/proof/module/helpers_test.go index 1d4ed38ed..b8588e554 100644 --- a/x/proof/module/helpers_test.go +++ b/x/proof/module/helpers_test.go @@ -23,8 +23,8 @@ import ( apptypes "github.com/pokt-network/poktroll/x/application/types" proof "github.com/pokt-network/poktroll/x/proof/module" "github.com/pokt-network/poktroll/x/proof/types" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" + "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" suppliertypes "github.com/pokt-network/poktroll/x/supplier/types" ) @@ -130,7 +130,7 @@ func networkWithClaimObjects( claim := createClaim( t, net, ctx, supplierAcct.Address.String(), - sessionkeeper.GetSessionStartBlockHeight(blockHeight), + shared.GetSessionStartBlockHeight(blockHeight), appAcct.Address.String(), ) claims = append(claims, *claim) @@ -160,7 +160,7 @@ func encodeSessionHeader( Service: &sharedtypes.Service{Id: testServiceId}, SessionId: sessionId, SessionStartBlockHeight: sessionStartHeight, - SessionEndBlockHeight: sessionkeeper.GetSessionEndBlockHeight(sessionStartHeight), + SessionEndBlockHeight: shared.GetSessionEndBlockHeight(sessionStartHeight), } cdc := codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) sessionHeaderBz := cdc.MustMarshalJSON(sessionHeader) @@ -210,7 +210,7 @@ func createClaim( Service: &sharedtypes.Service{Id: testServiceId}, SessionId: sessionId, SessionStartBlockHeight: sessionStartHeight, - SessionEndBlockHeight: sessionkeeper.GetSessionEndBlockHeight(sessionStartHeight), + SessionEndBlockHeight: shared.GetSessionEndBlockHeight(sessionStartHeight), }, RootHash: rootHash, } diff --git a/x/proof/module/query_claim_test.go b/x/proof/module/query_claim_test.go index f4e2597bd..b941ea8b0 100644 --- a/x/proof/module/query_claim_test.go +++ b/x/proof/module/query_claim_test.go @@ -16,7 +16,7 @@ import ( _ "github.com/pokt-network/poktroll/testutil/testpolylog" proof "github.com/pokt-network/poktroll/x/proof/module" "github.com/pokt-network/poktroll/x/proof/types" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" + "github.com/pokt-network/poktroll/x/shared" ) func TestClaim_Show(t *testing.T) { @@ -128,12 +128,12 @@ func TestClaim_List(t *testing.T) { // independent constant, which requires us to temporarily align the // with the num blocks per session. See the `forloop` in `networkWithClaimObjects` // that has a TODO_HACK as well. - require.Equal(t, 0, numSuppliers*numApps%sessionkeeper.NumBlocksPerSession) + require.Equal(t, 0, numSuppliers*numApps%shared.NumBlocksPerSession) - numSessions := numSuppliers * numApps / sessionkeeper.NumBlocksPerSession + numSessions := numSuppliers * numApps / shared.NumBlocksPerSession // Submitting one claim per block for simplicity - numClaimsPerSession := sessionkeeper.NumBlocksPerSession + numClaimsPerSession := shared.NumBlocksPerSession totalClaims := numSessions * numClaimsPerSession net, claims := networkWithClaimObjects(t, numSessions, numSuppliers, numApps) diff --git a/x/proof/types/message_submit_proof_test.go b/x/proof/types/message_submit_proof_test.go index 6c5b98abd..d05419e38 100644 --- a/x/proof/types/message_submit_proof_test.go +++ b/x/proof/types/message_submit_proof_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/require" "github.com/pokt-network/poktroll/testutil/sample" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" + "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -30,7 +30,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { Service: testService, SessionId: "mock_session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: sessionkeeper.GetSessionEndBlockHeight(1), + SessionEndBlockHeight: shared.GetSessionEndBlockHeight(1), }, Proof: testClosestMerkleProof, }, @@ -49,7 +49,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { Service: testService, SessionId: "mock_session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: sessionkeeper.GetSessionEndBlockHeight(1), + SessionEndBlockHeight: shared.GetSessionEndBlockHeight(1), }, Proof: testClosestMerkleProof, }, @@ -68,7 +68,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { Service: &sharedtypes.Service{Id: ""}, SessionId: "mock_session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: sessionkeeper.GetSessionEndBlockHeight(1), + SessionEndBlockHeight: shared.GetSessionEndBlockHeight(1), }, Proof: testClosestMerkleProof, }, @@ -83,7 +83,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { Service: testService, SessionId: "mock_session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: sessionkeeper.GetSessionEndBlockHeight(1), + SessionEndBlockHeight: shared.GetSessionEndBlockHeight(1), }, Proof: testClosestMerkleProof, }, diff --git a/x/session/keeper/session_hydrator.go b/x/session/keeper/session_hydrator.go index 67fc6b1a5..cba24a8e0 100644 --- a/x/session/keeper/session_hydrator.go +++ b/x/session/keeper/session_hydrator.go @@ -12,6 +12,7 @@ import ( _ "golang.org/x/crypto/sha3" "github.com/pokt-network/poktroll/x/session/types" + "github.com/pokt-network/poktroll/x/shared" sharedhelpers "github.com/pokt-network/poktroll/x/shared/helpers" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -20,11 +21,6 @@ var SHA3HashLen = crypto.SHA3_256.Size() // TODO_BLOCKER(#21): Make these configurable governance param const ( - // TODO_BLOCKER: Remove direct usage of these constants in helper functions - // when they will be replaced by governance params - NumBlocksPerSession = 4 - // Duration of the grace period in number of sessions - SessionGracePeriod = 1 NumSupplierPerSession = 15 SessionIDComponentDelimiter = "." ) @@ -103,11 +99,11 @@ func (k Keeper) hydrateSessionMetadata(ctx context.Context, sh *sessionHydrator) ) } - sh.session.NumBlocksPerSession = NumBlocksPerSession - sh.session.SessionNumber = GetSessionNumber(sh.blockHeight) + sh.session.NumBlocksPerSession = shared.NumBlocksPerSession + sh.session.SessionNumber = shared.GetSessionNumber(sh.blockHeight) - sh.sessionHeader.SessionStartBlockHeight = GetSessionStartBlockHeight(sh.blockHeight) - sh.sessionHeader.SessionEndBlockHeight = GetSessionEndBlockHeight(sh.blockHeight) + sh.sessionHeader.SessionStartBlockHeight = shared.GetSessionStartBlockHeight(sh.blockHeight) + sh.sessionHeader.SessionEndBlockHeight = shared.GetSessionEndBlockHeight(sh.blockHeight) return nil } @@ -267,39 +263,6 @@ func sha3Hash(bz []byte) []byte { return hasher.Sum(nil) } -// GetSessionStartBlockHeight returns the block height at which the session starts -// Returns 0 if the block height is not a consensus produced block. -// Example: If NumBlocksPerSession == 4, sessions start at blocks 1, 5, 9, etc. -func GetSessionStartBlockHeight(blockHeight int64) int64 { - if blockHeight <= 0 { - return 0 - } - return blockHeight - ((blockHeight - 1) % NumBlocksPerSession) -} - -// GetSessionEndBlockHeight returns the block height at which the session ends -// Returns 0 if the block height is not a consensus produced block. -// Example: If NumBlocksPerSession == 4, sessions end at blocks 4, 8, 11, etc. -func GetSessionEndBlockHeight(blockHeight int64) int64 { - if blockHeight <= 0 { - return 0 - } - - return GetSessionStartBlockHeight(blockHeight) + NumBlocksPerSession - 1 -} - -// GetSessionNumber returns the session number given the block height. -// Returns session number 0 if the block height is not a consensus produced block. -// Returns session number 1 for block 1 to block NumBlocksPerSession - 1 (inclusive). -// i.e. If NubBlocksPerSession == 4, session == 1 for [1, 4], session == 2 for [5, 8], etc. -func GetSessionNumber(blockHeight int64) int64 { - if blockHeight <= 0 { - return 0 - } - - return ((blockHeight - 1) / NumBlocksPerSession) + 1 -} - // GetSessionId returns the string and bytes representation of the sessionId // given the application public key, service ID, block hash, and block height // that is used to get the session start block height. @@ -325,16 +288,10 @@ func GetSessionId( return sessionId, sessionIdBz } -// GetSessionGracePeriodBlockCount returns the number of blocks in the session -// grace period. -func GetSessionGracePeriodBlockCount() int64 { - return SessionGracePeriod * NumBlocksPerSession -} - // getSessionStartBlockHeightBz returns the bytes representation of the session // start block height given the block height. func getSessionStartBlockHeightBz(blockHeight int64) []byte { - sessionStartBlockHeight := GetSessionStartBlockHeight(blockHeight) + sessionStartBlockHeight := shared.GetSessionStartBlockHeight(blockHeight) sessionStartBlockHeightBz := make([]byte, 8) binary.LittleEndian.PutUint64(sessionStartBlockHeightBz, uint64(sessionStartBlockHeight)) return sessionStartBlockHeightBz diff --git a/x/shared/session.go b/x/shared/session.go new file mode 100644 index 000000000..5240059a5 --- /dev/null +++ b/x/shared/session.go @@ -0,0 +1,65 @@ +package shared + +// NumBlocksPerSession is a place-holder that will be removed once the respective governance +// parameter is implemented. +// +// TODO_BLOCKER(#517): Remove direct usage of these constants in helper functions +// when they will be replaced by governance params +const NumBlocksPerSession = 4 + +// SessionGracePeriodBlocks is the number of blocks after the session ends before the +// "session grace period" is considered to have elapsed. +// +// TODO_BLOCKER: This is a place-holder that will be removed once the respective +// governance parameter is implemented. +const SessionGracePeriodBlocks = 4 + +// GetSessionStartBlockHeight returns the block height at which the session starts +// Returns 0 if the block height is not a consensus produced block. +// Example: If NumBlocksPerSession == 4, sessions start at blocks 1, 5, 9, etc. +func GetSessionStartBlockHeight(blockHeight int64) int64 { + if blockHeight <= 0 { + return 0 + } + + // TODO_BLOCKER(#543): If the num_blocks_per_session param has ever been changed, + // this function may cause unexpected behavior. + return blockHeight - ((blockHeight - 1) % NumBlocksPerSession) +} + +// GetSessionEndBlockHeight returns the block height at which the session ends +// Returns 0 if the block height is not a consensus produced block. +// Example: If NumBlocksPerSession == 4, sessions end at blocks 4, 8, 11, etc. +func GetSessionEndBlockHeight(blockHeight int64) int64 { + if blockHeight <= 0 { + return 0 + } + + return GetSessionStartBlockHeight(blockHeight) + NumBlocksPerSession - 1 +} + +// GetSessionNumber returns the session number given the block height. +// Returns session number 0 if the block height is not a consensus produced block. +// Returns session number 1 for block 1 to block NumBlocksPerSession - 1 (inclusive). +// i.e. If NubBlocksPerSession == 4, session == 1 for [1, 4], session == 2 for [5, 8], etc. +func GetSessionNumber(blockHeight int64) int64 { + if blockHeight <= 0 { + return 0 + } + + // TODO_BLOCKER(#543): If the num_blocks_per_session param has ever been changed, + // this function may cause unexpected behavior. + return ((blockHeight - 1) / NumBlocksPerSession) + 1 +} + +// GetSessionGracePeriodEndHeight returns the block height at which the grace period +// for the session ending with sessionEndHeight elapses. +func GetSessionGracePeriodEndHeight(sessionEndHeight int64) int64 { + return sessionEndHeight + SessionGracePeriodBlocks +} + +// IsGracePeriodElapsed returns true if the grace period for the session ending with +// sessionEndHeight has elapsed, given currentHeight. +func IsGracePeriodElapsed(sessionEndHeight, currentHeight int64) bool { + return currentHeight > GetSessionGracePeriodEndHeight(sessionEndHeight) +} diff --git a/x/shared/types/types.go b/x/shared/types/types.go index ab1254f4c..78d9ec9f9 100644 --- a/x/shared/types/types.go +++ b/x/shared/types/types.go @@ -1 +1,3 @@ package types + +// This file is in place to declare the package for dynamically generated protobufs diff --git a/x/tokenomics/keeper/keeper_test.go b/x/tokenomics/keeper/keeper_test.go index f5d7f527a..3fdd0dd88 100644 --- a/x/tokenomics/keeper/keeper_test.go +++ b/x/tokenomics/keeper/keeper_test.go @@ -18,8 +18,8 @@ import ( "github.com/pokt-network/poktroll/testutil/sample" apptypes "github.com/pokt-network/poktroll/x/application/types" prooftypes "github.com/pokt-network/poktroll/x/proof/types" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" + "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" tokenomicskeeper "github.com/pokt-network/poktroll/x/tokenomics/keeper" tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" @@ -60,7 +60,7 @@ func (s *TestSuite) SetupTest() { Service: &sharedtypes.Service{Id: testServiceId}, SessionId: "session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: sessionkeeper.GetSessionEndBlockHeight(1), + SessionEndBlockHeight: shared.GetSessionEndBlockHeight(1), }, RootHash: smstRootWithSum(69), } diff --git a/x/tokenomics/keeper/settle_pending_claims.go b/x/tokenomics/keeper/settle_pending_claims.go index a8600264c..59c87aa38 100644 --- a/x/tokenomics/keeper/settle_pending_claims.go +++ b/x/tokenomics/keeper/settle_pending_claims.go @@ -8,7 +8,7 @@ import ( "github.com/pokt-network/poktroll/telemetry" prooftypes "github.com/pokt-network/poktroll/x/proof/types" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" + "github.com/pokt-network/poktroll/x/shared" "github.com/pokt-network/poktroll/x/tokenomics/types" ) @@ -129,7 +129,7 @@ func (k Keeper) getExpiringClaims(ctx sdk.Context) (expiringClaims []prooftypes. // TODO_BLOCKER: query the on-chain governance parameter once available. // `* 3` is just a random factor Olshansky added for now to make sure expiration // doesn't happen immediately after a session's grace period is complete. - submitProofWindowEndHeight := sessionkeeper.GetSessionGracePeriodBlockCount() * 3 + submitProofWindowEndHeight := shared.SessionGracePeriodBlocks * int64(3) // TODO_BLOCKER(@Olshansk): Optimize this by indexing claims appropriately // and only retrieving the claims that need to be settled rather than all diff --git a/x/tokenomics/keeper/settle_session_accounting_test.go b/x/tokenomics/keeper/settle_session_accounting_test.go index c96934128..528250aa5 100644 --- a/x/tokenomics/keeper/settle_session_accounting_test.go +++ b/x/tokenomics/keeper/settle_session_accounting_test.go @@ -14,8 +14,8 @@ import ( "github.com/pokt-network/poktroll/testutil/sample" apptypes "github.com/pokt-network/poktroll/x/application/types" prooftypes "github.com/pokt-network/poktroll/x/proof/types" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" + "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" ) @@ -52,7 +52,7 @@ func TestSettleSessionAccounting_HandleAppGoingIntoDebt(t *testing.T) { }, SessionId: "session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: sessionkeeper.GetSessionEndBlockHeight(1), + SessionEndBlockHeight: shared.GetSessionEndBlockHeight(1), }, RootHash: smstRootWithSum(appStake.Amount.Uint64() + 1), // More than the app stake } @@ -93,7 +93,7 @@ func TestSettleSessionAccounting_AppNotFound(t *testing.T) { }, SessionId: "session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: sessionkeeper.GetSessionEndBlockHeight(1), + SessionEndBlockHeight: shared.GetSessionEndBlockHeight(1), }, RootHash: smstRootWithSum(42), } @@ -297,7 +297,7 @@ func baseClaim(appAddr, supplierAddr string, sum uint64) prooftypes.Claim { }, SessionId: "session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: sessionkeeper.GetSessionEndBlockHeight(1), + SessionEndBlockHeight: shared.GetSessionEndBlockHeight(1), }, RootHash: smstRootWithSum(sum), }