From 16e9499b502ac540c8d8404a52c41140e63fcb86 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Mon, 12 Feb 2024 13:38:07 +0100 Subject: [PATCH 01/24] scaffold: module session --dep account,bank,application,supplier ignite scaffold module session --dep account,bank,application,supplier --- api/poktroll/application/genesis.pulsar.go | 8 + api/poktroll/session/genesis.pulsar.go | 595 ++++++++++ api/poktroll/session/module/module.pulsar.go | 578 ++++++++++ api/poktroll/session/params.pulsar.go | 499 ++++++++ api/poktroll/session/query.pulsar.go | 1010 ++++++++++++++++ api/poktroll/session/tx.pulsar.go | 1089 ++++++++++++++++++ app/app.go | 3 + app/app_config.go | 12 + proto/poktroll/session/genesis.proto | 17 + proto/poktroll/session/module/module.proto | 14 + proto/poktroll/session/params.proto | 15 + proto/poktroll/session/query.proto | 30 + proto/poktroll/session/tx.proto | 40 + x/session/keeper/keeper.go | 67 ++ x/session/keeper/msg_server.go | 17 + x/session/keeper/msg_server_test.go | 24 + x/session/keeper/msg_update_params.go | 23 + x/session/keeper/msg_update_params_test.go | 64 + x/session/keeper/params.go | 33 + x/session/keeper/params_test.go | 18 + x/session/keeper/query.go | 7 + x/session/keeper/query_params.go | 20 + x/session/keeper/query_params_test.go | 20 + x/session/module/autocli.go | 35 + x/session/module/genesis.go | 24 + x/session/module/genesis_test.go | 29 + x/session/module/module.go | 220 ++++ x/session/module/simulation.go | 64 + x/session/simulation/helpers.go | 15 + x/session/types/codec.go | 17 + x/session/types/errors.go | 13 + x/session/types/expected_keepers.go | 33 + x/session/types/genesis.go | 24 + x/session/types/genesis_test.go | 41 + x/session/types/keys.go | 20 + x/session/types/msg_update_params.go | 21 + x/session/types/params.go | 32 + x/session/types/types.go | 1 + 38 files changed, 4792 insertions(+) create mode 100644 api/poktroll/session/genesis.pulsar.go create mode 100644 api/poktroll/session/module/module.pulsar.go create mode 100644 api/poktroll/session/params.pulsar.go create mode 100644 api/poktroll/session/query.pulsar.go create mode 100644 api/poktroll/session/tx.pulsar.go create mode 100644 proto/poktroll/session/genesis.proto create mode 100644 proto/poktroll/session/module/module.proto create mode 100644 proto/poktroll/session/params.proto create mode 100644 proto/poktroll/session/query.proto create mode 100644 proto/poktroll/session/tx.proto create mode 100644 x/session/keeper/keeper.go create mode 100644 x/session/keeper/msg_server.go create mode 100644 x/session/keeper/msg_server_test.go create mode 100644 x/session/keeper/msg_update_params.go create mode 100644 x/session/keeper/msg_update_params_test.go create mode 100644 x/session/keeper/params.go create mode 100644 x/session/keeper/params_test.go create mode 100644 x/session/keeper/query.go create mode 100644 x/session/keeper/query_params.go create mode 100644 x/session/keeper/query_params_test.go create mode 100644 x/session/module/autocli.go create mode 100644 x/session/module/genesis.go create mode 100644 x/session/module/genesis_test.go create mode 100644 x/session/module/module.go create mode 100644 x/session/module/simulation.go create mode 100644 x/session/simulation/helpers.go create mode 100644 x/session/types/codec.go create mode 100644 x/session/types/errors.go create mode 100644 x/session/types/expected_keepers.go create mode 100644 x/session/types/genesis.go create mode 100644 x/session/types/genesis_test.go create mode 100644 x/session/types/keys.go create mode 100644 x/session/types/msg_update_params.go create mode 100644 x/session/types/params.go create mode 100644 x/session/types/types.go diff --git a/api/poktroll/application/genesis.pulsar.go b/api/poktroll/application/genesis.pulsar.go index 02d9e6c3d..67b121817 100644 --- a/api/poktroll/application/genesis.pulsar.go +++ b/api/poktroll/application/genesis.pulsar.go @@ -608,7 +608,11 @@ type GenesisState struct { // params defines all the parameters of the module. Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` +<<<<<<< HEAD ApplicationList []*Application `protobuf:"bytes,2,rep,name=application_list,json=applicationList,proto3" json:"application_list,omitempty"` +======= + ApplicationList []*Application `protobuf:"bytes,2,rep,name=applicationList,proto3" json:"applicationList,omitempty"` +>>>>>>> 87307009 (scaffold: module session --dep account,bank,application,supplier) } func (x *GenesisState) Reset() { @@ -704,7 +708,11 @@ var file_poktroll_application_genesis_proto_goTypes = []interface{}{ } var file_poktroll_application_genesis_proto_depIdxs = []int32{ 1, // 0: poktroll.application.GenesisState.params:type_name -> poktroll.application.Params +<<<<<<< HEAD 2, // 1: poktroll.application.GenesisState.application_list:type_name -> poktroll.application.Application +======= + 2, // 1: poktroll.application.GenesisState.applicationList:type_name -> poktroll.application.Application +>>>>>>> 87307009 (scaffold: module session --dep account,bank,application,supplier) 2, // [2:2] is the sub-list for method output_type 2, // [2:2] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name diff --git a/api/poktroll/session/genesis.pulsar.go b/api/poktroll/session/genesis.pulsar.go new file mode 100644 index 000000000..eb80c4693 --- /dev/null +++ b/api/poktroll/session/genesis.pulsar.go @@ -0,0 +1,595 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package session + +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_session_genesis_proto_init() + md_GenesisState = File_poktroll_session_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_session_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.session.GenesisState.params": + return x.Params != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.GenesisState")) + } + panic(fmt.Errorf("message poktroll.session.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.session.GenesisState.params": + x.Params = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.GenesisState")) + } + panic(fmt.Errorf("message poktroll.session.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.session.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.session.GenesisState")) + } + panic(fmt.Errorf("message poktroll.session.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.session.GenesisState.params": + x.Params = value.Message().Interface().(*Params) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.GenesisState")) + } + panic(fmt.Errorf("message poktroll.session.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.session.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.session.GenesisState")) + } + panic(fmt.Errorf("message poktroll.session.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.session.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.session.GenesisState")) + } + panic(fmt.Errorf("message poktroll.session.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.session.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/session/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 session 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_session_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_session_genesis_proto_rawDescGZIP(), []int{0} +} + +func (x *GenesisState) GetParams() *Params { + if x != nil { + return x.Params + } + return nil +} + +var File_poktroll_session_genesis_proto protoreflect.FileDescriptor + +var file_poktroll_session_genesis_proto_rawDesc = []byte{ + 0x0a, 0x1e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 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, 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, 0x4b, 0x0a, 0x0c, 0x47, 0x65, + 0x6e, 0x65, 0x73, 0x69, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x3b, 0x0a, 0x06, 0x70, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 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, 0x42, 0xa8, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, + 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 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 ( + file_poktroll_session_genesis_proto_rawDescOnce sync.Once + file_poktroll_session_genesis_proto_rawDescData = file_poktroll_session_genesis_proto_rawDesc +) + +func file_poktroll_session_genesis_proto_rawDescGZIP() []byte { + file_poktroll_session_genesis_proto_rawDescOnce.Do(func() { + file_poktroll_session_genesis_proto_rawDescData = protoimpl.X.CompressGZIP(file_poktroll_session_genesis_proto_rawDescData) + }) + return file_poktroll_session_genesis_proto_rawDescData +} + +var file_poktroll_session_genesis_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_poktroll_session_genesis_proto_goTypes = []interface{}{ + (*GenesisState)(nil), // 0: poktroll.session.GenesisState + (*Params)(nil), // 1: poktroll.session.Params +} +var file_poktroll_session_genesis_proto_depIdxs = []int32{ + 1, // 0: poktroll.session.GenesisState.params:type_name -> poktroll.session.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_session_genesis_proto_init() } +func file_poktroll_session_genesis_proto_init() { + if File_poktroll_session_genesis_proto != nil { + return + } + file_poktroll_session_params_proto_init() + if !protoimpl.UnsafeEnabled { + file_poktroll_session_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_session_genesis_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_poktroll_session_genesis_proto_goTypes, + DependencyIndexes: file_poktroll_session_genesis_proto_depIdxs, + MessageInfos: file_poktroll_session_genesis_proto_msgTypes, + }.Build() + File_poktroll_session_genesis_proto = out.File + file_poktroll_session_genesis_proto_rawDesc = nil + file_poktroll_session_genesis_proto_goTypes = nil + file_poktroll_session_genesis_proto_depIdxs = nil +} diff --git a/api/poktroll/session/module/module.pulsar.go b/api/poktroll/session/module/module.pulsar.go new file mode 100644 index 000000000..66f2ee183 --- /dev/null +++ b/api/poktroll/session/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_session_module_module_proto_init() + md_Module = File_poktroll_session_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_session_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.session.module.Module.authority": + return x.Authority != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.module.Module")) + } + panic(fmt.Errorf("message poktroll.session.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.session.module.Module.authority": + x.Authority = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.module.Module")) + } + panic(fmt.Errorf("message poktroll.session.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.session.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.session.module.Module")) + } + panic(fmt.Errorf("message poktroll.session.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.session.module.Module.authority": + x.Authority = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.module.Module")) + } + panic(fmt.Errorf("message poktroll.session.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.session.module.Module.authority": + panic(fmt.Errorf("field authority of message poktroll.session.module.Module is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.module.Module")) + } + panic(fmt.Errorf("message poktroll.session.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.session.module.Module.authority": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.module.Module")) + } + panic(fmt.Errorf("message poktroll.session.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.session.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/session/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_session_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_session_module_module_proto_rawDescGZIP(), []int{0} +} + +func (x *Module) GetAuthority() string { + if x != nil { + return x.Authority + } + return "" +} + +var File_poktroll_session_module_module_proto protoreflect.FileDescriptor + +var file_poktroll_session_module_module_proto_rawDesc = []byte{ + 0x0a, 0x24, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x17, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 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, 0x5a, 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, 0x32, 0xba, 0xc0, 0x96, 0xda, 0x01, + 0x2c, 0x0a, 0x2a, 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, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0xd2, 0x01, + 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x42, 0x0b, 0x4d, + 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x28, 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, 0x2f, + 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x4d, 0xaa, 0x02, 0x17, 0x50, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, + 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0xca, 0x02, 0x17, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, + 0xe2, 0x02, 0x23, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x3a, 0x3a, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75, + 0x6c, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_poktroll_session_module_module_proto_rawDescOnce sync.Once + file_poktroll_session_module_module_proto_rawDescData = file_poktroll_session_module_module_proto_rawDesc +) + +func file_poktroll_session_module_module_proto_rawDescGZIP() []byte { + file_poktroll_session_module_module_proto_rawDescOnce.Do(func() { + file_poktroll_session_module_module_proto_rawDescData = protoimpl.X.CompressGZIP(file_poktroll_session_module_module_proto_rawDescData) + }) + return file_poktroll_session_module_module_proto_rawDescData +} + +var file_poktroll_session_module_module_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_poktroll_session_module_module_proto_goTypes = []interface{}{ + (*Module)(nil), // 0: poktroll.session.module.Module +} +var file_poktroll_session_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_session_module_module_proto_init() } +func file_poktroll_session_module_module_proto_init() { + if File_poktroll_session_module_module_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_poktroll_session_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_session_module_module_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_poktroll_session_module_module_proto_goTypes, + DependencyIndexes: file_poktroll_session_module_module_proto_depIdxs, + MessageInfos: file_poktroll_session_module_module_proto_msgTypes, + }.Build() + File_poktroll_session_module_module_proto = out.File + file_poktroll_session_module_module_proto_rawDesc = nil + file_poktroll_session_module_module_proto_goTypes = nil + file_poktroll_session_module_module_proto_depIdxs = nil +} diff --git a/api/poktroll/session/params.pulsar.go b/api/poktroll/session/params.pulsar.go new file mode 100644 index 000000000..c9ea81482 --- /dev/null +++ b/api/poktroll/session/params.pulsar.go @@ -0,0 +1,499 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package session + +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_session_params_proto_init() + md_Params = File_poktroll_session_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_session_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.session.Params")) + } + panic(fmt.Errorf("message poktroll.session.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.session.Params")) + } + panic(fmt.Errorf("message poktroll.session.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.session.Params")) + } + panic(fmt.Errorf("message poktroll.session.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.session.Params")) + } + panic(fmt.Errorf("message poktroll.session.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.session.Params")) + } + panic(fmt.Errorf("message poktroll.session.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.session.Params")) + } + panic(fmt.Errorf("message poktroll.session.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.session.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/session/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_session_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_session_params_proto_rawDescGZIP(), []int{0} +} + +var File_poktroll_session_params_proto protoreflect.FileDescriptor + +var file_poktroll_session_params_proto_rawDesc = []byte{ + 0x0a, 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, 0x12, + 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, +} + +var ( + file_poktroll_session_params_proto_rawDescOnce sync.Once + file_poktroll_session_params_proto_rawDescData = file_poktroll_session_params_proto_rawDesc +) + +func file_poktroll_session_params_proto_rawDescGZIP() []byte { + file_poktroll_session_params_proto_rawDescOnce.Do(func() { + file_poktroll_session_params_proto_rawDescData = protoimpl.X.CompressGZIP(file_poktroll_session_params_proto_rawDescData) + }) + return file_poktroll_session_params_proto_rawDescData +} + +var file_poktroll_session_params_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_poktroll_session_params_proto_goTypes = []interface{}{ + (*Params)(nil), // 0: poktroll.session.Params +} +var file_poktroll_session_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_session_params_proto_init() } +func file_poktroll_session_params_proto_init() { + if File_poktroll_session_params_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_poktroll_session_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_session_params_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_poktroll_session_params_proto_goTypes, + DependencyIndexes: file_poktroll_session_params_proto_depIdxs, + MessageInfos: file_poktroll_session_params_proto_msgTypes, + }.Build() + File_poktroll_session_params_proto = out.File + file_poktroll_session_params_proto_rawDesc = nil + file_poktroll_session_params_proto_goTypes = nil + file_poktroll_session_params_proto_depIdxs = nil +} diff --git a/api/poktroll/session/query.pulsar.go b/api/poktroll/session/query.pulsar.go new file mode 100644 index 000000000..2bcff4417 --- /dev/null +++ b/api/poktroll/session/query.pulsar.go @@ -0,0 +1,1010 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package session + +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_session_query_proto_init() + md_QueryParamsRequest = File_poktroll_session_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_session_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.session.QueryParamsRequest")) + } + panic(fmt.Errorf("message poktroll.session.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.session.QueryParamsRequest")) + } + panic(fmt.Errorf("message poktroll.session.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.session.QueryParamsRequest")) + } + panic(fmt.Errorf("message poktroll.session.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.session.QueryParamsRequest")) + } + panic(fmt.Errorf("message poktroll.session.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.session.QueryParamsRequest")) + } + panic(fmt.Errorf("message poktroll.session.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.session.QueryParamsRequest")) + } + panic(fmt.Errorf("message poktroll.session.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.session.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_session_query_proto_init() + md_QueryParamsResponse = File_poktroll_session_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_session_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.session.QueryParamsResponse.params": + return x.Params != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryParamsResponse")) + } + panic(fmt.Errorf("message poktroll.session.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.session.QueryParamsResponse.params": + x.Params = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryParamsResponse")) + } + panic(fmt.Errorf("message poktroll.session.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.session.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.session.QueryParamsResponse")) + } + panic(fmt.Errorf("message poktroll.session.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.session.QueryParamsResponse.params": + x.Params = value.Message().Interface().(*Params) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryParamsResponse")) + } + panic(fmt.Errorf("message poktroll.session.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.session.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.session.QueryParamsResponse")) + } + panic(fmt.Errorf("message poktroll.session.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.session.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.session.QueryParamsResponse")) + } + panic(fmt.Errorf("message poktroll.session.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.session.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/session/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_session_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_session_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_session_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_session_query_proto_rawDescGZIP(), []int{1} +} + +func (x *QueryParamsResponse) GetParams() *Params { + if x != nil { + return x.Params + } + return nil +} + +var File_poktroll_session_query_proto protoreflect.FileDescriptor + +var file_poktroll_session_query_proto_rawDesc = []byte{ + 0x0a, 0x1c, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 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, 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, 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, 0x14, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x52, 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x3b, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 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, 0x32, 0x8e, 0x01, 0x0a, + 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x84, 0x01, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x73, 0x12, 0x24, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, + 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2d, + 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x12, 0x25, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, + 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xa6, 0x01, + 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 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 ( + file_poktroll_session_query_proto_rawDescOnce sync.Once + file_poktroll_session_query_proto_rawDescData = file_poktroll_session_query_proto_rawDesc +) + +func file_poktroll_session_query_proto_rawDescGZIP() []byte { + file_poktroll_session_query_proto_rawDescOnce.Do(func() { + file_poktroll_session_query_proto_rawDescData = protoimpl.X.CompressGZIP(file_poktroll_session_query_proto_rawDescData) + }) + return file_poktroll_session_query_proto_rawDescData +} + +var file_poktroll_session_query_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_poktroll_session_query_proto_goTypes = []interface{}{ + (*QueryParamsRequest)(nil), // 0: poktroll.session.QueryParamsRequest + (*QueryParamsResponse)(nil), // 1: poktroll.session.QueryParamsResponse + (*Params)(nil), // 2: poktroll.session.Params +} +var file_poktroll_session_query_proto_depIdxs = []int32{ + 2, // 0: poktroll.session.QueryParamsResponse.params:type_name -> poktroll.session.Params + 0, // 1: poktroll.session.Query.Params:input_type -> poktroll.session.QueryParamsRequest + 1, // 2: poktroll.session.Query.Params:output_type -> poktroll.session.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_session_query_proto_init() } +func file_poktroll_session_query_proto_init() { + if File_poktroll_session_query_proto != nil { + return + } + file_poktroll_session_params_proto_init() + if !protoimpl.UnsafeEnabled { + file_poktroll_session_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_session_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_session_query_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_poktroll_session_query_proto_goTypes, + DependencyIndexes: file_poktroll_session_query_proto_depIdxs, + MessageInfos: file_poktroll_session_query_proto_msgTypes, + }.Build() + File_poktroll_session_query_proto = out.File + file_poktroll_session_query_proto_rawDesc = nil + file_poktroll_session_query_proto_goTypes = nil + file_poktroll_session_query_proto_depIdxs = nil +} diff --git a/api/poktroll/session/tx.pulsar.go b/api/poktroll/session/tx.pulsar.go new file mode 100644 index 000000000..20ba9d62e --- /dev/null +++ b/api/poktroll/session/tx.pulsar.go @@ -0,0 +1,1089 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package session + +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_session_tx_proto_init() + md_MsgUpdateParams = File_poktroll_session_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_session_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.session.MsgUpdateParams.authority": + return x.Authority != "" + case "poktroll.session.MsgUpdateParams.params": + return x.Params != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.MsgUpdateParams")) + } + panic(fmt.Errorf("message poktroll.session.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.session.MsgUpdateParams.authority": + x.Authority = "" + case "poktroll.session.MsgUpdateParams.params": + x.Params = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.MsgUpdateParams")) + } + panic(fmt.Errorf("message poktroll.session.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.session.MsgUpdateParams.authority": + value := x.Authority + return protoreflect.ValueOfString(value) + case "poktroll.session.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.session.MsgUpdateParams")) + } + panic(fmt.Errorf("message poktroll.session.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.session.MsgUpdateParams.authority": + x.Authority = value.Interface().(string) + case "poktroll.session.MsgUpdateParams.params": + x.Params = value.Message().Interface().(*Params) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.MsgUpdateParams")) + } + panic(fmt.Errorf("message poktroll.session.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.session.MsgUpdateParams.params": + if x.Params == nil { + x.Params = new(Params) + } + return protoreflect.ValueOfMessage(x.Params.ProtoReflect()) + case "poktroll.session.MsgUpdateParams.authority": + panic(fmt.Errorf("field authority of message poktroll.session.MsgUpdateParams is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.MsgUpdateParams")) + } + panic(fmt.Errorf("message poktroll.session.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.session.MsgUpdateParams.authority": + return protoreflect.ValueOfString("") + case "poktroll.session.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.session.MsgUpdateParams")) + } + panic(fmt.Errorf("message poktroll.session.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.session.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_session_tx_proto_init() + md_MsgUpdateParamsResponse = File_poktroll_session_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_session_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.session.MsgUpdateParamsResponse")) + } + panic(fmt.Errorf("message poktroll.session.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.session.MsgUpdateParamsResponse")) + } + panic(fmt.Errorf("message poktroll.session.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.session.MsgUpdateParamsResponse")) + } + panic(fmt.Errorf("message poktroll.session.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.session.MsgUpdateParamsResponse")) + } + panic(fmt.Errorf("message poktroll.session.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.session.MsgUpdateParamsResponse")) + } + panic(fmt.Errorf("message poktroll.session.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.session.MsgUpdateParamsResponse")) + } + panic(fmt.Errorf("message poktroll.session.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.session.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/session/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_session_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_session_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_session_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_session_tx_proto_rawDescGZIP(), []int{1} +} + +var File_poktroll_session_tx_proto protoreflect.FileDescriptor + +var file_poktroll_session_tx_proto_rawDesc = []byte{ + 0x0a, 0x19, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x2f, 0x74, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 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, 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, 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, + 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, + 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, +} + +var ( + file_poktroll_session_tx_proto_rawDescOnce sync.Once + file_poktroll_session_tx_proto_rawDescData = file_poktroll_session_tx_proto_rawDesc +) + +func file_poktroll_session_tx_proto_rawDescGZIP() []byte { + file_poktroll_session_tx_proto_rawDescOnce.Do(func() { + file_poktroll_session_tx_proto_rawDescData = protoimpl.X.CompressGZIP(file_poktroll_session_tx_proto_rawDescData) + }) + return file_poktroll_session_tx_proto_rawDescData +} + +var file_poktroll_session_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_poktroll_session_tx_proto_goTypes = []interface{}{ + (*MsgUpdateParams)(nil), // 0: poktroll.session.MsgUpdateParams + (*MsgUpdateParamsResponse)(nil), // 1: poktroll.session.MsgUpdateParamsResponse + (*Params)(nil), // 2: poktroll.session.Params +} +var file_poktroll_session_tx_proto_depIdxs = []int32{ + 2, // 0: poktroll.session.MsgUpdateParams.params:type_name -> poktroll.session.Params + 0, // 1: poktroll.session.Msg.UpdateParams:input_type -> poktroll.session.MsgUpdateParams + 1, // 2: poktroll.session.Msg.UpdateParams:output_type -> poktroll.session.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_session_tx_proto_init() } +func file_poktroll_session_tx_proto_init() { + if File_poktroll_session_tx_proto != nil { + return + } + file_poktroll_session_params_proto_init() + if !protoimpl.UnsafeEnabled { + file_poktroll_session_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_session_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_session_tx_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_poktroll_session_tx_proto_goTypes, + DependencyIndexes: file_poktroll_session_tx_proto_depIdxs, + MessageInfos: file_poktroll_session_tx_proto_msgTypes, + }.Build() + File_poktroll_session_tx_proto = out.File + file_poktroll_session_tx_proto_rawDesc = nil + file_poktroll_session_tx_proto_goTypes = nil + file_poktroll_session_tx_proto_depIdxs = nil +} diff --git a/app/app.go b/app/app.go index fe3daf4af..996581a93 100644 --- a/app/app.go +++ b/app/app.go @@ -58,6 +58,7 @@ import ( servicemodulekeeper "github.com/pokt-network/poktroll/x/service/keeper" suppliermodulekeeper "github.com/pokt-network/poktroll/x/supplier/keeper" + sessionmodulekeeper "github.com/pokt-network/poktroll/x/session/keeper" // this line is used by starport scaffolding # stargate/app/moduleImport "github.com/pokt-network/poktroll/docs" @@ -126,6 +127,7 @@ type App struct { GatewayKeeper gatewaymodulekeeper.Keeper ApplicationKeeper applicationmodulekeeper.Keeper SupplierKeeper suppliermodulekeeper.Keeper + SessionKeeper sessionmodulekeeper.Keeper // this line is used by starport scaffolding # stargate/app/keeperDeclaration // simulation manager @@ -268,6 +270,7 @@ func New( &app.GatewayKeeper, &app.ApplicationKeeper, &app.SupplierKeeper, + &app.SessionKeeper, // 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 72078535c..e4cc1b5e2 100644 --- a/app/app_config.go +++ b/app/app_config.go @@ -79,6 +79,8 @@ import ( gatewaymoduletypes "github.com/pokt-network/poktroll/x/gateway/types" _ "github.com/pokt-network/poktroll/x/service/module" // import for side-effects servicemoduletypes "github.com/pokt-network/poktroll/x/service/types" + _ "github.com/pokt-network/poktroll/x/session/module" // import for side-effects + sessionmoduletypes "github.com/pokt-network/poktroll/x/session/types" _ "github.com/pokt-network/poktroll/x/supplier/module" // import for side-effects suppliermoduletypes "github.com/pokt-network/poktroll/x/supplier/types" "google.golang.org/protobuf/types/known/durationpb" @@ -123,6 +125,7 @@ var ( gatewaymoduletypes.ModuleName, applicationmoduletypes.ModuleName, suppliermoduletypes.ModuleName, + sessionmoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/initGenesis } @@ -151,6 +154,7 @@ var ( gatewaymoduletypes.ModuleName, applicationmoduletypes.ModuleName, suppliermoduletypes.ModuleName, + sessionmoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/beginBlockers } @@ -173,6 +177,7 @@ var ( gatewaymoduletypes.ModuleName, applicationmoduletypes.ModuleName, suppliermoduletypes.ModuleName, + sessionmoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/endBlockers } @@ -196,6 +201,9 @@ var ( {Account: gatewaymoduletypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner, authtypes.Staking}}, {Account: applicationmoduletypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner, authtypes.Staking}}, {Account: suppliermoduletypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner, authtypes.Staking}}, + {Account: sessionmoduletypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner, authtypes.Staking}}, + {Account: sessionmoduletypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner, authtypes.Staking}}, + {Account: sessionmoduletypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner, authtypes.Staking}}, // this line is used by starport scaffolding # stargate/app/maccPerms } @@ -342,6 +350,10 @@ var ( Name: suppliermoduletypes.ModuleName, Config: appconfig.WrapAny(&suppliermodulev1.Module{}), }, + { + Name: sessionmoduletypes.ModuleName, + Config: appconfig.WrapAny(&sessionmodulev1.Module{}), + }, // this line is used by starport scaffolding # stargate/app/moduleConfig }, }) diff --git a/proto/poktroll/session/genesis.proto b/proto/poktroll/session/genesis.proto new file mode 100644 index 000000000..bd2f42a8e --- /dev/null +++ b/proto/poktroll/session/genesis.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package poktroll.session; + +import "amino/amino.proto"; +import "gogoproto/gogo.proto"; +import "poktroll/session/params.proto"; + +option go_package = "github.com/pokt-network/poktroll/x/session/types"; + +// GenesisState defines the session 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/session/module/module.proto b/proto/poktroll/session/module/module.proto new file mode 100644 index 000000000..b3c5e4339 --- /dev/null +++ b/proto/poktroll/session/module/module.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package poktroll.session.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/session" + }; + + // 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/session/params.proto b/proto/poktroll/session/params.proto new file mode 100644 index 000000000..1e4784a20 --- /dev/null +++ b/proto/poktroll/session/params.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package poktroll.session; + +import "amino/amino.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/pokt-network/poktroll/x/session/types"; + +// Params defines the parameters for the module. +message Params { + option (amino.name) = "poktroll/x/session/Params"; + option (gogoproto.equal) = true; + + +} \ No newline at end of file diff --git a/proto/poktroll/session/query.proto b/proto/poktroll/session/query.proto new file mode 100644 index 000000000..86d926a58 --- /dev/null +++ b/proto/poktroll/session/query.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; +package poktroll.session; + +import "amino/amino.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "poktroll/session/params.proto"; + +option go_package = "github.com/pokt-network/poktroll/x/session/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/session/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/session/tx.proto b/proto/poktroll/session/tx.proto new file mode 100644 index 000000000..37e78c39a --- /dev/null +++ b/proto/poktroll/session/tx.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; +package poktroll.session; + +import "amino/amino.proto"; +import "cosmos/msg/v1/msg.proto"; +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "poktroll/session/params.proto"; + +option go_package = "github.com/pokt-network/poktroll/x/session/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/session/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/x/session/keeper/keeper.go b/x/session/keeper/keeper.go new file mode 100644 index 000000000..24dd364b7 --- /dev/null +++ b/x/session/keeper/keeper.go @@ -0,0 +1,67 @@ +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/session/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 + + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper + applicationKeeper types.ApplicationKeeper + supplierKeeper types.SupplierKeeper + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeService store.KVStoreService, + logger log.Logger, + authority string, + + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, + applicationKeeper types.ApplicationKeeper, + supplierKeeper types.SupplierKeeper, +) 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, + + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + applicationKeeper: applicationKeeper, + supplierKeeper: supplierKeeper, + } +} + +// 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/session/keeper/msg_server.go b/x/session/keeper/msg_server.go new file mode 100644 index 000000000..6dbe55462 --- /dev/null +++ b/x/session/keeper/msg_server.go @@ -0,0 +1,17 @@ +package keeper + +import ( + "github.com/pokt-network/poktroll/x/session/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/session/keeper/msg_server_test.go b/x/session/keeper/msg_server_test.go new file mode 100644 index 000000000..d3c3bd5bd --- /dev/null +++ b/x/session/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/session/keeper" + "github.com/pokt-network/poktroll/x/session/types" +) + +func setupMsgServer(t testing.TB) (keeper.Keeper, types.MsgServer, context.Context) { + k, ctx := keepertest.SessionKeeper(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) +} diff --git a/x/session/keeper/msg_update_params.go b/x/session/keeper/msg_update_params.go new file mode 100644 index 000000000..04360d582 --- /dev/null +++ b/x/session/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/session/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/session/keeper/msg_update_params_test.go b/x/session/keeper/msg_update_params_test.go new file mode 100644 index 000000000..d645dac66 --- /dev/null +++ b/x/session/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/session/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/session/keeper/params.go b/x/session/keeper/params.go new file mode 100644 index 000000000..deb132ff1 --- /dev/null +++ b/x/session/keeper/params.go @@ -0,0 +1,33 @@ +package keeper + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/runtime" + + "github.com/pokt-network/poktroll/x/session/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/session/keeper/params_test.go b/x/session/keeper/params_test.go new file mode 100644 index 000000000..6a6c06f17 --- /dev/null +++ b/x/session/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/session/types" +) + +func TestGetParams(t *testing.T) { + k, ctx := keepertest.SessionKeeper(t) + params := types.DefaultParams() + + require.NoError(t, k.SetParams(ctx, params)) + require.EqualValues(t, params, k.GetParams(ctx)) +} diff --git a/x/session/keeper/query.go b/x/session/keeper/query.go new file mode 100644 index 000000000..700ec87e8 --- /dev/null +++ b/x/session/keeper/query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/pokt-network/poktroll/x/session/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/session/keeper/query_params.go b/x/session/keeper/query_params.go new file mode 100644 index 000000000..75734ad7a --- /dev/null +++ b/x/session/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/session/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/session/keeper/query_params_test.go b/x/session/keeper/query_params_test.go new file mode 100644 index 000000000..4e8acf5d7 --- /dev/null +++ b/x/session/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/session/types" +) + +func TestParamsQuery(t *testing.T) { + keeper, ctx := keepertest.SessionKeeper(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/session/module/autocli.go b/x/session/module/autocli.go new file mode 100644 index 000000000..d16cee25d --- /dev/null +++ b/x/session/module/autocli.go @@ -0,0 +1,35 @@ +package session + +import ( + autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" + + modulev1 "github.com/pokt-network/poktroll/api/poktroll/session" +) + +// 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 + }, + }, + } +} diff --git a/x/session/module/genesis.go b/x/session/module/genesis.go new file mode 100644 index 000000000..2007b8a74 --- /dev/null +++ b/x/session/module/genesis.go @@ -0,0 +1,24 @@ +package session + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/pokt-network/poktroll/x/session/keeper" + "github.com/pokt-network/poktroll/x/session/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/session/module/genesis_test.go b/x/session/module/genesis_test.go new file mode 100644 index 000000000..a6e2d7ded --- /dev/null +++ b/x/session/module/genesis_test.go @@ -0,0 +1,29 @@ +package session_test + +import ( + "testing" + + keepertest "github.com/pokt-network/poktroll/testutil/keeper" + "github.com/pokt-network/poktroll/testutil/nullify" + "github.com/pokt-network/poktroll/x/session/module" + "github.com/pokt-network/poktroll/x/session/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.SessionKeeper(t) + session.InitGenesis(ctx, k, genesisState) + got := session.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/session/module/module.go b/x/session/module/module.go new file mode 100644 index 000000000..733e8bf0f --- /dev/null +++ b/x/session/module/module.go @@ -0,0 +1,220 @@ +package session + +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/session/module" + "github.com/pokt-network/poktroll/x/session/keeper" + "github.com/pokt-network/poktroll/x/session/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 + ApplicationKeeper types.ApplicationKeeper + SupplierKeeper types.SupplierKeeper +} + +type ModuleOutputs struct { + depinject.Out + + SessionKeeper 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(), + in.AccountKeeper, + in.BankKeeper, + in.ApplicationKeeper, + in.SupplierKeeper, + ) + m := NewAppModule( + in.Cdc, + k, + in.AccountKeeper, + in.BankKeeper, + ) + + return ModuleOutputs{SessionKeeper: k, Module: m} +} diff --git a/x/session/module/simulation.go b/x/session/module/simulation.go new file mode 100644 index 000000000..2a654eb18 --- /dev/null +++ b/x/session/module/simulation.go @@ -0,0 +1,64 @@ +package session + +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" + sessionsimulation "github.com/pokt-network/poktroll/x/session/simulation" + "github.com/pokt-network/poktroll/x/session/types" +) + +// avoid unused import issue +var ( + _ = sessionsimulation.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() + } + sessionGenesis := types.GenesisState{ + Params: types.DefaultParams(), + // this line is used by starport scaffolding # simapp/module/genesisState + } + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&sessionGenesis) +} + +// 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/session/simulation/helpers.go b/x/session/simulation/helpers.go new file mode 100644 index 000000000..92c437c0d --- /dev/null +++ b/x/session/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/session/types/codec.go b/x/session/types/codec.go new file mode 100644 index 000000000..ac5526374 --- /dev/null +++ b/x/session/types/codec.go @@ -0,0 +1,17 @@ +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/session/types/errors.go b/x/session/types/errors.go new file mode 100644 index 000000000..a5e632f95 --- /dev/null +++ b/x/session/types/errors.go @@ -0,0 +1,13 @@ +package types + +// DONTCOVER + +import ( + sdkerrors "cosmossdk.io/errors" +) + +// x/session 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/session/types/expected_keepers.go b/x/session/types/expected_keepers.go new file mode 100644 index 000000000..b803d09ec --- /dev/null +++ b/x/session/types/expected_keepers.go @@ -0,0 +1,33 @@ +package types + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type ApplicationKeeper interface { + // TODO Add methods imported from application should be defined here +} + +type SupplierKeeper interface { + // TODO Add methods imported from supplier should be defined here +} + +// 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/session/types/genesis.go b/x/session/types/genesis.go new file mode 100644 index 000000000..0af9b4416 --- /dev/null +++ b/x/session/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/session/types/genesis_test.go b/x/session/types/genesis_test.go new file mode 100644 index 000000000..5393179e8 --- /dev/null +++ b/x/session/types/genesis_test.go @@ -0,0 +1,41 @@ +package types_test + +import ( + "testing" + + "github.com/pokt-network/poktroll/x/session/types" + "github.com/stretchr/testify/require" +) + +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) + } + }) + } +} diff --git a/x/session/types/keys.go b/x/session/types/keys.go new file mode 100644 index 000000000..c798c9a12 --- /dev/null +++ b/x/session/types/keys.go @@ -0,0 +1,20 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "session" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_session" +) + +var ( + ParamsKey = []byte("p_session") +) + +func KeyPrefix(p string) []byte { + return []byte(p) +} diff --git a/x/session/types/msg_update_params.go b/x/session/types/msg_update_params.go new file mode 100644 index 000000000..e36d023de --- /dev/null +++ b/x/session/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/session/types/params.go b/x/session/types/params.go new file mode 100644 index 000000000..4f3215e35 --- /dev/null +++ b/x/session/types/params.go @@ -0,0 +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{} +} + +// 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/session/types/types.go b/x/session/types/types.go new file mode 100644 index 000000000..ab1254f4c --- /dev/null +++ b/x/session/types/types.go @@ -0,0 +1 @@ +package types From 9ce6bf4a33e18ff6e1991619ac41e17e2ac5f36f Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Mon, 12 Feb 2024 13:53:23 +0100 Subject: [PATCH 02/24] scaffold: query get-session --module session ignite scaffold query get-session application_address service_id block_height --module session --- api/poktroll/session/query.pulsar.go | 1090 ++++++++++++++++++++++++- proto/poktroll/session/query.proto | 29 +- x/session/keeper/query_get_session.go | 23 + x/session/module/autocli.go | 7 + 4 files changed, 1113 insertions(+), 36 deletions(-) create mode 100644 x/session/keeper/query_get_session.go diff --git a/api/poktroll/session/query.pulsar.go b/api/poktroll/session/query.pulsar.go index 2bcff4417..e52fb39ef 100644 --- a/api/poktroll/session/query.pulsar.go +++ b/api/poktroll/session/query.pulsar.go @@ -807,6 +807,910 @@ func (x *fastReflection_QueryParamsResponse) ProtoMethods() *protoiface.Methods } } +var ( + md_QueryGetSessionRequest protoreflect.MessageDescriptor + fd_QueryGetSessionRequest_applicationAddress protoreflect.FieldDescriptor + fd_QueryGetSessionRequest_serviceId protoreflect.FieldDescriptor + fd_QueryGetSessionRequest_blockHeight protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_session_query_proto_init() + md_QueryGetSessionRequest = File_poktroll_session_query_proto.Messages().ByName("QueryGetSessionRequest") + fd_QueryGetSessionRequest_applicationAddress = md_QueryGetSessionRequest.Fields().ByName("applicationAddress") + fd_QueryGetSessionRequest_serviceId = md_QueryGetSessionRequest.Fields().ByName("serviceId") + fd_QueryGetSessionRequest_blockHeight = md_QueryGetSessionRequest.Fields().ByName("blockHeight") +} + +var _ protoreflect.Message = (*fastReflection_QueryGetSessionRequest)(nil) + +type fastReflection_QueryGetSessionRequest QueryGetSessionRequest + +func (x *QueryGetSessionRequest) ProtoReflect() protoreflect.Message { + return (*fastReflection_QueryGetSessionRequest)(x) +} + +func (x *QueryGetSessionRequest) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_session_query_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_QueryGetSessionRequest_messageType fastReflection_QueryGetSessionRequest_messageType +var _ protoreflect.MessageType = fastReflection_QueryGetSessionRequest_messageType{} + +type fastReflection_QueryGetSessionRequest_messageType struct{} + +func (x fastReflection_QueryGetSessionRequest_messageType) Zero() protoreflect.Message { + return (*fastReflection_QueryGetSessionRequest)(nil) +} +func (x fastReflection_QueryGetSessionRequest_messageType) New() protoreflect.Message { + return new(fastReflection_QueryGetSessionRequest) +} +func (x fastReflection_QueryGetSessionRequest_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_QueryGetSessionRequest +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_QueryGetSessionRequest) Descriptor() protoreflect.MessageDescriptor { + return md_QueryGetSessionRequest +} + +// 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_QueryGetSessionRequest) Type() protoreflect.MessageType { + return _fastReflection_QueryGetSessionRequest_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_QueryGetSessionRequest) New() protoreflect.Message { + return new(fastReflection_QueryGetSessionRequest) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_QueryGetSessionRequest) Interface() protoreflect.ProtoMessage { + return (*QueryGetSessionRequest)(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_QueryGetSessionRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.ApplicationAddress != "" { + value := protoreflect.ValueOfString(x.ApplicationAddress) + if !f(fd_QueryGetSessionRequest_applicationAddress, value) { + return + } + } + if x.ServiceId != "" { + value := protoreflect.ValueOfString(x.ServiceId) + if !f(fd_QueryGetSessionRequest_serviceId, value) { + return + } + } + if x.BlockHeight != "" { + value := protoreflect.ValueOfString(x.BlockHeight) + if !f(fd_QueryGetSessionRequest_blockHeight, 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_QueryGetSessionRequest) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.session.QueryGetSessionRequest.applicationAddress": + return x.ApplicationAddress != "" + case "poktroll.session.QueryGetSessionRequest.serviceId": + return x.ServiceId != "" + case "poktroll.session.QueryGetSessionRequest.blockHeight": + return x.BlockHeight != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionRequest")) + } + panic(fmt.Errorf("message poktroll.session.QueryGetSessionRequest 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_QueryGetSessionRequest) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.session.QueryGetSessionRequest.applicationAddress": + x.ApplicationAddress = "" + case "poktroll.session.QueryGetSessionRequest.serviceId": + x.ServiceId = "" + case "poktroll.session.QueryGetSessionRequest.blockHeight": + x.BlockHeight = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionRequest")) + } + panic(fmt.Errorf("message poktroll.session.QueryGetSessionRequest 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_QueryGetSessionRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.session.QueryGetSessionRequest.applicationAddress": + value := x.ApplicationAddress + return protoreflect.ValueOfString(value) + case "poktroll.session.QueryGetSessionRequest.serviceId": + value := x.ServiceId + return protoreflect.ValueOfString(value) + case "poktroll.session.QueryGetSessionRequest.blockHeight": + value := x.BlockHeight + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionRequest")) + } + panic(fmt.Errorf("message poktroll.session.QueryGetSessionRequest 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_QueryGetSessionRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.session.QueryGetSessionRequest.applicationAddress": + x.ApplicationAddress = value.Interface().(string) + case "poktroll.session.QueryGetSessionRequest.serviceId": + x.ServiceId = value.Interface().(string) + case "poktroll.session.QueryGetSessionRequest.blockHeight": + x.BlockHeight = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionRequest")) + } + panic(fmt.Errorf("message poktroll.session.QueryGetSessionRequest 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_QueryGetSessionRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.session.QueryGetSessionRequest.applicationAddress": + panic(fmt.Errorf("field applicationAddress of message poktroll.session.QueryGetSessionRequest is not mutable")) + case "poktroll.session.QueryGetSessionRequest.serviceId": + panic(fmt.Errorf("field serviceId of message poktroll.session.QueryGetSessionRequest is not mutable")) + case "poktroll.session.QueryGetSessionRequest.blockHeight": + panic(fmt.Errorf("field blockHeight of message poktroll.session.QueryGetSessionRequest is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionRequest")) + } + panic(fmt.Errorf("message poktroll.session.QueryGetSessionRequest 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_QueryGetSessionRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.session.QueryGetSessionRequest.applicationAddress": + return protoreflect.ValueOfString("") + case "poktroll.session.QueryGetSessionRequest.serviceId": + return protoreflect.ValueOfString("") + case "poktroll.session.QueryGetSessionRequest.blockHeight": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionRequest")) + } + panic(fmt.Errorf("message poktroll.session.QueryGetSessionRequest 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_QueryGetSessionRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.session.QueryGetSessionRequest", 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_QueryGetSessionRequest) 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_QueryGetSessionRequest) 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_QueryGetSessionRequest) 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_QueryGetSessionRequest) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*QueryGetSessionRequest) + 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.ApplicationAddress) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.ServiceId) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.BlockHeight) + 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().(*QueryGetSessionRequest) + 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.BlockHeight) > 0 { + i -= len(x.BlockHeight) + copy(dAtA[i:], x.BlockHeight) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.BlockHeight))) + i-- + dAtA[i] = 0x1a + } + if len(x.ServiceId) > 0 { + i -= len(x.ServiceId) + copy(dAtA[i:], x.ServiceId) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ServiceId))) + i-- + dAtA[i] = 0x12 + } + if len(x.ApplicationAddress) > 0 { + i -= len(x.ApplicationAddress) + copy(dAtA[i:], x.ApplicationAddress) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ApplicationAddress))) + 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().(*QueryGetSessionRequest) + 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: QueryGetSessionRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryGetSessionRequest: 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 ApplicationAddress", 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.ApplicationAddress = 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 ServiceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.ServiceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", 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.BlockHeight = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_QueryGetSessionResponse protoreflect.MessageDescriptor +) + +func init() { + file_poktroll_session_query_proto_init() + md_QueryGetSessionResponse = File_poktroll_session_query_proto.Messages().ByName("QueryGetSessionResponse") +} + +var _ protoreflect.Message = (*fastReflection_QueryGetSessionResponse)(nil) + +type fastReflection_QueryGetSessionResponse QueryGetSessionResponse + +func (x *QueryGetSessionResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_QueryGetSessionResponse)(x) +} + +func (x *QueryGetSessionResponse) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_session_query_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_QueryGetSessionResponse_messageType fastReflection_QueryGetSessionResponse_messageType +var _ protoreflect.MessageType = fastReflection_QueryGetSessionResponse_messageType{} + +type fastReflection_QueryGetSessionResponse_messageType struct{} + +func (x fastReflection_QueryGetSessionResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_QueryGetSessionResponse)(nil) +} +func (x fastReflection_QueryGetSessionResponse_messageType) New() protoreflect.Message { + return new(fastReflection_QueryGetSessionResponse) +} +func (x fastReflection_QueryGetSessionResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_QueryGetSessionResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_QueryGetSessionResponse) Descriptor() protoreflect.MessageDescriptor { + return md_QueryGetSessionResponse +} + +// 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_QueryGetSessionResponse) Type() protoreflect.MessageType { + return _fastReflection_QueryGetSessionResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_QueryGetSessionResponse) New() protoreflect.Message { + return new(fastReflection_QueryGetSessionResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_QueryGetSessionResponse) Interface() protoreflect.ProtoMessage { + return (*QueryGetSessionResponse)(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_QueryGetSessionResponse) 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_QueryGetSessionResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionResponse")) + } + panic(fmt.Errorf("message poktroll.session.QueryGetSessionResponse 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_QueryGetSessionResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionResponse")) + } + panic(fmt.Errorf("message poktroll.session.QueryGetSessionResponse 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_QueryGetSessionResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionResponse")) + } + panic(fmt.Errorf("message poktroll.session.QueryGetSessionResponse 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_QueryGetSessionResponse) 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.session.QueryGetSessionResponse")) + } + panic(fmt.Errorf("message poktroll.session.QueryGetSessionResponse 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_QueryGetSessionResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionResponse")) + } + panic(fmt.Errorf("message poktroll.session.QueryGetSessionResponse 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_QueryGetSessionResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionResponse")) + } + panic(fmt.Errorf("message poktroll.session.QueryGetSessionResponse 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_QueryGetSessionResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.session.QueryGetSessionResponse", 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_QueryGetSessionResponse) 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_QueryGetSessionResponse) 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_QueryGetSessionResponse) 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_QueryGetSessionResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*QueryGetSessionResponse) + 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().(*QueryGetSessionResponse) + 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().(*QueryGetSessionResponse) + 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: QueryGetSessionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryGetSessionResponse: 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 @@ -884,6 +1788,83 @@ func (x *QueryParamsResponse) GetParams() *Params { return nil } +type QueryGetSessionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ApplicationAddress string `protobuf:"bytes,1,opt,name=applicationAddress,proto3" json:"applicationAddress,omitempty"` + ServiceId string `protobuf:"bytes,2,opt,name=serviceId,proto3" json:"serviceId,omitempty"` + BlockHeight string `protobuf:"bytes,3,opt,name=blockHeight,proto3" json:"blockHeight,omitempty"` +} + +func (x *QueryGetSessionRequest) Reset() { + *x = QueryGetSessionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_session_query_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryGetSessionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryGetSessionRequest) ProtoMessage() {} + +// Deprecated: Use QueryGetSessionRequest.ProtoReflect.Descriptor instead. +func (*QueryGetSessionRequest) Descriptor() ([]byte, []int) { + return file_poktroll_session_query_proto_rawDescGZIP(), []int{2} +} + +func (x *QueryGetSessionRequest) GetApplicationAddress() string { + if x != nil { + return x.ApplicationAddress + } + return "" +} + +func (x *QueryGetSessionRequest) GetServiceId() string { + if x != nil { + return x.ServiceId + } + return "" +} + +func (x *QueryGetSessionRequest) GetBlockHeight() string { + if x != nil { + return x.BlockHeight + } + return "" +} + +type QueryGetSessionResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *QueryGetSessionResponse) Reset() { + *x = QueryGetSessionResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_session_query_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryGetSessionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryGetSessionResponse) ProtoMessage() {} + +// Deprecated: Use QueryGetSessionResponse.ProtoReflect.Descriptor instead. +func (*QueryGetSessionResponse) Descriptor() ([]byte, []int) { + return file_poktroll_session_query_proto_rawDescGZIP(), []int{3} +} + var File_poktroll_session_query_proto protoreflect.FileDescriptor var file_poktroll_session_query_proto_rawDesc = []byte{ @@ -905,27 +1886,50 @@ var file_poktroll_session_query_proto_rawDesc = []byte{ 0x3b, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 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, 0x32, 0x8e, 0x01, 0x0a, - 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x84, 0x01, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x12, 0x24, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x88, 0x01, 0x0a, + 0x16, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2e, 0x0a, 0x12, 0x61, 0x70, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x12, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, + 0x69, 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x19, 0x0a, 0x17, 0x51, 0x75, 0x65, 0x72, 0x79, + 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x32, 0xd5, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x84, 0x01, 0x0a, + 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x24, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, - 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2d, - 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x12, 0x25, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, - 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, - 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xa6, 0x01, - 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, - 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 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, + 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, + 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x12, 0x25, 0x2f, 0x70, + 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, + 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x70, 0x61, 0x72, + 0x61, 0x6d, 0x73, 0x12, 0xc4, 0x01, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x28, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x70, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x61, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x5b, 0x12, + 0x59, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2f, + 0x67, 0x65, 0x74, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x7b, 0x61, 0x70, 0x70, + 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x7d, + 0x2f, 0x7b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x7d, 0x2f, 0x7b, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x7d, 0x42, 0xa6, 0x01, 0x0a, 0x14, 0x63, + 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 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 ( @@ -940,18 +1944,22 @@ func file_poktroll_session_query_proto_rawDescGZIP() []byte { return file_poktroll_session_query_proto_rawDescData } -var file_poktroll_session_query_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_poktroll_session_query_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_poktroll_session_query_proto_goTypes = []interface{}{ - (*QueryParamsRequest)(nil), // 0: poktroll.session.QueryParamsRequest - (*QueryParamsResponse)(nil), // 1: poktroll.session.QueryParamsResponse - (*Params)(nil), // 2: poktroll.session.Params + (*QueryParamsRequest)(nil), // 0: poktroll.session.QueryParamsRequest + (*QueryParamsResponse)(nil), // 1: poktroll.session.QueryParamsResponse + (*QueryGetSessionRequest)(nil), // 2: poktroll.session.QueryGetSessionRequest + (*QueryGetSessionResponse)(nil), // 3: poktroll.session.QueryGetSessionResponse + (*Params)(nil), // 4: poktroll.session.Params } var file_poktroll_session_query_proto_depIdxs = []int32{ - 2, // 0: poktroll.session.QueryParamsResponse.params:type_name -> poktroll.session.Params + 4, // 0: poktroll.session.QueryParamsResponse.params:type_name -> poktroll.session.Params 0, // 1: poktroll.session.Query.Params:input_type -> poktroll.session.QueryParamsRequest - 1, // 2: poktroll.session.Query.Params:output_type -> poktroll.session.QueryParamsResponse - 2, // [2:3] is the sub-list for method output_type - 1, // [1:2] is the sub-list for method input_type + 2, // 2: poktroll.session.Query.GetSession:input_type -> poktroll.session.QueryGetSessionRequest + 1, // 3: poktroll.session.Query.Params:output_type -> poktroll.session.QueryParamsResponse + 3, // 4: poktroll.session.Query.GetSession:output_type -> poktroll.session.QueryGetSessionResponse + 3, // [3:5] is the sub-list for method output_type + 1, // [1:3] 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 @@ -988,6 +1996,30 @@ func file_poktroll_session_query_proto_init() { return nil } } + file_poktroll_session_query_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryGetSessionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_poktroll_session_query_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryGetSessionResponse); 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{ @@ -995,7 +2027,7 @@ func file_poktroll_session_query_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_poktroll_session_query_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 4, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/poktroll/session/query.proto b/proto/poktroll/session/query.proto index 86d926a58..0209b38ca 100644 --- a/proto/poktroll/session/query.proto +++ b/proto/poktroll/session/query.proto @@ -1,4 +1,5 @@ syntax = "proto3"; + package poktroll.session; import "amino/amino.proto"; @@ -11,20 +12,34 @@ option go_package = "github.com/pokt-network/poktroll/x/session/types"; // Query defines the gRPC querier service. service Query { + // Parameters queries the parameters of the module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + rpc Params (QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/pokt-network/poktroll/session/params"; + + } + + // Queries a list of GetSession items. + rpc GetSession (QueryGetSessionRequest) returns (QueryGetSessionResponse) { + option (google.api.http).get = "/pokt-network/poktroll/session/get_session/{applicationAddress}/{serviceId}/{blockHeight}"; + } } - // 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 + Params params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; +} + +message QueryGetSessionRequest { + string applicationAddress = 1; + string serviceId = 2; + string blockHeight = 3; +} + +message QueryGetSessionResponse {} + diff --git a/x/session/keeper/query_get_session.go b/x/session/keeper/query_get_session.go new file mode 100644 index 000000000..073e0a0f3 --- /dev/null +++ b/x/session/keeper/query_get_session.go @@ -0,0 +1,23 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/pokt-network/poktroll/x/session/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) GetSession(goCtx context.Context, req *types.QueryGetSessionRequest) (*types.QueryGetSessionResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + // TODO: Process the query + _ = ctx + + return &types.QueryGetSessionResponse{}, nil +} diff --git a/x/session/module/autocli.go b/x/session/module/autocli.go index d16cee25d..8b07ed261 100644 --- a/x/session/module/autocli.go +++ b/x/session/module/autocli.go @@ -17,6 +17,13 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { Use: "params", Short: "Shows the parameters of the module", }, + { + RpcMethod: "GetSession", + Use: "get-session [application-address] [service-id] [block-height]", + Short: "Query get-session", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "applicationAddress"}, {ProtoField: "serviceId"}, {ProtoField: "blockHeight"}}, + }, + // this line is used by ignite scaffolding # autocli/query }, }, From f0c16884e7f800217b4ed5e2ec1f88e4b2901918 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Mon, 12 Feb 2024 14:10:09 +0100 Subject: [PATCH 03/24] reconcile: session related proto files --- api/poktroll/application/genesis.pulsar.go | 8 - api/poktroll/session/query.pulsar.go | 413 +++-- api/poktroll/session/session.pulsar.go | 1796 ++++++++++++++++++++ proto/poktroll/session/query.proto | 25 +- proto/poktroll/session/session.proto | 33 + 5 files changed, 2102 insertions(+), 173 deletions(-) create mode 100644 api/poktroll/session/session.pulsar.go create mode 100644 proto/poktroll/session/session.proto diff --git a/api/poktroll/application/genesis.pulsar.go b/api/poktroll/application/genesis.pulsar.go index 67b121817..02d9e6c3d 100644 --- a/api/poktroll/application/genesis.pulsar.go +++ b/api/poktroll/application/genesis.pulsar.go @@ -608,11 +608,7 @@ type GenesisState struct { // params defines all the parameters of the module. Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` -<<<<<<< HEAD ApplicationList []*Application `protobuf:"bytes,2,rep,name=application_list,json=applicationList,proto3" json:"application_list,omitempty"` -======= - ApplicationList []*Application `protobuf:"bytes,2,rep,name=applicationList,proto3" json:"applicationList,omitempty"` ->>>>>>> 87307009 (scaffold: module session --dep account,bank,application,supplier) } func (x *GenesisState) Reset() { @@ -708,11 +704,7 @@ var file_poktroll_application_genesis_proto_goTypes = []interface{}{ } var file_poktroll_application_genesis_proto_depIdxs = []int32{ 1, // 0: poktroll.application.GenesisState.params:type_name -> poktroll.application.Params -<<<<<<< HEAD 2, // 1: poktroll.application.GenesisState.application_list:type_name -> poktroll.application.Application -======= - 2, // 1: poktroll.application.GenesisState.applicationList:type_name -> poktroll.application.Application ->>>>>>> 87307009 (scaffold: module session --dep account,bank,application,supplier) 2, // [2:2] is the sub-list for method output_type 2, // [2:2] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name diff --git a/api/poktroll/session/query.pulsar.go b/api/poktroll/session/query.pulsar.go index e52fb39ef..77939bd87 100644 --- a/api/poktroll/session/query.pulsar.go +++ b/api/poktroll/session/query.pulsar.go @@ -5,8 +5,10 @@ import ( _ "cosmossdk.io/api/amino" _ "cosmossdk.io/api/cosmos/base/query/v1beta1" fmt "fmt" + _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" + shared "github.com/pokt-network/poktroll/api/poktroll/shared" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -808,18 +810,18 @@ func (x *fastReflection_QueryParamsResponse) ProtoMethods() *protoiface.Methods } var ( - md_QueryGetSessionRequest protoreflect.MessageDescriptor - fd_QueryGetSessionRequest_applicationAddress protoreflect.FieldDescriptor - fd_QueryGetSessionRequest_serviceId protoreflect.FieldDescriptor - fd_QueryGetSessionRequest_blockHeight protoreflect.FieldDescriptor + md_QueryGetSessionRequest protoreflect.MessageDescriptor + fd_QueryGetSessionRequest_application_address protoreflect.FieldDescriptor + fd_QueryGetSessionRequest_service protoreflect.FieldDescriptor + fd_QueryGetSessionRequest_block_height protoreflect.FieldDescriptor ) func init() { file_poktroll_session_query_proto_init() md_QueryGetSessionRequest = File_poktroll_session_query_proto.Messages().ByName("QueryGetSessionRequest") - fd_QueryGetSessionRequest_applicationAddress = md_QueryGetSessionRequest.Fields().ByName("applicationAddress") - fd_QueryGetSessionRequest_serviceId = md_QueryGetSessionRequest.Fields().ByName("serviceId") - fd_QueryGetSessionRequest_blockHeight = md_QueryGetSessionRequest.Fields().ByName("blockHeight") + fd_QueryGetSessionRequest_application_address = md_QueryGetSessionRequest.Fields().ByName("application_address") + fd_QueryGetSessionRequest_service = md_QueryGetSessionRequest.Fields().ByName("service") + fd_QueryGetSessionRequest_block_height = md_QueryGetSessionRequest.Fields().ByName("block_height") } var _ protoreflect.Message = (*fastReflection_QueryGetSessionRequest)(nil) @@ -889,19 +891,19 @@ func (x *fastReflection_QueryGetSessionRequest) Interface() protoreflect.ProtoMe func (x *fastReflection_QueryGetSessionRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { if x.ApplicationAddress != "" { value := protoreflect.ValueOfString(x.ApplicationAddress) - if !f(fd_QueryGetSessionRequest_applicationAddress, value) { + if !f(fd_QueryGetSessionRequest_application_address, value) { return } } - if x.ServiceId != "" { - value := protoreflect.ValueOfString(x.ServiceId) - if !f(fd_QueryGetSessionRequest_serviceId, value) { + if x.Service != nil { + value := protoreflect.ValueOfMessage(x.Service.ProtoReflect()) + if !f(fd_QueryGetSessionRequest_service, value) { return } } - if x.BlockHeight != "" { - value := protoreflect.ValueOfString(x.BlockHeight) - if !f(fd_QueryGetSessionRequest_blockHeight, value) { + if x.BlockHeight != int64(0) { + value := protoreflect.ValueOfInt64(x.BlockHeight) + if !f(fd_QueryGetSessionRequest_block_height, value) { return } } @@ -920,12 +922,12 @@ func (x *fastReflection_QueryGetSessionRequest) Range(f func(protoreflect.FieldD // a repeated field is populated if it is non-empty. func (x *fastReflection_QueryGetSessionRequest) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.session.QueryGetSessionRequest.applicationAddress": + case "poktroll.session.QueryGetSessionRequest.application_address": return x.ApplicationAddress != "" - case "poktroll.session.QueryGetSessionRequest.serviceId": - return x.ServiceId != "" - case "poktroll.session.QueryGetSessionRequest.blockHeight": - return x.BlockHeight != "" + case "poktroll.session.QueryGetSessionRequest.service": + return x.Service != nil + case "poktroll.session.QueryGetSessionRequest.block_height": + return x.BlockHeight != int64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionRequest")) @@ -942,12 +944,12 @@ func (x *fastReflection_QueryGetSessionRequest) Has(fd protoreflect.FieldDescrip // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetSessionRequest) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.session.QueryGetSessionRequest.applicationAddress": + case "poktroll.session.QueryGetSessionRequest.application_address": x.ApplicationAddress = "" - case "poktroll.session.QueryGetSessionRequest.serviceId": - x.ServiceId = "" - case "poktroll.session.QueryGetSessionRequest.blockHeight": - x.BlockHeight = "" + case "poktroll.session.QueryGetSessionRequest.service": + x.Service = nil + case "poktroll.session.QueryGetSessionRequest.block_height": + x.BlockHeight = int64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionRequest")) @@ -964,15 +966,15 @@ func (x *fastReflection_QueryGetSessionRequest) Clear(fd protoreflect.FieldDescr // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_QueryGetSessionRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "poktroll.session.QueryGetSessionRequest.applicationAddress": + case "poktroll.session.QueryGetSessionRequest.application_address": value := x.ApplicationAddress return protoreflect.ValueOfString(value) - case "poktroll.session.QueryGetSessionRequest.serviceId": - value := x.ServiceId - return protoreflect.ValueOfString(value) - case "poktroll.session.QueryGetSessionRequest.blockHeight": + case "poktroll.session.QueryGetSessionRequest.service": + value := x.Service + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "poktroll.session.QueryGetSessionRequest.block_height": value := x.BlockHeight - return protoreflect.ValueOfString(value) + return protoreflect.ValueOfInt64(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionRequest")) @@ -993,12 +995,12 @@ func (x *fastReflection_QueryGetSessionRequest) Get(descriptor protoreflect.Fiel // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetSessionRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "poktroll.session.QueryGetSessionRequest.applicationAddress": + case "poktroll.session.QueryGetSessionRequest.application_address": x.ApplicationAddress = value.Interface().(string) - case "poktroll.session.QueryGetSessionRequest.serviceId": - x.ServiceId = value.Interface().(string) - case "poktroll.session.QueryGetSessionRequest.blockHeight": - x.BlockHeight = value.Interface().(string) + case "poktroll.session.QueryGetSessionRequest.service": + x.Service = value.Message().Interface().(*shared.Service) + case "poktroll.session.QueryGetSessionRequest.block_height": + x.BlockHeight = value.Int() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionRequest")) @@ -1019,12 +1021,15 @@ func (x *fastReflection_QueryGetSessionRequest) Set(fd protoreflect.FieldDescrip // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetSessionRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.session.QueryGetSessionRequest.applicationAddress": - panic(fmt.Errorf("field applicationAddress of message poktroll.session.QueryGetSessionRequest is not mutable")) - case "poktroll.session.QueryGetSessionRequest.serviceId": - panic(fmt.Errorf("field serviceId of message poktroll.session.QueryGetSessionRequest is not mutable")) - case "poktroll.session.QueryGetSessionRequest.blockHeight": - panic(fmt.Errorf("field blockHeight of message poktroll.session.QueryGetSessionRequest is not mutable")) + case "poktroll.session.QueryGetSessionRequest.service": + if x.Service == nil { + x.Service = new(shared.Service) + } + return protoreflect.ValueOfMessage(x.Service.ProtoReflect()) + case "poktroll.session.QueryGetSessionRequest.application_address": + panic(fmt.Errorf("field application_address of message poktroll.session.QueryGetSessionRequest is not mutable")) + case "poktroll.session.QueryGetSessionRequest.block_height": + panic(fmt.Errorf("field block_height of message poktroll.session.QueryGetSessionRequest is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionRequest")) @@ -1038,12 +1043,13 @@ func (x *fastReflection_QueryGetSessionRequest) Mutable(fd protoreflect.FieldDes // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_QueryGetSessionRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.session.QueryGetSessionRequest.applicationAddress": - return protoreflect.ValueOfString("") - case "poktroll.session.QueryGetSessionRequest.serviceId": - return protoreflect.ValueOfString("") - case "poktroll.session.QueryGetSessionRequest.blockHeight": + case "poktroll.session.QueryGetSessionRequest.application_address": return protoreflect.ValueOfString("") + case "poktroll.session.QueryGetSessionRequest.service": + m := new(shared.Service) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "poktroll.session.QueryGetSessionRequest.block_height": + return protoreflect.ValueOfInt64(int64(0)) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionRequest")) @@ -1117,13 +1123,12 @@ func (x *fastReflection_QueryGetSessionRequest) ProtoMethods() *protoiface.Metho if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } - l = len(x.ServiceId) - if l > 0 { + if x.Service != nil { + l = options.Size(x.Service) n += 1 + l + runtime.Sov(uint64(l)) } - l = len(x.BlockHeight) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(l)) + if x.BlockHeight != 0 { + n += 1 + runtime.Sov(uint64(x.BlockHeight)) } if x.unknownFields != nil { n += len(x.unknownFields) @@ -1154,17 +1159,22 @@ func (x *fastReflection_QueryGetSessionRequest) ProtoMethods() *protoiface.Metho i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.BlockHeight) > 0 { - i -= len(x.BlockHeight) - copy(dAtA[i:], x.BlockHeight) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.BlockHeight))) + if x.BlockHeight != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.BlockHeight)) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x18 } - if len(x.ServiceId) > 0 { - i -= len(x.ServiceId) - copy(dAtA[i:], x.ServiceId) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ServiceId))) + if x.Service != nil { + encoded, err := options.Marshal(x.Service) + 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 } @@ -1258,9 +1268,9 @@ func (x *fastReflection_QueryGetSessionRequest) ProtoMethods() *protoiface.Metho iNdEx = postIndex case 2: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ServiceId", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Service", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -1270,29 +1280,33 @@ func (x *fastReflection_QueryGetSessionRequest) ProtoMethods() *protoiface.Metho } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.ServiceId = string(dAtA[iNdEx:postIndex]) + if x.Service == nil { + x.Service = &shared.Service{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Service); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } iNdEx = postIndex case 3: - if wireType != 2 { + if wireType != 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) } - var stringLen uint64 + x.BlockHeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -1302,24 +1316,11 @@ func (x *fastReflection_QueryGetSessionRequest) ProtoMethods() *protoiface.Metho } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + x.BlockHeight |= int64(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.BlockHeight = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -1356,12 +1357,14 @@ func (x *fastReflection_QueryGetSessionRequest) ProtoMethods() *protoiface.Metho } var ( - md_QueryGetSessionResponse protoreflect.MessageDescriptor + md_QueryGetSessionResponse protoreflect.MessageDescriptor + fd_QueryGetSessionResponse_session protoreflect.FieldDescriptor ) func init() { file_poktroll_session_query_proto_init() md_QueryGetSessionResponse = File_poktroll_session_query_proto.Messages().ByName("QueryGetSessionResponse") + fd_QueryGetSessionResponse_session = md_QueryGetSessionResponse.Fields().ByName("session") } var _ protoreflect.Message = (*fastReflection_QueryGetSessionResponse)(nil) @@ -1429,6 +1432,12 @@ func (x *fastReflection_QueryGetSessionResponse) Interface() protoreflect.ProtoM // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_QueryGetSessionResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Session != nil { + value := protoreflect.ValueOfMessage(x.Session.ProtoReflect()) + if !f(fd_QueryGetSessionResponse_session, value) { + return + } + } } // Has reports whether a field is populated. @@ -1444,6 +1453,8 @@ func (x *fastReflection_QueryGetSessionResponse) Range(f func(protoreflect.Field // a repeated field is populated if it is non-empty. func (x *fastReflection_QueryGetSessionResponse) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { + case "poktroll.session.QueryGetSessionResponse.session": + return x.Session != nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionResponse")) @@ -1460,6 +1471,8 @@ func (x *fastReflection_QueryGetSessionResponse) Has(fd protoreflect.FieldDescri // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetSessionResponse) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { + case "poktroll.session.QueryGetSessionResponse.session": + x.Session = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionResponse")) @@ -1476,6 +1489,9 @@ func (x *fastReflection_QueryGetSessionResponse) Clear(fd protoreflect.FieldDesc // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_QueryGetSessionResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { + case "poktroll.session.QueryGetSessionResponse.session": + value := x.Session + return protoreflect.ValueOfMessage(value.ProtoReflect()) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionResponse")) @@ -1496,6 +1512,8 @@ func (x *fastReflection_QueryGetSessionResponse) Get(descriptor protoreflect.Fie // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetSessionResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { + case "poktroll.session.QueryGetSessionResponse.session": + x.Session = value.Message().Interface().(*Session) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionResponse")) @@ -1516,6 +1534,11 @@ func (x *fastReflection_QueryGetSessionResponse) Set(fd protoreflect.FieldDescri // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetSessionResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "poktroll.session.QueryGetSessionResponse.session": + if x.Session == nil { + x.Session = new(Session) + } + return protoreflect.ValueOfMessage(x.Session.ProtoReflect()) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionResponse")) @@ -1529,6 +1552,9 @@ func (x *fastReflection_QueryGetSessionResponse) Mutable(fd protoreflect.FieldDe // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_QueryGetSessionResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "poktroll.session.QueryGetSessionResponse.session": + m := new(Session) + return protoreflect.ValueOfMessage(m.ProtoReflect()) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionResponse")) @@ -1598,6 +1624,10 @@ func (x *fastReflection_QueryGetSessionResponse) ProtoMethods() *protoiface.Meth var n int var l int _ = l + if x.Session != nil { + l = options.Size(x.Session) + n += 1 + l + runtime.Sov(uint64(l)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -1627,6 +1657,20 @@ func (x *fastReflection_QueryGetSessionResponse) ProtoMethods() *protoiface.Meth i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if x.Session != nil { + encoded, err := options.Marshal(x.Session) + 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 { @@ -1676,6 +1720,42 @@ func (x *fastReflection_QueryGetSessionResponse) ProtoMethods() *protoiface.Meth return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryGetSessionResponse: 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 Session", 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.Session == nil { + x.Session = &Session{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Session); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -1793,9 +1873,9 @@ type QueryGetSessionRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ApplicationAddress string `protobuf:"bytes,1,opt,name=applicationAddress,proto3" json:"applicationAddress,omitempty"` - ServiceId string `protobuf:"bytes,2,opt,name=serviceId,proto3" json:"serviceId,omitempty"` - BlockHeight string `protobuf:"bytes,3,opt,name=blockHeight,proto3" json:"blockHeight,omitempty"` + ApplicationAddress string `protobuf:"bytes,1,opt,name=application_address,json=applicationAddress,proto3" json:"application_address,omitempty"` // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic encoding + Service *shared.Service `protobuf:"bytes,2,opt,name=service,proto3" json:"service,omitempty"` // The service id to query the session for + BlockHeight int64 `protobuf:"varint,3,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` // The block height to query the session for } func (x *QueryGetSessionRequest) Reset() { @@ -1825,24 +1905,26 @@ func (x *QueryGetSessionRequest) GetApplicationAddress() string { return "" } -func (x *QueryGetSessionRequest) GetServiceId() string { +func (x *QueryGetSessionRequest) GetService() *shared.Service { if x != nil { - return x.ServiceId + return x.Service } - return "" + return nil } -func (x *QueryGetSessionRequest) GetBlockHeight() string { +func (x *QueryGetSessionRequest) GetBlockHeight() int64 { if x != nil { return x.BlockHeight } - return "" + return 0 } type QueryGetSessionResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Session *Session `protobuf:"bytes,1,opt,name=session,proto3" json:"session,omitempty"` } func (x *QueryGetSessionResponse) Reset() { @@ -1865,6 +1947,13 @@ func (*QueryGetSessionResponse) Descriptor() ([]byte, []int) { return file_poktroll_session_query_proto_rawDescGZIP(), []int{3} } +func (x *QueryGetSessionResponse) GetSession() *Session { + if x != nil { + return x.Session + } + return nil +} + var File_poktroll_session_query_proto protoreflect.FileDescriptor var file_poktroll_session_query_proto_rawDesc = []byte{ @@ -1875,61 +1964,70 @@ var file_poktroll_session_query_proto_rawDesc = []byte{ 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, 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, 0x14, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x52, 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, - 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x3b, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 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, 0x22, 0x88, 0x01, 0x0a, - 0x16, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2e, 0x0a, 0x12, 0x61, 0x70, 0x70, 0x6c, 0x69, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x12, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, - 0x69, 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, - 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x19, 0x0a, 0x17, 0x51, 0x75, 0x65, 0x72, 0x79, - 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x32, 0xd5, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x84, 0x01, 0x0a, - 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x24, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, - 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, - 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, - 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x12, 0x25, 0x2f, 0x70, - 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, - 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x70, 0x61, 0x72, - 0x61, 0x6d, 0x73, 0x12, 0xc4, 0x01, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x12, 0x28, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x70, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x61, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x5b, 0x12, - 0x59, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, + 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x1a, 0x2a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, + 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x70, 0x61, + 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 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, 0x1a, 0x1e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2f, - 0x67, 0x65, 0x74, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x7b, 0x61, 0x70, 0x70, - 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x7d, - 0x2f, 0x7b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x7d, 0x2f, 0x7b, 0x62, 0x6c, - 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x7d, 0x42, 0xa6, 0x01, 0x0a, 0x14, 0x63, - 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 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, + 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1d, 0x70, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2f, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x14, 0x0a, 0x12, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x22, 0x52, 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x06, 0x70, 0x61, 0x72, + 0x61, 0x6d, 0x73, 0x18, 0x01, 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, 0x22, 0xba, 0x01, 0x0a, 0x16, 0x51, 0x75, 0x65, 0x72, 0x79, + 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x49, 0x0a, 0x13, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, + 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x12, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x32, 0x0a, 0x07, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, + 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x22, 0x4e, 0x0a, 0x17, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, + 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x19, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x32, 0xa6, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x84, 0x01, + 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x24, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, + 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x12, 0x25, 0x2f, + 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x70, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x12, 0x95, 0x01, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x28, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, + 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x32, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2c, + 0x12, 0x2a, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, + 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x2f, 0x67, 0x65, 0x74, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0xa6, 0x01, 0x0a, + 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 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 ( @@ -1951,18 +2049,22 @@ var file_poktroll_session_query_proto_goTypes = []interface{}{ (*QueryGetSessionRequest)(nil), // 2: poktroll.session.QueryGetSessionRequest (*QueryGetSessionResponse)(nil), // 3: poktroll.session.QueryGetSessionResponse (*Params)(nil), // 4: poktroll.session.Params + (*shared.Service)(nil), // 5: poktroll.shared.Service + (*Session)(nil), // 6: poktroll.session.Session } var file_poktroll_session_query_proto_depIdxs = []int32{ 4, // 0: poktroll.session.QueryParamsResponse.params:type_name -> poktroll.session.Params - 0, // 1: poktroll.session.Query.Params:input_type -> poktroll.session.QueryParamsRequest - 2, // 2: poktroll.session.Query.GetSession:input_type -> poktroll.session.QueryGetSessionRequest - 1, // 3: poktroll.session.Query.Params:output_type -> poktroll.session.QueryParamsResponse - 3, // 4: poktroll.session.Query.GetSession:output_type -> poktroll.session.QueryGetSessionResponse - 3, // [3:5] is the sub-list for method output_type - 1, // [1:3] 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 + 5, // 1: poktroll.session.QueryGetSessionRequest.service:type_name -> poktroll.shared.Service + 6, // 2: poktroll.session.QueryGetSessionResponse.session:type_name -> poktroll.session.Session + 0, // 3: poktroll.session.Query.Params:input_type -> poktroll.session.QueryParamsRequest + 2, // 4: poktroll.session.Query.GetSession:input_type -> poktroll.session.QueryGetSessionRequest + 1, // 5: poktroll.session.Query.Params:output_type -> poktroll.session.QueryParamsResponse + 3, // 6: poktroll.session.Query.GetSession:output_type -> poktroll.session.QueryGetSessionResponse + 5, // [5:7] is the sub-list for method output_type + 3, // [3:5] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_poktroll_session_query_proto_init() } @@ -1971,6 +2073,7 @@ func file_poktroll_session_query_proto_init() { return } file_poktroll_session_params_proto_init() + file_poktroll_session_session_proto_init() if !protoimpl.UnsafeEnabled { file_poktroll_session_query_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*QueryParamsRequest); i { diff --git a/api/poktroll/session/session.pulsar.go b/api/poktroll/session/session.pulsar.go new file mode 100644 index 000000000..16d444256 --- /dev/null +++ b/api/poktroll/session/session.pulsar.go @@ -0,0 +1,1796 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package session + +import ( + application "cosmossdk.io/api/poktroll/application" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + runtime "github.com/cosmos/cosmos-proto/runtime" + shared "github.com/pokt-network/poktroll/api/poktroll/shared" + 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_SessionHeader protoreflect.MessageDescriptor + fd_SessionHeader_application_address protoreflect.FieldDescriptor + fd_SessionHeader_service protoreflect.FieldDescriptor + fd_SessionHeader_session_start_block_height protoreflect.FieldDescriptor + fd_SessionHeader_session_id protoreflect.FieldDescriptor + fd_SessionHeader_session_end_block_height protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_session_session_proto_init() + md_SessionHeader = File_poktroll_session_session_proto.Messages().ByName("SessionHeader") + fd_SessionHeader_application_address = md_SessionHeader.Fields().ByName("application_address") + fd_SessionHeader_service = md_SessionHeader.Fields().ByName("service") + fd_SessionHeader_session_start_block_height = md_SessionHeader.Fields().ByName("session_start_block_height") + fd_SessionHeader_session_id = md_SessionHeader.Fields().ByName("session_id") + fd_SessionHeader_session_end_block_height = md_SessionHeader.Fields().ByName("session_end_block_height") +} + +var _ protoreflect.Message = (*fastReflection_SessionHeader)(nil) + +type fastReflection_SessionHeader SessionHeader + +func (x *SessionHeader) ProtoReflect() protoreflect.Message { + return (*fastReflection_SessionHeader)(x) +} + +func (x *SessionHeader) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_session_session_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_SessionHeader_messageType fastReflection_SessionHeader_messageType +var _ protoreflect.MessageType = fastReflection_SessionHeader_messageType{} + +type fastReflection_SessionHeader_messageType struct{} + +func (x fastReflection_SessionHeader_messageType) Zero() protoreflect.Message { + return (*fastReflection_SessionHeader)(nil) +} +func (x fastReflection_SessionHeader_messageType) New() protoreflect.Message { + return new(fastReflection_SessionHeader) +} +func (x fastReflection_SessionHeader_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_SessionHeader +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_SessionHeader) Descriptor() protoreflect.MessageDescriptor { + return md_SessionHeader +} + +// 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_SessionHeader) Type() protoreflect.MessageType { + return _fastReflection_SessionHeader_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_SessionHeader) New() protoreflect.Message { + return new(fastReflection_SessionHeader) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_SessionHeader) Interface() protoreflect.ProtoMessage { + return (*SessionHeader)(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_SessionHeader) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.ApplicationAddress != "" { + value := protoreflect.ValueOfString(x.ApplicationAddress) + if !f(fd_SessionHeader_application_address, value) { + return + } + } + if x.Service != nil { + value := protoreflect.ValueOfMessage(x.Service.ProtoReflect()) + if !f(fd_SessionHeader_service, value) { + return + } + } + if x.SessionStartBlockHeight != int64(0) { + value := protoreflect.ValueOfInt64(x.SessionStartBlockHeight) + if !f(fd_SessionHeader_session_start_block_height, value) { + return + } + } + if x.SessionId != "" { + value := protoreflect.ValueOfString(x.SessionId) + if !f(fd_SessionHeader_session_id, value) { + return + } + } + if x.SessionEndBlockHeight != int64(0) { + value := protoreflect.ValueOfInt64(x.SessionEndBlockHeight) + if !f(fd_SessionHeader_session_end_block_height, 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_SessionHeader) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.session.SessionHeader.application_address": + return x.ApplicationAddress != "" + case "poktroll.session.SessionHeader.service": + return x.Service != nil + case "poktroll.session.SessionHeader.session_start_block_height": + return x.SessionStartBlockHeight != int64(0) + case "poktroll.session.SessionHeader.session_id": + return x.SessionId != "" + case "poktroll.session.SessionHeader.session_end_block_height": + return x.SessionEndBlockHeight != int64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.SessionHeader")) + } + panic(fmt.Errorf("message poktroll.session.SessionHeader 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_SessionHeader) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.session.SessionHeader.application_address": + x.ApplicationAddress = "" + case "poktroll.session.SessionHeader.service": + x.Service = nil + case "poktroll.session.SessionHeader.session_start_block_height": + x.SessionStartBlockHeight = int64(0) + case "poktroll.session.SessionHeader.session_id": + x.SessionId = "" + case "poktroll.session.SessionHeader.session_end_block_height": + x.SessionEndBlockHeight = int64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.SessionHeader")) + } + panic(fmt.Errorf("message poktroll.session.SessionHeader 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_SessionHeader) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.session.SessionHeader.application_address": + value := x.ApplicationAddress + return protoreflect.ValueOfString(value) + case "poktroll.session.SessionHeader.service": + value := x.Service + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "poktroll.session.SessionHeader.session_start_block_height": + value := x.SessionStartBlockHeight + return protoreflect.ValueOfInt64(value) + case "poktroll.session.SessionHeader.session_id": + value := x.SessionId + return protoreflect.ValueOfString(value) + case "poktroll.session.SessionHeader.session_end_block_height": + value := x.SessionEndBlockHeight + return protoreflect.ValueOfInt64(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.SessionHeader")) + } + panic(fmt.Errorf("message poktroll.session.SessionHeader 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_SessionHeader) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.session.SessionHeader.application_address": + x.ApplicationAddress = value.Interface().(string) + case "poktroll.session.SessionHeader.service": + x.Service = value.Message().Interface().(*shared.Service) + case "poktroll.session.SessionHeader.session_start_block_height": + x.SessionStartBlockHeight = value.Int() + case "poktroll.session.SessionHeader.session_id": + x.SessionId = value.Interface().(string) + case "poktroll.session.SessionHeader.session_end_block_height": + x.SessionEndBlockHeight = value.Int() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.SessionHeader")) + } + panic(fmt.Errorf("message poktroll.session.SessionHeader 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_SessionHeader) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.session.SessionHeader.service": + if x.Service == nil { + x.Service = new(shared.Service) + } + return protoreflect.ValueOfMessage(x.Service.ProtoReflect()) + case "poktroll.session.SessionHeader.application_address": + panic(fmt.Errorf("field application_address of message poktroll.session.SessionHeader is not mutable")) + case "poktroll.session.SessionHeader.session_start_block_height": + panic(fmt.Errorf("field session_start_block_height of message poktroll.session.SessionHeader is not mutable")) + case "poktroll.session.SessionHeader.session_id": + panic(fmt.Errorf("field session_id of message poktroll.session.SessionHeader is not mutable")) + case "poktroll.session.SessionHeader.session_end_block_height": + panic(fmt.Errorf("field session_end_block_height of message poktroll.session.SessionHeader is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.SessionHeader")) + } + panic(fmt.Errorf("message poktroll.session.SessionHeader 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_SessionHeader) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.session.SessionHeader.application_address": + return protoreflect.ValueOfString("") + case "poktroll.session.SessionHeader.service": + m := new(shared.Service) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "poktroll.session.SessionHeader.session_start_block_height": + return protoreflect.ValueOfInt64(int64(0)) + case "poktroll.session.SessionHeader.session_id": + return protoreflect.ValueOfString("") + case "poktroll.session.SessionHeader.session_end_block_height": + return protoreflect.ValueOfInt64(int64(0)) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.SessionHeader")) + } + panic(fmt.Errorf("message poktroll.session.SessionHeader 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_SessionHeader) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.session.SessionHeader", 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_SessionHeader) 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_SessionHeader) 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_SessionHeader) 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_SessionHeader) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*SessionHeader) + 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.ApplicationAddress) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Service != nil { + l = options.Size(x.Service) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.SessionStartBlockHeight != 0 { + n += 1 + runtime.Sov(uint64(x.SessionStartBlockHeight)) + } + l = len(x.SessionId) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.SessionEndBlockHeight != 0 { + n += 1 + runtime.Sov(uint64(x.SessionEndBlockHeight)) + } + 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().(*SessionHeader) + 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.SessionEndBlockHeight != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.SessionEndBlockHeight)) + i-- + dAtA[i] = 0x28 + } + if len(x.SessionId) > 0 { + i -= len(x.SessionId) + copy(dAtA[i:], x.SessionId) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.SessionId))) + i-- + dAtA[i] = 0x22 + } + if x.SessionStartBlockHeight != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.SessionStartBlockHeight)) + i-- + dAtA[i] = 0x18 + } + if x.Service != nil { + encoded, err := options.Marshal(x.Service) + 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.ApplicationAddress) > 0 { + i -= len(x.ApplicationAddress) + copy(dAtA[i:], x.ApplicationAddress) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ApplicationAddress))) + 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().(*SessionHeader) + 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: SessionHeader: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: SessionHeader: 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 ApplicationAddress", 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.ApplicationAddress = 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 Service", 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.Service == nil { + x.Service = &shared.Service{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Service); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SessionStartBlockHeight", wireType) + } + x.SessionStartBlockHeight = 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.SessionStartBlockHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SessionId", 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.SessionId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SessionEndBlockHeight", wireType) + } + x.SessionEndBlockHeight = 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.SessionEndBlockHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var _ protoreflect.List = (*_Session_6_list)(nil) + +type _Session_6_list struct { + list *[]*shared.Supplier +} + +func (x *_Session_6_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_Session_6_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_Session_6_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*shared.Supplier) + (*x.list)[i] = concreteValue +} + +func (x *_Session_6_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*shared.Supplier) + *x.list = append(*x.list, concreteValue) +} + +func (x *_Session_6_list) AppendMutable() protoreflect.Value { + v := new(shared.Supplier) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Session_6_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_Session_6_list) NewElement() protoreflect.Value { + v := new(shared.Supplier) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Session_6_list) IsValid() bool { + return x.list != nil +} + +var ( + md_Session protoreflect.MessageDescriptor + fd_Session_header protoreflect.FieldDescriptor + fd_Session_session_id protoreflect.FieldDescriptor + fd_Session_session_number protoreflect.FieldDescriptor + fd_Session_num_blocks_per_session protoreflect.FieldDescriptor + fd_Session_application protoreflect.FieldDescriptor + fd_Session_suppliers protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_session_session_proto_init() + md_Session = File_poktroll_session_session_proto.Messages().ByName("Session") + fd_Session_header = md_Session.Fields().ByName("header") + fd_Session_session_id = md_Session.Fields().ByName("session_id") + fd_Session_session_number = md_Session.Fields().ByName("session_number") + fd_Session_num_blocks_per_session = md_Session.Fields().ByName("num_blocks_per_session") + fd_Session_application = md_Session.Fields().ByName("application") + fd_Session_suppliers = md_Session.Fields().ByName("suppliers") +} + +var _ protoreflect.Message = (*fastReflection_Session)(nil) + +type fastReflection_Session Session + +func (x *Session) ProtoReflect() protoreflect.Message { + return (*fastReflection_Session)(x) +} + +func (x *Session) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_session_session_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_Session_messageType fastReflection_Session_messageType +var _ protoreflect.MessageType = fastReflection_Session_messageType{} + +type fastReflection_Session_messageType struct{} + +func (x fastReflection_Session_messageType) Zero() protoreflect.Message { + return (*fastReflection_Session)(nil) +} +func (x fastReflection_Session_messageType) New() protoreflect.Message { + return new(fastReflection_Session) +} +func (x fastReflection_Session_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_Session +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_Session) Descriptor() protoreflect.MessageDescriptor { + return md_Session +} + +// 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_Session) Type() protoreflect.MessageType { + return _fastReflection_Session_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_Session) New() protoreflect.Message { + return new(fastReflection_Session) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_Session) Interface() protoreflect.ProtoMessage { + return (*Session)(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_Session) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Header != nil { + value := protoreflect.ValueOfMessage(x.Header.ProtoReflect()) + if !f(fd_Session_header, value) { + return + } + } + if x.SessionId != "" { + value := protoreflect.ValueOfString(x.SessionId) + if !f(fd_Session_session_id, value) { + return + } + } + if x.SessionNumber != int64(0) { + value := protoreflect.ValueOfInt64(x.SessionNumber) + if !f(fd_Session_session_number, value) { + return + } + } + if x.NumBlocksPerSession != int64(0) { + value := protoreflect.ValueOfInt64(x.NumBlocksPerSession) + if !f(fd_Session_num_blocks_per_session, value) { + return + } + } + if x.Application != nil { + value := protoreflect.ValueOfMessage(x.Application.ProtoReflect()) + if !f(fd_Session_application, value) { + return + } + } + if len(x.Suppliers) != 0 { + value := protoreflect.ValueOfList(&_Session_6_list{list: &x.Suppliers}) + if !f(fd_Session_suppliers, 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_Session) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.session.Session.header": + return x.Header != nil + case "poktroll.session.Session.session_id": + return x.SessionId != "" + case "poktroll.session.Session.session_number": + return x.SessionNumber != int64(0) + case "poktroll.session.Session.num_blocks_per_session": + return x.NumBlocksPerSession != int64(0) + case "poktroll.session.Session.application": + return x.Application != nil + case "poktroll.session.Session.suppliers": + return len(x.Suppliers) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Session")) + } + panic(fmt.Errorf("message poktroll.session.Session 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_Session) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.session.Session.header": + x.Header = nil + case "poktroll.session.Session.session_id": + x.SessionId = "" + case "poktroll.session.Session.session_number": + x.SessionNumber = int64(0) + case "poktroll.session.Session.num_blocks_per_session": + x.NumBlocksPerSession = int64(0) + case "poktroll.session.Session.application": + x.Application = nil + case "poktroll.session.Session.suppliers": + x.Suppliers = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Session")) + } + panic(fmt.Errorf("message poktroll.session.Session 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_Session) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.session.Session.header": + value := x.Header + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "poktroll.session.Session.session_id": + value := x.SessionId + return protoreflect.ValueOfString(value) + case "poktroll.session.Session.session_number": + value := x.SessionNumber + return protoreflect.ValueOfInt64(value) + case "poktroll.session.Session.num_blocks_per_session": + value := x.NumBlocksPerSession + return protoreflect.ValueOfInt64(value) + case "poktroll.session.Session.application": + value := x.Application + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "poktroll.session.Session.suppliers": + if len(x.Suppliers) == 0 { + return protoreflect.ValueOfList(&_Session_6_list{}) + } + listValue := &_Session_6_list{list: &x.Suppliers} + return protoreflect.ValueOfList(listValue) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Session")) + } + panic(fmt.Errorf("message poktroll.session.Session 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_Session) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.session.Session.header": + x.Header = value.Message().Interface().(*SessionHeader) + case "poktroll.session.Session.session_id": + x.SessionId = value.Interface().(string) + case "poktroll.session.Session.session_number": + x.SessionNumber = value.Int() + case "poktroll.session.Session.num_blocks_per_session": + x.NumBlocksPerSession = value.Int() + case "poktroll.session.Session.application": + x.Application = value.Message().Interface().(*application.Application) + case "poktroll.session.Session.suppliers": + lv := value.List() + clv := lv.(*_Session_6_list) + x.Suppliers = *clv.list + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Session")) + } + panic(fmt.Errorf("message poktroll.session.Session 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_Session) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.session.Session.header": + if x.Header == nil { + x.Header = new(SessionHeader) + } + return protoreflect.ValueOfMessage(x.Header.ProtoReflect()) + case "poktroll.session.Session.application": + if x.Application == nil { + x.Application = new(application.Application) + } + return protoreflect.ValueOfMessage(x.Application.ProtoReflect()) + case "poktroll.session.Session.suppliers": + if x.Suppliers == nil { + x.Suppliers = []*shared.Supplier{} + } + value := &_Session_6_list{list: &x.Suppliers} + return protoreflect.ValueOfList(value) + case "poktroll.session.Session.session_id": + panic(fmt.Errorf("field session_id of message poktroll.session.Session is not mutable")) + case "poktroll.session.Session.session_number": + panic(fmt.Errorf("field session_number of message poktroll.session.Session is not mutable")) + case "poktroll.session.Session.num_blocks_per_session": + panic(fmt.Errorf("field num_blocks_per_session of message poktroll.session.Session is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Session")) + } + panic(fmt.Errorf("message poktroll.session.Session 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_Session) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.session.Session.header": + m := new(SessionHeader) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "poktroll.session.Session.session_id": + return protoreflect.ValueOfString("") + case "poktroll.session.Session.session_number": + return protoreflect.ValueOfInt64(int64(0)) + case "poktroll.session.Session.num_blocks_per_session": + return protoreflect.ValueOfInt64(int64(0)) + case "poktroll.session.Session.application": + m := new(application.Application) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "poktroll.session.Session.suppliers": + list := []*shared.Supplier{} + return protoreflect.ValueOfList(&_Session_6_list{list: &list}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Session")) + } + panic(fmt.Errorf("message poktroll.session.Session 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_Session) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.session.Session", 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_Session) 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_Session) 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_Session) 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_Session) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*Session) + 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.Header != nil { + l = options.Size(x.Header) + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.SessionId) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.SessionNumber != 0 { + n += 1 + runtime.Sov(uint64(x.SessionNumber)) + } + if x.NumBlocksPerSession != 0 { + n += 1 + runtime.Sov(uint64(x.NumBlocksPerSession)) + } + if x.Application != nil { + l = options.Size(x.Application) + n += 1 + l + runtime.Sov(uint64(l)) + } + if len(x.Suppliers) > 0 { + for _, e := range x.Suppliers { + l = options.Size(e) + 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().(*Session) + 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.Suppliers) > 0 { + for iNdEx := len(x.Suppliers) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Suppliers[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x32 + } + } + if x.Application != nil { + encoded, err := options.Marshal(x.Application) + 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] = 0x2a + } + if x.NumBlocksPerSession != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.NumBlocksPerSession)) + i-- + dAtA[i] = 0x20 + } + if x.SessionNumber != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.SessionNumber)) + i-- + dAtA[i] = 0x18 + } + if len(x.SessionId) > 0 { + i -= len(x.SessionId) + copy(dAtA[i:], x.SessionId) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.SessionId))) + i-- + dAtA[i] = 0x12 + } + if x.Header != nil { + encoded, err := options.Marshal(x.Header) + 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().(*Session) + 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: Session: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Session: 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 Header", 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.Header == nil { + x.Header = &SessionHeader{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Header); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SessionId", 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.SessionId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SessionNumber", wireType) + } + x.SessionNumber = 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.SessionNumber |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + 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 |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Application", 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.Application == nil { + x.Application = &application.Application{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Application); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Suppliers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Suppliers = append(x.Suppliers, &shared.Supplier{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Suppliers[len(x.Suppliers)-1]); 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/session/session.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) +) + +// 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. +type SessionHeader struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ApplicationAddress string `protobuf:"bytes,1,opt,name=application_address,json=applicationAddress,proto3" json:"application_address,omitempty"` // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic encoding + Service *shared.Service `protobuf:"bytes,2,opt,name=service,proto3" json:"service,omitempty"` // The service this session is for + SessionStartBlockHeight int64 `protobuf:"varint,3,opt,name=session_start_block_height,json=sessionStartBlockHeight,proto3" json:"session_start_block_height,omitempty"` // The height at which this session started + // NOTE: session_id can be derived from the above values using on-chain but is included in the header for convenience + SessionId string `protobuf:"bytes,4,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` // A unique pseudoranom ID for this session + SessionEndBlockHeight int64 `protobuf:"varint,5,opt,name=session_end_block_height,json=sessionEndBlockHeight,proto3" json:"session_end_block_height,omitempty"` // The height at which this session ended, this is the last block of the session +} + +func (x *SessionHeader) Reset() { + *x = SessionHeader{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_session_session_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SessionHeader) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SessionHeader) ProtoMessage() {} + +// Deprecated: Use SessionHeader.ProtoReflect.Descriptor instead. +func (*SessionHeader) Descriptor() ([]byte, []int) { + return file_poktroll_session_session_proto_rawDescGZIP(), []int{0} +} + +func (x *SessionHeader) GetApplicationAddress() string { + if x != nil { + return x.ApplicationAddress + } + return "" +} + +func (x *SessionHeader) GetService() *shared.Service { + if x != nil { + return x.Service + } + return nil +} + +func (x *SessionHeader) GetSessionStartBlockHeight() int64 { + if x != nil { + return x.SessionStartBlockHeight + } + return 0 +} + +func (x *SessionHeader) GetSessionId() string { + if x != nil { + return x.SessionId + } + return "" +} + +func (x *SessionHeader) GetSessionEndBlockHeight() int64 { + if x != nil { + return x.SessionEndBlockHeight + } + return 0 +} + +// Session is a fully hydrated session object that contains all the information for the Session +// and its parcipants. +type Session struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Header *SessionHeader `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` // The header of the session containing lightweight data + SessionId string `protobuf:"bytes,2,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` // A unique pseudoranom ID for this session + SessionNumber int64 `protobuf:"varint,3,opt,name=session_number,json=sessionNumber,proto3" json:"session_number,omitempty"` // The session number since genesis + NumBlocksPerSession int64 `protobuf:"varint,4,opt,name=num_blocks_per_session,json=numBlocksPerSession,proto3" json:"num_blocks_per_session,omitempty"` // The number of blocks per session when this session started + Application *application.Application `protobuf:"bytes,5,opt,name=application,proto3" json:"application,omitempty"` // A fully hydrated application object this session is for + Suppliers []*shared.Supplier `protobuf:"bytes,6,rep,name=suppliers,proto3" json:"suppliers,omitempty"` // A fully hydrated set of servicers that are serving the application +} + +func (x *Session) Reset() { + *x = Session{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_session_session_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Session) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Session) ProtoMessage() {} + +// Deprecated: Use Session.ProtoReflect.Descriptor instead. +func (*Session) Descriptor() ([]byte, []int) { + return file_poktroll_session_session_proto_rawDescGZIP(), []int{1} +} + +func (x *Session) GetHeader() *SessionHeader { + if x != nil { + return x.Header + } + return nil +} + +func (x *Session) GetSessionId() string { + if x != nil { + return x.SessionId + } + return "" +} + +func (x *Session) GetSessionNumber() int64 { + if x != nil { + return x.SessionNumber + } + return 0 +} + +func (x *Session) GetNumBlocksPerSession() int64 { + if x != nil { + return x.NumBlocksPerSession + } + return 0 +} + +func (x *Session) GetApplication() *application.Application { + if x != nil { + return x.Application + } + return nil +} + +func (x *Session) GetSuppliers() []*shared.Supplier { + if x != nil { + return x.Suppliers + } + return nil +} + +var File_poktroll_session_session_proto protoreflect.FileDescriptor + +var file_poktroll_session_session_proto_rawDesc = []byte{ + 0x0a, 0x1e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x10, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 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, 0x1d, 0x70, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2f, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x26, 0x70, 0x6f, + 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, + 0x68, 0x61, 0x72, 0x65, 0x64, 0x2f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa3, 0x02, 0x0a, 0x0d, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x49, 0x0a, 0x13, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x12, 0x61, + 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x12, 0x32, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, + 0x61, 0x72, 0x65, 0x64, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3b, 0x0a, 0x1a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x17, 0x73, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, 0x67, + 0x68, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, + 0x64, 0x12, 0x37, 0x0a, 0x18, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x6e, 0x64, + 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x15, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x64, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0xbb, 0x02, 0x0a, 0x07, 0x53, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x37, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, + 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x25, + 0x0a, 0x0e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x4e, + 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x33, 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, + 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x13, 0x6e, 0x75, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, + 0x50, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x43, 0x0a, 0x0b, 0x61, 0x70, + 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x21, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x0b, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x37, 0x0a, 0x09, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x73, 0x18, 0x06, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, + 0x61, 0x72, 0x65, 0x64, 0x2e, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x52, 0x09, 0x73, + 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x73, 0x42, 0xa8, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, + 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x42, 0x0c, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 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 ( + file_poktroll_session_session_proto_rawDescOnce sync.Once + file_poktroll_session_session_proto_rawDescData = file_poktroll_session_session_proto_rawDesc +) + +func file_poktroll_session_session_proto_rawDescGZIP() []byte { + file_poktroll_session_session_proto_rawDescOnce.Do(func() { + file_poktroll_session_session_proto_rawDescData = protoimpl.X.CompressGZIP(file_poktroll_session_session_proto_rawDescData) + }) + return file_poktroll_session_session_proto_rawDescData +} + +var file_poktroll_session_session_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_poktroll_session_session_proto_goTypes = []interface{}{ + (*SessionHeader)(nil), // 0: poktroll.session.SessionHeader + (*Session)(nil), // 1: poktroll.session.Session + (*shared.Service)(nil), // 2: poktroll.shared.Service + (*application.Application)(nil), // 3: poktroll.application.Application + (*shared.Supplier)(nil), // 4: poktroll.shared.Supplier +} +var file_poktroll_session_session_proto_depIdxs = []int32{ + 2, // 0: poktroll.session.SessionHeader.service:type_name -> poktroll.shared.Service + 0, // 1: poktroll.session.Session.header:type_name -> poktroll.session.SessionHeader + 3, // 2: poktroll.session.Session.application:type_name -> poktroll.application.Application + 4, // 3: poktroll.session.Session.suppliers:type_name -> poktroll.shared.Supplier + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_poktroll_session_session_proto_init() } +func file_poktroll_session_session_proto_init() { + if File_poktroll_session_session_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_poktroll_session_session_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SessionHeader); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_poktroll_session_session_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Session); 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_session_session_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_poktroll_session_session_proto_goTypes, + DependencyIndexes: file_poktroll_session_session_proto_depIdxs, + MessageInfos: file_poktroll_session_session_proto_msgTypes, + }.Build() + File_poktroll_session_session_proto = out.File + file_poktroll_session_session_proto_rawDesc = nil + file_poktroll_session_session_proto_goTypes = nil + file_poktroll_session_session_proto_depIdxs = nil +} diff --git a/proto/poktroll/session/query.proto b/proto/poktroll/session/query.proto index 0209b38ca..89a20ab60 100644 --- a/proto/poktroll/session/query.proto +++ b/proto/poktroll/session/query.proto @@ -5,24 +5,27 @@ package poktroll.session; import "amino/amino.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; +import "cosmos_proto/cosmos.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; + + import "poktroll/session/params.proto"; +import "poktroll/session/session.proto"; +import "poktroll/shared/service.proto"; option go_package = "github.com/pokt-network/poktroll/x/session/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/session/params"; - } - + // Queries a list of GetSession items. rpc GetSession (QueryGetSessionRequest) returns (QueryGetSessionResponse) { - option (google.api.http).get = "/pokt-network/poktroll/session/get_session/{applicationAddress}/{serviceId}/{blockHeight}"; - + option (google.api.http).get = "/pokt-network/poktroll/session/get_session"; } } // QueryParamsRequest is request type for the Query/Params RPC method. @@ -30,16 +33,18 @@ 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]; } message QueryGetSessionRequest { - string applicationAddress = 1; - string serviceId = 2; - string blockHeight = 3; + string application_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic encoding + poktroll.shared.Service service = 2; // The service id to query the session for + int64 block_height = 3; // The block height to query the session for } -message QueryGetSessionResponse {} +message QueryGetSessionResponse { + Session session = 1; +} diff --git a/proto/poktroll/session/session.proto b/proto/poktroll/session/session.proto new file mode 100644 index 000000000..2c03af313 --- /dev/null +++ b/proto/poktroll/session/session.proto @@ -0,0 +1,33 @@ +syntax = "proto3"; +package poktroll.session; + +option go_package = "github.com/pokt-network/poktroll/x/session/types"; + +import "cosmos_proto/cosmos.proto"; +import "poktroll/shared/service.proto"; +import "poktroll/application/application.proto"; +import "poktroll/shared/supplier.proto"; + +// NOTE: Using signed integers for consistency with the cosmos SDK + +// SessionHeader is a lightweight header for a session that can be passed around. +// It is the minimal amount of data required to hydrate & retrieve all data relevant to the session. +message SessionHeader { + string application_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic encoding + poktroll.shared.Service service = 2; // The service this session is for + int64 session_start_block_height = 3; // The height at which this session started + // NOTE: session_id can be derived from the above values using on-chain but is included in the header for convenience + string session_id = 4; // A unique pseudoranom ID for this session + int64 session_end_block_height = 5; // The height at which this session ended, this is the last block of the session +} + +// Session is a fully hydrated session object that contains all the information for the Session +// and its parcipants. +message Session { + SessionHeader header = 1; // The header of the session containing lightweight data + string session_id = 2; // A unique pseudoranom ID for this session + int64 session_number = 3; // The session number since genesis + int64 num_blocks_per_session = 4; // The number of blocks per session when this session started + poktroll.application.Application application = 5; // A fully hydrated application object this session is for + repeated poktroll.shared.Supplier suppliers = 6; // A fully hydrated set of servicers that are serving the application +} \ No newline at end of file From b3e4b981015f6c3edd3215b065dd56f19011ff30 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Tue, 13 Feb 2024 05:15:26 +0100 Subject: [PATCH 04/24] reconcile: Migrate session module related functionality --- Makefile | 2 +- app/app.go | 1 - app/app_config.go | 2 - go.mod | 2 +- proto/poktroll/session/params.proto | 1 - proto/poktroll/session/query.proto | 2 - testutil/keeper/session.go | 234 ++++++++++++ testutil/network/network.go | 29 ++ testutil/session/mocks/mocks.go | 10 + x/session/keeper/block_hash.go | 19 + x/session/keeper/keeper.go | 23 ++ x/session/keeper/query_get_session.go | 30 +- x/session/keeper/query_get_session_test.go | 166 +++++++++ x/session/keeper/session_hydrator.go | 306 ++++++++++++++++ x/session/keeper/session_hydrator_test.go | 359 +++++++++++++++++++ x/session/module/helpers_test.go | 45 +++ x/session/module/module.go | 3 +- x/session/module/query.go | 31 ++ x/session/module/query_get_session.go | 65 ++++ x/session/module/query_get_session_test.go | 196 ++++++++++ x/session/module/query_params.go | 36 ++ x/session/module/tx.go | 31 ++ x/session/types/errors.go | 12 +- x/session/types/expected_keepers.go | 21 +- x/session/types/query_get_session_request.go | 39 ++ x/session/types/session_header.go | 34 ++ x/session/types/session_header_test.go | 86 +++++ 27 files changed, 1762 insertions(+), 23 deletions(-) create mode 100644 testutil/keeper/session.go create mode 100644 testutil/session/mocks/mocks.go create mode 100644 x/session/keeper/block_hash.go create mode 100644 x/session/keeper/query_get_session_test.go create mode 100644 x/session/keeper/session_hydrator.go create mode 100644 x/session/keeper/session_hydrator_test.go create mode 100644 x/session/module/helpers_test.go create mode 100644 x/session/module/query.go create mode 100644 x/session/module/query_get_session.go create mode 100644 x/session/module/query_get_session_test.go create mode 100644 x/session/module/query_params.go create mode 100644 x/session/module/tx.go create mode 100644 x/session/types/query_get_session_request.go create mode 100644 x/session/types/session_header.go create mode 100644 x/session/types/session_header_test.go diff --git a/Makefile b/Makefile index 1193a02d4..61d5f9d41 100644 --- a/Makefile +++ b/Makefile @@ -247,7 +247,7 @@ go_mockgen: ## Use `mockgen` to generate mocks used for testing purposes of all go generate ./x/application/types/ go generate ./x/gateway/types/ go generate ./x/supplier/types/ - # go generate ./x/session/types/ + go generate ./x/session/types/ go generate ./x/service/types/ # go generate ./x/tokenomics/types/ go generate ./pkg/client/interface.go diff --git a/app/app.go b/app/app.go index 996581a93..92d96e0e4 100644 --- a/app/app.go +++ b/app/app.go @@ -58,7 +58,6 @@ import ( servicemodulekeeper "github.com/pokt-network/poktroll/x/service/keeper" suppliermodulekeeper "github.com/pokt-network/poktroll/x/supplier/keeper" - sessionmodulekeeper "github.com/pokt-network/poktroll/x/session/keeper" // this line is used by starport scaffolding # stargate/app/moduleImport "github.com/pokt-network/poktroll/docs" diff --git a/app/app_config.go b/app/app_config.go index e4cc1b5e2..a6be51b90 100644 --- a/app/app_config.go +++ b/app/app_config.go @@ -202,8 +202,6 @@ var ( {Account: applicationmoduletypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner, authtypes.Staking}}, {Account: suppliermoduletypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner, authtypes.Staking}}, {Account: sessionmoduletypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner, authtypes.Staking}}, - {Account: sessionmoduletypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner, authtypes.Staking}}, - {Account: sessionmoduletypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner, authtypes.Staking}}, // this line is used by starport scaffolding # stargate/app/maccPerms } diff --git a/go.mod b/go.mod index b545e2745..e75c2562d 100644 --- a/go.mod +++ b/go.mod @@ -42,6 +42,7 @@ require ( github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.18.2 github.com/stretchr/testify v1.8.4 + golang.org/x/crypto v0.18.0 golang.org/x/tools v0.17.0 google.golang.org/genproto/googleapis/api v0.0.0-20240116215550-a9fa1716bcac google.golang.org/grpc v1.60.1 @@ -313,7 +314,6 @@ require ( go.uber.org/fx v1.20.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.18.0 // indirect golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.20.0 // indirect diff --git a/proto/poktroll/session/params.proto b/proto/poktroll/session/params.proto index 1e4784a20..1a7dff149 100644 --- a/proto/poktroll/session/params.proto +++ b/proto/poktroll/session/params.proto @@ -11,5 +11,4 @@ message Params { option (amino.name) = "poktroll/x/session/Params"; option (gogoproto.equal) = true; - } \ No newline at end of file diff --git a/proto/poktroll/session/query.proto b/proto/poktroll/session/query.proto index 89a20ab60..89fbb144e 100644 --- a/proto/poktroll/session/query.proto +++ b/proto/poktroll/session/query.proto @@ -1,12 +1,10 @@ syntax = "proto3"; - package poktroll.session; import "amino/amino.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos_proto/cosmos.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; import "poktroll/session/params.proto"; diff --git a/testutil/keeper/session.go b/testutil/keeper/session.go new file mode 100644 index 000000000..fc137eb9e --- /dev/null +++ b/testutil/keeper/session.go @@ -0,0 +1,234 @@ +package keeper + +import ( + "context" + "encoding/hex" + "testing" + + "cosmossdk.io/log" + sdkmath "cosmossdk.io/math" + "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/golang/mock/gomock" + "github.com/stretchr/testify/require" + + "github.com/pokt-network/poktroll/testutil/sample" + "github.com/pokt-network/poktroll/testutil/session/mocks" + apptypes "github.com/pokt-network/poktroll/x/application/types" + "github.com/pokt-network/poktroll/x/session/keeper" + "github.com/pokt-network/poktroll/x/session/types" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" +) + +var ( + TestServiceId1 = "svc1" // staked for by app1 & supplier1 + TestServiceId11 = "svc11" // staked for by app1 + + TestServiceId2 = "svc2" // staked for by app2 & supplier1 + TestServiceId22 = "svc22" // staked for by app2 + + TestServiceId12 = "svc12" // staked for by app1, app2 & supplier1 + + TestApp1Address = "pokt1mdccn4u38eyjdxkk4h0jaddw4n3c72u82m5m9e" // Generated via sample.AccAddress() + TestApp1 = apptypes.Application{ + Address: TestApp1Address, + Stake: &sdk.Coin{Denom: "upokt", Amount: sdkmath.NewInt(100)}, + ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ + { + Service: &sharedtypes.Service{Id: TestServiceId1}, + }, + { + Service: &sharedtypes.Service{Id: TestServiceId11}, + }, + { + Service: &sharedtypes.Service{Id: TestServiceId12}, + }, + }, + } + + TestApp2Address = "pokt133amv5suh75zwkxxcq896azvmmwszg99grvk9f" // Generated via sample.AccAddress() + TestApp2 = apptypes.Application{ + Address: TestApp1Address, + Stake: &sdk.Coin{Denom: "upokt", Amount: sdkmath.NewInt(100)}, + ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ + { + Service: &sharedtypes.Service{Id: TestServiceId2}, + }, + { + Service: &sharedtypes.Service{Id: TestServiceId22}, + }, + { + Service: &sharedtypes.Service{Id: TestServiceId12}, + }, + }, + } + + TestSupplierUrl = "http://olshansky.info" + TestSupplierAddress = sample.AccAddress() + TestSupplier = sharedtypes.Supplier{ + Address: TestSupplierAddress, + Stake: &sdk.Coin{Denom: "upokt", Amount: sdkmath.NewInt(100)}, + Services: []*sharedtypes.SupplierServiceConfig{ + { + Service: &sharedtypes.Service{Id: TestServiceId1}, + Endpoints: []*sharedtypes.SupplierEndpoint{ + { + Url: TestSupplierUrl, + RpcType: sharedtypes.RPCType_JSON_RPC, + Configs: make([]*sharedtypes.ConfigOption, 0), + }, + }, + }, + { + Service: &sharedtypes.Service{Id: TestServiceId2}, + Endpoints: []*sharedtypes.SupplierEndpoint{ + { + Url: TestSupplierUrl, + RpcType: sharedtypes.RPCType_GRPC, + Configs: make([]*sharedtypes.ConfigOption, 0), + }, + }, + }, + { + Service: &sharedtypes.Service{Id: TestServiceId12}, + Endpoints: []*sharedtypes.SupplierEndpoint{ + { + Url: TestSupplierUrl, + RpcType: sharedtypes.RPCType_GRPC, + Configs: make([]*sharedtypes.ConfigOption, 0), + }, + }, + }, + }, + } +) + +func SessionKeeper(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) + + ctrl := gomock.NewController(t) + mockBankKeeper := mocks.NewMockBankKeeper(ctrl) + + mockAccountKeeper := mocks.NewMockAccountKeeper(ctrl) + mockAccountKeeper.EXPECT().GetAccount(gomock.Any(), gomock.Any()).AnyTimes() + + mockAppKeeper := defaultAppKeeperMock(t) + mockSupplierKeeper := defaultSupplierKeeperMock(t) + + // TODO_CONSOLIDATE: This was passed-in instead of authority.String() in the + // original code. It's not clear what the difference is. + // paramsSubspace := typesparams.NewSubspace(cdc, + // types.Amino, + // storeKey, + // memStoreKey, + // "SessionParams", + // ) + + k := keeper.NewKeeper( + cdc, + runtime.NewKVStoreService(storeKey), + log.NewNopLogger(), + authority.String(), + mockAccountKeeper, + mockBankKeeper, + mockAppKeeper, + mockSupplierKeeper, + ) + + // TODO_TECHDEBT: See the comment at the bottom of this file explaining + // why we don't support options yet. + // for _, opt := range opts { + // opt(k) + // } + + ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger()) + + // Initialize params + k.SetParams(ctx, types.DefaultParams()) + + // In prod, the hashes of all block heights are stored in the hash store while + // the block hashes below are hardcoded to match the hardcoded session IDs used + // in the `session_hydrator_test.go`. + // TODO_IMPROVE: Use fixtures populated by block hashes and their corresponding + // session IDs for each block height in the [0, N] interval, instead of using + // in-place hardcoded values. + // Store block hashes to be used in tests + blockHash := map[int64]string{ + 0: "", + 4: "261594ddc3c8afc5b4c63f59ee58e89d3a115bcd164c83fd79349de0b1ffd21d", + 8: "251665c7cf286a30fbd98acd983c63e9a34efc16496511373405e24eb02a8fb9", + } + + store := ctx.KVStore(storeKey) + for height, hash := range blockHash { + hashBz, err := hex.DecodeString(hash) + require.NoError(t, err) + store.Set(keeper.GetBlockHashKey(height), hashBz) + } + + return k, ctx +} + +func defaultAppKeeperMock(t testing.TB) types.ApplicationKeeper { + t.Helper() + ctrl := gomock.NewController(t) + + getAppFn := func(_ context.Context, appAddr string) (apptypes.Application, bool) { + switch appAddr { + case TestApp1Address: + return TestApp1, true + case TestApp2Address: + return TestApp2, true + default: + return apptypes.Application{}, false + } + } + + mockAppKeeper := mocks.NewMockApplicationKeeper(ctrl) + mockAppKeeper.EXPECT().GetApplication(gomock.Any(), gomock.Any()).AnyTimes().DoAndReturn(getAppFn) + mockAppKeeper.EXPECT().GetApplication(gomock.Any(), TestApp1Address).AnyTimes().Return(TestApp1, true) + + return mockAppKeeper +} + +func defaultSupplierKeeperMock(t testing.TB) types.SupplierKeeper { + t.Helper() + ctrl := gomock.NewController(t) + + allSuppliers := []sharedtypes.Supplier{TestSupplier} + + mockSupplierKeeper := mocks.NewMockSupplierKeeper(ctrl) + mockSupplierKeeper.EXPECT().GetAllSupplier(gomock.Any()).AnyTimes().Return(allSuppliers) + + return mockSupplierKeeper +} + +// TODO_TECHDEBT: Figure out how to vary the supplierKeep on a per test basis with exposing `SupplierKeeper publically` + +// type option[V any] func(k *keeper.Keeper) + +// WithPublisher returns an option function which sets the given publishCh of the +// resulting observable when passed to NewObservable(). +// func WithSupplierKeeperMock(supplierKeeper types.SupplierKeeper) option[any] { +// return func(k *keeper.Keeper) { +// k.supplierKeeper = supplierKeeper +// } +// } diff --git a/testutil/network/network.go b/testutil/network/network.go index 0cb263462..d2dbc068b 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -106,6 +106,35 @@ func DefaultApplicationModuleGenesisState(t *testing.T, n int) *apptypes.Genesis return state } +// DefaultSupplierModuleGenesisState generates a GenesisState object with a given number of suppliers. +// It returns the populated GenesisState object. +func DefaultSupplierModuleGenesisState(t *testing.T, n int) *suppliertypes.GenesisState { + t.Helper() + state := suppliertypes.DefaultGenesis() + for i := 0; i < n; i++ { + stake := sdk.NewCoin("upokt", sdkmath.NewInt(int64(i))) + supplier := sharedtypes.Supplier{ + Address: sample.AccAddress(), + Stake: &stake, + Services: []*sharedtypes.SupplierServiceConfig{ + { + Service: &sharedtypes.Service{Id: fmt.Sprintf("svc%d", i)}, + Endpoints: []*sharedtypes.SupplierEndpoint{ + { + Url: fmt.Sprintf("http://localhost:%d", i), + RpcType: sharedtypes.RPCType_JSON_RPC, + }, + }, + }, + }, + } + // TODO_CONSIDERATION: Evaluate whether we need `nullify.Fill` or if we should enforce `(gogoproto.nullable) = false` everywhere + // nullify.Fill(&supplier) + state.SupplierList = append(state.SupplierList, supplier) + } + return state +} + // DefaultGatewayModuleGenesisState generates a GenesisState object with a given // number of gateways. It returns the populated GenesisState object. func DefaultGatewayModuleGenesisState(t *testing.T, n int) *gatewaytypes.GenesisState { diff --git a/testutil/session/mocks/mocks.go b/testutil/session/mocks/mocks.go new file mode 100644 index 000000000..423f63d3e --- /dev/null +++ b/testutil/session/mocks/mocks.go @@ -0,0 +1,10 @@ +package mocks + +// This file is in place to declare the package for dynamically generated structs. +// +// Note that this does not follow the Cosmos SDK pattern of committing Mocks to main. +// For example, they commit auto-generate code to main: https://github.com/cosmos/cosmos-sdk/blob/main/x/gov/testutil/expected_keepers_mocks.go +// Documentation on how Cosmos uses mockgen can be found here: https://docs.cosmos.network/main/build/building-modules/testing#unit-tests +// +// IMPORTANT: We have attempted to use `.gitkeep` files instead, but it causes a circular dependency issue with protobuf and mock generation +// since we are leveraging `ignite` to compile `.proto` files which requires `.go` files to compile. diff --git a/x/session/keeper/block_hash.go b/x/session/keeper/block_hash.go new file mode 100644 index 000000000..f875b9fb3 --- /dev/null +++ b/x/session/keeper/block_hash.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + "fmt" + + "github.com/cosmos/cosmos-sdk/runtime" +) + +// GetBlockHash returns the hash of the block at the given height. +func (k Keeper) GetBlockHash(ctx context.Context, height int64) []byte { + store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + return store.Get(GetBlockHashKey(height)) +} + +// GetBlockHashKey returns the key used to store the block hash for a given height. +func GetBlockHashKey(height int64) []byte { + return []byte(fmt.Sprintf("Blockhash:%d", height)) +} diff --git a/x/session/keeper/keeper.go b/x/session/keeper/keeper.go index 24dd364b7..66025c7ed 100644 --- a/x/session/keeper/keeper.go +++ b/x/session/keeper/keeper.go @@ -1,11 +1,13 @@ package keeper import ( + "context" "fmt" "cosmossdk.io/core/store" "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/pokt-network/poktroll/x/session/types" @@ -65,3 +67,24 @@ func (k Keeper) GetAuthority() string { func (k Keeper) Logger() log.Logger { return k.logger.With("module", fmt.Sprintf("x/%s", types.ModuleName)) } + +// BeginBlocker is called at the beginning of every block. +// It fetches the block hash from the committed block ans saves its hash +// in the store. +func (k Keeper) BeginBlocker(goCtx context.Context) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // ctx.BlockHeader().LastBlockId.Hash is the hash of the last block committed + hash := ctx.BlockHeader().LastBlockId.Hash + // ctx.BlockHeader().Height is the height of the last committed block. + height := ctx.BlockHeader().Height + // Block height 1 is the first committed block which uses `genesis.json` as its parent. + // See the explanation here for more details: https://github.com/pokt-network/poktroll/issues/377#issuecomment-1936607294 + // Fallback to an empty byte slice during the genesis block. + if height == 1 { + hash = []byte{} + } + + store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store.Set(GetBlockHashKey(height), hash) +} diff --git a/x/session/keeper/query_get_session.go b/x/session/keeper/query_get_session.go index 073e0a0f3..8d365f171 100644 --- a/x/session/keeper/query_get_session.go +++ b/x/session/keeper/query_get_session.go @@ -4,20 +4,42 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/pokt-network/poktroll/x/session/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/pokt-network/poktroll/x/session/types" ) +// GetSession should be deterministic and always return the same session for +// the same block height. func (k Keeper) GetSession(goCtx context.Context, req *types.QueryGetSessionRequest) (*types.QueryGetSessionResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } + if err := req.ValidateBasic(); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + ctx := sdk.UnwrapSDKContext(goCtx) - // TODO: Process the query - _ = ctx + // Note that `GetSession` is called via the `Query` service rather than the `Msg` server. + // The former is stateful but does not lead to state transitions, while the latter one + // does. The request height depends on how much the node has synched and only acts as a read, + // while the `Msg` server handles the code flow of the validator/sequencer when a new block + // is being proposed. + blockHeight := req.BlockHeight - return &types.QueryGetSessionResponse{}, nil + k.Logger().Info("Getting session for height: %d", blockHeight) + + sessionHydrator := NewSessionHydrator(req.ApplicationAddress, req.Service.Id, blockHeight) + session, err := k.HydrateSession(ctx, sessionHydrator) + if err != nil { + return nil, err + } + + res := &types.QueryGetSessionResponse{ + Session: session, + } + return res, nil } diff --git a/x/session/keeper/query_get_session_test.go b/x/session/keeper/query_get_session_test.go new file mode 100644 index 000000000..597095833 --- /dev/null +++ b/x/session/keeper/query_get_session_test.go @@ -0,0 +1,166 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/pokt-network/poktroll/cmd/poktrolld/cmd" + keepertest "github.com/pokt-network/poktroll/testutil/keeper" + "github.com/pokt-network/poktroll/testutil/sample" + "github.com/pokt-network/poktroll/x/session/types" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" +) + +func init() { + cmd.InitSDKConfig() +} + +// NOTE: See `session_hydrator_test.go` for more extensive test coverage of different +// GetSession scenarios. This is just used to verify a few basic scenarios that act as +// the Cosmos SDK context aware wrapper around it. + +func TestSession_GetSession_Success(t *testing.T) { + keeper, ctx := keepertest.SessionKeeper(t) + ctx = ctx.WithBlockHeight(100) // provide a sufficiently large block height to avoid errors + + // TODO_TECHDEBT(#377): These test assume that the genesis block has a height of 0, + // rewrite them in terms of height = 1 genesis. + type test struct { + name string + + appAddr string + serviceId string + blockHeight int64 + + expectedSessionId string + expectedSessionNumber int64 + expectedNumSuppliers int + } + + tests := []test{ + { + name: "valid - app1 svc1 at height=1", + + appAddr: keepertest.TestApp1Address, + serviceId: keepertest.TestServiceId1, + blockHeight: 1, + + // Intentionally only checking a subset of the session metadata returned + expectedSessionId: "6f2e0b6cba5a8cb93506ed4045143c4268945ebfb730b2c98fc7e3dc40132926", + expectedSessionNumber: 0, + expectedNumSuppliers: 1, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + req := &types.QueryGetSessionRequest{ + ApplicationAddress: tt.appAddr, + Service: &sharedtypes.Service{ + Id: tt.serviceId, + }, + BlockHeight: 1, + } + + response, err := keeper.GetSession(ctx, req) + require.NoError(t, err) + require.NotNil(t, response) + + require.Equal(t, tt.expectedSessionId, response.Session.SessionId) + require.Equal(t, tt.expectedSessionNumber, response.Session.SessionNumber) + require.Len(t, response.Session.Suppliers, tt.expectedNumSuppliers) + }) + } +} + +func TestSession_GetSession_Failure(t *testing.T) { + keeper, ctx := keepertest.SessionKeeper(t) + ctx = ctx.WithBlockHeight(100) // provide a sufficiently large block height to avoid errors + + type test struct { + name string + + appAddr string + serviceId string + blockHeight int64 + + expectedErrContains string + } + + tests := []test{ + { + name: "application address does not reflected a staked application", + + appAddr: sample.AccAddress(), // a random (valid) app address that's not staked + serviceId: keepertest.TestServiceId1, + blockHeight: 1, + + expectedErrContains: types.ErrSessionAppNotFound.Error(), + }, + { + name: "application staked for service that has no available suppliers", + + appAddr: keepertest.TestApp1Address, + serviceId: keepertest.TestServiceId11, + blockHeight: 1, + + expectedErrContains: types.ErrSessionSuppliersNotFound.Error(), + }, + { + name: "application is valid but not staked for the specified service", + + appAddr: keepertest.TestApp1Address, + serviceId: "svc9001", // App1 is not staked for service over 9000 + blockHeight: 1, + + expectedErrContains: types.ErrSessionAppNotStakedForService.Error(), + }, + { + name: "application address is invalid format", + + appAddr: "invalid_app_address", + serviceId: keepertest.TestServiceId1, + blockHeight: 1, + + expectedErrContains: types.ErrSessionInvalidAppAddress.Error(), + }, + { + name: "service ID is invalid", + + appAddr: keepertest.TestApp1Address, + serviceId: "service_id_is_too_long_to_be_valid", + blockHeight: 1, + + expectedErrContains: "invalid service in session", + }, + { + name: "negative block height", + + appAddr: keepertest.TestApp1Address, + serviceId: keepertest.TestServiceId1, + blockHeight: -1, + + expectedErrContains: "invalid block height for session being retrieved", + }, + } + + expectedRes := (*types.QueryGetSessionResponse)(nil) + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + req := &types.QueryGetSessionRequest{ + ApplicationAddress: tt.appAddr, + Service: &sharedtypes.Service{ + Id: tt.serviceId, + }, + BlockHeight: tt.blockHeight, + } + + res, err := keeper.GetSession(ctx, req) + require.Error(t, err) + require.Contains(t, err.Error(), tt.expectedErrContains) + require.Equal(t, expectedRes, res) + }) + } +} diff --git a/x/session/keeper/session_hydrator.go b/x/session/keeper/session_hydrator.go new file mode 100644 index 000000000..6a36309c7 --- /dev/null +++ b/x/session/keeper/session_hydrator.go @@ -0,0 +1,306 @@ +package keeper + +import ( + "crypto" + "encoding/binary" + "encoding/hex" + "fmt" + "math/rand" + + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + _ "golang.org/x/crypto/sha3" + + "github.com/pokt-network/poktroll/x/session/types" + sharedhelpers "github.com/pokt-network/poktroll/x/shared/helpers" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" +) + +// TODO_TECHDEBT(#377): The business logic in this file assume that genesis has +// a block height of 0. Revisit it and adjust, where/if necessary, accounting for the +// fact that it's 1. + +var SHA3HashLen = crypto.SHA3_256.Size() + +// TODO_BLOCKER(#21): Make these configurable governance param +const ( + // TODO_BLOCKER: Remove direct usage of these constants in helper functions + // when they will be replaced by governance params + NumBlocksPerSession = 4 + // Duration of the grace period in number of sessions + SessionGracePeriod = 1 + NumSupplierPerSession = 15 + SessionIDComponentDelimiter = "." +) + +type sessionHydrator struct { + // The session header that is used to hydrate the rest of the session data + sessionHeader *types.SessionHeader + + // The fully hydrated session object + session *types.Session + + // The height at which the session being request + blockHeight int64 + + // A redundant helper that maintains a hex decoded copy of `session.Id` used for session hydration + sessionIdBz []byte +} + +func NewSessionHydrator( + appAddress string, + serviceId string, + blockHeight int64, +) *sessionHydrator { + sessionHeader := &types.SessionHeader{ + ApplicationAddress: appAddress, + Service: &sharedtypes.Service{Id: serviceId}, + } + return &sessionHydrator{ + sessionHeader: sessionHeader, + session: &types.Session{}, + blockHeight: blockHeight, + sessionIdBz: make([]byte, 0), + } +} + +// GetSession implements of the exposed `UtilityModule.GetSession` function +// TECHDEBT(#519): Add custom error types depending on the type of issue that occurred and assert on them in the unit tests. +func (k Keeper) HydrateSession(ctx sdk.Context, sh *sessionHydrator) (*types.Session, error) { + logger := k.Logger().With("method", "hydrateSession") + + if err := k.hydrateSessionMetadata(ctx, sh); err != nil { + return nil, sdkerrors.Wrapf(types.ErrSessionHydration, "failed to hydrate the session metadata: %v", err) + } + logger.Debug("Finished hydrating session metadata") + + if err := k.hydrateSessionID(ctx, sh); err != nil { + return nil, sdkerrors.Wrapf(types.ErrSessionHydration, "failed to hydrate the session ID: %v", err) + } + logger.Info(fmt.Sprintf("Finished hydrating session ID: %s", sh.sessionHeader.SessionId)) + + if err := k.hydrateSessionApplication(ctx, sh); err != nil { + return nil, sdkerrors.Wrapf(types.ErrSessionHydration, "failed to hydrate application for session: %v", err) + } + logger.Debug("Finished hydrating session application: %+v", sh.session.Application) + + if err := k.hydrateSessionSuppliers(ctx, sh); err != nil { + return nil, sdkerrors.Wrapf(types.ErrSessionHydration, "failed to hydrate suppliers for session: %v", err) + } + logger.Debug("Finished hydrating session suppliers: %+v") + + sh.session.Header = sh.sessionHeader + sh.session.SessionId = sh.sessionHeader.SessionId + + return sh.session, nil +} + +// hydrateSessionMetadata hydrates metadata related to the session such as the height at which the session started, its number, the number of blocks per session, etc.. +func (k Keeper) hydrateSessionMetadata(ctx sdk.Context, sh *sessionHydrator) error { + // TODO_TECHDEBT: Add a test if `blockHeight` is ahead of the current chain or what this node is aware of + + if sh.blockHeight > ctx.BlockHeight() { + return sdkerrors.Wrapf( + types.ErrSessionHydration, + "block height %d is ahead of the last committed block height %d", + sh.blockHeight, ctx.BlockHeight(), + ) + } + + sh.session.NumBlocksPerSession = NumBlocksPerSession + sh.session.SessionNumber = GetSessionNumber(sh.blockHeight) + + sh.sessionHeader.SessionStartBlockHeight = GetSessionStartBlockHeight(sh.blockHeight) + sh.sessionHeader.SessionEndBlockHeight = GetSessionEndBlockHeight(sh.blockHeight) + return nil +} + +// hydrateSessionID use both session and on-chain data to determine a unique session ID +func (k Keeper) hydrateSessionID(ctx sdk.Context, sh *sessionHydrator) error { + prevHashBz := k.GetBlockHash(ctx, sh.sessionHeader.SessionStartBlockHeight) + + // TODO_TECHDEBT: In the future, we will need to valid that the Service is a valid service depending on whether + // or not its permissioned or permissionless + + if !sharedhelpers.IsValidService(sh.sessionHeader.Service) { + return sdkerrors.Wrapf(types.ErrSessionHydration, "invalid service: %v", sh.sessionHeader.Service) + } + + sh.sessionHeader.SessionId, sh.sessionIdBz = GetSessionId( + sh.sessionHeader.ApplicationAddress, + sh.sessionHeader.Service.Id, + prevHashBz, + sh.blockHeight, + ) + + return nil +} + +// hydrateSessionApplication hydrates the full Application actor based on the address provided +func (k Keeper) hydrateSessionApplication(ctx sdk.Context, sh *sessionHydrator) error { + app, appIsFound := k.applicationKeeper.GetApplication(ctx, sh.sessionHeader.ApplicationAddress) + if !appIsFound { + return sdkerrors.Wrapf(types.ErrSessionAppNotFound, "could not find app with address: %s at height %d", sh.sessionHeader.ApplicationAddress, sh.sessionHeader.SessionStartBlockHeight) + } + + for _, appServiceConfig := range app.ServiceConfigs { + if appServiceConfig.Service.Id == sh.sessionHeader.Service.Id { + sh.session.Application = &app + return nil + } + } + + return sdkerrors.Wrapf(types.ErrSessionAppNotStakedForService, "application %s not staked for service %s", sh.sessionHeader.ApplicationAddress, sh.sessionHeader.Service.Id) +} + +// hydrateSessionSuppliers finds the suppliers that are staked at the session height and populates the session with them +func (k Keeper) hydrateSessionSuppliers(ctx sdk.Context, sh *sessionHydrator) error { + logger := k.Logger().With("method", "hydrateSessionSuppliers") + + // TODO_TECHDEBT(@Olshansk, @bryanchriswhite): Need to retrieve the suppliers at SessionStartBlockHeight, + // NOT THE CURRENT ONE which is what's provided by the context. For now, for simplicity, + // only retrieving the suppliers at the current block height which could create a discrepancy + // if new suppliers were staked mid session. + // TODO(@bryanchriswhite): Investigate if `BlockClient` + `ReplayObservable` where `N = SessionLength` could be used here.` + suppliers := k.supplierKeeper.GetAllSupplier(ctx) + + candidateSuppliers := make([]*sharedtypes.Supplier, 0) + for _, s := range suppliers { + // NB: Allocate a new heap variable as s is a value and we're appending + // to a slice of pointers; otherwise, we'd be appending new pointers to + // the same memory address containing the last supplier in the loop. + supplier := s + // TODO_OPTIMIZE: If `supplier.Services` was a map[string]struct{}, we could eliminate `slices.Contains()`'s loop + for _, supplierServiceConfig := range supplier.Services { + if supplierServiceConfig.Service.Id == sh.sessionHeader.Service.Id { + candidateSuppliers = append(candidateSuppliers, &supplier) + break + } + } + } + + if len(candidateSuppliers) == 0 { + logger.Error("[ERROR] no suppliers found for session") + return sdkerrors.Wrapf(types.ErrSessionSuppliersNotFound, "could not find suppliers for service %s at height %d", sh.sessionHeader.Service, sh.sessionHeader.SessionStartBlockHeight) + } + + if len(candidateSuppliers) < NumSupplierPerSession { + logger.Info(fmt.Sprintf("[WARN] number of available suppliers (%d) is less than the number of suppliers per session (%d)", len(candidateSuppliers), NumSupplierPerSession)) + sh.session.Suppliers = candidateSuppliers + } else { + sh.session.Suppliers = pseudoRandomSelection(candidateSuppliers, NumSupplierPerSession, sh.sessionIdBz) + } + + return nil +} + +// TODO_INVESTIGATE: We are using a `Go` native implementation for a pseudo-random number generator. In order +// for it to be language agnostic, a general purpose algorithm MUST be used. +// pseudoRandomSelection returns a random subset of the candidates. +func pseudoRandomSelection(candidates []*sharedtypes.Supplier, numTarget int, sessionIdBz []byte) []*sharedtypes.Supplier { + // Take the first 8 bytes of sessionId to use as the seed + // NB: There is specific reason why `BigEndian` was chosen over `LittleEndian` in this specific context. + seed := int64(binary.BigEndian.Uint64(sha3Hash(sessionIdBz)[:8])) + + // Retrieve the indices for the candidates + actors := make([]*sharedtypes.Supplier, 0) + uniqueIndices := uniqueRandomIndices(seed, int64(len(candidates)), int64(numTarget)) + for idx := range uniqueIndices { + actors = append(actors, candidates[idx]) + } + + return actors +} + +// uniqueRandomIndices returns a map of `numIndices` unique random numbers less than `maxIndex` +// seeded by `seed`. +// panics if `numIndicies > maxIndex` since that code path SHOULD never be executed. +// NB: A map pointing to empty structs is used to simulate set behavior. +func uniqueRandomIndices(seed, maxIndex, numIndices int64) map[int64]struct{} { + // This should never happen + if numIndices > maxIndex { + panic(fmt.Sprintf("uniqueRandomIndices: numIndices (%d) is greater than maxIndex (%d)", numIndices, maxIndex)) + } + + // create a new random source with the seed + randSrc := rand.NewSource(seed) + + // initialize a map to capture the indicesMap we'll return + indicesMap := make(map[int64]struct{}, maxIndex) + + // The random source could potentially return duplicates, so while loop until we have enough unique indices + for int64(len(indicesMap)) < numIndices { + indicesMap[randSrc.Int63()%int64(maxIndex)] = struct{}{} + } + + return indicesMap +} + +func concatWithDelimiter(delimiter string, b ...[]byte) (result []byte) { + for _, bz := range b { + result = append(result, bz...) + result = append(result, []byte(delimiter)...) + } + return result +} + +func sha3Hash(bz []byte) []byte { + hasher := crypto.SHA3_256.New() + hasher.Write(bz) + return hasher.Sum(nil) +} + +// GetSessionStartBlockHeight returns the block height at which the session starts +func GetSessionStartBlockHeight(blockHeight int64) int64 { + return blockHeight - (blockHeight % NumBlocksPerSession) +} + +// GetSessionEndBlockHeight returns the block height at which the session ends +func GetSessionEndBlockHeight(blockHeight int64) int64 { + return GetSessionStartBlockHeight(blockHeight) + NumBlocksPerSession - 1 +} + +// GetSessionNumber returns the session number given the block height +func GetSessionNumber(blockHeight int64) int64 { + return blockHeight / NumBlocksPerSession +} + +// 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. +func GetSessionId( + appPubKey, + serviceId string, + blockHashBz []byte, + blockHeight int64, +) (sessionId string, sessionIdBz []byte) { + appPubKeyBz := []byte(appPubKey) + serviceIdBz := []byte(serviceId) + + blockHeightBz := getSessionStartBlockHeightBz(blockHeight) + sessionIdBz = concatWithDelimiter( + SessionIDComponentDelimiter, + blockHashBz, + serviceIdBz, + appPubKeyBz, + blockHeightBz, + ) + sessionId = hex.EncodeToString(sha3Hash(sessionIdBz)) + + 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) + sessionStartBlockHeightBz := make([]byte, 8) + binary.LittleEndian.PutUint64(sessionStartBlockHeightBz, uint64(sessionStartBlockHeight)) + return sessionStartBlockHeightBz +} diff --git a/x/session/keeper/session_hydrator_test.go b/x/session/keeper/session_hydrator_test.go new file mode 100644 index 000000000..e914ca0ea --- /dev/null +++ b/x/session/keeper/session_hydrator_test.go @@ -0,0 +1,359 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + keepertest "github.com/pokt-network/poktroll/testutil/keeper" + "github.com/pokt-network/poktroll/testutil/sample" + "github.com/pokt-network/poktroll/x/session/keeper" + "github.com/pokt-network/poktroll/x/session/types" +) + +// TODO_TECHDEBT(#377): All the tests in this file assume genesis has a block +// height of 0. Rewrite them in terms of height = 1 genesis. + +func TestSession_HydrateSession_Success_BaseCase(t *testing.T) { + sessionKeeper, ctx := keepertest.SessionKeeper(t) + ctx = ctx.WithBlockHeight(100) // provide a sufficiently large block height to avoid errors + blockHeight := int64(10) + + sessionHydrator := keeper.NewSessionHydrator(keepertest.TestApp1Address, keepertest.TestServiceId1, blockHeight) + session, err := sessionKeeper.HydrateSession(ctx, sessionHydrator) + require.NoError(t, err) + + // Check the header + sessionHeader := session.Header + require.Equal(t, keepertest.TestApp1Address, sessionHeader.ApplicationAddress) + require.Equal(t, keepertest.TestServiceId1, sessionHeader.Service.Id) + require.Equal(t, "", sessionHeader.Service.Name) + require.Equal(t, int64(8), sessionHeader.SessionStartBlockHeight) + require.Equal(t, int64(11), sessionHeader.SessionEndBlockHeight) + require.Equal(t, "f621ad93e2d9ebf2e967eb16b8ea2bc470baa1d4e13a82f348f34c6fc93eae7f", sessionHeader.SessionId) + + // Check the session + require.Equal(t, int64(4), session.NumBlocksPerSession) + require.Equal(t, "f621ad93e2d9ebf2e967eb16b8ea2bc470baa1d4e13a82f348f34c6fc93eae7f", session.SessionId) + require.Equal(t, int64(2), session.SessionNumber) + + // Check the application + app := session.Application + require.Equal(t, keepertest.TestApp1Address, app.Address) + require.Len(t, app.ServiceConfigs, 3) + + // Check the suppliers + suppliers := session.Suppliers + require.Len(t, suppliers, 1) + supplier := suppliers[0] + require.Equal(t, keepertest.TestSupplierAddress, supplier.Address) + require.Len(t, supplier.Services, 3) +} + +func TestSession_HydrateSession_Metadata(t *testing.T) { + type test struct { + desc string + blockHeight int64 + + expectedNumBlocksPerSession int64 + expectedSessionNumber int64 + expectedSessionStartBlock int64 + expectedSessionEndBlock int64 + errExpected error + } + + // TODO_TECHDEBT: Extend these tests once `NumBlocksPerSession` is configurable. + // Currently assumes NumBlocksPerSession=4 + tests := []test{ + { + desc: "blockHeight = 0", + blockHeight: 0, + + expectedNumBlocksPerSession: 4, + expectedSessionNumber: 0, + expectedSessionStartBlock: 0, + expectedSessionEndBlock: 3, + errExpected: nil, + }, + { + desc: "blockHeight = 1", + blockHeight: 1, + + expectedNumBlocksPerSession: 4, + expectedSessionNumber: 0, + expectedSessionStartBlock: 0, + expectedSessionEndBlock: 3, + errExpected: nil, + }, + { + desc: "blockHeight = sessionHeight", + blockHeight: 4, + + expectedNumBlocksPerSession: 4, + expectedSessionNumber: 1, + expectedSessionStartBlock: 4, + expectedSessionEndBlock: 7, + errExpected: nil, + }, + { + desc: "blockHeight != sessionHeight", + blockHeight: 5, + + expectedNumBlocksPerSession: 4, + expectedSessionNumber: 1, + expectedSessionStartBlock: 4, + expectedSessionEndBlock: 7, + errExpected: nil, + }, + { + desc: "blockHeight > contextHeight", + blockHeight: 9001, // block height over 9000 is too high given that the context height is 100 + + errExpected: types.ErrSessionHydration, + }, + } + + appAddr := keepertest.TestApp1Address + serviceId := keepertest.TestServiceId1 + sessionKeeper, ctx := keepertest.SessionKeeper(t) + ctx = ctx.WithBlockHeight(100) // provide a sufficiently large block height to avoid errors + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + sessionHydrator := keeper.NewSessionHydrator(appAddr, serviceId, tt.blockHeight) + session, err := sessionKeeper.HydrateSession(ctx, sessionHydrator) + + if tt.errExpected != nil { + require.ErrorIs(t, tt.errExpected, err) + return + } + require.NoError(t, err) + + require.Equal(t, tt.expectedNumBlocksPerSession, session.NumBlocksPerSession) + require.Equal(t, tt.expectedSessionNumber, session.SessionNumber) + require.Equal(t, tt.expectedSessionStartBlock, session.Header.SessionStartBlockHeight) + require.Equal(t, tt.expectedSessionEndBlock, session.Header.SessionEndBlockHeight) + }) + } +} + +func TestSession_HydrateSession_SessionId(t *testing.T) { + type test struct { + desc string + + blockHeight1 int64 + blockHeight2 int64 + + appAddr1 string + appAddr2 string + + serviceId1 string + serviceId2 string + + expectedSessionId1 string + expectedSessionId2 string + } + + // TODO_TECHDEBT: Extend these tests once `NumBlocksPerSession` is configurable. + // Currently assumes NumBlocksPerSession=4 + tests := []test{ + { + desc: "(app1, svc1): sessionId at first session block != sessionId at next session block", + + blockHeight1: 4, + blockHeight2: 8, + + appAddr1: keepertest.TestApp1Address, // app1 + appAddr2: keepertest.TestApp1Address, // app1 + + serviceId1: keepertest.TestServiceId1, // svc1 + serviceId2: keepertest.TestServiceId1, // svc1 + + expectedSessionId1: "8d7919d1addb175425ed99bc897aee7fecd6a184e46a0ce4119b610db9242db5", + expectedSessionId2: "f621ad93e2d9ebf2e967eb16b8ea2bc470baa1d4e13a82f348f34c6fc93eae7f", + }, + { + desc: "app1: sessionId for svc1 != sessionId for svc12", + + blockHeight1: 4, + blockHeight2: 4, + + appAddr1: keepertest.TestApp1Address, // app1 + appAddr2: keepertest.TestApp1Address, // app1 + + serviceId1: keepertest.TestServiceId1, // svc1 + serviceId2: keepertest.TestServiceId12, // svc12 + + expectedSessionId1: "8d7919d1addb175425ed99bc897aee7fecd6a184e46a0ce4119b610db9242db5", + expectedSessionId2: "40d02827f0f3f717caf844cd4cfbe1ebc2f3ada7d4e5974ed6ec795b9a715e07", + }, + { + desc: "svc12: sessionId for app1 != sessionId for app2", + + blockHeight1: 4, + blockHeight2: 4, + + appAddr1: keepertest.TestApp1Address, // app1 + appAddr2: keepertest.TestApp2Address, // app2 + + serviceId1: keepertest.TestServiceId12, // svc12 + serviceId2: keepertest.TestServiceId12, // svc12 + + expectedSessionId1: "40d02827f0f3f717caf844cd4cfbe1ebc2f3ada7d4e5974ed6ec795b9a715e07", + expectedSessionId2: "5c338ae8bf5138b7ca9a0ca124942984734531fb30f1670da772ef3e635939f6", + }, + } + + sessionKeeper, ctx := keepertest.SessionKeeper(t) + ctx = ctx.WithBlockHeight(100) // provide a sufficiently large block height to avoid errors + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + sessionHydrator1 := keeper.NewSessionHydrator(tt.appAddr1, tt.serviceId1, tt.blockHeight1) + session1, err := sessionKeeper.HydrateSession(ctx, sessionHydrator1) + require.NoError(t, err) + + sessionHydrator2 := keeper.NewSessionHydrator(tt.appAddr2, tt.serviceId2, tt.blockHeight2) + session2, err := sessionKeeper.HydrateSession(ctx, sessionHydrator2) + require.NoError(t, err) + + require.NotEqual(t, session1.Header.SessionId, session2.Header.SessionId) + require.Equal(t, tt.expectedSessionId1, session1.Header.SessionId) + require.Equal(t, tt.expectedSessionId2, session2.Header.SessionId) + }) + } +} + +// TODO_TECHDEBT: Expand these tests to account for application joining/leaving the network at different heights as well changing the services they support +func TestSession_HydrateSession_Application(t *testing.T) { + type test struct { + // Description + desc string + // Inputs + appAddr string + serviceId string + + // Outputs + expectedErr error + } + + tests := []test{ + { + desc: "app is found", + + appAddr: keepertest.TestApp1Address, + serviceId: keepertest.TestServiceId1, + + expectedErr: nil, + }, + { + desc: "app is not found", + + appAddr: sample.AccAddress(), // Generating a random address on the fly + serviceId: keepertest.TestServiceId1, + + expectedErr: types.ErrSessionHydration, + }, + { + desc: "invalid app address", + + appAddr: "invalid", + serviceId: keepertest.TestServiceId1, + + expectedErr: types.ErrSessionHydration, + }, + { + desc: "invalid - app not staked for service", + + appAddr: keepertest.TestApp1Address, // app1 + serviceId: "svc9001", // app1 is only stake for svc1 and svc11 + + expectedErr: types.ErrSessionHydration, + }, + // TODO_TECHDEBT: Add tests for when: + // - Application join/leaves (stakes/unstakes) altogether + // - Application adds/removes certain services mid-session + // - Application increases stakes mid-session + } + + blockHeight := int64(10) + sessionKeeper, ctx := keepertest.SessionKeeper(t) + ctx = ctx.WithBlockHeight(100) // provide a sufficiently large block height to avoid errors + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + sessionHydrator := keeper.NewSessionHydrator(tt.appAddr, tt.serviceId, blockHeight) + _, err := sessionKeeper.HydrateSession(ctx, sessionHydrator) + if tt.expectedErr != nil { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +// TODO_TECHDEBT: Expand these tests to account for supplier joining/leaving the network at different heights as well changing the services they support +func TestSession_HydrateSession_Suppliers(t *testing.T) { + type test struct { + // Description + desc string + + // Inputs + appAddr string + serviceId string + + // Outputs + numExpectedSuppliers int + expectedErr error + } + + // TODO_TECHDEBT: Extend these tests once `NumBlocksPerSession` is configurable. + // Currently assumes NumSupplierPerSession=15 + tests := []test{ + { + desc: "num_suppliers_available = 0", + + appAddr: keepertest.TestApp1Address, // app1 + serviceId: keepertest.TestServiceId11, + + numExpectedSuppliers: 0, + expectedErr: types.ErrSessionSuppliersNotFound, + }, + { + desc: "num_suppliers_available < num_suppliers_per_session_param", + + appAddr: keepertest.TestApp1Address, // app1 + serviceId: keepertest.TestServiceId1, // svc1 + + numExpectedSuppliers: 1, + expectedErr: nil, + }, + // TODO_TECHDEBT: Add this test once we make the num suppliers per session configurable + // { + // name: "num_suppliers_available > num_suppliers_per_session_param", + // }, + // TODO_TECHDEBT: Add tests for when: + // - Supplier join/leaves (stakes/unstakes) altogether + // - Supplier adds/removes certain services mid-session + // - Supplier increases stakes mid-session + } + + blockHeight := int64(10) + sessionKeeper, ctx := keepertest.SessionKeeper(t) + ctx = ctx.WithBlockHeight(100) // provide a sufficiently large block height to avoid errors + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) {}) + + sessionHydrator := keeper.NewSessionHydrator(tt.appAddr, tt.serviceId, blockHeight) + session, err := sessionKeeper.HydrateSession(ctx, sessionHydrator) + + if tt.expectedErr != nil { + require.ErrorContains(t, err, tt.expectedErr.Error()) + continue + } + require.NoError(t, err) + require.Len(t, session.Suppliers, tt.numExpectedSuppliers) + } +} diff --git a/x/session/module/helpers_test.go b/x/session/module/helpers_test.go new file mode 100644 index 000000000..7a2cf436e --- /dev/null +++ b/x/session/module/helpers_test.go @@ -0,0 +1,45 @@ +// Package session_test provides unit tests for the CLI functionality. +package session_test + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/pokt-network/poktroll/cmd/poktrolld/cmd" + "github.com/pokt-network/poktroll/testutil/network" + apptypes "github.com/pokt-network/poktroll/x/application/types" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" + suppliertypes "github.com/pokt-network/poktroll/x/supplier/types" +) + +// Dummy variable to avoid unused import error. +var _ = strconv.IntSize + +// init initializes the SDK configuration. +func init() { + cmd.InitSDKConfig() +} + +// networkWithApplicationsAndSupplier creates a new network with a given number of supplier & application objects. +// It returns the network and a slice of the created supplier & application objects. +func networkWithApplicationsAndSupplier(t *testing.T, n int) (*network.Network, []sharedtypes.Supplier, []apptypes.Application) { + t.Helper() + cfg := network.DefaultConfig() + + // Prepare the application genesis state + applicationGenesisState := network.DefaultApplicationModuleGenesisState(t, n) + buf, err := cfg.Codec.MarshalJSON(applicationGenesisState) + require.NoError(t, err) + cfg.GenesisState[apptypes.ModuleName] = buf + + // Prepare the supplier genesis state + supplierGenesisState := network.DefaultSupplierModuleGenesisState(t, n) + buf, err = cfg.Codec.MarshalJSON(supplierGenesisState) + require.NoError(t, err) + cfg.GenesisState[suppliertypes.ModuleName] = buf + + // Start the network + return network.New(t, cfg), supplierGenesisState.SupplierList, applicationGenesisState.ApplicationList +} diff --git a/x/session/module/module.go b/x/session/module/module.go index 733e8bf0f..a7f99ea0d 100644 --- a/x/session/module/module.go +++ b/x/session/module/module.go @@ -145,7 +145,8 @@ 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 { +func (am AppModule) BeginBlock(ctx context.Context) error { + am.keeper.BeginBlocker(ctx) return nil } diff --git a/x/session/module/query.go b/x/session/module/query.go new file mode 100644 index 000000000..a26d1a2e7 --- /dev/null +++ b/x/session/module/query.go @@ -0,0 +1,31 @@ +package session + +import ( + "fmt" + // "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + + "github.com/pokt-network/poktroll/x/session/types" +) + +// GetQueryCmd returns the cli query commands for this module +func (am AppModule) GetQueryCmd(queryRoute string) *cobra.Command { + // Group session queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdQueryParams()) + cmd.AddCommand(CmdGetSession()) + + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/session/module/query_get_session.go b/x/session/module/query_get_session.go new file mode 100644 index 000000000..a514b4c61 --- /dev/null +++ b/x/session/module/query_get_session.go @@ -0,0 +1,65 @@ +package session + +import ( + "fmt" + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/pokt-network/poktroll/x/session/types" +) + +var _ = strconv.Itoa(0) + +func CmdGetSession() *cobra.Command { + cmd := &cobra.Command{ + Use: "get-session [block_height]", + Short: "Query get-session", + Long: `Query the session data for a specific (app, service, height) tuple. + +[block_height] is optional. If unspecified, or set to 0, it defaults to the latest height of the node being queried. + +This is a query operation that will not result in a state transition but simply gives a view into the chain state. + +Example: +$ poktrolld --home=$(POKTROLLD_HOME) q session get-session pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 svc1 42 --node $(POCKET_NODE)`, + Args: cobra.RangeArgs(2, 3), + RunE: func(cmd *cobra.Command, args []string) (err error) { + appAddressString := args[0] + serviceIdString := args[1] + blockHeightString := "0" // 0 will default to latest height + if len(args) == 3 { + blockHeightString = args[2] + } + + blockHeight, err := strconv.ParseInt(blockHeightString, 10, 64) + if err != nil { + return fmt.Errorf("couldn't convert block height to int: %s; (%v)", blockHeightString, err) + } + + getSessionReq := types.NewQueryGetSessionRequest(appAddressString, serviceIdString, blockHeight) + if err := getSessionReq.ValidateBasic(); err != nil { + return err + } + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + getSessionRes, err := queryClient.GetSession(cmd.Context(), getSessionReq) + if err != nil { + return err + } + + return clientCtx.PrintProto(getSessionRes) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/session/module/query_get_session_test.go b/x/session/module/query_get_session_test.go new file mode 100644 index 000000000..48853e249 --- /dev/null +++ b/x/session/module/query_get_session_test.go @@ -0,0 +1,196 @@ +package session_test + +import ( + "fmt" + "testing" + + sdkerrors "cosmossdk.io/errors" + tmcli "github.com/cometbft/cometbft/libs/cli" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/stretchr/testify/require" + + session "github.com/pokt-network/poktroll/x/session/module" + sessiontypes "github.com/pokt-network/poktroll/x/session/types" +) + +func TestCLI_GetSession(t *testing.T) { + // Prepare the network + net, suppliers, applications := networkWithApplicationsAndSupplier(t, 2) + _, err := net.WaitForHeight(10) // Wait for a sufficiently high block height to ensure the staking transactions have been processed + require.NoError(t, err) + val := net.Validators[0] + ctx := val.ClientCtx + + // Sanity check the application configs are what we expect them to be + appSvc0 := applications[0] + appSvc1 := applications[1] + + require.Len(t, appSvc0.ServiceConfigs, 2) + require.Len(t, appSvc1.ServiceConfigs, 2) + + require.Equal(t, appSvc0.ServiceConfigs[0].Service.Id, "svc0") // svc0 has a supplier + require.Equal(t, appSvc0.ServiceConfigs[1].Service.Id, "svc00") // svc00 doesn't have a supplier + require.Equal(t, appSvc1.ServiceConfigs[0].Service.Id, "svc1") // svc1 has a supplier + require.Equal(t, appSvc1.ServiceConfigs[1].Service.Id, "svc11") // svc11 doesn't have a supplier + + // Sanity check the supplier configs are what we expect them to be + supplierSvc0 := suppliers[0] // supplier for svc0 + supplierSvc1 := suppliers[1] // supplier for svc1 + + require.Len(t, supplierSvc0.Services, 1) + require.Len(t, supplierSvc1.Services, 1) + + require.Equal(t, supplierSvc0.Services[0].Service.Id, "svc0") + require.Equal(t, supplierSvc1.Services[0].Service.Id, "svc1") + + // Prepare the test cases + tests := []struct { + desc string + + appAddress string + serviceId string + blockHeight int64 + + expectedErr *sdkerrors.Error + expectedNumSuppliers int + }{ + // Valid requests + { + desc: "valid - block height specified and is zero", + + appAddress: appSvc0.Address, + serviceId: "svc0", + blockHeight: 0, + + expectedErr: nil, + expectedNumSuppliers: 1, + }, + { + desc: "valid - block height specified and is greater than zero", + + appAddress: appSvc1.Address, + serviceId: "svc1", + blockHeight: 10, + + expectedErr: nil, + expectedNumSuppliers: 1, + }, + { + desc: "valid - block height unspecified and defaults to 0", + + appAddress: appSvc0.Address, + serviceId: "svc0", + // blockHeight: intentionally omitted, + + expectedErr: nil, + expectedNumSuppliers: 1, + }, + + // Invalid requests - incompatible state + { + desc: "invalid - app not staked for service", + + appAddress: appSvc0.Address, + serviceId: "svc9001", // appSvc0 is only staked for svc0 (has supplier) and svc00 (doesn't have supplier) and is not staked for service over 9000 + blockHeight: 0, + + expectedErr: sessiontypes.ErrSessionAppNotStakedForService, + }, + { + desc: "invalid - no suppliers staked for service", + + appAddress: appSvc0.Address, // dynamically getting address from applications + serviceId: "svc00", // appSvc0 is only staked for svc0 (has supplier) and svc00 (doesn't have supplier) + blockHeight: 0, + + expectedErr: sessiontypes.ErrSessionSuppliersNotFound, + }, + { + desc: "invalid - block height is in the future", + + appAddress: appSvc0.Address, // dynamically getting address from applications + serviceId: "svc0", + blockHeight: 9001, // block height over 9000 is greater than the context height of 10 + + expectedErr: sessiontypes.ErrSessionInvalidBlockHeight, + }, + + // Invalid requests - bad app address input + { + desc: "invalid - invalid appAddress", + + appAddress: "invalidAddress", // providing a deliberately invalid address + serviceId: "svc0", + blockHeight: 0, + + expectedErr: sessiontypes.ErrSessionInvalidAppAddress, + }, + { + desc: "invalid - missing appAddress", + // appAddress: intentionally omitted + serviceId: "svc0", + blockHeight: 0, + + expectedErr: sessiontypes.ErrSessionInvalidAppAddress, + }, + + // Invalid requests - bad serviceID input + { + desc: "invalid - invalid service ID", + appAddress: appSvc0.Address, // dynamically getting address from applications + serviceId: "invalidServiceId", + blockHeight: 0, + + expectedErr: sessiontypes.ErrSessionInvalidService, + }, + { + desc: "invalid - missing service ID", + appAddress: appSvc0.Address, // dynamically getting address from applications + // serviceId: intentionally omitted + blockHeight: 0, + + expectedErr: sessiontypes.ErrSessionInvalidService, + }, + } + + // We want to use the `--output=json` flag for all tests so it's easy to unmarshal below + common := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + + // Run the tests + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + // Prepare the arguments for the CLI command + args := []string{ + tt.appAddress, + tt.serviceId, + fmt.Sprintf("%d", tt.blockHeight), + } + args = append(args, common...) + + // Execute the command + getSessionOut, err := clitestutil.ExecTestCLICmd(ctx, session.CmdGetSession(), args) + if tt.expectedErr != nil { + require.Error(t, err) + require.ErrorIs(t, err, tt.expectedErr) + require.Contains(t, err.Error(), tt.expectedErr.Error()) + return + } + require.NoError(t, err) + + var getSessionRes sessiontypes.QueryGetSessionResponse + err = net.Config.Codec.UnmarshalJSON(getSessionOut.Bytes(), &getSessionRes) + require.NoError(t, err) + require.NotNil(t, getSessionRes) + + session := getSessionRes.Session + require.NotNil(t, session) + + // Verify some data about the session + require.Equal(t, tt.appAddress, session.Application.Address) + require.Equal(t, tt.serviceId, session.Header.Service.Id) + require.Len(t, session.Suppliers, tt.expectedNumSuppliers) + }) + } +} diff --git a/x/session/module/query_params.go b/x/session/module/query_params.go new file mode 100644 index 000000000..38db81a74 --- /dev/null +++ b/x/session/module/query_params.go @@ -0,0 +1,36 @@ +package session + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/pokt-network/poktroll/x/session/types" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/session/module/tx.go b/x/session/module/tx.go new file mode 100644 index 000000000..2b4351a99 --- /dev/null +++ b/x/session/module/tx.go @@ -0,0 +1,31 @@ +package session + +import ( + "fmt" + "time" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + + "github.com/pokt-network/poktroll/x/session/types" +) + +var ( + DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/session/types/errors.go b/x/session/types/errors.go index a5e632f95..bd9b368f5 100644 --- a/x/session/types/errors.go +++ b/x/session/types/errors.go @@ -8,6 +8,14 @@ import ( // x/session 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") + ErrSample = sdkerrors.Register(ModuleName, 1101, "sample error") + ErrSessionHydration = sdkerrors.Register(ModuleName, 1102, "error during session hydration") + ErrSessionAppNotFound = sdkerrors.Register(ModuleName, 1103, "application for session not found not found ") + ErrSessionAppNotStakedForService = sdkerrors.Register(ModuleName, 1104, "application in session not staked for requested service") + ErrSessionSuppliersNotFound = sdkerrors.Register(ModuleName, 1105, "no suppliers not found for session") + ErrSessionInvalidAppAddress = sdkerrors.Register(ModuleName, 1106, "invalid application address for session") + ErrSessionInvalidService = sdkerrors.Register(ModuleName, 1107, "invalid service in session") + ErrSessionInvalidBlockHeight = sdkerrors.Register(ModuleName, 1108, "invalid block height for session") + ErrSessionInvalidSessionId = sdkerrors.Register(ModuleName, 1109, "invalid sessionId") ) diff --git a/x/session/types/expected_keepers.go b/x/session/types/expected_keepers.go index b803d09ec..77d30d6dc 100644 --- a/x/session/types/expected_keepers.go +++ b/x/session/types/expected_keepers.go @@ -1,18 +1,15 @@ package types +//go:generate mockgen -destination ../../../testutil/session/mocks/expected_keepers_mock.go -package mocks . AccountKeeper,BankKeeper,ApplicationKeeper,SupplierKeeper + import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" -) -type ApplicationKeeper interface { - // TODO Add methods imported from application should be defined here -} - -type SupplierKeeper interface { - // TODO Add methods imported from supplier should be defined here -} + apptypes "github.com/pokt-network/poktroll/x/application/types" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" +) // AccountKeeper defines the expected interface for the Account module. type AccountKeeper interface { @@ -31,3 +28,11 @@ type ParamSubspace interface { Get(context.Context, []byte, interface{}) Set(context.Context, []byte, interface{}) } + +type ApplicationKeeper interface { + GetApplication(ctx context.Context, address string) (app apptypes.Application, found bool) +} + +type SupplierKeeper interface { + GetAllSupplier(ctx context.Context) (suppliers []sharedtypes.Supplier) +} diff --git a/x/session/types/query_get_session_request.go b/x/session/types/query_get_session_request.go new file mode 100644 index 000000000..3c7b754d3 --- /dev/null +++ b/x/session/types/query_get_session_request.go @@ -0,0 +1,39 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + sharedhelpers "github.com/pokt-network/poktroll/x/shared/helpers" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" +) + +// NOTE: Please note that `QueryGetSessionRequest` is not a `sdk.Msg`, and is therefore not a message/request +// that will be signable or invoke a state transition. However, following a similar `ValidateBasic` pattern +// allows us to localize & reuse validation logic. +func NewQueryGetSessionRequest(appAddress, serviceId string, blockHeight int64) *QueryGetSessionRequest { + return &QueryGetSessionRequest{ + ApplicationAddress: appAddress, + Service: &sharedtypes.Service{ + Id: serviceId, + }, + BlockHeight: blockHeight, + } +} + +func (query *QueryGetSessionRequest) ValidateBasic() error { + // Validate the application address + if _, err := sdk.AccAddressFromBech32(query.ApplicationAddress); err != nil { + return ErrSessionInvalidAppAddress.Wrapf("invalid app address for session being retrieved %s; (%v)", query.ApplicationAddress, err) + } + + // Validate the Service ID + if !sharedhelpers.IsValidService(query.Service) { + return ErrSessionInvalidService.Wrapf("invalid service for session being retrieved %s;", query.Service) + } + + // Validate the height for which a session is being retrieved + if query.BlockHeight < 0 { // Note that `0` defaults to the latest height rather than genesis + return ErrSessionInvalidBlockHeight.Wrapf("invalid block height for session being retrieved %d;", query.BlockHeight) + } + return nil +} diff --git a/x/session/types/session_header.go b/x/session/types/session_header.go new file mode 100644 index 000000000..adcb3b040 --- /dev/null +++ b/x/session/types/session_header.go @@ -0,0 +1,34 @@ +package types + +import ( + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// TODO_TECHDEBT: Make sure this is used everywhere we validate components +// of the session header. +func (sh *SessionHeader) ValidateBasic() error { + // Validate the application address + if _, err := sdk.AccAddressFromBech32(sh.ApplicationAddress); err != nil { + return sdkerrors.Wrapf(ErrSessionInvalidAppAddress, "invalid application address: %s; (%v)", sh.ApplicationAddress, err) + } + + // Validate the session ID + // TODO_TECHDEBT: Introduce a `SessionId#ValidateBasic` method. + if sh.SessionId == "" { + return sdkerrors.Wrapf(ErrSessionInvalidSessionId, "invalid session ID: %s", sh.SessionId) + } + + // Validate the service + // TODO_TECHDEBT: Introduce a `Service#ValidateBasic` method. + if sh.Service == nil { + return sdkerrors.Wrapf(ErrSessionInvalidService, "invalid service: %s", sh.Service) + } + + // Check if session end height is greater than session start height + if sh.SessionEndBlockHeight <= sh.SessionStartBlockHeight { + return sdkerrors.Wrapf(ErrSessionInvalidBlockHeight, "session end block height cannot be less than or equal to session start block height") + } + + return nil +} diff --git a/x/session/types/session_header_test.go b/x/session/types/session_header_test.go new file mode 100644 index 000000000..e0e60ce93 --- /dev/null +++ b/x/session/types/session_header_test.go @@ -0,0 +1,86 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/pokt-network/poktroll/testutil/sample" + "github.com/pokt-network/poktroll/x/session/types" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" +) + +func TestSessionHeader_ValidateBasic(t *testing.T) { + tests := []struct { + desc string + sh types.SessionHeader + err error + }{ + { + desc: "invalid - invalid application address", + sh: types.SessionHeader{ + ApplicationAddress: "invalid_address", + SessionId: "valid_session_id", + Service: &sharedtypes.Service{}, + SessionStartBlockHeight: 100, + SessionEndBlockHeight: 101, + }, + err: types.ErrSessionInvalidAppAddress, + }, + { + desc: "invalid - empty session id", + sh: types.SessionHeader{ + ApplicationAddress: sample.AccAddress(), + SessionId: "", + Service: &sharedtypes.Service{}, + SessionStartBlockHeight: 100, + SessionEndBlockHeight: 101, + }, + err: types.ErrSessionInvalidSessionId, + }, + { + desc: "invalid - nil service", + sh: types.SessionHeader{ + ApplicationAddress: sample.AccAddress(), + SessionId: "valid_session_id", + Service: nil, + SessionStartBlockHeight: 100, + SessionEndBlockHeight: 101, + }, + err: types.ErrSessionInvalidService, + }, + { + desc: "invalid - start block height greater than end block height", + sh: types.SessionHeader{ + ApplicationAddress: sample.AccAddress(), + SessionId: "valid_session_id", + Service: &sharedtypes.Service{}, + SessionStartBlockHeight: 100, + SessionEndBlockHeight: 99, + }, + err: types.ErrSessionInvalidBlockHeight, + }, + { + desc: "valid", + sh: types.SessionHeader{ + ApplicationAddress: sample.AccAddress(), + SessionId: "valid_session_id", + Service: &sharedtypes.Service{}, + SessionStartBlockHeight: 100, + SessionEndBlockHeight: 101, + }, + err: nil, + }, + } + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + err := tt.sh.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + } else { + require.NoError(t, err) + } + }) + } +} From a398c8af3605997e23ac070091ed2a56e23b3f18 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Wed, 14 Feb 2024 19:52:43 +0100 Subject: [PATCH 05/24] reconcile: fix bad pulsar and missing app imports --- api/poktroll/application/genesis.pulsar.go | 11 +++++------ api/poktroll/application/query.pulsar.go | 11 +++++------ api/poktroll/session/query.pulsar.go | 5 ++--- api/poktroll/session/session.pulsar.go | 2 +- app/app.go | 1 + app/app_config.go | 1 + proto/buf.gen.pulsar.yaml | 2 +- 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/api/poktroll/application/genesis.pulsar.go b/api/poktroll/application/genesis.pulsar.go index 02d9e6c3d..a115c2817 100644 --- a/api/poktroll/application/genesis.pulsar.go +++ b/api/poktroll/application/genesis.pulsar.go @@ -607,7 +607,7 @@ type GenesisState struct { unknownFields protoimpl.UnknownFields // params defines all the parameters of the module. - Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` + Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` ApplicationList []*Application `protobuf:"bytes,2,rep,name=application_list,json=applicationList,proto3" json:"application_list,omitempty"` } @@ -698,13 +698,13 @@ func file_poktroll_application_genesis_proto_rawDescGZIP() []byte { var file_poktroll_application_genesis_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_poktroll_application_genesis_proto_goTypes = []interface{}{ - (*GenesisState)(nil), // 0: poktroll.application.GenesisState - (*Params)(nil), // 1: poktroll.application.Params - (*Application)(nil), // 2: poktroll.application.Application + (*GenesisState)(nil), // 0: poktroll.application.GenesisState + (*Params)(nil), // 1: poktroll.application.Params + (*Application)(nil), // 2: poktroll.Application } var file_poktroll_application_genesis_proto_depIdxs = []int32{ 1, // 0: poktroll.application.GenesisState.params:type_name -> poktroll.application.Params - 2, // 1: poktroll.application.GenesisState.application_list:type_name -> poktroll.application.Application + 2, // 1: poktroll.application.GenesisState.application_list:type_name -> poktroll.Application 2, // [2:2] is the sub-list for method output_type 2, // [2:2] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name @@ -718,7 +718,6 @@ func file_poktroll_application_genesis_proto_init() { return } file_poktroll_application_params_proto_init() - file_poktroll_application_application_proto_init() if !protoimpl.UnsafeEnabled { file_poktroll_application_genesis_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GenesisState); i { diff --git a/api/poktroll/application/query.pulsar.go b/api/poktroll/application/query.pulsar.go index 257a22acd..b9d852377 100644 --- a/api/poktroll/application/query.pulsar.go +++ b/api/poktroll/application/query.pulsar.go @@ -2858,8 +2858,8 @@ type QueryAllApplicationResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Application []*Application `protobuf:"bytes,1,rep,name=application,proto3" json:"application,omitempty"` - Pagination *v1beta1.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` + Application []*Application `protobuf:"bytes,1,rep,name=application,proto3" json:"application,omitempty"` + Pagination *v1beta1.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } func (x *QueryAllApplicationResponse) Reset() { @@ -3019,15 +3019,15 @@ var file_poktroll_application_query_proto_goTypes = []interface{}{ (*QueryAllApplicationRequest)(nil), // 4: poktroll.application.QueryAllApplicationRequest (*QueryAllApplicationResponse)(nil), // 5: poktroll.application.QueryAllApplicationResponse (*Params)(nil), // 6: poktroll.application.Params - (*Application)(nil), // 7: poktroll.application.Application + (*Application)(nil), // 7: poktroll.Application (*v1beta1.PageRequest)(nil), // 8: cosmos.base.query.v1beta1.PageRequest (*v1beta1.PageResponse)(nil), // 9: cosmos.base.query.v1beta1.PageResponse } var file_poktroll_application_query_proto_depIdxs = []int32{ 6, // 0: poktroll.application.QueryParamsResponse.params:type_name -> poktroll.application.Params - 7, // 1: poktroll.application.QueryGetApplicationResponse.application:type_name -> poktroll.application.Application + 7, // 1: poktroll.application.QueryGetApplicationResponse.application:type_name -> poktroll.Application 8, // 2: poktroll.application.QueryAllApplicationRequest.pagination:type_name -> cosmos.base.query.v1beta1.PageRequest - 7, // 3: poktroll.application.QueryAllApplicationResponse.application:type_name -> poktroll.application.Application + 7, // 3: poktroll.application.QueryAllApplicationResponse.application:type_name -> poktroll.Application 9, // 4: poktroll.application.QueryAllApplicationResponse.pagination:type_name -> cosmos.base.query.v1beta1.PageResponse 0, // 5: poktroll.application.Query.Params:input_type -> poktroll.application.QueryParamsRequest 2, // 6: poktroll.application.Query.Application:input_type -> poktroll.application.QueryGetApplicationRequest @@ -3048,7 +3048,6 @@ func file_poktroll_application_query_proto_init() { return } file_poktroll_application_params_proto_init() - file_poktroll_application_application_proto_init() if !protoimpl.UnsafeEnabled { file_poktroll_application_query_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*QueryParamsRequest); i { diff --git a/api/poktroll/session/query.pulsar.go b/api/poktroll/session/query.pulsar.go index 77939bd87..62328021e 100644 --- a/api/poktroll/session/query.pulsar.go +++ b/api/poktroll/session/query.pulsar.go @@ -2050,12 +2050,12 @@ var file_poktroll_session_query_proto_goTypes = []interface{}{ (*QueryGetSessionResponse)(nil), // 3: poktroll.session.QueryGetSessionResponse (*Params)(nil), // 4: poktroll.session.Params (*shared.Service)(nil), // 5: poktroll.shared.Service - (*Session)(nil), // 6: poktroll.session.Session + (*Session)(nil), // 6: poktroll.Session } var file_poktroll_session_query_proto_depIdxs = []int32{ 4, // 0: poktroll.session.QueryParamsResponse.params:type_name -> poktroll.session.Params 5, // 1: poktroll.session.QueryGetSessionRequest.service:type_name -> poktroll.shared.Service - 6, // 2: poktroll.session.QueryGetSessionResponse.session:type_name -> poktroll.session.Session + 6, // 2: poktroll.session.QueryGetSessionResponse.session:type_name -> poktroll.Session 0, // 3: poktroll.session.Query.Params:input_type -> poktroll.session.QueryParamsRequest 2, // 4: poktroll.session.Query.GetSession:input_type -> poktroll.session.QueryGetSessionRequest 1, // 5: poktroll.session.Query.Params:output_type -> poktroll.session.QueryParamsResponse @@ -2073,7 +2073,6 @@ func file_poktroll_session_query_proto_init() { return } file_poktroll_session_params_proto_init() - file_poktroll_session_session_proto_init() if !protoimpl.UnsafeEnabled { file_poktroll_session_query_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*QueryParamsRequest); i { diff --git a/api/poktroll/session/session.pulsar.go b/api/poktroll/session/session.pulsar.go index 16d444256..c0a424878 100644 --- a/api/poktroll/session/session.pulsar.go +++ b/api/poktroll/session/session.pulsar.go @@ -2,10 +2,10 @@ package session import ( - application "cosmossdk.io/api/poktroll/application" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" + application "github.com/pokt-network/poktroll/api/poktroll/application" shared "github.com/pokt-network/poktroll/api/poktroll/shared" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" diff --git a/app/app.go b/app/app.go index 92d96e0e4..2e07766c4 100644 --- a/app/app.go +++ b/app/app.go @@ -56,6 +56,7 @@ import ( applicationmodulekeeper "github.com/pokt-network/poktroll/x/application/keeper" gatewaymodulekeeper "github.com/pokt-network/poktroll/x/gateway/keeper" servicemodulekeeper "github.com/pokt-network/poktroll/x/service/keeper" + sessionmodulekeeper "github.com/pokt-network/poktroll/x/session/keeper" suppliermodulekeeper "github.com/pokt-network/poktroll/x/supplier/keeper" // this line is used by starport scaffolding # stargate/app/moduleImport diff --git a/app/app_config.go b/app/app_config.go index a6be51b90..4bfe04789 100644 --- a/app/app_config.go +++ b/app/app_config.go @@ -72,6 +72,7 @@ import ( applicationmodulev1 "github.com/pokt-network/poktroll/api/poktroll/application/module" gatewaymodulev1 "github.com/pokt-network/poktroll/api/poktroll/gateway/module" servicemodulev1 "github.com/pokt-network/poktroll/api/poktroll/service/module" + sessionmodulev1 "github.com/pokt-network/poktroll/api/poktroll/session/module" suppliermodulev1 "github.com/pokt-network/poktroll/api/poktroll/supplier/module" _ "github.com/pokt-network/poktroll/x/application/module" // import for side-effects applicationmoduletypes "github.com/pokt-network/poktroll/x/application/types" diff --git a/proto/buf.gen.pulsar.yaml b/proto/buf.gen.pulsar.yaml index 1fcae879e..3f46e1774 100644 --- a/proto/buf.gen.pulsar.yaml +++ b/proto/buf.gen.pulsar.yaml @@ -16,7 +16,7 @@ managed: plugins: - name: go-pulsar out: ./api - opt: paths=source_relative,Mpoktroll/shared/service.proto=github.com/pokt-network/poktroll/api/poktroll/shared,Mpoktroll/shared/supplier.proto=github.com/pokt-network/poktroll/api/poktroll/shared + opt: paths=source_relative,Mpoktroll/shared/service.proto=github.com/pokt-network/poktroll/api/poktroll/shared,Mpoktroll/shared/supplier.proto=github.com/pokt-network/poktroll/api/poktroll/shared,Mpoktroll/application/application.proto=github.com/pokt-network/poktroll/api/poktroll/application,Mpoktroll/supplier/supplier.proto=github.com/pokt-network/poktroll/api/poktroll/supplier,Mpoktroll/session/session.proto=github.com/pokt-network/poktroll/api/poktroll/session - name: go-grpc out: ./api opt: paths=source_relative From 6e8c677d545ea2ea8ecc795247add9be5ced06ac Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Wed, 14 Feb 2024 20:02:50 +0100 Subject: [PATCH 06/24] reconcile: remove duplicate supplier test util --- testutil/network/network.go | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/testutil/network/network.go b/testutil/network/network.go index d2dbc068b..8c7520893 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -112,7 +112,7 @@ func DefaultSupplierModuleGenesisState(t *testing.T, n int) *suppliertypes.Genes t.Helper() state := suppliertypes.DefaultGenesis() for i := 0; i < n; i++ { - stake := sdk.NewCoin("upokt", sdkmath.NewInt(int64(i))) + stake := sdk.NewCoin("upokt", math.NewInt(int64(i))) supplier := sharedtypes.Supplier{ Address: sample.AccAddress(), Stake: &stake, @@ -228,32 +228,3 @@ func freePorts(n int) ([]string, error) { } return ports, nil } - -// DefaultSupplierModuleGenesisState generates a GenesisState object with a given number of suppliers. -// It returns the populated GenesisState object. -func DefaultSupplierModuleGenesisState(t *testing.T, n int) *suppliertypes.GenesisState { - t.Helper() - state := suppliertypes.DefaultGenesis() - for i := 0; i < n; i++ { - stake := sdk.NewCoin("upokt", math.NewInt(int64(i))) - supplier := sharedtypes.Supplier{ - Address: sample.AccAddress(), - Stake: &stake, - Services: []*sharedtypes.SupplierServiceConfig{ - { - Service: &sharedtypes.Service{Id: fmt.Sprintf("svc%d", i)}, - Endpoints: []*sharedtypes.SupplierEndpoint{ - { - Url: fmt.Sprintf("http://localhost:%d", i), - RpcType: sharedtypes.RPCType_JSON_RPC, - }, - }, - }, - }, - } - // TODO_CONSIDERATION: Evaluate whether we need `nullify.Fill` or if we should enforce `(gogoproto.nullable) = false` everywhere - // nullify.Fill(&supplier) - state.SupplierList = append(state.SupplierList, supplier) - } - return state -} From fa985bc01dafc8ab2855510950cbca4649cded62 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Wed, 14 Feb 2024 21:04:22 +0100 Subject: [PATCH 07/24] reconcile: adapt store usage --- testutil/keeper/session.go | 15 ++++----------- x/session/keeper/block_hash.go | 16 ++++++++-------- x/session/keeper/keeper.go | 12 ++++++++++-- x/session/types/key_session.go | 24 ++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 21 deletions(-) create mode 100644 x/session/types/key_session.go diff --git a/testutil/keeper/session.go b/testutil/keeper/session.go index fc137eb9e..b192715ca 100644 --- a/testutil/keeper/session.go +++ b/testutil/keeper/session.go @@ -9,6 +9,7 @@ import ( sdkmath "cosmossdk.io/math" "cosmossdk.io/store" "cosmossdk.io/store/metrics" + "cosmossdk.io/store/prefix" storetypes "cosmossdk.io/store/types" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" dbm "github.com/cosmos/cosmos-db" @@ -133,15 +134,6 @@ func SessionKeeper(t testing.TB) (keeper.Keeper, sdk.Context) { mockAppKeeper := defaultAppKeeperMock(t) mockSupplierKeeper := defaultSupplierKeeperMock(t) - // TODO_CONSOLIDATE: This was passed-in instead of authority.String() in the - // original code. It's not clear what the difference is. - // paramsSubspace := typesparams.NewSubspace(cdc, - // types.Amino, - // storeKey, - // memStoreKey, - // "SessionParams", - // ) - k := keeper.NewKeeper( cdc, runtime.NewKVStoreService(storeKey), @@ -177,11 +169,12 @@ func SessionKeeper(t testing.TB) (keeper.Keeper, sdk.Context) { 8: "251665c7cf286a30fbd98acd983c63e9a34efc16496511373405e24eb02a8fb9", } - store := ctx.KVStore(storeKey) + storeAdapter := runtime.KVStoreAdapter(runtime.NewKVStoreService(storeKey).OpenKVStore(ctx)) + store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.SessionKeyPrefix)) for height, hash := range blockHash { hashBz, err := hex.DecodeString(hash) require.NoError(t, err) - store.Set(keeper.GetBlockHashKey(height), hashBz) + store.Set(types.SessionKey(height), hashBz) } return k, ctx diff --git a/x/session/keeper/block_hash.go b/x/session/keeper/block_hash.go index f875b9fb3..8b19201b2 100644 --- a/x/session/keeper/block_hash.go +++ b/x/session/keeper/block_hash.go @@ -2,18 +2,18 @@ package keeper import ( "context" - "fmt" + "cosmossdk.io/store/prefix" "github.com/cosmos/cosmos-sdk/runtime" + + "github.com/pokt-network/poktroll/x/session/types" ) // GetBlockHash returns the hash of the block at the given height. func (k Keeper) GetBlockHash(ctx context.Context, height int64) []byte { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - return store.Get(GetBlockHashKey(height)) -} - -// GetBlockHashKey returns the key used to store the block hash for a given height. -func GetBlockHashKey(height int64) []byte { - return []byte(fmt.Sprintf("Blockhash:%d", height)) + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.SessionKeyPrefix)) + return store.Get(types.SessionKey( + height, + )) } diff --git a/x/session/keeper/keeper.go b/x/session/keeper/keeper.go index 66025c7ed..e822d664b 100644 --- a/x/session/keeper/keeper.go +++ b/x/session/keeper/keeper.go @@ -6,6 +6,7 @@ import ( "cosmossdk.io/core/store" "cosmossdk.io/log" + "cosmossdk.io/store/prefix" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" @@ -85,6 +86,13 @@ func (k Keeper) BeginBlocker(goCtx context.Context) { hash = []byte{} } - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - store.Set(GetBlockHashKey(height), hash) + // TODO_HACK: This is a temporary hack to to prevent panic because of the + // ctx.BlockHeader().LastBlockId.Hash being nil. + hash = []byte{} + + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(goCtx)) + store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.SessionKeyPrefix)) + store.Set(types.SessionKey( + height, + ), hash) } diff --git a/x/session/types/key_session.go b/x/session/types/key_session.go new file mode 100644 index 000000000..9abb1c680 --- /dev/null +++ b/x/session/types/key_session.go @@ -0,0 +1,24 @@ +package types + +import ( + "encoding/binary" + fmt "fmt" +) + +var _ binary.ByteOrder + +const ( + // ServiceKeyPrefix is the prefix to retrieve all Service + SessionKeyPrefix = "Session/value/" +) + +// ServiceKey returns the store key to retrieve a Service from the index fields +func SessionKey(blockHeight int64) []byte { + var key []byte + + serviceIDBz := []byte(fmt.Sprintf("%d", blockHeight)) + key = append(key, serviceIDBz...) + key = append(key, []byte("/")...) + + return key +} From 7b60cd0b5a2eaba19933e26a3ce4986603a708a6 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Wed, 14 Feb 2024 21:35:37 +0100 Subject: [PATCH 08/24] reconcile: make query_get_session test pass --- go.mod | 1 + go.sum | 5 +++++ x/session/module/query_get_session_test.go | 10 ++++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index e75c2562d..445d98a58 100644 --- a/go.mod +++ b/go.mod @@ -33,6 +33,7 @@ require ( github.com/cosmos/gogoproto v1.4.11 github.com/cosmos/ibc-go/modules/capability v1.0.0 github.com/cosmos/ibc-go/v8 v8.0.0 + github.com/gogo/status v1.1.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.3 github.com/gorilla/mux v1.8.1 diff --git a/go.sum b/go.sum index bda8d18ab..6f32c213d 100644 --- a/go.sum +++ b/go.sum @@ -753,6 +753,7 @@ github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14j github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gofrs/uuid/v5 v5.0.0 h1:p544++a97kEL+svbcFbCQVM9KFu0Yo25UoISXGNNH9M= github.com/gofrs/uuid/v5 v5.0.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8= +github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= @@ -764,6 +765,8 @@ github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/gogo/status v1.1.0 h1:+eIkrewn5q6b30y+g/BJINVVdi2xH7je5MPJ3ZPK3JA= +github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM= github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188/go.mod h1:vXjM/+wXQnTPR4KqTKDgJukSZ6amVRtWMPEjE6sQoK8= @@ -2734,6 +2737,7 @@ google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCID google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= @@ -2862,6 +2866,7 @@ google.golang.org/genproto/googleapis/api v0.0.0-20240116215550-a9fa1716bcac/go. google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac h1:nUQEQmH/csSvFECKYRv6HWEyypysidKl2I6Qpsglq/0= google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:daQN87bsDqDoe316QbbvX60nMoJQa4r6Ds0ZuoAe5yA= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= +google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= diff --git a/x/session/module/query_get_session_test.go b/x/session/module/query_get_session_test.go index 48853e249..4a482afda 100644 --- a/x/session/module/query_get_session_test.go +++ b/x/session/module/query_get_session_test.go @@ -3,10 +3,12 @@ package session_test import ( "fmt" "testing" + "time" sdkerrors "cosmossdk.io/errors" tmcli "github.com/cometbft/cometbft/libs/cli" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/gogo/status" "github.com/stretchr/testify/require" session "github.com/pokt-network/poktroll/x/session/module" @@ -16,7 +18,7 @@ import ( func TestCLI_GetSession(t *testing.T) { // Prepare the network net, suppliers, applications := networkWithApplicationsAndSupplier(t, 2) - _, err := net.WaitForHeight(10) // Wait for a sufficiently high block height to ensure the staking transactions have been processed + _, err := net.WaitForHeightWithTimeout(10, 30*time.Second) // Wait for a sufficiently high block height to ensure the staking transactions have been processed require.NoError(t, err) val := net.Validators[0] ctx := val.ClientCtx @@ -172,9 +174,9 @@ func TestCLI_GetSession(t *testing.T) { // Execute the command getSessionOut, err := clitestutil.ExecTestCLICmd(ctx, session.CmdGetSession(), args) if tt.expectedErr != nil { - require.Error(t, err) - require.ErrorIs(t, err, tt.expectedErr) - require.Contains(t, err.Error(), tt.expectedErr.Error()) + stat, ok := status.FromError(tt.expectedErr) + require.True(t, ok) + require.Contains(t, stat.Message(), tt.expectedErr.Error()) return } require.NoError(t, err) From 6e9d25d8669ec8ba25e4e8264fa2359a6a8db534 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Wed, 14 Feb 2024 22:42:08 +0100 Subject: [PATCH 09/24] reconcile: Get block hash --- x/session/keeper/keeper.go | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/x/session/keeper/keeper.go b/x/session/keeper/keeper.go index e822d664b..377a31428 100644 --- a/x/session/keeper/keeper.go +++ b/x/session/keeper/keeper.go @@ -75,24 +75,12 @@ func (k Keeper) Logger() log.Logger { func (k Keeper) BeginBlocker(goCtx context.Context) { ctx := sdk.UnwrapSDKContext(goCtx) - // ctx.BlockHeader().LastBlockId.Hash is the hash of the last block committed - hash := ctx.BlockHeader().LastBlockId.Hash + // ctx.BlockHeader().AppHash is the hash of the last block committed + hash := ctx.BlockHeader().AppHash // ctx.BlockHeader().Height is the height of the last committed block. height := ctx.BlockHeader().Height - // Block height 1 is the first committed block which uses `genesis.json` as its parent. - // See the explanation here for more details: https://github.com/pokt-network/poktroll/issues/377#issuecomment-1936607294 - // Fallback to an empty byte slice during the genesis block. - if height == 1 { - hash = []byte{} - } - - // TODO_HACK: This is a temporary hack to to prevent panic because of the - // ctx.BlockHeader().LastBlockId.Hash being nil. - hash = []byte{} storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(goCtx)) store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.SessionKeyPrefix)) - store.Set(types.SessionKey( - height, - ), hash) + store.Set(types.SessionKey(height), hash) } From 6a53d0952e1ef6337889c5a09aa780df467b5441 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Wed, 14 Feb 2024 23:12:06 +0100 Subject: [PATCH 10/24] reconcile: Add proto fix self import --- Makefile | 13 + api/poktroll/application/genesis.pulsar.go | 59 ++-- api/poktroll/application/query.pulsar.go | 267 +++++++++--------- api/poktroll/session/query.pulsar.go | 312 ++++++++++----------- 4 files changed, 332 insertions(+), 319 deletions(-) diff --git a/Makefile b/Makefile index 61d5f9d41..414e11362 100644 --- a/Makefile +++ b/Makefile @@ -141,6 +141,19 @@ warn_destructive: ## Print WARNING to the user proto_regen: ## Delete existing protobuf artifacts and regenerate them find . \( -name "*.pb.go" -o -name "*.pb.gw.go" \) | xargs --no-run-if-empty rm ignite generate proto-go --yes + $(MAKE) proto_fix_self_import + +.PHONY: proto_fix_self_import +proto_fix_self_import: ## TODO: explain + @for dir in $(wildcard ./api/poktroll/*/); do \ + module=$$(basename $$dir); \ + echo "Processing module $$module"; \ + grep -lRP '\s+'$$module' "github.com/pokt-network/poktroll/api/poktroll/'$$module'"' ./api/poktroll/$$module | while read -r file; do \ + echo "Modifying file: $$file"; \ + sed -i -E 's,^[[:space:]]+'$$module'[[:space:]]+"github.com/pokt-network/poktroll/api/poktroll/'$$module'",,' "$$file"; \ + sed -i 's,'$$module'\.,,g' "$$file"; \ + done; \ + done .PHONY: proto_clean_pulsar proto_clean_pulsar: ## TODO: explain... diff --git a/api/poktroll/application/genesis.pulsar.go b/api/poktroll/application/genesis.pulsar.go index a115c2817..4f327299b 100644 --- a/api/poktroll/application/genesis.pulsar.go +++ b/api/poktroll/application/genesis.pulsar.go @@ -6,6 +6,7 @@ import ( 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" @@ -170,15 +171,15 @@ func (x *fastReflection_GenesisState) Range(f func(protoreflect.FieldDescriptor, // a repeated field is populated if it is non-empty. func (x *fastReflection_GenesisState) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.application.GenesisState.params": + case "poktroll.GenesisState.params": return x.Params != nil - case "poktroll.application.GenesisState.application_list": + case "poktroll.GenesisState.application_list": return len(x.ApplicationList) != 0 default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.GenesisState")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.GenesisState")) } - panic(fmt.Errorf("message poktroll.application.GenesisState does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.GenesisState does not contain field %s", fd.FullName())) } } @@ -190,15 +191,15 @@ func (x *fastReflection_GenesisState) Has(fd protoreflect.FieldDescriptor) bool // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_GenesisState) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.application.GenesisState.params": + case "poktroll.GenesisState.params": x.Params = nil - case "poktroll.application.GenesisState.application_list": + case "poktroll.GenesisState.application_list": x.ApplicationList = nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.GenesisState")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.GenesisState")) } - panic(fmt.Errorf("message poktroll.application.GenesisState does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.GenesisState does not contain field %s", fd.FullName())) } } @@ -210,10 +211,10 @@ func (x *fastReflection_GenesisState) Clear(fd protoreflect.FieldDescriptor) { // 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.application.GenesisState.params": + case "poktroll.GenesisState.params": value := x.Params return protoreflect.ValueOfMessage(value.ProtoReflect()) - case "poktroll.application.GenesisState.application_list": + case "poktroll.GenesisState.application_list": if len(x.ApplicationList) == 0 { return protoreflect.ValueOfList(&_GenesisState_2_list{}) } @@ -221,9 +222,9 @@ func (x *fastReflection_GenesisState) Get(descriptor protoreflect.FieldDescripto return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.GenesisState")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.GenesisState")) } - panic(fmt.Errorf("message poktroll.application.GenesisState does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message poktroll.GenesisState does not contain field %s", descriptor.FullName())) } } @@ -239,17 +240,17 @@ func (x *fastReflection_GenesisState) Get(descriptor protoreflect.FieldDescripto // 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.application.GenesisState.params": + case "poktroll.GenesisState.params": x.Params = value.Message().Interface().(*Params) - case "poktroll.application.GenesisState.application_list": + case "poktroll.GenesisState.application_list": lv := value.List() clv := lv.(*_GenesisState_2_list) x.ApplicationList = *clv.list default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.GenesisState")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.GenesisState")) } - panic(fmt.Errorf("message poktroll.application.GenesisState does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.GenesisState does not contain field %s", fd.FullName())) } } @@ -265,12 +266,12 @@ func (x *fastReflection_GenesisState) Set(fd protoreflect.FieldDescriptor, value // 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.application.GenesisState.params": + case "poktroll.GenesisState.params": if x.Params == nil { x.Params = new(Params) } return protoreflect.ValueOfMessage(x.Params.ProtoReflect()) - case "poktroll.application.GenesisState.application_list": + case "poktroll.GenesisState.application_list": if x.ApplicationList == nil { x.ApplicationList = []*Application{} } @@ -278,9 +279,9 @@ func (x *fastReflection_GenesisState) Mutable(fd protoreflect.FieldDescriptor) p return protoreflect.ValueOfList(value) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.GenesisState")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.GenesisState")) } - panic(fmt.Errorf("message poktroll.application.GenesisState does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.GenesisState does not contain field %s", fd.FullName())) } } @@ -289,17 +290,17 @@ func (x *fastReflection_GenesisState) Mutable(fd protoreflect.FieldDescriptor) p // 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.application.GenesisState.params": + case "poktroll.GenesisState.params": m := new(Params) return protoreflect.ValueOfMessage(m.ProtoReflect()) - case "poktroll.application.GenesisState.application_list": + case "poktroll.GenesisState.application_list": list := []*Application{} return protoreflect.ValueOfList(&_GenesisState_2_list{list: &list}) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.GenesisState")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.GenesisState")) } - panic(fmt.Errorf("message poktroll.application.GenesisState does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.GenesisState does not contain field %s", fd.FullName())) } } @@ -309,7 +310,7 @@ func (x *fastReflection_GenesisState) NewField(fd protoreflect.FieldDescriptor) 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.application.GenesisState", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in poktroll.GenesisState", d.FullName())) } panic("unreachable") } @@ -698,13 +699,13 @@ func file_poktroll_application_genesis_proto_rawDescGZIP() []byte { var file_poktroll_application_genesis_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_poktroll_application_genesis_proto_goTypes = []interface{}{ - (*GenesisState)(nil), // 0: poktroll.application.GenesisState - (*Params)(nil), // 1: poktroll.application.Params + (*GenesisState)(nil), // 0: poktroll.GenesisState + (*Params)(nil), // 1: poktroll.Params (*Application)(nil), // 2: poktroll.Application } var file_poktroll_application_genesis_proto_depIdxs = []int32{ - 1, // 0: poktroll.application.GenesisState.params:type_name -> poktroll.application.Params - 2, // 1: poktroll.application.GenesisState.application_list:type_name -> poktroll.Application + 1, // 0: poktroll.GenesisState.params:type_name -> poktroll.Params + 2, // 1: poktroll.GenesisState.application_list:type_name -> poktroll.Application 2, // [2:2] is the sub-list for method output_type 2, // [2:2] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name diff --git a/api/poktroll/application/query.pulsar.go b/api/poktroll/application/query.pulsar.go index b9d852377..8447e3de9 100644 --- a/api/poktroll/application/query.pulsar.go +++ b/api/poktroll/application/query.pulsar.go @@ -8,6 +8,7 @@ import ( 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" @@ -108,9 +109,9 @@ func (x *fastReflection_QueryParamsRequest) Has(fd protoreflect.FieldDescriptor) switch fd.FullName() { default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryParamsRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsRequest")) } - panic(fmt.Errorf("message poktroll.application.QueryParamsRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsRequest does not contain field %s", fd.FullName())) } } @@ -124,9 +125,9 @@ func (x *fastReflection_QueryParamsRequest) Clear(fd protoreflect.FieldDescripto switch fd.FullName() { default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryParamsRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsRequest")) } - panic(fmt.Errorf("message poktroll.application.QueryParamsRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsRequest does not contain field %s", fd.FullName())) } } @@ -140,9 +141,9 @@ func (x *fastReflection_QueryParamsRequest) Get(descriptor protoreflect.FieldDes switch descriptor.FullName() { default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryParamsRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsRequest")) } - panic(fmt.Errorf("message poktroll.application.QueryParamsRequest does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsRequest does not contain field %s", descriptor.FullName())) } } @@ -160,9 +161,9 @@ func (x *fastReflection_QueryParamsRequest) Set(fd protoreflect.FieldDescriptor, switch fd.FullName() { default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryParamsRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsRequest")) } - panic(fmt.Errorf("message poktroll.application.QueryParamsRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsRequest does not contain field %s", fd.FullName())) } } @@ -180,9 +181,9 @@ func (x *fastReflection_QueryParamsRequest) Mutable(fd protoreflect.FieldDescrip switch fd.FullName() { default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryParamsRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsRequest")) } - panic(fmt.Errorf("message poktroll.application.QueryParamsRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsRequest does not contain field %s", fd.FullName())) } } @@ -193,9 +194,9 @@ func (x *fastReflection_QueryParamsRequest) NewField(fd protoreflect.FieldDescri switch fd.FullName() { default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryParamsRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsRequest")) } - panic(fmt.Errorf("message poktroll.application.QueryParamsRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsRequest does not contain field %s", fd.FullName())) } } @@ -205,7 +206,7 @@ func (x *fastReflection_QueryParamsRequest) NewField(fd protoreflect.FieldDescri 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.application.QueryParamsRequest", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in poktroll.QueryParamsRequest", d.FullName())) } panic("unreachable") } @@ -470,13 +471,13 @@ func (x *fastReflection_QueryParamsResponse) Range(f func(protoreflect.FieldDesc // a repeated field is populated if it is non-empty. func (x *fastReflection_QueryParamsResponse) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.application.QueryParamsResponse.params": + case "poktroll.QueryParamsResponse.params": return x.Params != nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryParamsResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsResponse")) } - panic(fmt.Errorf("message poktroll.application.QueryParamsResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsResponse does not contain field %s", fd.FullName())) } } @@ -488,13 +489,13 @@ func (x *fastReflection_QueryParamsResponse) Has(fd protoreflect.FieldDescriptor // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryParamsResponse) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.application.QueryParamsResponse.params": + case "poktroll.QueryParamsResponse.params": x.Params = nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryParamsResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsResponse")) } - panic(fmt.Errorf("message poktroll.application.QueryParamsResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsResponse does not contain field %s", fd.FullName())) } } @@ -506,14 +507,14 @@ func (x *fastReflection_QueryParamsResponse) Clear(fd protoreflect.FieldDescript // 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.application.QueryParamsResponse.params": + case "poktroll.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.application.QueryParamsResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsResponse")) } - panic(fmt.Errorf("message poktroll.application.QueryParamsResponse does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsResponse does not contain field %s", descriptor.FullName())) } } @@ -529,13 +530,13 @@ func (x *fastReflection_QueryParamsResponse) Get(descriptor protoreflect.FieldDe // 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.application.QueryParamsResponse.params": + case "poktroll.QueryParamsResponse.params": x.Params = value.Message().Interface().(*Params) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryParamsResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsResponse")) } - panic(fmt.Errorf("message poktroll.application.QueryParamsResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsResponse does not contain field %s", fd.FullName())) } } @@ -551,16 +552,16 @@ func (x *fastReflection_QueryParamsResponse) Set(fd protoreflect.FieldDescriptor // 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.application.QueryParamsResponse.params": + case "poktroll.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.application.QueryParamsResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsResponse")) } - panic(fmt.Errorf("message poktroll.application.QueryParamsResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsResponse does not contain field %s", fd.FullName())) } } @@ -569,14 +570,14 @@ func (x *fastReflection_QueryParamsResponse) Mutable(fd protoreflect.FieldDescri // 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.application.QueryParamsResponse.params": + case "poktroll.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.application.QueryParamsResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsResponse")) } - panic(fmt.Errorf("message poktroll.application.QueryParamsResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsResponse does not contain field %s", fd.FullName())) } } @@ -586,7 +587,7 @@ func (x *fastReflection_QueryParamsResponse) NewField(fd protoreflect.FieldDescr 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.application.QueryParamsResponse", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in poktroll.QueryParamsResponse", d.FullName())) } panic("unreachable") } @@ -905,13 +906,13 @@ func (x *fastReflection_QueryGetApplicationRequest) Range(f func(protoreflect.Fi // a repeated field is populated if it is non-empty. func (x *fastReflection_QueryGetApplicationRequest) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.application.QueryGetApplicationRequest.address": + case "poktroll.QueryGetApplicationRequest.address": return x.Address != "" default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryGetApplicationRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetApplicationRequest")) } - panic(fmt.Errorf("message poktroll.application.QueryGetApplicationRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetApplicationRequest does not contain field %s", fd.FullName())) } } @@ -923,13 +924,13 @@ func (x *fastReflection_QueryGetApplicationRequest) Has(fd protoreflect.FieldDes // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetApplicationRequest) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.application.QueryGetApplicationRequest.address": + case "poktroll.QueryGetApplicationRequest.address": x.Address = "" default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryGetApplicationRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetApplicationRequest")) } - panic(fmt.Errorf("message poktroll.application.QueryGetApplicationRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetApplicationRequest does not contain field %s", fd.FullName())) } } @@ -941,14 +942,14 @@ func (x *fastReflection_QueryGetApplicationRequest) Clear(fd protoreflect.FieldD // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_QueryGetApplicationRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "poktroll.application.QueryGetApplicationRequest.address": + case "poktroll.QueryGetApplicationRequest.address": value := x.Address return protoreflect.ValueOfString(value) default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryGetApplicationRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetApplicationRequest")) } - panic(fmt.Errorf("message poktroll.application.QueryGetApplicationRequest does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetApplicationRequest does not contain field %s", descriptor.FullName())) } } @@ -964,13 +965,13 @@ func (x *fastReflection_QueryGetApplicationRequest) Get(descriptor protoreflect. // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetApplicationRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "poktroll.application.QueryGetApplicationRequest.address": + case "poktroll.QueryGetApplicationRequest.address": x.Address = value.Interface().(string) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryGetApplicationRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetApplicationRequest")) } - panic(fmt.Errorf("message poktroll.application.QueryGetApplicationRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetApplicationRequest does not contain field %s", fd.FullName())) } } @@ -986,13 +987,13 @@ func (x *fastReflection_QueryGetApplicationRequest) Set(fd protoreflect.FieldDes // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetApplicationRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.application.QueryGetApplicationRequest.address": - panic(fmt.Errorf("field address of message poktroll.application.QueryGetApplicationRequest is not mutable")) + case "poktroll.QueryGetApplicationRequest.address": + panic(fmt.Errorf("field address of message poktroll.QueryGetApplicationRequest is not mutable")) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryGetApplicationRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetApplicationRequest")) } - panic(fmt.Errorf("message poktroll.application.QueryGetApplicationRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetApplicationRequest does not contain field %s", fd.FullName())) } } @@ -1001,13 +1002,13 @@ func (x *fastReflection_QueryGetApplicationRequest) Mutable(fd protoreflect.Fiel // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_QueryGetApplicationRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.application.QueryGetApplicationRequest.address": + case "poktroll.QueryGetApplicationRequest.address": return protoreflect.ValueOfString("") default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryGetApplicationRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetApplicationRequest")) } - panic(fmt.Errorf("message poktroll.application.QueryGetApplicationRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetApplicationRequest does not contain field %s", fd.FullName())) } } @@ -1017,7 +1018,7 @@ func (x *fastReflection_QueryGetApplicationRequest) NewField(fd protoreflect.Fie func (x *fastReflection_QueryGetApplicationRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { switch d.FullName() { default: - panic(fmt.Errorf("%s is not a oneof field in poktroll.application.QueryGetApplicationRequest", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in poktroll.QueryGetApplicationRequest", d.FullName())) } panic("unreachable") } @@ -1325,13 +1326,13 @@ func (x *fastReflection_QueryGetApplicationResponse) Range(f func(protoreflect.F // a repeated field is populated if it is non-empty. func (x *fastReflection_QueryGetApplicationResponse) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.application.QueryGetApplicationResponse.application": + case "poktroll.QueryGetApplicationResponse.application": return x.Application != nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryGetApplicationResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetApplicationResponse")) } - panic(fmt.Errorf("message poktroll.application.QueryGetApplicationResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetApplicationResponse does not contain field %s", fd.FullName())) } } @@ -1343,13 +1344,13 @@ func (x *fastReflection_QueryGetApplicationResponse) Has(fd protoreflect.FieldDe // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetApplicationResponse) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.application.QueryGetApplicationResponse.application": + case "poktroll.QueryGetApplicationResponse.application": x.Application = nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryGetApplicationResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetApplicationResponse")) } - panic(fmt.Errorf("message poktroll.application.QueryGetApplicationResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetApplicationResponse does not contain field %s", fd.FullName())) } } @@ -1361,14 +1362,14 @@ func (x *fastReflection_QueryGetApplicationResponse) Clear(fd protoreflect.Field // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_QueryGetApplicationResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "poktroll.application.QueryGetApplicationResponse.application": + case "poktroll.QueryGetApplicationResponse.application": value := x.Application return protoreflect.ValueOfMessage(value.ProtoReflect()) default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryGetApplicationResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetApplicationResponse")) } - panic(fmt.Errorf("message poktroll.application.QueryGetApplicationResponse does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetApplicationResponse does not contain field %s", descriptor.FullName())) } } @@ -1384,13 +1385,13 @@ func (x *fastReflection_QueryGetApplicationResponse) Get(descriptor protoreflect // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetApplicationResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "poktroll.application.QueryGetApplicationResponse.application": + case "poktroll.QueryGetApplicationResponse.application": x.Application = value.Message().Interface().(*Application) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryGetApplicationResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetApplicationResponse")) } - panic(fmt.Errorf("message poktroll.application.QueryGetApplicationResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetApplicationResponse does not contain field %s", fd.FullName())) } } @@ -1406,16 +1407,16 @@ func (x *fastReflection_QueryGetApplicationResponse) Set(fd protoreflect.FieldDe // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetApplicationResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.application.QueryGetApplicationResponse.application": + case "poktroll.QueryGetApplicationResponse.application": if x.Application == nil { x.Application = new(Application) } return protoreflect.ValueOfMessage(x.Application.ProtoReflect()) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryGetApplicationResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetApplicationResponse")) } - panic(fmt.Errorf("message poktroll.application.QueryGetApplicationResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetApplicationResponse does not contain field %s", fd.FullName())) } } @@ -1424,14 +1425,14 @@ func (x *fastReflection_QueryGetApplicationResponse) Mutable(fd protoreflect.Fie // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_QueryGetApplicationResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.application.QueryGetApplicationResponse.application": + case "poktroll.QueryGetApplicationResponse.application": m := new(Application) return protoreflect.ValueOfMessage(m.ProtoReflect()) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryGetApplicationResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetApplicationResponse")) } - panic(fmt.Errorf("message poktroll.application.QueryGetApplicationResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetApplicationResponse does not contain field %s", fd.FullName())) } } @@ -1441,7 +1442,7 @@ func (x *fastReflection_QueryGetApplicationResponse) NewField(fd protoreflect.Fi func (x *fastReflection_QueryGetApplicationResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { switch d.FullName() { default: - panic(fmt.Errorf("%s is not a oneof field in poktroll.application.QueryGetApplicationResponse", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in poktroll.QueryGetApplicationResponse", d.FullName())) } panic("unreachable") } @@ -1760,13 +1761,13 @@ func (x *fastReflection_QueryAllApplicationRequest) Range(f func(protoreflect.Fi // a repeated field is populated if it is non-empty. func (x *fastReflection_QueryAllApplicationRequest) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.application.QueryAllApplicationRequest.pagination": + case "poktroll.QueryAllApplicationRequest.pagination": return x.Pagination != nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryAllApplicationRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryAllApplicationRequest")) } - panic(fmt.Errorf("message poktroll.application.QueryAllApplicationRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryAllApplicationRequest does not contain field %s", fd.FullName())) } } @@ -1778,13 +1779,13 @@ func (x *fastReflection_QueryAllApplicationRequest) Has(fd protoreflect.FieldDes // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryAllApplicationRequest) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.application.QueryAllApplicationRequest.pagination": + case "poktroll.QueryAllApplicationRequest.pagination": x.Pagination = nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryAllApplicationRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryAllApplicationRequest")) } - panic(fmt.Errorf("message poktroll.application.QueryAllApplicationRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryAllApplicationRequest does not contain field %s", fd.FullName())) } } @@ -1796,14 +1797,14 @@ func (x *fastReflection_QueryAllApplicationRequest) Clear(fd protoreflect.FieldD // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_QueryAllApplicationRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "poktroll.application.QueryAllApplicationRequest.pagination": + case "poktroll.QueryAllApplicationRequest.pagination": value := x.Pagination return protoreflect.ValueOfMessage(value.ProtoReflect()) default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryAllApplicationRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryAllApplicationRequest")) } - panic(fmt.Errorf("message poktroll.application.QueryAllApplicationRequest does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message poktroll.QueryAllApplicationRequest does not contain field %s", descriptor.FullName())) } } @@ -1819,13 +1820,13 @@ func (x *fastReflection_QueryAllApplicationRequest) Get(descriptor protoreflect. // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryAllApplicationRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "poktroll.application.QueryAllApplicationRequest.pagination": + case "poktroll.QueryAllApplicationRequest.pagination": x.Pagination = value.Message().Interface().(*v1beta1.PageRequest) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryAllApplicationRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryAllApplicationRequest")) } - panic(fmt.Errorf("message poktroll.application.QueryAllApplicationRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryAllApplicationRequest does not contain field %s", fd.FullName())) } } @@ -1841,16 +1842,16 @@ func (x *fastReflection_QueryAllApplicationRequest) Set(fd protoreflect.FieldDes // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryAllApplicationRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.application.QueryAllApplicationRequest.pagination": + case "poktroll.QueryAllApplicationRequest.pagination": if x.Pagination == nil { x.Pagination = new(v1beta1.PageRequest) } return protoreflect.ValueOfMessage(x.Pagination.ProtoReflect()) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryAllApplicationRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryAllApplicationRequest")) } - panic(fmt.Errorf("message poktroll.application.QueryAllApplicationRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryAllApplicationRequest does not contain field %s", fd.FullName())) } } @@ -1859,14 +1860,14 @@ func (x *fastReflection_QueryAllApplicationRequest) Mutable(fd protoreflect.Fiel // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_QueryAllApplicationRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.application.QueryAllApplicationRequest.pagination": + case "poktroll.QueryAllApplicationRequest.pagination": m := new(v1beta1.PageRequest) return protoreflect.ValueOfMessage(m.ProtoReflect()) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryAllApplicationRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryAllApplicationRequest")) } - panic(fmt.Errorf("message poktroll.application.QueryAllApplicationRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryAllApplicationRequest does not contain field %s", fd.FullName())) } } @@ -1876,7 +1877,7 @@ func (x *fastReflection_QueryAllApplicationRequest) NewField(fd protoreflect.Fie func (x *fastReflection_QueryAllApplicationRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { switch d.FullName() { default: - panic(fmt.Errorf("%s is not a oneof field in poktroll.application.QueryAllApplicationRequest", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in poktroll.QueryAllApplicationRequest", d.FullName())) } panic("unreachable") } @@ -2254,15 +2255,15 @@ func (x *fastReflection_QueryAllApplicationResponse) Range(f func(protoreflect.F // a repeated field is populated if it is non-empty. func (x *fastReflection_QueryAllApplicationResponse) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.application.QueryAllApplicationResponse.application": + case "poktroll.QueryAllApplicationResponse.application": return len(x.Application) != 0 - case "poktroll.application.QueryAllApplicationResponse.pagination": + case "poktroll.QueryAllApplicationResponse.pagination": return x.Pagination != nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryAllApplicationResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryAllApplicationResponse")) } - panic(fmt.Errorf("message poktroll.application.QueryAllApplicationResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryAllApplicationResponse does not contain field %s", fd.FullName())) } } @@ -2274,15 +2275,15 @@ func (x *fastReflection_QueryAllApplicationResponse) Has(fd protoreflect.FieldDe // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryAllApplicationResponse) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.application.QueryAllApplicationResponse.application": + case "poktroll.QueryAllApplicationResponse.application": x.Application = nil - case "poktroll.application.QueryAllApplicationResponse.pagination": + case "poktroll.QueryAllApplicationResponse.pagination": x.Pagination = nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryAllApplicationResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryAllApplicationResponse")) } - panic(fmt.Errorf("message poktroll.application.QueryAllApplicationResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryAllApplicationResponse does not contain field %s", fd.FullName())) } } @@ -2294,20 +2295,20 @@ func (x *fastReflection_QueryAllApplicationResponse) Clear(fd protoreflect.Field // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_QueryAllApplicationResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "poktroll.application.QueryAllApplicationResponse.application": + case "poktroll.QueryAllApplicationResponse.application": if len(x.Application) == 0 { return protoreflect.ValueOfList(&_QueryAllApplicationResponse_1_list{}) } listValue := &_QueryAllApplicationResponse_1_list{list: &x.Application} return protoreflect.ValueOfList(listValue) - case "poktroll.application.QueryAllApplicationResponse.pagination": + case "poktroll.QueryAllApplicationResponse.pagination": value := x.Pagination return protoreflect.ValueOfMessage(value.ProtoReflect()) default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryAllApplicationResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryAllApplicationResponse")) } - panic(fmt.Errorf("message poktroll.application.QueryAllApplicationResponse does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message poktroll.QueryAllApplicationResponse does not contain field %s", descriptor.FullName())) } } @@ -2323,17 +2324,17 @@ func (x *fastReflection_QueryAllApplicationResponse) Get(descriptor protoreflect // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryAllApplicationResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "poktroll.application.QueryAllApplicationResponse.application": + case "poktroll.QueryAllApplicationResponse.application": lv := value.List() clv := lv.(*_QueryAllApplicationResponse_1_list) x.Application = *clv.list - case "poktroll.application.QueryAllApplicationResponse.pagination": + case "poktroll.QueryAllApplicationResponse.pagination": x.Pagination = value.Message().Interface().(*v1beta1.PageResponse) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryAllApplicationResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryAllApplicationResponse")) } - panic(fmt.Errorf("message poktroll.application.QueryAllApplicationResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryAllApplicationResponse does not contain field %s", fd.FullName())) } } @@ -2349,22 +2350,22 @@ func (x *fastReflection_QueryAllApplicationResponse) Set(fd protoreflect.FieldDe // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryAllApplicationResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.application.QueryAllApplicationResponse.application": + case "poktroll.QueryAllApplicationResponse.application": if x.Application == nil { x.Application = []*Application{} } value := &_QueryAllApplicationResponse_1_list{list: &x.Application} return protoreflect.ValueOfList(value) - case "poktroll.application.QueryAllApplicationResponse.pagination": + case "poktroll.QueryAllApplicationResponse.pagination": if x.Pagination == nil { x.Pagination = new(v1beta1.PageResponse) } return protoreflect.ValueOfMessage(x.Pagination.ProtoReflect()) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryAllApplicationResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryAllApplicationResponse")) } - panic(fmt.Errorf("message poktroll.application.QueryAllApplicationResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryAllApplicationResponse does not contain field %s", fd.FullName())) } } @@ -2373,17 +2374,17 @@ func (x *fastReflection_QueryAllApplicationResponse) Mutable(fd protoreflect.Fie // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_QueryAllApplicationResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.application.QueryAllApplicationResponse.application": + case "poktroll.QueryAllApplicationResponse.application": list := []*Application{} return protoreflect.ValueOfList(&_QueryAllApplicationResponse_1_list{list: &list}) - case "poktroll.application.QueryAllApplicationResponse.pagination": + case "poktroll.QueryAllApplicationResponse.pagination": m := new(v1beta1.PageResponse) return protoreflect.ValueOfMessage(m.ProtoReflect()) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.application.QueryAllApplicationResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryAllApplicationResponse")) } - panic(fmt.Errorf("message poktroll.application.QueryAllApplicationResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryAllApplicationResponse does not contain field %s", fd.FullName())) } } @@ -2393,7 +2394,7 @@ func (x *fastReflection_QueryAllApplicationResponse) NewField(fd protoreflect.Fi func (x *fastReflection_QueryAllApplicationResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { switch d.FullName() { default: - panic(fmt.Errorf("%s is not a oneof field in poktroll.application.QueryAllApplicationResponse", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in poktroll.QueryAllApplicationResponse", d.FullName())) } panic("unreachable") } @@ -3012,29 +3013,29 @@ func file_poktroll_application_query_proto_rawDescGZIP() []byte { var file_poktroll_application_query_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_poktroll_application_query_proto_goTypes = []interface{}{ - (*QueryParamsRequest)(nil), // 0: poktroll.application.QueryParamsRequest - (*QueryParamsResponse)(nil), // 1: poktroll.application.QueryParamsResponse - (*QueryGetApplicationRequest)(nil), // 2: poktroll.application.QueryGetApplicationRequest - (*QueryGetApplicationResponse)(nil), // 3: poktroll.application.QueryGetApplicationResponse - (*QueryAllApplicationRequest)(nil), // 4: poktroll.application.QueryAllApplicationRequest - (*QueryAllApplicationResponse)(nil), // 5: poktroll.application.QueryAllApplicationResponse - (*Params)(nil), // 6: poktroll.application.Params + (*QueryParamsRequest)(nil), // 0: poktroll.QueryParamsRequest + (*QueryParamsResponse)(nil), // 1: poktroll.QueryParamsResponse + (*QueryGetApplicationRequest)(nil), // 2: poktroll.QueryGetApplicationRequest + (*QueryGetApplicationResponse)(nil), // 3: poktroll.QueryGetApplicationResponse + (*QueryAllApplicationRequest)(nil), // 4: poktroll.QueryAllApplicationRequest + (*QueryAllApplicationResponse)(nil), // 5: poktroll.QueryAllApplicationResponse + (*Params)(nil), // 6: poktroll.Params (*Application)(nil), // 7: poktroll.Application (*v1beta1.PageRequest)(nil), // 8: cosmos.base.query.v1beta1.PageRequest (*v1beta1.PageResponse)(nil), // 9: cosmos.base.query.v1beta1.PageResponse } var file_poktroll_application_query_proto_depIdxs = []int32{ - 6, // 0: poktroll.application.QueryParamsResponse.params:type_name -> poktroll.application.Params - 7, // 1: poktroll.application.QueryGetApplicationResponse.application:type_name -> poktroll.Application - 8, // 2: poktroll.application.QueryAllApplicationRequest.pagination:type_name -> cosmos.base.query.v1beta1.PageRequest - 7, // 3: poktroll.application.QueryAllApplicationResponse.application:type_name -> poktroll.Application - 9, // 4: poktroll.application.QueryAllApplicationResponse.pagination:type_name -> cosmos.base.query.v1beta1.PageResponse - 0, // 5: poktroll.application.Query.Params:input_type -> poktroll.application.QueryParamsRequest - 2, // 6: poktroll.application.Query.Application:input_type -> poktroll.application.QueryGetApplicationRequest - 4, // 7: poktroll.application.Query.ApplicationAll:input_type -> poktroll.application.QueryAllApplicationRequest - 1, // 8: poktroll.application.Query.Params:output_type -> poktroll.application.QueryParamsResponse - 3, // 9: poktroll.application.Query.Application:output_type -> poktroll.application.QueryGetApplicationResponse - 5, // 10: poktroll.application.Query.ApplicationAll:output_type -> poktroll.application.QueryAllApplicationResponse + 6, // 0: poktroll.QueryParamsResponse.params:type_name -> poktroll.Params + 7, // 1: poktroll.QueryGetApplicationResponse.application:type_name -> poktroll.Application + 8, // 2: poktroll.QueryAllApplicationRequest.pagination:type_name -> cosmos.base.query.v1beta1.PageRequest + 7, // 3: poktroll.QueryAllApplicationResponse.application:type_name -> poktroll.Application + 9, // 4: poktroll.QueryAllApplicationResponse.pagination:type_name -> cosmos.base.query.v1beta1.PageResponse + 0, // 5: poktroll.Query.Params:input_type -> poktroll.QueryParamsRequest + 2, // 6: poktroll.Query.Application:input_type -> poktroll.QueryGetApplicationRequest + 4, // 7: poktroll.Query.ApplicationAll:input_type -> poktroll.QueryAllApplicationRequest + 1, // 8: poktroll.Query.Params:output_type -> poktroll.QueryParamsResponse + 3, // 9: poktroll.Query.Application:output_type -> poktroll.QueryGetApplicationResponse + 5, // 10: poktroll.Query.ApplicationAll:output_type -> poktroll.QueryAllApplicationResponse 8, // [8:11] is the sub-list for method output_type 5, // [5:8] is the sub-list for method input_type 5, // [5:5] is the sub-list for extension type_name diff --git a/api/poktroll/session/query.pulsar.go b/api/poktroll/session/query.pulsar.go index 62328021e..95fe25015 100644 --- a/api/poktroll/session/query.pulsar.go +++ b/api/poktroll/session/query.pulsar.go @@ -3,11 +3,11 @@ package session import ( _ "cosmossdk.io/api/amino" - _ "cosmossdk.io/api/cosmos/base/query/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" + shared "github.com/pokt-network/poktroll/api/poktroll/shared" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -109,9 +109,9 @@ func (x *fastReflection_QueryParamsRequest) Has(fd protoreflect.FieldDescriptor) switch fd.FullName() { default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryParamsRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsRequest")) } - panic(fmt.Errorf("message poktroll.session.QueryParamsRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsRequest does not contain field %s", fd.FullName())) } } @@ -125,9 +125,9 @@ func (x *fastReflection_QueryParamsRequest) Clear(fd protoreflect.FieldDescripto switch fd.FullName() { default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryParamsRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsRequest")) } - panic(fmt.Errorf("message poktroll.session.QueryParamsRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsRequest does not contain field %s", fd.FullName())) } } @@ -141,9 +141,9 @@ func (x *fastReflection_QueryParamsRequest) Get(descriptor protoreflect.FieldDes switch descriptor.FullName() { default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryParamsRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsRequest")) } - panic(fmt.Errorf("message poktroll.session.QueryParamsRequest does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsRequest does not contain field %s", descriptor.FullName())) } } @@ -161,9 +161,9 @@ func (x *fastReflection_QueryParamsRequest) Set(fd protoreflect.FieldDescriptor, switch fd.FullName() { default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryParamsRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsRequest")) } - panic(fmt.Errorf("message poktroll.session.QueryParamsRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsRequest does not contain field %s", fd.FullName())) } } @@ -181,9 +181,9 @@ func (x *fastReflection_QueryParamsRequest) Mutable(fd protoreflect.FieldDescrip switch fd.FullName() { default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryParamsRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsRequest")) } - panic(fmt.Errorf("message poktroll.session.QueryParamsRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsRequest does not contain field %s", fd.FullName())) } } @@ -194,9 +194,9 @@ func (x *fastReflection_QueryParamsRequest) NewField(fd protoreflect.FieldDescri switch fd.FullName() { default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryParamsRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsRequest")) } - panic(fmt.Errorf("message poktroll.session.QueryParamsRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsRequest does not contain field %s", fd.FullName())) } } @@ -206,7 +206,7 @@ func (x *fastReflection_QueryParamsRequest) NewField(fd protoreflect.FieldDescri 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.session.QueryParamsRequest", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in poktroll.QueryParamsRequest", d.FullName())) } panic("unreachable") } @@ -471,13 +471,13 @@ func (x *fastReflection_QueryParamsResponse) Range(f func(protoreflect.FieldDesc // a repeated field is populated if it is non-empty. func (x *fastReflection_QueryParamsResponse) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.session.QueryParamsResponse.params": + case "poktroll.QueryParamsResponse.params": return x.Params != nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryParamsResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsResponse")) } - panic(fmt.Errorf("message poktroll.session.QueryParamsResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsResponse does not contain field %s", fd.FullName())) } } @@ -489,13 +489,13 @@ func (x *fastReflection_QueryParamsResponse) Has(fd protoreflect.FieldDescriptor // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryParamsResponse) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.session.QueryParamsResponse.params": + case "poktroll.QueryParamsResponse.params": x.Params = nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryParamsResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsResponse")) } - panic(fmt.Errorf("message poktroll.session.QueryParamsResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsResponse does not contain field %s", fd.FullName())) } } @@ -507,14 +507,14 @@ func (x *fastReflection_QueryParamsResponse) Clear(fd protoreflect.FieldDescript // 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.session.QueryParamsResponse.params": + case "poktroll.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.session.QueryParamsResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsResponse")) } - panic(fmt.Errorf("message poktroll.session.QueryParamsResponse does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsResponse does not contain field %s", descriptor.FullName())) } } @@ -530,13 +530,13 @@ func (x *fastReflection_QueryParamsResponse) Get(descriptor protoreflect.FieldDe // 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.session.QueryParamsResponse.params": + case "poktroll.QueryParamsResponse.params": x.Params = value.Message().Interface().(*Params) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryParamsResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsResponse")) } - panic(fmt.Errorf("message poktroll.session.QueryParamsResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsResponse does not contain field %s", fd.FullName())) } } @@ -552,16 +552,16 @@ func (x *fastReflection_QueryParamsResponse) Set(fd protoreflect.FieldDescriptor // 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.session.QueryParamsResponse.params": + case "poktroll.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.session.QueryParamsResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsResponse")) } - panic(fmt.Errorf("message poktroll.session.QueryParamsResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsResponse does not contain field %s", fd.FullName())) } } @@ -570,14 +570,14 @@ func (x *fastReflection_QueryParamsResponse) Mutable(fd protoreflect.FieldDescri // 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.session.QueryParamsResponse.params": + case "poktroll.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.session.QueryParamsResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryParamsResponse")) } - panic(fmt.Errorf("message poktroll.session.QueryParamsResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryParamsResponse does not contain field %s", fd.FullName())) } } @@ -587,7 +587,7 @@ func (x *fastReflection_QueryParamsResponse) NewField(fd protoreflect.FieldDescr 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.session.QueryParamsResponse", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in poktroll.QueryParamsResponse", d.FullName())) } panic("unreachable") } @@ -922,17 +922,17 @@ func (x *fastReflection_QueryGetSessionRequest) Range(f func(protoreflect.FieldD // a repeated field is populated if it is non-empty. func (x *fastReflection_QueryGetSessionRequest) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.session.QueryGetSessionRequest.application_address": + case "poktroll.QueryGetSessionRequest.application_address": return x.ApplicationAddress != "" - case "poktroll.session.QueryGetSessionRequest.service": + case "poktroll.QueryGetSessionRequest.service": return x.Service != nil - case "poktroll.session.QueryGetSessionRequest.block_height": + case "poktroll.QueryGetSessionRequest.block_height": return x.BlockHeight != int64(0) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetSessionRequest")) } - panic(fmt.Errorf("message poktroll.session.QueryGetSessionRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetSessionRequest does not contain field %s", fd.FullName())) } } @@ -944,17 +944,17 @@ func (x *fastReflection_QueryGetSessionRequest) Has(fd protoreflect.FieldDescrip // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetSessionRequest) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.session.QueryGetSessionRequest.application_address": + case "poktroll.QueryGetSessionRequest.application_address": x.ApplicationAddress = "" - case "poktroll.session.QueryGetSessionRequest.service": + case "poktroll.QueryGetSessionRequest.service": x.Service = nil - case "poktroll.session.QueryGetSessionRequest.block_height": + case "poktroll.QueryGetSessionRequest.block_height": x.BlockHeight = int64(0) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetSessionRequest")) } - panic(fmt.Errorf("message poktroll.session.QueryGetSessionRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetSessionRequest does not contain field %s", fd.FullName())) } } @@ -966,20 +966,20 @@ func (x *fastReflection_QueryGetSessionRequest) Clear(fd protoreflect.FieldDescr // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_QueryGetSessionRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "poktroll.session.QueryGetSessionRequest.application_address": + case "poktroll.QueryGetSessionRequest.application_address": value := x.ApplicationAddress return protoreflect.ValueOfString(value) - case "poktroll.session.QueryGetSessionRequest.service": + case "poktroll.QueryGetSessionRequest.service": value := x.Service return protoreflect.ValueOfMessage(value.ProtoReflect()) - case "poktroll.session.QueryGetSessionRequest.block_height": + case "poktroll.QueryGetSessionRequest.block_height": value := x.BlockHeight return protoreflect.ValueOfInt64(value) default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetSessionRequest")) } - panic(fmt.Errorf("message poktroll.session.QueryGetSessionRequest does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetSessionRequest does not contain field %s", descriptor.FullName())) } } @@ -995,17 +995,17 @@ func (x *fastReflection_QueryGetSessionRequest) Get(descriptor protoreflect.Fiel // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetSessionRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "poktroll.session.QueryGetSessionRequest.application_address": + case "poktroll.QueryGetSessionRequest.application_address": x.ApplicationAddress = value.Interface().(string) - case "poktroll.session.QueryGetSessionRequest.service": + case "poktroll.QueryGetSessionRequest.service": x.Service = value.Message().Interface().(*shared.Service) - case "poktroll.session.QueryGetSessionRequest.block_height": + case "poktroll.QueryGetSessionRequest.block_height": x.BlockHeight = value.Int() default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetSessionRequest")) } - panic(fmt.Errorf("message poktroll.session.QueryGetSessionRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetSessionRequest does not contain field %s", fd.FullName())) } } @@ -1021,20 +1021,20 @@ func (x *fastReflection_QueryGetSessionRequest) Set(fd protoreflect.FieldDescrip // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetSessionRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.session.QueryGetSessionRequest.service": + case "poktroll.QueryGetSessionRequest.service": if x.Service == nil { x.Service = new(shared.Service) } return protoreflect.ValueOfMessage(x.Service.ProtoReflect()) - case "poktroll.session.QueryGetSessionRequest.application_address": - panic(fmt.Errorf("field application_address of message poktroll.session.QueryGetSessionRequest is not mutable")) - case "poktroll.session.QueryGetSessionRequest.block_height": - panic(fmt.Errorf("field block_height of message poktroll.session.QueryGetSessionRequest is not mutable")) + case "poktroll.QueryGetSessionRequest.application_address": + panic(fmt.Errorf("field application_address of message poktroll.QueryGetSessionRequest is not mutable")) + case "poktroll.QueryGetSessionRequest.block_height": + panic(fmt.Errorf("field block_height of message poktroll.QueryGetSessionRequest is not mutable")) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetSessionRequest")) } - panic(fmt.Errorf("message poktroll.session.QueryGetSessionRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetSessionRequest does not contain field %s", fd.FullName())) } } @@ -1043,18 +1043,18 @@ func (x *fastReflection_QueryGetSessionRequest) Mutable(fd protoreflect.FieldDes // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_QueryGetSessionRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.session.QueryGetSessionRequest.application_address": + case "poktroll.QueryGetSessionRequest.application_address": return protoreflect.ValueOfString("") - case "poktroll.session.QueryGetSessionRequest.service": + case "poktroll.QueryGetSessionRequest.service": m := new(shared.Service) return protoreflect.ValueOfMessage(m.ProtoReflect()) - case "poktroll.session.QueryGetSessionRequest.block_height": + case "poktroll.QueryGetSessionRequest.block_height": return protoreflect.ValueOfInt64(int64(0)) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetSessionRequest")) } - panic(fmt.Errorf("message poktroll.session.QueryGetSessionRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetSessionRequest does not contain field %s", fd.FullName())) } } @@ -1064,7 +1064,7 @@ func (x *fastReflection_QueryGetSessionRequest) NewField(fd protoreflect.FieldDe func (x *fastReflection_QueryGetSessionRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { switch d.FullName() { default: - panic(fmt.Errorf("%s is not a oneof field in poktroll.session.QueryGetSessionRequest", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in poktroll.QueryGetSessionRequest", d.FullName())) } panic("unreachable") } @@ -1453,13 +1453,13 @@ func (x *fastReflection_QueryGetSessionResponse) Range(f func(protoreflect.Field // a repeated field is populated if it is non-empty. func (x *fastReflection_QueryGetSessionResponse) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.session.QueryGetSessionResponse.session": + case "poktroll.QueryGetSessionResponse.session": return x.Session != nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetSessionResponse")) } - panic(fmt.Errorf("message poktroll.session.QueryGetSessionResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetSessionResponse does not contain field %s", fd.FullName())) } } @@ -1471,13 +1471,13 @@ func (x *fastReflection_QueryGetSessionResponse) Has(fd protoreflect.FieldDescri // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetSessionResponse) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.session.QueryGetSessionResponse.session": + case "poktroll.QueryGetSessionResponse.session": x.Session = nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetSessionResponse")) } - panic(fmt.Errorf("message poktroll.session.QueryGetSessionResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetSessionResponse does not contain field %s", fd.FullName())) } } @@ -1489,14 +1489,14 @@ func (x *fastReflection_QueryGetSessionResponse) Clear(fd protoreflect.FieldDesc // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_QueryGetSessionResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "poktroll.session.QueryGetSessionResponse.session": + case "poktroll.QueryGetSessionResponse.session": value := x.Session return protoreflect.ValueOfMessage(value.ProtoReflect()) default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetSessionResponse")) } - panic(fmt.Errorf("message poktroll.session.QueryGetSessionResponse does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetSessionResponse does not contain field %s", descriptor.FullName())) } } @@ -1512,13 +1512,13 @@ func (x *fastReflection_QueryGetSessionResponse) Get(descriptor protoreflect.Fie // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetSessionResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "poktroll.session.QueryGetSessionResponse.session": + case "poktroll.QueryGetSessionResponse.session": x.Session = value.Message().Interface().(*Session) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetSessionResponse")) } - panic(fmt.Errorf("message poktroll.session.QueryGetSessionResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetSessionResponse does not contain field %s", fd.FullName())) } } @@ -1534,16 +1534,16 @@ func (x *fastReflection_QueryGetSessionResponse) Set(fd protoreflect.FieldDescri // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetSessionResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.session.QueryGetSessionResponse.session": + case "poktroll.QueryGetSessionResponse.session": if x.Session == nil { x.Session = new(Session) } return protoreflect.ValueOfMessage(x.Session.ProtoReflect()) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetSessionResponse")) } - panic(fmt.Errorf("message poktroll.session.QueryGetSessionResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetSessionResponse does not contain field %s", fd.FullName())) } } @@ -1552,14 +1552,14 @@ func (x *fastReflection_QueryGetSessionResponse) Mutable(fd protoreflect.FieldDe // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_QueryGetSessionResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.session.QueryGetSessionResponse.session": + case "poktroll.QueryGetSessionResponse.session": m := new(Session) return protoreflect.ValueOfMessage(m.ProtoReflect()) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.QueryGetSessionResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.QueryGetSessionResponse")) } - panic(fmt.Errorf("message poktroll.session.QueryGetSessionResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.QueryGetSessionResponse does not contain field %s", fd.FullName())) } } @@ -1569,7 +1569,7 @@ func (x *fastReflection_QueryGetSessionResponse) NewField(fd protoreflect.FieldD func (x *fastReflection_QueryGetSessionResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { switch d.FullName() { default: - panic(fmt.Errorf("%s is not a oneof field in poktroll.session.QueryGetSessionResponse", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in poktroll.QueryGetSessionResponse", d.FullName())) } panic("unreachable") } @@ -1966,68 +1966,66 @@ var file_poktroll_session_query_proto_rawDesc = []byte{ 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x1a, 0x2a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, - 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x70, 0x61, - 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 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, 0x1a, 0x1e, 0x70, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2f, - 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1d, 0x70, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2f, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x14, 0x0a, 0x12, + 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, 0x1a, 0x1e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x1a, 0x1d, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, + 0x65, 0x64, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x14, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x52, 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, + 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 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, 0x22, 0xba, 0x01, 0x0a, 0x16, 0x51, + 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x49, 0x0a, 0x13, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x12, 0x61, 0x70, + 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x12, 0x32, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, + 0x72, 0x65, 0x64, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, + 0x69, 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x4e, 0x0a, 0x17, 0x51, 0x75, 0x65, 0x72, 0x79, + 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x33, 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, + 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x32, 0xa6, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x12, 0x84, 0x01, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x24, 0x2e, 0x70, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x22, 0x52, 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x06, 0x70, 0x61, 0x72, - 0x61, 0x6d, 0x73, 0x18, 0x01, 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, 0x22, 0xba, 0x01, 0x0a, 0x16, 0x51, 0x75, 0x65, 0x72, 0x79, + 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2d, 0x82, 0xd3, 0xe4, 0x93, 0x02, + 0x27, 0x12, 0x25, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, + 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x95, 0x01, 0x0a, 0x0a, 0x47, 0x65, 0x74, + 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x28, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x49, 0x0a, 0x13, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, - 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x12, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x32, 0x0a, 0x07, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, - 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, - 0x67, 0x68, 0x74, 0x22, 0x4e, 0x0a, 0x17, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, - 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, - 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x19, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x32, 0xa6, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x84, 0x01, - 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x24, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, - 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, - 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x12, 0x25, 0x2f, - 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, - 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x70, 0x61, - 0x72, 0x61, 0x6d, 0x73, 0x12, 0x95, 0x01, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x12, 0x28, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, - 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, - 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, - 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x32, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2c, - 0x12, 0x2a, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, - 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x2f, 0x67, 0x65, 0x74, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0xa6, 0x01, 0x0a, - 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 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, + 0x74, 0x1a, 0x29, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x32, 0x82, 0xd3, + 0xe4, 0x93, 0x02, 0x2c, 0x12, 0x2a, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x67, 0x65, 0x74, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x42, 0xa6, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, + 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 ( @@ -2044,22 +2042,22 @@ func file_poktroll_session_query_proto_rawDescGZIP() []byte { var file_poktroll_session_query_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_poktroll_session_query_proto_goTypes = []interface{}{ - (*QueryParamsRequest)(nil), // 0: poktroll.session.QueryParamsRequest - (*QueryParamsResponse)(nil), // 1: poktroll.session.QueryParamsResponse - (*QueryGetSessionRequest)(nil), // 2: poktroll.session.QueryGetSessionRequest - (*QueryGetSessionResponse)(nil), // 3: poktroll.session.QueryGetSessionResponse - (*Params)(nil), // 4: poktroll.session.Params + (*QueryParamsRequest)(nil), // 0: poktroll.QueryParamsRequest + (*QueryParamsResponse)(nil), // 1: poktroll.QueryParamsResponse + (*QueryGetSessionRequest)(nil), // 2: poktroll.QueryGetSessionRequest + (*QueryGetSessionResponse)(nil), // 3: poktroll.QueryGetSessionResponse + (*Params)(nil), // 4: poktroll.Params (*shared.Service)(nil), // 5: poktroll.shared.Service (*Session)(nil), // 6: poktroll.Session } var file_poktroll_session_query_proto_depIdxs = []int32{ - 4, // 0: poktroll.session.QueryParamsResponse.params:type_name -> poktroll.session.Params - 5, // 1: poktroll.session.QueryGetSessionRequest.service:type_name -> poktroll.shared.Service - 6, // 2: poktroll.session.QueryGetSessionResponse.session:type_name -> poktroll.Session - 0, // 3: poktroll.session.Query.Params:input_type -> poktroll.session.QueryParamsRequest - 2, // 4: poktroll.session.Query.GetSession:input_type -> poktroll.session.QueryGetSessionRequest - 1, // 5: poktroll.session.Query.Params:output_type -> poktroll.session.QueryParamsResponse - 3, // 6: poktroll.session.Query.GetSession:output_type -> poktroll.session.QueryGetSessionResponse + 4, // 0: poktroll.QueryParamsResponse.params:type_name -> poktroll.Params + 5, // 1: poktroll.QueryGetSessionRequest.service:type_name -> poktroll.shared.Service + 6, // 2: poktroll.QueryGetSessionResponse.session:type_name -> poktroll.Session + 0, // 3: poktroll.Query.Params:input_type -> poktroll.QueryParamsRequest + 2, // 4: poktroll.Query.GetSession:input_type -> poktroll.QueryGetSessionRequest + 1, // 5: poktroll.Query.Params:output_type -> poktroll.QueryParamsResponse + 3, // 6: poktroll.Query.GetSession:output_type -> poktroll.QueryGetSessionResponse 5, // [5:7] is the sub-list for method output_type 3, // [3:5] is the sub-list for method input_type 3, // [3:3] is the sub-list for extension type_name From 44359b9f0dff251b817e291c7ff46504f167bb7e Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Wed, 14 Feb 2024 23:19:17 +0100 Subject: [PATCH 11/24] reconcile: fix linting --- x/session/module/genesis_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/session/module/genesis_test.go b/x/session/module/genesis_test.go index a6e2d7ded..cef69220e 100644 --- a/x/session/module/genesis_test.go +++ b/x/session/module/genesis_test.go @@ -5,7 +5,7 @@ import ( keepertest "github.com/pokt-network/poktroll/testutil/keeper" "github.com/pokt-network/poktroll/testutil/nullify" - "github.com/pokt-network/poktroll/x/session/module" + session "github.com/pokt-network/poktroll/x/session/module" "github.com/pokt-network/poktroll/x/session/types" "github.com/stretchr/testify/require" ) From 3e8f7d2a4ae672f2aa5192b04e4b015b195d47d7 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Thu, 15 Feb 2024 00:38:53 +0100 Subject: [PATCH 12/24] chore: remove diffs with main --- proto/poktroll/session/params.proto | 1 - x/session/keeper/block_hash.go | 4 +-- x/session/keeper/params_test.go | 4 +-- x/session/keeper/query_params_test.go | 4 +-- x/session/module/genesis_test.go | 46 +++++++++++++++++---------- x/session/types/errors.go | 4 +-- x/session/types/expected_keepers.go | 4 +-- x/session/types/genesis_test.go | 41 ------------------------ 8 files changed, 37 insertions(+), 71 deletions(-) delete mode 100644 x/session/types/genesis_test.go diff --git a/proto/poktroll/session/params.proto b/proto/poktroll/session/params.proto index 1a7dff149..9616a05d7 100644 --- a/proto/poktroll/session/params.proto +++ b/proto/poktroll/session/params.proto @@ -10,5 +10,4 @@ option go_package = "github.com/pokt-network/poktroll/x/session/types"; message Params { option (amino.name) = "poktroll/x/session/Params"; option (gogoproto.equal) = true; - } \ No newline at end of file diff --git a/x/session/keeper/block_hash.go b/x/session/keeper/block_hash.go index 8b19201b2..17878cc8b 100644 --- a/x/session/keeper/block_hash.go +++ b/x/session/keeper/block_hash.go @@ -13,7 +13,5 @@ import ( func (k Keeper) GetBlockHash(ctx context.Context, height int64) []byte { storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.SessionKeyPrefix)) - return store.Get(types.SessionKey( - height, - )) + return store.Get(types.SessionKey(height)) } diff --git a/x/session/keeper/params_test.go b/x/session/keeper/params_test.go index 6a6c06f17..77e756c64 100644 --- a/x/session/keeper/params_test.go +++ b/x/session/keeper/params_test.go @@ -5,12 +5,12 @@ import ( "github.com/stretchr/testify/require" - keepertest "github.com/pokt-network/poktroll/testutil/keeper" + testkeeper "github.com/pokt-network/poktroll/testutil/keeper" "github.com/pokt-network/poktroll/x/session/types" ) func TestGetParams(t *testing.T) { - k, ctx := keepertest.SessionKeeper(t) + k, ctx := testkeeper.SessionKeeper(t) params := types.DefaultParams() require.NoError(t, k.SetParams(ctx, params)) diff --git a/x/session/keeper/query_params_test.go b/x/session/keeper/query_params_test.go index 4e8acf5d7..26d2859a9 100644 --- a/x/session/keeper/query_params_test.go +++ b/x/session/keeper/query_params_test.go @@ -5,12 +5,12 @@ import ( "github.com/stretchr/testify/require" - keepertest "github.com/pokt-network/poktroll/testutil/keeper" + testkeeper "github.com/pokt-network/poktroll/testutil/keeper" "github.com/pokt-network/poktroll/x/session/types" ) func TestParamsQuery(t *testing.T) { - keeper, ctx := keepertest.SessionKeeper(t) + keeper, ctx := testkeeper.SessionKeeper(t) params := types.DefaultParams() require.NoError(t, keeper.SetParams(ctx, params)) diff --git a/x/session/module/genesis_test.go b/x/session/module/genesis_test.go index cef69220e..5cb9ce577 100644 --- a/x/session/module/genesis_test.go +++ b/x/session/module/genesis_test.go @@ -3,27 +3,39 @@ package session_test import ( "testing" - keepertest "github.com/pokt-network/poktroll/testutil/keeper" - "github.com/pokt-network/poktroll/testutil/nullify" - session "github.com/pokt-network/poktroll/x/session/module" "github.com/pokt-network/poktroll/x/session/types" "github.com/stretchr/testify/require" ) -func TestGenesis(t *testing.T) { - genesisState := types.GenesisState{ - Params: types.DefaultParams(), +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 # genesis/test/state + // 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) + } + }) } - - k, ctx := keepertest.SessionKeeper(t) - session.InitGenesis(ctx, k, genesisState) - got := session.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/session/types/errors.go b/x/session/types/errors.go index bd9b368f5..8e6993f6f 100644 --- a/x/session/types/errors.go +++ b/x/session/types/errors.go @@ -8,8 +8,8 @@ import ( // x/session 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") + ErrSessionInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") + ErrSessionSample = sdkerrors.Register(ModuleName, 1101, "sample error") ErrSessionHydration = sdkerrors.Register(ModuleName, 1102, "error during session hydration") ErrSessionAppNotFound = sdkerrors.Register(ModuleName, 1103, "application for session not found not found ") ErrSessionAppNotStakedForService = sdkerrors.Register(ModuleName, 1104, "application in session not staked for requested service") diff --git a/x/session/types/expected_keepers.go b/x/session/types/expected_keepers.go index 77d30d6dc..50c3c7cd3 100644 --- a/x/session/types/expected_keepers.go +++ b/x/session/types/expected_keepers.go @@ -13,14 +13,12 @@ import ( // 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(ctx context.Context, addr sdk.AccAddress) sdk.AccountI // only used for simulation } // 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. diff --git a/x/session/types/genesis_test.go b/x/session/types/genesis_test.go deleted file mode 100644 index 5393179e8..000000000 --- a/x/session/types/genesis_test.go +++ /dev/null @@ -1,41 +0,0 @@ -package types_test - -import ( - "testing" - - "github.com/pokt-network/poktroll/x/session/types" - "github.com/stretchr/testify/require" -) - -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) - } - }) - } -} From dbf52d936bef31a618e0b40ef517ed0a50ea0da2 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Thu, 15 Feb 2024 00:41:38 +0100 Subject: [PATCH 13/24] chore: fix import order --- x/session/module/genesis_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x/session/module/genesis_test.go b/x/session/module/genesis_test.go index 5cb9ce577..0c9b49159 100644 --- a/x/session/module/genesis_test.go +++ b/x/session/module/genesis_test.go @@ -3,8 +3,9 @@ package session_test import ( "testing" - "github.com/pokt-network/poktroll/x/session/types" "github.com/stretchr/testify/require" + + "github.com/pokt-network/poktroll/x/session/types" ) func TestGenesisState_Validate(t *testing.T) { From 7344c99843ff9379bcae44c5e45110a18bfc3929 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Thu, 15 Feb 2024 00:44:35 +0100 Subject: [PATCH 14/24] chore: fix error name --- x/session/keeper/msg_update_params.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/session/keeper/msg_update_params.go b/x/session/keeper/msg_update_params.go index 04360d582..e483b7984 100644 --- a/x/session/keeper/msg_update_params.go +++ b/x/session/keeper/msg_update_params.go @@ -11,7 +11,7 @@ import ( 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) + return nil, errorsmod.Wrapf(types.ErrSessionInvalidSigner, "invalid authority; expected %s, got %s", k.GetAuthority(), req.Authority) } ctx := sdk.UnwrapSDKContext(goCtx) From 0e14b24d0c2f2b40af7ef557feb0482d7943e600 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Thu, 15 Feb 2024 00:47:14 +0100 Subject: [PATCH 15/24] reconcile: add cmd long description --- x/session/module/autocli.go | 12 +++++++++--- x/session/module/query_get_session.go | 4 +--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/x/session/module/autocli.go b/x/session/module/autocli.go index 8b07ed261..1d777b4e1 100644 --- a/x/session/module/autocli.go +++ b/x/session/module/autocli.go @@ -18,9 +18,15 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { Short: "Shows the parameters of the module", }, { - RpcMethod: "GetSession", - Use: "get-session [application-address] [service-id] [block-height]", - Short: "Query get-session", + RpcMethod: "GetSession", + Use: "get-session [application-address] [service-id] [block-height]", + Short: "Query get-session", + Long: `Query the session data for a specific (app, service, height) tuple. + +This is a query operation that will not result in a state transition but simply gives a view into the chain state. + +Example: +$ poktrolld --home=$(POKTROLLD_HOME) q session get-session pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 svc1 42 --node $(POCKET_NODE)`, PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "applicationAddress"}, {ProtoField: "serviceId"}, {ProtoField: "blockHeight"}}, }, diff --git a/x/session/module/query_get_session.go b/x/session/module/query_get_session.go index a514b4c61..51dd47b6b 100644 --- a/x/session/module/query_get_session.go +++ b/x/session/module/query_get_session.go @@ -15,12 +15,10 @@ var _ = strconv.Itoa(0) func CmdGetSession() *cobra.Command { cmd := &cobra.Command{ - Use: "get-session [block_height]", + Use: "get-session ", Short: "Query get-session", Long: `Query the session data for a specific (app, service, height) tuple. -[block_height] is optional. If unspecified, or set to 0, it defaults to the latest height of the node being queried. - This is a query operation that will not result in a state transition but simply gives a view into the chain state. Example: From dbc5ef2ca60e979b6ec266daab67e62bfb392a48 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Thu, 15 Feb 2024 00:54:25 +0100 Subject: [PATCH 16/24] reconcile: rearrange to match main --- x/session/types/expected_keepers.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/x/session/types/expected_keepers.go b/x/session/types/expected_keepers.go index 50c3c7cd3..758c3461e 100644 --- a/x/session/types/expected_keepers.go +++ b/x/session/types/expected_keepers.go @@ -11,22 +11,15 @@ import ( sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) -// AccountKeeper defines the expected interface for the Account module. +// AccountKeeper defines the expected account keeper used for simulations (noalias) type AccountKeeper interface { GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI // only used for simulation } -// BankKeeper defines the expected interface for the Bank module. -type BankKeeper interface { - SpendableCoins(context.Context, sdk.AccAddress) sdk.Coins -} - -// ParamSubspace defines the expected Subspace interface for parameters. -type ParamSubspace interface { - Get(context.Context, []byte, interface{}) - Set(context.Context, []byte, interface{}) -} +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface{} +// ApplicationKeeper defines the expected application keeper to retrieve applications type ApplicationKeeper interface { GetApplication(ctx context.Context, address string) (app apptypes.Application, found bool) } @@ -34,3 +27,9 @@ type ApplicationKeeper interface { type SupplierKeeper interface { GetAllSupplier(ctx context.Context) (suppliers []sharedtypes.Supplier) } + +// ParamSubspace defines the expected Subspace interface for parameters. +type ParamSubspace interface { + Get(context.Context, []byte, interface{}) + Set(context.Context, []byte, interface{}) +} From b910f61ab205c3f2bc4723ae938fb29700d11daa Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Thu, 15 Feb 2024 00:57:49 +0100 Subject: [PATCH 17/24] chore: comply with linter --- x/session/types/msg_update_params.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/session/types/msg_update_params.go b/x/session/types/msg_update_params.go index e36d023de..aeed4a633 100644 --- a/x/session/types/msg_update_params.go +++ b/x/session/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 { From 24f66182de043d8c66ea894393aa4644bab32e36 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Thu, 15 Feb 2024 01:08:57 +0100 Subject: [PATCH 18/24] chore: revert BankKeeper interface --- x/session/types/expected_keepers.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/x/session/types/expected_keepers.go b/x/session/types/expected_keepers.go index 758c3461e..7d06db3bc 100644 --- a/x/session/types/expected_keepers.go +++ b/x/session/types/expected_keepers.go @@ -17,7 +17,9 @@ type AccountKeeper interface { } // BankKeeper defines the expected interface needed to retrieve account balances. -type BankKeeper interface{} +type BankKeeper interface { + SpendableCoins(context.Context, sdk.AccAddress) sdk.Coins +} // ApplicationKeeper defines the expected application keeper to retrieve applications type ApplicationKeeper interface { From 4dbc4d59b3a1fb7e78aebf3a043e73f492abbfee Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Thu, 15 Feb 2024 01:47:07 +0100 Subject: [PATCH 19/24] chore: rename block hash store key --- testutil/keeper/session.go | 4 ++-- x/session/keeper/block_hash.go | 4 ++-- x/session/keeper/keeper.go | 4 ++-- x/session/types/{key_session.go => key_block_hash.go} | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) rename x/session/types/{key_session.go => key_block_hash.go} (51%) diff --git a/testutil/keeper/session.go b/testutil/keeper/session.go index b192715ca..0687016c8 100644 --- a/testutil/keeper/session.go +++ b/testutil/keeper/session.go @@ -170,11 +170,11 @@ func SessionKeeper(t testing.TB) (keeper.Keeper, sdk.Context) { } storeAdapter := runtime.KVStoreAdapter(runtime.NewKVStoreService(storeKey).OpenKVStore(ctx)) - store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.SessionKeyPrefix)) + store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.BlockHashKeyPrefix)) for height, hash := range blockHash { hashBz, err := hex.DecodeString(hash) require.NoError(t, err) - store.Set(types.SessionKey(height), hashBz) + store.Set(types.BlockHashKey(height), hashBz) } return k, ctx diff --git a/x/session/keeper/block_hash.go b/x/session/keeper/block_hash.go index 17878cc8b..080a1fd0c 100644 --- a/x/session/keeper/block_hash.go +++ b/x/session/keeper/block_hash.go @@ -12,6 +12,6 @@ import ( // GetBlockHash returns the hash of the block at the given height. func (k Keeper) GetBlockHash(ctx context.Context, height int64) []byte { storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.SessionKeyPrefix)) - return store.Get(types.SessionKey(height)) + store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.BlockHashKeyPrefix)) + return store.Get(types.BlockHashKey(height)) } diff --git a/x/session/keeper/keeper.go b/x/session/keeper/keeper.go index 377a31428..1c321b13f 100644 --- a/x/session/keeper/keeper.go +++ b/x/session/keeper/keeper.go @@ -81,6 +81,6 @@ func (k Keeper) BeginBlocker(goCtx context.Context) { height := ctx.BlockHeader().Height storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(goCtx)) - store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.SessionKeyPrefix)) - store.Set(types.SessionKey(height), hash) + store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.BlockHashKeyPrefix)) + store.Set(types.BlockHashKey(height), hash) } diff --git a/x/session/types/key_session.go b/x/session/types/key_block_hash.go similarity index 51% rename from x/session/types/key_session.go rename to x/session/types/key_block_hash.go index 9abb1c680..56472742a 100644 --- a/x/session/types/key_session.go +++ b/x/session/types/key_block_hash.go @@ -8,12 +8,12 @@ import ( var _ binary.ByteOrder const ( - // ServiceKeyPrefix is the prefix to retrieve all Service - SessionKeyPrefix = "Session/value/" + // BlockHashKeyPrefix is the prefix to retrieve all BlockHash + BlockHashKeyPrefix = "BlockHash/value/" ) -// ServiceKey returns the store key to retrieve a Service from the index fields -func SessionKey(blockHeight int64) []byte { +// BlockHashKey returns the store key to retrieve a BlockHash from the index fields +func BlockHashKey(blockHeight int64) []byte { var key []byte serviceIDBz := []byte(fmt.Sprintf("%d", blockHeight)) From 93ae83f0f4442dde8443c23cf555623f36243e48 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Thu, 15 Feb 2024 15:57:56 +0100 Subject: [PATCH 20/24] chore: make example more readable --- x/session/module/query_get_session.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/session/module/query_get_session.go b/x/session/module/query_get_session.go index 51dd47b6b..d28d66861 100644 --- a/x/session/module/query_get_session.go +++ b/x/session/module/query_get_session.go @@ -22,7 +22,7 @@ func CmdGetSession() *cobra.Command { This is a query operation that will not result in a state transition but simply gives a view into the chain state. Example: -$ poktrolld --home=$(POKTROLLD_HOME) q session get-session pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 svc1 42 --node $(POCKET_NODE)`, +$ poktrolld q session get-session pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 svc1 42 --node $(POCKET_NODE) --home $(POKTROLLD_HOME)`, Args: cobra.RangeArgs(2, 3), RunE: func(cmd *cobra.Command, args []string) (err error) { appAddressString := args[0] From 80c996c282f3ec004f09427bc499bdc1a42ab338 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Thu, 15 Feb 2024 21:46:37 +0100 Subject: [PATCH 21/24] fix: autocli positional argument names --- x/session/module/autocli.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x/session/module/autocli.go b/x/session/module/autocli.go index 1d777b4e1..bf35f4984 100644 --- a/x/session/module/autocli.go +++ b/x/session/module/autocli.go @@ -19,15 +19,15 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "GetSession", - Use: "get-session [application-address] [service-id] [block-height]", + Use: "get-session [application-address] [service] [block-height]", Short: "Query get-session", Long: `Query the session data for a specific (app, service, height) tuple. This is a query operation that will not result in a state transition but simply gives a view into the chain state. Example: -$ poktrolld --home=$(POKTROLLD_HOME) q session get-session pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 svc1 42 --node $(POCKET_NODE)`, - PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "applicationAddress"}, {ProtoField: "serviceId"}, {ProtoField: "blockHeight"}}, +$ poktrolld q session get-session pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 svc1 42 --node $(POCKET_NODE) --home $(POKTROLLD_HOME) `, + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "application_address"}, {ProtoField: "service"}, {ProtoField: "block_height"}}, }, // this line is used by ignite scaffolding # autocli/query From d670f36d30e310e006958c30330b05f697a89148 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Fri, 16 Feb 2024 09:18:24 +0100 Subject: [PATCH 22/24] fix: CLI overrides --- x/session/module/query.go | 2 +- x/session/module/tx.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x/session/module/query.go b/x/session/module/query.go index a26d1a2e7..cd9fa7ed0 100644 --- a/x/session/module/query.go +++ b/x/session/module/query.go @@ -12,7 +12,7 @@ import ( ) // GetQueryCmd returns the cli query commands for this module -func (am AppModule) GetQueryCmd(queryRoute string) *cobra.Command { +func (am AppModule) GetQueryCmd() *cobra.Command { // Group session queries under a subcommand cmd := &cobra.Command{ Use: types.ModuleName, diff --git a/x/session/module/tx.go b/x/session/module/tx.go index 2b4351a99..638661956 100644 --- a/x/session/module/tx.go +++ b/x/session/module/tx.go @@ -16,7 +16,7 @@ var ( ) // GetTxCmd returns the transaction commands for this module -func GetTxCmd() *cobra.Command { +func (am AppModule) GetTxCmd() *cobra.Command { cmd := &cobra.Command{ Use: types.ModuleName, Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), From 51f021eeff12ac80fe3ad45780b44f08913394fa Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Sun, 18 Feb 2024 03:54:11 +0100 Subject: [PATCH 23/24] fix: use appropriate methods for block hash storage --- x/session/keeper/keeper.go | 13 +++++++------ x/session/module/module.go | 10 +++++++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/x/session/keeper/keeper.go b/x/session/keeper/keeper.go index 1c321b13f..45b6b0d20 100644 --- a/x/session/keeper/keeper.go +++ b/x/session/keeper/keeper.go @@ -69,16 +69,17 @@ func (k Keeper) Logger() log.Logger { return k.logger.With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -// BeginBlocker is called at the beginning of every block. +// StoreBlockHash is called at the end of every block. // It fetches the block hash from the committed block ans saves its hash // in the store. -func (k Keeper) BeginBlocker(goCtx context.Context) { +func (k Keeper) StoreBlockHash(goCtx context.Context) { ctx := sdk.UnwrapSDKContext(goCtx) - // ctx.BlockHeader().AppHash is the hash of the last block committed - hash := ctx.BlockHeader().AppHash - // ctx.BlockHeader().Height is the height of the last committed block. - height := ctx.BlockHeader().Height + // ctx.HeaderHash() is the hash of the block being validated. + hash := ctx.HeaderHash() + + // ctx.BlocHeight() is the height of the block being validated. + height := ctx.BlockHeight() storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(goCtx)) store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.BlockHashKeyPrefix)) diff --git a/x/session/module/module.go b/x/session/module/module.go index a7f99ea0d..319dac10b 100644 --- a/x/session/module/module.go +++ b/x/session/module/module.go @@ -145,14 +145,18 @@ 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(ctx context.Context) error { - am.keeper.BeginBlocker(ctx) +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 { +func (am AppModule) EndBlock(ctx context.Context) error { + // Store the block hash at the end of every block, so we can query the block hash + // to construct the SessionID. + // EndBlock is preferred over BeginBlock to avoid wasting resources if the block + // does not get committed. + am.keeper.StoreBlockHash(ctx) return nil } From 84d60835d2f2db31c694595a9de75ba7ae42163f Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Sun, 18 Feb 2024 03:54:11 +0100 Subject: [PATCH 24/24] chore: session module review improvements --- api/poktroll/session/query.pulsar.go | 2 +- api/poktroll/session/tx.pulsar.go | 3 +- proto/poktroll/session/genesis.proto | 10 +- proto/poktroll/session/params.proto | 4 +- proto/poktroll/session/query.proto | 9 +- proto/poktroll/session/session.proto | 1 + proto/poktroll/session/tx.proto | 17 +-- testutil/keeper/session.go | 15 +-- x/session/keeper/msg_server.go | 4 +- x/session/keeper/msg_server_test.go | 4 + x/session/keeper/msg_update_params.go | 8 +- x/session/keeper/msg_update_params_test.go | 42 ++++--- x/session/keeper/params.go | 10 +- x/session/keeper/query.go | 4 +- x/session/keeper/query_get_session.go | 5 +- x/session/keeper/query_get_session_test.go | 75 ++++++------ x/session/keeper/query_params.go | 7 +- x/session/keeper/session_hydrator.go | 85 ++++++++------ x/session/keeper/session_hydrator_test.go | 111 +++++++++--------- x/session/module/autocli.go | 47 ++++---- x/session/module/genesis.go | 10 +- x/session/module/genesis_test.go | 14 +-- x/session/module/helpers_test.go | 12 +- x/session/module/module.go | 5 +- x/session/module/query_get_session_test.go | 28 ++--- x/session/module/tx.go | 6 +- x/session/types/errors.go | 21 ++-- x/session/types/expected_keepers.go | 12 +- x/session/types/genesis.go | 5 - x/session/types/key_block_hash.go | 4 +- x/session/types/keys.go | 8 +- ...ate_params.go => message_update_params.go} | 0 x/session/types/params.go | 4 +- x/session/types/session_header.go | 13 +- x/session/types/session_header_test.go | 36 +++--- x/session/types/types.go | 2 + 36 files changed, 309 insertions(+), 334 deletions(-) rename x/session/types/{msg_update_params.go => message_update_params.go} (100%) diff --git a/api/poktroll/session/query.pulsar.go b/api/poktroll/session/query.pulsar.go index 95fe25015..dc8b2cf41 100644 --- a/api/poktroll/session/query.pulsar.go +++ b/api/poktroll/session/query.pulsar.go @@ -1874,7 +1874,7 @@ type QueryGetSessionRequest struct { unknownFields protoimpl.UnknownFields ApplicationAddress string `protobuf:"bytes,1,opt,name=application_address,json=applicationAddress,proto3" json:"application_address,omitempty"` // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic encoding - Service *shared.Service `protobuf:"bytes,2,opt,name=service,proto3" json:"service,omitempty"` // The service id to query the session for + Service *shared.Service `protobuf:"bytes,2,opt,name=service,proto3" json:"service,omitempty"` // The service to query the session for BlockHeight int64 `protobuf:"varint,3,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` // The block height to query the session for } diff --git a/api/poktroll/session/tx.pulsar.go b/api/poktroll/session/tx.pulsar.go index 20ba9d62e..deb862e76 100644 --- a/api/poktroll/session/tx.pulsar.go +++ b/api/poktroll/session/tx.pulsar.go @@ -892,8 +892,7 @@ 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. - // + // params defines the x/session parameters to update. // NOTE: All parameters must be supplied. Params *Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params,omitempty"` } diff --git a/proto/poktroll/session/genesis.proto b/proto/poktroll/session/genesis.proto index bd2f42a8e..263c0d0ef 100644 --- a/proto/poktroll/session/genesis.proto +++ b/proto/poktroll/session/genesis.proto @@ -1,17 +1,15 @@ syntax = "proto3"; package poktroll.session; +option go_package = "github.com/pokt-network/poktroll/x/session/types"; + import "amino/amino.proto"; import "gogoproto/gogo.proto"; -import "poktroll/session/params.proto"; -option go_package = "github.com/pokt-network/poktroll/x/session/types"; +import "poktroll/session/params.proto"; // GenesisState defines the session module's genesis state. message GenesisState { // params defines all the parameters of the module. - Params params = 1 [ - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true - ]; + Params params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } diff --git a/proto/poktroll/session/params.proto b/proto/poktroll/session/params.proto index 9616a05d7..cbe3559dc 100644 --- a/proto/poktroll/session/params.proto +++ b/proto/poktroll/session/params.proto @@ -1,11 +1,11 @@ syntax = "proto3"; package poktroll.session; +option go_package = "github.com/pokt-network/poktroll/x/session/types"; + import "amino/amino.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/pokt-network/poktroll/x/session/types"; - // Params defines the parameters for the module. message Params { option (amino.name) = "poktroll/x/session/Params"; diff --git a/proto/poktroll/session/query.proto b/proto/poktroll/session/query.proto index 89fbb144e..f695a5fc6 100644 --- a/proto/poktroll/session/query.proto +++ b/proto/poktroll/session/query.proto @@ -1,18 +1,17 @@ syntax = "proto3"; package poktroll.session; +option go_package = "github.com/pokt-network/poktroll/x/session/types"; + import "amino/amino.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos_proto/cosmos.proto"; - import "poktroll/session/params.proto"; import "poktroll/session/session.proto"; import "poktroll/shared/service.proto"; -option go_package = "github.com/pokt-network/poktroll/x/session/types"; - // Query defines the gRPC querier service. service Query { @@ -21,7 +20,7 @@ service Query { option (google.api.http).get = "/pokt-network/poktroll/session/params"; } - // Queries a list of GetSession items. + // Queries the session given app_address, service and block_height. rpc GetSession (QueryGetSessionRequest) returns (QueryGetSessionResponse) { option (google.api.http).get = "/pokt-network/poktroll/session/get_session"; } @@ -38,7 +37,7 @@ message QueryParamsResponse { message QueryGetSessionRequest { string application_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic encoding - poktroll.shared.Service service = 2; // The service id to query the session for + poktroll.shared.Service service = 2; // The service to query the session for int64 block_height = 3; // The block height to query the session for } diff --git a/proto/poktroll/session/session.proto b/proto/poktroll/session/session.proto index 2c03af313..071fbb6e2 100644 --- a/proto/poktroll/session/session.proto +++ b/proto/poktroll/session/session.proto @@ -4,6 +4,7 @@ package poktroll.session; option go_package = "github.com/pokt-network/poktroll/x/session/types"; import "cosmos_proto/cosmos.proto"; + import "poktroll/shared/service.proto"; import "poktroll/application/application.proto"; import "poktroll/shared/supplier.proto"; diff --git a/proto/poktroll/session/tx.proto b/proto/poktroll/session/tx.proto index 37e78c39a..747ed8888 100644 --- a/proto/poktroll/session/tx.proto +++ b/proto/poktroll/session/tx.proto @@ -1,13 +1,14 @@ syntax = "proto3"; package poktroll.session; +option go_package = "github.com/pokt-network/poktroll/x/session/types"; + import "amino/amino.proto"; import "cosmos/msg/v1/msg.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; -import "poktroll/session/params.proto"; -option go_package = "github.com/pokt-network/poktroll/x/session/types"; +import "poktroll/session/params.proto"; // Msg defines the Msg service. service Msg { @@ -26,13 +27,13 @@ message 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. - // + // TODO_IMPROVE(#322): The requirement to provide all params is adopted from the + // latest Cosmos SDK version. We should look into either improving this ourselves + // or seeing if it is on their roadmap. + + // 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.nullable) = false, (amino.dont_omitempty) = true]; } // MsgUpdateParamsResponse defines the response structure for executing a diff --git a/testutil/keeper/session.go b/testutil/keeper/session.go index 0687016c8..35845cad5 100644 --- a/testutil/keeper/session.go +++ b/testutil/keeper/session.go @@ -6,7 +6,7 @@ import ( "testing" "cosmossdk.io/log" - sdkmath "cosmossdk.io/math" + "cosmossdk.io/math" "cosmossdk.io/store" "cosmossdk.io/store/metrics" "cosmossdk.io/store/prefix" @@ -42,7 +42,7 @@ var ( TestApp1Address = "pokt1mdccn4u38eyjdxkk4h0jaddw4n3c72u82m5m9e" // Generated via sample.AccAddress() TestApp1 = apptypes.Application{ Address: TestApp1Address, - Stake: &sdk.Coin{Denom: "upokt", Amount: sdkmath.NewInt(100)}, + Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ { Service: &sharedtypes.Service{Id: TestServiceId1}, @@ -59,7 +59,7 @@ var ( TestApp2Address = "pokt133amv5suh75zwkxxcq896azvmmwszg99grvk9f" // Generated via sample.AccAddress() TestApp2 = apptypes.Application{ Address: TestApp1Address, - Stake: &sdk.Coin{Denom: "upokt", Amount: sdkmath.NewInt(100)}, + Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ { Service: &sharedtypes.Service{Id: TestServiceId2}, @@ -77,7 +77,7 @@ var ( TestSupplierAddress = sample.AccAddress() TestSupplier = sharedtypes.Supplier{ Address: TestSupplierAddress, - Stake: &sdk.Coin{Denom: "upokt", Amount: sdkmath.NewInt(100)}, + Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.SupplierServiceConfig{ { Service: &sharedtypes.Service{Id: TestServiceId1}, @@ -113,7 +113,8 @@ var ( } ) -func SessionKeeper(t testing.TB) (keeper.Keeper, sdk.Context) { +func SessionKeeper(t testing.TB) (keeper.Keeper, context.Context) { + t.Helper() storeKey := storetypes.NewKVStoreKey(types.StoreKey) db := dbm.NewMemDB() @@ -154,7 +155,7 @@ func SessionKeeper(t testing.TB) (keeper.Keeper, sdk.Context) { ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger()) // Initialize params - k.SetParams(ctx, types.DefaultParams()) + require.NoError(t, k.SetParams(ctx, types.DefaultParams())) // In prod, the hashes of all block heights are stored in the hash store while // the block hashes below are hardcoded to match the hardcoded session IDs used @@ -209,7 +210,7 @@ func defaultSupplierKeeperMock(t testing.TB) types.SupplierKeeper { allSuppliers := []sharedtypes.Supplier{TestSupplier} mockSupplierKeeper := mocks.NewMockSupplierKeeper(ctrl) - mockSupplierKeeper.EXPECT().GetAllSupplier(gomock.Any()).AnyTimes().Return(allSuppliers) + mockSupplierKeeper.EXPECT().GetAllSuppliers(gomock.Any()).AnyTimes().Return(allSuppliers) return mockSupplierKeeper } diff --git a/x/session/keeper/msg_server.go b/x/session/keeper/msg_server.go index 6dbe55462..65ddfeec7 100644 --- a/x/session/keeper/msg_server.go +++ b/x/session/keeper/msg_server.go @@ -1,8 +1,6 @@ package keeper -import ( - "github.com/pokt-network/poktroll/x/session/types" -) +import "github.com/pokt-network/poktroll/x/session/types" type msgServer struct { Keeper diff --git a/x/session/keeper/msg_server_test.go b/x/session/keeper/msg_server_test.go index d3c3bd5bd..a47fa7cf4 100644 --- a/x/session/keeper/msg_server_test.go +++ b/x/session/keeper/msg_server_test.go @@ -12,11 +12,15 @@ import ( ) func setupMsgServer(t testing.TB) (keeper.Keeper, types.MsgServer, context.Context) { + t.Helper() + k, ctx := keepertest.SessionKeeper(t) return k, keeper.NewMsgServerImpl(k), ctx } func TestMsgServer(t *testing.T) { + t.Helper() + k, ms, ctx := setupMsgServer(t) require.NotNil(t, ms) require.NotNil(t, ctx) diff --git a/x/session/keeper/msg_update_params.go b/x/session/keeper/msg_update_params.go index e483b7984..2e1050043 100644 --- a/x/session/keeper/msg_update_params.go +++ b/x/session/keeper/msg_update_params.go @@ -3,18 +3,14 @@ package keeper import ( "context" - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/pokt-network/poktroll/x/session/types" ) -func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { +func (k msgServer) UpdateParams(ctx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { if k.GetAuthority() != req.Authority { - return nil, errorsmod.Wrapf(types.ErrSessionInvalidSigner, "invalid authority; expected %s, got %s", k.GetAuthority(), req.Authority) + return nil, types.ErrSessionInvalidSigner.Wrapf("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 } diff --git a/x/session/keeper/msg_update_params_test.go b/x/session/keeper/msg_update_params_test.go index d645dac66..43fe64482 100644 --- a/x/session/keeper/msg_update_params_test.go +++ b/x/session/keeper/msg_update_params_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "github.com/pokt-network/poktroll/x/session/types" @@ -13,49 +12,48 @@ 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 + tests := []struct { + desc string + params *types.MsgUpdateParams + shouldError bool + expectedErrMsg string }{ { - name: "invalid authority", - input: &types.MsgUpdateParams{ + desc: "invalid authority", + params: &types.MsgUpdateParams{ Authority: "invalid", Params: params, }, - expErr: true, - expErrMsg: "invalid authority", + shouldError: true, + expectedErrMsg: "invalid authority", }, { - name: "send enabled param", - input: &types.MsgUpdateParams{ + desc: "send enabled param", + params: &types.MsgUpdateParams{ Authority: k.GetAuthority(), Params: types.Params{}, }, - expErr: false, + shouldError: false, }, { - name: "all good", - input: &types.MsgUpdateParams{ + desc: "all good", + params: &types.MsgUpdateParams{ Authority: k.GetAuthority(), Params: params, }, - expErr: false, + shouldError: false, }, } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - _, err := ms.UpdateParams(wctx, tc.input) + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + _, err := ms.UpdateParams(ctx, test.params) - if tc.expErr { + if test.shouldError { require.Error(t, err) - require.Contains(t, err.Error(), tc.expErrMsg) + require.Contains(t, err.Error(), test.expectedErrMsg) } else { require.NoError(t, err) } diff --git a/x/session/keeper/params.go b/x/session/keeper/params.go index deb132ff1..90dc1cea1 100644 --- a/x/session/keeper/params.go +++ b/x/session/keeper/params.go @@ -11,23 +11,23 @@ import ( // 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 { + paramsBz := store.Get(types.ParamsKey) + if paramsBz == nil { return params } - k.cdc.MustUnmarshal(bz, ¶ms) + k.cdc.MustUnmarshal(paramsBz, ¶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) + paramsBz, err := k.cdc.Marshal(¶ms) if err != nil { return err } - store.Set(types.ParamsKey, bz) + store.Set(types.ParamsKey, paramsBz) return nil } diff --git a/x/session/keeper/query.go b/x/session/keeper/query.go index 700ec87e8..c8c803ba1 100644 --- a/x/session/keeper/query.go +++ b/x/session/keeper/query.go @@ -1,7 +1,5 @@ package keeper -import ( - "github.com/pokt-network/poktroll/x/session/types" -) +import "github.com/pokt-network/poktroll/x/session/types" var _ types.QueryServer = Keeper{} diff --git a/x/session/keeper/query_get_session.go b/x/session/keeper/query_get_session.go index 8d365f171..a8901b6cb 100644 --- a/x/session/keeper/query_get_session.go +++ b/x/session/keeper/query_get_session.go @@ -3,7 +3,6 @@ package keeper import ( "context" - sdk "github.com/cosmos/cosmos-sdk/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -12,7 +11,7 @@ import ( // GetSession should be deterministic and always return the same session for // the same block height. -func (k Keeper) GetSession(goCtx context.Context, req *types.QueryGetSessionRequest) (*types.QueryGetSessionResponse, error) { +func (k Keeper) GetSession(ctx context.Context, req *types.QueryGetSessionRequest) (*types.QueryGetSessionResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } @@ -21,8 +20,6 @@ func (k Keeper) GetSession(goCtx context.Context, req *types.QueryGetSessionRequ return nil, status.Error(codes.InvalidArgument, err.Error()) } - ctx := sdk.UnwrapSDKContext(goCtx) - // Note that `GetSession` is called via the `Query` service rather than the `Msg` server. // The former is stateful but does not lead to state transitions, while the latter one // does. The request height depends on how much the node has synched and only acts as a read, diff --git a/x/session/keeper/query_get_session_test.go b/x/session/keeper/query_get_session_test.go index 597095833..2ffab5cad 100644 --- a/x/session/keeper/query_get_session_test.go +++ b/x/session/keeper/query_get_session_test.go @@ -3,6 +3,7 @@ package keeper_test import ( "testing" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "github.com/pokt-network/poktroll/cmd/poktrolld/cmd" @@ -22,12 +23,12 @@ func init() { func TestSession_GetSession_Success(t *testing.T) { keeper, ctx := keepertest.SessionKeeper(t) - ctx = ctx.WithBlockHeight(100) // provide a sufficiently large block height to avoid errors + ctx = sdk.UnwrapSDKContext(ctx).WithBlockHeight(100) // provide a sufficiently large block height to avoid errors // TODO_TECHDEBT(#377): These test assume that the genesis block has a height of 0, // rewrite them in terms of height = 1 genesis. - type test struct { - name string + tests := []struct { + desc string appAddr string serviceId string @@ -36,11 +37,9 @@ func TestSession_GetSession_Success(t *testing.T) { expectedSessionId string expectedSessionNumber int64 expectedNumSuppliers int - } - - tests := []test{ + }{ { - name: "valid - app1 svc1 at height=1", + desc: "valid - app1 svc1 at height=1", appAddr: keepertest.TestApp1Address, serviceId: keepertest.TestServiceId1, @@ -53,12 +52,12 @@ func TestSession_GetSession_Success(t *testing.T) { }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { req := &types.QueryGetSessionRequest{ - ApplicationAddress: tt.appAddr, + ApplicationAddress: test.appAddr, Service: &sharedtypes.Service{ - Id: tt.serviceId, + Id: test.serviceId, }, BlockHeight: 1, } @@ -67,99 +66,97 @@ func TestSession_GetSession_Success(t *testing.T) { require.NoError(t, err) require.NotNil(t, response) - require.Equal(t, tt.expectedSessionId, response.Session.SessionId) - require.Equal(t, tt.expectedSessionNumber, response.Session.SessionNumber) - require.Len(t, response.Session.Suppliers, tt.expectedNumSuppliers) + require.Equal(t, test.expectedSessionId, response.Session.SessionId) + require.Equal(t, test.expectedSessionNumber, response.Session.SessionNumber) + require.Len(t, response.Session.Suppliers, test.expectedNumSuppliers) }) } } func TestSession_GetSession_Failure(t *testing.T) { keeper, ctx := keepertest.SessionKeeper(t) - ctx = ctx.WithBlockHeight(100) // provide a sufficiently large block height to avoid errors + ctx = sdk.UnwrapSDKContext(ctx).WithBlockHeight(100) // provide a sufficiently large block height to avoid errors - type test struct { - name string + tests := []struct { + desc string appAddr string serviceId string blockHeight int64 - expectedErrContains string - } - - tests := []test{ + expectedErrMsg string + }{ { - name: "application address does not reflected a staked application", + desc: "application address does not reflected a staked application", appAddr: sample.AccAddress(), // a random (valid) app address that's not staked serviceId: keepertest.TestServiceId1, blockHeight: 1, - expectedErrContains: types.ErrSessionAppNotFound.Error(), + expectedErrMsg: types.ErrSessionAppNotFound.Error(), }, { - name: "application staked for service that has no available suppliers", + desc: "application staked for service that has no available suppliers", appAddr: keepertest.TestApp1Address, serviceId: keepertest.TestServiceId11, blockHeight: 1, - expectedErrContains: types.ErrSessionSuppliersNotFound.Error(), + expectedErrMsg: types.ErrSessionSuppliersNotFound.Error(), }, { - name: "application is valid but not staked for the specified service", + desc: "application is valid but not staked for the specified service", appAddr: keepertest.TestApp1Address, serviceId: "svc9001", // App1 is not staked for service over 9000 blockHeight: 1, - expectedErrContains: types.ErrSessionAppNotStakedForService.Error(), + expectedErrMsg: types.ErrSessionAppNotStakedForService.Error(), }, { - name: "application address is invalid format", + desc: "application address is invalid format", appAddr: "invalid_app_address", serviceId: keepertest.TestServiceId1, blockHeight: 1, - expectedErrContains: types.ErrSessionInvalidAppAddress.Error(), + expectedErrMsg: types.ErrSessionInvalidAppAddress.Error(), }, { - name: "service ID is invalid", + desc: "service ID is invalid", appAddr: keepertest.TestApp1Address, serviceId: "service_id_is_too_long_to_be_valid", blockHeight: 1, - expectedErrContains: "invalid service in session", + expectedErrMsg: "invalid service in session", }, { - name: "negative block height", + desc: "negative block height", appAddr: keepertest.TestApp1Address, serviceId: keepertest.TestServiceId1, blockHeight: -1, - expectedErrContains: "invalid block height for session being retrieved", + expectedErrMsg: "invalid block height for session being retrieved", }, } expectedRes := (*types.QueryGetSessionResponse)(nil) - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { req := &types.QueryGetSessionRequest{ - ApplicationAddress: tt.appAddr, + ApplicationAddress: test.appAddr, Service: &sharedtypes.Service{ - Id: tt.serviceId, + Id: test.serviceId, }, - BlockHeight: tt.blockHeight, + BlockHeight: test.blockHeight, } res, err := keeper.GetSession(ctx, req) require.Error(t, err) - require.Contains(t, err.Error(), tt.expectedErrContains) + require.Contains(t, err.Error(), test.expectedErrMsg) require.Equal(t, expectedRes, res) }) } diff --git a/x/session/keeper/query_params.go b/x/session/keeper/query_params.go index 75734ad7a..89f4256f4 100644 --- a/x/session/keeper/query_params.go +++ b/x/session/keeper/query_params.go @@ -3,18 +3,19 @@ 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/session/types" ) -func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { +func (k Keeper) Params( + ctx 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/session/keeper/session_hydrator.go b/x/session/keeper/session_hydrator.go index 6a36309c7..6b3621000 100644 --- a/x/session/keeper/session_hydrator.go +++ b/x/session/keeper/session_hydrator.go @@ -1,6 +1,7 @@ package keeper import ( + "context" "crypto" "encoding/binary" "encoding/hex" @@ -8,9 +9,9 @@ import ( "math/rand" sdkerrors "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" _ "golang.org/x/crypto/sha3" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/pokt-network/poktroll/x/session/types" sharedhelpers "github.com/pokt-network/poktroll/x/shared/helpers" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" @@ -44,7 +45,7 @@ type sessionHydrator struct { blockHeight int64 // A redundant helper that maintains a hex decoded copy of `session.Id` used for session hydration - sessionIdBz []byte + sessionIDBz []byte } func NewSessionHydrator( @@ -60,32 +61,32 @@ func NewSessionHydrator( sessionHeader: sessionHeader, session: &types.Session{}, blockHeight: blockHeight, - sessionIdBz: make([]byte, 0), + sessionIDBz: make([]byte, 0), } } // GetSession implements of the exposed `UtilityModule.GetSession` function -// TECHDEBT(#519): Add custom error types depending on the type of issue that occurred and assert on them in the unit tests. -func (k Keeper) HydrateSession(ctx sdk.Context, sh *sessionHydrator) (*types.Session, error) { +// TECHDEBT(#519,#348): Add custom error types depending on the type of issue that occurred and assert on them in the unit tests. +func (k Keeper) HydrateSession(ctx context.Context, sh *sessionHydrator) (*types.Session, error) { logger := k.Logger().With("method", "hydrateSession") if err := k.hydrateSessionMetadata(ctx, sh); err != nil { - return nil, sdkerrors.Wrapf(types.ErrSessionHydration, "failed to hydrate the session metadata: %v", err) + return nil, types.ErrSessionHydration.Wrapf("failed to hydrate the session metadata: %v", err) } logger.Debug("Finished hydrating session metadata") if err := k.hydrateSessionID(ctx, sh); err != nil { - return nil, sdkerrors.Wrapf(types.ErrSessionHydration, "failed to hydrate the session ID: %v", err) + return nil, types.ErrSessionHydration.Wrapf("failed to hydrate the session ID: %v", err) } logger.Info(fmt.Sprintf("Finished hydrating session ID: %s", sh.sessionHeader.SessionId)) if err := k.hydrateSessionApplication(ctx, sh); err != nil { - return nil, sdkerrors.Wrapf(types.ErrSessionHydration, "failed to hydrate application for session: %v", err) + return nil, types.ErrSessionHydration.Wrapf("failed to hydrate application for session: %v", err) } logger.Debug("Finished hydrating session application: %+v", sh.session.Application) if err := k.hydrateSessionSuppliers(ctx, sh); err != nil { - return nil, sdkerrors.Wrapf(types.ErrSessionHydration, "failed to hydrate suppliers for session: %v", err) + return nil, types.ErrSessionHydration.Wrapf("failed to hydrate suppliers for session: %v", err) } logger.Debug("Finished hydrating session suppliers: %+v") @@ -96,14 +97,15 @@ func (k Keeper) HydrateSession(ctx sdk.Context, sh *sessionHydrator) (*types.Ses } // hydrateSessionMetadata hydrates metadata related to the session such as the height at which the session started, its number, the number of blocks per session, etc.. -func (k Keeper) hydrateSessionMetadata(ctx sdk.Context, sh *sessionHydrator) error { +func (k Keeper) hydrateSessionMetadata(ctx context.Context, sh *sessionHydrator) error { // TODO_TECHDEBT: Add a test if `blockHeight` is ahead of the current chain or what this node is aware of - if sh.blockHeight > ctx.BlockHeight() { + lastCommittedBlockHeight := sdk.UnwrapSDKContext(ctx).BlockHeight() + if sh.blockHeight > lastCommittedBlockHeight { return sdkerrors.Wrapf( types.ErrSessionHydration, "block height %d is ahead of the last committed block height %d", - sh.blockHeight, ctx.BlockHeight(), + sh.blockHeight, lastCommittedBlockHeight, ) } @@ -116,17 +118,17 @@ func (k Keeper) hydrateSessionMetadata(ctx sdk.Context, sh *sessionHydrator) err } // hydrateSessionID use both session and on-chain data to determine a unique session ID -func (k Keeper) hydrateSessionID(ctx sdk.Context, sh *sessionHydrator) error { +func (k Keeper) hydrateSessionID(ctx context.Context, sh *sessionHydrator) error { prevHashBz := k.GetBlockHash(ctx, sh.sessionHeader.SessionStartBlockHeight) - // TODO_TECHDEBT: In the future, we will need to valid that the Service is a valid service depending on whether + // TODO_TECHDEBT: In the future, we will need to validate that the Service is a valid service depending on whether // or not its permissioned or permissionless if !sharedhelpers.IsValidService(sh.sessionHeader.Service) { - return sdkerrors.Wrapf(types.ErrSessionHydration, "invalid service: %v", sh.sessionHeader.Service) + return types.ErrSessionHydration.Wrapf("invalid service: %v", sh.sessionHeader.Service) } - sh.sessionHeader.SessionId, sh.sessionIdBz = GetSessionId( + sh.sessionHeader.SessionId, sh.sessionIDBz = GetSessionId( sh.sessionHeader.ApplicationAddress, sh.sessionHeader.Service.Id, prevHashBz, @@ -137,24 +139,33 @@ func (k Keeper) hydrateSessionID(ctx sdk.Context, sh *sessionHydrator) error { } // hydrateSessionApplication hydrates the full Application actor based on the address provided -func (k Keeper) hydrateSessionApplication(ctx sdk.Context, sh *sessionHydrator) error { - app, appIsFound := k.applicationKeeper.GetApplication(ctx, sh.sessionHeader.ApplicationAddress) +func (k Keeper) hydrateSessionApplication(ctx context.Context, sh *sessionHydrator) error { + foundApp, appIsFound := k.applicationKeeper.GetApplication(ctx, sh.sessionHeader.ApplicationAddress) if !appIsFound { - return sdkerrors.Wrapf(types.ErrSessionAppNotFound, "could not find app with address: %s at height %d", sh.sessionHeader.ApplicationAddress, sh.sessionHeader.SessionStartBlockHeight) + return types.ErrSessionAppNotFound.Wrapf( + "could not find app with address: %s at height %d", + sh.sessionHeader.ApplicationAddress, + sh.sessionHeader.SessionStartBlockHeight, + ) } - for _, appServiceConfig := range app.ServiceConfigs { + for _, appServiceConfig := range foundApp.ServiceConfigs { if appServiceConfig.Service.Id == sh.sessionHeader.Service.Id { - sh.session.Application = &app + sh.session.Application = &foundApp return nil } } - return sdkerrors.Wrapf(types.ErrSessionAppNotStakedForService, "application %s not staked for service %s", sh.sessionHeader.ApplicationAddress, sh.sessionHeader.Service.Id) + return types.ErrSessionAppNotStakedForService.Wrapf( + "application %s not staked for service %s", + sh.sessionHeader.ApplicationAddress, + sh.sessionHeader.Service.Id, + ) } -// hydrateSessionSuppliers finds the suppliers that are staked at the session height and populates the session with them -func (k Keeper) hydrateSessionSuppliers(ctx sdk.Context, sh *sessionHydrator) error { +// hydrateSessionSuppliers finds the suppliers that are staked at the session +// height and populates the session with them. +func (k Keeper) hydrateSessionSuppliers(ctx context.Context, sh *sessionHydrator) error { logger := k.Logger().With("method", "hydrateSessionSuppliers") // TODO_TECHDEBT(@Olshansk, @bryanchriswhite): Need to retrieve the suppliers at SessionStartBlockHeight, @@ -162,7 +173,7 @@ func (k Keeper) hydrateSessionSuppliers(ctx sdk.Context, sh *sessionHydrator) er // only retrieving the suppliers at the current block height which could create a discrepancy // if new suppliers were staked mid session. // TODO(@bryanchriswhite): Investigate if `BlockClient` + `ReplayObservable` where `N = SessionLength` could be used here.` - suppliers := k.supplierKeeper.GetAllSupplier(ctx) + suppliers := k.supplierKeeper.GetAllSuppliers(ctx) candidateSuppliers := make([]*sharedtypes.Supplier, 0) for _, s := range suppliers { @@ -181,14 +192,22 @@ func (k Keeper) hydrateSessionSuppliers(ctx sdk.Context, sh *sessionHydrator) er if len(candidateSuppliers) == 0 { logger.Error("[ERROR] no suppliers found for session") - return sdkerrors.Wrapf(types.ErrSessionSuppliersNotFound, "could not find suppliers for service %s at height %d", sh.sessionHeader.Service, sh.sessionHeader.SessionStartBlockHeight) + return types.ErrSessionSuppliersNotFound.Wrapf( + "could not find suppliers for service %s at height %d", + sh.sessionHeader.Service, + sh.sessionHeader.SessionStartBlockHeight, + ) } if len(candidateSuppliers) < NumSupplierPerSession { - logger.Info(fmt.Sprintf("[WARN] number of available suppliers (%d) is less than the number of suppliers per session (%d)", len(candidateSuppliers), NumSupplierPerSession)) + logger.Info(fmt.Sprintf( + "[WARN] number of available suppliers (%d) is less than the number of suppliers per session (%d)", + len(candidateSuppliers), + NumSupplierPerSession, + )) sh.session.Suppliers = candidateSuppliers } else { - sh.session.Suppliers = pseudoRandomSelection(candidateSuppliers, NumSupplierPerSession, sh.sessionIdBz) + sh.session.Suppliers = pseudoRandomSelection(candidateSuppliers, NumSupplierPerSession, sh.sessionIDBz) } return nil @@ -197,10 +216,10 @@ func (k Keeper) hydrateSessionSuppliers(ctx sdk.Context, sh *sessionHydrator) er // TODO_INVESTIGATE: We are using a `Go` native implementation for a pseudo-random number generator. In order // for it to be language agnostic, a general purpose algorithm MUST be used. // pseudoRandomSelection returns a random subset of the candidates. -func pseudoRandomSelection(candidates []*sharedtypes.Supplier, numTarget int, sessionIdBz []byte) []*sharedtypes.Supplier { +func pseudoRandomSelection(candidates []*sharedtypes.Supplier, numTarget int, sessionIDBz []byte) []*sharedtypes.Supplier { // Take the first 8 bytes of sessionId to use as the seed // NB: There is specific reason why `BigEndian` was chosen over `LittleEndian` in this specific context. - seed := int64(binary.BigEndian.Uint64(sha3Hash(sessionIdBz)[:8])) + seed := int64(binary.BigEndian.Uint64(sha3Hash(sessionIDBz)[:8])) // Retrieve the indices for the candidates actors := make([]*sharedtypes.Supplier, 0) @@ -236,9 +255,9 @@ func uniqueRandomIndices(seed, maxIndex, numIndices int64) map[int64]struct{} { return indicesMap } -func concatWithDelimiter(delimiter string, b ...[]byte) (result []byte) { - for _, bz := range b { - result = append(result, bz...) +func concatWithDelimiter(delimiter string, bz ...[]byte) (result []byte) { + for _, b := range bz { + result = append(result, b...) result = append(result, []byte(delimiter)...) } return result diff --git a/x/session/keeper/session_hydrator_test.go b/x/session/keeper/session_hydrator_test.go index e914ca0ea..ab9eb96ac 100644 --- a/x/session/keeper/session_hydrator_test.go +++ b/x/session/keeper/session_hydrator_test.go @@ -3,6 +3,7 @@ package keeper_test import ( "testing" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" keepertest "github.com/pokt-network/poktroll/testutil/keeper" @@ -16,7 +17,8 @@ import ( func TestSession_HydrateSession_Success_BaseCase(t *testing.T) { sessionKeeper, ctx := keepertest.SessionKeeper(t) - ctx = ctx.WithBlockHeight(100) // provide a sufficiently large block height to avoid errors + + ctx = sdk.UnwrapSDKContext(ctx).WithBlockHeight(100) // provide a sufficiently large block height to avoid errors blockHeight := int64(10) sessionHydrator := keeper.NewSessionHydrator(keepertest.TestApp1Address, keepertest.TestServiceId1, blockHeight) @@ -45,13 +47,16 @@ func TestSession_HydrateSession_Success_BaseCase(t *testing.T) { // Check the suppliers suppliers := session.Suppliers require.Len(t, suppliers, 1) + supplier := suppliers[0] require.Equal(t, keepertest.TestSupplierAddress, supplier.Address) require.Len(t, supplier.Services, 3) } func TestSession_HydrateSession_Metadata(t *testing.T) { - type test struct { + // TODO_TECHDEBT: Extend these tests once `NumBlocksPerSession` is configurable. + // Currently assumes NumBlocksPerSession=4 + tests := []struct { desc string blockHeight int64 @@ -59,12 +64,8 @@ func TestSession_HydrateSession_Metadata(t *testing.T) { expectedSessionNumber int64 expectedSessionStartBlock int64 expectedSessionEndBlock int64 - errExpected error - } - - // TODO_TECHDEBT: Extend these tests once `NumBlocksPerSession` is configurable. - // Currently assumes NumBlocksPerSession=4 - tests := []test{ + expectedErr error + }{ { desc: "blockHeight = 0", blockHeight: 0, @@ -73,7 +74,7 @@ func TestSession_HydrateSession_Metadata(t *testing.T) { expectedSessionNumber: 0, expectedSessionStartBlock: 0, expectedSessionEndBlock: 3, - errExpected: nil, + expectedErr: nil, }, { desc: "blockHeight = 1", @@ -83,7 +84,7 @@ func TestSession_HydrateSession_Metadata(t *testing.T) { expectedSessionNumber: 0, expectedSessionStartBlock: 0, expectedSessionEndBlock: 3, - errExpected: nil, + expectedErr: nil, }, { desc: "blockHeight = sessionHeight", @@ -93,7 +94,7 @@ func TestSession_HydrateSession_Metadata(t *testing.T) { expectedSessionNumber: 1, expectedSessionStartBlock: 4, expectedSessionEndBlock: 7, - errExpected: nil, + expectedErr: nil, }, { desc: "blockHeight != sessionHeight", @@ -103,42 +104,44 @@ func TestSession_HydrateSession_Metadata(t *testing.T) { expectedSessionNumber: 1, expectedSessionStartBlock: 4, expectedSessionEndBlock: 7, - errExpected: nil, + expectedErr: nil, }, { desc: "blockHeight > contextHeight", blockHeight: 9001, // block height over 9000 is too high given that the context height is 100 - errExpected: types.ErrSessionHydration, + expectedErr: types.ErrSessionHydration, }, } appAddr := keepertest.TestApp1Address serviceId := keepertest.TestServiceId1 sessionKeeper, ctx := keepertest.SessionKeeper(t) - ctx = ctx.WithBlockHeight(100) // provide a sufficiently large block height to avoid errors + ctx = sdk.UnwrapSDKContext(ctx).WithBlockHeight(100) // provide a sufficiently large block height to avoid errors - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) { - sessionHydrator := keeper.NewSessionHydrator(appAddr, serviceId, tt.blockHeight) + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + sessionHydrator := keeper.NewSessionHydrator(appAddr, serviceId, test.blockHeight) session, err := sessionKeeper.HydrateSession(ctx, sessionHydrator) - if tt.errExpected != nil { - require.ErrorIs(t, tt.errExpected, err) + if test.expectedErr != nil { + require.ErrorIs(t, test.expectedErr, err) return } require.NoError(t, err) - require.Equal(t, tt.expectedNumBlocksPerSession, session.NumBlocksPerSession) - require.Equal(t, tt.expectedSessionNumber, session.SessionNumber) - require.Equal(t, tt.expectedSessionStartBlock, session.Header.SessionStartBlockHeight) - require.Equal(t, tt.expectedSessionEndBlock, session.Header.SessionEndBlockHeight) + require.Equal(t, test.expectedNumBlocksPerSession, session.NumBlocksPerSession) + require.Equal(t, test.expectedSessionNumber, session.SessionNumber) + require.Equal(t, test.expectedSessionStartBlock, session.Header.SessionStartBlockHeight) + require.Equal(t, test.expectedSessionEndBlock, session.Header.SessionEndBlockHeight) }) } } func TestSession_HydrateSession_SessionId(t *testing.T) { - type test struct { + // TODO_TECHDEBT: Extend these tests once `NumBlocksPerSession` is configurable. + // Currently assumes NumBlocksPerSession=4 + tests := []struct { desc string blockHeight1 int64 @@ -152,11 +155,7 @@ func TestSession_HydrateSession_SessionId(t *testing.T) { expectedSessionId1 string expectedSessionId2 string - } - - // TODO_TECHDEBT: Extend these tests once `NumBlocksPerSession` is configurable. - // Currently assumes NumBlocksPerSession=4 - tests := []test{ + }{ { desc: "(app1, svc1): sessionId at first session block != sessionId at next session block", @@ -205,28 +204,28 @@ func TestSession_HydrateSession_SessionId(t *testing.T) { } sessionKeeper, ctx := keepertest.SessionKeeper(t) - ctx = ctx.WithBlockHeight(100) // provide a sufficiently large block height to avoid errors + ctx = sdk.UnwrapSDKContext(ctx).WithBlockHeight(100) // provide a sufficiently large block height to avoid errors - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) { - sessionHydrator1 := keeper.NewSessionHydrator(tt.appAddr1, tt.serviceId1, tt.blockHeight1) + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + sessionHydrator1 := keeper.NewSessionHydrator(test.appAddr1, test.serviceId1, test.blockHeight1) session1, err := sessionKeeper.HydrateSession(ctx, sessionHydrator1) require.NoError(t, err) - sessionHydrator2 := keeper.NewSessionHydrator(tt.appAddr2, tt.serviceId2, tt.blockHeight2) + sessionHydrator2 := keeper.NewSessionHydrator(test.appAddr2, test.serviceId2, test.blockHeight2) session2, err := sessionKeeper.HydrateSession(ctx, sessionHydrator2) require.NoError(t, err) require.NotEqual(t, session1.Header.SessionId, session2.Header.SessionId) - require.Equal(t, tt.expectedSessionId1, session1.Header.SessionId) - require.Equal(t, tt.expectedSessionId2, session2.Header.SessionId) + require.Equal(t, test.expectedSessionId1, session1.Header.SessionId) + require.Equal(t, test.expectedSessionId2, session2.Header.SessionId) }) } } // TODO_TECHDEBT: Expand these tests to account for application joining/leaving the network at different heights as well changing the services they support func TestSession_HydrateSession_Application(t *testing.T) { - type test struct { + tests := []struct { // Description desc string // Inputs @@ -235,9 +234,7 @@ func TestSession_HydrateSession_Application(t *testing.T) { // Outputs expectedErr error - } - - tests := []test{ + }{ { desc: "app is found", @@ -278,13 +275,13 @@ func TestSession_HydrateSession_Application(t *testing.T) { blockHeight := int64(10) sessionKeeper, ctx := keepertest.SessionKeeper(t) - ctx = ctx.WithBlockHeight(100) // provide a sufficiently large block height to avoid errors + ctx = sdk.UnwrapSDKContext(ctx).WithBlockHeight(100) // provide a sufficiently large block height to avoid errors - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) { - sessionHydrator := keeper.NewSessionHydrator(tt.appAddr, tt.serviceId, blockHeight) + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + sessionHydrator := keeper.NewSessionHydrator(test.appAddr, test.serviceId, blockHeight) _, err := sessionKeeper.HydrateSession(ctx, sessionHydrator) - if tt.expectedErr != nil { + if test.expectedErr != nil { require.Error(t, err) } else { require.NoError(t, err) @@ -295,7 +292,9 @@ func TestSession_HydrateSession_Application(t *testing.T) { // TODO_TECHDEBT: Expand these tests to account for supplier joining/leaving the network at different heights as well changing the services they support func TestSession_HydrateSession_Suppliers(t *testing.T) { - type test struct { + // TODO_TECHDEBT: Extend these tests once `NumBlocksPerSession` is configurable. + // Currently assumes NumSupplierPerSession=15 + tests := []struct { // Description desc string @@ -306,11 +305,7 @@ func TestSession_HydrateSession_Suppliers(t *testing.T) { // Outputs numExpectedSuppliers int expectedErr error - } - - // TODO_TECHDEBT: Extend these tests once `NumBlocksPerSession` is configurable. - // Currently assumes NumSupplierPerSession=15 - tests := []test{ + }{ { desc: "num_suppliers_available = 0", @@ -341,19 +336,19 @@ func TestSession_HydrateSession_Suppliers(t *testing.T) { blockHeight := int64(10) sessionKeeper, ctx := keepertest.SessionKeeper(t) - ctx = ctx.WithBlockHeight(100) // provide a sufficiently large block height to avoid errors + ctx = sdk.UnwrapSDKContext(ctx).WithBlockHeight(100) // provide a sufficiently large block height to avoid errors - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) {}) + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) {}) - sessionHydrator := keeper.NewSessionHydrator(tt.appAddr, tt.serviceId, blockHeight) + sessionHydrator := keeper.NewSessionHydrator(test.appAddr, test.serviceId, blockHeight) session, err := sessionKeeper.HydrateSession(ctx, sessionHydrator) - if tt.expectedErr != nil { - require.ErrorContains(t, err, tt.expectedErr.Error()) + if test.expectedErr != nil { + require.ErrorContains(t, err, test.expectedErr.Error()) continue } require.NoError(t, err) - require.Len(t, session.Suppliers, tt.numExpectedSuppliers) + require.Len(t, session.Suppliers, test.numExpectedSuppliers) } } diff --git a/x/session/module/autocli.go b/x/session/module/autocli.go index bf35f4984..75f59bd46 100644 --- a/x/session/module/autocli.go +++ b/x/session/module/autocli.go @@ -10,25 +10,25 @@ import ( func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { return &autocliv1.ModuleOptions{ Query: &autocliv1.ServiceCommandDescriptor{ - Service: modulev1.Query_ServiceDesc.ServiceName, + Service: modulev1.Query_ServiceDesc.ServiceName, RpcCommandOptions: []*autocliv1.RpcCommandOptions{ - { - RpcMethod: "Params", - Use: "params", - Short: "Shows the parameters of the module", - }, - { - RpcMethod: "GetSession", - Use: "get-session [application-address] [service] [block-height]", - Short: "Query get-session", - Long: `Query the session data for a specific (app, service, height) tuple. - -This is a query operation that will not result in a state transition but simply gives a view into the chain state. - -Example: -$ poktrolld q session get-session pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 svc1 42 --node $(POCKET_NODE) --home $(POKTROLLD_HOME) `, - PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "application_address"}, {ProtoField: "service"}, {ProtoField: "block_height"}}, - }, + // { + // RpcMethod: "Params", + // Use: "params", + // Short: "Shows the parameters of the module", + // }, + // { + // RpcMethod: "GetSession", + // Use: "get-session [application-address] [service] [block-height]", + // Short: "Query get-session", + // Long: `Query the session data for a specific (app, service, height) tuple. + // + // This is a query operation that will not result in a state transition but simply gives a view into the chain state. + // + // Example: + // $ poktrolld q session get-session pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 svc1 42 --node $(POCKET_NODE) --home $(POKTROLLD_HOME) `, + // PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "application_address"}, {ProtoField: "service"}, {ProtoField: "block_height"}}, + // }, // this line is used by ignite scaffolding # autocli/query }, @@ -36,11 +36,12 @@ $ poktrolld q session get-session pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 sv 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 - }, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + // { + // RpcMethod: "UpdateParams", + // Skip: true, // skipped because authority gated + // }, + // this line is used by ignite scaffolding # autocli/tx }, }, diff --git a/x/session/module/genesis.go b/x/session/module/genesis.go index 2007b8a74..0e0430eac 100644 --- a/x/session/module/genesis.go +++ b/x/session/module/genesis.go @@ -1,20 +1,22 @@ package session import ( - sdk "github.com/cosmos/cosmos-sdk/types" + "context" "github.com/pokt-network/poktroll/x/session/keeper" "github.com/pokt-network/poktroll/x/session/types" ) // InitGenesis initializes the module's state from a provided genesis state. -func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { +func InitGenesis(ctx context.Context, k keeper.Keeper, genState types.GenesisState) { // this line is used by starport scaffolding # genesis/module/init - k.SetParams(ctx, genState.Params) + if err := k.SetParams(ctx, genState.Params); err != nil { + panic(err) + } } // ExportGenesis returns the module's exported genesis. -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { +func ExportGenesis(ctx context.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.Params = k.GetParams(ctx) diff --git a/x/session/module/genesis_test.go b/x/session/module/genesis_test.go index 0c9b49159..91b8cc149 100644 --- a/x/session/module/genesis_test.go +++ b/x/session/module/genesis_test.go @@ -12,12 +12,12 @@ func TestGenesisState_Validate(t *testing.T) { tests := []struct { desc string genState *types.GenesisState - valid bool + isValid bool }{ { desc: "default is valid", genState: types.DefaultGenesis(), - valid: true, + isValid: true, }, { desc: "valid genesis state", @@ -25,14 +25,14 @@ func TestGenesisState_Validate(t *testing.T) { // this line is used by starport scaffolding # types/genesis/validField }, - valid: true, + isValid: 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 { + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + err := test.genState.Validate() + if test.isValid { require.NoError(t, err) } else { require.Error(t, err) diff --git a/x/session/module/helpers_test.go b/x/session/module/helpers_test.go index 7a2cf436e..a010d5e15 100644 --- a/x/session/module/helpers_test.go +++ b/x/session/module/helpers_test.go @@ -7,7 +7,6 @@ import ( "github.com/stretchr/testify/require" - "github.com/pokt-network/poktroll/cmd/poktrolld/cmd" "github.com/pokt-network/poktroll/testutil/network" apptypes "github.com/pokt-network/poktroll/x/application/types" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" @@ -17,14 +16,13 @@ import ( // Dummy variable to avoid unused import error. var _ = strconv.IntSize -// init initializes the SDK configuration. -func init() { - cmd.InitSDKConfig() -} - // networkWithApplicationsAndSupplier creates a new network with a given number of supplier & application objects. // It returns the network and a slice of the created supplier & application objects. -func networkWithApplicationsAndSupplier(t *testing.T, n int) (*network.Network, []sharedtypes.Supplier, []apptypes.Application) { +func networkWithApplicationsAndSupplier(t *testing.T, n int) ( + *network.Network, + []sharedtypes.Supplier, + []apptypes.Application, +) { t.Helper() cfg := network.DefaultConfig() diff --git a/x/session/module/module.go b/x/session/module/module.go index 319dac10b..a8c55809b 100644 --- a/x/session/module/module.go +++ b/x/session/module/module.go @@ -171,10 +171,7 @@ func (am AppModule) IsAppModule() {} // ---------------------------------------------------------------------------- func init() { - appmodule.Register( - &modulev1.Module{}, - appmodule.Provide(ProvideModule), - ) + appmodule.Register(&modulev1.Module{}, appmodule.Provide(ProvideModule)) } type ModuleInputs struct { diff --git a/x/session/module/query_get_session_test.go b/x/session/module/query_get_session_test.go index 4a482afda..f2b230d1e 100644 --- a/x/session/module/query_get_session_test.go +++ b/x/session/module/query_get_session_test.go @@ -82,7 +82,7 @@ func TestCLI_GetSession(t *testing.T) { appAddress: appSvc0.Address, serviceId: "svc0", - // blockHeight: intentionally omitted, + // blockHeight explicitly omitted, expectedErr: nil, expectedNumSuppliers: 1, @@ -129,7 +129,7 @@ func TestCLI_GetSession(t *testing.T) { }, { desc: "invalid - missing appAddress", - // appAddress: intentionally omitted + // appAddress explicitly omitted serviceId: "svc0", blockHeight: 0, @@ -148,7 +148,7 @@ func TestCLI_GetSession(t *testing.T) { { desc: "invalid - missing service ID", appAddress: appSvc0.Address, // dynamically getting address from applications - // serviceId: intentionally omitted + // serviceId explicitly omitted blockHeight: 0, expectedErr: sessiontypes.ErrSessionInvalidService, @@ -161,22 +161,22 @@ func TestCLI_GetSession(t *testing.T) { } // Run the tests - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) { + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { // Prepare the arguments for the CLI command args := []string{ - tt.appAddress, - tt.serviceId, - fmt.Sprintf("%d", tt.blockHeight), + test.appAddress, + test.serviceId, + fmt.Sprintf("%d", test.blockHeight), } args = append(args, common...) // Execute the command getSessionOut, err := clitestutil.ExecTestCLICmd(ctx, session.CmdGetSession(), args) - if tt.expectedErr != nil { - stat, ok := status.FromError(tt.expectedErr) + if test.expectedErr != nil { + stat, ok := status.FromError(test.expectedErr) require.True(t, ok) - require.Contains(t, stat.Message(), tt.expectedErr.Error()) + require.Contains(t, stat.Message(), test.expectedErr.Error()) return } require.NoError(t, err) @@ -190,9 +190,9 @@ func TestCLI_GetSession(t *testing.T) { require.NotNil(t, session) // Verify some data about the session - require.Equal(t, tt.appAddress, session.Application.Address) - require.Equal(t, tt.serviceId, session.Header.Service.Id) - require.Len(t, session.Suppliers, tt.expectedNumSuppliers) + require.Equal(t, test.appAddress, session.Application.Address) + require.Equal(t, test.serviceId, session.Header.Service.Id) + require.Len(t, session.Suppliers, test.expectedNumSuppliers) }) } } diff --git a/x/session/module/tx.go b/x/session/module/tx.go index 638661956..e17d16773 100644 --- a/x/session/module/tx.go +++ b/x/session/module/tx.go @@ -2,7 +2,6 @@ package session import ( "fmt" - "time" "github.com/spf13/cobra" @@ -11,11 +10,8 @@ import ( "github.com/pokt-network/poktroll/x/session/types" ) -var ( - DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) -) - // GetTxCmd returns the transaction commands for this module +// TODO_TECHDEBT(#370): remove if custom query commands are consolidated into AutoCLI. func (am AppModule) GetTxCmd() *cobra.Command { cmd := &cobra.Command{ Use: types.ModuleName, diff --git a/x/session/types/errors.go b/x/session/types/errors.go index 8e6993f6f..6ffff939c 100644 --- a/x/session/types/errors.go +++ b/x/session/types/errors.go @@ -2,20 +2,17 @@ package types // DONTCOVER -import ( - sdkerrors "cosmossdk.io/errors" -) +import sdkerrors "cosmossdk.io/errors" // x/session module sentinel errors var ( ErrSessionInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") - ErrSessionSample = sdkerrors.Register(ModuleName, 1101, "sample error") - ErrSessionHydration = sdkerrors.Register(ModuleName, 1102, "error during session hydration") - ErrSessionAppNotFound = sdkerrors.Register(ModuleName, 1103, "application for session not found not found ") - ErrSessionAppNotStakedForService = sdkerrors.Register(ModuleName, 1104, "application in session not staked for requested service") - ErrSessionSuppliersNotFound = sdkerrors.Register(ModuleName, 1105, "no suppliers not found for session") - ErrSessionInvalidAppAddress = sdkerrors.Register(ModuleName, 1106, "invalid application address for session") - ErrSessionInvalidService = sdkerrors.Register(ModuleName, 1107, "invalid service in session") - ErrSessionInvalidBlockHeight = sdkerrors.Register(ModuleName, 1108, "invalid block height for session") - ErrSessionInvalidSessionId = sdkerrors.Register(ModuleName, 1109, "invalid sessionId") + ErrSessionHydration = sdkerrors.Register(ModuleName, 1101, "error during session hydration") + ErrSessionAppNotFound = sdkerrors.Register(ModuleName, 1102, "application for session not found not found ") + ErrSessionAppNotStakedForService = sdkerrors.Register(ModuleName, 1103, "application in session not staked for requested service") + ErrSessionSuppliersNotFound = sdkerrors.Register(ModuleName, 1104, "no suppliers not found for session") + ErrSessionInvalidAppAddress = sdkerrors.Register(ModuleName, 1105, "invalid application address for session") + 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") ) diff --git a/x/session/types/expected_keepers.go b/x/session/types/expected_keepers.go index 7d06db3bc..560226293 100644 --- a/x/session/types/expected_keepers.go +++ b/x/session/types/expected_keepers.go @@ -1,7 +1,7 @@ -package types - //go:generate mockgen -destination ../../../testutil/session/mocks/expected_keepers_mock.go -package mocks . AccountKeeper,BankKeeper,ApplicationKeeper,SupplierKeeper +package types + import ( "context" @@ -27,11 +27,5 @@ type ApplicationKeeper interface { } type SupplierKeeper interface { - GetAllSupplier(ctx context.Context) (suppliers []sharedtypes.Supplier) -} - -// ParamSubspace defines the expected Subspace interface for parameters. -type ParamSubspace interface { - Get(context.Context, []byte, interface{}) - Set(context.Context, []byte, interface{}) + GetAllSuppliers(ctx context.Context) (suppliers []sharedtypes.Supplier) } diff --git a/x/session/types/genesis.go b/x/session/types/genesis.go index 0af9b4416..a88ab1682 100644 --- a/x/session/types/genesis.go +++ b/x/session/types/genesis.go @@ -1,11 +1,6 @@ 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 { diff --git a/x/session/types/key_block_hash.go b/x/session/types/key_block_hash.go index 56472742a..a692cf4c4 100644 --- a/x/session/types/key_block_hash.go +++ b/x/session/types/key_block_hash.go @@ -2,14 +2,14 @@ package types import ( "encoding/binary" - fmt "fmt" + "fmt" ) var _ binary.ByteOrder const ( // BlockHashKeyPrefix is the prefix to retrieve all BlockHash - BlockHashKeyPrefix = "BlockHash/value/" + BlockHashKeyPrefix = "BlockHash/height/" ) // BlockHashKey returns the store key to retrieve a BlockHash from the index fields diff --git a/x/session/types/keys.go b/x/session/types/keys.go index c798c9a12..6c4bececc 100644 --- a/x/session/types/keys.go +++ b/x/session/types/keys.go @@ -11,10 +11,6 @@ const ( MemStoreKey = "mem_session" ) -var ( - ParamsKey = []byte("p_session") -) +var ParamsKey = []byte("p_session") -func KeyPrefix(p string) []byte { - return []byte(p) -} +func KeyPrefix(p string) []byte { return []byte(p) } diff --git a/x/session/types/msg_update_params.go b/x/session/types/message_update_params.go similarity index 100% rename from x/session/types/msg_update_params.go rename to x/session/types/message_update_params.go diff --git a/x/session/types/params.go b/x/session/types/params.go index 4f3215e35..95b0cf8a2 100644 --- a/x/session/types/params.go +++ b/x/session/types/params.go @@ -1,8 +1,6 @@ package types -import ( - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" -) +import paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" var _ paramtypes.ParamSet = (*Params)(nil) diff --git a/x/session/types/session_header.go b/x/session/types/session_header.go index adcb3b040..6e3daa1d0 100644 --- a/x/session/types/session_header.go +++ b/x/session/types/session_header.go @@ -1,33 +1,30 @@ package types -import ( - sdkerrors "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" -) +import sdk "github.com/cosmos/cosmos-sdk/types" // TODO_TECHDEBT: Make sure this is used everywhere we validate components // of the session header. func (sh *SessionHeader) ValidateBasic() error { // Validate the application address if _, err := sdk.AccAddressFromBech32(sh.ApplicationAddress); err != nil { - return sdkerrors.Wrapf(ErrSessionInvalidAppAddress, "invalid application address: %s; (%v)", sh.ApplicationAddress, err) + return ErrSessionInvalidAppAddress.Wrapf("invalid application address: %s; (%v)", sh.ApplicationAddress, err) } // Validate the session ID // TODO_TECHDEBT: Introduce a `SessionId#ValidateBasic` method. if sh.SessionId == "" { - return sdkerrors.Wrapf(ErrSessionInvalidSessionId, "invalid session ID: %s", sh.SessionId) + return ErrSessionInvalidSessionId.Wrapf("invalid session ID: %s", sh.SessionId) } // Validate the service // TODO_TECHDEBT: Introduce a `Service#ValidateBasic` method. if sh.Service == nil { - return sdkerrors.Wrapf(ErrSessionInvalidService, "invalid service: %s", sh.Service) + return ErrSessionInvalidService.Wrapf("invalid service: %s", sh.Service) } // Check if session end height is greater than session start height if sh.SessionEndBlockHeight <= sh.SessionStartBlockHeight { - return sdkerrors.Wrapf(ErrSessionInvalidBlockHeight, "session end block height cannot be less than or equal to session start block height") + return ErrSessionInvalidBlockHeight.Wrapf("session end block height cannot be less than or equal to session start block height") } return nil diff --git a/x/session/types/session_header_test.go b/x/session/types/session_header_test.go index e0e60ce93..5d952be42 100644 --- a/x/session/types/session_header_test.go +++ b/x/session/types/session_header_test.go @@ -12,72 +12,72 @@ import ( func TestSessionHeader_ValidateBasic(t *testing.T) { tests := []struct { - desc string - sh types.SessionHeader - err error + desc string + sessionHeader types.SessionHeader + expectedErr error }{ { desc: "invalid - invalid application address", - sh: types.SessionHeader{ + sessionHeader: types.SessionHeader{ ApplicationAddress: "invalid_address", SessionId: "valid_session_id", Service: &sharedtypes.Service{}, SessionStartBlockHeight: 100, SessionEndBlockHeight: 101, }, - err: types.ErrSessionInvalidAppAddress, + expectedErr: types.ErrSessionInvalidAppAddress, }, { desc: "invalid - empty session id", - sh: types.SessionHeader{ + sessionHeader: types.SessionHeader{ ApplicationAddress: sample.AccAddress(), SessionId: "", Service: &sharedtypes.Service{}, SessionStartBlockHeight: 100, SessionEndBlockHeight: 101, }, - err: types.ErrSessionInvalidSessionId, + expectedErr: types.ErrSessionInvalidSessionId, }, { desc: "invalid - nil service", - sh: types.SessionHeader{ + sessionHeader: types.SessionHeader{ ApplicationAddress: sample.AccAddress(), SessionId: "valid_session_id", Service: nil, SessionStartBlockHeight: 100, SessionEndBlockHeight: 101, }, - err: types.ErrSessionInvalidService, + expectedErr: types.ErrSessionInvalidService, }, { desc: "invalid - start block height greater than end block height", - sh: types.SessionHeader{ + sessionHeader: types.SessionHeader{ ApplicationAddress: sample.AccAddress(), SessionId: "valid_session_id", Service: &sharedtypes.Service{}, SessionStartBlockHeight: 100, SessionEndBlockHeight: 99, }, - err: types.ErrSessionInvalidBlockHeight, + expectedErr: types.ErrSessionInvalidBlockHeight, }, { desc: "valid", - sh: types.SessionHeader{ + sessionHeader: types.SessionHeader{ ApplicationAddress: sample.AccAddress(), SessionId: "valid_session_id", Service: &sharedtypes.Service{}, SessionStartBlockHeight: 100, SessionEndBlockHeight: 101, }, - err: nil, + expectedErr: nil, }, } - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) { - err := tt.sh.ValidateBasic() - if tt.err != nil { - require.ErrorIs(t, err, tt.err) + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + err := test.sessionHeader.ValidateBasic() + if test.expectedErr != nil { + require.ErrorIs(t, err, test.expectedErr) } else { require.NoError(t, err) } diff --git a/x/session/types/types.go b/x/session/types/types.go index ab1254f4c..78d9ec9f9 100644 --- a/x/session/types/types.go +++ b/x/session/types/types.go @@ -1 +1,3 @@ package types + +// This file is in place to declare the package for dynamically generated protobufs