From 42cf5c68f3aea12f977feebd54313879f2ef85b3 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 28 May 2024 08:52:27 +0200 Subject: [PATCH] refactor: move `num_blocks_per_session` param to shared module (#546) --- Makefile | 4 +- api/poktroll/session/params.pulsar.go | 94 ++++--------------- api/poktroll/shared/params.pulsar.go | 94 +++++++++++++++---- config.yml | 2 +- e2e/tests/parse_params_test.go | 14 +-- e2e/tests/reset_params_test.go | 9 ++ e2e/tests/update_params.feature | 10 +- e2e/tests/update_params_test.go | 18 ++-- pkg/relayer/session/proof.go | 30 +++--- proto/poktroll/session/params.proto | 2 - proto/poktroll/shared/params.proto | 2 +- .../authz/dao_genesis_authorizations.json | 9 ++ tools/scripts/goimports/filters/filters.go | 12 +++ tools/scripts/goimports/main.go | 1 + .../{session_all.json => shared_all.json} | 2 +- x/proof/keeper/msg_server_submit_proof.go | 2 +- 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 | 2 +- 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 31 files changed, 298 insertions(+), 250 deletions(-) rename tools/scripts/params/{session_all.json => shared_all.json} (78%) rename x/{session => shared}/types/params_test.go (100%) diff --git a/Makefile b/Makefile index 031054840..20391630a 100644 --- a/Makefile +++ b/Makefile @@ -835,8 +835,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/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/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 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/reset_params_test.go b/e2e/tests/reset_params_test.go index c4d3985ea..88083a177 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" ) @@ -37,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), } } @@ -86,6 +88,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/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/e2e/tests/update_params_test.go b/e2e/tests/update_params_test.go index f0f1fff12..8bde266a6 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" ) @@ -79,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) } } @@ -314,12 +320,12 @@ func (s *suite) assertExpectedModuleParamsUpdated(moduleName string) { }, }, ) - case sessiontypes.ModuleName: - numBlocksPerSession := uint64(s.expectedModuleParams[moduleName][sessiontypes.ParamNumBlocksPerSession].value.(int64)) + case sharedtypes.ModuleName: + 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, }, }, @@ -345,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/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/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/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, } ) 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" 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() 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..dee271e3a 100644 --- a/x/shared/types/genesis.go +++ b/x/shared/types/genesis.go @@ -20,5 +20,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/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