From a3d3d176c93b6367aa876591fe52c5461d1da8ee Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 14 May 2024 14:48:22 +0200 Subject: [PATCH 01/61] feat: add `num_blocks_per_session` session module param --- api/poktroll/session/params.pulsar.go | 94 ++++++++++++++++++++---- api/poktroll/session/tx.pulsar.go | 53 ++++++------- config.yml | 3 + e2e/tests/params_types_test.go | 5 -- e2e/tests/parse_params_test.go | 70 ++++++++++++++++++ e2e/tests/update_params.feature | 13 +++- e2e/tests/update_params_test.go | 64 +++++++++++++++- proto/poktroll/session/params.proto | 2 + proto/poktroll/session/tx.proto | 2 +- tools/scripts/params/session_all.json | 13 ++++ x/application/types/params.go | 2 + x/proof/types/params.go | 4 +- x/service/types/params.go | 5 +- x/session/types/errors.go | 2 + x/session/types/genesis.go | 2 +- x/session/types/message_update_params.go | 2 +- x/session/types/params.go | 47 ++++++++++-- 17 files changed, 321 insertions(+), 62 deletions(-) create mode 100644 tools/scripts/params/session_all.json diff --git a/api/poktroll/session/params.pulsar.go b/api/poktroll/session/params.pulsar.go index c9ea81482..39d1e8a86 100644 --- a/api/poktroll/session/params.pulsar.go +++ b/api/poktroll/session/params.pulsar.go @@ -15,12 +15,14 @@ import ( ) var ( - md_Params protoreflect.MessageDescriptor + md_Params protoreflect.MessageDescriptor + fd_Params_num_blocks_per_session protoreflect.FieldDescriptor ) func init() { file_poktroll_session_params_proto_init() md_Params = File_poktroll_session_params_proto.Messages().ByName("Params") + fd_Params_num_blocks_per_session = md_Params.Fields().ByName("num_blocks_per_session") } var _ protoreflect.Message = (*fastReflection_Params)(nil) @@ -88,6 +90,12 @@ func (x *fastReflection_Params) Interface() protoreflect.ProtoMessage { // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_Params) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.NumBlocksPerSession != uint64(0) { + value := protoreflect.ValueOfUint64(x.NumBlocksPerSession) + if !f(fd_Params_num_blocks_per_session, value) { + return + } + } } // Has reports whether a field is populated. @@ -103,6 +111,8 @@ func (x *fastReflection_Params) Range(f func(protoreflect.FieldDescriptor, proto // a repeated field is populated if it is non-empty. func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { + case "poktroll.session.Params.num_blocks_per_session": + return x.NumBlocksPerSession != uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Params")) @@ -119,6 +129,8 @@ func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool { // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Params) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { + case "poktroll.session.Params.num_blocks_per_session": + x.NumBlocksPerSession = uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Params")) @@ -135,6 +147,9 @@ func (x *fastReflection_Params) Clear(fd protoreflect.FieldDescriptor) { // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { + case "poktroll.session.Params.num_blocks_per_session": + value := x.NumBlocksPerSession + return protoreflect.ValueOfUint64(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Params")) @@ -155,6 +170,8 @@ func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) pro // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Params) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { + case "poktroll.session.Params.num_blocks_per_session": + x.NumBlocksPerSession = value.Uint() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Params")) @@ -175,6 +192,8 @@ func (x *fastReflection_Params) Set(fd protoreflect.FieldDescriptor, value proto // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Params) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "poktroll.session.Params.num_blocks_per_session": + panic(fmt.Errorf("field num_blocks_per_session of message poktroll.session.Params is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Params")) @@ -188,6 +207,8 @@ func (x *fastReflection_Params) Mutable(fd protoreflect.FieldDescriptor) protore // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_Params) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "poktroll.session.Params.num_blocks_per_session": + return protoreflect.ValueOfUint64(uint64(0)) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Params")) @@ -257,6 +278,9 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { var n int var l int _ = l + if x.NumBlocksPerSession != 0 { + n += 1 + runtime.Sov(uint64(x.NumBlocksPerSession)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -286,6 +310,11 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if x.NumBlocksPerSession != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.NumBlocksPerSession)) + i-- + dAtA[i] = 0x8 + } if input.Buf != nil { input.Buf = append(input.Buf, dAtA...) } else { @@ -335,6 +364,25 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field NumBlocksPerSession", wireType) + } + x.NumBlocksPerSession = 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.NumBlocksPerSession |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -388,6 +436,8 @@ type Params struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + NumBlocksPerSession uint64 `protobuf:"varint,1,opt,name=num_blocks_per_session,json=numBlocksPerSession,proto3" json:"num_blocks_per_session,omitempty"` } func (x *Params) Reset() { @@ -410,6 +460,13 @@ func (*Params) Descriptor() ([]byte, []int) { return file_poktroll_session_params_proto_rawDescGZIP(), []int{0} } +func (x *Params) GetNumBlocksPerSession() uint64 { + if x != nil { + return x.NumBlocksPerSession + } + return 0 +} + var File_poktroll_session_params_proto protoreflect.FileDescriptor var file_poktroll_session_params_proto_rawDesc = []byte{ @@ -418,21 +475,26 @@ var file_poktroll_session_params_proto_rawDesc = []byte{ 0x10, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x1a, 0x11, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x6d, 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, 0x22, 0x2c, 0x0a, 0x06, 0x50, 0x61, - 0x72, 0x61, 0x6d, 0x73, 0x3a, 0x22, 0xe8, 0xa0, 0x1f, 0x01, 0x8a, 0xe7, 0xb0, 0x2a, 0x19, 0x70, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x78, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x2f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xa7, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, - 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x42, 0x0b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x21, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, - 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, - 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xca, 0x02, 0x10, 0x50, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xe2, - 0x02, 0x1c, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, - 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x7d, 0x0a, 0x06, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x12, 0x4f, 0x0a, 0x16, 0x6e, 0x75, 0x6d, 0x5f, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x04, 0x42, 0x1a, 0xea, 0xde, 0x1f, 0x16, 0x6e, 0x75, 0x6d, 0x5f, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x52, 0x13, 0x6e, 0x75, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x22, 0xe8, 0xa0, 0x1f, 0x01, 0x8a, 0xe7, 0xb0, 0x2a, 0x19, + 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x78, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x2f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xa7, 0x01, 0x0a, 0x14, 0x63, 0x6f, + 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x42, 0x0b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, + 0x01, 0x5a, 0x21, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x10, 0x50, 0x6f, 0x6b, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xca, 0x02, 0x10, + 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0xe2, 0x02, 0x1c, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, + 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/poktroll/session/tx.pulsar.go b/api/poktroll/session/tx.pulsar.go index deb862e76..c391cfd4b 100644 --- a/api/poktroll/session/tx.pulsar.go +++ b/api/poktroll/session/tx.pulsar.go @@ -972,38 +972,39 @@ var file_poktroll_session_tx_proto_rawDesc = []byte{ 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, 0x1d, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x70, 0x61, 0x72, - 0x61, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbd, 0x01, 0x0a, 0x0f, 0x4d, 0x73, + 0x61, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc7, 0x01, 0x0a, 0x0f, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x36, 0x0a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x61, 0x75, 0x74, 0x68, - 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x3b, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, + 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x45, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, - 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, - 0x6d, 0x73, 0x3a, 0x35, 0x82, 0xe7, 0xb0, 0x2a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, - 0x74, 0x79, 0x8a, 0xe7, 0xb0, 0x2a, 0x22, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, - 0x78, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x19, 0x0a, 0x17, 0x4d, 0x73, 0x67, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x6a, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x5c, 0x0a, 0x0c, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x21, 0x2e, 0x70, 0x6f, - 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x4d, - 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x29, - 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, - 0x42, 0xa3, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, - 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x21, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, - 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, - 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x10, - 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0xca, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0xe2, 0x02, 0x1c, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, - 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0xea, 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, - 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x13, 0xc8, 0xde, 0x1f, 0x00, 0xea, 0xde, 0x1f, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0xa8, + 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x3a, 0x35, 0x82, 0xe7, + 0xb0, 0x2a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x8a, 0xe7, 0xb0, 0x2a, + 0x22, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x78, 0x2f, 0x73, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x2f, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, + 0x61, 0x6d, 0x73, 0x22, 0x19, 0x0a, 0x17, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x6a, + 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x5c, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x21, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x29, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x4d, 0x73, 0x67, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0xa3, 0x01, 0x0a, 0x14, 0x63, + 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x21, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xca, 0x02, 0x10, 0x50, 0x6f, 0x6b, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xe2, 0x02, 0x1c, + 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x11, 0x50, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/config.yml b/config.yml index 217397882..ef28519a3 100644 --- a/config.yml +++ b/config.yml @@ -179,3 +179,6 @@ genesis: service: params: add_service_fee: "1000000000" + session: + params: + num_blocks_per_session: 4 diff --git a/e2e/tests/params_types_test.go b/e2e/tests/params_types_test.go index 30b736b31..facd7abca 100644 --- a/e2e/tests/params_types_test.go +++ b/e2e/tests/params_types_test.go @@ -2,11 +2,6 @@ package e2e -const ( - computeUnitsToTokensMultipler = "compute_units_to_tokens_multiplier" - minRelayDifficultyBits = "min_relay_difficulty_bits" -) - type ( // moduleNameKey is the key for a module name in the module params map. moduleNameKey = string diff --git a/e2e/tests/parse_params_test.go b/e2e/tests/parse_params_test.go index ef4f59146..82b7bcd2c 100644 --- a/e2e/tests/parse_params_test.go +++ b/e2e/tests/parse_params_test.go @@ -10,7 +10,10 @@ import ( "github.com/cosmos/gogoproto/proto" "github.com/regen-network/gocuke" + apptypes "github.com/pokt-network/poktroll/x/application/types" prooftypes "github.com/pokt-network/poktroll/x/proof/types" + servicetypes "github.com/pokt-network/poktroll/x/service/types" + sessiontypes "github.com/pokt-network/poktroll/x/session/types" tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" ) @@ -71,6 +74,13 @@ func (s *suite) paramsMapToMsgUpdateParams(moduleName string, paramsMap paramsMa msgUpdateParams = s.newTokenomicsMsgUpdateParams(paramsMap) case prooftypes.ModuleName: msgUpdateParams = s.newProofMsgUpdateParams(paramsMap) + case sessiontypes.ModuleName: + msgUpdateParams = s.newSessionMsgUpdateParams(paramsMap) + case apptypes.ModuleName: + msgUpdateParams = s.newAppMsgUpdateParams(paramsMap) + case servicetypes.ModuleName: + msgUpdateParams = s.newServiceMsgUpdateParams(paramsMap) + // NB: gateway & supplier modules currently have no parameters default: err := fmt.Errorf("unexpected module name %q", moduleName) s.Fatal(err) @@ -119,6 +129,66 @@ func (s *suite) newProofMsgUpdateParams(params paramsMap) cosmostypes.Msg { return proto.Message(msgUpdateParams) } +func (s *suite) newSessionMsgUpdateParams(params paramsMap) cosmostypes.Msg { + authority := authtypes.NewModuleAddress(s.granterName).String() + + msgUpdateParams := &sessiontypes.MsgUpdateParams{ + Authority: authority, + Params: sessiontypes.Params{}, + } + + for paramName, paramValue := range params { + s.Logf("paramName: %s, value: %v", paramName, paramValue.value) + switch paramName { + case sessiontypes.NameNumBlocksPerSession: + msgUpdateParams.Params.NumBlocksPerSession = paramValue.value.(int64) + default: + s.Fatalf("unexpected %q type param name %q", paramValue.typeStr, paramName) + } + } + return proto.Message(msgUpdateParams) +} + +func (s *suite) newAppMsgUpdateParams(params paramsMap) cosmostypes.Msg { + authority := authtypes.NewModuleAddress(s.granterName).String() + + msgUpdateParams := &apptypes.MsgUpdateParams{ + Authority: authority, + Params: apptypes.Params{}, + } + + for paramName, paramValue := range params { + s.Logf("paramName: %s, value: %v", paramName, paramValue.value) + switch paramName { + case apptypes.NameMaxDelegatedGateways: + msgUpdateParams.Params.MaxDelegatedGateways = uint64(paramValue.value.(int64)) + default: + s.Fatalf("unexpected %q type param name %q", paramValue.typeStr, paramName) + } + } + return proto.Message(msgUpdateParams) +} + +func (s *suite) newServiceMsgUpdateParams(params paramsMap) cosmostypes.Msg { + authority := authtypes.NewModuleAddress(s.granterName).String() + + msgUpdateParams := &servicetypes.MsgUpdateParams{ + Authority: authority, + Params: servicetypes.Params{}, + } + + for paramName, paramValue := range params { + s.Logf("paramName: %s, value: %v", paramName, paramValue.value) + switch paramName { + case servicetypes.NameAddServiceFee: + msgUpdateParams.Params.AddServiceFee = uint64(paramValue.value.(int64)) + default: + s.Fatalf("unexpected %q type param name %q", paramValue.typeStr, paramName) + } + } + return proto.Message(msgUpdateParams) +} + // newMsgUpdateParam returns a MsgUpdateParam for the given module name, param name, // and param type/value. func (s *suite) newMsgUpdateParam( diff --git a/e2e/tests/update_params.feature b/e2e/tests/update_params.feature index e88f17819..3c19802c8 100644 --- a/e2e/tests/update_params.feature +++ b/e2e/tests/update_params.feature @@ -33,6 +33,17 @@ Feature: Params Namespace | min_relay_difficulty_bits | 8 | int64 | Then all "proof" module params should be updated + # NB: If you are reading this and the proof module has parameters + # that are not being updated in this test, please update the test. + Scenario: An authorized user updates all "session" module params + Given the user has the pocketd binary installed + And all "session" 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.session.MsgUpdateParams" message exists + When the "pnf" account sends an authz exec message to update all "session" module params + | name | value | type | + | num_blocks_per_session | 10 | int64 | + Then all "session" module params should be updated + # NB: If you are reading this and any module has parameters that # are not being updated in this test, please update the test. Scenario Outline: An authorized user updates individual module params @@ -49,7 +60,7 @@ Feature: Params Namespace | tokenomics | /poktroll.tokenomics.MsgUpdateParam | compute_units_to_tokens_multiplier | 68 | int64 | | proof | /poktroll.proof.MsgUpdateParam | min_relay_difficulty_bits | 12 | int64 | - Scenario: An unauthorized cannot update individual module params + Scenario: An unauthorized user cannot update individual module params Given the user has the pocketd binary installed And all "proof" 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.proof.MsgUpdateParams" message exists diff --git a/e2e/tests/update_params_test.go b/e2e/tests/update_params_test.go index ca66e4dbd..7671a7555 100644 --- a/e2e/tests/update_params_test.go +++ b/e2e/tests/update_params_test.go @@ -15,7 +15,12 @@ import ( "github.com/regen-network/gocuke" "github.com/stretchr/testify/require" + apptypes "github.com/pokt-network/poktroll/x/application/types" + gatewaytypes "github.com/pokt-network/poktroll/x/gateway/types" prooftypes "github.com/pokt-network/poktroll/x/proof/types" + servicetypes "github.com/pokt-network/poktroll/x/service/types" + sessiontypes "github.com/pokt-network/poktroll/x/session/types" + suppliertypes "github.com/pokt-network/poktroll/x/supplier/types" tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" ) @@ -49,6 +54,31 @@ func (s *suite) AllModuleParamsAreSetToTheirDefaultValues(moduleName string) { s.cdc.MustUnmarshalJSON([]byte(res.Stdout), &proofParamsRes) require.Equal(s, prooftypes.DefaultParams(), proofParamsRes.GetParams()) + case sessiontypes.ModuleName: + var sessionParamsRes sessiontypes.QueryParamsResponse + s.cdc.MustUnmarshalJSON([]byte(res.Stdout), &sessionParamsRes) + require.Equal(s, sessiontypes.DefaultParams(), sessionParamsRes.GetParams()) + + case apptypes.ModuleName: + var appParamsRes apptypes.QueryParamsResponse + s.cdc.MustUnmarshalJSON([]byte(res.Stdout), &appParamsRes) + require.Equal(s, apptypes.DefaultParams(), appParamsRes.GetParams()) + + case gatewaytypes.ModuleName: + var gatewayParamsRes gatewaytypes.QueryParamsResponse + s.cdc.MustUnmarshalJSON([]byte(res.Stdout), &gatewayParamsRes) + require.Equal(s, gatewaytypes.DefaultParams(), gatewayParamsRes.GetParams()) + + case suppliertypes.ModuleName: + var supplierParamsRes suppliertypes.QueryParamsResponse + s.cdc.MustUnmarshalJSON([]byte(res.Stdout), &supplierParamsRes) + require.Equal(s, suppliertypes.DefaultParams(), supplierParamsRes.GetParams()) + + case servicetypes.ModuleName: + var serviceParamsRes servicetypes.QueryParamsResponse + s.cdc.MustUnmarshalJSON([]byte(res.Stdout), &serviceParamsRes) + require.Equal(s, servicetypes.DefaultParams(), serviceParamsRes.GetParams()) + default: s.Fatalf("unexpected module name: (%v)", moduleName) } @@ -276,7 +306,7 @@ func (s *suite) assertExpectedModuleParamsUpdated(moduleName string) { switch moduleName { case tokenomicstypes.ModuleName: - computeUnitsToTokensMultiplier := uint64(s.expectedModuleParams[moduleName][computeUnitsToTokensMultipler].value.(int64)) + computeUnitsToTokensMultiplier := uint64(s.expectedModuleParams[moduleName][tokenomicstypes.NameComputeUnitsToTokensMultiplier].value.(int64)) assertUpdatedParams(s, []byte(res.Stdout), &tokenomicstypes.QueryParamsResponse{ @@ -286,7 +316,7 @@ func (s *suite) assertExpectedModuleParamsUpdated(moduleName string) { }, ) case prooftypes.ModuleName: - minRelayDifficultyBits := uint64(s.expectedModuleParams[moduleName][minRelayDifficultyBits].value.(int64)) + minRelayDifficultyBits := uint64(s.expectedModuleParams[moduleName][prooftypes.NameMinRelayDifficultyBits].value.(int64)) assertUpdatedParams(s, []byte(res.Stdout), &prooftypes.QueryParamsResponse{ @@ -295,6 +325,36 @@ func (s *suite) assertExpectedModuleParamsUpdated(moduleName string) { }, }, ) + case sessiontypes.ModuleName: + numBlocksPerSession := s.expectedModuleParams[moduleName][sessiontypes.NameNumBlocksPerSession].value.(int64) + assertUpdatedParams(s, + []byte(res.Stdout), + &sessiontypes.QueryParamsResponse{ + Params: sessiontypes.Params{ + NumBlocksPerSession: numBlocksPerSession, + }, + }, + ) + case apptypes.ModuleName: + maxDelegatedGateways := uint64(s.expectedModuleParams[moduleName][apptypes.NameMaxDelegatedGateways].value.(int64)) + assertUpdatedParams(s, + []byte(res.Stdout), + &apptypes.QueryParamsResponse{ + Params: apptypes.Params{ + MaxDelegatedGateways: maxDelegatedGateways, + }, + }, + ) + case servicetypes.ModuleName: + addServiceFee := uint64(s.expectedModuleParams[moduleName][servicetypes.NameAddServiceFee].value.(int64)) + assertUpdatedParams(s, + []byte(res.Stdout), + &servicetypes.QueryParamsResponse{ + Params: servicetypes.Params{ + AddServiceFee: addServiceFee, + }, + }, + ) default: s.Fatalf("unexpected module name %q", moduleName) } diff --git a/proto/poktroll/session/params.proto b/proto/poktroll/session/params.proto index cbe3559dc..33f7c0077 100644 --- a/proto/poktroll/session/params.proto +++ b/proto/poktroll/session/params.proto @@ -10,4 +10,6 @@ import "gogoproto/gogo.proto"; message Params { option (amino.name) = "poktroll/x/session/Params"; option (gogoproto.equal) = true; + + uint64 num_blocks_per_session = 1 [(gogoproto.jsontag) = "num_blocks_per_session"]; } \ No newline at end of file diff --git a/proto/poktroll/session/tx.proto b/proto/poktroll/session/tx.proto index 747ed8888..c0434408e 100644 --- a/proto/poktroll/session/tx.proto +++ b/proto/poktroll/session/tx.proto @@ -33,7 +33,7 @@ message MsgUpdateParams { // params defines the x/session parameters to update. // NOTE: All parameters must be supplied. - Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + Params params = 2 [(gogoproto.jsontag) = "params",(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // MsgUpdateParamsResponse defines the response structure for executing a diff --git a/tools/scripts/params/session_all.json b/tools/scripts/params/session_all.json new file mode 100644 index 000000000..ad3294cb3 --- /dev/null +++ b/tools/scripts/params/session_all.json @@ -0,0 +1,13 @@ +{ + "body": { + "messages": [ + { + "@type": "/poktroll.session.MsgUpdateParams", + "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", + "params": { + "num_blocks_per_session": "8" + } + } + ] + } +} diff --git a/x/application/types/params.go b/x/application/types/params.go index 7542f35ac..3bf923e51 100644 --- a/x/application/types/params.go +++ b/x/application/types/params.go @@ -6,6 +6,8 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) +const NameMaxDelegatedGateways = "max_delegated_gateways" + var ( _ paramtypes.ParamSet = (*Params)(nil) diff --git a/x/proof/types/params.go b/x/proof/types/params.go index f8d80f3ba..0962e765c 100644 --- a/x/proof/types/params.go +++ b/x/proof/types/params.go @@ -53,11 +53,11 @@ func (params *Params) ValidateBasic() error { func ValidateMinRelayDifficultyBits(v interface{}) error { difficulty, ok := v.(uint64) if !ok { - return ErrProofParamNameInvalid.Wrapf("invalid parameter type: %T", v) + return ErrProofParamInvalid.Wrapf("invalid parameter type: %T", v) } if difficulty < 0 { - return ErrProofParamNameInvalid.Wrapf("invalid ValidateMinRelayDifficultyBits: (%v)", difficulty) + return ErrProofParamInvalid.Wrapf("invalid MinRelayDifficultyBits: (%v)", difficulty) } return nil diff --git a/x/service/types/params.go b/x/service/types/params.go index 48af04d00..5d1a6e436 100644 --- a/x/service/types/params.go +++ b/x/service/types/params.go @@ -9,7 +9,10 @@ import ( // DefaultAddServiceFee is the default value for the add service fee // parameter in the genesis state of the service module. // TODO_BLOCKER: Revisit default param values for service fee -const DefaultAddServiceFee = 1000000000 // 1000 POKT +const ( + NameAddServiceFee = "add_service_fee" + DefaultAddServiceFee = 1000000000 // 1000 POKT +) var ( _ paramtypes.ParamSet = (*Params)(nil) diff --git a/x/session/types/errors.go b/x/session/types/errors.go index 6ffff939c..c6339194d 100644 --- a/x/session/types/errors.go +++ b/x/session/types/errors.go @@ -15,4 +15,6 @@ var ( ErrSessionInvalidService = sdkerrors.Register(ModuleName, 1106, "invalid service in session") ErrSessionInvalidBlockHeight = sdkerrors.Register(ModuleName, 1107, "invalid block height for session") ErrSessionInvalidSessionId = sdkerrors.Register(ModuleName, 1108, "invalid sessionId") + ErrSessionParamNameInvalid = sdkerrors.Register(ModuleName, 1109, "the provided param name is invalid") + ErrSessionParamInvalid = sdkerrors.Register(ModuleName, 1110, "the provided param is invalid") ) diff --git a/x/session/types/genesis.go b/x/session/types/genesis.go index a88ab1682..60d614ce4 100644 --- a/x/session/types/genesis.go +++ b/x/session/types/genesis.go @@ -15,5 +15,5 @@ func DefaultGenesis() *GenesisState { func (gs GenesisState) Validate() error { // this line is used by starport scaffolding # genesis/types/validate - return gs.Params.Validate() + return gs.Params.ValidateBasic() } diff --git a/x/session/types/message_update_params.go b/x/session/types/message_update_params.go index aeed4a633..e5f5ab0bc 100644 --- a/x/session/types/message_update_params.go +++ b/x/session/types/message_update_params.go @@ -13,7 +13,7 @@ func (m *MsgUpdateParams) ValidateBasic() error { return errorsmod.Wrap(err, "invalid authority address") } - if err := m.Params.Validate(); err != nil { + if err := m.Params.ValidateBasic(); err != nil { return err } diff --git a/x/session/types/params.go b/x/session/types/params.go index 95b0cf8a2..b7bae799d 100644 --- a/x/session/types/params.go +++ b/x/session/types/params.go @@ -2,7 +2,15 @@ package types import paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" -var _ paramtypes.ParamSet = (*Params)(nil) +const ( + DefaultNumBlocksPerSession = 4 + NameNumBlocksPerSession = "num_blocks_per_session" +) + +var ( + _ paramtypes.ParamSet = (*Params)(nil) + KeyNumBlocksPerSession = []byte("NumBlocksPerSession") +) // ParamKeyTable the param key table for launch module func ParamKeyTable() paramtypes.KeyTable { @@ -11,7 +19,9 @@ func ParamKeyTable() paramtypes.KeyTable { // NewParams creates a new Params instance func NewParams() Params { - return Params{} + return Params{ + NumBlocksPerSession: DefaultNumBlocksPerSession, + } } // DefaultParams returns a default set of parameters @@ -20,11 +30,36 @@ func DefaultParams() Params { } // ParamSetPairs get the params.ParamSet -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{} +func (params *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair( + KeyNumBlocksPerSession, + ¶ms.NumBlocksPerSession, + ValidateNumBlocksPerSession, + ), + } } -// Validate validates the set of params -func (p Params) Validate() error { +// ValidateBasic does a sanity check on the provided params. +func (params *Params) ValidateBasic() error { + if err := ValidateNumBlocksPerSession(params.NumBlocksPerSession); err != nil { + return err + } + + return nil +} + +// ValidateNumBlocksPerSession validates the MinRelayDifficultyBits param +// NB: The argument is an interface type to satisfy the ParamSetPair function signature. +func ValidateNumBlocksPerSession(v interface{}) error { + numBlocksPerSession, ok := v.(uint64) + if !ok { + return ErrSessionParamInvalid.Wrapf("invalid parameter type: %T", v) + } + + if numBlocksPerSession < 0 { + return ErrSessionParamInvalid.Wrapf("invalid NumBlocksPerSession: (%v)", numBlocksPerSession) + } + return nil } From 99455d56f75113839504873a0a4482d9b2db9c62 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 15 May 2024 10:17:01 +0200 Subject: [PATCH 02/61] feat: add make target to update all session params --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile b/Makefile index cde147271..fcaa90543 100644 --- a/Makefile +++ b/Makefile @@ -800,6 +800,7 @@ claim_list_session: ## List all the claims ending at a specific session (specifi # TODO_CONSIDERATION: additional factoring (e.g. POKTROLLD_FLAGS). PARAM_FLAGS = --home=$(POKTROLLD_HOME) --keyring-backend test --from $(PNF_ADDRESS) --node $(POCKET_NODE) +### Tokenomics Module Params ### .PHONY: update_tokenomics_params_all params_update_tokenomics_all: ## Update the tokenomics module params poktrolld tx authz exec ./tools/scripts/params/tokenomics_all.json $(PARAM_FLAGS) @@ -808,6 +809,7 @@ params_update_tokenomics_all: ## Update the tokenomics module params params_update_tokenomics_compute_units_to_tokens_multiplier: ## Update the tokenomics module params poktrolld tx authz exec ./tools/scripts/params/tokenomics_compute_units_to_tokens_multiplier.json $(PARAM_FLAGS) +### Proof Module Params ### .PHONY: params_update_proof_all params_update_proof_all: ## Update the proof module params poktrolld tx authz exec ./tools/scripts/params/proof_all.json $(PARAM_FLAGS) @@ -816,6 +818,11 @@ params_update_proof_all: ## Update the proof module params params_update_proof_min_relay_difficulty_bits: ## Update the proof module params poktrolld tx authz exec ./tools/scripts/params/proof_min_relay_difficulty_bits.json $(PARAM_FLAGS) +### Session Module Params ### +.PHONY: params_update_session_all +params_update_session_all: ## Update the session module params + poktrolld tx authz exec ./tools/scripts/params/session_all.json $(PARAM_FLAGS) + .PHONY: params_query_all params_query_all: check_jq ## Query the params from all available modules @for module in $(MODULES); do \ From 05e631a74cf6b0b6f42f2f622eac7e247b1ba6c5 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 15 May 2024 10:17:42 +0200 Subject: [PATCH 03/61] chore: use default param values in param update msgs --- tools/scripts/params/proof_min_relay_difficulty_bits.json | 2 +- tools/scripts/params/session_all.json | 2 +- .../params/tokenomics_compute_units_to_tokens_multiplier.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/scripts/params/proof_min_relay_difficulty_bits.json b/tools/scripts/params/proof_min_relay_difficulty_bits.json index 6f6ade8c7..72c14a1d5 100644 --- a/tools/scripts/params/proof_min_relay_difficulty_bits.json +++ b/tools/scripts/params/proof_min_relay_difficulty_bits.json @@ -5,7 +5,7 @@ "@type": "/poktroll.proof.MsgUpdateParam", "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", "name": "min_relay_difficulty_bits", - "as_int64": "10" + "as_int64": "0" } ] } diff --git a/tools/scripts/params/session_all.json b/tools/scripts/params/session_all.json index ad3294cb3..55b2f6200 100644 --- a/tools/scripts/params/session_all.json +++ b/tools/scripts/params/session_all.json @@ -5,7 +5,7 @@ "@type": "/poktroll.session.MsgUpdateParams", "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", "params": { - "num_blocks_per_session": "8" + "num_blocks_per_session": "4" } } ] diff --git a/tools/scripts/params/tokenomics_compute_units_to_tokens_multiplier.json b/tools/scripts/params/tokenomics_compute_units_to_tokens_multiplier.json index 10c34f501..363bb1350 100644 --- a/tools/scripts/params/tokenomics_compute_units_to_tokens_multiplier.json +++ b/tools/scripts/params/tokenomics_compute_units_to_tokens_multiplier.json @@ -5,7 +5,7 @@ "@type": "/poktroll.tokenomics.MsgUpdateParam", "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", "name": "compute_units_to_tokens_multiplier", - "as_int64": "69" + "as_int64": "42" } ] } From bf3bff3be892c2f7c9e8a975e76148770b332abf Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 15 May 2024 14:19:01 +0200 Subject: [PATCH 04/61] Empty commit From 3aa53ec364ab9a14a2013c8fbfc2171e401fb874 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 15 May 2024 14:31:19 +0200 Subject: [PATCH 05/61] fixup! feat: add `num_blocks_per_session` session module param --- e2e/tests/parse_params_test.go | 2 +- e2e/tests/update_params_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/tests/parse_params_test.go b/e2e/tests/parse_params_test.go index 82b7bcd2c..abede73ac 100644 --- a/e2e/tests/parse_params_test.go +++ b/e2e/tests/parse_params_test.go @@ -141,7 +141,7 @@ func (s *suite) newSessionMsgUpdateParams(params paramsMap) cosmostypes.Msg { s.Logf("paramName: %s, value: %v", paramName, paramValue.value) switch paramName { case sessiontypes.NameNumBlocksPerSession: - msgUpdateParams.Params.NumBlocksPerSession = paramValue.value.(int64) + msgUpdateParams.Params.NumBlocksPerSession = uint64(paramValue.value.(int64)) default: s.Fatalf("unexpected %q type param name %q", paramValue.typeStr, paramName) } diff --git a/e2e/tests/update_params_test.go b/e2e/tests/update_params_test.go index 7671a7555..535aecc74 100644 --- a/e2e/tests/update_params_test.go +++ b/e2e/tests/update_params_test.go @@ -326,7 +326,7 @@ func (s *suite) assertExpectedModuleParamsUpdated(moduleName string) { }, ) case sessiontypes.ModuleName: - numBlocksPerSession := s.expectedModuleParams[moduleName][sessiontypes.NameNumBlocksPerSession].value.(int64) + numBlocksPerSession := uint64(s.expectedModuleParams[moduleName][sessiontypes.NameNumBlocksPerSession].value.(int64)) assertUpdatedParams(s, []byte(res.Stdout), &sessiontypes.QueryParamsResponse{ From d7a04dcbba009812f2f9fed0fcce866ee4cd1f53 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 16 May 2024 10:20:01 +0200 Subject: [PATCH 06/61] test: add coverage for sessiontypes.Params#ValidateNumBlocksPerSession() --- x/session/types/params_test.go | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 x/session/types/params_test.go diff --git a/x/session/types/params_test.go b/x/session/types/params_test.go new file mode 100644 index 000000000..5c9f2e829 --- /dev/null +++ b/x/session/types/params_test.go @@ -0,0 +1,42 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestParams_ValidateNumBlocksPerSession(t *testing.T) { + tests := []struct { + desc string + numBlocksPerSession any + err error + }{ + { + desc: "invalid type", + numBlocksPerSession: "invalid", + err: ErrSessionParamInvalid.Wrapf("invalid parameter type: %T", "invalid"), + }, + { + desc: "zero NumBlocksPerSession", + numBlocksPerSession: uint64(0), + err: ErrSessionParamInvalid.Wrapf("invalid NumBlocksPerSession: (%v)", uint64(0)), + }, + { + desc: "valid NumBlocksPerSession", + numBlocksPerSession: uint64(4), + }, + } + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + err := ValidateNumBlocksPerSession(tt.numBlocksPerSession) + if tt.err != nil { + require.Error(t, err) + require.Contains(t, err.Error(), tt.err.Error()) + } else { + require.NoError(t, err) + } + }) + } +} From 56ae9a84f3c0f6b382da25524c9faad8405ec942 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 16 May 2024 10:20:37 +0200 Subject: [PATCH 07/61] fix: #ValidateNumBlocksPerSession() --- x/session/types/params.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/session/types/params.go b/x/session/types/params.go index b7bae799d..b90119e07 100644 --- a/x/session/types/params.go +++ b/x/session/types/params.go @@ -57,7 +57,7 @@ func ValidateNumBlocksPerSession(v interface{}) error { return ErrSessionParamInvalid.Wrapf("invalid parameter type: %T", v) } - if numBlocksPerSession < 0 { + if numBlocksPerSession < 1 { return ErrSessionParamInvalid.Wrapf("invalid NumBlocksPerSession: (%v)", numBlocksPerSession) } From b291bc183996e621f3bffd1281d637b923f6c0c8 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 16 May 2024 10:21:43 +0200 Subject: [PATCH 08/61] chore: review feedback improvements Co-authored-by: Daniel Olshansky --- x/session/types/params.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/session/types/params.go b/x/session/types/params.go index b90119e07..d29506f6e 100644 --- a/x/session/types/params.go +++ b/x/session/types/params.go @@ -49,7 +49,7 @@ func (params *Params) ValidateBasic() error { return nil } -// ValidateNumBlocksPerSession validates the MinRelayDifficultyBits param +// ValidateNumBlocksPerSession validates the NumBlocksPerSession param // NB: The argument is an interface type to satisfy the ParamSetPair function signature. func ValidateNumBlocksPerSession(v interface{}) error { numBlocksPerSession, ok := v.(uint64) From 40e1e7f441055fd779ad06e8b9b4fb3150cd66cf Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 16 May 2024 10:28:03 +0200 Subject: [PATCH 09/61] refactor: rename param name vars --- e2e/tests/parse_params_test.go | 10 +++++----- e2e/tests/update_params_test.go | 10 +++++----- x/application/types/params.go | 2 +- x/proof/keeper/msg_server_update_param.go | 2 +- x/proof/keeper/msg_server_update_param_test.go | 2 +- x/proof/types/message_update_param.go | 2 +- x/proof/types/message_update_param_test.go | 4 ++-- x/proof/types/params.go | 2 +- x/service/types/params.go | 2 +- x/session/types/params.go | 2 +- x/tokenomics/keeper/msg_server_update_param.go | 2 +- x/tokenomics/keeper/msg_server_update_param_test.go | 2 +- x/tokenomics/types/message_update_param.go | 2 +- x/tokenomics/types/message_update_param_test.go | 4 ++-- x/tokenomics/types/params.go | 2 +- 15 files changed, 25 insertions(+), 25 deletions(-) diff --git a/e2e/tests/parse_params_test.go b/e2e/tests/parse_params_test.go index abede73ac..97d8e9b0f 100644 --- a/e2e/tests/parse_params_test.go +++ b/e2e/tests/parse_params_test.go @@ -100,7 +100,7 @@ func (s *suite) newTokenomicsMsgUpdateParams(params paramsMap) cosmostypes.Msg { for paramName, paramValue := range params { switch paramName { - case tokenomicstypes.NameComputeUnitsToTokensMultiplier: + case tokenomicstypes.ParamComputeUnitsToTokensMultiplier: msgUpdateParams.Params.ComputeUnitsToTokensMultiplier = uint64(paramValue.value.(int64)) default: s.Fatalf("unexpected %q type param name %q", paramValue.typeStr, paramName) @@ -120,7 +120,7 @@ func (s *suite) newProofMsgUpdateParams(params paramsMap) cosmostypes.Msg { for paramName, paramValue := range params { s.Logf("paramName: %s, value: %v", paramName, paramValue.value) switch paramName { - case prooftypes.NameMinRelayDifficultyBits: + case prooftypes.ParamMinRelayDifficultyBits: msgUpdateParams.Params.MinRelayDifficultyBits = uint64(paramValue.value.(int64)) default: s.Fatalf("unexpected %q type param name %q", paramValue.typeStr, paramName) @@ -140,7 +140,7 @@ func (s *suite) newSessionMsgUpdateParams(params paramsMap) cosmostypes.Msg { for paramName, paramValue := range params { s.Logf("paramName: %s, value: %v", paramName, paramValue.value) switch paramName { - case sessiontypes.NameNumBlocksPerSession: + case sessiontypes.ParamNumBlocksPerSession: msgUpdateParams.Params.NumBlocksPerSession = uint64(paramValue.value.(int64)) default: s.Fatalf("unexpected %q type param name %q", paramValue.typeStr, paramName) @@ -160,7 +160,7 @@ func (s *suite) newAppMsgUpdateParams(params paramsMap) cosmostypes.Msg { for paramName, paramValue := range params { s.Logf("paramName: %s, value: %v", paramName, paramValue.value) switch paramName { - case apptypes.NameMaxDelegatedGateways: + case apptypes.ParamMaxDelegatedGateways: msgUpdateParams.Params.MaxDelegatedGateways = uint64(paramValue.value.(int64)) default: s.Fatalf("unexpected %q type param name %q", paramValue.typeStr, paramName) @@ -180,7 +180,7 @@ func (s *suite) newServiceMsgUpdateParams(params paramsMap) cosmostypes.Msg { for paramName, paramValue := range params { s.Logf("paramName: %s, value: %v", paramName, paramValue.value) switch paramName { - case servicetypes.NameAddServiceFee: + case servicetypes.ParamAddServiceFee: msgUpdateParams.Params.AddServiceFee = uint64(paramValue.value.(int64)) default: s.Fatalf("unexpected %q type param name %q", paramValue.typeStr, paramName) diff --git a/e2e/tests/update_params_test.go b/e2e/tests/update_params_test.go index 535aecc74..0c01d294d 100644 --- a/e2e/tests/update_params_test.go +++ b/e2e/tests/update_params_test.go @@ -306,7 +306,7 @@ func (s *suite) assertExpectedModuleParamsUpdated(moduleName string) { switch moduleName { case tokenomicstypes.ModuleName: - computeUnitsToTokensMultiplier := uint64(s.expectedModuleParams[moduleName][tokenomicstypes.NameComputeUnitsToTokensMultiplier].value.(int64)) + computeUnitsToTokensMultiplier := uint64(s.expectedModuleParams[moduleName][tokenomicstypes.ParamComputeUnitsToTokensMultiplier].value.(int64)) assertUpdatedParams(s, []byte(res.Stdout), &tokenomicstypes.QueryParamsResponse{ @@ -316,7 +316,7 @@ func (s *suite) assertExpectedModuleParamsUpdated(moduleName string) { }, ) case prooftypes.ModuleName: - minRelayDifficultyBits := uint64(s.expectedModuleParams[moduleName][prooftypes.NameMinRelayDifficultyBits].value.(int64)) + minRelayDifficultyBits := uint64(s.expectedModuleParams[moduleName][prooftypes.ParamMinRelayDifficultyBits].value.(int64)) assertUpdatedParams(s, []byte(res.Stdout), &prooftypes.QueryParamsResponse{ @@ -326,7 +326,7 @@ func (s *suite) assertExpectedModuleParamsUpdated(moduleName string) { }, ) case sessiontypes.ModuleName: - numBlocksPerSession := uint64(s.expectedModuleParams[moduleName][sessiontypes.NameNumBlocksPerSession].value.(int64)) + numBlocksPerSession := uint64(s.expectedModuleParams[moduleName][sessiontypes.ParamNumBlocksPerSession].value.(int64)) assertUpdatedParams(s, []byte(res.Stdout), &sessiontypes.QueryParamsResponse{ @@ -336,7 +336,7 @@ func (s *suite) assertExpectedModuleParamsUpdated(moduleName string) { }, ) case apptypes.ModuleName: - maxDelegatedGateways := uint64(s.expectedModuleParams[moduleName][apptypes.NameMaxDelegatedGateways].value.(int64)) + maxDelegatedGateways := uint64(s.expectedModuleParams[moduleName][apptypes.ParamMaxDelegatedGateways].value.(int64)) assertUpdatedParams(s, []byte(res.Stdout), &apptypes.QueryParamsResponse{ @@ -346,7 +346,7 @@ func (s *suite) assertExpectedModuleParamsUpdated(moduleName string) { }, ) case servicetypes.ModuleName: - addServiceFee := uint64(s.expectedModuleParams[moduleName][servicetypes.NameAddServiceFee].value.(int64)) + addServiceFee := uint64(s.expectedModuleParams[moduleName][servicetypes.ParamAddServiceFee].value.(int64)) assertUpdatedParams(s, []byte(res.Stdout), &servicetypes.QueryParamsResponse{ diff --git a/x/application/types/params.go b/x/application/types/params.go index 3bf923e51..732aca8fb 100644 --- a/x/application/types/params.go +++ b/x/application/types/params.go @@ -6,7 +6,7 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) -const NameMaxDelegatedGateways = "max_delegated_gateways" +const ParamMaxDelegatedGateways = "max_delegated_gateways" var ( _ paramtypes.ParamSet = (*Params)(nil) diff --git a/x/proof/keeper/msg_server_update_param.go b/x/proof/keeper/msg_server_update_param.go index 1280e6b93..9b8770489 100644 --- a/x/proof/keeper/msg_server_update_param.go +++ b/x/proof/keeper/msg_server_update_param.go @@ -24,7 +24,7 @@ func (k msgServer) UpdateParam( params := k.GetParams(ctx) switch msg.Name { - case types.NameMinRelayDifficultyBits: + case types.ParamMinRelayDifficultyBits: value, ok := msg.AsType.(*types.MsgUpdateParam_AsInt64) if !ok { return nil, fmt.Errorf("unsupported value type for %s param: %T", msg.Name, msg.AsType) diff --git a/x/proof/keeper/msg_server_update_param_test.go b/x/proof/keeper/msg_server_update_param_test.go index fc98161fe..9b11ccb4f 100644 --- a/x/proof/keeper/msg_server_update_param_test.go +++ b/x/proof/keeper/msg_server_update_param_test.go @@ -24,7 +24,7 @@ func TestMsgUpdateParam_UpdateMinRelayDifficultyBitsOnly(t *testing.T) { // Update the min relay difficulty bits updateParamMsg := &prooftypes.MsgUpdateParam{ Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), - Name: prooftypes.NameMinRelayDifficultyBits, + Name: prooftypes.ParamMinRelayDifficultyBits, AsType: &prooftypes.MsgUpdateParam_AsInt64{AsInt64: expectedMinRelayDifficultyBits}, } res, err := msgSrv.UpdateParam(ctx, updateParamMsg) diff --git a/x/proof/types/message_update_param.go b/x/proof/types/message_update_param.go index a90efc87b..4b46e5e07 100644 --- a/x/proof/types/message_update_param.go +++ b/x/proof/types/message_update_param.go @@ -47,7 +47,7 @@ func (msg *MsgUpdateParam) ValidateBasic() error { // Parameter name must be supported by this module. switch msg.Name { - case NameMinRelayDifficultyBits: + case ParamMinRelayDifficultyBits: return msg.paramTypeIsInt64() default: return ErrProofParamNameInvalid.Wrapf("unsupported name param %q", msg.Name) diff --git a/x/proof/types/message_update_param_test.go b/x/proof/types/message_update_param_test.go index 37101a476..7b5328668 100644 --- a/x/proof/types/message_update_param_test.go +++ b/x/proof/types/message_update_param_test.go @@ -37,7 +37,7 @@ func TestMsgUpdateParam_ValidateBasic(t *testing.T) { name: "invalid: incorrect param type", msg: MsgUpdateParam{ Authority: sample.AccAddress(), - Name: NameMinRelayDifficultyBits, + Name: ParamMinRelayDifficultyBits, AsType: &MsgUpdateParam_AsString{AsString: "invalid"}, }, expectedErr: ErrProofParamInvalid, @@ -45,7 +45,7 @@ func TestMsgUpdateParam_ValidateBasic(t *testing.T) { name: "valid: correct authority and param name", msg: MsgUpdateParam{ Authority: sample.AccAddress(), - Name: NameMinRelayDifficultyBits, + Name: ParamMinRelayDifficultyBits, AsType: &MsgUpdateParam_AsInt64{AsInt64: 1}, }, diff --git a/x/proof/types/params.go b/x/proof/types/params.go index 0962e765c..aba00b70c 100644 --- a/x/proof/types/params.go +++ b/x/proof/types/params.go @@ -6,7 +6,7 @@ var ( _ paramtypes.ParamSet = (*Params)(nil) KeyMinRelayDifficultyBits = []byte("MinRelayDifficultyBits") - NameMinRelayDifficultyBits = "min_relay_difficulty_bits" + ParamMinRelayDifficultyBits = "min_relay_difficulty_bits" DefaultMinRelayDifficultyBits uint64 = 0 // TODO_BLOCKER(#142, #401): Determine the default value. ) diff --git a/x/service/types/params.go b/x/service/types/params.go index 5d1a6e436..ee3a4b792 100644 --- a/x/service/types/params.go +++ b/x/service/types/params.go @@ -10,7 +10,7 @@ import ( // parameter in the genesis state of the service module. // TODO_BLOCKER: Revisit default param values for service fee const ( - NameAddServiceFee = "add_service_fee" + ParamAddServiceFee = "add_service_fee" DefaultAddServiceFee = 1000000000 // 1000 POKT ) diff --git a/x/session/types/params.go b/x/session/types/params.go index d29506f6e..3fd7f5010 100644 --- a/x/session/types/params.go +++ b/x/session/types/params.go @@ -4,7 +4,7 @@ import paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" const ( DefaultNumBlocksPerSession = 4 - NameNumBlocksPerSession = "num_blocks_per_session" + ParamNumBlocksPerSession = "num_blocks_per_session" ) var ( diff --git a/x/tokenomics/keeper/msg_server_update_param.go b/x/tokenomics/keeper/msg_server_update_param.go index 1ca990d6d..0f1415e0f 100644 --- a/x/tokenomics/keeper/msg_server_update_param.go +++ b/x/tokenomics/keeper/msg_server_update_param.go @@ -24,7 +24,7 @@ func (k msgServer) UpdateParam( params := k.GetParams(ctx) switch msg.Name { - case types.NameComputeUnitsToTokensMultiplier: + case types.ParamComputeUnitsToTokensMultiplier: value, ok := msg.AsType.(*types.MsgUpdateParam_AsInt64) if !ok { return nil, fmt.Errorf("unsupported value type for %s param: %T", msg.Name, msg.AsType) diff --git a/x/tokenomics/keeper/msg_server_update_param_test.go b/x/tokenomics/keeper/msg_server_update_param_test.go index 2144d84b1..344734671 100644 --- a/x/tokenomics/keeper/msg_server_update_param_test.go +++ b/x/tokenomics/keeper/msg_server_update_param_test.go @@ -24,7 +24,7 @@ func TestMsgUpdateParam_UpdateMinRelayDifficultyBitsOnly(t *testing.T) { // Update the min relay difficulty bits updateParamMsg := &tokenomicstypes.MsgUpdateParam{ Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), - Name: tokenomicstypes.NameComputeUnitsToTokensMultiplier, + Name: tokenomicstypes.ParamComputeUnitsToTokensMultiplier, AsType: &tokenomicstypes.MsgUpdateParam_AsInt64{AsInt64: expectedComputeUnitsToTokensMultiplier}, } res, err := msgSrv.UpdateParam(ctx, updateParamMsg) diff --git a/x/tokenomics/types/message_update_param.go b/x/tokenomics/types/message_update_param.go index 4c96e20ee..32d0fa358 100644 --- a/x/tokenomics/types/message_update_param.go +++ b/x/tokenomics/types/message_update_param.go @@ -45,7 +45,7 @@ func (msg *MsgUpdateParam) ValidateBasic() error { // Parameter name must be supported by this module. switch msg.Name { - case NameComputeUnitsToTokensMultiplier: + case ParamComputeUnitsToTokensMultiplier: return msg.paramTypeIsInt64() default: return ErrTokenomicsParamNameInvalid.Wrapf("unsupported name param %q", msg.Name) diff --git a/x/tokenomics/types/message_update_param_test.go b/x/tokenomics/types/message_update_param_test.go index 6abb3aff4..c0898f089 100644 --- a/x/tokenomics/types/message_update_param_test.go +++ b/x/tokenomics/types/message_update_param_test.go @@ -36,7 +36,7 @@ func TestMsgUpdateParam_ValidateBasic(t *testing.T) { name: "invalid: incorrect param type", msg: MsgUpdateParam{ Authority: sample.AccAddress(), - Name: NameComputeUnitsToTokensMultiplier, + Name: ParamComputeUnitsToTokensMultiplier, AsType: &MsgUpdateParam_AsString{AsString: "invalid"}, }, expectedErr: ErrTokenomicsParamInvalid, @@ -44,7 +44,7 @@ func TestMsgUpdateParam_ValidateBasic(t *testing.T) { name: "valid: correct authority and param name", msg: MsgUpdateParam{ Authority: sample.AccAddress(), - Name: NameComputeUnitsToTokensMultiplier, + Name: ParamComputeUnitsToTokensMultiplier, AsType: &MsgUpdateParam_AsInt64{AsInt64: 1}, }, expectedErr: nil, diff --git a/x/tokenomics/types/params.go b/x/tokenomics/types/params.go index b7e9756f6..42f62d9b0 100644 --- a/x/tokenomics/types/params.go +++ b/x/tokenomics/types/params.go @@ -8,7 +8,7 @@ var ( _ paramtypes.ParamSet = (*Params)(nil) KeyComputeUnitsToTokensMultiplier = []byte("ComputeUnitsToTokensMultiplier") - NameComputeUnitsToTokensMultiplier = "compute_units_to_tokens_multiplier" + ParamComputeUnitsToTokensMultiplier = "compute_units_to_tokens_multiplier" DefaultComputeUnitsToTokensMultiplier uint64 = 42 // TODO_BLOCKER: Determine the default value. ) From 2c3338126f5ef9628d03302c216c834419e49bb5 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 16 May 2024 15:28:52 +0200 Subject: [PATCH 10/61] fix: unit tests --- x/session/keeper/msg_update_params_test.go | 2 +- x/session/module/genesis_test.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/x/session/keeper/msg_update_params_test.go b/x/session/keeper/msg_update_params_test.go index bf9df225b..f28228bd6 100644 --- a/x/session/keeper/msg_update_params_test.go +++ b/x/session/keeper/msg_update_params_test.go @@ -35,7 +35,7 @@ func TestMsgUpdateParams(t *testing.T) { Authority: k.GetAuthority(), Params: types.Params{}, }, - shouldError: false, + shouldError: true, }, { desc: "valid: send default params", diff --git a/x/session/module/genesis_test.go b/x/session/module/genesis_test.go index 91b8cc149..5fab07849 100644 --- a/x/session/module/genesis_test.go +++ b/x/session/module/genesis_test.go @@ -20,8 +20,11 @@ func TestGenesisState_Validate(t *testing.T) { isValid: true, }, { - desc: "valid genesis state", + desc: "valid genesis state", genState: &types.GenesisState{ + Params: types.Params{ + NumBlocksPerSession: 1, + }, // this line is used by starport scaffolding # types/genesis/validField }, From 86e114d24776e933be13713c7d525d50386ad92d Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 21 May 2024 13:40:10 +0200 Subject: [PATCH 11/61] Empty commit From eaf5f15f169ca36b00454008d3e976edc35acbab Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 22 May 2024 07:59:16 +0200 Subject: [PATCH 12/61] Empty commit From a757d5a93cdc6e9865dcbad5f5ffdcb435a57c7a Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 22 May 2024 08:18:22 +0200 Subject: [PATCH 13/61] Empty commit From 6c6ec62b4aa3c18488c28b62a69d004361585f80 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 22 May 2024 12:57:41 +0200 Subject: [PATCH 14/61] chore: add "unauthorized" account to config.yml instead of creating in E2E test --- config.yml | 4 ++++ e2e/tests/update_params.feature | 2 -- e2e/tests/update_params_test.go | 11 ----------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/config.yml b/config.yml index ef28519a3..d54a9cc30 100644 --- a/config.yml +++ b/config.yml @@ -51,6 +51,10 @@ accounts: mnemonic: "elder spatial erosion soap athlete tide subject recipe also awkward head pattern cart version beach usual oxygen confirm erupt diamond maze smooth census garment" coins: - 300000000upokt + - name: unauthorized + mnemonic: "abuse tumble whip pioneer immense pipe method note upon glory switch rail metal camp gasp top require rain party total struggle glance between fossil" + coins: + - 100000upokt faucet: name: faucet coins: diff --git a/e2e/tests/update_params.feature b/e2e/tests/update_params.feature index 3c19802c8..e1acb3a06 100644 --- a/e2e/tests/update_params.feature +++ b/e2e/tests/update_params.feature @@ -5,7 +5,6 @@ Feature: Params Namespace 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 - And a key and account exist for the "unauthorized" user 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 | @@ -64,7 +63,6 @@ Feature: Params Namespace Given the user has the pocketd binary installed And all "proof" 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.proof.MsgUpdateParams" message exists - And a key and account exist for the "unauthorized" user When the "unauthorized" account sends an authz exec message to update "proof" the module param | name | value | type | | "min_relay_difficulty_bits | 666 | int64 | diff --git a/e2e/tests/update_params_test.go b/e2e/tests/update_params_test.go index 0c01d294d..f0f1fff12 100644 --- a/e2e/tests/update_params_test.go +++ b/e2e/tests/update_params_test.go @@ -149,17 +149,6 @@ func (s *suite) AnAuthzGrantFromTheAccountToTheAccountForTheMessageExists( s.granteeName = granteeName } -// AKeyAndAccountExistForTheUser checks if a key with the given name exists in the keyring, -// and if not, adds a new key with the given name to the keyring. It then checks if an account -// corresponding the the new key exists. -func (s *suite) AKeyAndAccountExistForTheUser(keyName string) { - if !s.keyExistsInKeyring(keyName) { - s.addKeyToKeyring(keyName) - } - - s.ensureAccountForKeyName(keyName) -} - // AllModuleParamsShouldBeSetToTheirDefaultValues asserts that all module params are set to their default values. func (s *suite) AllModuleParamsShouldBeSetToTheirDefaultValues(moduleName string) { s.AllModuleParamsAreSetToTheirDefaultValues(moduleName) From 638f0c958cc797c0066af35142f305177744b895 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 16 May 2024 21:01:33 +0200 Subject: [PATCH 15/61] chore: add client.SessionQueryClient#GetParams interface method --- pkg/client/interface.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/client/interface.go b/pkg/client/interface.go index 77484c454..c9f7d127b 100644 --- a/pkg/client/interface.go +++ b/pkg/client/interface.go @@ -274,4 +274,6 @@ type SessionQueryClient interface { serviceId string, blockHeight int64, ) (*sessiontypes.Session, error) + // GetParams queries the chain for the current session module parameters. + GetParams(ctx context.Context) (*sessiontypes.Params, error) } From a6667eb0250496ddb867c63ee6e994ce0572d806 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 16 May 2024 21:01:57 +0200 Subject: [PATCH 16/61] chore: add ErrQuerySessionParams --- pkg/client/query/errors.go | 1 + 1 file changed, 1 insertion(+) 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") ) From 42a63f11035698602066342ad07e8f248d80a458 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 16 May 2024 21:02:22 +0200 Subject: [PATCH 17/61] feat: implement sessionQuerier#GetParams() --- pkg/client/query/sessionquerier.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/client/query/sessionquerier.go b/pkg/client/query/sessionquerier.go index 6a86205fe..a406fa7f3 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" @@ -64,3 +64,12 @@ func (sessq *sessionQuerier) GetSession( } return res.Session, nil } + +func (sessq *sessionQuerier) GetParams(ctx context.Context) (*sessiontypes.Params, error) { + req := &sessiontypes.QueryParamsRequest{} + res, err := sessq.sessionQuerier.Params(ctx, req) + if err != nil { + return nil, ErrQuerySessionParams.Wrapf("[%v]", err) + } + return &res.Params, nil +} From 16dafd33108886927812b5470bbbe180fdd30205 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Fri, 17 May 2024 08:49:48 +0200 Subject: [PATCH 18/61] chore: add SessionQueryClient#GetSessionGracePeriodCount interface method --- pkg/client/interface.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/client/interface.go b/pkg/client/interface.go index c9f7d127b..e5f11a5a4 100644 --- a/pkg/client/interface.go +++ b/pkg/client/interface.go @@ -276,4 +276,5 @@ type SessionQueryClient interface { ) (*sessiontypes.Session, error) // GetParams queries the chain for the current session module parameters. GetParams(ctx context.Context) (*sessiontypes.Params, error) + GetSessionGracePeriodBlockCount(ctx context.Context, blockHeight int64) (uint64, error) } From 48526a00809ad39c0c61f24ac67a30dabff0cb48 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Fri, 17 May 2024 08:50:26 +0200 Subject: [PATCH 19/61] feat: implement sessionQuerier#GetSessionGracePeriodBlockCount() --- pkg/client/query/sessionquerier.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pkg/client/query/sessionquerier.go b/pkg/client/query/sessionquerier.go index a406fa7f3..85c02b5c4 100644 --- a/pkg/client/query/sessionquerier.go +++ b/pkg/client/query/sessionquerier.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/gogoproto/grpc" "github.com/pokt-network/poktroll/pkg/client" + sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -65,6 +66,7 @@ func (sessq *sessionQuerier) GetSession( return res.Session, nil } +// TODO_IN_THIS_PR: godoc comments... func (sessq *sessionQuerier) GetParams(ctx context.Context) (*sessiontypes.Params, error) { req := &sessiontypes.QueryParamsRequest{} res, err := sessq.sessionQuerier.Params(ctx, req) @@ -73,3 +75,26 @@ func (sessq *sessionQuerier) GetParams(ctx context.Context) (*sessiontypes.Param } return &res.Params, nil } + +// TODO_TECHDEBT: 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. +// +// TODO_IN_THIS_PR: godoc comments... +func (sessq *sessionQuerier) GetSessionGracePeriodBlockCount( + ctx context.Context, + queryHeight int64, +) (uint64, error) { + paramsRes, err := sessq.sessionQuerier.Params(ctx, &sessiontypes.QueryParamsRequest{}) + if err != nil { + return 0, err + } + + // TODO_BLOCKER: Use `queryHeight` & some alternate queries to retrieve + // the value of session params at that height. + _ = queryHeight + + numBlocksPerSession := paramsRes.GetParams().NumBlocksPerSession + + return sessionkeeper.SessionGracePeriod * numBlocksPerSession, nil +} From 3d59a5dae4add84f59ab8eedb345d1efdc21f43b Mon Sep 17 00:00:00 2001 From: Bryan White Date: Fri, 17 May 2024 08:52:03 +0200 Subject: [PATCH 20/61] chore: add sessionQueryClient field to relayerSessionsManager --- pkg/relayer/session/session.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/relayer/session/session.go b/pkg/relayer/session/session.go index 84d786eed..9dcf02937 100644 --- a/pkg/relayer/session/session.go +++ b/pkg/relayer/session/session.go @@ -48,6 +48,8 @@ type relayerSessionsManager struct { // storesDirectory points to a path on disk where KVStore data files are created. storesDirectory string + + sessionQueryClient client.SessionQueryClient } // NewRelayerSessions creates a new relayerSessions. @@ -73,6 +75,7 @@ func NewRelayerSessions( deps, &rs.blockClient, &rs.supplierClient, + &rs.sessionQueryClient, ); err != nil { return nil, err } From c24ba018aa1b101fd39a03584550e7f6094803f8 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Fri, 17 May 2024 08:52:40 +0200 Subject: [PATCH 21/61] refactor: IsWithinGracePeriod from a static function to a method on relayerSessionsManager --- pkg/relayer/session/session.go | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/pkg/relayer/session/session.go b/pkg/relayer/session/session.go index 9dcf02937..903eba24b 100644 --- a/pkg/relayer/session/session.go +++ b/pkg/relayer/session/session.go @@ -12,7 +12,6 @@ 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" ) @@ -167,8 +166,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() @@ -197,7 +197,14 @@ 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()) { + isWithinGracePeriod, err := rs.IsWithinGracePeriod(ctx, endBlockHeight, block.Height()) + if err != nil { + // TODO_IMPROVE + rs.logger.Error().Err(err).Msg("failed to check if within grace period") + return nil, true + } + + if isWithinGracePeriod { // 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 { @@ -324,8 +331,20 @@ func (rs *relayerSessionsManager) mapAddMinedRelayToSessionTree( // 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() +// +// TODO_TECHDEBT: move to the SessionQueryClient. +func (rs *relayerSessionsManager) IsWithinGracePeriod( + ctx context.Context, + sessionEndBlockHeight, + currentBlockHeight int64, +) (bool, error) { + sessionGracePeriodEndBlocks, err := rs.sessionQueryClient.GetSessionGracePeriodBlockCount(ctx, currentBlockHeight) + if err != nil { + return false, err + } + + sessionGracePeriodEndHeight := sessionEndBlockHeight + int64(sessionGracePeriodEndBlocks) + return currentBlockHeight <= sessionGracePeriodEndHeight, nil } // IsPastGracePeriod checks if the grace period for the session, given its end From b23d9d820377f4f0f91a8350432a51c409e6dad5 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Fri, 17 May 2024 08:53:11 +0200 Subject: [PATCH 22/61] chore: add IsWithinGracePeriod method to relayerProxy --- pkg/relayer/proxy/relay_verifier.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/pkg/relayer/proxy/relay_verifier.go b/pkg/relayer/proxy/relay_verifier.go index 011b1b293..7ce028e99 100644 --- a/pkg/relayer/proxy/relay_verifier.go +++ b/pkg/relayer/proxy/relay_verifier.go @@ -3,7 +3,6 @@ package proxy import ( "context" - sessiontypes "github.com/pokt-network/poktroll/pkg/relayer/session" "github.com/pokt-network/poktroll/x/service/types" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -99,7 +98,12 @@ 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) { + isWithinGracePeriod, err := rp.IsWithinGracePeriod(ctx, sessionEndblockHeight, currentBlockHeight) + if err != nil { + return 0, err + } + + if isWithinGracePeriod { // 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 @@ -115,3 +119,21 @@ func (rp *relayerProxy) getTargetSessionBlockHeight( // The RelayRequest's session is active so return the current block height. return currentBlockHeight, nil } + +// IsWithinGracePeriod checks if the grace period for the session has ended +// and signals whether it is time to create a claim for it. +// +// TODO_TECHDEBT: move to the SessionQueryClient. +func (rp *relayerProxy) IsWithinGracePeriod( + ctx context.Context, + sessionEndBlockHeight, + currentBlockHeight int64, +) (bool, error) { + sessionGracePeriodEndBlocks, err := rp.sessionQuerier.GetSessionGracePeriodBlockCount(ctx, currentBlockHeight) + if err != nil { + return false, err + } + + sessionGracePeriodEndHeight := sessionEndBlockHeight + int64(sessionGracePeriodEndBlocks) + return currentBlockHeight <= sessionGracePeriodEndHeight, nil +} From 43682ed42bb01cc2db2454036875ebd54a5ca81d Mon Sep 17 00:00:00 2001 From: Bryan White Date: Fri, 17 May 2024 08:53:38 +0200 Subject: [PATCH 23/61] docs: update relayerProxy#sessoinQuerier godoc comment --- pkg/relayer/proxy/proxy.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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, From 7b64b2b5bf43dcd45835207135b852f05a5b0af1 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Fri, 17 May 2024 09:00:40 +0200 Subject: [PATCH 24/61] refactor: move duplicated #IsWithinGracePeriod methods to sessionQuerier --- pkg/client/interface.go | 1 + pkg/client/query/sessionquerier.go | 16 ++++++++++++++++ pkg/relayer/proxy/relay_verifier.go | 20 +------------------- pkg/relayer/session/session.go | 20 +------------------- 4 files changed, 19 insertions(+), 38 deletions(-) diff --git a/pkg/client/interface.go b/pkg/client/interface.go index e5f11a5a4..41afe7ce2 100644 --- a/pkg/client/interface.go +++ b/pkg/client/interface.go @@ -277,4 +277,5 @@ type SessionQueryClient interface { // GetParams queries the chain for the current session module parameters. GetParams(ctx context.Context) (*sessiontypes.Params, error) GetSessionGracePeriodBlockCount(ctx context.Context, blockHeight int64) (uint64, error) + IsWithinGracePeriod(ctx context.Context, sessionEndBlockHeight, currentBlockHeight int64) (bool, error) } diff --git a/pkg/client/query/sessionquerier.go b/pkg/client/query/sessionquerier.go index 85c02b5c4..5dd87c086 100644 --- a/pkg/client/query/sessionquerier.go +++ b/pkg/client/query/sessionquerier.go @@ -98,3 +98,19 @@ func (sessq *sessionQuerier) GetSessionGracePeriodBlockCount( return sessionkeeper.SessionGracePeriod * numBlocksPerSession, nil } + +// IsWithinGracePeriod checks if the grace period for the session has ended +// and signals whether it is time to create a claim for it. +func (sessq *sessionQuerier) IsWithinGracePeriod( + ctx context.Context, + sessionEndBlockHeight, + currentBlockHeight int64, +) (bool, error) { + sessionGracePeriodEndBlocks, err := sessq.GetSessionGracePeriodBlockCount(ctx, currentBlockHeight) + if err != nil { + return false, err + } + + sessionGracePeriodEndHeight := sessionEndBlockHeight + int64(sessionGracePeriodEndBlocks) + return currentBlockHeight <= sessionGracePeriodEndHeight, nil +} diff --git a/pkg/relayer/proxy/relay_verifier.go b/pkg/relayer/proxy/relay_verifier.go index 7ce028e99..59bd1e1ce 100644 --- a/pkg/relayer/proxy/relay_verifier.go +++ b/pkg/relayer/proxy/relay_verifier.go @@ -98,7 +98,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. - isWithinGracePeriod, err := rp.IsWithinGracePeriod(ctx, sessionEndblockHeight, currentBlockHeight) + isWithinGracePeriod, err := rp.sessionQuerier.IsWithinGracePeriod(ctx, sessionEndblockHeight, currentBlockHeight) if err != nil { return 0, err } @@ -119,21 +119,3 @@ func (rp *relayerProxy) getTargetSessionBlockHeight( // The RelayRequest's session is active so return the current block height. return currentBlockHeight, nil } - -// IsWithinGracePeriod checks if the grace period for the session has ended -// and signals whether it is time to create a claim for it. -// -// TODO_TECHDEBT: move to the SessionQueryClient. -func (rp *relayerProxy) IsWithinGracePeriod( - ctx context.Context, - sessionEndBlockHeight, - currentBlockHeight int64, -) (bool, error) { - sessionGracePeriodEndBlocks, err := rp.sessionQuerier.GetSessionGracePeriodBlockCount(ctx, currentBlockHeight) - if err != nil { - return false, err - } - - sessionGracePeriodEndHeight := sessionEndBlockHeight + int64(sessionGracePeriodEndBlocks) - return currentBlockHeight <= sessionGracePeriodEndHeight, nil -} diff --git a/pkg/relayer/session/session.go b/pkg/relayer/session/session.go index 903eba24b..4f10fd7f4 100644 --- a/pkg/relayer/session/session.go +++ b/pkg/relayer/session/session.go @@ -197,7 +197,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. - isWithinGracePeriod, err := rs.IsWithinGracePeriod(ctx, endBlockHeight, block.Height()) + isWithinGracePeriod, err := rs.sessionQueryClient.IsWithinGracePeriod(ctx, endBlockHeight, block.Height()) if err != nil { // TODO_IMPROVE rs.logger.Error().Err(err).Msg("failed to check if within grace period") @@ -329,24 +329,6 @@ func (rs *relayerSessionsManager) mapAddMinedRelayToSessionTree( 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. -// -// TODO_TECHDEBT: move to the SessionQueryClient. -func (rs *relayerSessionsManager) IsWithinGracePeriod( - ctx context.Context, - sessionEndBlockHeight, - currentBlockHeight int64, -) (bool, error) { - sessionGracePeriodEndBlocks, err := rs.sessionQueryClient.GetSessionGracePeriodBlockCount(ctx, currentBlockHeight) - if err != nil { - return false, err - } - - sessionGracePeriodEndHeight := sessionEndBlockHeight + int64(sessionGracePeriodEndBlocks) - return currentBlockHeight <= sessionGracePeriodEndHeight, nil -} - // IsPastGracePeriod checks if the grace period for the session, given its end // block height, has ended. func IsPastGracePeriod(sessionEndBlockHeight, currentBlockHeight int64) bool { From 5c42c06465214f694b172800c6e7129a0a8b8b0c Mon Sep 17 00:00:00 2001 From: Bryan White Date: Fri, 17 May 2024 09:18:25 +0200 Subject: [PATCH 25/61] chore: add SessionQueryClient#IsPastGracePeriod() interface method --- pkg/client/interface.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/client/interface.go b/pkg/client/interface.go index 41afe7ce2..34fb2a3e6 100644 --- a/pkg/client/interface.go +++ b/pkg/client/interface.go @@ -278,4 +278,5 @@ type SessionQueryClient interface { GetParams(ctx context.Context) (*sessiontypes.Params, error) GetSessionGracePeriodBlockCount(ctx context.Context, blockHeight int64) (uint64, error) IsWithinGracePeriod(ctx context.Context, sessionEndBlockHeight, currentBlockHeight int64) (bool, error) + IsPastGracePeriod(ctx context.Context, sessionEndBlockHeight, currentBlockHeight int64) (bool, error) } From 264edb24639229eb4aab2b0c84e019d605be2de4 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Fri, 17 May 2024 09:19:51 +0200 Subject: [PATCH 26/61] refactor: IsPastGracePeriod from a static function to a sessionQuerier method --- pkg/client/query/sessionquerier.go | 18 ++++++++++++++++++ pkg/relayer/session/session.go | 14 +++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/pkg/client/query/sessionquerier.go b/pkg/client/query/sessionquerier.go index 5dd87c086..9dc4206ee 100644 --- a/pkg/client/query/sessionquerier.go +++ b/pkg/client/query/sessionquerier.go @@ -112,5 +112,23 @@ func (sessq *sessionQuerier) IsWithinGracePeriod( } sessionGracePeriodEndHeight := sessionEndBlockHeight + int64(sessionGracePeriodEndBlocks) + return currentBlockHeight <= sessionGracePeriodEndHeight, nil } + +// IsPastGracePeriod checks if the grace period for the session, given its end +// block height, has ended. +func (sessq *sessionQuerier) IsPastGracePeriod( + ctx context.Context, + sessionEndBlockHeight, + queryHeight int64, +) (bool, error) { + sessionGracePeriodBlockCount, err := sessq.GetSessionGracePeriodBlockCount(ctx, queryHeight) + if err != nil { + return false, err + } + + sessionGracePeriodEndHeight := sessionEndBlockHeight + int64(sessionGracePeriodBlockCount) + + return queryHeight > sessionGracePeriodEndHeight, nil +} diff --git a/pkg/relayer/session/session.go b/pkg/relayer/session/session.go index 4f10fd7f4..17be35f22 100644 --- a/pkg/relayer/session/session.go +++ b/pkg/relayer/session/session.go @@ -218,10 +218,16 @@ func (rs *relayerSessionsManager) mapBlockToSessionsToClaim( continue } + isPastSessionGracePeriod, err := rs.sessionQueryClient.IsPastGracePeriod(ctx, endBlockHeight, block.Height()) + if err != nil { + rs.logger.Error().Err(err).Msg("failed to check if past grace period") + return nil, true + } + // 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 isPastSessionGracePeriod { lateSessions = append(lateSessions, sessionTree) } else { onTimeSessions = append(onTimeSessions, sessionTree) @@ -328,9 +334,3 @@ func (rs *relayerSessionsManager) mapAddMinedRelayToSessionTree( // Skip because this map function only outputs errors. return nil, true } - -// 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() -} From d75e5ae040315eea6f522eeff93e62b65c71b1d7 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 21 May 2024 17:54:11 +0200 Subject: [PATCH 27/61] refactor: factor static functions back out to session pkg w/ appropriate args --- pkg/client/query/sessionquerier.go | 21 ++++++++++----------- x/session/session.go | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 x/session/session.go diff --git a/pkg/client/query/sessionquerier.go b/pkg/client/query/sessionquerier.go index 9dc4206ee..754e47c85 100644 --- a/pkg/client/query/sessionquerier.go +++ b/pkg/client/query/sessionquerier.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/gogoproto/grpc" "github.com/pokt-network/poktroll/pkg/client" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" + "github.com/pokt-network/poktroll/x/session" sessiontypes "github.com/pokt-network/poktroll/x/session/types" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -95,25 +95,24 @@ func (sessq *sessionQuerier) GetSessionGracePeriodBlockCount( _ = queryHeight numBlocksPerSession := paramsRes.GetParams().NumBlocksPerSession - - return sessionkeeper.SessionGracePeriod * numBlocksPerSession, nil + return session.GetSessionGracePeriodBlockCount(numBlocksPerSession), nil } // IsWithinGracePeriod checks if the grace period for the session has ended // and signals whether it is time to create a claim for it. func (sessq *sessionQuerier) IsWithinGracePeriod( ctx context.Context, - sessionEndBlockHeight, - currentBlockHeight int64, + sessionEndHeight, + queryHeight int64, ) (bool, error) { - sessionGracePeriodEndBlocks, err := sessq.GetSessionGracePeriodBlockCount(ctx, currentBlockHeight) + paramsRes, err := sessq.sessionQuerier.Params(ctx, &sessiontypes.QueryParamsRequest{}) if err != nil { return false, err } - sessionGracePeriodEndHeight := sessionEndBlockHeight + int64(sessionGracePeriodEndBlocks) + numBlocksPerSession := paramsRes.GetParams().NumBlocksPerSession - return currentBlockHeight <= sessionGracePeriodEndHeight, nil + return session.IsWithinGracePeriod(numBlocksPerSession, sessionEndHeight, queryHeight), nil } // IsPastGracePeriod checks if the grace period for the session, given its end @@ -123,12 +122,12 @@ func (sessq *sessionQuerier) IsPastGracePeriod( sessionEndBlockHeight, queryHeight int64, ) (bool, error) { - sessionGracePeriodBlockCount, err := sessq.GetSessionGracePeriodBlockCount(ctx, queryHeight) + paramsRes, err := sessq.sessionQuerier.Params(ctx, &sessiontypes.QueryParamsRequest{}) if err != nil { return false, err } - sessionGracePeriodEndHeight := sessionEndBlockHeight + int64(sessionGracePeriodBlockCount) + numBlocksPerSession := paramsRes.GetParams().NumBlocksPerSession - return queryHeight > sessionGracePeriodEndHeight, nil + return session.IsPastGracePeriod(numBlocksPerSession, sessionEndBlockHeight, queryHeight), nil } diff --git a/x/session/session.go b/x/session/session.go new file mode 100644 index 000000000..8712c7f09 --- /dev/null +++ b/x/session/session.go @@ -0,0 +1,21 @@ +package session + +import ( + sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" +) + +func GetSessionGracePeriodBlockCount(numBlocksPerSession uint64) uint64 { + return sessionkeeper.SessionGracePeriod * numBlocksPerSession +} + +func IsWithinGracePeriod(numBlocksPerSession uint64, sessionEndHeight, queryHeight int64) bool { + sessionGracePeriodBlockCount := GetSessionGracePeriodBlockCount(numBlocksPerSession) + sessionGracePeriodEndHeight := sessionEndHeight + int64(sessionGracePeriodBlockCount) + return queryHeight <= sessionGracePeriodEndHeight +} + +func IsPastGracePeriod(numBlocksPerSession uint64, sessionEndHeight, queryHeight int64) bool { + sessionGracePeriodBlockCount := GetSessionGracePeriodBlockCount(numBlocksPerSession) + sessionGracePeriodEndHeight := sessionEndHeight + int64(sessionGracePeriodBlockCount) + return queryHeight > sessionGracePeriodEndHeight +} From 79a141d9f4c58447cf462e8847231f249cf5cfc6 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 21 May 2024 17:54:52 +0200 Subject: [PATCH 28/61] test: add #IsWithinGracePeriod & #IsPastGracePeriod to the mock session query client --- .../testqueryclients/sessionquerier.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/testutil/testclient/testqueryclients/sessionquerier.go b/testutil/testclient/testqueryclients/sessionquerier.go index c8c24770a..5304250d9 100644 --- a/testutil/testclient/testqueryclients/sessionquerier.go +++ b/testutil/testclient/testqueryclients/sessionquerier.go @@ -9,6 +9,7 @@ import ( "github.com/golang/mock/gomock" "github.com/pokt-network/poktroll/testutil/mockclient" + "github.com/pokt-network/poktroll/x/session" sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" @@ -58,6 +59,14 @@ func NewTestSessionQueryClient( }). AnyTimes() + sessionQuerier.EXPECT().IsWithinGracePeriod(gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn(IsWithinDefaultGracePeriod). + AnyTimes() + + sessionQuerier.EXPECT().IsPastGracePeriod(gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn(IsPastDefaultGracePeriod). + AnyTimes() + return sessionQuerier } @@ -99,3 +108,13 @@ func AddToExistingSessions( delete(sessionsMap, sessionId) }) } + +func IsWithinDefaultGracePeriod(_ context.Context, sessionEndHeight, queryHeight int64) (bool, error) { + numBlocksPerSession := sessiontypes.DefaultParams().NumBlocksPerSession + return session.IsWithinGracePeriod(numBlocksPerSession, sessionEndHeight, queryHeight), nil +} + +func IsPastDefaultGracePeriod(_ context.Context, sessionEndHeight, queryHeight int64) (bool, error) { + numBlocksPerSession := sessiontypes.DefaultParams().NumBlocksPerSession + return session.IsPastGracePeriod(numBlocksPerSession, sessionEndHeight, queryHeight), nil +} From 6ca2f88b54e1817a8e9d910f42f74cc8d323e890 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 21 May 2024 17:55:30 +0200 Subject: [PATCH 29/61] test: fix failing test by supplying session query client dependency --- pkg/relayer/session/session_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/relayer/session/session_test.go b/pkg/relayer/session/session_test.go index 0d681076c..110b13941 100644 --- a/pkg/relayer/session/session_test.go +++ b/pkg/relayer/session/session_test.go @@ -20,6 +20,7 @@ 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" @@ -71,7 +72,9 @@ func TestRelayerSessionsManager_Start(t *testing.T) { ). AnyTimes() - deps := depinject.Supply(blockClient, blockQueryClientMock, supplierClient) + sessionQueryClientMock := testqueryclients.NewTestSessionQueryClient(t) + + deps := depinject.Supply(blockClient, blockQueryClientMock, supplierClient, sessionQueryClientMock) storesDirectoryOpt := testrelayer.WithTempStoresDirectory(t) // Create a new relayer sessions manager. From 05d8c73a4dfc841c1ac71281f58621fbe4a99e94 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 21 May 2024 19:32:27 +0200 Subject: [PATCH 30/61] wip: comment & simplify --- pkg/client/interface.go | 12 +++++-- pkg/client/query/sessionquerier.go | 52 ++++++++++++++++-------------- pkg/relayer/session/session.go | 1 - x/session/session.go | 14 +++++--- 4 files changed, 47 insertions(+), 32 deletions(-) diff --git a/pkg/client/interface.go b/pkg/client/interface.go index 34fb2a3e6..9d2184d97 100644 --- a/pkg/client/interface.go +++ b/pkg/client/interface.go @@ -276,7 +276,13 @@ type SessionQueryClient interface { ) (*sessiontypes.Session, error) // GetParams queries the chain for the current session module parameters. GetParams(ctx context.Context) (*sessiontypes.Params, error) - GetSessionGracePeriodBlockCount(ctx context.Context, blockHeight int64) (uint64, error) - IsWithinGracePeriod(ctx context.Context, sessionEndBlockHeight, currentBlockHeight int64) (bool, error) - IsPastGracePeriod(ctx context.Context, sessionEndBlockHeight, currentBlockHeight int64) (bool, error) + // GetSessionGracePeriodBlockCount returns the number of blocks in the grace period + // for the session which includes queryHeight. + GetSessionGracePeriodBlockCount(ctx context.Context, queryHeight int64) (uint64, error) + // IsWithinGracePeriod returns true if the grace period for the session ending with + // sessionEndHeight has not yet elapsed, given currentHeight. + IsWithinGracePeriod(ctx context.Context, sessionEndHeight, currentHeight int64) (bool, error) + // IsPastGracePeriod returns true if the grace period for the session ending with + // sessionEndHeight has elapsed, given currentHeight. + IsPastGracePeriod(ctx context.Context, sessionEndHeight, currentHeight int64) (bool, error) } diff --git a/pkg/client/query/sessionquerier.go b/pkg/client/query/sessionquerier.go index 754e47c85..c20a4b95b 100644 --- a/pkg/client/query/sessionquerier.go +++ b/pkg/client/query/sessionquerier.go @@ -66,7 +66,11 @@ func (sessq *sessionQuerier) GetSession( return res.Session, nil } -// TODO_IN_THIS_PR: godoc comments... +// GetParams queries & returns the session 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 (sessq *sessionQuerier) GetParams(ctx context.Context) (*sessiontypes.Params, error) { req := &sessiontypes.QueryParamsRequest{} res, err := sessq.sessionQuerier.Params(ctx, req) @@ -76,58 +80,58 @@ func (sessq *sessionQuerier) GetParams(ctx context.Context) (*sessiontypes.Param return &res.Params, nil } -// TODO_TECHDEBT: 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. -// -// TODO_IN_THIS_PR: godoc comments... +// GetSessionGracePeriodBlockCount returns the number of blocks in the grace period +// for the session which includes queryHeight. func (sessq *sessionQuerier) GetSessionGracePeriodBlockCount( ctx context.Context, - queryHeight int64, + sessionEndHeight int64, ) (uint64, error) { - paramsRes, err := sessq.sessionQuerier.Params(ctx, &sessiontypes.QueryParamsRequest{}) + params, err := sessq.GetParams(ctx) if err != nil { return 0, err } - // TODO_BLOCKER: Use `queryHeight` & some alternate queries to retrieve - // the value of session params at that height. - _ = queryHeight + // TODO_BLOCKER(#543): Use the values of session params at `sessionEndHeight`. + _ = sessionEndHeight - numBlocksPerSession := paramsRes.GetParams().NumBlocksPerSession + numBlocksPerSession := params.GetNumBlocksPerSession() return session.GetSessionGracePeriodBlockCount(numBlocksPerSession), nil } -// IsWithinGracePeriod checks if the grace period for the session has ended -// and signals whether it is time to create a claim for it. +// IsWithinGracePeriod returns true if the grace period for the session ending with +// sessionEndHeight has not yet elapsed, given currentHeight. func (sessq *sessionQuerier) IsWithinGracePeriod( ctx context.Context, sessionEndHeight, - queryHeight int64, + currentHeight int64, ) (bool, error) { - paramsRes, err := sessq.sessionQuerier.Params(ctx, &sessiontypes.QueryParamsRequest{}) + params, err := sessq.GetParams(ctx) if err != nil { return false, err } - numBlocksPerSession := paramsRes.GetParams().NumBlocksPerSession + // TODO_BLOCKER(#543): Use the values of session params at `sessionEndHeight`. + _ = sessionEndHeight - return session.IsWithinGracePeriod(numBlocksPerSession, sessionEndHeight, queryHeight), nil + numBlocksPerSession := params.GetNumBlocksPerSession() + return session.IsWithinGracePeriod(numBlocksPerSession, sessionEndHeight, currentHeight), nil } -// IsPastGracePeriod checks if the grace period for the session, given its end -// block height, has ended. +// IsPastGracePeriod returns true if the grace period for the session ending with +// sessionEndHeight has elapsed, given currentHeight. func (sessq *sessionQuerier) IsPastGracePeriod( ctx context.Context, - sessionEndBlockHeight, - queryHeight int64, + sessionEndHeight, + currentHeight int64, ) (bool, error) { paramsRes, err := sessq.sessionQuerier.Params(ctx, &sessiontypes.QueryParamsRequest{}) if err != nil { return false, err } - numBlocksPerSession := paramsRes.GetParams().NumBlocksPerSession + // TODO_BLOCKER(#543): Use the values of session params at `sessionEndHeight`. + _ = sessionEndHeight - return session.IsPastGracePeriod(numBlocksPerSession, sessionEndBlockHeight, queryHeight), nil + numBlocksPerSession := paramsRes.GetParams().NumBlocksPerSession + return session.IsPastGracePeriod(numBlocksPerSession, sessionEndHeight, currentHeight), nil } diff --git a/pkg/relayer/session/session.go b/pkg/relayer/session/session.go index 17be35f22..b96f42b43 100644 --- a/pkg/relayer/session/session.go +++ b/pkg/relayer/session/session.go @@ -199,7 +199,6 @@ func (rs *relayerSessionsManager) mapBlockToSessionsToClaim( // implement off-chain window closing and on-chain window checks. isWithinGracePeriod, err := rs.sessionQueryClient.IsWithinGracePeriod(ctx, endBlockHeight, block.Height()) if err != nil { - // TODO_IMPROVE rs.logger.Error().Err(err).Msg("failed to check if within grace period") return nil, true } diff --git a/x/session/session.go b/x/session/session.go index 8712c7f09..d4ee53dec 100644 --- a/x/session/session.go +++ b/x/session/session.go @@ -4,18 +4,24 @@ import ( sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" ) +// GetSessionGracePeriodBlockCount returns the number of blocks in the grace period +// given some numBlocksPerSession. func GetSessionGracePeriodBlockCount(numBlocksPerSession uint64) uint64 { return sessionkeeper.SessionGracePeriod * numBlocksPerSession } -func IsWithinGracePeriod(numBlocksPerSession uint64, sessionEndHeight, queryHeight int64) bool { +// IsWithinGracePeriod returns true if the grace period for the session ending with +// sessionEndHeight has not yet elapsed, given currentHeight. +func IsWithinGracePeriod(numBlocksPerSession uint64, sessionEndHeight, currentHeight int64) bool { sessionGracePeriodBlockCount := GetSessionGracePeriodBlockCount(numBlocksPerSession) sessionGracePeriodEndHeight := sessionEndHeight + int64(sessionGracePeriodBlockCount) - return queryHeight <= sessionGracePeriodEndHeight + return currentHeight <= sessionGracePeriodEndHeight } -func IsPastGracePeriod(numBlocksPerSession uint64, sessionEndHeight, queryHeight int64) bool { +// IsPastGracePeriod returns true if the grace period for the session ending with +// sessionEndHeight has elapsed, given currentHeight. +func IsPastGracePeriod(numBlocksPerSession uint64, sessionEndHeight, currentHeight int64) bool { sessionGracePeriodBlockCount := GetSessionGracePeriodBlockCount(numBlocksPerSession) sessionGracePeriodEndHeight := sessionEndHeight + int64(sessionGracePeriodBlockCount) - return queryHeight > sessionGracePeriodEndHeight + return currentHeight > sessionGracePeriodEndHeight } From eb983c1e28acdc0f452a728210fe2adda4f724c6 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 22 May 2024 11:06:34 +0200 Subject: [PATCH 31/61] refactor: factor out GetSessionGracePeriodEndHeight --- pkg/client/interface.go | 3 +++ pkg/client/query/sessionquerier.go | 18 ++++++++++++++++++ .../testqueryclients/sessionquerier.go | 18 ++++++++++++++++++ x/session/session.go | 13 +++++++++---- 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/pkg/client/interface.go b/pkg/client/interface.go index 9d2184d97..f034cffb3 100644 --- a/pkg/client/interface.go +++ b/pkg/client/interface.go @@ -276,6 +276,9 @@ type SessionQueryClient interface { ) (*sessiontypes.Session, error) // GetParams queries the chain for the current session module parameters. GetParams(ctx context.Context) (*sessiontypes.Params, error) + // GetSessionGracePeriodEndHeight returns the height at which the grace period for + // the session ending with sessionEndHeight elapses. + GetSessionGracePeriodEndHeight(ctx context.Context, sessionEndHeight int64) (int64, error) // GetSessionGracePeriodBlockCount returns the number of blocks in the grace period // for the session which includes queryHeight. GetSessionGracePeriodBlockCount(ctx context.Context, queryHeight int64) (uint64, error) diff --git a/pkg/client/query/sessionquerier.go b/pkg/client/query/sessionquerier.go index c20a4b95b..0a087c2f5 100644 --- a/pkg/client/query/sessionquerier.go +++ b/pkg/client/query/sessionquerier.go @@ -80,6 +80,24 @@ func (sessq *sessionQuerier) GetParams(ctx context.Context) (*sessiontypes.Param return &res.Params, nil } +// GetSessionGracePeriodEndHeight returns the height at which the grace period for +// the session ending with sessionEndHeight elapses. +func (sessq *sessionQuerier) GetSessionGracePeriodEndHeight( + ctx context.Context, + sessionEndHeight int64, +) (int64, error) { + params, err := sessq.GetParams(ctx) + if err != nil { + return 0, err + } + + // TODO_BLOCKER(#543): Use the values of session params at `sessionEndHeight`. + _ = sessionEndHeight + + numBlocksPerSession := params.GetNumBlocksPerSession() + return session.GetSessionGracePeriodEndHeight(numBlocksPerSession, sessionEndHeight), nil +} + // GetSessionGracePeriodBlockCount returns the number of blocks in the grace period // for the session which includes queryHeight. func (sessq *sessionQuerier) GetSessionGracePeriodBlockCount( diff --git a/testutil/testclient/testqueryclients/sessionquerier.go b/testutil/testclient/testqueryclients/sessionquerier.go index 5304250d9..c63150971 100644 --- a/testutil/testclient/testqueryclients/sessionquerier.go +++ b/testutil/testclient/testqueryclients/sessionquerier.go @@ -59,6 +59,14 @@ func NewTestSessionQueryClient( }). AnyTimes() + sessionQuerier.EXPECT().GetSessionGracePeriodBlockCount(gomock.Any(), gomock.Any()). + DoAndReturn(GetSessionGracePeriodBlockCount). + AnyTimes() + + sessionQuerier.EXPECT().GetSessionGracePeriodEndHeight(gomock.Any(), gomock.Any()). + DoAndReturn(GetSessionGracePeriodEndHeight). + AnyTimes() + sessionQuerier.EXPECT().IsWithinGracePeriod(gomock.Any(), gomock.Any(), gomock.Any()). DoAndReturn(IsWithinDefaultGracePeriod). AnyTimes() @@ -109,6 +117,16 @@ func AddToExistingSessions( }) } +func GetSessionGracePeriodBlockCount(_ context.Context, sessionEndHeight int64) (int64, error) { + numBlocksPerSession := sessiontypes.DefaultParams().NumBlocksPerSession + return int64(session.GetSessionGracePeriodBlockCount(numBlocksPerSession)), nil +} + +func GetSessionGracePeriodEndHeight(_ context.Context, sessionEndHeight int64) (int64, error) { + numBlocksPerSession := sessiontypes.DefaultParams().NumBlocksPerSession + return session.GetSessionGracePeriodEndHeight(numBlocksPerSession, sessionEndHeight), nil +} + func IsWithinDefaultGracePeriod(_ context.Context, sessionEndHeight, queryHeight int64) (bool, error) { numBlocksPerSession := sessiontypes.DefaultParams().NumBlocksPerSession return session.IsWithinGracePeriod(numBlocksPerSession, sessionEndHeight, queryHeight), nil diff --git a/x/session/session.go b/x/session/session.go index d4ee53dec..129191031 100644 --- a/x/session/session.go +++ b/x/session/session.go @@ -10,18 +10,23 @@ func GetSessionGracePeriodBlockCount(numBlocksPerSession uint64) uint64 { return sessionkeeper.SessionGracePeriod * numBlocksPerSession } +// GetSessionGracePeriodEndHeight returns the height at which the grace period for +// the session ending with sessionEndHeight elapses. +func GetSessionGracePeriodEndHeight(numBlocksPerSession uint64, sessionEndHeight int64) int64 { + sessionGracePeriodBlockCount := GetSessionGracePeriodBlockCount(numBlocksPerSession) + return sessionEndHeight + int64(sessionGracePeriodBlockCount) +} + // IsWithinGracePeriod returns true if the grace period for the session ending with // sessionEndHeight has not yet elapsed, given currentHeight. func IsWithinGracePeriod(numBlocksPerSession uint64, sessionEndHeight, currentHeight int64) bool { - sessionGracePeriodBlockCount := GetSessionGracePeriodBlockCount(numBlocksPerSession) - sessionGracePeriodEndHeight := sessionEndHeight + int64(sessionGracePeriodBlockCount) + sessionGracePeriodEndHeight := GetSessionGracePeriodEndHeight(numBlocksPerSession, sessionEndHeight) return currentHeight <= sessionGracePeriodEndHeight } // IsPastGracePeriod returns true if the grace period for the session ending with // sessionEndHeight has elapsed, given currentHeight. func IsPastGracePeriod(numBlocksPerSession uint64, sessionEndHeight, currentHeight int64) bool { - sessionGracePeriodBlockCount := GetSessionGracePeriodBlockCount(numBlocksPerSession) - sessionGracePeriodEndHeight := sessionEndHeight + int64(sessionGracePeriodBlockCount) + sessionGracePeriodEndHeight := GetSessionGracePeriodEndHeight(numBlocksPerSession, sessionEndHeight) return currentHeight > sessionGracePeriodEndHeight } From f4d4d2ee79da1001a169a448f329c2fb71154550 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 22 May 2024 12:06:54 +0200 Subject: [PATCH 32/61] chore: refactor & simplify claim/proof submission --- pkg/relayer/session/claim.go | 14 +++++++++++--- pkg/relayer/session/proof.go | 17 +++++++++++++---- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/pkg/relayer/session/claim.go b/pkg/relayer/session/claim.go index f9be2455d..a0ca57c4c 100644 --- a/pkg/relayer/session/claim.go +++ b/pkg/relayer/session/claim.go @@ -11,7 +11,6 @@ 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" ) // createClaims maps over the sessionsToClaimObs observable. For each claim batch, it: @@ -82,11 +81,20 @@ 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, err := rs.sessionQueryClient.GetSessionGracePeriodEndHeight(ctx, sessionEndHeight) + if err != nil { + // 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. + failSubmitProofsSessionsCh <- sessionTrees + } + + 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 dc2029765..841f36365 100644 --- a/pkg/relayer/session/proof.go +++ b/pkg/relayer/session/proof.go @@ -12,7 +12,6 @@ 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" ) // submitProofs maps over the given claimedSessions observable. @@ -77,10 +76,20 @@ func (rs *relayerSessionsManager) waitForEarliestSubmitProofsHeightAndGeneratePr ) []relayer.SessionTree { // Given the sessionTrees are grouped by their sessionEndHeight, we can use the // first one from the group to calculate the earliest height for proof submission. - createClaimHeight := sessionTrees[0].GetSessionHeader().GetSessionEndBlockHeight() - // TODO_TECHDEBT(@red-0ne): Centralize the business logic that involves taking + sessionEndHeight := sessionTrees[0].GetSessionHeader().GetSessionEndBlockHeight() + + sessionGracePeriodEndHeight, err := rs.sessionQueryClient.GetSessionGracePeriodEndHeight(ctx, sessionEndHeight) + if err != nil { + // 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. + failSubmitProofsSessionsCh <- sessionTrees + } + + // TODO_TECHDEBT(#516): Centralize the business logic that involves taking // into account the heights, windows and grace periods into helper functions. - submitProofsWindowStartHeight := createClaimHeight + sessionkeeper.GetSessionGracePeriodBlockCount() + submitProofsWindowStartHeight := sessionGracePeriodEndHeight + 1 // TODO_BLOCKER: query the on-chain governance parameter once available. // + claimproofparams.GovSubmitProofWindowStartHeightOffset From 3ceeb180373d5c94ace709343464ea9c490ffad2 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 22 May 2024 13:05:51 +0200 Subject: [PATCH 33/61] Empty commit From 297b3f0c529d73c54350f715e793b5fefdbe8ad3 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 22 May 2024 13:12:13 +0200 Subject: [PATCH 34/61] chore: self-review improvements --- testutil/testclient/testqueryclients/sessionquerier.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testutil/testclient/testqueryclients/sessionquerier.go b/testutil/testclient/testqueryclients/sessionquerier.go index c63150971..9b444b78a 100644 --- a/testutil/testclient/testqueryclients/sessionquerier.go +++ b/testutil/testclient/testqueryclients/sessionquerier.go @@ -60,11 +60,11 @@ func NewTestSessionQueryClient( AnyTimes() sessionQuerier.EXPECT().GetSessionGracePeriodBlockCount(gomock.Any(), gomock.Any()). - DoAndReturn(GetSessionGracePeriodBlockCount). + DoAndReturn(GetDefaultSessionGracePeriodBlockCount). AnyTimes() sessionQuerier.EXPECT().GetSessionGracePeriodEndHeight(gomock.Any(), gomock.Any()). - DoAndReturn(GetSessionGracePeriodEndHeight). + DoAndReturn(GetDefaultSessionGracePeriodEndHeight). AnyTimes() sessionQuerier.EXPECT().IsWithinGracePeriod(gomock.Any(), gomock.Any(), gomock.Any()). @@ -117,12 +117,12 @@ func AddToExistingSessions( }) } -func GetSessionGracePeriodBlockCount(_ context.Context, sessionEndHeight int64) (int64, error) { +func GetDefaultSessionGracePeriodBlockCount(_ context.Context, sessionEndHeight int64) (int64, error) { numBlocksPerSession := sessiontypes.DefaultParams().NumBlocksPerSession return int64(session.GetSessionGracePeriodBlockCount(numBlocksPerSession)), nil } -func GetSessionGracePeriodEndHeight(_ context.Context, sessionEndHeight int64) (int64, error) { +func GetSDefaultessionGracePeriodEndHeight(_ context.Context, sessionEndHeight int64) (int64, error) { numBlocksPerSession := sessiontypes.DefaultParams().NumBlocksPerSession return session.GetSessionGracePeriodEndHeight(numBlocksPerSession, sessionEndHeight), nil } From bf3ddc2ba3f7342326869635c527e3fb42441b64 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 22 May 2024 13:23:55 +0200 Subject: [PATCH 35/61] fix: typo --- testutil/testclient/testqueryclients/sessionquerier.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testutil/testclient/testqueryclients/sessionquerier.go b/testutil/testclient/testqueryclients/sessionquerier.go index 9b444b78a..7d03d7f2c 100644 --- a/testutil/testclient/testqueryclients/sessionquerier.go +++ b/testutil/testclient/testqueryclients/sessionquerier.go @@ -122,7 +122,7 @@ func GetDefaultSessionGracePeriodBlockCount(_ context.Context, sessionEndHeight return int64(session.GetSessionGracePeriodBlockCount(numBlocksPerSession)), nil } -func GetSDefaultessionGracePeriodEndHeight(_ context.Context, sessionEndHeight int64) (int64, error) { +func GetDefaultSessionGracePeriodEndHeight(_ context.Context, sessionEndHeight int64) (int64, error) { numBlocksPerSession := sessiontypes.DefaultParams().NumBlocksPerSession return session.GetSessionGracePeriodEndHeight(numBlocksPerSession, sessionEndHeight), nil } From 1e0a99601573e1d502a6e5a8a98d3e495ce0da85 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 23 May 2024 09:33:28 +0200 Subject: [PATCH 36/61] scaffold: module shared --- api/poktroll/shared/genesis.pulsar.go | 594 +++ api/poktroll/shared/module/module.pulsar.go | 578 +++ api/poktroll/shared/params.pulsar.go | 499 +++ api/poktroll/shared/query.pulsar.go | 1010 +++++ api/poktroll/shared/query_grpc.pb.go | 111 + api/poktroll/shared/tx.pulsar.go | 1089 +++++ api/poktroll/shared/tx_grpc.pb.go | 113 + app/app.go | 7 +- app/app_config.go | 20 +- docs/static/openapi.yml | 4159 +++++++++++-------- proto/poktroll/shared/genesis.proto | 17 + proto/poktroll/shared/module/module.proto | 14 + proto/poktroll/shared/params.proto | 15 + proto/poktroll/shared/query.proto | 30 + proto/poktroll/shared/tx.proto | 40 + testutil/keeper/shared.go | 49 + x/shared/keeper/keeper.go | 59 + x/shared/keeper/msg_server.go | 17 + x/shared/keeper/msg_server_test.go | 24 + x/shared/keeper/msg_update_params.go | 23 + x/shared/keeper/msg_update_params_test.go | 64 + x/shared/keeper/params.go | 34 + x/shared/keeper/params_test.go | 18 + x/shared/keeper/query.go | 7 + x/shared/keeper/query_params.go | 20 + x/shared/keeper/query_params_test.go | 20 + x/shared/module/autocli.go | 35 + x/shared/module/genesis.go | 24 + x/shared/module/genesis_test.go | 31 + x/shared/module/module.go | 221 + x/shared/module/simulation.go | 64 + x/shared/simulation/helpers.go | 15 + x/shared/types/codec.go | 21 + x/shared/types/errors.go | 14 + x/shared/types/expected_keepers.go | 29 + x/shared/types/genesis.go | 24 + x/shared/types/genesis.pb.go | 324 ++ x/shared/types/genesis_test.go | 41 + x/shared/types/keys.go | 24 + x/shared/types/msg_update_params.go | 21 + x/shared/types/params.go | 41 + x/shared/types/params.pb.go | 288 ++ x/shared/types/query.pb.go | 540 +++ x/shared/types/query.pb.gw.go | 153 + x/shared/types/tx.pb.go | 598 +++ x/shared/types/types.go | 2 - 46 files changed, 9454 insertions(+), 1687 deletions(-) create mode 100644 api/poktroll/shared/genesis.pulsar.go create mode 100644 api/poktroll/shared/module/module.pulsar.go create mode 100644 api/poktroll/shared/params.pulsar.go create mode 100644 api/poktroll/shared/query.pulsar.go create mode 100644 api/poktroll/shared/query_grpc.pb.go create mode 100644 api/poktroll/shared/tx.pulsar.go create mode 100644 api/poktroll/shared/tx_grpc.pb.go create mode 100644 proto/poktroll/shared/genesis.proto create mode 100644 proto/poktroll/shared/module/module.proto create mode 100644 proto/poktroll/shared/params.proto create mode 100644 proto/poktroll/shared/query.proto create mode 100644 proto/poktroll/shared/tx.proto create mode 100644 testutil/keeper/shared.go create mode 100644 x/shared/keeper/keeper.go create mode 100644 x/shared/keeper/msg_server.go create mode 100644 x/shared/keeper/msg_server_test.go create mode 100644 x/shared/keeper/msg_update_params.go create mode 100644 x/shared/keeper/msg_update_params_test.go create mode 100644 x/shared/keeper/params.go create mode 100644 x/shared/keeper/params_test.go create mode 100644 x/shared/keeper/query.go create mode 100644 x/shared/keeper/query_params.go create mode 100644 x/shared/keeper/query_params_test.go create mode 100644 x/shared/module/autocli.go create mode 100644 x/shared/module/genesis.go create mode 100644 x/shared/module/genesis_test.go create mode 100644 x/shared/module/module.go create mode 100644 x/shared/module/simulation.go create mode 100644 x/shared/simulation/helpers.go create mode 100644 x/shared/types/codec.go create mode 100644 x/shared/types/errors.go create mode 100644 x/shared/types/expected_keepers.go create mode 100644 x/shared/types/genesis.go create mode 100644 x/shared/types/genesis.pb.go create mode 100644 x/shared/types/genesis_test.go create mode 100644 x/shared/types/keys.go create mode 100644 x/shared/types/msg_update_params.go create mode 100644 x/shared/types/params.go create mode 100644 x/shared/types/params.pb.go create mode 100644 x/shared/types/query.pb.go create mode 100644 x/shared/types/query.pb.gw.go create mode 100644 x/shared/types/tx.pb.go diff --git a/api/poktroll/shared/genesis.pulsar.go b/api/poktroll/shared/genesis.pulsar.go new file mode 100644 index 000000000..fd78a8946 --- /dev/null +++ b/api/poktroll/shared/genesis.pulsar.go @@ -0,0 +1,594 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package shared + +import ( + _ "cosmossdk.io/api/amino" + fmt "fmt" + runtime "github.com/cosmos/cosmos-proto/runtime" + _ "github.com/cosmos/gogoproto/gogoproto" + 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_GenesisState protoreflect.MessageDescriptor + fd_GenesisState_params protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_shared_genesis_proto_init() + md_GenesisState = File_poktroll_shared_genesis_proto.Messages().ByName("GenesisState") + fd_GenesisState_params = md_GenesisState.Fields().ByName("params") +} + +var _ protoreflect.Message = (*fastReflection_GenesisState)(nil) + +type fastReflection_GenesisState GenesisState + +func (x *GenesisState) ProtoReflect() protoreflect.Message { + return (*fastReflection_GenesisState)(x) +} + +func (x *GenesisState) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_shared_genesis_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_GenesisState_messageType fastReflection_GenesisState_messageType +var _ protoreflect.MessageType = fastReflection_GenesisState_messageType{} + +type fastReflection_GenesisState_messageType struct{} + +func (x fastReflection_GenesisState_messageType) Zero() protoreflect.Message { + return (*fastReflection_GenesisState)(nil) +} +func (x fastReflection_GenesisState_messageType) New() protoreflect.Message { + return new(fastReflection_GenesisState) +} +func (x fastReflection_GenesisState_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_GenesisState +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_GenesisState) Descriptor() protoreflect.MessageDescriptor { + return md_GenesisState +} + +// 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_GenesisState) Type() protoreflect.MessageType { + return _fastReflection_GenesisState_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_GenesisState) New() protoreflect.Message { + return new(fastReflection_GenesisState) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_GenesisState) Interface() protoreflect.ProtoMessage { + return (*GenesisState)(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_GenesisState) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Params != nil { + value := protoreflect.ValueOfMessage(x.Params.ProtoReflect()) + if !f(fd_GenesisState_params, 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_GenesisState) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.shared.GenesisState.params": + return x.Params != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.GenesisState")) + } + panic(fmt.Errorf("message poktroll.shared.GenesisState 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_GenesisState) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.shared.GenesisState.params": + x.Params = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.GenesisState")) + } + panic(fmt.Errorf("message poktroll.shared.GenesisState 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_GenesisState) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.shared.GenesisState.params": + value := x.Params + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.GenesisState")) + } + panic(fmt.Errorf("message poktroll.shared.GenesisState 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_GenesisState) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.shared.GenesisState.params": + x.Params = value.Message().Interface().(*Params) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.GenesisState")) + } + panic(fmt.Errorf("message poktroll.shared.GenesisState 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_GenesisState) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.shared.GenesisState.params": + if x.Params == nil { + x.Params = new(Params) + } + return protoreflect.ValueOfMessage(x.Params.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.GenesisState")) + } + panic(fmt.Errorf("message poktroll.shared.GenesisState 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_GenesisState) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.shared.GenesisState.params": + m := new(Params) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.GenesisState")) + } + panic(fmt.Errorf("message poktroll.shared.GenesisState 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_GenesisState) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.shared.GenesisState", 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_GenesisState) 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_GenesisState) 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_GenesisState) 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_GenesisState) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*GenesisState) + 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.Params != nil { + l = options.Size(x.Params) + 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().(*GenesisState) + 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.Params != nil { + encoded, err := options.Marshal(x.Params) + 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().(*GenesisState) + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GenesisState: 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 Params", 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.Params == nil { + x.Params = &Params{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Params); 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 +// protoc (unknown) +// source: poktroll/shared/genesis.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) +) + +// GenesisState defines the shared module's genesis state. +type GenesisState struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // params defines all the parameters of the module. + Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` +} + +func (x *GenesisState) Reset() { + *x = GenesisState{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_shared_genesis_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GenesisState) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GenesisState) ProtoMessage() {} + +// Deprecated: Use GenesisState.ProtoReflect.Descriptor instead. +func (*GenesisState) Descriptor() ([]byte, []int) { + return file_poktroll_shared_genesis_proto_rawDescGZIP(), []int{0} +} + +func (x *GenesisState) GetParams() *Params { + if x != nil { + return x.Params + } + return nil +} + +var File_poktroll_shared_genesis_proto protoreflect.FileDescriptor + +var file_poktroll_shared_genesis_proto_rawDesc = []byte{ + 0x0a, 0x1d, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, + 0x64, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x0f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, + 0x1a, 0x11, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x6d, 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, 0x70, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, + 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x4a, 0x0a, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, + 0x69, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x3a, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, + 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 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, 0xa2, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, + 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x42, 0x0c, 0x47, 0x65, 0x6e, + 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x20, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, + 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0xa2, 0x02, 0x03, + 0x50, 0x53, 0x58, 0xaa, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, + 0x68, 0x61, 0x72, 0x65, 0x64, 0xca, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0xe2, 0x02, 0x1b, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x3a, 0x3a, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_poktroll_shared_genesis_proto_rawDescOnce sync.Once + file_poktroll_shared_genesis_proto_rawDescData = file_poktroll_shared_genesis_proto_rawDesc +) + +func file_poktroll_shared_genesis_proto_rawDescGZIP() []byte { + file_poktroll_shared_genesis_proto_rawDescOnce.Do(func() { + file_poktroll_shared_genesis_proto_rawDescData = protoimpl.X.CompressGZIP(file_poktroll_shared_genesis_proto_rawDescData) + }) + return file_poktroll_shared_genesis_proto_rawDescData +} + +var file_poktroll_shared_genesis_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_poktroll_shared_genesis_proto_goTypes = []interface{}{ + (*GenesisState)(nil), // 0: poktroll.shared.GenesisState + (*Params)(nil), // 1: poktroll.shared.Params +} +var file_poktroll_shared_genesis_proto_depIdxs = []int32{ + 1, // 0: poktroll.shared.GenesisState.params:type_name -> poktroll.shared.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 +} + +func init() { file_poktroll_shared_genesis_proto_init() } +func file_poktroll_shared_genesis_proto_init() { + if File_poktroll_shared_genesis_proto != nil { + return + } + file_poktroll_shared_params_proto_init() + if !protoimpl.UnsafeEnabled { + file_poktroll_shared_genesis_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GenesisState); 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_shared_genesis_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_poktroll_shared_genesis_proto_goTypes, + DependencyIndexes: file_poktroll_shared_genesis_proto_depIdxs, + MessageInfos: file_poktroll_shared_genesis_proto_msgTypes, + }.Build() + File_poktroll_shared_genesis_proto = out.File + file_poktroll_shared_genesis_proto_rawDesc = nil + file_poktroll_shared_genesis_proto_goTypes = nil + file_poktroll_shared_genesis_proto_depIdxs = nil +} diff --git a/api/poktroll/shared/module/module.pulsar.go b/api/poktroll/shared/module/module.pulsar.go new file mode 100644 index 000000000..65c5b6bed --- /dev/null +++ b/api/poktroll/shared/module/module.pulsar.go @@ -0,0 +1,578 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package module + +import ( + _ "cosmossdk.io/api/cosmos/app/v1alpha1" + 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_Module protoreflect.MessageDescriptor + fd_Module_authority protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_shared_module_module_proto_init() + md_Module = File_poktroll_shared_module_module_proto.Messages().ByName("Module") + fd_Module_authority = md_Module.Fields().ByName("authority") +} + +var _ protoreflect.Message = (*fastReflection_Module)(nil) + +type fastReflection_Module Module + +func (x *Module) ProtoReflect() protoreflect.Message { + return (*fastReflection_Module)(x) +} + +func (x *Module) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_shared_module_module_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_Module_messageType fastReflection_Module_messageType +var _ protoreflect.MessageType = fastReflection_Module_messageType{} + +type fastReflection_Module_messageType struct{} + +func (x fastReflection_Module_messageType) Zero() protoreflect.Message { + return (*fastReflection_Module)(nil) +} +func (x fastReflection_Module_messageType) New() protoreflect.Message { + return new(fastReflection_Module) +} +func (x fastReflection_Module_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_Module +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_Module) Descriptor() protoreflect.MessageDescriptor { + return md_Module +} + +// 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_Module) Type() protoreflect.MessageType { + return _fastReflection_Module_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_Module) New() protoreflect.Message { + return new(fastReflection_Module) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_Module) Interface() protoreflect.ProtoMessage { + return (*Module)(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_Module) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Authority != "" { + value := protoreflect.ValueOfString(x.Authority) + if !f(fd_Module_authority, 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_Module) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.shared.module.Module.authority": + return x.Authority != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.module.Module")) + } + panic(fmt.Errorf("message poktroll.shared.module.Module 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_Module) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.shared.module.Module.authority": + x.Authority = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.module.Module")) + } + panic(fmt.Errorf("message poktroll.shared.module.Module 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_Module) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.shared.module.Module.authority": + value := x.Authority + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.module.Module")) + } + panic(fmt.Errorf("message poktroll.shared.module.Module 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_Module) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.shared.module.Module.authority": + x.Authority = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.module.Module")) + } + panic(fmt.Errorf("message poktroll.shared.module.Module 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_Module) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.shared.module.Module.authority": + panic(fmt.Errorf("field authority of message poktroll.shared.module.Module is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.module.Module")) + } + panic(fmt.Errorf("message poktroll.shared.module.Module 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_Module) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.shared.module.Module.authority": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.module.Module")) + } + panic(fmt.Errorf("message poktroll.shared.module.Module 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_Module) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.shared.module.Module", 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_Module) 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_Module) 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_Module) 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_Module) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*Module) + 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.Authority) + 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().(*Module) + 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.Authority) > 0 { + i -= len(x.Authority) + copy(dAtA[i:], x.Authority) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Authority))) + 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().(*Module) + 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: Module: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Module: 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 Authority", 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.Authority = 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, + } +} + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: poktroll/shared/module/module.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) +) + +// Module is the config object for the module. +type Module struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // authority defines the custom module authority. If not set, defaults to the governance module. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` +} + +func (x *Module) Reset() { + *x = Module{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_shared_module_module_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Module) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Module) ProtoMessage() {} + +// Deprecated: Use Module.ProtoReflect.Descriptor instead. +func (*Module) Descriptor() ([]byte, []int) { + return file_poktroll_shared_module_module_proto_rawDescGZIP(), []int{0} +} + +func (x *Module) GetAuthority() string { + if x != nil { + return x.Authority + } + return "" +} + +var File_poktroll_shared_module_module_proto protoreflect.FileDescriptor + +var file_poktroll_shared_module_module_proto_rawDesc = []byte{ + 0x0a, 0x23, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, + 0x64, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, + 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x1a, 0x20, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x59, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x75, 0x74, + 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x75, + 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x3a, 0x31, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x2b, 0x0a, + 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x6f, 0x6b, 0x74, + 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x2f, 0x78, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x42, 0xcc, 0x01, 0x0a, 0x1a, 0x63, + 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, + 0x65, 0x64, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, + 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x27, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, + 0x65, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x4d, 0xaa, 0x02, 0x16, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x2e, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, + 0xca, 0x02, 0x16, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, + 0x65, 0x64, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0xe2, 0x02, 0x22, 0x50, 0x6f, 0x6b, 0x74, + 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x5c, 0x4d, 0x6f, 0x64, 0x75, + 0x6c, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, + 0x18, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x68, 0x61, 0x72, 0x65, + 0x64, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_poktroll_shared_module_module_proto_rawDescOnce sync.Once + file_poktroll_shared_module_module_proto_rawDescData = file_poktroll_shared_module_module_proto_rawDesc +) + +func file_poktroll_shared_module_module_proto_rawDescGZIP() []byte { + file_poktroll_shared_module_module_proto_rawDescOnce.Do(func() { + file_poktroll_shared_module_module_proto_rawDescData = protoimpl.X.CompressGZIP(file_poktroll_shared_module_module_proto_rawDescData) + }) + return file_poktroll_shared_module_module_proto_rawDescData +} + +var file_poktroll_shared_module_module_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_poktroll_shared_module_module_proto_goTypes = []interface{}{ + (*Module)(nil), // 0: poktroll.shared.module.Module +} +var file_poktroll_shared_module_module_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_shared_module_module_proto_init() } +func file_poktroll_shared_module_module_proto_init() { + if File_poktroll_shared_module_module_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_poktroll_shared_module_module_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Module); 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_shared_module_module_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_poktroll_shared_module_module_proto_goTypes, + DependencyIndexes: file_poktroll_shared_module_module_proto_depIdxs, + MessageInfos: file_poktroll_shared_module_module_proto_msgTypes, + }.Build() + File_poktroll_shared_module_module_proto = out.File + file_poktroll_shared_module_module_proto_rawDesc = nil + file_poktroll_shared_module_module_proto_goTypes = nil + file_poktroll_shared_module_module_proto_depIdxs = nil +} diff --git a/api/poktroll/shared/params.pulsar.go b/api/poktroll/shared/params.pulsar.go new file mode 100644 index 000000000..672581c0a --- /dev/null +++ b/api/poktroll/shared/params.pulsar.go @@ -0,0 +1,499 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package shared + +import ( + _ "cosmossdk.io/api/amino" + fmt "fmt" + runtime "github.com/cosmos/cosmos-proto/runtime" + _ "github.com/cosmos/gogoproto/gogoproto" + 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_Params protoreflect.MessageDescriptor +) + +func init() { + file_poktroll_shared_params_proto_init() + md_Params = File_poktroll_shared_params_proto.Messages().ByName("Params") +} + +var _ protoreflect.Message = (*fastReflection_Params)(nil) + +type fastReflection_Params Params + +func (x *Params) ProtoReflect() protoreflect.Message { + return (*fastReflection_Params)(x) +} + +func (x *Params) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_shared_params_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_Params_messageType fastReflection_Params_messageType +var _ protoreflect.MessageType = fastReflection_Params_messageType{} + +type fastReflection_Params_messageType struct{} + +func (x fastReflection_Params_messageType) Zero() protoreflect.Message { + return (*fastReflection_Params)(nil) +} +func (x fastReflection_Params_messageType) New() protoreflect.Message { + return new(fastReflection_Params) +} +func (x fastReflection_Params_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_Params +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_Params) Descriptor() protoreflect.MessageDescriptor { + return md_Params +} + +// 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_Params) Type() protoreflect.MessageType { + return _fastReflection_Params_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_Params) New() protoreflect.Message { + return new(fastReflection_Params) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_Params) Interface() protoreflect.ProtoMessage { + return (*Params)(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_Params) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { +} + +// 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_Params) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.Params")) + } + panic(fmt.Errorf("message poktroll.shared.Params 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_Params) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.Params")) + } + panic(fmt.Errorf("message poktroll.shared.Params 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_Params) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.Params")) + } + panic(fmt.Errorf("message poktroll.shared.Params 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_Params) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.Params")) + } + panic(fmt.Errorf("message poktroll.shared.Params 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_Params) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.Params")) + } + panic(fmt.Errorf("message poktroll.shared.Params 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_Params) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.Params")) + } + panic(fmt.Errorf("message poktroll.shared.Params 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_Params) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.shared.Params", 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_Params) 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_Params) 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_Params) 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_Params) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*Params) + 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.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().(*Params) + 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 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().(*Params) + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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/shared/params.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) +) + +// Params defines the parameters for the module. +type Params struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *Params) Reset() { + *x = Params{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_shared_params_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Params) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Params) ProtoMessage() {} + +// Deprecated: Use Params.ProtoReflect.Descriptor instead. +func (*Params) Descriptor() ([]byte, []int) { + return file_poktroll_shared_params_proto_rawDescGZIP(), []int{0} +} + +var File_poktroll_shared_params_proto protoreflect.FileDescriptor + +var file_poktroll_shared_params_proto_rawDesc = []byte{ + 0x0a, 0x1c, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, + 0x64, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, + 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x1a, + 0x11, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x6d, 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, 0x22, 0x2b, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x73, 0x3a, 0x21, 0xe8, 0xa0, 0x1f, 0x01, 0x8a, 0xe7, 0xb0, 0x2a, 0x18, 0x70, 0x6f, 0x6b, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x78, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2f, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xa1, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, + 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x42, 0x0b, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x20, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0xa2, 0x02, + 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, + 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0xca, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0xe2, 0x02, 0x1b, 0x50, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x3a, 0x3a, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_poktroll_shared_params_proto_rawDescOnce sync.Once + file_poktroll_shared_params_proto_rawDescData = file_poktroll_shared_params_proto_rawDesc +) + +func file_poktroll_shared_params_proto_rawDescGZIP() []byte { + file_poktroll_shared_params_proto_rawDescOnce.Do(func() { + file_poktroll_shared_params_proto_rawDescData = protoimpl.X.CompressGZIP(file_poktroll_shared_params_proto_rawDescData) + }) + return file_poktroll_shared_params_proto_rawDescData +} + +var file_poktroll_shared_params_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_poktroll_shared_params_proto_goTypes = []interface{}{ + (*Params)(nil), // 0: poktroll.shared.Params +} +var file_poktroll_shared_params_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_shared_params_proto_init() } +func file_poktroll_shared_params_proto_init() { + if File_poktroll_shared_params_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_poktroll_shared_params_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Params); 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_shared_params_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_poktroll_shared_params_proto_goTypes, + DependencyIndexes: file_poktroll_shared_params_proto_depIdxs, + MessageInfos: file_poktroll_shared_params_proto_msgTypes, + }.Build() + File_poktroll_shared_params_proto = out.File + file_poktroll_shared_params_proto_rawDesc = nil + file_poktroll_shared_params_proto_goTypes = nil + file_poktroll_shared_params_proto_depIdxs = nil +} diff --git a/api/poktroll/shared/query.pulsar.go b/api/poktroll/shared/query.pulsar.go new file mode 100644 index 000000000..dc6ba3a9d --- /dev/null +++ b/api/poktroll/shared/query.pulsar.go @@ -0,0 +1,1010 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package shared + +import ( + _ "cosmossdk.io/api/amino" + _ "cosmossdk.io/api/cosmos/base/query/v1beta1" + fmt "fmt" + runtime "github.com/cosmos/cosmos-proto/runtime" + _ "github.com/cosmos/gogoproto/gogoproto" + _ "google.golang.org/genproto/googleapis/api/annotations" + 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_QueryParamsRequest protoreflect.MessageDescriptor +) + +func init() { + file_poktroll_shared_query_proto_init() + md_QueryParamsRequest = File_poktroll_shared_query_proto.Messages().ByName("QueryParamsRequest") +} + +var _ protoreflect.Message = (*fastReflection_QueryParamsRequest)(nil) + +type fastReflection_QueryParamsRequest QueryParamsRequest + +func (x *QueryParamsRequest) ProtoReflect() protoreflect.Message { + return (*fastReflection_QueryParamsRequest)(x) +} + +func (x *QueryParamsRequest) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_shared_query_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_QueryParamsRequest_messageType fastReflection_QueryParamsRequest_messageType +var _ protoreflect.MessageType = fastReflection_QueryParamsRequest_messageType{} + +type fastReflection_QueryParamsRequest_messageType struct{} + +func (x fastReflection_QueryParamsRequest_messageType) Zero() protoreflect.Message { + return (*fastReflection_QueryParamsRequest)(nil) +} +func (x fastReflection_QueryParamsRequest_messageType) New() protoreflect.Message { + return new(fastReflection_QueryParamsRequest) +} +func (x fastReflection_QueryParamsRequest_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_QueryParamsRequest +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_QueryParamsRequest) Descriptor() protoreflect.MessageDescriptor { + return md_QueryParamsRequest +} + +// 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_QueryParamsRequest) Type() protoreflect.MessageType { + return _fastReflection_QueryParamsRequest_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_QueryParamsRequest) New() protoreflect.Message { + return new(fastReflection_QueryParamsRequest) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_QueryParamsRequest) Interface() protoreflect.ProtoMessage { + return (*QueryParamsRequest)(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_QueryParamsRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { +} + +// 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_QueryParamsRequest) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.QueryParamsRequest")) + } + panic(fmt.Errorf("message poktroll.shared.QueryParamsRequest 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_QueryParamsRequest) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.QueryParamsRequest")) + } + panic(fmt.Errorf("message poktroll.shared.QueryParamsRequest 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_QueryParamsRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.QueryParamsRequest")) + } + panic(fmt.Errorf("message poktroll.shared.QueryParamsRequest 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_QueryParamsRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.QueryParamsRequest")) + } + panic(fmt.Errorf("message poktroll.shared.QueryParamsRequest 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_QueryParamsRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.QueryParamsRequest")) + } + panic(fmt.Errorf("message poktroll.shared.QueryParamsRequest 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_QueryParamsRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.QueryParamsRequest")) + } + panic(fmt.Errorf("message poktroll.shared.QueryParamsRequest 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_QueryParamsRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.shared.QueryParamsRequest", 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_QueryParamsRequest) 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_QueryParamsRequest) 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_QueryParamsRequest) 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_QueryParamsRequest) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*QueryParamsRequest) + 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.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().(*QueryParamsRequest) + 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 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().(*QueryParamsRequest) + 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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_QueryParamsResponse protoreflect.MessageDescriptor + fd_QueryParamsResponse_params protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_shared_query_proto_init() + md_QueryParamsResponse = File_poktroll_shared_query_proto.Messages().ByName("QueryParamsResponse") + fd_QueryParamsResponse_params = md_QueryParamsResponse.Fields().ByName("params") +} + +var _ protoreflect.Message = (*fastReflection_QueryParamsResponse)(nil) + +type fastReflection_QueryParamsResponse QueryParamsResponse + +func (x *QueryParamsResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_QueryParamsResponse)(x) +} + +func (x *QueryParamsResponse) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_shared_query_proto_msgTypes[1] + 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_QueryParamsResponse_messageType fastReflection_QueryParamsResponse_messageType +var _ protoreflect.MessageType = fastReflection_QueryParamsResponse_messageType{} + +type fastReflection_QueryParamsResponse_messageType struct{} + +func (x fastReflection_QueryParamsResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_QueryParamsResponse)(nil) +} +func (x fastReflection_QueryParamsResponse_messageType) New() protoreflect.Message { + return new(fastReflection_QueryParamsResponse) +} +func (x fastReflection_QueryParamsResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_QueryParamsResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_QueryParamsResponse) Descriptor() protoreflect.MessageDescriptor { + return md_QueryParamsResponse +} + +// 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_QueryParamsResponse) Type() protoreflect.MessageType { + return _fastReflection_QueryParamsResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_QueryParamsResponse) New() protoreflect.Message { + return new(fastReflection_QueryParamsResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_QueryParamsResponse) Interface() protoreflect.ProtoMessage { + return (*QueryParamsResponse)(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_QueryParamsResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Params != nil { + value := protoreflect.ValueOfMessage(x.Params.ProtoReflect()) + if !f(fd_QueryParamsResponse_params, 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_QueryParamsResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.shared.QueryParamsResponse.params": + return x.Params != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.QueryParamsResponse")) + } + panic(fmt.Errorf("message poktroll.shared.QueryParamsResponse 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_QueryParamsResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.shared.QueryParamsResponse.params": + x.Params = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.QueryParamsResponse")) + } + panic(fmt.Errorf("message poktroll.shared.QueryParamsResponse 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_QueryParamsResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.shared.QueryParamsResponse.params": + value := x.Params + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.QueryParamsResponse")) + } + panic(fmt.Errorf("message poktroll.shared.QueryParamsResponse 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_QueryParamsResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.shared.QueryParamsResponse.params": + x.Params = value.Message().Interface().(*Params) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.QueryParamsResponse")) + } + panic(fmt.Errorf("message poktroll.shared.QueryParamsResponse 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_QueryParamsResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.shared.QueryParamsResponse.params": + if x.Params == nil { + x.Params = new(Params) + } + return protoreflect.ValueOfMessage(x.Params.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.QueryParamsResponse")) + } + panic(fmt.Errorf("message poktroll.shared.QueryParamsResponse 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_QueryParamsResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.shared.QueryParamsResponse.params": + m := new(Params) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.QueryParamsResponse")) + } + panic(fmt.Errorf("message poktroll.shared.QueryParamsResponse 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_QueryParamsResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.shared.QueryParamsResponse", 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_QueryParamsResponse) 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_QueryParamsResponse) 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_QueryParamsResponse) 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_QueryParamsResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*QueryParamsResponse) + 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.Params != nil { + l = options.Size(x.Params) + 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().(*QueryParamsResponse) + 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.Params != nil { + encoded, err := options.Marshal(x.Params) + 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().(*QueryParamsResponse) + 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryParamsResponse: 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 Params", 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.Params == nil { + x.Params = &Params{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Params); 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 +// protoc (unknown) +// source: poktroll/shared/query.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) +) + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *QueryParamsRequest) Reset() { + *x = QueryParamsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_shared_query_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryParamsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryParamsRequest) ProtoMessage() {} + +// Deprecated: Use QueryParamsRequest.ProtoReflect.Descriptor instead. +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return file_poktroll_shared_query_proto_rawDescGZIP(), []int{0} +} + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // params holds all the parameters of this module. + Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` +} + +func (x *QueryParamsResponse) Reset() { + *x = QueryParamsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_shared_query_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryParamsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryParamsResponse) ProtoMessage() {} + +// Deprecated: Use QueryParamsResponse.ProtoReflect.Descriptor instead. +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return file_poktroll_shared_query_proto_rawDescGZIP(), []int{1} +} + +func (x *QueryParamsResponse) GetParams() *Params { + if x != nil { + return x.Params + } + return nil +} + +var File_poktroll_shared_query_proto protoreflect.FileDescriptor + +var file_poktroll_shared_query_proto_rawDesc = []byte{ + 0x0a, 0x1b, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, + 0x64, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x70, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x1a, 0x11, + 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x6d, 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, 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, 0x1c, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, + 0x65, 0x64, 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, 0x51, 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x06, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 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, 0x8b, 0x01, 0x0a, 0x05, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x12, 0x81, 0x01, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x23, 0x2e, + 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, + 0x61, 0x72, 0x65, 0x64, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x26, + 0x12, 0x24, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, + 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2f, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xa0, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x70, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x42, 0x0a, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x20, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0xa2, 0x02, + 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, + 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0xca, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0xe2, 0x02, 0x1b, 0x50, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x3a, 0x3a, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_poktroll_shared_query_proto_rawDescOnce sync.Once + file_poktroll_shared_query_proto_rawDescData = file_poktroll_shared_query_proto_rawDesc +) + +func file_poktroll_shared_query_proto_rawDescGZIP() []byte { + file_poktroll_shared_query_proto_rawDescOnce.Do(func() { + file_poktroll_shared_query_proto_rawDescData = protoimpl.X.CompressGZIP(file_poktroll_shared_query_proto_rawDescData) + }) + return file_poktroll_shared_query_proto_rawDescData +} + +var file_poktroll_shared_query_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_poktroll_shared_query_proto_goTypes = []interface{}{ + (*QueryParamsRequest)(nil), // 0: poktroll.shared.QueryParamsRequest + (*QueryParamsResponse)(nil), // 1: poktroll.shared.QueryParamsResponse + (*Params)(nil), // 2: poktroll.shared.Params +} +var file_poktroll_shared_query_proto_depIdxs = []int32{ + 2, // 0: poktroll.shared.QueryParamsResponse.params:type_name -> poktroll.shared.Params + 0, // 1: poktroll.shared.Query.Params:input_type -> poktroll.shared.QueryParamsRequest + 1, // 2: poktroll.shared.Query.Params:output_type -> poktroll.shared.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 +} + +func init() { file_poktroll_shared_query_proto_init() } +func file_poktroll_shared_query_proto_init() { + if File_poktroll_shared_query_proto != nil { + return + } + file_poktroll_shared_params_proto_init() + if !protoimpl.UnsafeEnabled { + file_poktroll_shared_query_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryParamsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_poktroll_shared_query_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryParamsResponse); 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_shared_query_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_poktroll_shared_query_proto_goTypes, + DependencyIndexes: file_poktroll_shared_query_proto_depIdxs, + MessageInfos: file_poktroll_shared_query_proto_msgTypes, + }.Build() + File_poktroll_shared_query_proto = out.File + file_poktroll_shared_query_proto_rawDesc = nil + file_poktroll_shared_query_proto_goTypes = nil + file_poktroll_shared_query_proto_depIdxs = nil +} diff --git a/api/poktroll/shared/query_grpc.pb.go b/api/poktroll/shared/query_grpc.pb.go new file mode 100644 index 000000000..fa58edaa5 --- /dev/null +++ b/api/poktroll/shared/query_grpc.pb.go @@ -0,0 +1,111 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: poktroll/shared/query.proto + +package shared + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + Query_Params_FullMethodName = "/poktroll.shared.Query/Params" +) + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) +} + +type queryClient struct { + cc grpc.ClientConnInterface +} + +func NewQueryClient(cc grpc.ClientConnInterface) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, Query_Params_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) + mustEmbedUnimplementedQueryServer() +} + +// UnimplementedQueryServer must be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (UnimplementedQueryServer) Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {} + +// UnsafeQueryServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to QueryServer will +// result in compilation errors. +type UnsafeQueryServer interface { + mustEmbedUnimplementedQueryServer() +} + +func RegisterQueryServer(s grpc.ServiceRegistrar, srv QueryServer) { + s.RegisterService(&Query_ServiceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Query_Params_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + 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) +var Query_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "poktroll.shared.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "poktroll/shared/query.proto", +} diff --git a/api/poktroll/shared/tx.pulsar.go b/api/poktroll/shared/tx.pulsar.go new file mode 100644 index 000000000..152712a8d --- /dev/null +++ b/api/poktroll/shared/tx.pulsar.go @@ -0,0 +1,1089 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package shared + +import ( + _ "cosmossdk.io/api/amino" + _ "cosmossdk.io/api/cosmos/msg/v1" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + runtime "github.com/cosmos/cosmos-proto/runtime" + _ "github.com/cosmos/gogoproto/gogoproto" + 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_MsgUpdateParams protoreflect.MessageDescriptor + fd_MsgUpdateParams_authority protoreflect.FieldDescriptor + fd_MsgUpdateParams_params protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_shared_tx_proto_init() + md_MsgUpdateParams = File_poktroll_shared_tx_proto.Messages().ByName("MsgUpdateParams") + fd_MsgUpdateParams_authority = md_MsgUpdateParams.Fields().ByName("authority") + fd_MsgUpdateParams_params = md_MsgUpdateParams.Fields().ByName("params") +} + +var _ protoreflect.Message = (*fastReflection_MsgUpdateParams)(nil) + +type fastReflection_MsgUpdateParams MsgUpdateParams + +func (x *MsgUpdateParams) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgUpdateParams)(x) +} + +func (x *MsgUpdateParams) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_shared_tx_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_MsgUpdateParams_messageType fastReflection_MsgUpdateParams_messageType +var _ protoreflect.MessageType = fastReflection_MsgUpdateParams_messageType{} + +type fastReflection_MsgUpdateParams_messageType struct{} + +func (x fastReflection_MsgUpdateParams_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgUpdateParams)(nil) +} +func (x fastReflection_MsgUpdateParams_messageType) New() protoreflect.Message { + return new(fastReflection_MsgUpdateParams) +} +func (x fastReflection_MsgUpdateParams_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgUpdateParams +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgUpdateParams) Descriptor() protoreflect.MessageDescriptor { + return md_MsgUpdateParams +} + +// 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_MsgUpdateParams) Type() protoreflect.MessageType { + return _fastReflection_MsgUpdateParams_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgUpdateParams) New() protoreflect.Message { + return new(fastReflection_MsgUpdateParams) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgUpdateParams) Interface() protoreflect.ProtoMessage { + return (*MsgUpdateParams)(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_MsgUpdateParams) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Authority != "" { + value := protoreflect.ValueOfString(x.Authority) + if !f(fd_MsgUpdateParams_authority, value) { + return + } + } + if x.Params != nil { + value := protoreflect.ValueOfMessage(x.Params.ProtoReflect()) + if !f(fd_MsgUpdateParams_params, 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_MsgUpdateParams) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.shared.MsgUpdateParams.authority": + return x.Authority != "" + case "poktroll.shared.MsgUpdateParams.params": + return x.Params != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParams")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParams 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_MsgUpdateParams) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.shared.MsgUpdateParams.authority": + x.Authority = "" + case "poktroll.shared.MsgUpdateParams.params": + x.Params = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParams")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParams 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_MsgUpdateParams) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.shared.MsgUpdateParams.authority": + value := x.Authority + return protoreflect.ValueOfString(value) + case "poktroll.shared.MsgUpdateParams.params": + value := x.Params + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParams")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParams 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_MsgUpdateParams) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.shared.MsgUpdateParams.authority": + x.Authority = value.Interface().(string) + case "poktroll.shared.MsgUpdateParams.params": + x.Params = value.Message().Interface().(*Params) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParams")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParams 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_MsgUpdateParams) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.shared.MsgUpdateParams.params": + if x.Params == nil { + x.Params = new(Params) + } + return protoreflect.ValueOfMessage(x.Params.ProtoReflect()) + case "poktroll.shared.MsgUpdateParams.authority": + panic(fmt.Errorf("field authority of message poktroll.shared.MsgUpdateParams is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParams")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParams 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_MsgUpdateParams) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.shared.MsgUpdateParams.authority": + return protoreflect.ValueOfString("") + case "poktroll.shared.MsgUpdateParams.params": + m := new(Params) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParams")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParams 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_MsgUpdateParams) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.shared.MsgUpdateParams", 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_MsgUpdateParams) 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_MsgUpdateParams) 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_MsgUpdateParams) 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_MsgUpdateParams) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgUpdateParams) + 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.Authority) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Params != nil { + l = options.Size(x.Params) + 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().(*MsgUpdateParams) + 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.Params != nil { + encoded, err := options.Marshal(x.Params) + 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.Authority) > 0 { + i -= len(x.Authority) + copy(dAtA[i:], x.Authority) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Authority))) + 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().(*MsgUpdateParams) + 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: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgUpdateParams: 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 Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Params", 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.Params == nil { + x.Params = &Params{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Params); 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_MsgUpdateParamsResponse protoreflect.MessageDescriptor +) + +func init() { + file_poktroll_shared_tx_proto_init() + md_MsgUpdateParamsResponse = File_poktroll_shared_tx_proto.Messages().ByName("MsgUpdateParamsResponse") +} + +var _ protoreflect.Message = (*fastReflection_MsgUpdateParamsResponse)(nil) + +type fastReflection_MsgUpdateParamsResponse MsgUpdateParamsResponse + +func (x *MsgUpdateParamsResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgUpdateParamsResponse)(x) +} + +func (x *MsgUpdateParamsResponse) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_shared_tx_proto_msgTypes[1] + 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_MsgUpdateParamsResponse_messageType fastReflection_MsgUpdateParamsResponse_messageType +var _ protoreflect.MessageType = fastReflection_MsgUpdateParamsResponse_messageType{} + +type fastReflection_MsgUpdateParamsResponse_messageType struct{} + +func (x fastReflection_MsgUpdateParamsResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgUpdateParamsResponse)(nil) +} +func (x fastReflection_MsgUpdateParamsResponse_messageType) New() protoreflect.Message { + return new(fastReflection_MsgUpdateParamsResponse) +} +func (x fastReflection_MsgUpdateParamsResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgUpdateParamsResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgUpdateParamsResponse) Descriptor() protoreflect.MessageDescriptor { + return md_MsgUpdateParamsResponse +} + +// 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_MsgUpdateParamsResponse) Type() protoreflect.MessageType { + return _fastReflection_MsgUpdateParamsResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgUpdateParamsResponse) New() protoreflect.Message { + return new(fastReflection_MsgUpdateParamsResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgUpdateParamsResponse) Interface() protoreflect.ProtoMessage { + return (*MsgUpdateParamsResponse)(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_MsgUpdateParamsResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { +} + +// 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_MsgUpdateParamsResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParamsResponse")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParamsResponse 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_MsgUpdateParamsResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParamsResponse")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParamsResponse 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_MsgUpdateParamsResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParamsResponse")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParamsResponse 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_MsgUpdateParamsResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParamsResponse")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParamsResponse 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_MsgUpdateParamsResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParamsResponse")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParamsResponse 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_MsgUpdateParamsResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParamsResponse")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParamsResponse 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_MsgUpdateParamsResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.shared.MsgUpdateParamsResponse", 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_MsgUpdateParamsResponse) 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_MsgUpdateParamsResponse) 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_MsgUpdateParamsResponse) 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_MsgUpdateParamsResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgUpdateParamsResponse) + 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.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().(*MsgUpdateParamsResponse) + 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 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().(*MsgUpdateParamsResponse) + 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: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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/shared/tx.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) +) + +// MsgUpdateParams is the Msg/UpdateParams request type. +type MsgUpdateParams struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // authority is the address that controls the module (defaults to x/gov unless overwritten). + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // params defines the module parameters to update. + // + // NOTE: All parameters must be supplied. + Params *Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params,omitempty"` +} + +func (x *MsgUpdateParams) Reset() { + *x = MsgUpdateParams{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_shared_tx_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgUpdateParams) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgUpdateParams) ProtoMessage() {} + +// Deprecated: Use MsgUpdateParams.ProtoReflect.Descriptor instead. +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return file_poktroll_shared_tx_proto_rawDescGZIP(), []int{0} +} + +func (x *MsgUpdateParams) GetAuthority() string { + if x != nil { + return x.Authority + } + return "" +} + +func (x *MsgUpdateParams) GetParams() *Params { + if x != nil { + return x.Params + } + return nil +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +type MsgUpdateParamsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *MsgUpdateParamsResponse) Reset() { + *x = MsgUpdateParamsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_shared_tx_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgUpdateParamsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgUpdateParamsResponse) ProtoMessage() {} + +// Deprecated: Use MsgUpdateParamsResponse.ProtoReflect.Descriptor instead. +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return file_poktroll_shared_tx_proto_rawDescGZIP(), []int{1} +} + +var File_poktroll_shared_tx_proto protoreflect.FileDescriptor + +var file_poktroll_shared_tx_proto_rawDesc = []byte{ + 0x0a, 0x18, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, + 0x64, 0x2f, 0x74, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x70, 0x6f, 0x6b, 0x74, + 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x1a, 0x11, 0x61, 0x6d, 0x69, + 0x6e, 0x6f, 0x2f, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x73, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x73, + 0x67, 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, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, + 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbb, 0x01, 0x0a, 0x0f, 0x4d, 0x73, 0x67, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x36, 0x0a, 0x09, 0x61, 0x75, + 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, + 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, + 0x74, 0x79, 0x12, 0x3a, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, + 0x61, 0x72, 0x65, 0x64, 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, 0x3a, 0x34, + 0x82, 0xe7, 0xb0, 0x2a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x8a, 0xe7, + 0xb0, 0x2a, 0x21, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x78, 0x2f, 0x73, 0x68, + 0x61, 0x72, 0x65, 0x64, 0x2f, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x22, 0x19, 0x0a, 0x17, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, + 0x68, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x5a, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x20, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x28, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0x9d, 0x01, 0x0a, 0x13, 0x63, 0x6f, + 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, + 0x64, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x20, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0xa2, 0x02, + 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, + 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0xca, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0xe2, 0x02, 0x1b, 0x50, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x3a, 0x3a, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_poktroll_shared_tx_proto_rawDescOnce sync.Once + file_poktroll_shared_tx_proto_rawDescData = file_poktroll_shared_tx_proto_rawDesc +) + +func file_poktroll_shared_tx_proto_rawDescGZIP() []byte { + file_poktroll_shared_tx_proto_rawDescOnce.Do(func() { + file_poktroll_shared_tx_proto_rawDescData = protoimpl.X.CompressGZIP(file_poktroll_shared_tx_proto_rawDescData) + }) + return file_poktroll_shared_tx_proto_rawDescData +} + +var file_poktroll_shared_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_poktroll_shared_tx_proto_goTypes = []interface{}{ + (*MsgUpdateParams)(nil), // 0: poktroll.shared.MsgUpdateParams + (*MsgUpdateParamsResponse)(nil), // 1: poktroll.shared.MsgUpdateParamsResponse + (*Params)(nil), // 2: poktroll.shared.Params +} +var file_poktroll_shared_tx_proto_depIdxs = []int32{ + 2, // 0: poktroll.shared.MsgUpdateParams.params:type_name -> poktroll.shared.Params + 0, // 1: poktroll.shared.Msg.UpdateParams:input_type -> poktroll.shared.MsgUpdateParams + 1, // 2: poktroll.shared.Msg.UpdateParams:output_type -> poktroll.shared.MsgUpdateParamsResponse + 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 +} + +func init() { file_poktroll_shared_tx_proto_init() } +func file_poktroll_shared_tx_proto_init() { + if File_poktroll_shared_tx_proto != nil { + return + } + file_poktroll_shared_params_proto_init() + if !protoimpl.UnsafeEnabled { + file_poktroll_shared_tx_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgUpdateParams); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_poktroll_shared_tx_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgUpdateParamsResponse); 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_shared_tx_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_poktroll_shared_tx_proto_goTypes, + DependencyIndexes: file_poktroll_shared_tx_proto_depIdxs, + MessageInfos: file_poktroll_shared_tx_proto_msgTypes, + }.Build() + File_poktroll_shared_tx_proto = out.File + file_poktroll_shared_tx_proto_rawDesc = nil + file_poktroll_shared_tx_proto_goTypes = nil + file_poktroll_shared_tx_proto_depIdxs = nil +} diff --git a/api/poktroll/shared/tx_grpc.pb.go b/api/poktroll/shared/tx_grpc.pb.go new file mode 100644 index 000000000..6e760cdf7 --- /dev/null +++ b/api/poktroll/shared/tx_grpc.pb.go @@ -0,0 +1,113 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: poktroll/shared/tx.proto + +package shared + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + Msg_UpdateParams_FullMethodName = "/poktroll.shared.Msg/UpdateParams" +) + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type MsgClient interface { + // UpdateParams defines a (governance) operation for updating the module + // parameters. The authority defaults to the x/gov module account. + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) +} + +type msgClient struct { + cc grpc.ClientConnInterface +} + +func NewMsgClient(cc grpc.ClientConnInterface) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, Msg_UpdateParams_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +// All implementations must embed UnimplementedMsgServer +// for forward compatibility +type MsgServer interface { + // UpdateParams defines a (governance) operation for updating the module + // parameters. The authority defaults to the x/gov module account. + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + mustEmbedUnimplementedMsgServer() +} + +// UnimplementedMsgServer must be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} +func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {} + +// UnsafeMsgServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to MsgServer will +// result in compilation errors. +type UnsafeMsgServer interface { + mustEmbedUnimplementedMsgServer() +} + +func RegisterMsgServer(s grpc.ServiceRegistrar, srv MsgServer) { + s.RegisterService(&Msg_ServiceDesc, srv) +} + +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Msg_UpdateParams_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + +// Msg_ServiceDesc is the grpc.ServiceDesc for Msg service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Msg_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "poktroll.shared.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "poktroll/shared/tx.proto", +} diff --git a/app/app.go b/app/app.go index 9ff1c00c9..59170ffcd 100644 --- a/app/app.go +++ b/app/app.go @@ -1,7 +1,8 @@ package app import ( - // this line is used by starport scaffolding # stargate/app/moduleImport + sharedmodulekeeper "github.com/pokt-network/poktroll/x/shared/keeper" +// this line is used by starport scaffolding # stargate/app/moduleImport "io" "os" "path/filepath" @@ -131,7 +132,8 @@ type App struct { SessionKeeper sessionmodulekeeper.Keeper ProofKeeper proofmodulekeeper.Keeper TokenomicsKeeper tokenomicsmodulekeeper.Keeper - // this line is used by starport scaffolding # stargate/app/keeperDeclaration + SharedKeeper sharedmodulekeeper.Keeper +// this line is used by starport scaffolding # stargate/app/keeperDeclaration // simulation manager sm *module.SimulationManager @@ -276,6 +278,7 @@ func New( &app.SessionKeeper, &app.ProofKeeper, &app.TokenomicsKeeper, + &app.SharedKeeper, // this line is used by starport scaffolding # stargate/app/keeperDefinition ); err != nil { panic(err) diff --git a/app/app_config.go b/app/app_config.go index 5edce4972..c7e1437d8 100644 --- a/app/app_config.go +++ b/app/app_config.go @@ -1,7 +1,10 @@ package app import ( - // this line is used by starport scaffolding # stargate/app/moduleImport + sharedmodulev1 "github.com/pokt-network/poktroll/api/poktroll/shared/module" +_ "github.com/pokt-network/poktroll/x/shared/module" // import for side-effects +sharedmoduletypes "github.com/pokt-network/poktroll/x/shared/types" +// this line is used by starport scaffolding # stargate/app/moduleImport "time" runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" @@ -136,7 +139,8 @@ var ( sessionmoduletypes.ModuleName, proofmoduletypes.ModuleName, tokenomicsmoduletypes.ModuleName, - // this line is used by starport scaffolding # stargate/app/initGenesis + sharedmoduletypes.ModuleName, +// this line is used by starport scaffolding # stargate/app/initGenesis } // During begin block slashing happens after distr.BeginBlocker so that @@ -167,7 +171,8 @@ var ( sessionmoduletypes.ModuleName, proofmoduletypes.ModuleName, tokenomicsmoduletypes.ModuleName, - // this line is used by starport scaffolding # stargate/app/beginBlockers + sharedmoduletypes.ModuleName, +// this line is used by starport scaffolding # stargate/app/beginBlockers } endBlockers = []string{ @@ -192,7 +197,8 @@ var ( sessionmoduletypes.ModuleName, proofmoduletypes.ModuleName, tokenomicsmoduletypes.ModuleName, - // this line is used by starport scaffolding # stargate/app/endBlockers + sharedmoduletypes.ModuleName, +// this line is used by starport scaffolding # stargate/app/endBlockers } preBlockers = []string{ @@ -375,7 +381,11 @@ var ( Name: tokenomicsmoduletypes.ModuleName, Config: appconfig.WrapAny(&tokenomicsmodulev1.Module{}), }, - // this line is used by starport scaffolding # stargate/app/moduleConfig + { + Name: sharedmoduletypes.ModuleName, + Config: appconfig.WrapAny(&sharedmodulev1.Module{}), + }, +// this line is used by starport scaffolding # stargate/app/moduleConfig }, }) ) diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 4936bf122..f09f70e84 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -15929,14 +15929,149 @@ paths: parameters. tags: - Msg - /poktroll.application.Msg/DelegateToGateway: - post: - operationId: PoktrollApplicationMsg_DelegateToGateway + /pokt-network/poktroll/application/application: + get: + operationId: PoktrollApplicationQuery_AllApplications responses: '200': description: A successful response. schema: type: object + properties: + applications: + type: array + items: + type: object + properties: + address: + type: string + title: >- + The Bech32 address of the application using cosmos' + ScalarDescriptor to ensure deterministic encoding + stake: + title: The total amount of uPOKT the application has staked + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + service_configs: + type: array + items: + type: object + properties: + service: + title: >- + The Service for which the application is + configured + type: object + properties: + id: + type: string + description: Unique identifier for the service + title: >- + For example, what if we want to request a + session for a certain service but with some + additional configs that identify it? + name: + type: string + description: >- + (Optional) Semantic human readable name for + the service + title: >- + TODO_TECHDEBT: Name is currently unused but + acts as a reminder that an optional onchain + representation of the service is necessary + title: >- + ApplicationServiceConfig holds the service + configuration the application stakes for + title: >- + The list of services this appliccation is configured to + request service for + delegatee_gateway_addresses: + type: array + items: + type: string + description: >- + TODO_TECHDEBT: Rename `delegatee_gateway_addresses` to + `gateway_addresses_delegated_to`. + + Ensure to rename all relevant configs, comments, + variables, function names, etc as well. + + + The Bech32 encoded addresses for all delegatee Gateways, + in a non-nullable slice + pending_undelegations: + type: object + additionalProperties: + type: object + properties: + gateway_addresses: + type: array + items: + type: string + description: >- + UndelegatingGatewayList is used as the Value of + `pending_undelegations`. + + It is required to store a repeated list of strings as + a map value. + description: >- + A map from sessionEndHeights to a list of Gateways. + + The key is the height of the last block of the session + during which the + + respective undelegation was committed. + + The value is a list of gateways being undelegated from. + + TODO_DOCUMENT(@red-0ne): Need to document the flow from + this comment + + so its clear to everyone why this is necessary; + https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. + title: >- + Application defines the type used to store an on-chain + definition and state for an application + pagination: + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: >- + PageResponse is to be embedded in gRPC response messages where + the + + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } default: description: An unexpected error response. schema: @@ -15956,37 +16091,176 @@ paths: type: string additionalProperties: {} parameters: - - name: body - in: body - required: true - schema: - type: object - properties: - app_address: - type: string - title: >- - The Bech32 address of the application using cosmos' - ScalarDescriptor to ensure deterministic deterministic - encoding using cosmos' ScalarDescriptor to ensure - deterministic deterministic encoding - gateway_address: - type: string - title: >- - The Bech32 address of the gateway the application wants to - delegate to using cosmos' ScalarDescriptor to ensure - deterministic deterministic encoding using cosmos' - ScalarDescriptor to ensure deterministic deterministic - encoding + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean tags: - - Msg - /poktroll.application.Msg/StakeApplication: - post: - operationId: PoktrollApplicationMsg_StakeApplication + - Query + /pokt-network/poktroll/application/application/{address}: + get: + summary: Queries a list of Application items. + operationId: PoktrollApplicationQuery_Application responses: '200': description: A successful response. schema: type: object + properties: + application: + type: object + properties: + address: + type: string + title: >- + The Bech32 address of the application using cosmos' + ScalarDescriptor to ensure deterministic encoding + stake: + title: The total amount of uPOKT the application has staked + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + service_configs: + type: array + items: + type: object + properties: + service: + title: The Service for which the application is configured + type: object + properties: + id: + type: string + description: Unique identifier for the service + title: >- + For example, what if we want to request a + session for a certain service but with some + additional configs that identify it? + name: + type: string + description: >- + (Optional) Semantic human readable name for the + service + title: >- + TODO_TECHDEBT: Name is currently unused but acts + as a reminder that an optional onchain + representation of the service is necessary + title: >- + ApplicationServiceConfig holds the service configuration + the application stakes for + title: >- + The list of services this appliccation is configured to + request service for + delegatee_gateway_addresses: + type: array + items: + type: string + description: >- + TODO_TECHDEBT: Rename `delegatee_gateway_addresses` to + `gateway_addresses_delegated_to`. + + Ensure to rename all relevant configs, comments, + variables, function names, etc as well. + + + The Bech32 encoded addresses for all delegatee Gateways, + in a non-nullable slice + pending_undelegations: + type: object + additionalProperties: + type: object + properties: + gateway_addresses: + type: array + items: + type: string + description: >- + UndelegatingGatewayList is used as the Value of + `pending_undelegations`. + + It is required to store a repeated list of strings as a + map value. + description: >- + A map from sessionEndHeights to a list of Gateways. + + The key is the height of the last block of the session + during which the + + respective undelegation was committed. + + The value is a list of gateways being undelegated from. + + TODO_DOCUMENT(@red-0ne): Need to document the flow from + this comment + + so its clear to everyone why this is necessary; + https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. + title: >- + Application defines the type used to store an on-chain + definition and state for an application default: description: An unexpected error response. schema: @@ -16006,31 +16280,154 @@ paths: type: string additionalProperties: {} parameters: - - name: body - in: body + - name: address + in: path required: true + type: string + tags: + - Query + /pokt-network/poktroll/application/params: + get: + summary: Parameters queries the parameters of the module. + operationId: PoktrollApplicationQuery_Params + responses: + '200': + description: A successful response. schema: type: object properties: - address: - type: string - title: >- - The Bech32 address of the application using cosmos' - ScalarDescriptor to ensure deterministic encoding - stake: - title: >- - The total amount of uPOKT the application has staked. Must be - ≥ to the current amount that the application has staked (if - any) + params: + description: params holds all the parameters of this module. type: object properties: - denom: - type: string - amount: + max_delegated_gateways: type: string - description: >- - Coin defines a token with a denomination and an amount. - + format: uint64 + description: >- + QueryParamsResponse is response type for the Query/Params RPC + method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + tags: + - Query + /poktroll.application.Msg/DelegateToGateway: + post: + operationId: PoktrollApplicationMsg_DelegateToGateway + responses: + '200': + description: A successful response. + schema: + type: object + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: body + in: body + required: true + schema: + type: object + properties: + app_address: + type: string + title: >- + The Bech32 address of the application using cosmos' + ScalarDescriptor to ensure deterministic deterministic + encoding using cosmos' ScalarDescriptor to ensure + deterministic deterministic encoding + gateway_address: + type: string + title: >- + The Bech32 address of the gateway the application wants to + delegate to using cosmos' ScalarDescriptor to ensure + deterministic deterministic encoding using cosmos' + ScalarDescriptor to ensure deterministic deterministic + encoding + tags: + - Msg + /poktroll.application.Msg/StakeApplication: + post: + operationId: PoktrollApplicationMsg_StakeApplication + responses: + '200': + description: A successful response. + schema: + type: object + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: body + in: body + required: true + schema: + type: object + properties: + address: + type: string + title: >- + The Bech32 address of the application using cosmos' + ScalarDescriptor to ensure deterministic encoding + stake: + title: >- + The total amount of uPOKT the application has staked. Must be + ≥ to the current amount that the application has staked (if + any) + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + NOTE: The amount field is an Int which implements the custom method @@ -16364,119 +16761,14 @@ paths: description: MsgUpdateParams is the Msg/UpdateParams request type. tags: - Msg - /pokt-network/poktroll/proof/claim: - get: - operationId: PoktrollProofQuery_AllClaims + /poktroll.proof.Msg/CreateClaim: + post: + operationId: PoktrollProofMsg_CreateClaim responses: '200': description: A successful response. schema: type: object - properties: - claims: - type: array - items: - type: object - properties: - supplier_address: - type: string - title: the address of the supplier that submitted this claim - session_header: - description: >- - The session header of the session that this claim is - for. - type: object - properties: - application_address: - type: string - title: >- - The Bech32 address of the application using cosmos' - ScalarDescriptor to ensure deterministic encoding - service: - title: The service this session is for - type: object - properties: - id: - type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a - session for a certain service but with some - additional configs that identify it? - name: - type: string - description: >- - (Optional) Semantic human readable name for the - service - title: >- - TODO_TECHDEBT: Name is currently unused but acts - as a reminder that an optional onchain - representation of the service is necessary - session_id: - type: string - description: A unique pseudoranom ID for this session - title: >- - NOTE: session_id can be derived from the above - values using on-chain but is included in the header - for convenience - session_start_block_height: - type: string - format: int64 - title: The height at which this session started - session_end_block_height: - type: string - format: int64 - description: >- - Note that`session_end_block_height` is a derivative - of (`start` + `num_blocks_per_session`) - - as goverened by on-chain params at the time of the - session start. - - It is stored as an additional field to simplofy - business logic in case - - the number of blocks_per_session changes during the - session. - - - The height at which this session ended, this is the - last block of the session - root_hash: - type: string - format: byte - description: Root hash returned from smt.SMST#Root(). - title: >- - Claim is the serialized object stored on-chain for claims - pending to be proven - pagination: - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: >- - PageResponse is to be embedded in gRPC response messages where - the - - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } default: description: An unexpected error response. schema: @@ -16496,159 +16788,92 @@ paths: type: string additionalProperties: {} parameters: - - name: pagination.key - description: |- - key is a value returned in PageResponse.next_key to begin - querying the next page most efficiently. Only one of offset or key - should be set. - in: query - required: false - type: string - format: byte - - name: pagination.offset - description: >- - offset is a numeric offset that can be used when key is unavailable. - - It is less efficient than using key. Only one of offset or key - should - - be set. - in: query - required: false - type: string - format: uint64 - - name: pagination.limit - description: >- - limit is the total number of results to be returned in the result - page. - - If left empty it will default to a value to be set by each app. - in: query - required: false - type: string - format: uint64 - - name: pagination.count_total - description: >- - count_total is set to true to indicate that the result set should - include - - a count of the total number of items available for pagination in - UIs. - - count_total is only respected when offset is used. It is ignored - when key - - is set. - in: query - required: false - type: boolean - - name: pagination.reverse - description: >- - reverse is set to true if results are to be returned in the - descending order. - - - Since: cosmos-sdk 0.43 - in: query - required: false - type: boolean - - name: supplier_address - in: query - required: false - type: string - - name: session_id - in: query - required: false - type: string - - name: session_end_height - in: query - required: false - type: string - format: uint64 - tags: - - Query - /pokt-network/poktroll/proof/claim/{session_id}/{supplier_address}: - get: - summary: Queries a list of Claim items. - operationId: PoktrollProofQuery_Claim - responses: - '200': - description: A successful response. + - name: body + in: body + required: true schema: type: object properties: - claim: + supplier_address: + type: string + session_header: type: object properties: - supplier_address: + application_address: type: string - title: the address of the supplier that submitted this claim - session_header: - description: The session header of the session that this claim is for. + title: >- + The Bech32 address of the application using cosmos' + ScalarDescriptor to ensure deterministic encoding + service: + title: The service this session is for type: object properties: - application_address: - type: string - title: >- - The Bech32 address of the application using cosmos' - ScalarDescriptor to ensure deterministic encoding - service: - title: The service this session is for - type: object - properties: - id: - type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a session - for a certain service but with some additional - configs that identify it? - name: - type: string - description: >- - (Optional) Semantic human readable name for the - service - title: >- - TODO_TECHDEBT: Name is currently unused but acts - as a reminder that an optional onchain - representation of the service is necessary - session_id: + id: type: string - description: A unique pseudoranom ID for this session + description: Unique identifier for the service title: >- - NOTE: session_id can be derived from the above values - using on-chain but is included in the header for - convenience - session_start_block_height: - type: string - format: int64 - title: The height at which this session started - session_end_block_height: + For example, what if we want to request a session for + a certain service but with some additional configs + that identify it? + name: type: string - format: int64 description: >- - Note that`session_end_block_height` is a derivative of - (`start` + `num_blocks_per_session`) + (Optional) Semantic human readable name for the + service + title: >- + TODO_TECHDEBT: Name is currently unused but acts as a + reminder that an optional onchain representation of + the service is necessary + session_id: + type: string + description: A unique pseudoranom ID for this session + title: >- + NOTE: session_id can be derived from the above values + using on-chain but is included in the header for + convenience + session_start_block_height: + type: string + format: int64 + title: The height at which this session started + session_end_block_height: + type: string + format: int64 + description: >- + Note that`session_end_block_height` is a derivative of + (`start` + `num_blocks_per_session`) - as goverened by on-chain params at the time of the - session start. + as goverened by on-chain params at the time of the session + start. - It is stored as an additional field to simplofy - business logic in case + It is stored as an additional field to simplofy business + logic in case - the number of blocks_per_session changes during the - session. + the number of blocks_per_session changes during the + session. - The height at which this session ended, this is the - last block of the session - root_hash: - type: string - format: byte - description: Root hash returned from smt.SMST#Root(). - title: >- - Claim is the serialized object stored on-chain for claims - pending to be proven + The height at which this session ended, this is the last + block of the session + description: >- + SessionHeader is a lightweight header for a session that can + be passed around. + + It is the minimal amount of data required to hydrate & + retrieve all data relevant to the session. + root_hash: + type: string + format: byte + title: root returned from smt.SMST#Root() + tags: + - Msg + /poktroll.proof.Msg/SubmitProof: + post: + operationId: PoktrollProofMsg_SubmitProof + responses: + '200': + description: A successful response. + schema: + type: object default: description: An unexpected error response. schema: @@ -16668,20 +16893,87 @@ paths: type: string additionalProperties: {} parameters: - - name: session_id - in: path - required: true - type: string - - name: supplier_address - in: path + - name: body + in: body required: true - type: string + schema: + type: object + properties: + supplier_address: + type: string + session_header: + type: object + properties: + application_address: + type: string + title: >- + The Bech32 address of the application using cosmos' + ScalarDescriptor to ensure deterministic encoding + service: + title: The service this session is for + type: object + properties: + id: + type: string + description: Unique identifier for the service + title: >- + For example, what if we want to request a session for + a certain service but with some additional configs + that identify it? + name: + type: string + description: >- + (Optional) Semantic human readable name for the + service + title: >- + TODO_TECHDEBT: Name is currently unused but acts as a + reminder that an optional onchain representation of + the service is necessary + session_id: + type: string + description: A unique pseudoranom ID for this session + title: >- + NOTE: session_id can be derived from the above values + using on-chain but is included in the header for + convenience + session_start_block_height: + type: string + format: int64 + title: The height at which this session started + session_end_block_height: + type: string + format: int64 + description: >- + Note that`session_end_block_height` is a derivative of + (`start` + `num_blocks_per_session`) + + as goverened by on-chain params at the time of the session + start. + + It is stored as an additional field to simplofy business + logic in case + + the number of blocks_per_session changes during the + session. + + + The height at which this session ended, this is the last + block of the session + description: >- + SessionHeader is a lightweight header for a session that can + be passed around. + + It is the minimal amount of data required to hydrate & + retrieve all data relevant to the session. + proof: + type: string + format: byte + title: serialized version of *smt.SparseMerkleClosestProof tags: - - Query - /pokt-network/poktroll/proof/params: - get: - summary: Parameters queries the parameters of the module. - operationId: PoktrollProofQuery_Params + - Msg + /poktroll.proof.Msg/UpdateParam: + post: + operationId: PoktrollProofMsg_UpdateParam responses: '200': description: A successful response. @@ -16689,7 +16981,6 @@ paths: type: object properties: params: - description: params holds all the parameters of this module. type: object properties: min_relay_difficulty_bits: @@ -16698,9 +16989,12 @@ paths: description: >- The minimum difficulty in bits for a relay to be included in a Merkle proof. + description: Params defines the parameters for the module. description: >- - QueryParamsResponse is response type for the Query/Params RPC - method. + MsgUpdateParamResponse defines the response structure for + executing a + + MsgUpdateParam message after a single param update. default: description: An unexpected error response. schema: @@ -16719,119 +17013,57 @@ paths: '@type': type: string additionalProperties: {} - tags: - - Query - /pokt-network/poktroll/proof/proof: - get: - operationId: PoktrollProofQuery_AllProofs - responses: - '200': - description: A successful response. + parameters: + - name: body + description: >- + MsgUpdateParam is the Msg/UpdateParam request type to update a + single param. + in: body + required: true schema: type: object properties: - proofs: - type: array - items: - type: object - properties: - supplier_address: - type: string - session_header: - description: >- - The session header of the session that this claim is - for. - type: object - properties: - application_address: - type: string - title: >- - The Bech32 address of the application using cosmos' - ScalarDescriptor to ensure deterministic encoding - service: - title: The service this session is for - type: object - properties: - id: - type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a - session for a certain service but with some - additional configs that identify it? - name: - type: string - description: >- - (Optional) Semantic human readable name for the - service - title: >- - TODO_TECHDEBT: Name is currently unused but acts - as a reminder that an optional onchain - representation of the service is necessary - session_id: - type: string - description: A unique pseudoranom ID for this session - title: >- - NOTE: session_id can be derived from the above - values using on-chain but is included in the header - for convenience - session_start_block_height: - type: string - format: int64 - title: The height at which this session started - session_end_block_height: - type: string - format: int64 - description: >- - Note that`session_end_block_height` is a derivative - of (`start` + `num_blocks_per_session`) - - as goverened by on-chain params at the time of the - session start. - - It is stored as an additional field to simplofy - business logic in case - - the number of blocks_per_session changes during the - session. - - - The height at which this session ended, this is the - last block of the session - closest_merkle_proof: - type: string - format: byte - description: >- - The serialized SMST proof from the `#ClosestProof()` - method. - pagination: - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise + authority: + type: string description: >- - PageResponse is to be embedded in gRPC response messages where - the + authority is the address that controls the module (defaults to + x/gov unless overwritten). + name: + type: string + title: >- + The (name, as_type) tuple must match the corresponding name + and type as - corresponding request message has used PageRequest. + specified in the `Params`` message in `proof/params.proto.` + as_string: + type: string + as_int64: + type: string + format: int64 + as_bytes: + type: string + format: byte + description: >- + MsgUpdateParam is the Msg/UpdateParam request type to update a + single param. + tags: + - Msg + /poktroll.proof.Msg/UpdateParams: + post: + summary: |- + UpdateParams defines a (governance) operation for updating the module + parameters. The authority defaults to the x/gov module account. + operationId: PoktrollProofMsg_UpdateParams + responses: + '200': + description: A successful response. + schema: + type: object + description: >- + MsgUpdateParamsResponse defines the response structure for + executing a - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } + MsgUpdateParams message. default: description: An unexpected error response. schema: @@ -16851,194 +17083,43 @@ paths: type: string additionalProperties: {} parameters: - - name: pagination.key - description: |- - key is a value returned in PageResponse.next_key to begin - querying the next page most efficiently. Only one of offset or key - should be set. - in: query - required: false - type: string - format: byte - - name: pagination.offset - description: >- - offset is a numeric offset that can be used when key is unavailable. - - It is less efficient than using key. Only one of offset or key - should - - be set. - in: query - required: false - type: string - format: uint64 - - name: pagination.limit - description: >- - limit is the total number of results to be returned in the result - page. - - If left empty it will default to a value to be set by each app. - in: query - required: false - type: string - format: uint64 - - name: pagination.count_total - description: >- - count_total is set to true to indicate that the result set should - include - - a count of the total number of items available for pagination in - UIs. - - count_total is only respected when offset is used. It is ignored - when key - - is set. - in: query - required: false - type: boolean - - name: pagination.reverse + - name: body description: >- - reverse is set to true if results are to be returned in the - descending order. - - - Since: cosmos-sdk 0.43 - in: query - required: false - type: boolean - - name: supplier_address - in: query - required: false - type: string - - name: session_id - in: query - required: false - type: string - - name: session_end_height - in: query - required: false - type: string - format: uint64 - tags: - - Query - /pokt-network/poktroll/proof/proof/{session_id}/{supplier_address}: - get: - summary: Queries a list of Proof items. - operationId: PoktrollProofQuery_Proof - responses: - '200': - description: A successful response. + MsgUpdateParams is the Msg/UpdateParams request type to update all + params at once. + in: body + required: true schema: type: object properties: - proof: + authority: + type: string + description: >- + authority is the address that controls the module (defaults to + x/gov unless overwritten). + params: type: object properties: - supplier_address: - type: string - session_header: - description: The session header of the session that this claim is for. - type: object - properties: - application_address: - type: string - title: >- - The Bech32 address of the application using cosmos' - ScalarDescriptor to ensure deterministic encoding - service: - title: The service this session is for - type: object - properties: - id: - type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a session - for a certain service but with some additional - configs that identify it? - name: - type: string - description: >- - (Optional) Semantic human readable name for the - service - title: >- - TODO_TECHDEBT: Name is currently unused but acts - as a reminder that an optional onchain - representation of the service is necessary - session_id: - type: string - description: A unique pseudoranom ID for this session - title: >- - NOTE: session_id can be derived from the above values - using on-chain but is included in the header for - convenience - session_start_block_height: - type: string - format: int64 - title: The height at which this session started - session_end_block_height: - type: string - format: int64 - description: >- - Note that`session_end_block_height` is a derivative of - (`start` + `num_blocks_per_session`) - - as goverened by on-chain params at the time of the - session start. - - It is stored as an additional field to simplofy - business logic in case - - the number of blocks_per_session changes during the - session. - - - The height at which this session ended, this is the - last block of the session - closest_merkle_proof: + min_relay_difficulty_bits: type: string - format: byte + format: uint64 description: >- - The serialized SMST proof from the `#ClosestProof()` - method. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: session_id - in: path - required: true - type: string - - name: supplier_address - in: path - required: true - type: string - tags: - - Query - /poktroll.proof.Msg/CreateClaim: - post: - operationId: PoktrollProofMsg_CreateClaim - responses: - '200': - description: A successful response. - schema: - type: object + The minimum difficulty in bits for a relay to be included + in a Merkle proof. + description: Params defines the parameters for the module. + description: >- + MsgUpdateParams is the Msg/UpdateParams request type to update all + params at once. + tags: + - Msg + /poktroll.service.Msg/AddService: + post: + operationId: PoktrollServiceMsg_AddService + responses: + '200': + description: A successful response. + schema: + type: object default: description: An unexpected error response. schema: @@ -17059,91 +17140,81 @@ paths: additionalProperties: {} parameters: - name: body + description: >- + MsgAddService defines a message for adding a new message to the + network. + + Services can be added by any actor in the network making them truly + + permissionless. + + TODO_DOCUMENT(@h5law): This is a key function in making services + + permissionless, document it's usage and design - in docusaurus + covering how + + the entire process works. in: body required: true schema: type: object properties: - supplier_address: + address: type: string - session_header: + title: >- + The Bech32 address of the service supplier using cosmos' + ScalarDescriptor + service: + title: The Service for which the supplier is adding to the network type: object properties: - application_address: + id: type: string + description: Unique identifier for the service title: >- - The Bech32 address of the application using cosmos' - ScalarDescriptor to ensure deterministic encoding - service: - title: The service this session is for - type: object - properties: - id: - type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a session for - a certain service but with some additional configs - that identify it? - name: - type: string - description: >- - (Optional) Semantic human readable name for the - service - title: >- - TODO_TECHDEBT: Name is currently unused but acts as a - reminder that an optional onchain representation of - the service is necessary - session_id: + For example, what if we want to request a session for a + certain service but with some additional configs that + identify it? + name: type: string - description: A unique pseudoranom ID for this session + description: (Optional) Semantic human readable name for the service title: >- - NOTE: session_id can be derived from the above values - using on-chain but is included in the header for - convenience - session_start_block_height: - type: string - format: int64 - title: The height at which this session started - session_end_block_height: - type: string - format: int64 - description: >- - Note that`session_end_block_height` is a derivative of - (`start` + `num_blocks_per_session`) - - as goverened by on-chain params at the time of the session - start. + TODO_TECHDEBT: Name is currently unused but acts as a + reminder that an optional onchain representation of the + service is necessary + description: >- + MsgAddService defines a message for adding a new message to the + network. - It is stored as an additional field to simplofy business - logic in case + Services can be added by any actor in the network making them + truly - the number of blocks_per_session changes during the - session. + permissionless. + TODO_DOCUMENT(@h5law): This is a key function in making services - The height at which this session ended, this is the last - block of the session - description: >- - SessionHeader is a lightweight header for a session that can - be passed around. + permissionless, document it's usage and design - in docusaurus + covering how - It is the minimal amount of data required to hydrate & - retrieve all data relevant to the session. - root_hash: - type: string - format: byte - title: root returned from smt.SMST#Root() + the entire process works. tags: - Msg - /poktroll.proof.Msg/SubmitProof: + /poktroll.service.Msg/UpdateParams: post: - operationId: PoktrollProofMsg_SubmitProof + summary: |- + UpdateParams defines a (governance) operation for updating the module + parameters. The authority defaults to the x/gov module account. + operationId: PoktrollServiceMsg_UpdateParams responses: '200': description: A successful response. schema: type: object + description: >- + MsgUpdateParamsResponse defines the response structure for + executing a + + MsgUpdateParams message. default: description: An unexpected error response. schema: @@ -17164,86 +17235,413 @@ paths: additionalProperties: {} parameters: - name: body + description: MsgUpdateParams is the Msg/UpdateParams request type. in: body required: true schema: type: object properties: - supplier_address: + authority: type: string - session_header: + description: >- + authority is the address that controls the module (defaults to + x/gov unless overwritten). + params: + description: |- + params defines the x/service parameters to update. + NOTE: All parameters must be supplied. type: object properties: - application_address: + add_service_fee: type: string - title: >- - The Bech32 address of the application using cosmos' - ScalarDescriptor to ensure deterministic encoding - service: - title: The service this session is for + format: uint64 + description: |- + The amount of uPOKT required to add a new service. + This will be deducted from the signer's account balance, + and transferred to the pocket network foundation. + description: MsgUpdateParams is the Msg/UpdateParams request type. + tags: + - Msg + /pokt-network/poktroll/session/get_session: + get: + summary: Queries the session given app_address, service and block_height. + operationId: PoktrollSessionQuery_GetSession + responses: + '200': + description: A successful response. + schema: + type: object + properties: + session: + type: object + properties: + header: + title: The header of the session containing lightweight data type: object properties: - id: + application_address: type: string - description: Unique identifier for the service title: >- - For example, what if we want to request a session for - a certain service but with some additional configs - that identify it? - name: + The Bech32 address of the application using cosmos' + ScalarDescriptor to ensure deterministic encoding + service: + title: The service this session is for + type: object + properties: + id: + type: string + description: Unique identifier for the service + title: >- + For example, what if we want to request a session + for a certain service but with some additional + configs that identify it? + name: + type: string + description: >- + (Optional) Semantic human readable name for the + service + title: >- + TODO_TECHDEBT: Name is currently unused but acts + as a reminder that an optional onchain + representation of the service is necessary + session_id: type: string - description: >- - (Optional) Semantic human readable name for the - service + description: A unique pseudoranom ID for this session title: >- - TODO_TECHDEBT: Name is currently unused but acts as a - reminder that an optional onchain representation of - the service is necessary + NOTE: session_id can be derived from the above values + using on-chain but is included in the header for + convenience + session_start_block_height: + type: string + format: int64 + title: The height at which this session started + session_end_block_height: + type: string + format: int64 + description: >- + Note that`session_end_block_height` is a derivative of + (`start` + `num_blocks_per_session`) + + as goverened by on-chain params at the time of the + session start. + + It is stored as an additional field to simplofy + business logic in case + + the number of blocks_per_session changes during the + session. + + + The height at which this session ended, this is the + last block of the session + description: >- + SessionHeader is a lightweight header for a session that + can be passed around. + + It is the minimal amount of data required to hydrate & + retrieve all data relevant to the session. session_id: type: string - description: A unique pseudoranom ID for this session - title: >- - NOTE: session_id can be derived from the above values - using on-chain but is included in the header for - convenience - session_start_block_height: + title: A unique pseudoranom ID for this session + session_number: type: string format: int64 - title: The height at which this session started - session_end_block_height: + title: The session number since genesis + num_blocks_per_session: type: string format: int64 - description: >- - Note that`session_end_block_height` is a derivative of - (`start` + `num_blocks_per_session`) - - as goverened by on-chain params at the time of the session - start. - - It is stored as an additional field to simplofy business - logic in case + title: The number of blocks per session when this session started + application: + title: A fully hydrated application object this session is for + type: object + properties: + address: + type: string + title: >- + The Bech32 address of the application using cosmos' + ScalarDescriptor to ensure deterministic encoding + stake: + title: The total amount of uPOKT the application has staked + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. - the number of blocks_per_session changes during the - session. + NOTE: The amount field is an Int which implements the + custom method - The height at which this session ended, this is the last - block of the session + signatures required by gogoproto. + service_configs: + type: array + items: + type: object + properties: + service: + title: >- + The Service for which the application is + configured + type: object + properties: + id: + type: string + description: Unique identifier for the service + title: >- + For example, what if we want to request a + session for a certain service but with some + additional configs that identify it? + name: + type: string + description: >- + (Optional) Semantic human readable name for + the service + title: >- + TODO_TECHDEBT: Name is currently unused but + acts as a reminder that an optional onchain + representation of the service is necessary + title: >- + ApplicationServiceConfig holds the service + configuration the application stakes for + title: >- + The list of services this appliccation is configured + to request service for + delegatee_gateway_addresses: + type: array + items: + type: string + description: >- + TODO_TECHDEBT: Rename `delegatee_gateway_addresses` to + `gateway_addresses_delegated_to`. + + Ensure to rename all relevant configs, comments, + variables, function names, etc as well. + + + The Bech32 encoded addresses for all delegatee + Gateways, in a non-nullable slice + pending_undelegations: + type: object + additionalProperties: + type: object + properties: + gateway_addresses: + type: array + items: + type: string + description: >- + UndelegatingGatewayList is used as the Value of + `pending_undelegations`. + + It is required to store a repeated list of strings + as a map value. + description: >- + A map from sessionEndHeights to a list of Gateways. + + The key is the height of the last block of the session + during which the + + respective undelegation was committed. + + The value is a list of gateways being undelegated + from. + + TODO_DOCUMENT(@red-0ne): Need to document the flow + from this comment + + so its clear to everyone why this is necessary; + https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. + suppliers: + type: array + items: + type: object + properties: + address: + type: string + title: >- + The Bech32 address of the supplier using cosmos' + ScalarDescriptor to ensure deterministic encoding + stake: + title: The total amount of uPOKT the supplier has staked + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements + the custom method + + signatures required by gogoproto. + services: + type: array + items: + type: object + properties: + service: + title: >- + The Service for which the supplier is + configured + type: object + properties: + id: + type: string + description: Unique identifier for the service + title: >- + For example, what if we want to request a + session for a certain service but with + some additional configs that identify it? + name: + type: string + description: >- + (Optional) Semantic human readable name + for the service + title: >- + TODO_TECHDEBT: Name is currently unused + but acts as a reminder that an optional + onchain representation of the service is + necessary + endpoints: + type: array + items: + type: object + properties: + url: + type: string + title: URL of the endpoint + rpc_type: + title: Type of RPC exposed on the url above + type: string + enum: + - UNKNOWN_RPC + - GRPC + - WEBSOCKET + - JSON_RPC + - REST + default: UNKNOWN_RPC + description: |- + - UNKNOWN_RPC: Undefined RPC type + - GRPC: gRPC + - WEBSOCKET: WebSocket + - JSON_RPC: JSON-RPC + - REST: REST + configs: + type: array + items: + type: object + properties: + key: + title: Config option key + type: string + enum: + - UNKNOWN_CONFIG + - TIMEOUT + default: UNKNOWN_CONFIG + description: >- + Enum to define configuration options + + TODO_RESEARCH: Should these be configs, + SLAs or something else? There will be + more discussion once we get closer to + implementing on-chain QoS. + + - UNKNOWN_CONFIG: Undefined config option + - TIMEOUT: Timeout setting + value: + type: string + title: Config option value + title: >- + Key-value wrapper for config options, as + proto maps can't be keyed by enums + title: >- + Additional configuration options for the + endpoint + title: >- + SupplierEndpoint message to hold service + configuration details + title: List of endpoints for the service + title: >- + SupplierServiceConfig holds the service + configuration the supplier stakes for + title: The service configs this supplier can support + description: >- + Supplier is the type defining the actor in Pocket + Network that provides RPC services. + title: >- + A fully hydrated set of servicers that are serving the + application description: >- - SessionHeader is a lightweight header for a session that can - be passed around. + Session is a fully hydrated session object that contains all + the information for the Session - It is the minimal amount of data required to hydrate & - retrieve all data relevant to the session. - proof: + and its parcipants. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: type: string - format: byte - title: serialized version of *smt.SparseMerkleClosestProof + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: application_address + description: >- + The Bech32 address of the application using cosmos' ScalarDescriptor + to ensure deterministic encoding + in: query + required: false + type: string + - name: service.id + description: >- + For example, what if we want to request a session for a certain + service but with some additional configs that identify it? + + + Unique identifier for the service + in: query + required: false + type: string + - name: service.name + description: >- + TODO_TECHDEBT: Name is currently unused but acts as a reminder that + an optional onchain representation of the service is necessary + + + (Optional) Semantic human readable name for the service + in: query + required: false + type: string + - name: block_height + description: The block height to query the session for + in: query + required: false + type: string + format: int64 tags: - - Msg - /poktroll.proof.Msg/UpdateParam: - post: - operationId: PoktrollProofMsg_UpdateParam + - Query + /pokt-network/poktroll/session/params: + get: + summary: Parameters queries the parameters of the module. + operationId: PoktrollSessionQuery_Params responses: '200': description: A successful response. @@ -17251,20 +17649,15 @@ paths: type: object properties: params: + description: params holds all the parameters of this module. type: object properties: - min_relay_difficulty_bits: + num_blocks_per_session: type: string format: uint64 - description: >- - The minimum difficulty in bits for a relay to be included - in a Merkle proof. - description: Params defines the parameters for the module. description: >- - MsgUpdateParamResponse defines the response structure for - executing a - - MsgUpdateParam message after a single param update. + QueryParamsResponse is response type for the Query/Params RPC + method. default: description: An unexpected error response. schema: @@ -17283,47 +17676,14 @@ paths: '@type': type: string additionalProperties: {} - parameters: - - name: body - description: >- - MsgUpdateParam is the Msg/UpdateParam request type to update a - single param. - in: body - required: true - schema: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to - x/gov unless overwritten). - name: - type: string - title: >- - The (name, as_type) tuple must match the corresponding name - and type as - - specified in the `Params`` message in `proof/params.proto.` - as_string: - type: string - as_int64: - type: string - format: int64 - as_bytes: - type: string - format: byte - description: >- - MsgUpdateParam is the Msg/UpdateParam request type to update a - single param. tags: - - Msg - /poktroll.proof.Msg/UpdateParams: + - Query + /poktroll.session.Msg/UpdateParams: post: summary: |- UpdateParams defines a (governance) operation for updating the module parameters. The authority defaults to the x/gov module account. - operationId: PoktrollProofMsg_UpdateParams + operationId: PoktrollSessionMsg_UpdateParams responses: '200': description: A successful response. @@ -17354,9 +17714,7 @@ paths: additionalProperties: {} parameters: - name: body - description: >- - MsgUpdateParams is the Msg/UpdateParams request type to update all - params at once. + description: MsgUpdateParams is the Msg/UpdateParams request type. in: body required: true schema: @@ -17368,28 +17726,69 @@ paths: authority is the address that controls the module (defaults to x/gov unless overwritten). params: + description: |- + params defines the x/session parameters to update. + NOTE: All parameters must be supplied. type: object properties: - min_relay_difficulty_bits: + num_blocks_per_session: type: string format: uint64 - description: >- - The minimum difficulty in bits for a relay to be included - in a Merkle proof. - description: Params defines the parameters for the module. - description: >- - MsgUpdateParams is the Msg/UpdateParams request type to update all - params at once. + description: MsgUpdateParams is the Msg/UpdateParams request type. tags: - Msg - /poktroll.service.Msg/AddService: + /pokt-network/poktroll/shared/params: + get: + summary: Parameters queries the parameters of the module. + operationId: PoktrollSharedQuery_Params + responses: + '200': + description: A successful response. + schema: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + description: >- + QueryParamsResponse is response type for the Query/Params RPC + method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + tags: + - Query + /poktroll.shared.Msg/UpdateParams: post: - operationId: PoktrollServiceMsg_AddService + summary: |- + UpdateParams defines a (governance) operation for updating the module + parameters. The authority defaults to the x/gov module account. + operationId: PoktrollSharedMsg_UpdateParams responses: '200': description: A successful response. schema: type: object + description: >- + MsgUpdateParamsResponse defines the response structure for + executing a + + MsgUpdateParams message. default: description: An unexpected error response. schema: @@ -17410,102 +17809,7 @@ paths: additionalProperties: {} parameters: - name: body - description: >- - MsgAddService defines a message for adding a new message to the - network. - - Services can be added by any actor in the network making them truly - - permissionless. - - TODO_DOCUMENT(@h5law): This is a key function in making services - - permissionless, document it's usage and design - in docusaurus - covering how - - the entire process works. - in: body - required: true - schema: - type: object - properties: - address: - type: string - title: >- - The Bech32 address of the service supplier using cosmos' - ScalarDescriptor - service: - title: The Service for which the supplier is adding to the network - type: object - properties: - id: - type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a session for a - certain service but with some additional configs that - identify it? - name: - type: string - description: (Optional) Semantic human readable name for the service - title: >- - TODO_TECHDEBT: Name is currently unused but acts as a - reminder that an optional onchain representation of the - service is necessary - description: >- - MsgAddService defines a message for adding a new message to the - network. - - Services can be added by any actor in the network making them - truly - - permissionless. - - TODO_DOCUMENT(@h5law): This is a key function in making services - - permissionless, document it's usage and design - in docusaurus - covering how - - the entire process works. - tags: - - Msg - /poktroll.service.Msg/UpdateParams: - post: - summary: |- - UpdateParams defines a (governance) operation for updating the module - parameters. The authority defaults to the x/gov module account. - operationId: PoktrollServiceMsg_UpdateParams - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgUpdateParamsResponse defines the response structure for - executing a - - MsgUpdateParams message. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: MsgUpdateParams is the Msg/UpdateParams request type. + description: MsgUpdateParams is the Msg/UpdateParams request type. in: body required: true schema: @@ -17518,70 +17822,8 @@ paths: x/gov unless overwritten). params: description: |- - params defines the x/service parameters to update. - NOTE: All parameters must be supplied. - type: object - properties: - add_service_fee: - type: string - format: uint64 - description: |- - The amount of uPOKT required to add a new service. - This will be deducted from the signer's account balance, - and transferred to the pocket network foundation. - description: MsgUpdateParams is the Msg/UpdateParams request type. - tags: - - Msg - /poktroll.session.Msg/UpdateParams: - post: - summary: |- - UpdateParams defines a (governance) operation for updating the module - parameters. The authority defaults to the x/gov module account. - operationId: PoktrollSessionMsg_UpdateParams - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgUpdateParamsResponse defines the response structure for - executing a + params defines the module parameters to update. - MsgUpdateParams message. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: MsgUpdateParams is the Msg/UpdateParams request type. - in: body - required: true - schema: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to - x/gov unless overwritten). - params: - description: |- - params defines the x/session parameters to update. NOTE: All parameters must be supplied. type: object description: MsgUpdateParams is the Msg/UpdateParams request type. @@ -17832,52 +18074,6 @@ paths: description: MsgUpdateParams is the Msg/UpdateParams request type. tags: - Msg - /pokt-network/poktroll/tokenomics/params: - get: - summary: Parameters queries the parameters of the module. - operationId: PoktrollTokenomicsQuery_Params - responses: - '200': - description: A successful response. - schema: - type: object - properties: - params: - description: params holds all the parameters of this module. - type: object - properties: - compute_units_to_tokens_multiplier: - type: string - format: uint64 - description: >- - The amount of upokt that a compute unit should translate - to when settling a session. - - TODO_DOCUMENT(@Olshansk): Make sure to document the units - of this parameter (or the map) once finalized. - description: >- - QueryParamsResponse is response type for the Query/Params RPC - method. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - tags: - - Query /poktroll.tokenomics.Msg/UpdateParam: post: operationId: PoktrollTokenomicsMsg_UpdateParam @@ -24574,36 +24770,93 @@ definitions: description: |- Version defines the versioning scheme used to negotiate the IBC verison in the connection handshake. - poktroll.application.MsgDelegateToGateway: + cosmos.base.query.v1beta1.PageRequest: type: object properties: - app_address: + key: type: string - title: >- - The Bech32 address of the application using cosmos' ScalarDescriptor - to ensure deterministic deterministic encoding using cosmos' - ScalarDescriptor to ensure deterministic deterministic encoding - gateway_address: + format: byte + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + offset: type: string - title: >- - The Bech32 address of the gateway the application wants to delegate to - using cosmos' ScalarDescriptor to ensure deterministic deterministic - encoding using cosmos' ScalarDescriptor to ensure deterministic - deterministic encoding - poktroll.application.MsgDelegateToGatewayResponse: - type: object - poktroll.application.MsgStakeApplication: + format: uint64 + description: |- + offset is a numeric offset that can be used when key is unavailable. + It is less efficient than using key. Only one of offset or key should + be set. + limit: + type: string + format: uint64 + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + count_total: + type: boolean + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in UIs. + + count_total is only respected when offset is used. It is ignored when + key + + is set. + reverse: + type: boolean + description: >- + reverse is set to true if results are to be returned in the descending + order. + + + Since: cosmos-sdk 0.43 + description: |- + message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } + title: |- + PageRequest is to be embedded in gRPC request messages for efficient + pagination. Ex: + cosmos.base.query.v1beta1.PageResponse: type: object properties: - address: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: |- + total is total number of results available if PageRequest.count_total + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + poktroll.application.Application: + type: object + properties: + address: type: string title: >- The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic encoding stake: - title: >- - The total amount of uPOKT the application has staked. Must be ≥ to the - current amount that the application has staked (if any) + title: The total amount of uPOKT the application has staked type: object properties: denom: @@ -24615,7 +24868,7 @@ definitions: NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. - services: + service_configs: type: array items: type: object @@ -24641,64 +24894,318 @@ definitions: title: >- ApplicationServiceConfig holds the service configuration the application stakes for - title: The list of services this application is staked to request service for - poktroll.application.MsgStakeApplicationResponse: - type: object - poktroll.application.MsgUndelegateFromGateway: + title: >- + The list of services this appliccation is configured to request + service for + delegatee_gateway_addresses: + type: array + items: + type: string + description: >- + TODO_TECHDEBT: Rename `delegatee_gateway_addresses` to + `gateway_addresses_delegated_to`. + + Ensure to rename all relevant configs, comments, variables, function + names, etc as well. + + + The Bech32 encoded addresses for all delegatee Gateways, in a + non-nullable slice + pending_undelegations: + type: object + additionalProperties: + type: object + properties: + gateway_addresses: + type: array + items: + type: string + description: >- + UndelegatingGatewayList is used as the Value of + `pending_undelegations`. + + It is required to store a repeated list of strings as a map value. + description: >- + A map from sessionEndHeights to a list of Gateways. + + The key is the height of the last block of the session during which + the + + respective undelegation was committed. + + The value is a list of gateways being undelegated from. + + TODO_DOCUMENT(@red-0ne): Need to document the flow from this comment + + so its clear to everyone why this is necessary; + https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. + title: >- + Application defines the type used to store an on-chain definition and + state for an application + poktroll.application.Params: type: object properties: - app_address: - type: string - title: >- - The Bech32 address of the application using cosmos' ScalarDescriptor - to ensure deterministic deterministic encoding using cosmos' - ScalarDescriptor to ensure deterministic deterministic encoding - gateway_address: + max_delegated_gateways: type: string - title: >- - The Bech32 address of the gateway the application wants to undelegate - from using cosmos' ScalarDescriptor to ensure deterministic - deterministic encoding using cosmos' ScalarDescriptor to ensure - deterministic deterministic encoding - poktroll.application.MsgUndelegateFromGatewayResponse: - type: object - poktroll.application.MsgUnstakeApplication: + format: uint64 + description: Params defines the parameters for the module. + poktroll.application.QueryAllApplicationsResponse: type: object properties: - address: - type: string - poktroll.application.MsgUnstakeApplicationResponse: + applications: + type: array + items: + type: object + properties: + address: + type: string + title: >- + The Bech32 address of the application using cosmos' + ScalarDescriptor to ensure deterministic encoding + stake: + title: The total amount of uPOKT the application has staked + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + service_configs: + type: array + items: + type: object + properties: + service: + title: The Service for which the application is configured + type: object + properties: + id: + type: string + description: Unique identifier for the service + title: >- + For example, what if we want to request a session for + a certain service but with some additional configs + that identify it? + name: + type: string + description: >- + (Optional) Semantic human readable name for the + service + title: >- + TODO_TECHDEBT: Name is currently unused but acts as a + reminder that an optional onchain representation of + the service is necessary + title: >- + ApplicationServiceConfig holds the service configuration the + application stakes for + title: >- + The list of services this appliccation is configured to request + service for + delegatee_gateway_addresses: + type: array + items: + type: string + description: >- + TODO_TECHDEBT: Rename `delegatee_gateway_addresses` to + `gateway_addresses_delegated_to`. + + Ensure to rename all relevant configs, comments, variables, + function names, etc as well. + + + The Bech32 encoded addresses for all delegatee Gateways, in a + non-nullable slice + pending_undelegations: + type: object + additionalProperties: + type: object + properties: + gateway_addresses: + type: array + items: + type: string + description: >- + UndelegatingGatewayList is used as the Value of + `pending_undelegations`. + + It is required to store a repeated list of strings as a map + value. + description: >- + A map from sessionEndHeights to a list of Gateways. + + The key is the height of the last block of the session during + which the + + respective undelegation was committed. + + The value is a list of gateways being undelegated from. + + TODO_DOCUMENT(@red-0ne): Need to document the flow from this + comment + + so its clear to everyone why this is necessary; + https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. + title: >- + Application defines the type used to store an on-chain definition + and state for an application + pagination: + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + poktroll.application.QueryGetApplicationResponse: type: object - poktroll.application.MsgUpdateParams: + properties: + application: + type: object + properties: + address: + type: string + title: >- + The Bech32 address of the application using cosmos' + ScalarDescriptor to ensure deterministic encoding + stake: + title: The total amount of uPOKT the application has staked + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + service_configs: + type: array + items: + type: object + properties: + service: + title: The Service for which the application is configured + type: object + properties: + id: + type: string + description: Unique identifier for the service + title: >- + For example, what if we want to request a session for a + certain service but with some additional configs that + identify it? + name: + type: string + description: (Optional) Semantic human readable name for the service + title: >- + TODO_TECHDEBT: Name is currently unused but acts as a + reminder that an optional onchain representation of the + service is necessary + title: >- + ApplicationServiceConfig holds the service configuration the + application stakes for + title: >- + The list of services this appliccation is configured to request + service for + delegatee_gateway_addresses: + type: array + items: + type: string + description: >- + TODO_TECHDEBT: Rename `delegatee_gateway_addresses` to + `gateway_addresses_delegated_to`. + + Ensure to rename all relevant configs, comments, variables, + function names, etc as well. + + + The Bech32 encoded addresses for all delegatee Gateways, in a + non-nullable slice + pending_undelegations: + type: object + additionalProperties: + type: object + properties: + gateway_addresses: + type: array + items: + type: string + description: >- + UndelegatingGatewayList is used as the Value of + `pending_undelegations`. + + It is required to store a repeated list of strings as a map + value. + description: >- + A map from sessionEndHeights to a list of Gateways. + + The key is the height of the last block of the session during + which the + + respective undelegation was committed. + + The value is a list of gateways being undelegated from. + + TODO_DOCUMENT(@red-0ne): Need to document the flow from this + comment + + so its clear to everyone why this is necessary; + https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. + title: >- + Application defines the type used to store an on-chain definition and + state for an application + poktroll.application.QueryParamsResponse: type: object properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to x/gov - unless overwritten). params: - description: |- - params defines the x/application parameters to update. - NOTE: All parameters must be supplied. + description: params holds all the parameters of this module. type: object properties: max_delegated_gateways: type: string format: uint64 - description: MsgUpdateParams is the Msg/UpdateParams request type. - poktroll.application.MsgUpdateParamsResponse: - type: object - description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. - poktroll.application.Params: + description: QueryParamsResponse is response type for the Query/Params RPC method. + poktroll.application.UndelegatingGatewayList: type: object properties: - max_delegated_gateways: - type: string - format: uint64 - description: Params defines the parameters for the module. + gateway_addresses: + type: array + items: + type: string + description: |- + UndelegatingGatewayList is used as the Value of `pending_undelegations`. + It is required to store a repeated list of strings as a map value. poktroll.shared.ApplicationServiceConfig: type: object properties: @@ -24740,10 +25247,128 @@ definitions: title: >- Service message to encapsulate unique and semantic identifiers for a service on the network - poktroll.gateway.MsgStakeGateway: + poktroll.application.MsgDelegateToGateway: type: object properties: - address: + app_address: + type: string + title: >- + The Bech32 address of the application using cosmos' ScalarDescriptor + to ensure deterministic deterministic encoding using cosmos' + ScalarDescriptor to ensure deterministic deterministic encoding + gateway_address: + type: string + title: >- + The Bech32 address of the gateway the application wants to delegate to + using cosmos' ScalarDescriptor to ensure deterministic deterministic + encoding using cosmos' ScalarDescriptor to ensure deterministic + deterministic encoding + poktroll.application.MsgDelegateToGatewayResponse: + type: object + poktroll.application.MsgStakeApplication: + type: object + properties: + address: + type: string + title: >- + The Bech32 address of the application using cosmos' ScalarDescriptor + to ensure deterministic encoding + stake: + title: >- + The total amount of uPOKT the application has staked. Must be ≥ to the + current amount that the application has staked (if any) + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + services: + type: array + items: + type: object + properties: + service: + title: The Service for which the application is configured + type: object + properties: + id: + type: string + description: Unique identifier for the service + title: >- + For example, what if we want to request a session for a + certain service but with some additional configs that + identify it? + name: + type: string + description: (Optional) Semantic human readable name for the service + title: >- + TODO_TECHDEBT: Name is currently unused but acts as a + reminder that an optional onchain representation of the + service is necessary + title: >- + ApplicationServiceConfig holds the service configuration the + application stakes for + title: The list of services this application is staked to request service for + poktroll.application.MsgStakeApplicationResponse: + type: object + poktroll.application.MsgUndelegateFromGateway: + type: object + properties: + app_address: + type: string + title: >- + The Bech32 address of the application using cosmos' ScalarDescriptor + to ensure deterministic deterministic encoding using cosmos' + ScalarDescriptor to ensure deterministic deterministic encoding + gateway_address: + type: string + title: >- + The Bech32 address of the gateway the application wants to undelegate + from using cosmos' ScalarDescriptor to ensure deterministic + deterministic encoding using cosmos' ScalarDescriptor to ensure + deterministic deterministic encoding + poktroll.application.MsgUndelegateFromGatewayResponse: + type: object + poktroll.application.MsgUnstakeApplication: + type: object + properties: + address: + type: string + poktroll.application.MsgUnstakeApplicationResponse: + type: object + poktroll.application.MsgUpdateParams: + type: object + properties: + authority: + type: string + description: >- + authority is the address that controls the module (defaults to x/gov + unless overwritten). + params: + description: |- + params defines the x/application parameters to update. + NOTE: All parameters must be supplied. + type: object + properties: + max_delegated_gateways: + type: string + format: uint64 + description: MsgUpdateParams is the Msg/UpdateParams request type. + poktroll.application.MsgUpdateParamsResponse: + type: object + description: |- + MsgUpdateParamsResponse defines the response structure for executing a + MsgUpdateParams message. + poktroll.gateway.MsgStakeGateway: + type: object + properties: + address: type: string title: The Bech32 address of the gateway stake: @@ -24793,91 +25418,12 @@ definitions: poktroll.gateway.Params: type: object description: Params defines the parameters for the module. - cosmos.base.query.v1beta1.PageRequest: - type: object - properties: - key: - type: string - format: byte - description: |- - key is a value returned in PageResponse.next_key to begin - querying the next page most efficiently. Only one of offset or key - should be set. - offset: - type: string - format: uint64 - description: |- - offset is a numeric offset that can be used when key is unavailable. - It is less efficient than using key. Only one of offset or key should - be set. - limit: - type: string - format: uint64 - description: >- - limit is the total number of results to be returned in the result - page. - - If left empty it will default to a value to be set by each app. - count_total: - type: boolean - description: >- - count_total is set to true to indicate that the result set should - include - - a count of the total number of items available for pagination in UIs. - - count_total is only respected when offset is used. It is ignored when - key - - is set. - reverse: - type: boolean - description: >- - reverse is set to true if results are to be returned in the descending - order. - - - Since: cosmos-sdk 0.43 - description: |- - message SomeRequest { - Foo some_parameter = 1; - PageRequest pagination = 2; - } - title: |- - PageRequest is to be embedded in gRPC request messages for efficient - pagination. Ex: - cosmos.base.query.v1beta1.PageResponse: - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: |- - total is total number of results available if PageRequest.count_total - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - poktroll.proof.Claim: + poktroll.proof.MsgCreateClaim: type: object properties: supplier_address: type: string - title: the address of the supplier that submitted this claim session_header: - description: The session header of the session that this claim is for. type: object properties: application_address: @@ -24930,30 +25476,24 @@ definitions: The height at which this session ended, this is the last block of the session + description: >- + SessionHeader is a lightweight header for a session that can be passed + around. + + It is the minimal amount of data required to hydrate & retrieve all + data relevant to the session. root_hash: type: string format: byte - description: Root hash returned from smt.SMST#Root(). - title: >- - Claim is the serialized object stored on-chain for claims pending to be - proven - poktroll.proof.Params: + title: root returned from smt.SMST#Root() + poktroll.proof.MsgCreateClaimResponse: type: object - properties: - min_relay_difficulty_bits: - type: string - format: uint64 - description: >- - The minimum difficulty in bits for a relay to be included in a Merkle - proof. - description: Params defines the parameters for the module. - poktroll.proof.Proof: + poktroll.proof.MsgSubmitProof: type: object properties: supplier_address: type: string session_header: - description: The session header of the session that this claim is for. type: object properties: application_address: @@ -25006,215 +25546,246 @@ definitions: The height at which this session ended, this is the last block of the session - closest_merkle_proof: + description: >- + SessionHeader is a lightweight header for a session that can be passed + around. + + It is the minimal amount of data required to hydrate & retrieve all + data relevant to the session. + proof: type: string format: byte - description: The serialized SMST proof from the `#ClosestProof()` method. - poktroll.proof.QueryAllClaimsResponse: + title: serialized version of *smt.SparseMerkleClosestProof + poktroll.proof.MsgSubmitProofResponse: + type: object + poktroll.proof.MsgUpdateParam: type: object properties: - claims: - type: array - items: - type: object - properties: - supplier_address: - type: string - title: the address of the supplier that submitted this claim - session_header: - description: The session header of the session that this claim is for. - type: object - properties: - application_address: - type: string - title: >- - The Bech32 address of the application using cosmos' - ScalarDescriptor to ensure deterministic encoding - service: - title: The service this session is for - type: object - properties: - id: - type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a session for a - certain service but with some additional configs that - identify it? - name: - type: string - description: (Optional) Semantic human readable name for the service - title: >- - TODO_TECHDEBT: Name is currently unused but acts as a - reminder that an optional onchain representation of the - service is necessary - session_id: - type: string - description: A unique pseudoranom ID for this session - title: >- - NOTE: session_id can be derived from the above values using - on-chain but is included in the header for convenience - session_start_block_height: - type: string - format: int64 - title: The height at which this session started - session_end_block_height: - type: string - format: int64 - description: >- - Note that`session_end_block_height` is a derivative of - (`start` + `num_blocks_per_session`) - - as goverened by on-chain params at the time of the session - start. - - It is stored as an additional field to simplofy business - logic in case - - the number of blocks_per_session changes during the session. - + authority: + type: string + description: >- + authority is the address that controls the module (defaults to x/gov + unless overwritten). + name: + type: string + title: >- + The (name, as_type) tuple must match the corresponding name and type + as - The height at which this session ended, this is the last - block of the session - root_hash: - type: string - format: byte - description: Root hash returned from smt.SMST#Root(). - title: >- - Claim is the serialized object stored on-chain for claims pending to - be proven - pagination: + specified in the `Params`` message in `proof/params.proto.` + as_string: + type: string + as_int64: + type: string + format: int64 + as_bytes: + type: string + format: byte + description: >- + MsgUpdateParam is the Msg/UpdateParam request type to update a single + param. + poktroll.proof.MsgUpdateParamResponse: + type: object + properties: + params: type: object properties: - next_key: + min_relay_difficulty_bits: type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: + format: uint64 + description: >- + The minimum difficulty in bits for a relay to be included in a + Merkle proof. + description: Params defines the parameters for the module. + description: |- + MsgUpdateParamResponse defines the response structure for executing a + MsgUpdateParam message after a single param update. + poktroll.proof.MsgUpdateParams: + type: object + properties: + authority: + type: string + description: >- + authority is the address that controls the module (defaults to x/gov + unless overwritten). + params: + type: object + properties: + min_relay_difficulty_bits: type: string format: uint64 + description: >- + The minimum difficulty in bits for a relay to be included in a + Merkle proof. + description: Params defines the parameters for the module. + description: >- + MsgUpdateParams is the Msg/UpdateParams request type to update all params + at once. + poktroll.proof.MsgUpdateParamsResponse: + type: object + description: |- + MsgUpdateParamsResponse defines the response structure for executing a + MsgUpdateParams message. + poktroll.proof.Params: + type: object + properties: + min_relay_difficulty_bits: + type: string + format: uint64 + description: >- + The minimum difficulty in bits for a relay to be included in a Merkle + proof. + description: Params defines the parameters for the module. + poktroll.session.SessionHeader: + type: object + properties: + application_address: + type: string + title: >- + The Bech32 address of the application using cosmos' ScalarDescriptor + to ensure deterministic encoding + service: + title: The service this session is for + type: object + properties: + id: + type: string + description: Unique identifier for the service title: >- - total is total number of results available if - PageRequest.count_total + For example, what if we want to request a session for a certain + service but with some additional configs that identify it? + name: + type: string + description: (Optional) Semantic human readable name for the service + title: >- + TODO_TECHDEBT: Name is currently unused but acts as a reminder + that an optional onchain representation of the service is + necessary + session_id: + type: string + description: A unique pseudoranom ID for this session + title: >- + NOTE: session_id can be derived from the above values using on-chain + but is included in the header for convenience + session_start_block_height: + type: string + format: int64 + title: The height at which this session started + session_end_block_height: + type: string + format: int64 + description: >- + Note that`session_end_block_height` is a derivative of (`start` + + `num_blocks_per_session`) - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. + as goverened by on-chain params at the time of the session start. - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - poktroll.proof.QueryAllProofsResponse: + It is stored as an additional field to simplofy business logic in case + + the number of blocks_per_session changes during the session. + + + The height at which this session ended, this is the last block of the + session + description: >- + SessionHeader is a lightweight header for a session that can be passed + around. + + It is the minimal amount of data required to hydrate & retrieve all data + relevant to the session. + poktroll.service.MsgAddService: type: object properties: - proofs: - type: array - items: - type: object - properties: - supplier_address: - type: string - session_header: - description: The session header of the session that this claim is for. - type: object - properties: - application_address: - type: string - title: >- - The Bech32 address of the application using cosmos' - ScalarDescriptor to ensure deterministic encoding - service: - title: The service this session is for - type: object - properties: - id: - type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a session for a - certain service but with some additional configs that - identify it? - name: - type: string - description: (Optional) Semantic human readable name for the service - title: >- - TODO_TECHDEBT: Name is currently unused but acts as a - reminder that an optional onchain representation of the - service is necessary - session_id: - type: string - description: A unique pseudoranom ID for this session - title: >- - NOTE: session_id can be derived from the above values using - on-chain but is included in the header for convenience - session_start_block_height: - type: string - format: int64 - title: The height at which this session started - session_end_block_height: - type: string - format: int64 - description: >- - Note that`session_end_block_height` is a derivative of - (`start` + `num_blocks_per_session`) + address: + type: string + title: >- + The Bech32 address of the service supplier using cosmos' + ScalarDescriptor + service: + title: The Service for which the supplier is adding to the network + type: object + properties: + id: + type: string + description: Unique identifier for the service + title: >- + For example, what if we want to request a session for a certain + service but with some additional configs that identify it? + name: + type: string + description: (Optional) Semantic human readable name for the service + title: >- + TODO_TECHDEBT: Name is currently unused but acts as a reminder + that an optional onchain representation of the service is + necessary + description: >- + MsgAddService defines a message for adding a new message to the network. - as goverened by on-chain params at the time of the session - start. + Services can be added by any actor in the network making them truly - It is stored as an additional field to simplofy business - logic in case + permissionless. - the number of blocks_per_session changes during the session. + TODO_DOCUMENT(@h5law): This is a key function in making services + permissionless, document it's usage and design - in docusaurus covering + how - The height at which this session ended, this is the last - block of the session - closest_merkle_proof: - type: string - format: byte - description: The serialized SMST proof from the `#ClosestProof()` method. - pagination: + the entire process works. + poktroll.service.MsgAddServiceResponse: + type: object + poktroll.service.MsgUpdateParams: + type: object + properties: + authority: + type: string + description: >- + authority is the address that controls the module (defaults to x/gov + unless overwritten). + params: + description: |- + params defines the x/service parameters to update. + NOTE: All parameters must be supplied. type: object properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: + add_service_fee: type: string format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise + description: |- + The amount of uPOKT required to add a new service. + This will be deducted from the signer's account balance, + and transferred to the pocket network foundation. + description: MsgUpdateParams is the Msg/UpdateParams request type. + poktroll.service.MsgUpdateParamsResponse: + type: object + description: |- + MsgUpdateParamsResponse defines the response structure for executing a + MsgUpdateParams message. + poktroll.service.Params: + type: object + properties: + add_service_fee: + type: string + format: uint64 description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - poktroll.proof.QueryGetClaimResponse: + The amount of uPOKT required to add a new service. + This will be deducted from the signer's account balance, + and transferred to the pocket network foundation. + description: Params defines the parameters for the module. + poktroll.session.Params: + type: object + properties: + num_blocks_per_session: + type: string + format: uint64 + description: Params defines the parameters for the module. + poktroll.session.QueryGetSessionResponse: type: object properties: - claim: + session: type: object properties: - supplier_address: - type: string - title: the address of the supplier that submitted this claim - session_header: - description: The session header of the session that this claim is for. + header: + title: The header of the session containing lightweight data type: object properties: application_address: @@ -25268,157 +25839,262 @@ definitions: The height at which this session ended, this is the last block of the session - root_hash: + description: >- + SessionHeader is a lightweight header for a session that can be + passed around. + + It is the minimal amount of data required to hydrate & retrieve + all data relevant to the session. + session_id: type: string - format: byte - description: Root hash returned from smt.SMST#Root(). - title: >- - Claim is the serialized object stored on-chain for claims pending to - be proven - poktroll.proof.QueryGetProofResponse: - type: object - properties: - proof: - type: object - properties: - supplier_address: + title: A unique pseudoranom ID for this session + session_number: + type: string + format: int64 + title: The session number since genesis + num_blocks_per_session: type: string - session_header: - description: The session header of the session that this claim is for. + format: int64 + title: The number of blocks per session when this session started + application: + title: A fully hydrated application object this session is for type: object properties: - application_address: + address: type: string title: >- The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic encoding - service: - title: The service this session is for + stake: + title: The total amount of uPOKT the application has staked type: object properties: - id: + denom: type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a session for a - certain service but with some additional configs that - identify it? - name: + amount: type: string - description: (Optional) Semantic human readable name for the service - title: >- - TODO_TECHDEBT: Name is currently unused but acts as a - reminder that an optional onchain representation of the - service is necessary - session_id: - type: string - description: A unique pseudoranom ID for this session + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + service_configs: + type: array + items: + type: object + properties: + service: + title: The Service for which the application is configured + type: object + properties: + id: + type: string + description: Unique identifier for the service + title: >- + For example, what if we want to request a session + for a certain service but with some additional + configs that identify it? + name: + type: string + description: >- + (Optional) Semantic human readable name for the + service + title: >- + TODO_TECHDEBT: Name is currently unused but acts as + a reminder that an optional onchain representation + of the service is necessary + title: >- + ApplicationServiceConfig holds the service configuration the + application stakes for title: >- - NOTE: session_id can be derived from the above values using - on-chain but is included in the header for convenience - session_start_block_height: - type: string - format: int64 - title: The height at which this session started - session_end_block_height: - type: string - format: int64 + The list of services this appliccation is configured to + request service for + delegatee_gateway_addresses: + type: array + items: + type: string description: >- - Note that`session_end_block_height` is a derivative of - (`start` + `num_blocks_per_session`) + TODO_TECHDEBT: Rename `delegatee_gateway_addresses` to + `gateway_addresses_delegated_to`. - as goverened by on-chain params at the time of the session - start. + Ensure to rename all relevant configs, comments, variables, + function names, etc as well. - It is stored as an additional field to simplofy business logic - in case - the number of blocks_per_session changes during the session. + The Bech32 encoded addresses for all delegatee Gateways, in a + non-nullable slice + pending_undelegations: + type: object + additionalProperties: + type: object + properties: + gateway_addresses: + type: array + items: + type: string + description: >- + UndelegatingGatewayList is used as the Value of + `pending_undelegations`. + It is required to store a repeated list of strings as a map + value. + description: >- + A map from sessionEndHeights to a list of Gateways. - The height at which this session ended, this is the last block - of the session - closest_merkle_proof: - type: string - format: byte - description: The serialized SMST proof from the `#ClosestProof()` method. - poktroll.proof.QueryParamsResponse: - type: object - properties: - params: - description: params holds all the parameters of this module. - type: object - properties: - min_relay_difficulty_bits: - type: string - format: uint64 - description: >- - The minimum difficulty in bits for a relay to be included in a - Merkle proof. - description: QueryParamsResponse is response type for the Query/Params RPC method. - poktroll.session.SessionHeader: - type: object - properties: - application_address: - type: string - title: >- - The Bech32 address of the application using cosmos' ScalarDescriptor - to ensure deterministic encoding - service: - title: The service this session is for - type: object - properties: - id: - type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a session for a certain - service but with some additional configs that identify it? - name: - type: string - description: (Optional) Semantic human readable name for the service - title: >- - TODO_TECHDEBT: Name is currently unused but acts as a reminder - that an optional onchain representation of the service is - necessary - session_id: - type: string - description: A unique pseudoranom ID for this session - title: >- - NOTE: session_id can be derived from the above values using on-chain - but is included in the header for convenience - session_start_block_height: - type: string - format: int64 - title: The height at which this session started - session_end_block_height: - type: string - format: int64 - description: >- - Note that`session_end_block_height` is a derivative of (`start` + - `num_blocks_per_session`) + The key is the height of the last block of the session during + which the - as goverened by on-chain params at the time of the session start. + respective undelegation was committed. - It is stored as an additional field to simplofy business logic in case + The value is a list of gateways being undelegated from. - the number of blocks_per_session changes during the session. + TODO_DOCUMENT(@red-0ne): Need to document the flow from this + comment + + so its clear to everyone why this is necessary; + https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. + suppliers: + type: array + items: + type: object + properties: + address: + type: string + title: >- + The Bech32 address of the supplier using cosmos' + ScalarDescriptor to ensure deterministic encoding + stake: + title: The total amount of uPOKT the supplier has staked + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. - The height at which this session ended, this is the last block of the - session - description: >- - SessionHeader is a lightweight header for a session that can be passed - around. + NOTE: The amount field is an Int which implements the custom + method - It is the minimal amount of data required to hydrate & retrieve all data - relevant to the session. - poktroll.proof.MsgCreateClaim: + signatures required by gogoproto. + services: + type: array + items: + type: object + properties: + service: + title: The Service for which the supplier is configured + type: object + properties: + id: + type: string + description: Unique identifier for the service + title: >- + For example, what if we want to request a session + for a certain service but with some additional + configs that identify it? + name: + type: string + description: >- + (Optional) Semantic human readable name for the + service + title: >- + TODO_TECHDEBT: Name is currently unused but acts + as a reminder that an optional onchain + representation of the service is necessary + endpoints: + type: array + items: + type: object + properties: + url: + type: string + title: URL of the endpoint + rpc_type: + title: Type of RPC exposed on the url above + type: string + enum: + - UNKNOWN_RPC + - GRPC + - WEBSOCKET + - JSON_RPC + - REST + default: UNKNOWN_RPC + description: |- + - UNKNOWN_RPC: Undefined RPC type + - GRPC: gRPC + - WEBSOCKET: WebSocket + - JSON_RPC: JSON-RPC + - REST: REST + configs: + type: array + items: + type: object + properties: + key: + title: Config option key + type: string + enum: + - UNKNOWN_CONFIG + - TIMEOUT + default: UNKNOWN_CONFIG + description: >- + Enum to define configuration options + + TODO_RESEARCH: Should these be configs, + SLAs or something else? There will be more + discussion once we get closer to + implementing on-chain QoS. + + - UNKNOWN_CONFIG: Undefined config option + - TIMEOUT: Timeout setting + value: + type: string + title: Config option value + title: >- + Key-value wrapper for config options, as proto + maps can't be keyed by enums + title: >- + Additional configuration options for the + endpoint + title: >- + SupplierEndpoint message to hold service + configuration details + title: List of endpoints for the service + title: >- + SupplierServiceConfig holds the service configuration the + supplier stakes for + title: The service configs this supplier can support + description: >- + Supplier is the type defining the actor in Pocket Network that + provides RPC services. + title: A fully hydrated set of servicers that are serving the application + description: >- + Session is a fully hydrated session object that contains all the + information for the Session + + and its parcipants. + poktroll.session.QueryParamsResponse: type: object properties: - supplier_address: - type: string - session_header: + params: + description: params holds all the parameters of this module. + type: object + properties: + num_blocks_per_session: + type: string + format: uint64 + description: QueryParamsResponse is response type for the Query/Params RPC method. + poktroll.session.Session: + type: object + properties: + header: + title: The header of the session containing lightweight data type: object properties: application_address: @@ -25477,250 +26153,236 @@ definitions: It is the minimal amount of data required to hydrate & retrieve all data relevant to the session. - root_hash: + session_id: type: string - format: byte - title: root returned from smt.SMST#Root() - poktroll.proof.MsgCreateClaimResponse: - type: object - poktroll.proof.MsgSubmitProof: - type: object - properties: - supplier_address: + title: A unique pseudoranom ID for this session + session_number: type: string - session_header: + format: int64 + title: The session number since genesis + num_blocks_per_session: + type: string + format: int64 + title: The number of blocks per session when this session started + application: + title: A fully hydrated application object this session is for type: object properties: - application_address: + address: type: string title: >- The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic encoding - service: - title: The service this session is for + stake: + title: The total amount of uPOKT the application has staked type: object properties: - id: + denom: type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a session for a - certain service but with some additional configs that identify - it? - name: + amount: type: string - description: (Optional) Semantic human readable name for the service - title: >- - TODO_TECHDEBT: Name is currently unused but acts as a reminder - that an optional onchain representation of the service is - necessary - session_id: - type: string - description: A unique pseudoranom ID for this session - title: >- - NOTE: session_id can be derived from the above values using - on-chain but is included in the header for convenience - session_start_block_height: - type: string - format: int64 - title: The height at which this session started - session_end_block_height: - type: string - format: int64 description: >- - Note that`session_end_block_height` is a derivative of (`start` + - `num_blocks_per_session`) + Coin defines a token with a denomination and an amount. - as goverened by on-chain params at the time of the session start. - It is stored as an additional field to simplofy business logic in - case + NOTE: The amount field is an Int which implements the custom + method - the number of blocks_per_session changes during the session. + signatures required by gogoproto. + service_configs: + type: array + items: + type: object + properties: + service: + title: The Service for which the application is configured + type: object + properties: + id: + type: string + description: Unique identifier for the service + title: >- + For example, what if we want to request a session for a + certain service but with some additional configs that + identify it? + name: + type: string + description: (Optional) Semantic human readable name for the service + title: >- + TODO_TECHDEBT: Name is currently unused but acts as a + reminder that an optional onchain representation of the + service is necessary + title: >- + ApplicationServiceConfig holds the service configuration the + application stakes for + title: >- + The list of services this appliccation is configured to request + service for + delegatee_gateway_addresses: + type: array + items: + type: string + description: >- + TODO_TECHDEBT: Rename `delegatee_gateway_addresses` to + `gateway_addresses_delegated_to`. + Ensure to rename all relevant configs, comments, variables, + function names, etc as well. - The height at which this session ended, this is the last block of - the session - description: >- - SessionHeader is a lightweight header for a session that can be passed - around. - It is the minimal amount of data required to hydrate & retrieve all - data relevant to the session. - proof: - type: string - format: byte - title: serialized version of *smt.SparseMerkleClosestProof - poktroll.proof.MsgSubmitProofResponse: - type: object - poktroll.proof.MsgUpdateParam: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to x/gov - unless overwritten). - name: - type: string - title: >- - The (name, as_type) tuple must match the corresponding name and type - as + The Bech32 encoded addresses for all delegatee Gateways, in a + non-nullable slice + pending_undelegations: + type: object + additionalProperties: + type: object + properties: + gateway_addresses: + type: array + items: + type: string + description: >- + UndelegatingGatewayList is used as the Value of + `pending_undelegations`. - specified in the `Params`` message in `proof/params.proto.` - as_string: - type: string - as_int64: - type: string - format: int64 - as_bytes: - type: string - format: byte - description: >- - MsgUpdateParam is the Msg/UpdateParam request type to update a single - param. - poktroll.proof.MsgUpdateParamResponse: - type: object - properties: - params: - type: object - properties: - min_relay_difficulty_bits: - type: string - format: uint64 - description: >- - The minimum difficulty in bits for a relay to be included in a - Merkle proof. - description: Params defines the parameters for the module. - description: |- - MsgUpdateParamResponse defines the response structure for executing a - MsgUpdateParam message after a single param update. - poktroll.proof.MsgUpdateParams: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to x/gov - unless overwritten). - params: - type: object - properties: - min_relay_difficulty_bits: - type: string - format: uint64 + It is required to store a repeated list of strings as a map + value. description: >- - The minimum difficulty in bits for a relay to be included in a - Merkle proof. - description: Params defines the parameters for the module. - description: >- - MsgUpdateParams is the Msg/UpdateParams request type to update all params - at once. - poktroll.proof.MsgUpdateParamsResponse: - type: object - description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. - poktroll.service.MsgAddService: - type: object - properties: - address: - type: string - title: >- - The Bech32 address of the service supplier using cosmos' - ScalarDescriptor - service: - title: The Service for which the supplier is adding to the network - type: object - properties: - id: - type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a session for a certain - service but with some additional configs that identify it? - name: - type: string - description: (Optional) Semantic human readable name for the service - title: >- - TODO_TECHDEBT: Name is currently unused but acts as a reminder - that an optional onchain representation of the service is - necessary - description: >- - MsgAddService defines a message for adding a new message to the network. + A map from sessionEndHeights to a list of Gateways. - Services can be added by any actor in the network making them truly + The key is the height of the last block of the session during + which the - permissionless. + respective undelegation was committed. - TODO_DOCUMENT(@h5law): This is a key function in making services + The value is a list of gateways being undelegated from. - permissionless, document it's usage and design - in docusaurus covering - how + TODO_DOCUMENT(@red-0ne): Need to document the flow from this + comment + + so its clear to everyone why this is necessary; + https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. + suppliers: + type: array + items: + type: object + properties: + address: + type: string + title: >- + The Bech32 address of the supplier using cosmos' + ScalarDescriptor to ensure deterministic encoding + stake: + title: The total amount of uPOKT the supplier has staked + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + services: + type: array + items: + type: object + properties: + service: + title: The Service for which the supplier is configured + type: object + properties: + id: + type: string + description: Unique identifier for the service + title: >- + For example, what if we want to request a session for + a certain service but with some additional configs + that identify it? + name: + type: string + description: >- + (Optional) Semantic human readable name for the + service + title: >- + TODO_TECHDEBT: Name is currently unused but acts as a + reminder that an optional onchain representation of + the service is necessary + endpoints: + type: array + items: + type: object + properties: + url: + type: string + title: URL of the endpoint + rpc_type: + title: Type of RPC exposed on the url above + type: string + enum: + - UNKNOWN_RPC + - GRPC + - WEBSOCKET + - JSON_RPC + - REST + default: UNKNOWN_RPC + description: |- + - UNKNOWN_RPC: Undefined RPC type + - GRPC: gRPC + - WEBSOCKET: WebSocket + - JSON_RPC: JSON-RPC + - REST: REST + configs: + type: array + items: + type: object + properties: + key: + title: Config option key + type: string + enum: + - UNKNOWN_CONFIG + - TIMEOUT + default: UNKNOWN_CONFIG + description: >- + Enum to define configuration options + + TODO_RESEARCH: Should these be configs, SLAs + or something else? There will be more + discussion once we get closer to implementing + on-chain QoS. + + - UNKNOWN_CONFIG: Undefined config option + - TIMEOUT: Timeout setting + value: + type: string + title: Config option value + title: >- + Key-value wrapper for config options, as proto + maps can't be keyed by enums + title: Additional configuration options for the endpoint + title: >- + SupplierEndpoint message to hold service configuration + details + title: List of endpoints for the service + title: >- + SupplierServiceConfig holds the service configuration the + supplier stakes for + title: The service configs this supplier can support + description: >- + Supplier is the type defining the actor in Pocket Network that + provides RPC services. + title: A fully hydrated set of servicers that are serving the application + description: >- + Session is a fully hydrated session object that contains all the + information for the Session - the entire process works. - poktroll.service.MsgAddServiceResponse: - type: object - poktroll.service.MsgUpdateParams: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to x/gov - unless overwritten). - params: - description: |- - params defines the x/service parameters to update. - NOTE: All parameters must be supplied. - type: object - properties: - add_service_fee: - type: string - format: uint64 - description: |- - The amount of uPOKT required to add a new service. - This will be deducted from the signer's account balance, - and transferred to the pocket network foundation. - description: MsgUpdateParams is the Msg/UpdateParams request type. - poktroll.service.MsgUpdateParamsResponse: - type: object - description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. - poktroll.service.Params: - type: object - properties: - add_service_fee: - type: string - format: uint64 - description: |- - The amount of uPOKT required to add a new service. - This will be deducted from the signer's account balance, - and transferred to the pocket network foundation. - description: Params defines the parameters for the module. - poktroll.session.MsgUpdateParams: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to x/gov - unless overwritten). - params: - description: |- - params defines the x/session parameters to update. - NOTE: All parameters must be supplied. - type: object - description: MsgUpdateParams is the Msg/UpdateParams request type. - poktroll.session.MsgUpdateParamsResponse: - type: object - description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. - poktroll.session.Params: - type: object - description: Params defines the parameters for the module. + and its parcipants. poktroll.shared.ConfigOption: type: object properties: @@ -25776,6 +26438,111 @@ definitions: - JSON_RPC: JSON-RPC - REST: REST title: Enum to define RPC types + poktroll.shared.Supplier: + type: object + properties: + address: + type: string + title: >- + The Bech32 address of the supplier using cosmos' ScalarDescriptor to + ensure deterministic encoding + stake: + title: The total amount of uPOKT the supplier has staked + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + services: + type: array + items: + type: object + properties: + service: + title: The Service for which the supplier is configured + type: object + properties: + id: + type: string + description: Unique identifier for the service + title: >- + For example, what if we want to request a session for a + certain service but with some additional configs that + identify it? + name: + type: string + description: (Optional) Semantic human readable name for the service + title: >- + TODO_TECHDEBT: Name is currently unused but acts as a + reminder that an optional onchain representation of the + service is necessary + endpoints: + type: array + items: + type: object + properties: + url: + type: string + title: URL of the endpoint + rpc_type: + title: Type of RPC exposed on the url above + type: string + enum: + - UNKNOWN_RPC + - GRPC + - WEBSOCKET + - JSON_RPC + - REST + default: UNKNOWN_RPC + description: |- + - UNKNOWN_RPC: Undefined RPC type + - GRPC: gRPC + - WEBSOCKET: WebSocket + - JSON_RPC: JSON-RPC + - REST: REST + configs: + type: array + items: + type: object + properties: + key: + title: Config option key + type: string + enum: + - UNKNOWN_CONFIG + - TIMEOUT + default: UNKNOWN_CONFIG + description: >- + Enum to define configuration options + + TODO_RESEARCH: Should these be configs, SLAs or + something else? There will be more discussion once + we get closer to implementing on-chain QoS. + + - UNKNOWN_CONFIG: Undefined config option + - TIMEOUT: Timeout setting + value: + type: string + title: Config option value + title: >- + Key-value wrapper for config options, as proto maps + can't be keyed by enums + title: Additional configuration options for the endpoint + title: SupplierEndpoint message to hold service configuration details + title: List of endpoints for the service + title: >- + SupplierServiceConfig holds the service configuration the supplier + stakes for + title: The service configs this supplier can support + description: >- + Supplier is the type defining the actor in Pocket Network that provides + RPC services. poktroll.shared.SupplierEndpoint: type: object properties: @@ -25904,6 +26671,59 @@ definitions: title: >- SupplierServiceConfig holds the service configuration the supplier stakes for + poktroll.session.MsgUpdateParams: + type: object + properties: + authority: + type: string + description: >- + authority is the address that controls the module (defaults to x/gov + unless overwritten). + params: + description: |- + params defines the x/session parameters to update. + NOTE: All parameters must be supplied. + type: object + properties: + num_blocks_per_session: + type: string + format: uint64 + description: MsgUpdateParams is the Msg/UpdateParams request type. + poktroll.session.MsgUpdateParamsResponse: + type: object + description: |- + MsgUpdateParamsResponse defines the response structure for executing a + MsgUpdateParams message. + poktroll.shared.Params: + type: object + description: Params defines the parameters for the module. + poktroll.shared.QueryParamsResponse: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + description: QueryParamsResponse is response type for the Query/Params RPC method. + poktroll.shared.MsgUpdateParams: + type: object + properties: + authority: + type: string + description: >- + authority is the address that controls the module (defaults to x/gov + unless overwritten). + params: + description: |- + params defines the module parameters to update. + + NOTE: All parameters must be supplied. + type: object + description: MsgUpdateParams is the Msg/UpdateParams request type. + poktroll.shared.MsgUpdateParamsResponse: + type: object + description: |- + MsgUpdateParamsResponse defines the response structure for executing a + MsgUpdateParams message. poktroll.supplier.MsgStakeSupplier: type: object properties: @@ -26044,36 +26864,6 @@ definitions: poktroll.supplier.Params: type: object description: Params defines the parameters for the module. - poktroll.tokenomics.Params: - type: object - properties: - compute_units_to_tokens_multiplier: - type: string - format: uint64 - description: >- - The amount of upokt that a compute unit should translate to when - settling a session. - - TODO_DOCUMENT(@Olshansk): Make sure to document the units of this - parameter (or the map) once finalized. - description: Params defines the parameters for the tokenomics module. - poktroll.tokenomics.QueryParamsResponse: - type: object - properties: - params: - description: params holds all the parameters of this module. - type: object - properties: - compute_units_to_tokens_multiplier: - type: string - format: uint64 - description: >- - The amount of upokt that a compute unit should translate to when - settling a session. - - TODO_DOCUMENT(@Olshansk): Make sure to document the units of this - parameter (or the map) once finalized. - description: QueryParamsResponse is response type for the Query/Params RPC method. poktroll.tokenomics.MsgUpdateParam: type: object properties: @@ -26148,3 +26938,16 @@ definitions: description: |- MsgUpdateParamsResponse defines the response structure for executing a MsgUpdateParams message. + poktroll.tokenomics.Params: + type: object + properties: + compute_units_to_tokens_multiplier: + type: string + format: uint64 + description: >- + The amount of upokt that a compute unit should translate to when + settling a session. + + TODO_DOCUMENT(@Olshansk): Make sure to document the units of this + parameter (or the map) once finalized. + description: Params defines the parameters for the tokenomics module. diff --git a/proto/poktroll/shared/genesis.proto b/proto/poktroll/shared/genesis.proto new file mode 100644 index 000000000..b2867abc4 --- /dev/null +++ b/proto/poktroll/shared/genesis.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package poktroll.shared; + +import "amino/amino.proto"; +import "gogoproto/gogo.proto"; +import "poktroll/shared/params.proto"; + +option go_package = "github.com/pokt-network/poktroll/x/shared/types"; + +// GenesisState defines the shared module's genesis state. +message GenesisState { + // params defines all the parameters of the module. + Params params = 1 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; +} diff --git a/proto/poktroll/shared/module/module.proto b/proto/poktroll/shared/module/module.proto new file mode 100644 index 000000000..4deb64e9c --- /dev/null +++ b/proto/poktroll/shared/module/module.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package poktroll.shared.module; + +import "cosmos/app/v1alpha1/module.proto"; + +// Module is the config object for the module. +message Module { + option (cosmos.app.v1alpha1.module) = { + go_import: "github.com/pokt-network/poktroll/x/shared" + }; + + // authority defines the custom module authority. If not set, defaults to the governance module. + string authority = 1; +} \ No newline at end of file diff --git a/proto/poktroll/shared/params.proto b/proto/poktroll/shared/params.proto new file mode 100644 index 000000000..b02eb8f55 --- /dev/null +++ b/proto/poktroll/shared/params.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package poktroll.shared; + +import "amino/amino.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/pokt-network/poktroll/x/shared/types"; + +// Params defines the parameters for the module. +message Params { + option (amino.name) = "poktroll/x/shared/Params"; + option (gogoproto.equal) = true; + + +} \ No newline at end of file diff --git a/proto/poktroll/shared/query.proto b/proto/poktroll/shared/query.proto new file mode 100644 index 000000000..7445dcbe2 --- /dev/null +++ b/proto/poktroll/shared/query.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; +package poktroll.shared; + +import "amino/amino.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "poktroll/shared/params.proto"; + +option go_package = "github.com/pokt-network/poktroll/x/shared/types"; + +// Query defines the gRPC querier service. +service Query { + // Parameters queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/pokt-network/poktroll/shared/params"; + } +} + +// 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 diff --git a/proto/poktroll/shared/tx.proto b/proto/poktroll/shared/tx.proto new file mode 100644 index 000000000..37938f942 --- /dev/null +++ b/proto/poktroll/shared/tx.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; +package poktroll.shared; + +import "amino/amino.proto"; +import "cosmos/msg/v1/msg.proto"; +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "poktroll/shared/params.proto"; + +option go_package = "github.com/pokt-network/poktroll/x/shared/types"; + +// Msg defines the Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + + // UpdateParams defines a (governance) operation for updating the module + // parameters. The authority defaults to the x/gov module account. + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); +} + +// MsgUpdateParams is the Msg/UpdateParams request type. +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "authority"; + option (amino.name) = "poktroll/x/shared/MsgUpdateParams"; + + // authority is the address that controls the module (defaults to x/gov unless overwritten). + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // params defines the module parameters to update. + // + // NOTE: All parameters must be supplied. + Params params = 2 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +message MsgUpdateParamsResponse {} \ No newline at end of file diff --git a/testutil/keeper/shared.go b/testutil/keeper/shared.go new file mode 100644 index 000000000..e7c780a5a --- /dev/null +++ b/testutil/keeper/shared.go @@ -0,0 +1,49 @@ +package keeper + +import ( + "testing" + + "cosmossdk.io/log" + "cosmossdk.io/store" + "cosmossdk.io/store/metrics" + storetypes "cosmossdk.io/store/types" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" + dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/runtime" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/stretchr/testify/require" + + "github.com/pokt-network/poktroll/x/shared/keeper" + "github.com/pokt-network/poktroll/x/shared/types" +) + +func SharedKeeper(t testing.TB) (keeper.Keeper, sdk.Context) { + storeKey := storetypes.NewKVStoreKey(types.StoreKey) + + db := dbm.NewMemDB() + stateStore := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) + stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + require.NoError(t, stateStore.LoadLatestVersion()) + + registry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(registry) + authority := authtypes.NewModuleAddress(govtypes.ModuleName) + + k := keeper.NewKeeper( + cdc, + runtime.NewKVStoreService(storeKey), + log.NewNopLogger(), + authority.String(), + ) + + ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger()) + + // Initialize params + k.SetParams(ctx, types.DefaultParams()) + + return k, ctx +} diff --git a/x/shared/keeper/keeper.go b/x/shared/keeper/keeper.go new file mode 100644 index 000000000..392e4abd0 --- /dev/null +++ b/x/shared/keeper/keeper.go @@ -0,0 +1,59 @@ +package keeper + +import ( + "fmt" + + "cosmossdk.io/core/store" + "cosmossdk.io/log" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + + + "github.com/pokt-network/poktroll/x/shared/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeService store.KVStoreService + logger log.Logger + + // the address capable of executing a MsgUpdateParams message. Typically, this + // should be the x/gov module account. + authority string + + + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeService store.KVStoreService, + logger log.Logger, + authority string, + +) Keeper { + if _, err := sdk.AccAddressFromBech32(authority); err != nil { + panic(fmt.Sprintf("invalid authority address: %s", authority)) + } + + return Keeper{ + cdc: cdc, + storeService: storeService, + authority: authority, + logger: logger, + + } +} + +// GetAuthority returns the module's authority. +func (k Keeper) GetAuthority() string { + return k.authority +} + +// Logger returns a module-specific logger. +func (k Keeper) Logger() log.Logger { + return k.logger.With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + + diff --git a/x/shared/keeper/msg_server.go b/x/shared/keeper/msg_server.go new file mode 100644 index 000000000..a44db4505 --- /dev/null +++ b/x/shared/keeper/msg_server.go @@ -0,0 +1,17 @@ +package keeper + +import ( + "github.com/pokt-network/poktroll/x/shared/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} diff --git a/x/shared/keeper/msg_server_test.go b/x/shared/keeper/msg_server_test.go new file mode 100644 index 000000000..a9d05fe66 --- /dev/null +++ b/x/shared/keeper/msg_server_test.go @@ -0,0 +1,24 @@ +package keeper_test + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + keepertest "github.com/pokt-network/poktroll/testutil/keeper" + "github.com/pokt-network/poktroll/x/shared/types" + "github.com/pokt-network/poktroll/x/shared/keeper" +) + +func setupMsgServer(t testing.TB) (keeper.Keeper, types.MsgServer, context.Context) { + k, ctx := keepertest.SharedKeeper(t) + return k, keeper.NewMsgServerImpl(k), ctx +} + +func TestMsgServer(t *testing.T) { + k, ms, ctx := setupMsgServer(t) + require.NotNil(t, ms) + require.NotNil(t, ctx) + require.NotEmpty(t, k) +} \ No newline at end of file diff --git a/x/shared/keeper/msg_update_params.go b/x/shared/keeper/msg_update_params.go new file mode 100644 index 000000000..f5582e9e9 --- /dev/null +++ b/x/shared/keeper/msg_update_params.go @@ -0,0 +1,23 @@ +package keeper + +import ( + "context" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/pokt-network/poktroll/x/shared/types" +) + +func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + if k.GetAuthority() != req.Authority { + return nil, errorsmod.Wrapf(types.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.GetAuthority(), req.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + if err := k.SetParams(ctx, req.Params); err != nil { + return nil, err + } + + return &types.MsgUpdateParamsResponse{}, nil +} diff --git a/x/shared/keeper/msg_update_params_test.go b/x/shared/keeper/msg_update_params_test.go new file mode 100644 index 000000000..200574b1e --- /dev/null +++ b/x/shared/keeper/msg_update_params_test.go @@ -0,0 +1,64 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + "github.com/pokt-network/poktroll/x/shared/types" +) + +func TestMsgUpdateParams(t *testing.T) { + k, ms, ctx := setupMsgServer(t) + params := types.DefaultParams() + require.NoError(t, k.SetParams(ctx, params)) + wctx := sdk.UnwrapSDKContext(ctx) + + // default params + testCases := []struct { + name string + input *types.MsgUpdateParams + expErr bool + expErrMsg string + }{ + { + name: "invalid authority", + input: &types.MsgUpdateParams{ + Authority: "invalid", + Params: params, + }, + expErr: true, + expErrMsg: "invalid authority", + }, + { + name: "send enabled param", + input: &types.MsgUpdateParams{ + Authority: k.GetAuthority(), + Params: types.Params{}, + }, + expErr: false, + }, + { + name: "all good", + input: &types.MsgUpdateParams{ + Authority: k.GetAuthority(), + Params: params, + }, + expErr: false, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + _, err := ms.UpdateParams(wctx, tc.input) + + if tc.expErr { + require.Error(t, err) + require.Contains(t, err.Error(), tc.expErrMsg) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/shared/keeper/params.go b/x/shared/keeper/params.go new file mode 100644 index 000000000..7315fa104 --- /dev/null +++ b/x/shared/keeper/params.go @@ -0,0 +1,34 @@ +package keeper + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/runtime" + + "github.com/pokt-network/poktroll/x/shared/types" +) + + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx context.Context) (params types.Params) { + store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + bz := store.Get(types.ParamsKey) + if bz == nil { + return params + } + + k.cdc.MustUnmarshal(bz, ¶ms) + return params +} + +// SetParams set the params +func (k Keeper) SetParams(ctx context.Context, params types.Params) error { + store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + bz, err := k.cdc.Marshal(¶ms) + if err != nil { + return err + } + store.Set(types.ParamsKey, bz) + + return nil +} diff --git a/x/shared/keeper/params_test.go b/x/shared/keeper/params_test.go new file mode 100644 index 000000000..cc7e9ed0c --- /dev/null +++ b/x/shared/keeper/params_test.go @@ -0,0 +1,18 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + keepertest "github.com/pokt-network/poktroll/testutil/keeper" + "github.com/pokt-network/poktroll/x/shared/types" +) + +func TestGetParams(t *testing.T) { + k, ctx := keepertest.SharedKeeper(t) + params := types.DefaultParams() + + require.NoError(t, k.SetParams(ctx, params)) + require.EqualValues(t, params, k.GetParams(ctx)) +} diff --git a/x/shared/keeper/query.go b/x/shared/keeper/query.go new file mode 100644 index 000000000..a98f9989a --- /dev/null +++ b/x/shared/keeper/query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/pokt-network/poktroll/x/shared/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/shared/keeper/query_params.go b/x/shared/keeper/query_params.go new file mode 100644 index 000000000..19ce236a5 --- /dev/null +++ b/x/shared/keeper/query_params.go @@ -0,0 +1,20 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/pokt-network/poktroll/x/shared/types" +) + +func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} diff --git a/x/shared/keeper/query_params_test.go b/x/shared/keeper/query_params_test.go new file mode 100644 index 000000000..4013514fd --- /dev/null +++ b/x/shared/keeper/query_params_test.go @@ -0,0 +1,20 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + keepertest "github.com/pokt-network/poktroll/testutil/keeper" + "github.com/pokt-network/poktroll/x/shared/types" +) + +func TestParamsQuery(t *testing.T) { + keeper, ctx := keepertest.SharedKeeper(t) + params := types.DefaultParams() + require.NoError(t, keeper.SetParams(ctx, params)) + + response, err := keeper.Params(ctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +} diff --git a/x/shared/module/autocli.go b/x/shared/module/autocli.go new file mode 100644 index 000000000..deb554498 --- /dev/null +++ b/x/shared/module/autocli.go @@ -0,0 +1,35 @@ +package shared + +import ( + autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" + + modulev1 "github.com/pokt-network/poktroll/api/poktroll/shared" +) + +// AutoCLIOptions implements the autocli.HasAutoCLIConfig interface. +func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { + return &autocliv1.ModuleOptions{ + Query: &autocliv1.ServiceCommandDescriptor{ + Service: modulev1.Query_ServiceDesc.ServiceName, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "Params", + Use: "params", + Short: "Shows the parameters of the module", + }, + // this line is used by ignite scaffolding # autocli/query + }, + }, + Tx: &autocliv1.ServiceCommandDescriptor{ + Service: modulev1.Msg_ServiceDesc.ServiceName, + EnhanceCustomCommand: true, // only required if you want to use the custom command + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "UpdateParams", + Skip: true, // skipped because authority gated + }, + // this line is used by ignite scaffolding # autocli/tx + }, + }, + } +} \ No newline at end of file diff --git a/x/shared/module/genesis.go b/x/shared/module/genesis.go new file mode 100644 index 000000000..d028fab95 --- /dev/null +++ b/x/shared/module/genesis.go @@ -0,0 +1,24 @@ +package shared + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/pokt-network/poktroll/x/shared/keeper" + "github.com/pokt-network/poktroll/x/shared/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // this line is used by starport scaffolding # genesis/module/init + k.SetParams(ctx, genState.Params) +} + +// ExportGenesis returns the module's exported genesis. +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + + // this line is used by starport scaffolding # genesis/module/export + + return genesis +} diff --git a/x/shared/module/genesis_test.go b/x/shared/module/genesis_test.go new file mode 100644 index 000000000..8c61028b3 --- /dev/null +++ b/x/shared/module/genesis_test.go @@ -0,0 +1,31 @@ +package shared_test + +import ( + "testing" + + keepertest "github.com/pokt-network/poktroll/testutil/keeper" + "github.com/pokt-network/poktroll/testutil/nullify" + "github.com/pokt-network/poktroll/x/shared/module" + "github.com/pokt-network/poktroll/x/shared/types" + "github.com/stretchr/testify/require" +) + +func TestGenesis(t *testing.T) { + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + + // this line is used by starport scaffolding # genesis/test/state + } + + k, ctx := keepertest.SharedKeeper(t) + shared.InitGenesis(ctx, k, genesisState) + got := shared.ExportGenesis(ctx, k) + require.NotNil(t, got) + + nullify.Fill(&genesisState) + nullify.Fill(got) + + + + // this line is used by starport scaffolding # genesis/test/assert +} diff --git a/x/shared/module/module.go b/x/shared/module/module.go new file mode 100644 index 000000000..a8515e054 --- /dev/null +++ b/x/shared/module/module.go @@ -0,0 +1,221 @@ +package shared + +import ( + "context" + "encoding/json" + "fmt" + + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/log" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + + + // this line is used by starport scaffolding # 1 + + modulev1 "github.com/pokt-network/poktroll/api/poktroll/shared/module" + "github.com/pokt-network/poktroll/x/shared/keeper" + "github.com/pokt-network/poktroll/x/shared/types" + +) + +var ( + _ module.AppModuleBasic = (*AppModule)(nil) + _ module.AppModuleSimulation = (*AppModule)(nil) + _ module.HasGenesis = (*AppModule)(nil) + _ module.HasInvariants = (*AppModule)(nil) + _ module.HasConsensusVersion = (*AppModule)(nil) + + _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.HasBeginBlocker = (*AppModule)(nil) + _ appmodule.HasEndBlocker = (*AppModule)(nil) + +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface that defines the +// independent methods a Cosmos SDK module needs to implement. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the name of the module as a string. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec for the module, which is used +// to marshal and unmarshal structs to/from []byte in order to persist them in the module's KVStore. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message. +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. +// The default GenesisState need to be defined by the module developer and is primarily used for testing. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form. +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 genState.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } +} + + + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + } +} + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the module's genesis initialization. It returns no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) +} + +// ExportGenesis returns the module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion is a sequence number for state-breaking change of the module. +// It should be incremented on each consensus-breaking change introduced by the module. +// To avoid wrong/empty versions, the initial version should be set to 1. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock contains the logic that is automatically triggered at the beginning of each block. +// The begin block implementation is optional. +func (am AppModule) BeginBlock(_ context.Context) error { + return nil +} + +// EndBlock contains the logic that is automatically triggered at the end of each block. +// The end block implementation is optional. +func (am AppModule) EndBlock(_ context.Context) error { + return nil +} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} + +// ---------------------------------------------------------------------------- +// App Wiring Setup +// ---------------------------------------------------------------------------- + +func init() { + appmodule.Register( + &modulev1.Module{}, + appmodule.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + StoreService store.KVStoreService + Cdc codec.Codec + Config *modulev1.Module + Logger log.Logger + + AccountKeeper types.AccountKeeper + BankKeeper types.BankKeeper + + +} + +type ModuleOutputs struct { + depinject.Out + + SharedKeeper keeper.Keeper + Module appmodule.AppModule +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + // default to governance authority if not provided + authority := authtypes.NewModuleAddress(govtypes.ModuleName) + if in.Config.Authority != "" { + authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) + } + k := keeper.NewKeeper( + in.Cdc, + in.StoreService, + in.Logger, + authority.String(), + ) + m := NewAppModule( + in.Cdc, + k, + in.AccountKeeper, + in.BankKeeper, + ) + + return ModuleOutputs{SharedKeeper: k, Module: m} +} diff --git a/x/shared/module/simulation.go b/x/shared/module/simulation.go new file mode 100644 index 000000000..fd747b94f --- /dev/null +++ b/x/shared/module/simulation.go @@ -0,0 +1,64 @@ +package shared + +import ( + "math/rand" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" + + "github.com/pokt-network/poktroll/testutil/sample" + sharedsimulation "github.com/pokt-network/poktroll/x/shared/simulation" + "github.com/pokt-network/poktroll/x/shared/types" +) + +// avoid unused import issue +var ( + _ = sharedsimulation.FindAccount + _ = rand.Rand{} + _ = sample.AccAddress + _ = sdk.AccAddress{} + _ = simulation.MsgEntryKind +) + +const ( + // this line is used by starport scaffolding # simapp/module/const +) + +// GenerateGenesisState creates a randomized GenState of the module. +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + accs := make([]string, len(simState.Accounts)) + for i, acc := range simState.Accounts { + accs[i] = acc.Address.String() + } + sharedGenesis := types.GenesisState{ + Params: types.DefaultParams(), + // this line is used by starport scaffolding # simapp/module/genesisState + } + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&sharedGenesis) +} + +// RegisterStoreDecoder registers a decoder. +func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) {} + +// ProposalContents doesn't return any content functions for governance proposals. +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { + return nil +} + +// WeightedOperations returns the all the gov module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + operations := make([]simtypes.WeightedOperation, 0) + + // this line is used by starport scaffolding # simapp/module/operation + + return operations +} + +// ProposalMsgs returns msgs used for governance proposals for simulations. +func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { + return []simtypes.WeightedProposalMsg{ + // this line is used by starport scaffolding # simapp/module/OpMsg + } +} diff --git a/x/shared/simulation/helpers.go b/x/shared/simulation/helpers.go new file mode 100644 index 000000000..92c437c0d --- /dev/null +++ b/x/shared/simulation/helpers.go @@ -0,0 +1,15 @@ +package simulation + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +// FindAccount find a specific address from an account list +func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { + creator, err := sdk.AccAddressFromBech32(address) + if err != nil { + panic(err) + } + return simtypes.FindAccount(accs, creator) +} diff --git a/x/shared/types/codec.go b/x/shared/types/codec.go new file mode 100644 index 000000000..42406fd9c --- /dev/null +++ b/x/shared/types/codec.go @@ -0,0 +1,21 @@ +package types + +import ( + + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" + + // this line is used by starport scaffolding # 1 +) + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + // this line is used by starport scaffolding # 3 + + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgUpdateParams{}, + ) + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + + diff --git a/x/shared/types/errors.go b/x/shared/types/errors.go new file mode 100644 index 000000000..cfeab5527 --- /dev/null +++ b/x/shared/types/errors.go @@ -0,0 +1,14 @@ +package types + +// DONTCOVER + +import ( + sdkerrors "cosmossdk.io/errors" +) + +// x/shared module sentinel errors +var ( + ErrInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") + ErrSample = sdkerrors.Register(ModuleName, 1101, "sample error") + +) diff --git a/x/shared/types/expected_keepers.go b/x/shared/types/expected_keepers.go new file mode 100644 index 000000000..56479a8a8 --- /dev/null +++ b/x/shared/types/expected_keepers.go @@ -0,0 +1,29 @@ +package types + +import ( + "context" + + + sdk "github.com/cosmos/cosmos-sdk/types" + +) + + + +// AccountKeeper defines the expected interface for the Account module. +type AccountKeeper interface { + GetAccount(context.Context, sdk.AccAddress) sdk.AccountI // only used for simulation + // Methods imported from account should be defined here +} + +// BankKeeper defines the expected interface for the Bank module. +type BankKeeper interface { + SpendableCoins(context.Context, sdk.AccAddress) sdk.Coins + // Methods imported from bank should be defined here +} + +// ParamSubspace defines the expected Subspace interface for parameters. +type ParamSubspace interface { + Get(context.Context, []byte, interface{}) + Set(context.Context, []byte, interface{}) +} diff --git a/x/shared/types/genesis.go b/x/shared/types/genesis.go new file mode 100644 index 000000000..c41be0742 --- /dev/null +++ b/x/shared/types/genesis.go @@ -0,0 +1,24 @@ +package types + +import ( +// this line is used by starport scaffolding # genesis/types/import +) + +// DefaultIndex is the default global index +const DefaultIndex uint64 = 1 + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + // this line is used by starport scaffolding # genesis/types/validate + + return gs.Params.Validate() +} diff --git a/x/shared/types/genesis.pb.go b/x/shared/types/genesis.pb.go new file mode 100644 index 000000000..9042f5f0f --- /dev/null +++ b/x/shared/types/genesis.pb.go @@ -0,0 +1,324 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: poktroll/shared/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + 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 + +// GenesisState defines the shared 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"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_7a0004d2eefa4b15, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "poktroll.shared.GenesisState") +} + +func init() { proto.RegisterFile("poktroll/shared/genesis.proto", fileDescriptor_7a0004d2eefa4b15) } + +var fileDescriptor_7a0004d2eefa4b15 = []byte{ + // 211 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0xc8, 0xcf, 0x2e, + 0x29, 0xca, 0xcf, 0xc9, 0xd1, 0x2f, 0xce, 0x48, 0x2c, 0x4a, 0x4d, 0xd1, 0x4f, 0x4f, 0xcd, 0x4b, + 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0x49, 0xeb, 0x41, 0xa4, + 0xa5, 0x04, 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x8d, 0x94, 0x48, 0x7a, 0x7e, + 0x7a, 0x3e, 0x98, 0xa9, 0x0f, 0x62, 0x41, 0x45, 0x65, 0xd0, 0x0d, 0x2e, 0x48, 0x2c, 0x4a, 0xcc, + 0x85, 0x9a, 0xab, 0xe4, 0xc5, 0xc5, 0xe3, 0x0e, 0xb1, 0x28, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, + 0x8a, 0x8b, 0x0d, 0x22, 0x2f, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xae, 0x87, 0x66, 0xb1, + 0x5e, 0x00, 0x58, 0xda, 0x89, 0xf3, 0xc4, 0x3d, 0x79, 0x86, 0x15, 0xcf, 0x37, 0x68, 0x31, 0x06, + 0x41, 0x75, 0x38, 0x79, 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, 0x7e, + 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xc8, 0x3c, 0xdd, 0xbc, 0xd4, + 0x92, 0xf2, 0xfc, 0xa2, 0x6c, 0x7d, 0xb8, 0xdb, 0x2a, 0x60, 0xae, 0x2b, 0xa9, 0x2c, 0x48, 0x2d, + 0x4e, 0x62, 0x03, 0xbb, 0xce, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x99, 0x3d, 0x6f, 0xbe, 0x16, + 0x01, 0x00, 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", 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 + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/shared/types/genesis_test.go b/x/shared/types/genesis_test.go new file mode 100644 index 000000000..39f74413f --- /dev/null +++ b/x/shared/types/genesis_test.go @@ -0,0 +1,41 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/pokt-network/poktroll/x/shared/types" +) + +func TestGenesisState_Validate(t *testing.T) { + tests := []struct { + desc string + genState *types.GenesisState + valid bool + } { + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "valid genesis state", + genState: &types.GenesisState{ + + // this line is used by starport scaffolding # types/genesis/validField + }, + valid: true, + }, + // this line is used by starport scaffolding # types/genesis/testcase + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} \ No newline at end of file diff --git a/x/shared/types/keys.go b/x/shared/types/keys.go new file mode 100644 index 000000000..e85ff9ba8 --- /dev/null +++ b/x/shared/types/keys.go @@ -0,0 +1,24 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "shared" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_shared" + + +) + +var ( + ParamsKey = []byte("p_shared") +) + + + +func KeyPrefix(p string) []byte { + return []byte(p) +} diff --git a/x/shared/types/msg_update_params.go b/x/shared/types/msg_update_params.go new file mode 100644 index 000000000..e36d023de --- /dev/null +++ b/x/shared/types/msg_update_params.go @@ -0,0 +1,21 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ sdk.Msg = &MsgUpdateParams{} + +// ValidateBasic does a sanity check on the provided data. +func (m *MsgUpdateParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { + return errorsmod.Wrap(err, "invalid authority address") + } + + if err := m.Params.Validate(); err != nil { + return err + } + + return nil +} diff --git a/x/shared/types/params.go b/x/shared/types/params.go new file mode 100644 index 000000000..e06131dcf --- /dev/null +++ b/x/shared/types/params.go @@ -0,0 +1,41 @@ +package types + +import ( + + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +var _ paramtypes.ParamSet = (*Params)(nil) + + + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new Params instance +func NewParams( +) Params { + return Params{ + } +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams( + ) +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + } +} + +// Validate validates the set of params +func (p Params) Validate() error { + return nil +} + diff --git a/x/shared/types/params.pb.go b/x/shared/types/params.pb.go new file mode 100644 index 000000000..117b22945 --- /dev/null +++ b/x/shared/types/params.pb.go @@ -0,0 +1,288 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: poktroll/shared/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + 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 + +// Params defines the parameters for the module. +type Params struct { +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_ee6189c7aa51bbf5, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Params)(nil), "poktroll.shared.Params") +} + +func init() { proto.RegisterFile("poktroll/shared/params.proto", fileDescriptor_ee6189c7aa51bbf5) } + +var fileDescriptor_ee6189c7aa51bbf5 = []byte{ + // 175 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0xc8, 0xcf, 0x2e, + 0x29, 0xca, 0xcf, 0xc9, 0xd1, 0x2f, 0xce, 0x48, 0x2c, 0x4a, 0x4d, 0xd1, 0x2f, 0x48, 0x2c, 0x4a, + 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0xc9, 0xea, 0x41, 0x64, 0xa5, + 0x04, 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x8d, 0x94, 0x48, 0x7a, 0x7e, 0x7a, + 0x3e, 0x98, 0xa9, 0x0f, 0x62, 0x41, 0x44, 0x95, 0xb4, 0xb9, 0xd8, 0x02, 0xc0, 0x26, 0x59, 0x29, + 0xbe, 0x58, 0x20, 0xcf, 0xd8, 0xf5, 0x7c, 0x83, 0x96, 0x04, 0xdc, 0xaa, 0x0a, 0x98, 0x65, 0x10, + 0x25, 0x4e, 0x9e, 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, 0xa5, 0x9f, 0x9e, + 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0xd2, 0xae, 0x9b, 0x97, 0x5a, 0x52, + 0x9e, 0x5f, 0x94, 0xad, 0x8f, 0x69, 0x56, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x7a, + 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8c, 0xd0, 0x5c, 0x87, 0xd8, 0x00, 0x00, 0x00, +} + +func (this *Params) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Params) + if !ok { + that2, ok := that.(Params) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) 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 ErrIntOverflowParams + } + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/shared/types/query.pb.go b/x/shared/types/query.pb.go new file mode 100644 index 000000000..031be3044 --- /dev/null +++ b/x/shared/types/query.pb.go @@ -0,0 +1,540 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: poktroll/shared/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "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" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_6adee1148228eb7c, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6adee1148228eb7c, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "poktroll.shared.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "poktroll.shared.QueryParamsResponse") +} + +func init() { proto.RegisterFile("poktroll/shared/query.proto", fileDescriptor_6adee1148228eb7c) } + +var fileDescriptor_6adee1148228eb7c = []byte{ + // 322 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2e, 0xc8, 0xcf, 0x2e, + 0x29, 0xca, 0xcf, 0xc9, 0xd1, 0x2f, 0xce, 0x48, 0x2c, 0x4a, 0x4d, 0xd1, 0x2f, 0x2c, 0x4d, 0x2d, + 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0x49, 0xea, 0x41, 0x24, 0xa5, 0x04, + 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x8d, 0x94, 0x48, 0x7a, 0x7e, 0x7a, 0x3e, + 0x98, 0xa9, 0x0f, 0x62, 0x41, 0x45, 0x65, 0xd2, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x13, 0x0b, + 0x32, 0xf5, 0x13, 0xf3, 0xf2, 0xf2, 0x4b, 0x12, 0x4b, 0x32, 0xf3, 0xf3, 0x8a, 0xa1, 0xb2, 0x5a, + 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xfa, 0x49, 0x89, 0xc5, 0xa9, 0x10, 0x0b, 0xf5, 0xcb, 0x0c, + 0x93, 0x52, 0x4b, 0x12, 0x0d, 0xf5, 0x0b, 0x12, 0xd3, 0x33, 0xf3, 0xc0, 0x8a, 0x61, 0x26, 0xa1, + 0x3b, 0xb0, 0x20, 0xb1, 0x28, 0x31, 0x17, 0x6a, 0x92, 0x92, 0x08, 0x97, 0x50, 0x20, 0x48, 0x7f, + 0x00, 0x58, 0x30, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x44, 0x29, 0x90, 0x4b, 0x18, 0x45, 0xb4, + 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, 0xc8, 0x8a, 0x8b, 0x0d, 0xa2, 0x59, 0x82, 0x51, 0x81, 0x51, + 0x83, 0xdb, 0x48, 0x5c, 0x0f, 0xcd, 0x7f, 0x7a, 0x10, 0x0d, 0x4e, 0x9c, 0x27, 0xee, 0xc9, 0x33, + 0xac, 0x78, 0xbe, 0x41, 0x8b, 0x31, 0x08, 0xaa, 0xc3, 0xa8, 0x9b, 0x91, 0x8b, 0x15, 0x6c, 0xa6, + 0x50, 0x23, 0x23, 0x17, 0x1b, 0x44, 0x9d, 0x90, 0x32, 0x86, 0x01, 0x98, 0x8e, 0x91, 0x52, 0xc1, + 0xaf, 0x08, 0xe2, 0x36, 0x25, 0x9d, 0xa6, 0xcb, 0x4f, 0x26, 0x33, 0xa9, 0x09, 0xa9, 0xe8, 0x83, + 0x54, 0xeb, 0xe6, 0xa5, 0x96, 0x94, 0xe7, 0x17, 0x65, 0xeb, 0x63, 0xf7, 0xbc, 0x93, 0xe7, 0x89, + 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, + 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, + 0xe9, 0x25, 0xe7, 0xe7, 0xe2, 0x30, 0xa9, 0x02, 0x66, 0x56, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, + 0x1b, 0x38, 0x20, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x42, 0xa6, 0xd3, 0x74, 0x09, 0x02, + 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/poktroll.shared.Query/Params", 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) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/poktroll.shared.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "poktroll.shared.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "poktroll/shared/query.proto", +} + +func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.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 + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.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) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 *QueryParamsResponse) 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", 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.Params.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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/shared/types/query.pb.gw.go b/x/shared/types/query.pb.gw.go new file mode 100644 index 000000000..8fdaf9bed --- /dev/null +++ b/x/shared/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: poktroll/shared/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(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. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_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_Params_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_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_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_Params_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_Params_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", "shared", "params"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage +) diff --git a/x/shared/types/tx.pb.go b/x/shared/types/tx.pb.go new file mode 100644 index 000000000..1d34c4e46 --- /dev/null +++ b/x/shared/types/tx.pb.go @@ -0,0 +1,598 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: poktroll/shared/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 + +// MsgUpdateParams is the Msg/UpdateParams request type. +type MsgUpdateParams struct { + // authority is the address that controls the module (defaults to x/gov unless overwritten). + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // params defines the module parameters to update. + // + // NOTE: All parameters must be supplied. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_3f2a7564b43f4d89, []int{0} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.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 *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3f2a7564b43f4d89, []int{1} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.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 *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgUpdateParams)(nil), "poktroll.shared.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "poktroll.shared.MsgUpdateParamsResponse") +} + +func init() { proto.RegisterFile("poktroll/shared/tx.proto", fileDescriptor_3f2a7564b43f4d89) } + +var fileDescriptor_3f2a7564b43f4d89 = []byte{ + // 344 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x28, 0xc8, 0xcf, 0x2e, + 0x29, 0xca, 0xcf, 0xc9, 0xd1, 0x2f, 0xce, 0x48, 0x2c, 0x4a, 0x4d, 0xd1, 0x2f, 0xa9, 0xd0, 0x2b, + 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0xc9, 0xe8, 0x41, 0x64, 0xa4, 0x04, 0x13, 0x73, 0x33, + 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x8d, 0x94, 0x78, 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0xb1, 0x7e, + 0x6e, 0x71, 0xba, 0x7e, 0x99, 0x21, 0x88, 0x82, 0x4a, 0x48, 0x42, 0x24, 0xe2, 0xc1, 0x3c, 0x7d, + 0x08, 0x07, 0x2a, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x11, 0x07, 0xb1, 0xa0, 0xa2, 0x32, 0xe8, + 0xee, 0x28, 0x48, 0x2c, 0x4a, 0xcc, 0x85, 0xea, 0x51, 0xda, 0xcd, 0xc8, 0xc5, 0xef, 0x5b, 0x9c, + 0x1e, 0x5a, 0x90, 0x92, 0x58, 0x92, 0x1a, 0x00, 0x96, 0x11, 0x32, 0xe3, 0xe2, 0x4c, 0x2c, 0x2d, + 0xc9, 0xc8, 0x2f, 0xca, 0x2c, 0xa9, 0x94, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x74, 0x92, 0xb8, 0xb4, + 0x45, 0x57, 0x04, 0x6a, 0x99, 0x63, 0x4a, 0x4a, 0x51, 0x6a, 0x71, 0x71, 0x70, 0x49, 0x51, 0x66, + 0x5e, 0x7a, 0x10, 0x42, 0xa9, 0x90, 0x15, 0x17, 0x1b, 0xc4, 0x6c, 0x09, 0x26, 0x05, 0x46, 0x0d, + 0x6e, 0x23, 0x71, 0x3d, 0x34, 0x8f, 0xea, 0x41, 0x2c, 0x70, 0xe2, 0x3c, 0x71, 0x4f, 0x9e, 0x61, + 0xc5, 0xf3, 0x0d, 0x5a, 0x8c, 0x41, 0x50, 0x1d, 0x56, 0x26, 0x4d, 0xcf, 0x37, 0x68, 0x21, 0xcc, + 0xea, 0x7a, 0xbe, 0x41, 0x4b, 0x11, 0xee, 0xf0, 0x0a, 0x98, 0xd3, 0xd1, 0x5c, 0xaa, 0x24, 0xc9, + 0x25, 0x8e, 0x26, 0x14, 0x94, 0x5a, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0x6a, 0x94, 0xc1, 0xc5, 0xec, + 0x5b, 0x9c, 0x2e, 0x14, 0xc5, 0xc5, 0x83, 0xe2, 0x37, 0x05, 0x0c, 0x37, 0xa1, 0x19, 0x20, 0xa5, + 0x41, 0x48, 0x05, 0xcc, 0x0a, 0x29, 0xd6, 0x06, 0x90, 0x17, 0x9c, 0x3c, 0x4f, 0x3c, 0x92, 0x63, + 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, + 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x3f, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, + 0x3f, 0x57, 0x1f, 0x64, 0xa8, 0x6e, 0x5e, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0xb6, 0x3e, 0xa6, 0xcf, + 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x91, 0x62, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, + 0x86, 0xe5, 0x6f, 0x48, 0x3c, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // UpdateParams defines a (governance) operation for updating the module + // parameters. The authority defaults to the x/gov module account. + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/poktroll.shared.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // UpdateParams defines a (governance) operation for updating the module + // parameters. The authority defaults to the x/gov module account. + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/poktroll.shared.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "poktroll.shared.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "poktroll/shared/tx.proto", +} + +func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgUpdateParams) 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 ErrIntOverflowTx + } + 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: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamsResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/shared/types/types.go b/x/shared/types/types.go index 78d9ec9f9..ab1254f4c 100644 --- a/x/shared/types/types.go +++ b/x/shared/types/types.go @@ -1,3 +1 @@ package types - -// This file is in place to declare the package for dynamically generated protobufs From 4acef34e46ccec129f9d8100483bd72f010ee9e4 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 23 May 2024 09:58:29 +0200 Subject: [PATCH 37/61] fix: linting --- app/app.go | 6 +-- app/app_config.go | 15 +++--- testutil/keeper/shared.go | 8 ++-- x/application/keeper/query_application.go | 3 +- x/application/module/tx.go | 1 + x/shared/keeper/keeper.go | 18 +++---- x/shared/keeper/msg_server_test.go | 8 ++-- x/shared/keeper/msg_update_params.go | 2 +- x/shared/keeper/msg_update_params_test.go | 2 +- x/shared/keeper/params.go | 3 +- x/shared/keeper/params_test.go | 4 +- x/shared/keeper/query_params.go | 2 +- x/shared/keeper/query_params_test.go | 4 +- x/shared/module/autocli.go | 6 +-- x/shared/module/genesis.go | 6 +-- x/shared/module/genesis_test.go | 11 ++--- x/shared/module/module.go | 33 ++++++------- x/shared/module/simulation.go | 6 +-- x/shared/types/codec.go | 4 -- x/shared/types/errors.go | 3 +- x/shared/types/expected_keepers.go | 12 ++--- x/shared/types/genesis_test.go | 57 ++++++++++++----------- x/shared/types/keys.go | 6 +-- x/shared/types/msg_update_params.go | 2 +- x/shared/types/params.go | 17 ++----- x/tokenomics/simulation/update_param.go | 1 + 26 files changed, 104 insertions(+), 136 deletions(-) diff --git a/app/app.go b/app/app.go index 59170ffcd..880e1ba26 100644 --- a/app/app.go +++ b/app/app.go @@ -2,7 +2,7 @@ package app import ( sharedmodulekeeper "github.com/pokt-network/poktroll/x/shared/keeper" -// this line is used by starport scaffolding # stargate/app/moduleImport + // this line is used by starport scaffolding # stargate/app/moduleImport "io" "os" "path/filepath" @@ -132,8 +132,8 @@ type App struct { SessionKeeper sessionmodulekeeper.Keeper ProofKeeper proofmodulekeeper.Keeper TokenomicsKeeper tokenomicsmodulekeeper.Keeper - SharedKeeper sharedmodulekeeper.Keeper -// this line is used by starport scaffolding # stargate/app/keeperDeclaration + SharedKeeper sharedmodulekeeper.Keeper + // this line is used by starport scaffolding # stargate/app/keeperDeclaration // simulation manager sm *module.SimulationManager diff --git a/app/app_config.go b/app/app_config.go index c7e1437d8..de23379e8 100644 --- a/app/app_config.go +++ b/app/app_config.go @@ -2,9 +2,10 @@ package app import ( sharedmodulev1 "github.com/pokt-network/poktroll/api/poktroll/shared/module" -_ "github.com/pokt-network/poktroll/x/shared/module" // import for side-effects -sharedmoduletypes "github.com/pokt-network/poktroll/x/shared/types" -// this line is used by starport scaffolding # stargate/app/moduleImport + _ "github.com/pokt-network/poktroll/x/shared/module" // import for side-effects + sharedmoduletypes "github.com/pokt-network/poktroll/x/shared/types" + + // this line is used by starport scaffolding # stargate/app/moduleImport "time" runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" @@ -140,7 +141,7 @@ var ( proofmoduletypes.ModuleName, tokenomicsmoduletypes.ModuleName, sharedmoduletypes.ModuleName, -// this line is used by starport scaffolding # stargate/app/initGenesis + // this line is used by starport scaffolding # stargate/app/initGenesis } // During begin block slashing happens after distr.BeginBlocker so that @@ -172,7 +173,7 @@ var ( proofmoduletypes.ModuleName, tokenomicsmoduletypes.ModuleName, sharedmoduletypes.ModuleName, -// this line is used by starport scaffolding # stargate/app/beginBlockers + // this line is used by starport scaffolding # stargate/app/beginBlockers } endBlockers = []string{ @@ -198,7 +199,7 @@ var ( proofmoduletypes.ModuleName, tokenomicsmoduletypes.ModuleName, sharedmoduletypes.ModuleName, -// this line is used by starport scaffolding # stargate/app/endBlockers + // this line is used by starport scaffolding # stargate/app/endBlockers } preBlockers = []string{ @@ -385,7 +386,7 @@ var ( Name: sharedmoduletypes.ModuleName, Config: appconfig.WrapAny(&sharedmodulev1.Module{}), }, -// this line is used by starport scaffolding # stargate/app/moduleConfig + // this line is used by starport scaffolding # stargate/app/moduleConfig }, }) ) diff --git a/testutil/keeper/shared.go b/testutil/keeper/shared.go index e7c780a5a..514025779 100644 --- a/testutil/keeper/shared.go +++ b/testutil/keeper/shared.go @@ -34,10 +34,10 @@ func SharedKeeper(t testing.TB) (keeper.Keeper, sdk.Context) { authority := authtypes.NewModuleAddress(govtypes.ModuleName) k := keeper.NewKeeper( - cdc, - runtime.NewKVStoreService(storeKey), - log.NewNopLogger(), - authority.String(), + cdc, + runtime.NewKVStoreService(storeKey), + log.NewNopLogger(), + authority.String(), ) ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger()) diff --git a/x/application/keeper/query_application.go b/x/application/keeper/query_application.go index af002bd19..446449d29 100644 --- a/x/application/keeper/query_application.go +++ b/x/application/keeper/query_application.go @@ -6,9 +6,10 @@ import ( "cosmossdk.io/store/prefix" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/pokt-network/poktroll/x/application/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/pokt-network/poktroll/x/application/types" ) func (k Keeper) AllApplications(ctx context.Context, req *types.QueryAllApplicationsRequest) (*types.QueryAllApplicationsResponse, error) { diff --git a/x/application/module/tx.go b/x/application/module/tx.go index 0d3edf22d..314b8bbbe 100644 --- a/x/application/module/tx.go +++ b/x/application/module/tx.go @@ -6,6 +6,7 @@ import ( "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" + "github.com/pokt-network/poktroll/x/application/types" ) diff --git a/x/shared/keeper/keeper.go b/x/shared/keeper/keeper.go index 392e4abd0..13075598b 100644 --- a/x/shared/keeper/keeper.go +++ b/x/shared/keeper/keeper.go @@ -7,7 +7,6 @@ import ( "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/pokt-network/poktroll/x/shared/types" ) @@ -18,20 +17,18 @@ type ( storeService store.KVStoreService logger log.Logger - // the address capable of executing a MsgUpdateParams message. Typically, this - // should be the x/gov module account. - authority string - - + // the address capable of executing a MsgUpdateParams message. Typically, this + // should be the x/gov module account. + authority string } ) func NewKeeper( - cdc codec.BinaryCodec, + cdc codec.BinaryCodec, storeService store.KVStoreService, - logger log.Logger, + logger log.Logger, authority string, - + ) Keeper { if _, err := sdk.AccAddressFromBech32(authority); err != nil { panic(fmt.Sprintf("invalid authority address: %s", authority)) @@ -42,7 +39,6 @@ func NewKeeper( storeService: storeService, authority: authority, logger: logger, - } } @@ -55,5 +51,3 @@ func (k Keeper) GetAuthority() string { func (k Keeper) Logger() log.Logger { return k.logger.With("module", fmt.Sprintf("x/%s", types.ModuleName)) } - - diff --git a/x/shared/keeper/msg_server_test.go b/x/shared/keeper/msg_server_test.go index a9d05fe66..69d6f0597 100644 --- a/x/shared/keeper/msg_server_test.go +++ b/x/shared/keeper/msg_server_test.go @@ -6,9 +6,9 @@ import ( "github.com/stretchr/testify/require" - keepertest "github.com/pokt-network/poktroll/testutil/keeper" - "github.com/pokt-network/poktroll/x/shared/types" - "github.com/pokt-network/poktroll/x/shared/keeper" + keepertest "github.com/pokt-network/poktroll/testutil/keeper" + "github.com/pokt-network/poktroll/x/shared/keeper" + "github.com/pokt-network/poktroll/x/shared/types" ) func setupMsgServer(t testing.TB) (keeper.Keeper, types.MsgServer, context.Context) { @@ -21,4 +21,4 @@ func TestMsgServer(t *testing.T) { require.NotNil(t, ms) require.NotNil(t, ctx) require.NotEmpty(t, k) -} \ No newline at end of file +} diff --git a/x/shared/keeper/msg_update_params.go b/x/shared/keeper/msg_update_params.go index f5582e9e9..7cb13fb2c 100644 --- a/x/shared/keeper/msg_update_params.go +++ b/x/shared/keeper/msg_update_params.go @@ -6,7 +6,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/pokt-network/poktroll/x/shared/types" + "github.com/pokt-network/poktroll/x/shared/types" ) func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { diff --git a/x/shared/keeper/msg_update_params_test.go b/x/shared/keeper/msg_update_params_test.go index 200574b1e..570d76d5c 100644 --- a/x/shared/keeper/msg_update_params_test.go +++ b/x/shared/keeper/msg_update_params_test.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/pokt-network/poktroll/x/shared/types" + "github.com/pokt-network/poktroll/x/shared/types" ) func TestMsgUpdateParams(t *testing.T) { diff --git a/x/shared/keeper/params.go b/x/shared/keeper/params.go index 7315fa104..1268768a8 100644 --- a/x/shared/keeper/params.go +++ b/x/shared/keeper/params.go @@ -5,10 +5,9 @@ import ( "github.com/cosmos/cosmos-sdk/runtime" - "github.com/pokt-network/poktroll/x/shared/types" + "github.com/pokt-network/poktroll/x/shared/types" ) - // GetParams get all parameters as types.Params func (k Keeper) GetParams(ctx context.Context) (params types.Params) { store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) diff --git a/x/shared/keeper/params_test.go b/x/shared/keeper/params_test.go index cc7e9ed0c..601e03eee 100644 --- a/x/shared/keeper/params_test.go +++ b/x/shared/keeper/params_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/require" - keepertest "github.com/pokt-network/poktroll/testutil/keeper" - "github.com/pokt-network/poktroll/x/shared/types" + keepertest "github.com/pokt-network/poktroll/testutil/keeper" + "github.com/pokt-network/poktroll/x/shared/types" ) func TestGetParams(t *testing.T) { diff --git a/x/shared/keeper/query_params.go b/x/shared/keeper/query_params.go index 19ce236a5..e02247587 100644 --- a/x/shared/keeper/query_params.go +++ b/x/shared/keeper/query_params.go @@ -7,7 +7,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/pokt-network/poktroll/x/shared/types" + "github.com/pokt-network/poktroll/x/shared/types" ) func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { diff --git a/x/shared/keeper/query_params_test.go b/x/shared/keeper/query_params_test.go index 4013514fd..0752ae03b 100644 --- a/x/shared/keeper/query_params_test.go +++ b/x/shared/keeper/query_params_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/require" - keepertest "github.com/pokt-network/poktroll/testutil/keeper" - "github.com/pokt-network/poktroll/x/shared/types" + keepertest "github.com/pokt-network/poktroll/testutil/keeper" + "github.com/pokt-network/poktroll/x/shared/types" ) func TestParamsQuery(t *testing.T) { diff --git a/x/shared/module/autocli.go b/x/shared/module/autocli.go index deb554498..457ff7eff 100644 --- a/x/shared/module/autocli.go +++ b/x/shared/module/autocli.go @@ -21,15 +21,15 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, }, Tx: &autocliv1.ServiceCommandDescriptor{ - Service: modulev1.Msg_ServiceDesc.ServiceName, + Service: modulev1.Msg_ServiceDesc.ServiceName, EnhanceCustomCommand: true, // only required if you want to use the custom command RpcCommandOptions: []*autocliv1.RpcCommandOptions{ { RpcMethod: "UpdateParams", - Skip: true, // skipped because authority gated + Skip: true, // skipped because authority gated }, // this line is used by ignite scaffolding # autocli/tx }, }, } -} \ No newline at end of file +} diff --git a/x/shared/module/genesis.go b/x/shared/module/genesis.go index d028fab95..d1ef9a3bf 100644 --- a/x/shared/module/genesis.go +++ b/x/shared/module/genesis.go @@ -9,7 +9,7 @@ import ( // InitGenesis initializes the module's state from a provided genesis state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { - // this line is used by starport scaffolding # genesis/module/init + // this line is used by starport scaffolding # genesis/module/init k.SetParams(ctx, genState.Params) } @@ -18,7 +18,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.Params = k.GetParams(ctx) - // this line is used by starport scaffolding # genesis/module/export + // this line is used by starport scaffolding # genesis/module/export - return genesis + return genesis } diff --git a/x/shared/module/genesis_test.go b/x/shared/module/genesis_test.go index 8c61028b3..0dbefcb90 100644 --- a/x/shared/module/genesis_test.go +++ b/x/shared/module/genesis_test.go @@ -3,17 +3,18 @@ package shared_test import ( "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/shared/module" + shared "github.com/pokt-network/poktroll/x/shared/module" "github.com/pokt-network/poktroll/x/shared/types" - "github.com/stretchr/testify/require" ) func TestGenesis(t *testing.T) { genesisState := types.GenesisState{ - Params: types.DefaultParams(), - + Params: types.DefaultParams(), + // this line is used by starport scaffolding # genesis/test/state } @@ -25,7 +26,5 @@ func TestGenesis(t *testing.T) { nullify.Fill(&genesisState) nullify.Fill(got) - - // this line is used by starport scaffolding # genesis/test/assert } diff --git a/x/shared/module/module.go b/x/shared/module/module.go index a8515e054..18f3b9c53 100644 --- a/x/shared/module/module.go +++ b/x/shared/module/module.go @@ -5,8 +5,8 @@ import ( "encoding/json" "fmt" - "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/store" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/store" "cosmossdk.io/depinject" "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/client" @@ -17,14 +17,12 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/grpc-ecosystem/grpc-gateway/runtime" - // this line is used by starport scaffolding # 1 modulev1 "github.com/pokt-network/poktroll/api/poktroll/shared/module" "github.com/pokt-network/poktroll/x/shared/keeper" "github.com/pokt-network/poktroll/x/shared/types" - ) var ( @@ -37,7 +35,6 @@ var ( _ appmodule.AppModule = (*AppModule)(nil) _ appmodule.HasBeginBlocker = (*AppModule)(nil) _ appmodule.HasEndBlocker = (*AppModule)(nil) - ) // ---------------------------------------------------------------------------- @@ -90,8 +87,6 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r } } - - // ---------------------------------------------------------------------------- // AppModule // ---------------------------------------------------------------------------- @@ -121,8 +116,8 @@ func NewAppModule( // RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) - types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) } // RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) @@ -172,7 +167,7 @@ func (am AppModule) IsAppModule() {} func init() { appmodule.Register( - &modulev1.Module{}, + &modulev1.Module{}, appmodule.Provide(ProvideModule), ) } @@ -187,15 +182,13 @@ type ModuleInputs struct { AccountKeeper types.AccountKeeper BankKeeper types.BankKeeper - - } type ModuleOutputs struct { depinject.Out SharedKeeper keeper.Keeper - Module appmodule.AppModule + Module appmodule.AppModule } func ProvideModule(in ModuleInputs) ModuleOutputs { @@ -205,16 +198,16 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) } k := keeper.NewKeeper( - in.Cdc, + in.Cdc, in.StoreService, - in.Logger, - authority.String(), + in.Logger, + authority.String(), ) m := NewAppModule( - in.Cdc, - k, - in.AccountKeeper, - in.BankKeeper, + in.Cdc, + k, + in.AccountKeeper, + in.BankKeeper, ) return ModuleOutputs{SharedKeeper: k, Module: m} diff --git a/x/shared/module/simulation.go b/x/shared/module/simulation.go index fd747b94f..8d195231d 100644 --- a/x/shared/module/simulation.go +++ b/x/shared/module/simulation.go @@ -23,7 +23,7 @@ var ( ) const ( - // this line is used by starport scaffolding # simapp/module/const +// this line is used by starport scaffolding # simapp/module/const ) // GenerateGenesisState creates a randomized GenState of the module. @@ -33,7 +33,7 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { accs[i] = acc.Address.String() } sharedGenesis := types.GenesisState{ - Params: types.DefaultParams(), + Params: types.DefaultParams(), // this line is used by starport scaffolding # simapp/module/genesisState } simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&sharedGenesis) @@ -59,6 +59,6 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp // ProposalMsgs returns msgs used for governance proposals for simulations. func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ - // this line is used by starport scaffolding # simapp/module/OpMsg + // this line is used by starport scaffolding # simapp/module/OpMsg } } diff --git a/x/shared/types/codec.go b/x/shared/types/codec.go index 42406fd9c..ac5526374 100644 --- a/x/shared/types/codec.go +++ b/x/shared/types/codec.go @@ -1,11 +1,9 @@ package types import ( - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" - // this line is used by starport scaffolding # 1 ) @@ -17,5 +15,3 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } - - diff --git a/x/shared/types/errors.go b/x/shared/types/errors.go index cfeab5527..01f55fb4d 100644 --- a/x/shared/types/errors.go +++ b/x/shared/types/errors.go @@ -9,6 +9,5 @@ import ( // x/shared module sentinel errors var ( ErrInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") - ErrSample = sdkerrors.Register(ModuleName, 1101, "sample error") - + ErrSample = sdkerrors.Register(ModuleName, 1101, "sample error") ) diff --git a/x/shared/types/expected_keepers.go b/x/shared/types/expected_keepers.go index 56479a8a8..4a50d01a9 100644 --- a/x/shared/types/expected_keepers.go +++ b/x/shared/types/expected_keepers.go @@ -3,23 +3,19 @@ package types import ( "context" - sdk "github.com/cosmos/cosmos-sdk/types" - ) - - // AccountKeeper defines the expected interface for the Account module. type AccountKeeper interface { - GetAccount(context.Context, sdk.AccAddress) sdk.AccountI // only used for simulation - // Methods imported from account should be defined here + GetAccount(context.Context, sdk.AccAddress) sdk.AccountI // only used for simulation + // Methods imported from account should be defined here } // BankKeeper defines the expected interface for the Bank module. type BankKeeper interface { - SpendableCoins(context.Context, sdk.AccAddress) sdk.Coins - // Methods imported from bank should be defined here + SpendableCoins(context.Context, sdk.AccAddress) sdk.Coins + // Methods imported from bank should be defined here } // ParamSubspace defines the expected Subspace interface for parameters. diff --git a/x/shared/types/genesis_test.go b/x/shared/types/genesis_test.go index 39f74413f..0fa73fbb1 100644 --- a/x/shared/types/genesis_test.go +++ b/x/shared/types/genesis_test.go @@ -4,38 +4,39 @@ import ( "testing" "github.com/stretchr/testify/require" + "github.com/pokt-network/poktroll/x/shared/types" ) func TestGenesisState_Validate(t *testing.T) { - tests := []struct { - desc string - genState *types.GenesisState - valid bool - } { - { - desc: "default is valid", - genState: types.DefaultGenesis(), - valid: true, - }, - { - desc: "valid genesis state", - genState: &types.GenesisState{ - - // this line is used by starport scaffolding # types/genesis/validField - }, - valid: true, - }, - // this line is used by starport scaffolding # types/genesis/testcase + tests := []struct { + desc string + genState *types.GenesisState + valid bool + }{ + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "valid genesis state", + genState: &types.GenesisState{ + + // this line is used by starport scaffolding # types/genesis/validField + }, + valid: true, + }, + // this line is used by starport scaffolding # types/genesis/testcase } for _, tc := range tests { t.Run(tc.desc, func(t *testing.T) { - err := tc.genState.Validate() - if tc.valid { - require.NoError(t, err) - } else { - require.Error(t, err) - } - }) - } -} \ No newline at end of file + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/shared/types/keys.go b/x/shared/types/keys.go index e85ff9ba8..ca525b6f3 100644 --- a/x/shared/types/keys.go +++ b/x/shared/types/keys.go @@ -9,16 +9,12 @@ const ( // MemStoreKey defines the in-memory store key MemStoreKey = "mem_shared" - - ) var ( ParamsKey = []byte("p_shared") ) - - func KeyPrefix(p string) []byte { - return []byte(p) + return []byte(p) } diff --git a/x/shared/types/msg_update_params.go b/x/shared/types/msg_update_params.go index e36d023de..aeed4a633 100644 --- a/x/shared/types/msg_update_params.go +++ b/x/shared/types/msg_update_params.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -var _ sdk.Msg = &MsgUpdateParams{} +var _ sdk.Msg = (*MsgUpdateParams)(nil) // ValidateBasic does a sanity check on the provided data. func (m *MsgUpdateParams) ValidateBasic() error { diff --git a/x/shared/types/params.go b/x/shared/types/params.go index e06131dcf..4f3215e35 100644 --- a/x/shared/types/params.go +++ b/x/shared/types/params.go @@ -1,41 +1,32 @@ package types import ( - - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) var _ paramtypes.ParamSet = (*Params)(nil) - - // ParamKeyTable the param key table for launch module func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } // NewParams creates a new Params instance -func NewParams( -) Params { - return Params{ - } +func NewParams() Params { + return Params{} } // DefaultParams returns a default set of parameters func DefaultParams() Params { - return NewParams( - ) + return NewParams() } // ParamSetPairs get the params.ParamSet func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{ - } + return paramtypes.ParamSetPairs{} } // Validate validates the set of params func (p Params) Validate() error { return nil } - diff --git a/x/tokenomics/simulation/update_param.go b/x/tokenomics/simulation/update_param.go index 13bd57880..fbf4bd7a6 100644 --- a/x/tokenomics/simulation/update_param.go +++ b/x/tokenomics/simulation/update_param.go @@ -6,6 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/pokt-network/poktroll/x/tokenomics/keeper" "github.com/pokt-network/poktroll/x/tokenomics/types" ) From e084a3b5ad91fdfaf6fd0cabd177990cd5932ff5 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 23 May 2024 10:19:46 +0200 Subject: [PATCH 38/61] refactor: move `num_blocks_per_session` param to shared module --- api/poktroll/session/params.pulsar.go | 94 ++++--------------- api/poktroll/shared/params.pulsar.go | 94 +++++++++++++++---- e2e/tests/update_params.feature | 10 +- proto/poktroll/session/params.proto | 2 - proto/poktroll/shared/params.proto | 2 +- .../authz/dao_genesis_authorizations.json | 9 ++ x/session/keeper/msg_update_params.go | 1 + x/session/keeper/msg_update_params_test.go | 2 +- x/session/module/genesis_test.go | 5 +- x/session/types/errors.go | 2 - x/session/types/params.go | 45 +-------- x/session/types/params.pb.go | 58 ++---------- x/shared/keeper/msg_update_params.go | 4 + x/shared/keeper/msg_update_params_test.go | 9 +- x/shared/types/errors.go | 5 +- x/shared/types/genesis.go | 12 +-- x/shared/types/genesis_test.go | 5 +- x/shared/types/msg_update_params.go | 2 +- x/shared/types/params.go | 45 ++++++++- x/shared/types/params.pb.go | 58 ++++++++++-- x/{session => shared}/types/params_test.go | 0 21 files changed, 236 insertions(+), 228 deletions(-) rename x/{session => shared}/types/params_test.go (100%) diff --git a/api/poktroll/session/params.pulsar.go b/api/poktroll/session/params.pulsar.go index 39d1e8a86..c9ea81482 100644 --- a/api/poktroll/session/params.pulsar.go +++ b/api/poktroll/session/params.pulsar.go @@ -15,14 +15,12 @@ import ( ) var ( - md_Params protoreflect.MessageDescriptor - fd_Params_num_blocks_per_session protoreflect.FieldDescriptor + md_Params protoreflect.MessageDescriptor ) func init() { file_poktroll_session_params_proto_init() md_Params = File_poktroll_session_params_proto.Messages().ByName("Params") - fd_Params_num_blocks_per_session = md_Params.Fields().ByName("num_blocks_per_session") } var _ protoreflect.Message = (*fastReflection_Params)(nil) @@ -90,12 +88,6 @@ func (x *fastReflection_Params) Interface() protoreflect.ProtoMessage { // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_Params) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.NumBlocksPerSession != uint64(0) { - value := protoreflect.ValueOfUint64(x.NumBlocksPerSession) - if !f(fd_Params_num_blocks_per_session, value) { - return - } - } } // Has reports whether a field is populated. @@ -111,8 +103,6 @@ func (x *fastReflection_Params) Range(f func(protoreflect.FieldDescriptor, proto // a repeated field is populated if it is non-empty. func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.session.Params.num_blocks_per_session": - return x.NumBlocksPerSession != uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Params")) @@ -129,8 +119,6 @@ func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool { // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Params) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.session.Params.num_blocks_per_session": - x.NumBlocksPerSession = uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Params")) @@ -147,9 +135,6 @@ func (x *fastReflection_Params) Clear(fd protoreflect.FieldDescriptor) { // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "poktroll.session.Params.num_blocks_per_session": - value := x.NumBlocksPerSession - return protoreflect.ValueOfUint64(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Params")) @@ -170,8 +155,6 @@ func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) pro // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Params) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "poktroll.session.Params.num_blocks_per_session": - x.NumBlocksPerSession = value.Uint() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Params")) @@ -192,8 +175,6 @@ func (x *fastReflection_Params) Set(fd protoreflect.FieldDescriptor, value proto // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Params) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.session.Params.num_blocks_per_session": - panic(fmt.Errorf("field num_blocks_per_session of message poktroll.session.Params is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Params")) @@ -207,8 +188,6 @@ func (x *fastReflection_Params) Mutable(fd protoreflect.FieldDescriptor) protore // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_Params) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.session.Params.num_blocks_per_session": - return protoreflect.ValueOfUint64(uint64(0)) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Params")) @@ -278,9 +257,6 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { var n int var l int _ = l - if x.NumBlocksPerSession != 0 { - n += 1 + runtime.Sov(uint64(x.NumBlocksPerSession)) - } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -310,11 +286,6 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if x.NumBlocksPerSession != 0 { - i = runtime.EncodeVarint(dAtA, i, uint64(x.NumBlocksPerSession)) - i-- - dAtA[i] = 0x8 - } if input.Buf != nil { input.Buf = append(input.Buf, dAtA...) } else { @@ -364,25 +335,6 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field NumBlocksPerSession", wireType) - } - x.NumBlocksPerSession = 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.NumBlocksPerSession |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -436,8 +388,6 @@ type Params struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - - NumBlocksPerSession uint64 `protobuf:"varint,1,opt,name=num_blocks_per_session,json=numBlocksPerSession,proto3" json:"num_blocks_per_session,omitempty"` } func (x *Params) Reset() { @@ -460,13 +410,6 @@ func (*Params) Descriptor() ([]byte, []int) { return file_poktroll_session_params_proto_rawDescGZIP(), []int{0} } -func (x *Params) GetNumBlocksPerSession() uint64 { - if x != nil { - return x.NumBlocksPerSession - } - return 0 -} - var File_poktroll_session_params_proto protoreflect.FileDescriptor var file_poktroll_session_params_proto_rawDesc = []byte{ @@ -475,26 +418,21 @@ var file_poktroll_session_params_proto_rawDesc = []byte{ 0x10, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x1a, 0x11, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x6d, 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, 0x22, 0x7d, 0x0a, 0x06, 0x50, 0x61, - 0x72, 0x61, 0x6d, 0x73, 0x12, 0x4f, 0x0a, 0x16, 0x6e, 0x75, 0x6d, 0x5f, 0x62, 0x6c, 0x6f, 0x63, - 0x6b, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x04, 0x42, 0x1a, 0xea, 0xde, 0x1f, 0x16, 0x6e, 0x75, 0x6d, 0x5f, 0x62, 0x6c, - 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x52, 0x13, 0x6e, 0x75, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x22, 0xe8, 0xa0, 0x1f, 0x01, 0x8a, 0xe7, 0xb0, 0x2a, 0x19, - 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x78, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x2f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xa7, 0x01, 0x0a, 0x14, 0x63, 0x6f, - 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x42, 0x0b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x21, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, - 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x10, 0x50, 0x6f, 0x6b, - 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xca, 0x02, 0x10, - 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0xe2, 0x02, 0x1c, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, - 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2c, 0x0a, 0x06, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x3a, 0x22, 0xe8, 0xa0, 0x1f, 0x01, 0x8a, 0xe7, 0xb0, 0x2a, 0x19, 0x70, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x78, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x2f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xa7, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, + 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x42, 0x0b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, + 0x5a, 0x21, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, + 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, + 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xca, 0x02, 0x10, 0x50, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xe2, + 0x02, 0x1c, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, + 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/poktroll/shared/params.pulsar.go b/api/poktroll/shared/params.pulsar.go index 672581c0a..bf24f26b3 100644 --- a/api/poktroll/shared/params.pulsar.go +++ b/api/poktroll/shared/params.pulsar.go @@ -15,12 +15,14 @@ import ( ) var ( - md_Params protoreflect.MessageDescriptor + md_Params protoreflect.MessageDescriptor + fd_Params_num_blocks_per_session protoreflect.FieldDescriptor ) func init() { file_poktroll_shared_params_proto_init() md_Params = File_poktroll_shared_params_proto.Messages().ByName("Params") + fd_Params_num_blocks_per_session = md_Params.Fields().ByName("num_blocks_per_session") } var _ protoreflect.Message = (*fastReflection_Params)(nil) @@ -88,6 +90,12 @@ func (x *fastReflection_Params) Interface() protoreflect.ProtoMessage { // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_Params) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.NumBlocksPerSession != uint64(0) { + value := protoreflect.ValueOfUint64(x.NumBlocksPerSession) + if !f(fd_Params_num_blocks_per_session, value) { + return + } + } } // Has reports whether a field is populated. @@ -103,6 +111,8 @@ func (x *fastReflection_Params) Range(f func(protoreflect.FieldDescriptor, proto // a repeated field is populated if it is non-empty. func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { + case "poktroll.shared.Params.num_blocks_per_session": + return x.NumBlocksPerSession != uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.Params")) @@ -119,6 +129,8 @@ func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool { // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Params) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { + case "poktroll.shared.Params.num_blocks_per_session": + x.NumBlocksPerSession = uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.Params")) @@ -135,6 +147,9 @@ func (x *fastReflection_Params) Clear(fd protoreflect.FieldDescriptor) { // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { + case "poktroll.shared.Params.num_blocks_per_session": + value := x.NumBlocksPerSession + return protoreflect.ValueOfUint64(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.Params")) @@ -155,6 +170,8 @@ func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) pro // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Params) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { + case "poktroll.shared.Params.num_blocks_per_session": + x.NumBlocksPerSession = value.Uint() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.Params")) @@ -175,6 +192,8 @@ func (x *fastReflection_Params) Set(fd protoreflect.FieldDescriptor, value proto // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Params) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "poktroll.shared.Params.num_blocks_per_session": + panic(fmt.Errorf("field num_blocks_per_session of message poktroll.shared.Params is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.Params")) @@ -188,6 +207,8 @@ func (x *fastReflection_Params) Mutable(fd protoreflect.FieldDescriptor) protore // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_Params) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "poktroll.shared.Params.num_blocks_per_session": + return protoreflect.ValueOfUint64(uint64(0)) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.Params")) @@ -257,6 +278,9 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { var n int var l int _ = l + if x.NumBlocksPerSession != 0 { + n += 1 + runtime.Sov(uint64(x.NumBlocksPerSession)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -286,6 +310,11 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if x.NumBlocksPerSession != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.NumBlocksPerSession)) + i-- + dAtA[i] = 0x8 + } if input.Buf != nil { input.Buf = append(input.Buf, dAtA...) } else { @@ -335,6 +364,25 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field NumBlocksPerSession", wireType) + } + x.NumBlocksPerSession = 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.NumBlocksPerSession |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -388,6 +436,8 @@ type Params struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + NumBlocksPerSession uint64 `protobuf:"varint,1,opt,name=num_blocks_per_session,json=numBlocksPerSession,proto3" json:"num_blocks_per_session,omitempty"` } func (x *Params) Reset() { @@ -410,6 +460,13 @@ func (*Params) Descriptor() ([]byte, []int) { return file_poktroll_shared_params_proto_rawDescGZIP(), []int{0} } +func (x *Params) GetNumBlocksPerSession() uint64 { + if x != nil { + return x.NumBlocksPerSession + } + return 0 +} + var File_poktroll_shared_params_proto protoreflect.FileDescriptor var file_poktroll_shared_params_proto_rawDesc = []byte{ @@ -418,21 +475,26 @@ var file_poktroll_shared_params_proto_rawDesc = []byte{ 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x1a, 0x11, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x6d, 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, 0x22, 0x2b, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, - 0x6d, 0x73, 0x3a, 0x21, 0xe8, 0xa0, 0x1f, 0x01, 0x8a, 0xe7, 0xb0, 0x2a, 0x18, 0x70, 0x6f, 0x6b, - 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x78, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2f, 0x50, - 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xa1, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, - 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x42, 0x0b, 0x50, - 0x61, 0x72, 0x61, 0x6d, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x20, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0xa2, 0x02, - 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, - 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0xca, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, - 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0xe2, 0x02, 0x1b, 0x50, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, - 0x6c, 0x3a, 0x3a, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x7c, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x73, 0x12, 0x4f, 0x0a, 0x16, 0x6e, 0x75, 0x6d, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, + 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x42, 0x1a, 0xea, 0xde, 0x1f, 0x16, 0x6e, 0x75, 0x6d, 0x5f, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x13, + 0x6e, 0x75, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x3a, 0x21, 0xe8, 0xa0, 0x1f, 0x01, 0x8a, 0xe7, 0xb0, 0x2a, 0x18, 0x70, 0x6f, + 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x78, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2f, + 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xa1, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x70, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x42, 0x0b, + 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x20, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0xa2, + 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x2e, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0xca, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0xe2, 0x02, 0x1b, 0x50, 0x6f, 0x6b, 0x74, + 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x5c, 0x47, 0x50, 0x42, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/e2e/tests/update_params.feature b/e2e/tests/update_params.feature index e1acb3a06..b7a43547d 100644 --- a/e2e/tests/update_params.feature +++ b/e2e/tests/update_params.feature @@ -34,14 +34,14 @@ Feature: Params Namespace # NB: If you are reading this and the proof module has parameters # that are not being updated in this test, please update the test. - Scenario: An authorized user updates all "session" module params + Scenario: An authorized user updates all "shared" module params Given the user has the pocketd binary installed - And all "session" 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.session.MsgUpdateParams" message exists - When the "pnf" account sends an authz exec message to update all "session" module params + And all "shared" 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.shared.MsgUpdateParams" message exists + When the "pnf" account sends an authz exec message to update all "shared" module params | name | value | type | | num_blocks_per_session | 10 | int64 | - Then all "session" module params should be updated + Then all "shared" module params should be updated # NB: If you are reading this and any module has parameters that # are not being updated in this test, please update the test. diff --git a/proto/poktroll/session/params.proto b/proto/poktroll/session/params.proto index 33f7c0077..cbe3559dc 100644 --- a/proto/poktroll/session/params.proto +++ b/proto/poktroll/session/params.proto @@ -10,6 +10,4 @@ import "gogoproto/gogo.proto"; message Params { option (amino.name) = "poktroll/x/session/Params"; option (gogoproto.equal) = true; - - uint64 num_blocks_per_session = 1 [(gogoproto.jsontag) = "num_blocks_per_session"]; } \ No newline at end of file diff --git a/proto/poktroll/shared/params.proto b/proto/poktroll/shared/params.proto index b02eb8f55..adeb68749 100644 --- a/proto/poktroll/shared/params.proto +++ b/proto/poktroll/shared/params.proto @@ -11,5 +11,5 @@ message Params { option (amino.name) = "poktroll/x/shared/Params"; option (gogoproto.equal) = true; - + uint64 num_blocks_per_session = 1 [(gogoproto.jsontag) = "num_blocks_per_session"]; } \ No newline at end of file diff --git a/tools/scripts/authz/dao_genesis_authorizations.json b/tools/scripts/authz/dao_genesis_authorizations.json index 72b68d552..1982c2777 100644 --- a/tools/scripts/authz/dao_genesis_authorizations.json +++ b/tools/scripts/authz/dao_genesis_authorizations.json @@ -62,6 +62,15 @@ }, "expiration": "2500-01-01T00:00:00Z" }, + { + "granter": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", + "grantee": "pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw", + "authorization": { + "@type": "\/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "\/poktroll.shared.MsgUpdateParams" + }, + "expiration": "2500-01-01T00:00:00Z" + }, { "granter": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", "grantee": "pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw", diff --git a/x/session/keeper/msg_update_params.go b/x/session/keeper/msg_update_params.go index dfe0fea52..84a5debfa 100644 --- a/x/session/keeper/msg_update_params.go +++ b/x/session/keeper/msg_update_params.go @@ -10,6 +10,7 @@ func (k msgServer) UpdateParams(ctx context.Context, req *types.MsgUpdateParams) if err := req.ValidateBasic(); err != nil { return nil, err } + if k.GetAuthority() != req.Authority { return nil, types.ErrSessionInvalidSigner.Wrapf("invalid authority; expected %s, got %s", k.GetAuthority(), req.Authority) } diff --git a/x/session/keeper/msg_update_params_test.go b/x/session/keeper/msg_update_params_test.go index f28228bd6..bf9df225b 100644 --- a/x/session/keeper/msg_update_params_test.go +++ b/x/session/keeper/msg_update_params_test.go @@ -35,7 +35,7 @@ func TestMsgUpdateParams(t *testing.T) { Authority: k.GetAuthority(), Params: types.Params{}, }, - shouldError: true, + shouldError: false, }, { desc: "valid: send default params", diff --git a/x/session/module/genesis_test.go b/x/session/module/genesis_test.go index 5fab07849..91b8cc149 100644 --- a/x/session/module/genesis_test.go +++ b/x/session/module/genesis_test.go @@ -20,11 +20,8 @@ func TestGenesisState_Validate(t *testing.T) { isValid: true, }, { - desc: "valid genesis state", + desc: "valid genesis state", genState: &types.GenesisState{ - Params: types.Params{ - NumBlocksPerSession: 1, - }, // this line is used by starport scaffolding # types/genesis/validField }, diff --git a/x/session/types/errors.go b/x/session/types/errors.go index c6339194d..6ffff939c 100644 --- a/x/session/types/errors.go +++ b/x/session/types/errors.go @@ -15,6 +15,4 @@ var ( ErrSessionInvalidService = sdkerrors.Register(ModuleName, 1106, "invalid service in session") ErrSessionInvalidBlockHeight = sdkerrors.Register(ModuleName, 1107, "invalid block height for session") ErrSessionInvalidSessionId = sdkerrors.Register(ModuleName, 1108, "invalid sessionId") - ErrSessionParamNameInvalid = sdkerrors.Register(ModuleName, 1109, "the provided param name is invalid") - ErrSessionParamInvalid = sdkerrors.Register(ModuleName, 1110, "the provided param is invalid") ) diff --git a/x/session/types/params.go b/x/session/types/params.go index 3fd7f5010..c894e0aa8 100644 --- a/x/session/types/params.go +++ b/x/session/types/params.go @@ -2,15 +2,7 @@ package types import paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" -const ( - DefaultNumBlocksPerSession = 4 - ParamNumBlocksPerSession = "num_blocks_per_session" -) - -var ( - _ paramtypes.ParamSet = (*Params)(nil) - KeyNumBlocksPerSession = []byte("NumBlocksPerSession") -) +var _ paramtypes.ParamSet = (*Params)(nil) // ParamKeyTable the param key table for launch module func ParamKeyTable() paramtypes.KeyTable { @@ -19,9 +11,7 @@ func ParamKeyTable() paramtypes.KeyTable { // NewParams creates a new Params instance func NewParams() Params { - return Params{ - NumBlocksPerSession: DefaultNumBlocksPerSession, - } + return Params{} } // DefaultParams returns a default set of parameters @@ -30,36 +20,11 @@ func DefaultParams() Params { } // ParamSetPairs get the params.ParamSet -func (params *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair( - KeyNumBlocksPerSession, - ¶ms.NumBlocksPerSession, - ValidateNumBlocksPerSession, - ), - } +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{} } // ValidateBasic does a sanity check on the provided params. -func (params *Params) ValidateBasic() error { - if err := ValidateNumBlocksPerSession(params.NumBlocksPerSession); err != nil { - return err - } - - return nil -} - -// ValidateNumBlocksPerSession validates the NumBlocksPerSession param -// NB: The argument is an interface type to satisfy the ParamSetPair function signature. -func ValidateNumBlocksPerSession(v interface{}) error { - numBlocksPerSession, ok := v.(uint64) - if !ok { - return ErrSessionParamInvalid.Wrapf("invalid parameter type: %T", v) - } - - if numBlocksPerSession < 1 { - return ErrSessionParamInvalid.Wrapf("invalid NumBlocksPerSession: (%v)", numBlocksPerSession) - } - +func (p Params) ValidateBasic() error { return nil } diff --git a/x/session/types/params.pb.go b/x/session/types/params.pb.go index 7373712f8..ef0c01648 100644 --- a/x/session/types/params.pb.go +++ b/x/session/types/params.pb.go @@ -26,7 +26,6 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { - NumBlocksPerSession uint64 `protobuf:"varint,1,opt,name=num_blocks_per_session,json=numBlocksPerSession,proto3" json:"num_blocks_per_session"` } func (m *Params) Reset() { *m = Params{} } @@ -62,13 +61,6 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetNumBlocksPerSession() uint64 { - if m != nil { - return m.NumBlocksPerSession - } - return 0 -} - func init() { proto.RegisterType((*Params)(nil), "poktroll.session.Params") } @@ -76,22 +68,18 @@ func init() { func init() { proto.RegisterFile("poktroll/session/params.proto", fileDescriptor_b9edf07916909b5b) } var fileDescriptor_b9edf07916909b5b = []byte{ - // 225 bytes of a gzipped FileDescriptorProto + // 176 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0xc8, 0xcf, 0x2e, 0x29, 0xca, 0xcf, 0xc9, 0xd1, 0x2f, 0x4e, 0x2d, 0x2e, 0xce, 0xcc, 0xcf, 0xd3, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x80, 0x49, 0xeb, 0x41, 0xa5, 0xa5, 0x04, 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x91, 0x94, 0x48, 0x7a, 0x7e, - 0x7a, 0x3e, 0x98, 0xa9, 0x0f, 0x62, 0x41, 0x44, 0x95, 0x6a, 0xb9, 0xd8, 0x02, 0xc0, 0x46, 0x09, - 0xf9, 0x73, 0x89, 0xe5, 0x95, 0xe6, 0xc6, 0x27, 0xe5, 0xe4, 0x27, 0x67, 0x17, 0xc7, 0x17, 0xa4, - 0x16, 0xc5, 0x43, 0x0d, 0x93, 0x60, 0x54, 0x60, 0xd4, 0x60, 0x71, 0x92, 0x7a, 0x75, 0x4f, 0x1e, - 0x87, 0x8a, 0x20, 0xe1, 0xbc, 0xd2, 0x5c, 0x27, 0xb0, 0x70, 0x40, 0x6a, 0x51, 0x30, 0x44, 0xd0, - 0x4a, 0xe9, 0xc5, 0x02, 0x79, 0xc6, 0xae, 0xe7, 0x1b, 0xb4, 0x24, 0xe1, 0xae, 0xaf, 0x80, 0xbb, - 0x1f, 0x62, 0xa9, 0x93, 0xd7, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, - 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, - 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x83, 0xf4, 0xeb, 0xe6, 0xa5, - 0x96, 0x94, 0xe7, 0x17, 0x65, 0xeb, 0x63, 0x31, 0xac, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, - 0xec, 0x23, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2a, 0x1d, 0x82, 0x30, 0x2d, 0x01, 0x00, - 0x00, + 0x7a, 0x3e, 0x98, 0xa9, 0x0f, 0x62, 0x41, 0x44, 0x95, 0x74, 0xb8, 0xd8, 0x02, 0xc0, 0x46, 0x59, + 0x29, 0xbd, 0x58, 0x20, 0xcf, 0xd8, 0xf5, 0x7c, 0x83, 0x96, 0x24, 0xdc, 0xb2, 0x0a, 0xb8, 0x75, + 0x10, 0x35, 0x4e, 0x5e, 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, 0x90, + 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0xd2, 0xaf, 0x9b, 0x97, 0x5a, + 0x52, 0x9e, 0x5f, 0x94, 0xad, 0x8f, 0xc5, 0xb0, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, + 0x03, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x03, 0x77, 0x93, 0x65, 0xdc, 0x00, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -113,9 +101,6 @@ func (this *Params) Equal(that interface{}) bool { } else if this == nil { return false } - if this.NumBlocksPerSession != that1.NumBlocksPerSession { - return false - } return true } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -138,11 +123,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.NumBlocksPerSession != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.NumBlocksPerSession)) - i-- - dAtA[i] = 0x8 - } return len(dAtA) - i, nil } @@ -163,9 +143,6 @@ func (m *Params) Size() (n int) { } var l int _ = l - if m.NumBlocksPerSession != 0 { - n += 1 + sovParams(uint64(m.NumBlocksPerSession)) - } return n } @@ -204,25 +181,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NumBlocksPerSession", wireType) - } - m.NumBlocksPerSession = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.NumBlocksPerSession |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/shared/keeper/msg_update_params.go b/x/shared/keeper/msg_update_params.go index 7cb13fb2c..8bdfb89b5 100644 --- a/x/shared/keeper/msg_update_params.go +++ b/x/shared/keeper/msg_update_params.go @@ -10,6 +10,10 @@ import ( ) func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + if err := req.ValidateBasic(); err != nil { + return nil, err + } + if k.GetAuthority() != req.Authority { return nil, errorsmod.Wrapf(types.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.GetAuthority(), req.Authority) } diff --git a/x/shared/keeper/msg_update_params_test.go b/x/shared/keeper/msg_update_params_test.go index 570d76d5c..e364fec4f 100644 --- a/x/shared/keeper/msg_update_params_test.go +++ b/x/shared/keeper/msg_update_params_test.go @@ -23,7 +23,7 @@ func TestMsgUpdateParams(t *testing.T) { expErrMsg string }{ { - name: "invalid authority", + name: "invalid: authority address invalid", input: &types.MsgUpdateParams{ Authority: "invalid", Params: params, @@ -32,15 +32,16 @@ func TestMsgUpdateParams(t *testing.T) { expErrMsg: "invalid authority", }, { - name: "send enabled param", + name: "invalid: send empty params", input: &types.MsgUpdateParams{ Authority: k.GetAuthority(), Params: types.Params{}, }, - expErr: false, + expErr: true, + expErrMsg: "invalid NumBlocksPerSession: (0): the provided param is invalid", }, { - name: "all good", + name: "valid: send default params", input: &types.MsgUpdateParams{ Authority: k.GetAuthority(), Params: params, diff --git a/x/shared/types/errors.go b/x/shared/types/errors.go index 01f55fb4d..9c60c7fed 100644 --- a/x/shared/types/errors.go +++ b/x/shared/types/errors.go @@ -8,6 +8,7 @@ import ( // x/shared module sentinel errors var ( - ErrInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") - ErrSample = sdkerrors.Register(ModuleName, 1101, "sample error") + ErrInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") + ErrSessionParamNameInvalid = sdkerrors.Register(ModuleName, 1101, "the provided param name is invalid") + ErrSessionParamInvalid = sdkerrors.Register(ModuleName, 1102, "the provided param is invalid") ) diff --git a/x/shared/types/genesis.go b/x/shared/types/genesis.go index c41be0742..e3dc5d8db 100644 --- a/x/shared/types/genesis.go +++ b/x/shared/types/genesis.go @@ -1,24 +1,20 @@ package types -import ( -// this line is used by starport scaffolding # genesis/types/import -) - // DefaultIndex is the default global index const DefaultIndex uint64 = 1 // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - // this line is used by starport scaffolding # genesis/types/default - Params: DefaultParams(), + // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), } } // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { - // this line is used by starport scaffolding # genesis/types/validate + // this line is used by starport scaffolding # genesis/types/validate - return gs.Params.Validate() + return gs.Params.ValidateBasic() } diff --git a/x/shared/types/genesis_test.go b/x/shared/types/genesis_test.go index 0fa73fbb1..a4a763951 100644 --- a/x/shared/types/genesis_test.go +++ b/x/shared/types/genesis_test.go @@ -20,8 +20,11 @@ func TestGenesisState_Validate(t *testing.T) { valid: true, }, { - desc: "valid genesis state", + desc: "valid genesis state", genState: &types.GenesisState{ + Params: types.Params{ + NumBlocksPerSession: 1, + }, // this line is used by starport scaffolding # types/genesis/validField }, diff --git a/x/shared/types/msg_update_params.go b/x/shared/types/msg_update_params.go index aeed4a633..e5f5ab0bc 100644 --- a/x/shared/types/msg_update_params.go +++ b/x/shared/types/msg_update_params.go @@ -13,7 +13,7 @@ func (m *MsgUpdateParams) ValidateBasic() error { return errorsmod.Wrap(err, "invalid authority address") } - if err := m.Params.Validate(); err != nil { + if err := m.Params.ValidateBasic(); err != nil { return err } diff --git a/x/shared/types/params.go b/x/shared/types/params.go index 4f3215e35..a310639a5 100644 --- a/x/shared/types/params.go +++ b/x/shared/types/params.go @@ -4,7 +4,15 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) -var _ paramtypes.ParamSet = (*Params)(nil) +const ( + DefaultNumBlocksPerSession = 4 + ParamNumBlocksPerSession = "num_blocks_per_session" +) + +var ( + _ paramtypes.ParamSet = (*Params)(nil) + KeyNumBlocksPerSession = []byte("NumBlocksPerSession") +) // ParamKeyTable the param key table for launch module func ParamKeyTable() paramtypes.KeyTable { @@ -13,7 +21,9 @@ func ParamKeyTable() paramtypes.KeyTable { // NewParams creates a new Params instance func NewParams() Params { - return Params{} + return Params{ + NumBlocksPerSession: DefaultNumBlocksPerSession, + } } // DefaultParams returns a default set of parameters @@ -22,11 +32,36 @@ func DefaultParams() Params { } // ParamSetPairs get the params.ParamSet -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{} +func (params *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair( + KeyNumBlocksPerSession, + ¶ms.NumBlocksPerSession, + ValidateNumBlocksPerSession, + ), + } } // Validate validates the set of params -func (p Params) Validate() error { +func (params *Params) ValidateBasic() error { + if err := ValidateNumBlocksPerSession(params.NumBlocksPerSession); err != nil { + return err + } + + return nil +} + +// ValidateNumBlocksPerSession validates the NumBlocksPerSession param +// NB: The argument is an interface type to satisfy the ParamSetPair function signature. +func ValidateNumBlocksPerSession(v interface{}) error { + numBlocksPerSession, ok := v.(uint64) + if !ok { + return ErrSessionParamInvalid.Wrapf("invalid parameter type: %T", v) + } + + if numBlocksPerSession < 1 { + return ErrSessionParamInvalid.Wrapf("invalid NumBlocksPerSession: (%v)", numBlocksPerSession) + } + return nil } diff --git a/x/shared/types/params.pb.go b/x/shared/types/params.pb.go index 117b22945..0929cac08 100644 --- a/x/shared/types/params.pb.go +++ b/x/shared/types/params.pb.go @@ -26,6 +26,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { + NumBlocksPerSession uint64 `protobuf:"varint,1,opt,name=num_blocks_per_session,json=numBlocksPerSession,proto3" json:"num_blocks_per_session"` } func (m *Params) Reset() { *m = Params{} } @@ -61,6 +62,13 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo +func (m *Params) GetNumBlocksPerSession() uint64 { + if m != nil { + return m.NumBlocksPerSession + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "poktroll.shared.Params") } @@ -68,18 +76,22 @@ func init() { func init() { proto.RegisterFile("poktroll/shared/params.proto", fileDescriptor_ee6189c7aa51bbf5) } var fileDescriptor_ee6189c7aa51bbf5 = []byte{ - // 175 bytes of a gzipped FileDescriptorProto + // 228 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0xc8, 0xcf, 0x2e, 0x29, 0xca, 0xcf, 0xc9, 0xd1, 0x2f, 0xce, 0x48, 0x2c, 0x4a, 0x4d, 0xd1, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0xc9, 0xea, 0x41, 0x64, 0xa5, 0x04, 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x8d, 0x94, 0x48, 0x7a, 0x7e, 0x7a, - 0x3e, 0x98, 0xa9, 0x0f, 0x62, 0x41, 0x44, 0x95, 0xb4, 0xb9, 0xd8, 0x02, 0xc0, 0x26, 0x59, 0x29, - 0xbe, 0x58, 0x20, 0xcf, 0xd8, 0xf5, 0x7c, 0x83, 0x96, 0x04, 0xdc, 0xaa, 0x0a, 0x98, 0x65, 0x10, - 0x25, 0x4e, 0x9e, 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, 0xa5, 0x9f, 0x9e, - 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0xd2, 0xae, 0x9b, 0x97, 0x5a, 0x52, - 0x9e, 0x5f, 0x94, 0xad, 0x8f, 0x69, 0x56, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x7a, - 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8c, 0xd0, 0x5c, 0x87, 0xd8, 0x00, 0x00, 0x00, + 0x3e, 0x98, 0xa9, 0x0f, 0x62, 0x41, 0x44, 0x95, 0x6a, 0xb8, 0xd8, 0x02, 0xc0, 0x26, 0x09, 0xf9, + 0x73, 0x89, 0xe5, 0x95, 0xe6, 0xc6, 0x27, 0xe5, 0xe4, 0x27, 0x67, 0x17, 0xc7, 0x17, 0xa4, 0x16, + 0xc5, 0x17, 0xa7, 0x16, 0x17, 0x67, 0xe6, 0xe7, 0x49, 0x30, 0x2a, 0x30, 0x6a, 0xb0, 0x38, 0x49, + 0xbd, 0xba, 0x27, 0x8f, 0x43, 0x45, 0x90, 0x70, 0x5e, 0x69, 0xae, 0x13, 0x58, 0x38, 0x20, 0xb5, + 0x28, 0x18, 0x22, 0x68, 0xa5, 0xf8, 0x62, 0x81, 0x3c, 0x63, 0xd7, 0xf3, 0x0d, 0x5a, 0x12, 0x70, + 0xb7, 0x57, 0xc0, 0x5c, 0x0f, 0xb1, 0xd3, 0xc9, 0xf3, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, + 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, + 0xe5, 0x18, 0xa2, 0xf4, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x41, + 0xda, 0x75, 0xf3, 0x52, 0x4b, 0xca, 0xf3, 0x8b, 0xb2, 0xf5, 0x31, 0xcd, 0x2a, 0xa9, 0x2c, 0x48, + 0x2d, 0x4e, 0x62, 0x03, 0xfb, 0xc7, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x43, 0x33, 0xe9, 0x1c, + 0x29, 0x01, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -101,6 +113,9 @@ func (this *Params) Equal(that interface{}) bool { } else if this == nil { return false } + if this.NumBlocksPerSession != that1.NumBlocksPerSession { + return false + } return true } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -123,6 +138,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.NumBlocksPerSession != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.NumBlocksPerSession)) + i-- + dAtA[i] = 0x8 + } return len(dAtA) - i, nil } @@ -143,6 +163,9 @@ func (m *Params) Size() (n int) { } var l int _ = l + if m.NumBlocksPerSession != 0 { + n += 1 + sovParams(uint64(m.NumBlocksPerSession)) + } return n } @@ -181,6 +204,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumBlocksPerSession", wireType) + } + m.NumBlocksPerSession = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumBlocksPerSession |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/session/types/params_test.go b/x/shared/types/params_test.go similarity index 100% rename from x/session/types/params_test.go rename to x/shared/types/params_test.go From eb647339fecd98f7a32392b86284023d2b440b6b Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 23 May 2024 11:26:56 +0200 Subject: [PATCH 39/61] Empty commit From bf31df83ec63197834ee17c3cace1a486ce10bee Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 23 May 2024 11:31:08 +0200 Subject: [PATCH 40/61] fixup! refactor: move `num_blocks_per_session` param to shared module --- e2e/tests/parse_params_test.go | 14 +++++++------- e2e/tests/update_params_test.go | 7 ++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/e2e/tests/parse_params_test.go b/e2e/tests/parse_params_test.go index 97d8e9b0f..f9e8cd306 100644 --- a/e2e/tests/parse_params_test.go +++ b/e2e/tests/parse_params_test.go @@ -13,7 +13,7 @@ import ( apptypes "github.com/pokt-network/poktroll/x/application/types" prooftypes "github.com/pokt-network/poktroll/x/proof/types" servicetypes "github.com/pokt-network/poktroll/x/service/types" - sessiontypes "github.com/pokt-network/poktroll/x/session/types" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" ) @@ -74,8 +74,8 @@ func (s *suite) paramsMapToMsgUpdateParams(moduleName string, paramsMap paramsMa msgUpdateParams = s.newTokenomicsMsgUpdateParams(paramsMap) case prooftypes.ModuleName: msgUpdateParams = s.newProofMsgUpdateParams(paramsMap) - case sessiontypes.ModuleName: - msgUpdateParams = s.newSessionMsgUpdateParams(paramsMap) + case sharedtypes.ModuleName: + msgUpdateParams = s.newSharedMsgUpdateParams(paramsMap) case apptypes.ModuleName: msgUpdateParams = s.newAppMsgUpdateParams(paramsMap) case servicetypes.ModuleName: @@ -129,18 +129,18 @@ func (s *suite) newProofMsgUpdateParams(params paramsMap) cosmostypes.Msg { return proto.Message(msgUpdateParams) } -func (s *suite) newSessionMsgUpdateParams(params paramsMap) cosmostypes.Msg { +func (s *suite) newSharedMsgUpdateParams(params paramsMap) cosmostypes.Msg { authority := authtypes.NewModuleAddress(s.granterName).String() - msgUpdateParams := &sessiontypes.MsgUpdateParams{ + msgUpdateParams := &sharedtypes.MsgUpdateParams{ Authority: authority, - Params: sessiontypes.Params{}, + Params: sharedtypes.Params{}, } for paramName, paramValue := range params { s.Logf("paramName: %s, value: %v", paramName, paramValue.value) switch paramName { - case sessiontypes.ParamNumBlocksPerSession: + case sharedtypes.ParamNumBlocksPerSession: msgUpdateParams.Params.NumBlocksPerSession = uint64(paramValue.value.(int64)) default: s.Fatalf("unexpected %q type param name %q", paramValue.typeStr, paramName) diff --git a/e2e/tests/update_params_test.go b/e2e/tests/update_params_test.go index f0f1fff12..ab7be1573 100644 --- a/e2e/tests/update_params_test.go +++ b/e2e/tests/update_params_test.go @@ -20,6 +20,7 @@ import ( prooftypes "github.com/pokt-network/poktroll/x/proof/types" servicetypes "github.com/pokt-network/poktroll/x/service/types" sessiontypes "github.com/pokt-network/poktroll/x/session/types" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" suppliertypes "github.com/pokt-network/poktroll/x/supplier/types" tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" ) @@ -315,11 +316,11 @@ func (s *suite) assertExpectedModuleParamsUpdated(moduleName string) { }, ) case sessiontypes.ModuleName: - numBlocksPerSession := uint64(s.expectedModuleParams[moduleName][sessiontypes.ParamNumBlocksPerSession].value.(int64)) + numBlocksPerSession := uint64(s.expectedModuleParams[moduleName][sharedtypes.ParamNumBlocksPerSession].value.(int64)) assertUpdatedParams(s, []byte(res.Stdout), - &sessiontypes.QueryParamsResponse{ - Params: sessiontypes.Params{ + &sharedtypes.QueryParamsResponse{ + Params: sharedtypes.Params{ NumBlocksPerSession: numBlocksPerSession, }, }, From c972ac99c4a5f2799a1869e2bf88fbb5eb9eb5ec Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 23 May 2024 11:42:03 +0200 Subject: [PATCH 41/61] fixup! refactor: move `num_blocks_per_session` param to shared module --- config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.yml b/config.yml index d54a9cc30..a967662a4 100644 --- a/config.yml +++ b/config.yml @@ -183,6 +183,6 @@ genesis: service: params: add_service_fee: "1000000000" - session: + shared: params: num_blocks_per_session: 4 From e17e3c4771b8dd5bda72b0debbba6fb77655afc2 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 23 May 2024 12:29:46 +0200 Subject: [PATCH 42/61] wip: triage & simplify --- .../tests/relays_stress_helpers_test.go | 27 +++--- pkg/client/interface.go | 17 +--- pkg/client/query/sessionquerier.go | 89 ------------------- pkg/client/query/sharedquerier.go | 55 ++++++++++++ pkg/crypto/rings/client.go | 6 +- pkg/relayer/proxy/proxy_test.go | 12 +-- pkg/relayer/proxy/relay_verifier.go | 8 +- pkg/relayer/session/claim.go | 15 ++-- pkg/relayer/session/proof.go | 10 +-- pkg/relayer/session/session.go | 22 +---- pkg/relayer/session/session_test.go | 4 +- .../testqueryclients/sessionquerier.go | 46 ++-------- 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 | 4 +- .../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 | 54 ++--------- x/session/session.go | 32 ------- x/shared/session.go | 54 +++++++++++ x/tokenomics/keeper/keeper_test.go | 4 +- x/tokenomics/keeper/settle_pending_claims.go | 4 +- .../keeper/settle_session_accounting_test.go | 8 +- 29 files changed, 210 insertions(+), 333 deletions(-) create mode 100644 pkg/client/query/sharedquerier.go delete mode 100644 x/session/session.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 0292d1841..0a3717e71 100644 --- a/load-testing/tests/relays_stress_helpers_test.go +++ b/load-testing/tests/relays_stress_helpers_test.go @@ -38,7 +38,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" ) @@ -161,9 +161,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(). @@ -304,15 +304,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", ) } @@ -343,12 +343,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 @@ -677,9 +676,9 @@ func (plan *actorLoadTestIncrementPlan) shouldIncrementActorCount( actorCount int64, startBlockHeight int64, ) bool { - 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 @@ -699,9 +698,9 @@ func (plan *actorLoadTestIncrementPlan) shouldIncrementSupplierCount( actorCount int64, startBlockHeight int64, ) bool { - 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 f034cffb3..0be469c37 100644 --- a/pkg/client/interface.go +++ b/pkg/client/interface.go @@ -274,18 +274,9 @@ type SessionQueryClient interface { serviceId string, blockHeight int64, ) (*sessiontypes.Session, error) +} + +type SharedQueryClient interface { // GetParams queries the chain for the current session module parameters. - GetParams(ctx context.Context) (*sessiontypes.Params, error) - // GetSessionGracePeriodEndHeight returns the height at which the grace period for - // the session ending with sessionEndHeight elapses. - GetSessionGracePeriodEndHeight(ctx context.Context, sessionEndHeight int64) (int64, error) - // GetSessionGracePeriodBlockCount returns the number of blocks in the grace period - // for the session which includes queryHeight. - GetSessionGracePeriodBlockCount(ctx context.Context, queryHeight int64) (uint64, error) - // IsWithinGracePeriod returns true if the grace period for the session ending with - // sessionEndHeight has not yet elapsed, given currentHeight. - IsWithinGracePeriod(ctx context.Context, sessionEndHeight, currentHeight int64) (bool, error) - // IsPastGracePeriod returns true if the grace period for the session ending with - // sessionEndHeight has elapsed, given currentHeight. - IsPastGracePeriod(ctx context.Context, sessionEndHeight, currentHeight int64) (bool, error) + GetParams(ctx context.Context) (*sharedtypes.Params, error) } diff --git a/pkg/client/query/sessionquerier.go b/pkg/client/query/sessionquerier.go index 0a087c2f5..a08d49f16 100644 --- a/pkg/client/query/sessionquerier.go +++ b/pkg/client/query/sessionquerier.go @@ -7,7 +7,6 @@ import ( "github.com/cosmos/gogoproto/grpc" "github.com/pokt-network/poktroll/pkg/client" - "github.com/pokt-network/poktroll/x/session" sessiontypes "github.com/pokt-network/poktroll/x/session/types" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -65,91 +64,3 @@ func (sessq *sessionQuerier) GetSession( } return res.Session, nil } - -// GetParams queries & returns the session 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 (sessq *sessionQuerier) GetParams(ctx context.Context) (*sessiontypes.Params, error) { - req := &sessiontypes.QueryParamsRequest{} - res, err := sessq.sessionQuerier.Params(ctx, req) - if err != nil { - return nil, ErrQuerySessionParams.Wrapf("[%v]", err) - } - return &res.Params, nil -} - -// GetSessionGracePeriodEndHeight returns the height at which the grace period for -// the session ending with sessionEndHeight elapses. -func (sessq *sessionQuerier) GetSessionGracePeriodEndHeight( - ctx context.Context, - sessionEndHeight int64, -) (int64, error) { - params, err := sessq.GetParams(ctx) - if err != nil { - return 0, err - } - - // TODO_BLOCKER(#543): Use the values of session params at `sessionEndHeight`. - _ = sessionEndHeight - - numBlocksPerSession := params.GetNumBlocksPerSession() - return session.GetSessionGracePeriodEndHeight(numBlocksPerSession, sessionEndHeight), nil -} - -// GetSessionGracePeriodBlockCount returns the number of blocks in the grace period -// for the session which includes queryHeight. -func (sessq *sessionQuerier) GetSessionGracePeriodBlockCount( - ctx context.Context, - sessionEndHeight int64, -) (uint64, error) { - params, err := sessq.GetParams(ctx) - if err != nil { - return 0, err - } - - // TODO_BLOCKER(#543): Use the values of session params at `sessionEndHeight`. - _ = sessionEndHeight - - numBlocksPerSession := params.GetNumBlocksPerSession() - return session.GetSessionGracePeriodBlockCount(numBlocksPerSession), nil -} - -// IsWithinGracePeriod returns true if the grace period for the session ending with -// sessionEndHeight has not yet elapsed, given currentHeight. -func (sessq *sessionQuerier) IsWithinGracePeriod( - ctx context.Context, - sessionEndHeight, - currentHeight int64, -) (bool, error) { - params, err := sessq.GetParams(ctx) - if err != nil { - return false, err - } - - // TODO_BLOCKER(#543): Use the values of session params at `sessionEndHeight`. - _ = sessionEndHeight - - numBlocksPerSession := params.GetNumBlocksPerSession() - return session.IsWithinGracePeriod(numBlocksPerSession, sessionEndHeight, currentHeight), nil -} - -// IsPastGracePeriod returns true if the grace period for the session ending with -// sessionEndHeight has elapsed, given currentHeight. -func (sessq *sessionQuerier) IsPastGracePeriod( - ctx context.Context, - sessionEndHeight, - currentHeight int64, -) (bool, error) { - paramsRes, err := sessq.sessionQuerier.Params(ctx, &sessiontypes.QueryParamsRequest{}) - if err != nil { - return false, err - } - - // TODO_BLOCKER(#543): Use the values of session params at `sessionEndHeight`. - _ = sessionEndHeight - - numBlocksPerSession := paramsRes.GetParams().NumBlocksPerSession - return session.IsPastGracePeriod(numBlocksPerSession, sessionEndHeight, currentHeight), nil -} diff --git a/pkg/client/query/sharedquerier.go b/pkg/client/query/sharedquerier.go new file mode 100644 index 000000000..cf72ff17d --- /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 +} + +// NewSessionQuerier returns a new instance of a client.SessionQueryClient 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 (sessq *sharedQuerier) GetParams(ctx context.Context) (*sharedtypes.Params, error) { + req := &sharedtypes.QueryParamsRequest{} + res, err := sessq.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/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 59bd1e1ce..11cba8b7d 100644 --- a/pkg/relayer/proxy/relay_verifier.go +++ b/pkg/relayer/proxy/relay_verifier.go @@ -4,6 +4,7 @@ import ( "context" "github.com/pokt-network/poktroll/x/service/types" + "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -98,12 +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. - isWithinGracePeriod, err := rp.sessionQuerier.IsWithinGracePeriod(ctx, sessionEndblockHeight, currentBlockHeight) - if err != nil { - return 0, err - } - - if isWithinGracePeriod { + 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 a0ca57c4c..1f5761a88 100644 --- a/pkg/relayer/session/claim.go +++ b/pkg/relayer/session/claim.go @@ -11,6 +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" + "github.com/pokt-network/poktroll/x/shared" ) // createClaims maps over the sessionsToClaimObs observable. For each claim batch, it: @@ -41,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)) @@ -85,15 +90,7 @@ func (rs *relayerSessionsManager) waitForEarliestCreateClaimsHeight( // 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. - sessionGracePeriodEndHeight, err := rs.sessionQueryClient.GetSessionGracePeriodEndHeight(ctx, sessionEndHeight) - if err != nil { - // 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. - failSubmitProofsSessionsCh <- sessionTrees - } - + sessionGracePeriodEndHeight := shared.GetSessionGracePeriodEndHeight(sessionEndHeight) createClaimsWindowStartHeight := sessionGracePeriodEndHeight + 1 // TODO_BLOCKER: query the on-chain governance parameter once available. diff --git a/pkg/relayer/session/proof.go b/pkg/relayer/session/proof.go index 841f36365..3a6d4a4c1 100644 --- a/pkg/relayer/session/proof.go +++ b/pkg/relayer/session/proof.go @@ -12,6 +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" + "github.com/pokt-network/poktroll/x/shared" ) // submitProofs maps over the given claimedSessions observable. @@ -78,14 +79,7 @@ func (rs *relayerSessionsManager) waitForEarliestSubmitProofsHeightAndGeneratePr // first one from the group to calculate the earliest height for proof submission. sessionEndHeight := sessionTrees[0].GetSessionHeader().GetSessionEndBlockHeight() - sessionGracePeriodEndHeight, err := rs.sessionQueryClient.GetSessionGracePeriodEndHeight(ctx, sessionEndHeight) - if err != nil { - // 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. - failSubmitProofsSessionsCh <- sessionTrees - } + sessionGracePeriodEndHeight := shared.GetSessionGracePeriodEndHeight(sessionEndHeight) // TODO_TECHDEBT(#516): Centralize the business logic that involves taking // into account the heights, windows and grace periods into helper functions. diff --git a/pkg/relayer/session/session.go b/pkg/relayer/session/session.go index b96f42b43..da4465f20 100644 --- a/pkg/relayer/session/session.go +++ b/pkg/relayer/session/session.go @@ -13,6 +13,7 @@ import ( "github.com/pokt-network/poktroll/pkg/polylog" "github.com/pokt-network/poktroll/pkg/relayer" sessiontypes "github.com/pokt-network/poktroll/x/session/types" + "github.com/pokt-network/poktroll/x/shared" ) var _ relayer.RelayerSessionsManager = (*relayerSessionsManager)(nil) @@ -47,8 +48,6 @@ type relayerSessionsManager struct { // storesDirectory points to a path on disk where KVStore data files are created. storesDirectory string - - sessionQueryClient client.SessionQueryClient } // NewRelayerSessions creates a new relayerSessions. @@ -74,7 +73,6 @@ func NewRelayerSessions( deps, &rs.blockClient, &rs.supplierClient, - &rs.sessionQueryClient, ); err != nil { return nil, err } @@ -181,7 +179,7 @@ func (rs *relayerSessionsManager) mapBlockToSessionsToClaim( // 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 @@ -197,13 +195,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. - isWithinGracePeriod, err := rs.sessionQueryClient.IsWithinGracePeriod(ctx, endBlockHeight, block.Height()) - if err != nil { - rs.logger.Error().Err(err).Msg("failed to check if within grace period") - return nil, true - } - - if isWithinGracePeriod { + if !shared.IsGracePeriodElapsed(sessionEndHeight, 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 { @@ -217,16 +209,10 @@ func (rs *relayerSessionsManager) mapBlockToSessionsToClaim( continue } - isPastSessionGracePeriod, err := rs.sessionQueryClient.IsPastGracePeriod(ctx, endBlockHeight, block.Height()) - if err != nil { - rs.logger.Error().Err(err).Msg("failed to check if past grace period") - return nil, true - } - // 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 isPastSessionGracePeriod { + if shared.IsGracePeriodElapsed(sessionEndHeight, block.Height()) { lateSessions = append(lateSessions, sessionTree) } else { onTimeSessions = append(onTimeSessions, sessionTree) diff --git a/pkg/relayer/session/session_test.go b/pkg/relayer/session/session_test.go index 110b13941..6fa2cc2a2 100644 --- a/pkg/relayer/session/session_test.go +++ b/pkg/relayer/session/session_test.go @@ -24,7 +24,7 @@ import ( "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) { @@ -104,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 7d03d7f2c..552e66969 100644 --- a/testutil/testclient/testqueryclients/sessionquerier.go +++ b/testutil/testclient/testqueryclients/sessionquerier.go @@ -9,9 +9,9 @@ import ( "github.com/golang/mock/gomock" "github.com/pokt-network/poktroll/testutil/mockclient" - "github.com/pokt-network/poktroll/x/session" 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" ) @@ -59,22 +59,6 @@ func NewTestSessionQueryClient( }). AnyTimes() - sessionQuerier.EXPECT().GetSessionGracePeriodBlockCount(gomock.Any(), gomock.Any()). - DoAndReturn(GetDefaultSessionGracePeriodBlockCount). - AnyTimes() - - sessionQuerier.EXPECT().GetSessionGracePeriodEndHeight(gomock.Any(), gomock.Any()). - DoAndReturn(GetDefaultSessionGracePeriodEndHeight). - AnyTimes() - - sessionQuerier.EXPECT().IsWithinGracePeriod(gomock.Any(), gomock.Any(), gomock.Any()). - DoAndReturn(IsWithinDefaultGracePeriod). - AnyTimes() - - sessionQuerier.EXPECT().IsPastGracePeriod(gomock.Any(), gomock.Any(), gomock.Any()). - DoAndReturn(IsPastDefaultGracePeriod). - AnyTimes() - return sessionQuerier } @@ -96,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{}, } @@ -116,23 +100,3 @@ func AddToExistingSessions( delete(sessionsMap, sessionId) }) } - -func GetDefaultSessionGracePeriodBlockCount(_ context.Context, sessionEndHeight int64) (int64, error) { - numBlocksPerSession := sessiontypes.DefaultParams().NumBlocksPerSession - return int64(session.GetSessionGracePeriodBlockCount(numBlocksPerSession)), nil -} - -func GetDefaultSessionGracePeriodEndHeight(_ context.Context, sessionEndHeight int64) (int64, error) { - numBlocksPerSession := sessiontypes.DefaultParams().NumBlocksPerSession - return session.GetSessionGracePeriodEndHeight(numBlocksPerSession, sessionEndHeight), nil -} - -func IsWithinDefaultGracePeriod(_ context.Context, sessionEndHeight, queryHeight int64) (bool, error) { - numBlocksPerSession := sessiontypes.DefaultParams().NumBlocksPerSession - return session.IsWithinGracePeriod(numBlocksPerSession, sessionEndHeight, queryHeight), nil -} - -func IsPastDefaultGracePeriod(_ context.Context, sessionEndHeight, queryHeight int64) (bool, error) { - numBlocksPerSession := sessiontypes.DefaultParams().NumBlocksPerSession - return session.IsPastGracePeriod(numBlocksPerSession, sessionEndHeight, queryHeight), nil -} 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 547f15a9a..61081e81f 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. @@ -441,7 +441,7 @@ func (k msgServer) validateClosestPath( // TODO_BLOCKER@(@Olshansk): Update `blockHeight` to be the value of when the `ProofWindow` // opens once the variable is added. sessionEndBlockHeightWithGracePeriod := sessionHeader.GetSessionEndBlockHeight() + - sessionkeeper.GetSessionGracePeriodBlockCount() + shared.SessionGracePeriodBlocks blockHash := k.sessionKeeper.GetBlockHash(ctx, sessionEndBlockHeightWithGracePeriod) // TODO: Investigate "proof for the path provided does not match one expected by the on-chain protocol" 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..74572b4cf 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" ) @@ -22,9 +23,9 @@ var SHA3HashLen = crypto.SHA3_256.Size() 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 +104,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 +268,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 +293,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/session/session.go b/x/session/session.go deleted file mode 100644 index 129191031..000000000 --- a/x/session/session.go +++ /dev/null @@ -1,32 +0,0 @@ -package session - -import ( - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" -) - -// GetSessionGracePeriodBlockCount returns the number of blocks in the grace period -// given some numBlocksPerSession. -func GetSessionGracePeriodBlockCount(numBlocksPerSession uint64) uint64 { - return sessionkeeper.SessionGracePeriod * numBlocksPerSession -} - -// GetSessionGracePeriodEndHeight returns the height at which the grace period for -// the session ending with sessionEndHeight elapses. -func GetSessionGracePeriodEndHeight(numBlocksPerSession uint64, sessionEndHeight int64) int64 { - sessionGracePeriodBlockCount := GetSessionGracePeriodBlockCount(numBlocksPerSession) - return sessionEndHeight + int64(sessionGracePeriodBlockCount) -} - -// IsWithinGracePeriod returns true if the grace period for the session ending with -// sessionEndHeight has not yet elapsed, given currentHeight. -func IsWithinGracePeriod(numBlocksPerSession uint64, sessionEndHeight, currentHeight int64) bool { - sessionGracePeriodEndHeight := GetSessionGracePeriodEndHeight(numBlocksPerSession, sessionEndHeight) - return currentHeight <= sessionGracePeriodEndHeight -} - -// IsPastGracePeriod returns true if the grace period for the session ending with -// sessionEndHeight has elapsed, given currentHeight. -func IsPastGracePeriod(numBlocksPerSession uint64, sessionEndHeight, currentHeight int64) bool { - sessionGracePeriodEndHeight := GetSessionGracePeriodEndHeight(numBlocksPerSession, sessionEndHeight) - return currentHeight > sessionGracePeriodEndHeight -} diff --git a/x/shared/session.go b/x/shared/session.go new file mode 100644 index 000000000..2e62a9091 --- /dev/null +++ b/x/shared/session.go @@ -0,0 +1,54 @@ +package shared + +const NumBlocksPerSession = 4 + +// SessionGracePeriodBlocks SHOULD be a multiple of +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 +} + +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/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 51f135b17..70fd9fee0 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), } From d8af99642c1f22da1d9ad276ac9869a3e59dec9e Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 23 May 2024 14:25:22 +0200 Subject: [PATCH 43/61] refactor: session query client & shared query client --- pkg/client/interface.go | 1 + pkg/client/query/sharedquerier.go | 2 +- pkg/deps/config/suppliers.go | 15 +++++++++++ pkg/relayer/cmd/cmd.go | 1 + pkg/relayer/session/session.go | 20 +++++++++++--- pkg/relayer/session/session_test.go | 4 +-- .../testqueryclients/sharedquerier.go | 26 +++++++++++++++++++ 7 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 testutil/testclient/testqueryclients/sharedquerier.go diff --git a/pkg/client/interface.go b/pkg/client/interface.go index 0be469c37..9cf82cde9 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 diff --git a/pkg/client/query/sharedquerier.go b/pkg/client/query/sharedquerier.go index cf72ff17d..15a0d22c1 100644 --- a/pkg/client/query/sharedquerier.go +++ b/pkg/client/query/sharedquerier.go @@ -20,7 +20,7 @@ type sharedQuerier struct { sharedQuerier sharedtypes.QueryClient } -// NewSessionQuerier returns a new instance of a client.SessionQueryClient by +// NewSharedQuerier returns a new instance of a client.SharedQueryClient by // injecting the dependecies provided by the depinject.Config. // // Required dependencies: diff --git a/pkg/deps/config/suppliers.go b/pkg/deps/config/suppliers.go index 80fa4a0e9..efc65b5e7 100644 --- a/pkg/deps/config/suppliers.go +++ b/pkg/deps/config/suppliers.go @@ -395,3 +395,18 @@ func NewSupplyBlockQueryClientFn(queryNodeRPCUrl *url.URL) SupplierFn { return depinject.Configs(deps, depinject.Supply(blockQueryClient)), nil } } + +func NewSharedQueryClientFn() 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..9409496d4 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.NewSharedQueryClientFn(), // leaf config.NewSupplyAccountQuerierFn(), config.NewSupplyApplicationQuerierFn(), config.NewSupplySupplierQuerierFn(), diff --git a/pkg/relayer/session/session.go b/pkg/relayer/session/session.go index da4465f20..c93aa818b 100644 --- a/pkg/relayer/session/session.go +++ b/pkg/relayer/session/session.go @@ -48,6 +48,8 @@ type relayerSessionsManager struct { // storesDirectory points to a path on disk where KVStore data files are created. storesDirectory string + + sharedQueryClient client.SharedQueryClient } // NewRelayerSessions creates a new relayerSessions. @@ -73,6 +75,7 @@ func NewRelayerSessions( deps, &rs.blockClient, &rs.supplierClient, + &rs.sharedQueryClient, ); err != nil { return nil, err } @@ -175,6 +178,15 @@ func (rs *relayerSessionsManager) mapBlockToSessionsToClaim( // They will be emitted last, after all the late sessions have been emitted. var onTimeSessions []relayer.SessionTree + // TODO_IMPROVE(#543): Params are currently queried each block. + 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 @@ -186,7 +198,7 @@ func (rs *relayerSessionsManager) mapBlockToSessionsToClaim( // before emitting the on-time sessions. var lateSessions []relayer.SessionTree - // !IsWithinGracePeriod is checking for sessions to claim with <= operator, + // 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 @@ -195,7 +207,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 !shared.IsGracePeriodElapsed(sessionEndHeight, block.Height()) { + if sessionEndHeight+shared.SessionGracePeriodBlocks <= 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 { @@ -212,7 +224,9 @@ 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 shared.IsGracePeriodElapsed(sessionEndHeight, block.Height()) { + sessionGracePeriodEndHeight := sessionEndHeight + shared.SessionGracePeriodBlocks + nextSessionEndHeight := sessionGracePeriodEndHeight + int64(numBlocksPerSession) + if nextSessionEndHeight >= block.Height() { lateSessions = append(lateSessions, sessionTree) } else { onTimeSessions = append(onTimeSessions, sessionTree) diff --git a/pkg/relayer/session/session_test.go b/pkg/relayer/session/session_test.go index 6fa2cc2a2..5444bee9d 100644 --- a/pkg/relayer/session/session_test.go +++ b/pkg/relayer/session/session_test.go @@ -72,9 +72,9 @@ func TestRelayerSessionsManager_Start(t *testing.T) { ). AnyTimes() - sessionQueryClientMock := testqueryclients.NewTestSessionQueryClient(t) + sharedQueryClientMock := testqueryclients.NewTestSharedQueryClient(t) - deps := depinject.Supply(blockClient, blockQueryClientMock, supplierClient, sessionQueryClientMock) + deps := depinject.Supply(blockClient, blockQueryClientMock, supplierClient, sharedQueryClientMock) storesDirectoryOpt := testrelayer.WithTempStoresDirectory(t) // Create a new relayer sessions manager. 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 +} From 82a356756d8dc84dc2e9a6d01adbaf0e955b3af8 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 23 May 2024 14:33:04 +0200 Subject: [PATCH 44/61] refactor: simplify --- pkg/relayer/session/session.go | 4 ++-- x/proof/keeper/msg_server_submit_proof.go | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/relayer/session/session.go b/pkg/relayer/session/session.go index c93aa818b..7afcea812 100644 --- a/pkg/relayer/session/session.go +++ b/pkg/relayer/session/session.go @@ -207,7 +207,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 sessionEndHeight+shared.SessionGracePeriodBlocks <= block.Height() { + if shared.GetSessionGracePeriodEndHeight(sessionEndHeight) <= 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 { @@ -224,7 +224,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. - sessionGracePeriodEndHeight := sessionEndHeight + shared.SessionGracePeriodBlocks + sessionGracePeriodEndHeight := shared.GetSessionGracePeriodEndHeight(sessionEndHeight) nextSessionEndHeight := sessionGracePeriodEndHeight + int64(numBlocksPerSession) if nextSessionEndHeight >= block.Height() { lateSessions = append(lateSessions, sessionTree) diff --git a/x/proof/keeper/msg_server_submit_proof.go b/x/proof/keeper/msg_server_submit_proof.go index 61081e81f..f13ffc066 100644 --- a/x/proof/keeper/msg_server_submit_proof.go +++ b/x/proof/keeper/msg_server_submit_proof.go @@ -440,8 +440,7 @@ func (k msgServer) validateClosestPath( // into account the heights, windows and grace periods into helper functions. // TODO_BLOCKER@(@Olshansk): Update `blockHeight` to be the value of when the `ProofWindow` // opens once the variable is added. - sessionEndBlockHeightWithGracePeriod := sessionHeader.GetSessionEndBlockHeight() + - shared.SessionGracePeriodBlocks + sessionEndBlockHeightWithGracePeriod := shared.GetSessionGracePeriodEndHeight(sessionHeader.GetSessionEndBlockHeight()) blockHash := k.sessionKeeper.GetBlockHash(ctx, sessionEndBlockHeightWithGracePeriod) // TODO: Investigate "proof for the path provided does not match one expected by the on-chain protocol" From 3e24eda772a20fdbed642bb78a2133f6f68fbc6f Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 23 May 2024 14:33:14 +0200 Subject: [PATCH 45/61] chore: add missing comment in types.go --- x/shared/types/types.go | 2 ++ 1 file changed, 2 insertions(+) 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 From 433236a72b65ba5439b31b7b9668171117b05798 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 23 May 2024 14:37:46 +0200 Subject: [PATCH 46/61] chore: self-review improvements --- pkg/client/interface.go | 4 +++- pkg/deps/config/suppliers.go | 7 +++++-- pkg/relayer/cmd/cmd.go | 2 +- pkg/relayer/session/session.go | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/client/interface.go b/pkg/client/interface.go index 9cf82cde9..3f801bf6b 100644 --- a/pkg/client/interface.go +++ b/pkg/client/interface.go @@ -277,7 +277,9 @@ type SessionQueryClient interface { ) (*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 session module parameters. + // GetParams queries the chain for the current shared module parameters. GetParams(ctx context.Context) (*sharedtypes.Params, error) } diff --git a/pkg/deps/config/suppliers.go b/pkg/deps/config/suppliers.go index efc65b5e7..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 { @@ -396,7 +396,10 @@ func NewSupplyBlockQueryClientFn(queryNodeRPCUrl *url.URL) SupplierFn { } } -func NewSharedQueryClientFn() SupplierFn { +// 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, diff --git a/pkg/relayer/cmd/cmd.go b/pkg/relayer/cmd/cmd.go index 9409496d4..03a870b78 100644 --- a/pkg/relayer/cmd/cmd.go +++ b/pkg/relayer/cmd/cmd.go @@ -195,7 +195,7 @@ func setupRelayerDependencies( supplyMiner, // leaf config.NewSupplyTxClientContextFn(queryNodeGRPCUrl, txNodeRPCUrl), // leaf config.NewSupplyDelegationClientFn(), // leaf - config.NewSharedQueryClientFn(), // leaf + config.NewSupplySharedQueryClientFn(), // leaf config.NewSupplyAccountQuerierFn(), config.NewSupplyApplicationQuerierFn(), config.NewSupplySupplierQuerierFn(), diff --git a/pkg/relayer/session/session.go b/pkg/relayer/session/session.go index 7afcea812..939833420 100644 --- a/pkg/relayer/session/session.go +++ b/pkg/relayer/session/session.go @@ -49,6 +49,7 @@ 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 } From e00fe4ba59a2f343af521ca4d8ae40443c2d651a Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 23 May 2024 14:45:26 +0200 Subject: [PATCH 47/61] fixup! chore: self-review improvements --- x/shared/session.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/shared/session.go b/x/shared/session.go index 2e62a9091..8fd5b3383 100644 --- a/x/shared/session.go +++ b/x/shared/session.go @@ -43,6 +43,8 @@ func GetSessionNumber(blockHeight int64) int64 { 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 } From a68ae8ddc12816f83ba27fde6fe990adaf8b7c8a Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 23 May 2024 15:03:11 +0200 Subject: [PATCH 48/61] fixup! fixup! chore: self-review improvements --- pkg/relayer/session/session.go | 8 ++++---- x/session/keeper/session_hydrator.go | 5 ----- x/shared/session.go | 8 +++++++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pkg/relayer/session/session.go b/pkg/relayer/session/session.go index 939833420..787f07885 100644 --- a/pkg/relayer/session/session.go +++ b/pkg/relayer/session/session.go @@ -199,6 +199,8 @@ func (rs *relayerSessionsManager) mapBlockToSessionsToClaim( // before emitting the on-time sessions. var lateSessions []relayer.SessionTree + 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. @@ -208,7 +210,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 shared.GetSessionGracePeriodEndHeight(sessionEndHeight) <= 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 { @@ -225,9 +227,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. - sessionGracePeriodEndHeight := shared.GetSessionGracePeriodEndHeight(sessionEndHeight) - nextSessionEndHeight := sessionGracePeriodEndHeight + int64(numBlocksPerSession) - if nextSessionEndHeight >= block.Height() { + if sessionGracePeriodEndHeight+int64(numBlocksPerSession) >= block.Height() { lateSessions = append(lateSessions, sessionTree) } else { onTimeSessions = append(onTimeSessions, sessionTree) diff --git a/x/session/keeper/session_hydrator.go b/x/session/keeper/session_hydrator.go index 74572b4cf..cba24a8e0 100644 --- a/x/session/keeper/session_hydrator.go +++ b/x/session/keeper/session_hydrator.go @@ -21,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 - - // Duration of the grace period in number of sessions - NumSupplierPerSession = 15 SessionIDComponentDelimiter = "." ) diff --git a/x/shared/session.go b/x/shared/session.go index 8fd5b3383..41f80e409 100644 --- a/x/shared/session.go +++ b/x/shared/session.go @@ -1,8 +1,14 @@ 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 SHOULD be a multiple of +// SessionGracePeriodBlocks is the number of blocks after the session ends before the +// "session grace period" is considered to have elapsed. const SessionGracePeriodBlocks = 4 // GetSessionStartBlockHeight returns the block height at which the session starts From 66e2be7adbde27eb1db43f724660e012d59101d8 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 23 May 2024 15:19:38 +0200 Subject: [PATCH 49/61] fixup! refactor: move `num_blocks_per_session` param to shared module --- Makefile | 4 ++-- e2e/tests/update_params_test.go | 11 ++++++++--- .../params/{session_all.json => shared_all.json} | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) rename tools/scripts/params/{session_all.json => shared_all.json} (78%) diff --git a/Makefile b/Makefile index 2f4fa580d..4f2b71abb 100644 --- a/Makefile +++ b/Makefile @@ -827,8 +827,8 @@ params_update_proof_min_relay_difficulty_bits: ## Update the proof module params ### Session Module Params ### .PHONY: params_update_session_all -params_update_session_all: ## Update the session module params - poktrolld tx authz exec ./tools/scripts/params/session_all.json $(PARAM_FLAGS) +params_update_shared_all: ## Update the session module params + poktrolld tx authz exec ./tools/scripts/params/shared_all.json $(PARAM_FLAGS) .PHONY: params_query_all params_query_all: check_jq ## Query the params from all available modules diff --git a/e2e/tests/update_params_test.go b/e2e/tests/update_params_test.go index ab7be1573..8bde266a6 100644 --- a/e2e/tests/update_params_test.go +++ b/e2e/tests/update_params_test.go @@ -80,8 +80,13 @@ func (s *suite) AllModuleParamsAreSetToTheirDefaultValues(moduleName string) { s.cdc.MustUnmarshalJSON([]byte(res.Stdout), &serviceParamsRes) require.Equal(s, servicetypes.DefaultParams(), serviceParamsRes.GetParams()) + case sharedtypes.ModuleName: + var sharedParamsRes sharedtypes.QueryParamsResponse + s.cdc.MustUnmarshalJSON([]byte(res.Stdout), &sharedParamsRes) + require.Equal(s, sharedtypes.DefaultParams(), sharedParamsRes.GetParams()) + default: - s.Fatalf("unexpected module name: (%v)", moduleName) + s.Fatalf("ERROR: unexpected module name: (%v)", moduleName) } } @@ -315,7 +320,7 @@ func (s *suite) assertExpectedModuleParamsUpdated(moduleName string) { }, }, ) - case sessiontypes.ModuleName: + case sharedtypes.ModuleName: numBlocksPerSession := uint64(s.expectedModuleParams[moduleName][sharedtypes.ParamNumBlocksPerSession].value.(int64)) assertUpdatedParams(s, []byte(res.Stdout), @@ -346,7 +351,7 @@ func (s *suite) assertExpectedModuleParamsUpdated(moduleName string) { }, ) default: - s.Fatalf("unexpected module name %q", moduleName) + s.Fatalf("ERROR: unexpected module name %q", moduleName) } } diff --git a/tools/scripts/params/session_all.json b/tools/scripts/params/shared_all.json similarity index 78% rename from tools/scripts/params/session_all.json rename to tools/scripts/params/shared_all.json index 55b2f6200..72502f45d 100644 --- a/tools/scripts/params/session_all.json +++ b/tools/scripts/params/shared_all.json @@ -2,7 +2,7 @@ "body": { "messages": [ { - "@type": "/poktroll.session.MsgUpdateParams", + "@type": "/poktroll.shared.MsgUpdateParams", "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", "params": { "num_blocks_per_session": "4" From 4d66581e8b1eb5cee0aa7d930df0987b1acd13be Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 23 May 2024 15:54:24 +0200 Subject: [PATCH 50/61] fix: broken E2E test --- e2e/tests/reset_params_test.go | 8 ++++++++ pkg/relayer/session/proof.go | 23 ++++++++++++++--------- x/proof/keeper/msg_server_submit_proof.go | 8 ++++---- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/e2e/tests/reset_params_test.go b/e2e/tests/reset_params_test.go index c4d3985ea..4871c9397 100644 --- a/e2e/tests/reset_params_test.go +++ b/e2e/tests/reset_params_test.go @@ -10,6 +10,7 @@ import ( apptypes "github.com/pokt-network/poktroll/x/application/types" gatewaytypes "github.com/pokt-network/poktroll/x/gateway/types" prooftypes "github.com/pokt-network/poktroll/x/proof/types" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" suppliertypes "github.com/pokt-network/poktroll/x/supplier/types" tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" ) @@ -86,6 +87,13 @@ func (s *suite) msgUpdateParamsToDefaultsAny(moduleName string) *codectypes.Any Params: tokenomicstypes.DefaultParams(), }, ) + case sharedtypes.ModuleName: + anyMsg, err = codectypes.NewAnyWithValue( + &sharedtypes.MsgUpdateParams{ + Authority: authtypes.NewModuleAddress(s.granterName).String(), + Params: sharedtypes.DefaultParams(), + }, + ) default: s.Fatalf("unknown module name: %s", moduleName) } diff --git a/pkg/relayer/session/proof.go b/pkg/relayer/session/proof.go index 3a6d4a4c1..d73c8c4b1 100644 --- a/pkg/relayer/session/proof.go +++ b/pkg/relayer/session/proof.go @@ -83,8 +83,9 @@ func (rs *relayerSessionsManager) waitForEarliestSubmitProofsHeightAndGeneratePr // 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: query the on-chain governance parameter once available. + // TODO_BLOCKER(#516): query the on-chain governance parameter once available. // + claimproofparams.GovSubmitProofWindowStartHeightOffset // we wait for submitProofsWindowStartHeight to be received before proceeding since we need its hash @@ -94,10 +95,14 @@ 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. - submitProofWindowStartBlock := rs.waitForBlock(ctx, submitProofsWindowStartHeight) + sessionPathBlock := rs.waitForBlock(ctx, sessionGracePeriodEndHeight) + // TODO_BLOCKER(#516): Wait one more block to ensure that a claim submitted at the earliest + // possible height is committed. This delay will also need to account for claim/proof + // window offsets which will be added in the future. + _ = rs.waitForBlock(ctx, submitProofsWindowStartHeight) // Generate proofs for all sessionTrees concurrently while waiting for the // earliest submitProofsHeight (pseudorandom submission distribution) to be reached. @@ -107,13 +112,13 @@ func (rs *relayerSessionsManager) waitForEarliestSubmitProofsHeightAndGeneratePr go rs.goProveClaims( ctx, sessionTrees, - submitProofWindowStartBlock, + sessionPathBlock, proofsGeneratedCh, failSubmitProofsSessionsCh, ) // Wait for the earliest submitProofsHeight to be reached before proceeding. - earliestSubmitProofsHeight := protocol.GetEarliestSubmitProofHeight(ctx, submitProofWindowStartBlock) + earliestSubmitProofsHeight := protocol.GetEarliestSubmitProofHeight(ctx, sessionPathBlock) _ = rs.waitForBlock(ctx, earliestSubmitProofsHeight) // Once the earliest submitProofsHeight has been reached, and all proofs have @@ -166,11 +171,11 @@ func (rs *relayerSessionsManager) newMapProveSessionsFn( // goProveClaims generates the proofs corresponding to the given sessionTrees, // then sends the successful and failed proofs to their respective channels. -// This function MUST to be run as a goroutine. +// This function MUST be run as a goroutine. func (rs *relayerSessionsManager) goProveClaims( ctx context.Context, sessionTrees []relayer.SessionTree, - submitProofWindowStartBlock client.Block, + sessionPathBlock client.Block, proofsGeneratedCh chan<- []relayer.SessionTree, failSubmitProofsSessionsCh chan<- []relayer.SessionTree, ) { @@ -185,9 +190,9 @@ func (rs *relayerSessionsManager) goProveClaims( default: } // Generate the proof path for the sessionTree using the previously committed - // submitProofWindowStartBlock hash. + // sessionPathBlock hash. path := proofkeeper.GetPathForProof( - submitProofWindowStartBlock.Hash(), + sessionPathBlock.Hash(), sessionTree.GetSessionHeader().GetSessionId(), ) diff --git a/x/proof/keeper/msg_server_submit_proof.go b/x/proof/keeper/msg_server_submit_proof.go index f13ffc066..b7d05a439 100644 --- a/x/proof/keeper/msg_server_submit_proof.go +++ b/x/proof/keeper/msg_server_submit_proof.go @@ -438,14 +438,14 @@ func (k msgServer) validateClosestPath( // // TODO_TECHDEBT(@red-0ne): Centralize the business logic that involves taking // into account the heights, windows and grace periods into helper functions. - // TODO_BLOCKER@(@Olshansk): Update `blockHeight` to be the value of when the `ProofWindow` + // TODO_BLOCKER@(#516): Update `blockHeight` to be the value of when the `ProofWindow` // opens once the variable is added. - sessionEndBlockHeightWithGracePeriod := shared.GetSessionGracePeriodEndHeight(sessionHeader.GetSessionEndBlockHeight()) - 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) { From 93e01aac94ac4c118e0b7ed2e9d8b292ee071aff Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 23 May 2024 15:19:38 +0200 Subject: [PATCH 51/61] fixup! refactor: move `num_blocks_per_session` param to shared module --- Makefile | 4 ++-- e2e/tests/update_params_test.go | 11 ++++++++--- .../params/{session_all.json => shared_all.json} | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) rename tools/scripts/params/{session_all.json => shared_all.json} (78%) diff --git a/Makefile b/Makefile index 2f4fa580d..4f2b71abb 100644 --- a/Makefile +++ b/Makefile @@ -827,8 +827,8 @@ params_update_proof_min_relay_difficulty_bits: ## Update the proof module params ### Session Module Params ### .PHONY: params_update_session_all -params_update_session_all: ## Update the session module params - poktrolld tx authz exec ./tools/scripts/params/session_all.json $(PARAM_FLAGS) +params_update_shared_all: ## Update the session module params + poktrolld tx authz exec ./tools/scripts/params/shared_all.json $(PARAM_FLAGS) .PHONY: params_query_all params_query_all: check_jq ## Query the params from all available modules diff --git a/e2e/tests/update_params_test.go b/e2e/tests/update_params_test.go index ab7be1573..8bde266a6 100644 --- a/e2e/tests/update_params_test.go +++ b/e2e/tests/update_params_test.go @@ -80,8 +80,13 @@ func (s *suite) AllModuleParamsAreSetToTheirDefaultValues(moduleName string) { s.cdc.MustUnmarshalJSON([]byte(res.Stdout), &serviceParamsRes) require.Equal(s, servicetypes.DefaultParams(), serviceParamsRes.GetParams()) + case sharedtypes.ModuleName: + var sharedParamsRes sharedtypes.QueryParamsResponse + s.cdc.MustUnmarshalJSON([]byte(res.Stdout), &sharedParamsRes) + require.Equal(s, sharedtypes.DefaultParams(), sharedParamsRes.GetParams()) + default: - s.Fatalf("unexpected module name: (%v)", moduleName) + s.Fatalf("ERROR: unexpected module name: (%v)", moduleName) } } @@ -315,7 +320,7 @@ func (s *suite) assertExpectedModuleParamsUpdated(moduleName string) { }, }, ) - case sessiontypes.ModuleName: + case sharedtypes.ModuleName: numBlocksPerSession := uint64(s.expectedModuleParams[moduleName][sharedtypes.ParamNumBlocksPerSession].value.(int64)) assertUpdatedParams(s, []byte(res.Stdout), @@ -346,7 +351,7 @@ func (s *suite) assertExpectedModuleParamsUpdated(moduleName string) { }, ) default: - s.Fatalf("unexpected module name %q", moduleName) + s.Fatalf("ERROR: unexpected module name %q", moduleName) } } diff --git a/tools/scripts/params/session_all.json b/tools/scripts/params/shared_all.json similarity index 78% rename from tools/scripts/params/session_all.json rename to tools/scripts/params/shared_all.json index 55b2f6200..72502f45d 100644 --- a/tools/scripts/params/session_all.json +++ b/tools/scripts/params/shared_all.json @@ -2,7 +2,7 @@ "body": { "messages": [ { - "@type": "/poktroll.session.MsgUpdateParams", + "@type": "/poktroll.shared.MsgUpdateParams", "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", "params": { "num_blocks_per_session": "4" From b6ce1d4f6d05def6cad2ba536f5379db5a496a1f Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 23 May 2024 15:54:24 +0200 Subject: [PATCH 52/61] fix: broken E2E test --- e2e/tests/reset_params_test.go | 8 ++++++ pkg/relayer/session/proof.go | 30 ++++++++++++++--------- x/proof/keeper/msg_server_submit_proof.go | 2 +- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/e2e/tests/reset_params_test.go b/e2e/tests/reset_params_test.go index c4d3985ea..4871c9397 100644 --- a/e2e/tests/reset_params_test.go +++ b/e2e/tests/reset_params_test.go @@ -10,6 +10,7 @@ import ( apptypes "github.com/pokt-network/poktroll/x/application/types" gatewaytypes "github.com/pokt-network/poktroll/x/gateway/types" prooftypes "github.com/pokt-network/poktroll/x/proof/types" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" suppliertypes "github.com/pokt-network/poktroll/x/supplier/types" tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" ) @@ -86,6 +87,13 @@ func (s *suite) msgUpdateParamsToDefaultsAny(moduleName string) *codectypes.Any Params: tokenomicstypes.DefaultParams(), }, ) + case sharedtypes.ModuleName: + anyMsg, err = codectypes.NewAnyWithValue( + &sharedtypes.MsgUpdateParams{ + Authority: authtypes.NewModuleAddress(s.granterName).String(), + Params: sharedtypes.DefaultParams(), + }, + ) default: s.Fatalf("unknown module name: %s", moduleName) } diff --git a/pkg/relayer/session/proof.go b/pkg/relayer/session/proof.go index dc2029765..52e3e8e69 100644 --- a/pkg/relayer/session/proof.go +++ b/pkg/relayer/session/proof.go @@ -77,11 +77,15 @@ func (rs *relayerSessionsManager) waitForEarliestSubmitProofsHeightAndGeneratePr ) []relayer.SessionTree { // Given the sessionTrees are grouped by their sessionEndHeight, we can use the // first one from the group to calculate the earliest height for proof submission. - createClaimHeight := sessionTrees[0].GetSessionHeader().GetSessionEndBlockHeight() - // TODO_TECHDEBT(@red-0ne): Centralize the business logic that involves taking + 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. - submitProofsWindowStartHeight := createClaimHeight + sessionkeeper.GetSessionGracePeriodBlockCount() - // TODO_BLOCKER: query the on-chain governance parameter once available. + // TODO_BLOCKER(#516): The proof submission window SHOULD NOT overlap with the claim window. + submitProofsWindowStartHeight := sessionGracePeriodEndHeight + 1 + // TODO_BLOCKER(#516): query the on-chain governance parameter once available. // + claimproofparams.GovSubmitProofWindowStartHeightOffset // we wait for submitProofsWindowStartHeight to be received before proceeding since we need its hash @@ -94,7 +98,11 @@ func (rs *relayerSessionsManager) waitForEarliestSubmitProofsHeightAndGeneratePr // submitProofWindowStartBlock 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. - submitProofWindowStartBlock := rs.waitForBlock(ctx, submitProofsWindowStartHeight) + sessionPathBlock := rs.waitForBlock(ctx, sessionGracePeriodEndHeight) + // TODO_BLOCKER(#516): Wait one more block to ensure that a claim submitted at the earliest + // possible height is committed. This delay will also need to account for claim/proof + // window offsets which will be added in the future. + _ = rs.waitForBlock(ctx, submitProofsWindowStartHeight) // Generate proofs for all sessionTrees concurrently while waiting for the // earliest submitProofsHeight (pseudorandom submission distribution) to be reached. @@ -104,13 +112,13 @@ func (rs *relayerSessionsManager) waitForEarliestSubmitProofsHeightAndGeneratePr go rs.goProveClaims( ctx, sessionTrees, - submitProofWindowStartBlock, + sessionPathBlock, proofsGeneratedCh, failSubmitProofsSessionsCh, ) // Wait for the earliest submitProofsHeight to be reached before proceeding. - earliestSubmitProofsHeight := protocol.GetEarliestSubmitProofHeight(ctx, submitProofWindowStartBlock) + earliestSubmitProofsHeight := protocol.GetEarliestSubmitProofHeight(ctx, sessionPathBlock) _ = rs.waitForBlock(ctx, earliestSubmitProofsHeight) // Once the earliest submitProofsHeight has been reached, and all proofs have @@ -163,11 +171,11 @@ func (rs *relayerSessionsManager) newMapProveSessionsFn( // goProveClaims generates the proofs corresponding to the given sessionTrees, // then sends the successful and failed proofs to their respective channels. -// This function MUST to be run as a goroutine. +// This function MUST be run as a goroutine. func (rs *relayerSessionsManager) goProveClaims( ctx context.Context, sessionTrees []relayer.SessionTree, - submitProofWindowStartBlock client.Block, + sessionPathBlock client.Block, proofsGeneratedCh chan<- []relayer.SessionTree, failSubmitProofsSessionsCh chan<- []relayer.SessionTree, ) { @@ -182,9 +190,9 @@ func (rs *relayerSessionsManager) goProveClaims( default: } // Generate the proof path for the sessionTree using the previously committed - // submitProofWindowStartBlock hash. + // sessionPathBlock hash. path := proofkeeper.GetPathForProof( - submitProofWindowStartBlock.Hash(), + sessionPathBlock.Hash(), sessionTree.GetSessionHeader().GetSessionId(), ) diff --git a/x/proof/keeper/msg_server_submit_proof.go b/x/proof/keeper/msg_server_submit_proof.go index 547f15a9a..20c4f96fb 100644 --- a/x/proof/keeper/msg_server_submit_proof.go +++ b/x/proof/keeper/msg_server_submit_proof.go @@ -438,7 +438,7 @@ func (k msgServer) validateClosestPath( // // TODO_TECHDEBT(@red-0ne): Centralize the business logic that involves taking // into account the heights, windows and grace periods into helper functions. - // TODO_BLOCKER@(@Olshansk): Update `blockHeight` to be the value of when the `ProofWindow` + // TODO_BLOCKER@(#516): Update `blockHeight` to be the value of when the `ProofWindow` // opens once the variable is added. sessionEndBlockHeightWithGracePeriod := sessionHeader.GetSessionEndBlockHeight() + sessionkeeper.GetSessionGracePeriodBlockCount() From bf24e6c6d0e5199387598c891eacdf4c02d35e6b Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 23 May 2024 16:33:37 +0200 Subject: [PATCH 53/61] fix: typo --- pkg/relayer/session/session.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/relayer/session/session.go b/pkg/relayer/session/session.go index 787f07885..03a7795db 100644 --- a/pkg/relayer/session/session.go +++ b/pkg/relayer/session/session.go @@ -227,7 +227,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 sessionGracePeriodEndHeight+int64(numBlocksPerSession) >= block.Height() { + if sessionGracePeriodEndHeight+int64(numBlocksPerSession) < block.Height() { lateSessions = append(lateSessions, sessionTree) } else { onTimeSessions = append(onTimeSessions, sessionTree) From 03a4079c2dfa494946a47bd76d09778a8d6a7b8f Mon Sep 17 00:00:00 2001 From: Bryan White Date: Mon, 27 May 2024 11:11:40 +0200 Subject: [PATCH 54/61] Empty commit From 89114f3e95ff58982e354ac89187315a545c8458 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Mon, 27 May 2024 11:17:41 +0200 Subject: [PATCH 55/61] fix: add omitted pb.go file --- x/shared/types/params.pb.go | 330 ++++++++++++++++++++++++++++++++++++ 1 file changed, 330 insertions(+) create mode 100644 x/shared/types/params.pb.go diff --git a/x/shared/types/params.pb.go b/x/shared/types/params.pb.go new file mode 100644 index 000000000..0929cac08 --- /dev/null +++ b/x/shared/types/params.pb.go @@ -0,0 +1,330 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: poktroll/shared/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + 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 + +// Params defines the parameters for the module. +type Params struct { + NumBlocksPerSession uint64 `protobuf:"varint,1,opt,name=num_blocks_per_session,json=numBlocksPerSession,proto3" json:"num_blocks_per_session"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_ee6189c7aa51bbf5, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetNumBlocksPerSession() uint64 { + if m != nil { + return m.NumBlocksPerSession + } + return 0 +} + +func init() { + proto.RegisterType((*Params)(nil), "poktroll.shared.Params") +} + +func init() { proto.RegisterFile("poktroll/shared/params.proto", fileDescriptor_ee6189c7aa51bbf5) } + +var fileDescriptor_ee6189c7aa51bbf5 = []byte{ + // 228 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0xc8, 0xcf, 0x2e, + 0x29, 0xca, 0xcf, 0xc9, 0xd1, 0x2f, 0xce, 0x48, 0x2c, 0x4a, 0x4d, 0xd1, 0x2f, 0x48, 0x2c, 0x4a, + 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0xc9, 0xea, 0x41, 0x64, 0xa5, + 0x04, 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x8d, 0x94, 0x48, 0x7a, 0x7e, 0x7a, + 0x3e, 0x98, 0xa9, 0x0f, 0x62, 0x41, 0x44, 0x95, 0x6a, 0xb8, 0xd8, 0x02, 0xc0, 0x26, 0x09, 0xf9, + 0x73, 0x89, 0xe5, 0x95, 0xe6, 0xc6, 0x27, 0xe5, 0xe4, 0x27, 0x67, 0x17, 0xc7, 0x17, 0xa4, 0x16, + 0xc5, 0x17, 0xa7, 0x16, 0x17, 0x67, 0xe6, 0xe7, 0x49, 0x30, 0x2a, 0x30, 0x6a, 0xb0, 0x38, 0x49, + 0xbd, 0xba, 0x27, 0x8f, 0x43, 0x45, 0x90, 0x70, 0x5e, 0x69, 0xae, 0x13, 0x58, 0x38, 0x20, 0xb5, + 0x28, 0x18, 0x22, 0x68, 0xa5, 0xf8, 0x62, 0x81, 0x3c, 0x63, 0xd7, 0xf3, 0x0d, 0x5a, 0x12, 0x70, + 0xb7, 0x57, 0xc0, 0x5c, 0x0f, 0xb1, 0xd3, 0xc9, 0xf3, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, + 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, + 0xe5, 0x18, 0xa2, 0xf4, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x41, + 0xda, 0x75, 0xf3, 0x52, 0x4b, 0xca, 0xf3, 0x8b, 0xb2, 0xf5, 0x31, 0xcd, 0x2a, 0xa9, 0x2c, 0x48, + 0x2d, 0x4e, 0x62, 0x03, 0xfb, 0xc7, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x43, 0x33, 0xe9, 0x1c, + 0x29, 0x01, 0x00, 0x00, +} + +func (this *Params) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Params) + if !ok { + that2, ok := that.(Params) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.NumBlocksPerSession != that1.NumBlocksPerSession { + return false + } + return true +} +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.NumBlocksPerSession != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.NumBlocksPerSession)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.NumBlocksPerSession != 0 { + n += 1 + sovParams(uint64(m.NumBlocksPerSession)) + } + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) 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 ErrIntOverflowParams + } + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumBlocksPerSession", wireType) + } + m.NumBlocksPerSession = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumBlocksPerSession |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) From 5db7c9b060a063089ae5d8b520493d614183ada4 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Mon, 27 May 2024 12:08:00 +0200 Subject: [PATCH 56/61] fix: linting --- x/shared/types/genesis_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/shared/types/genesis_test.go b/x/shared/types/genesis_test.go index d275af65f..a4a763951 100644 --- a/x/shared/types/genesis_test.go +++ b/x/shared/types/genesis_test.go @@ -20,7 +20,7 @@ func TestGenesisState_Validate(t *testing.T) { valid: true, }, { - desc: "valid genesis state", + desc: "valid genesis state", genState: &types.GenesisState{ Params: types.Params{ NumBlocksPerSession: 1, From 06137644ea5d739ab36465855d55e4c1262bf6b4 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Mon, 27 May 2024 12:08:30 +0200 Subject: [PATCH 57/61] fix: go imports script: exclude *.pulsar.go files & fix buffer size --- tools/scripts/goimports/filters/filters.go | 12 ++++++++++++ tools/scripts/goimports/main.go | 1 + 2 files changed, 13 insertions(+) diff --git a/tools/scripts/goimports/filters/filters.go b/tools/scripts/goimports/filters/filters.go index 5b78f4eb9..79868be70 100644 --- a/tools/scripts/goimports/filters/filters.go +++ b/tools/scripts/goimports/filters/filters.go @@ -46,6 +46,10 @@ func PathMatchesTestGo(path string) (bool, error) { return strings.HasSuffix(path, "_test.go"), nil } +func PathMatchesPulsarGo(path string) (bool, error) { + return strings.HasSuffix(path, ".pulsar.go"), nil +} + // ContentMatchesEmptyImportScaffold matches files that can't be goimport'd due // to ignite incompatibility. func ContentMatchesEmptyImportScaffold(path string) (bool, error) { @@ -66,6 +70,14 @@ func containsEmptyImportScaffold(goSrcPath string) (isEmptyImport bool, _ error) defer file.Close() scanner := bufio.NewScanner(file) + + // The default buffer size is 64KB, which is insufficient. + // Set a larger buffer size (e.g., 1 MB) to avoid the following error: + // bufio.Scanner: token too long + const maxBufferSize = 1024 * 1024 // 1 MB + buf := make([]byte, maxBufferSize) + scanner.Buffer(buf, maxBufferSize) + scanner.Split(importBlockSplit) for scanner.Scan() { diff --git a/tools/scripts/goimports/main.go b/tools/scripts/goimports/main.go index ca5c26648..ec209560a 100644 --- a/tools/scripts/goimports/main.go +++ b/tools/scripts/goimports/main.go @@ -24,6 +24,7 @@ var ( filters.PathMatchesProtobufGatewayGo, filters.PathMatchesMockGo, filters.PathMatchesTestGo, + filters.PathMatchesPulsarGo, filters.ContentMatchesEmptyImportScaffold, } ) From 77f704e51972e01c1c1b479e28a7a3c907bcd179 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Mon, 27 May 2024 13:11:33 +0200 Subject: [PATCH 58/61] Empty commit From c18ec7b26c97774acba82acee68bb07f9d1c14b2 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Fri, 24 May 2024 14:48:44 +0200 Subject: [PATCH 59/61] chore: review improvements --- pkg/relayer/session/proof.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/relayer/session/proof.go b/pkg/relayer/session/proof.go index d73c8c4b1..9acb77803 100644 --- a/pkg/relayer/session/proof.go +++ b/pkg/relayer/session/proof.go @@ -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 := shared.GetSessionGracePeriodEndHeight(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 From 203de35b7f91e2308e58fe29530d5444373c39ef Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 28 May 2024 08:22:07 +0200 Subject: [PATCH 60/61] fix: update_params.feature reset --- e2e/tests/reset_params_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/tests/reset_params_test.go b/e2e/tests/reset_params_test.go index 4871c9397..88083a177 100644 --- a/e2e/tests/reset_params_test.go +++ b/e2e/tests/reset_params_test.go @@ -38,6 +38,7 @@ func (s *suite) allModulesMsgUpdateParamsToDefaultsAny() []*codectypes.Any { s.msgUpdateParamsToDefaultsAny(suppliertypes.ModuleName), s.msgUpdateParamsToDefaultsAny(prooftypes.ModuleName), s.msgUpdateParamsToDefaultsAny(tokenomicstypes.ModuleName), + s.msgUpdateParamsToDefaultsAny(sharedtypes.ModuleName), } } From 6352a5f738fc1918488e1a0078287e3b410047ff Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 28 May 2024 08:31:30 +0200 Subject: [PATCH 61/61] chore: review improvements --- pkg/client/query/sharedquerier.go | 6 +++--- pkg/relayer/session/session.go | 4 +++- x/shared/session.go | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/client/query/sharedquerier.go b/pkg/client/query/sharedquerier.go index 15a0d22c1..2c4ac4abb 100644 --- a/pkg/client/query/sharedquerier.go +++ b/pkg/client/query/sharedquerier.go @@ -43,11 +43,11 @@ func NewSharedQuerier(deps depinject.Config) (client.SharedQueryClient, error) { // 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 +// Once `ModuleParamsClient` is implemented, use its replay observable's `#Last()` method // to get the most recently (asynchronously) observed (and cached) value. -func (sessq *sharedQuerier) GetParams(ctx context.Context) (*sharedtypes.Params, error) { +func (sq *sharedQuerier) GetParams(ctx context.Context) (*sharedtypes.Params, error) { req := &sharedtypes.QueryParamsRequest{} - res, err := sessq.sharedQuerier.Params(ctx, req) + res, err := sq.sharedQuerier.Params(ctx, req) if err != nil { return nil, ErrQuerySessionParams.Wrapf("[%v]", err) } diff --git a/pkg/relayer/session/session.go b/pkg/relayer/session/session.go index 03a7795db..531c1208e 100644 --- a/pkg/relayer/session/session.go +++ b/pkg/relayer/session/session.go @@ -179,7 +179,9 @@ func (rs *relayerSessionsManager) mapBlockToSessionsToClaim( // They will be emitted last, after all the late sessions have been emitted. var onTimeSessions []relayer.SessionTree - // TODO_IMPROVE(#543): Params are currently queried each block. + // 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") diff --git a/x/shared/session.go b/x/shared/session.go index 41f80e409..5240059a5 100644 --- a/x/shared/session.go +++ b/x/shared/session.go @@ -9,6 +9,9 @@ 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