From 919b35c7cc357404fa9269492231da9baeeb2222 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Tue, 19 Nov 2024 17:49:33 +0400 Subject: [PATCH 1/4] fix(server/v2/comebft): wire missing services + fix simulation (#21964) (cherry picked from commit d697a3de0f95b29ca7adcc48304cdb31e622fa31) # Conflicts: # server/v2/api/grpc/server.go # server/v2/cometbft/go.mod # server/v2/go.mod # server/v2/stf/branch/mergeiter.go --- api/cosmos/base/node/v2/query.pulsar.go | 981 ++++++++++++++++++ api/cosmos/base/node/v2/query_grpc.pb.go | 127 +++ client/grpc/cmtservice/service.go | 6 +- proto/cosmos/base/node/v2/query.proto | 22 + server/v2/api/grpc/nodeservice/query.pb.go | 532 ++++++++++ server/v2/api/grpc/nodeservice/query.pb.gw.go | 153 +++ server/v2/api/grpc/nodeservice/service.go | 29 + server/v2/api/grpc/server.go | 261 +++++ server/v2/cometbft/abci.go | 68 +- server/v2/cometbft/abci_test.go | 2 +- .../client/grpc/cmtservice/autocli.go | 71 -- .../client/grpc/cmtservice/service.go | 56 - server/v2/cometbft/client/rpc/block.go | 16 +- server/v2/cometbft/client/rpc/utils.go | 20 +- server/v2/cometbft/go.mod | 8 +- server/v2/cometbft/grpc.go | 220 ++++ server/v2/cometbft/query.go | 3 +- server/v2/cometbft/server.go | 1 - server/v2/go.mod | 120 +++ server/v2/stf/branch/mergeiter.go | 166 +++ simapp/v2/simdv2/cmd/commands.go | 44 +- simapp/v2/simdv2/cmd/root_di.go | 1 + .../integration/accounts/base_account_test.go | 2 +- tests/integration/accounts/wiring_test.go | 4 +- x/staking/keeper/grpc_query.go | 6 +- 25 files changed, 2732 insertions(+), 187 deletions(-) create mode 100644 api/cosmos/base/node/v2/query.pulsar.go create mode 100644 api/cosmos/base/node/v2/query_grpc.pb.go create mode 100644 proto/cosmos/base/node/v2/query.proto create mode 100644 server/v2/api/grpc/nodeservice/query.pb.go create mode 100644 server/v2/api/grpc/nodeservice/query.pb.gw.go create mode 100644 server/v2/api/grpc/nodeservice/service.go create mode 100644 server/v2/api/grpc/server.go delete mode 100644 server/v2/cometbft/client/grpc/cmtservice/autocli.go delete mode 100644 server/v2/cometbft/client/grpc/cmtservice/service.go create mode 100644 server/v2/cometbft/grpc.go create mode 100644 server/v2/go.mod create mode 100644 server/v2/stf/branch/mergeiter.go diff --git a/api/cosmos/base/node/v2/query.pulsar.go b/api/cosmos/base/node/v2/query.pulsar.go new file mode 100644 index 000000000000..e4039ccde48b --- /dev/null +++ b/api/cosmos/base/node/v2/query.pulsar.go @@ -0,0 +1,981 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package nodev2 + +import ( + fmt "fmt" + runtime "github.com/cosmos/cosmos-proto/runtime" + _ "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_ConfigRequest protoreflect.MessageDescriptor +) + +func init() { + file_cosmos_base_node_v2_query_proto_init() + md_ConfigRequest = File_cosmos_base_node_v2_query_proto.Messages().ByName("ConfigRequest") +} + +var _ protoreflect.Message = (*fastReflection_ConfigRequest)(nil) + +type fastReflection_ConfigRequest ConfigRequest + +func (x *ConfigRequest) ProtoReflect() protoreflect.Message { + return (*fastReflection_ConfigRequest)(x) +} + +func (x *ConfigRequest) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_base_node_v2_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_ConfigRequest_messageType fastReflection_ConfigRequest_messageType +var _ protoreflect.MessageType = fastReflection_ConfigRequest_messageType{} + +type fastReflection_ConfigRequest_messageType struct{} + +func (x fastReflection_ConfigRequest_messageType) Zero() protoreflect.Message { + return (*fastReflection_ConfigRequest)(nil) +} +func (x fastReflection_ConfigRequest_messageType) New() protoreflect.Message { + return new(fastReflection_ConfigRequest) +} +func (x fastReflection_ConfigRequest_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_ConfigRequest +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_ConfigRequest) Descriptor() protoreflect.MessageDescriptor { + return md_ConfigRequest +} + +// 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_ConfigRequest) Type() protoreflect.MessageType { + return _fastReflection_ConfigRequest_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_ConfigRequest) New() protoreflect.Message { + return new(fastReflection_ConfigRequest) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_ConfigRequest) Interface() protoreflect.ProtoMessage { + return (*ConfigRequest)(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_ConfigRequest) 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_ConfigRequest) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigRequest")) + } + panic(fmt.Errorf("message cosmos.base.node.v2.ConfigRequest 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_ConfigRequest) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigRequest")) + } + panic(fmt.Errorf("message cosmos.base.node.v2.ConfigRequest 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_ConfigRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigRequest")) + } + panic(fmt.Errorf("message cosmos.base.node.v2.ConfigRequest 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_ConfigRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigRequest")) + } + panic(fmt.Errorf("message cosmos.base.node.v2.ConfigRequest 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_ConfigRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigRequest")) + } + panic(fmt.Errorf("message cosmos.base.node.v2.ConfigRequest 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_ConfigRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigRequest")) + } + panic(fmt.Errorf("message cosmos.base.node.v2.ConfigRequest 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_ConfigRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.base.node.v2.ConfigRequest", 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_ConfigRequest) 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_ConfigRequest) 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_ConfigRequest) 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_ConfigRequest) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*ConfigRequest) + 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().(*ConfigRequest) + 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().(*ConfigRequest) + 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: ConfigRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ConfigRequest: 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_ConfigResponse protoreflect.MessageDescriptor + fd_ConfigResponse_minimum_gas_price protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_base_node_v2_query_proto_init() + md_ConfigResponse = File_cosmos_base_node_v2_query_proto.Messages().ByName("ConfigResponse") + fd_ConfigResponse_minimum_gas_price = md_ConfigResponse.Fields().ByName("minimum_gas_price") +} + +var _ protoreflect.Message = (*fastReflection_ConfigResponse)(nil) + +type fastReflection_ConfigResponse ConfigResponse + +func (x *ConfigResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_ConfigResponse)(x) +} + +func (x *ConfigResponse) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_base_node_v2_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_ConfigResponse_messageType fastReflection_ConfigResponse_messageType +var _ protoreflect.MessageType = fastReflection_ConfigResponse_messageType{} + +type fastReflection_ConfigResponse_messageType struct{} + +func (x fastReflection_ConfigResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_ConfigResponse)(nil) +} +func (x fastReflection_ConfigResponse_messageType) New() protoreflect.Message { + return new(fastReflection_ConfigResponse) +} +func (x fastReflection_ConfigResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_ConfigResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_ConfigResponse) Descriptor() protoreflect.MessageDescriptor { + return md_ConfigResponse +} + +// 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_ConfigResponse) Type() protoreflect.MessageType { + return _fastReflection_ConfigResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_ConfigResponse) New() protoreflect.Message { + return new(fastReflection_ConfigResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_ConfigResponse) Interface() protoreflect.ProtoMessage { + return (*ConfigResponse)(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_ConfigResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.MinimumGasPrice != "" { + value := protoreflect.ValueOfString(x.MinimumGasPrice) + if !f(fd_ConfigResponse_minimum_gas_price, 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_ConfigResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.base.node.v2.ConfigResponse.minimum_gas_price": + return x.MinimumGasPrice != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigResponse")) + } + panic(fmt.Errorf("message cosmos.base.node.v2.ConfigResponse 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_ConfigResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.base.node.v2.ConfigResponse.minimum_gas_price": + x.MinimumGasPrice = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigResponse")) + } + panic(fmt.Errorf("message cosmos.base.node.v2.ConfigResponse 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_ConfigResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.base.node.v2.ConfigResponse.minimum_gas_price": + value := x.MinimumGasPrice + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigResponse")) + } + panic(fmt.Errorf("message cosmos.base.node.v2.ConfigResponse 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_ConfigResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.base.node.v2.ConfigResponse.minimum_gas_price": + x.MinimumGasPrice = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigResponse")) + } + panic(fmt.Errorf("message cosmos.base.node.v2.ConfigResponse 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_ConfigResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.base.node.v2.ConfigResponse.minimum_gas_price": + panic(fmt.Errorf("field minimum_gas_price of message cosmos.base.node.v2.ConfigResponse is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigResponse")) + } + panic(fmt.Errorf("message cosmos.base.node.v2.ConfigResponse 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_ConfigResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.base.node.v2.ConfigResponse.minimum_gas_price": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigResponse")) + } + panic(fmt.Errorf("message cosmos.base.node.v2.ConfigResponse 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_ConfigResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.base.node.v2.ConfigResponse", 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_ConfigResponse) 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_ConfigResponse) 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_ConfigResponse) 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_ConfigResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*ConfigResponse) + 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.MinimumGasPrice) + 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().(*ConfigResponse) + 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.MinimumGasPrice) > 0 { + i -= len(x.MinimumGasPrice) + copy(dAtA[i:], x.MinimumGasPrice) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.MinimumGasPrice))) + 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().(*ConfigResponse) + 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: ConfigResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ConfigResponse: 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 MinimumGasPrice", 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.MinimumGasPrice = 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: cosmos/base/node/v2/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) +) + +// ConfigRequest defines the request structure for the Config gRPC query. +type ConfigRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ConfigRequest) Reset() { + *x = ConfigRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_base_node_v2_query_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ConfigRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfigRequest) ProtoMessage() {} + +// Deprecated: Use ConfigRequest.ProtoReflect.Descriptor instead. +func (*ConfigRequest) Descriptor() ([]byte, []int) { + return file_cosmos_base_node_v2_query_proto_rawDescGZIP(), []int{0} +} + +// ConfigResponse defines the response structure for the Config gRPC query. +type ConfigResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + MinimumGasPrice string `protobuf:"bytes,1,opt,name=minimum_gas_price,json=minimumGasPrice,proto3" json:"minimum_gas_price,omitempty"` +} + +func (x *ConfigResponse) Reset() { + *x = ConfigResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_base_node_v2_query_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ConfigResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfigResponse) ProtoMessage() {} + +// Deprecated: Use ConfigResponse.ProtoReflect.Descriptor instead. +func (*ConfigResponse) Descriptor() ([]byte, []int) { + return file_cosmos_base_node_v2_query_proto_rawDescGZIP(), []int{1} +} + +func (x *ConfigResponse) GetMinimumGasPrice() string { + if x != nil { + return x.MinimumGasPrice + } + return "" +} + +var File_cosmos_base_node_v2_query_proto protoreflect.FileDescriptor + +var file_cosmos_base_node_v2_query_proto_rawDesc = []byte{ + 0x0a, 0x1f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x6e, 0x6f, + 0x64, 0x65, 0x2f, 0x76, 0x32, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x13, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x6e, + 0x6f, 0x64, 0x65, 0x2e, 0x76, 0x32, 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, 0x22, 0x0f, 0x0a, 0x0d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x3c, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x11, 0x6d, 0x69, 0x6e, 0x69, 0x6d, + 0x75, 0x6d, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0f, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x47, 0x61, 0x73, 0x50, 0x72, + 0x69, 0x63, 0x65, 0x32, 0x81, 0x01, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x76, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x22, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x76, 0x32, 0x2e, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, + 0x2e, 0x76, 0x32, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x23, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1d, 0x12, 0x1b, 0x2f, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x76, 0x32, + 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x42, 0xc1, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, + 0x2e, 0x76, 0x32, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, + 0x01, 0x5a, 0x2b, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, + 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x76, 0x32, 0x3b, 0x6e, 0x6f, 0x64, 0x65, 0x76, 0x32, 0xa2, 0x02, + 0x03, 0x43, 0x42, 0x4e, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x42, 0x61, + 0x73, 0x65, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x13, 0x43, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x73, 0x65, 0x5c, 0x4e, 0x6f, 0x64, 0x65, 0x5c, 0x56, 0x32, + 0xe2, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x73, 0x65, 0x5c, 0x4e, + 0x6f, 0x64, 0x65, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0xea, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x42, 0x61, 0x73, + 0x65, 0x3a, 0x3a, 0x4e, 0x6f, 0x64, 0x65, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var ( + file_cosmos_base_node_v2_query_proto_rawDescOnce sync.Once + file_cosmos_base_node_v2_query_proto_rawDescData = file_cosmos_base_node_v2_query_proto_rawDesc +) + +func file_cosmos_base_node_v2_query_proto_rawDescGZIP() []byte { + file_cosmos_base_node_v2_query_proto_rawDescOnce.Do(func() { + file_cosmos_base_node_v2_query_proto_rawDescData = protoimpl.X.CompressGZIP(file_cosmos_base_node_v2_query_proto_rawDescData) + }) + return file_cosmos_base_node_v2_query_proto_rawDescData +} + +var file_cosmos_base_node_v2_query_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_cosmos_base_node_v2_query_proto_goTypes = []interface{}{ + (*ConfigRequest)(nil), // 0: cosmos.base.node.v2.ConfigRequest + (*ConfigResponse)(nil), // 1: cosmos.base.node.v2.ConfigResponse +} +var file_cosmos_base_node_v2_query_proto_depIdxs = []int32{ + 0, // 0: cosmos.base.node.v2.Service.Config:input_type -> cosmos.base.node.v2.ConfigRequest + 1, // 1: cosmos.base.node.v2.Service.Config:output_type -> cosmos.base.node.v2.ConfigResponse + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] 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_cosmos_base_node_v2_query_proto_init() } +func file_cosmos_base_node_v2_query_proto_init() { + if File_cosmos_base_node_v2_query_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_cosmos_base_node_v2_query_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConfigRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_base_node_v2_query_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConfigResponse); 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_cosmos_base_node_v2_query_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_cosmos_base_node_v2_query_proto_goTypes, + DependencyIndexes: file_cosmos_base_node_v2_query_proto_depIdxs, + MessageInfos: file_cosmos_base_node_v2_query_proto_msgTypes, + }.Build() + File_cosmos_base_node_v2_query_proto = out.File + file_cosmos_base_node_v2_query_proto_rawDesc = nil + file_cosmos_base_node_v2_query_proto_goTypes = nil + file_cosmos_base_node_v2_query_proto_depIdxs = nil +} diff --git a/api/cosmos/base/node/v2/query_grpc.pb.go b/api/cosmos/base/node/v2/query_grpc.pb.go new file mode 100644 index 000000000000..f87770fb5e63 --- /dev/null +++ b/api/cosmos/base/node/v2/query_grpc.pb.go @@ -0,0 +1,127 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: cosmos/base/node/v2/query.proto + +package nodev2 + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + Service_Config_FullMethodName = "/cosmos.base.node.v2.Service/Config" +) + +// ServiceClient is the client API for Service service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// Service defines the gRPC querier service for node related queries. +type ServiceClient interface { + // Config queries for the operator configuration. + Config(ctx context.Context, in *ConfigRequest, opts ...grpc.CallOption) (*ConfigResponse, error) +} + +type serviceClient struct { + cc grpc.ClientConnInterface +} + +func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient { + return &serviceClient{cc} +} + +func (c *serviceClient) Config(ctx context.Context, in *ConfigRequest, opts ...grpc.CallOption) (*ConfigResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ConfigResponse) + err := c.cc.Invoke(ctx, Service_Config_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ServiceServer is the server API for Service service. +// All implementations must embed UnimplementedServiceServer +// for forward compatibility. +// +// Service defines the gRPC querier service for node related queries. +type ServiceServer interface { + // Config queries for the operator configuration. + Config(context.Context, *ConfigRequest) (*ConfigResponse, error) + mustEmbedUnimplementedServiceServer() +} + +// UnimplementedServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedServiceServer struct{} + +func (UnimplementedServiceServer) Config(context.Context, *ConfigRequest) (*ConfigResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Config not implemented") +} +func (UnimplementedServiceServer) mustEmbedUnimplementedServiceServer() {} +func (UnimplementedServiceServer) testEmbeddedByValue() {} + +// UnsafeServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ServiceServer will +// result in compilation errors. +type UnsafeServiceServer interface { + mustEmbedUnimplementedServiceServer() +} + +func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer) { + // If the following call pancis, it indicates UnimplementedServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&Service_ServiceDesc, srv) +} + +func _Service_Config_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ConfigRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServiceServer).Config(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Service_Config_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceServer).Config(ctx, req.(*ConfigRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Service_ServiceDesc is the grpc.ServiceDesc for Service service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Service_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "cosmos.base.node.v2.Service", + HandlerType: (*ServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Config", + Handler: _Service_Config_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/base/node/v2/query.proto", +} diff --git a/client/grpc/cmtservice/service.go b/client/grpc/cmtservice/service.go index 31dfce2255ce..7d56efd3389d 100644 --- a/client/grpc/cmtservice/service.go +++ b/client/grpc/cmtservice/service.go @@ -38,12 +38,12 @@ type ( // NewQueryServer creates a new CometBFT query server. func NewQueryServer( - clientCtx CometRPC, + cometRPC CometRPC, queryFn abciQueryFn, consensusAddressCodec address.Codec, ) ServiceServer { return queryServer{ - rpc: clientCtx, + rpc: cometRPC, queryFn: queryFn, consensusCodec: consensusAddressCodec, } @@ -284,7 +284,7 @@ func (s queryServer) ABCIQuery(ctx context.Context, req *ABCIQueryRequest) (*ABC func RegisterTendermintService( clientCtx client.Context, server gogogrpc.Server, - iRegistry codectypes.InterfaceRegistry, + _ codectypes.InterfaceRegistry, queryFn abciQueryFn, ) { node, err := clientCtx.GetNode() diff --git a/proto/cosmos/base/node/v2/query.proto b/proto/cosmos/base/node/v2/query.proto new file mode 100644 index 000000000000..24de6fd21223 --- /dev/null +++ b/proto/cosmos/base/node/v2/query.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; +package cosmos.base.node.v2; + +import "google/api/annotations.proto"; + +option go_package = "cosmossdk.io/server/v2/api/grpc/nodeservice"; + +// Service defines the gRPC querier service for node related queries. +service Service { + // Config queries for the operator configuration. + rpc Config(ConfigRequest) returns (ConfigResponse) { + option (google.api.http).get = "/cosmos/base/node/v2/config"; + } +} + +// ConfigRequest defines the request structure for the Config gRPC query. +message ConfigRequest {} + +// ConfigResponse defines the response structure for the Config gRPC query. +message ConfigResponse { + string minimum_gas_price = 1; +} \ No newline at end of file diff --git a/server/v2/api/grpc/nodeservice/query.pb.go b/server/v2/api/grpc/nodeservice/query.pb.go new file mode 100644 index 000000000000..7201c35db4f1 --- /dev/null +++ b/server/v2/api/grpc/nodeservice/query.pb.go @@ -0,0 +1,532 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/base/node/v2/query.proto + +package nodeservice + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// ConfigRequest defines the request structure for the Config gRPC query. +type ConfigRequest struct { +} + +func (m *ConfigRequest) Reset() { *m = ConfigRequest{} } +func (m *ConfigRequest) String() string { return proto.CompactTextString(m) } +func (*ConfigRequest) ProtoMessage() {} +func (*ConfigRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e86a941b0be4e1ff, []int{0} +} +func (m *ConfigRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ConfigRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ConfigRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ConfigRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConfigRequest.Merge(m, src) +} +func (m *ConfigRequest) XXX_Size() int { + return m.Size() +} +func (m *ConfigRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ConfigRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ConfigRequest proto.InternalMessageInfo + +// ConfigResponse defines the response structure for the Config gRPC query. +type ConfigResponse struct { + MinimumGasPrice string `protobuf:"bytes,1,opt,name=minimum_gas_price,json=minimumGasPrice,proto3" json:"minimum_gas_price,omitempty"` +} + +func (m *ConfigResponse) Reset() { *m = ConfigResponse{} } +func (m *ConfigResponse) String() string { return proto.CompactTextString(m) } +func (*ConfigResponse) ProtoMessage() {} +func (*ConfigResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e86a941b0be4e1ff, []int{1} +} +func (m *ConfigResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ConfigResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ConfigResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ConfigResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConfigResponse.Merge(m, src) +} +func (m *ConfigResponse) XXX_Size() int { + return m.Size() +} +func (m *ConfigResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ConfigResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ConfigResponse proto.InternalMessageInfo + +func (m *ConfigResponse) GetMinimumGasPrice() string { + if m != nil { + return m.MinimumGasPrice + } + return "" +} + +func init() { + proto.RegisterType((*ConfigRequest)(nil), "cosmos.base.node.v2.ConfigRequest") + proto.RegisterType((*ConfigResponse)(nil), "cosmos.base.node.v2.ConfigResponse") +} + +func init() { proto.RegisterFile("cosmos/base/node/v2/query.proto", fileDescriptor_e86a941b0be4e1ff) } + +var fileDescriptor_e86a941b0be4e1ff = []byte{ + // 275 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0xb1, 0x4a, 0xf4, 0x40, + 0x14, 0x85, 0x33, 0x7f, 0xb1, 0x3f, 0x0e, 0xe8, 0x62, 0x6c, 0x64, 0xd5, 0x51, 0xb2, 0x8d, 0x28, + 0xcc, 0x40, 0x6c, 0xad, 0x14, 0xb1, 0x95, 0xb5, 0xb3, 0x59, 0x66, 0xb3, 0xd7, 0x30, 0x68, 0xe6, + 0x66, 0xe7, 0x26, 0x01, 0x4b, 0x7d, 0x02, 0xc1, 0x97, 0xb2, 0x5c, 0xb0, 0xb1, 0x94, 0xc4, 0x07, + 0x91, 0xc9, 0x68, 0x21, 0x2c, 0xb6, 0xe7, 0x7e, 0xe7, 0xdc, 0xc3, 0xe1, 0xfb, 0x19, 0x52, 0x81, + 0xa4, 0x66, 0x9a, 0x40, 0x59, 0x9c, 0x83, 0x6a, 0x52, 0xb5, 0xa8, 0xc1, 0x3d, 0xc8, 0xd2, 0x61, + 0x85, 0xf1, 0x56, 0x00, 0xa4, 0x07, 0xa4, 0x07, 0x64, 0x93, 0x8e, 0x76, 0x73, 0xc4, 0xfc, 0x1e, + 0x94, 0x2e, 0x8d, 0xd2, 0xd6, 0x62, 0xa5, 0x2b, 0x83, 0x96, 0x82, 0x25, 0x19, 0xf2, 0xf5, 0x73, + 0xb4, 0xb7, 0x26, 0x9f, 0xc0, 0xa2, 0x06, 0xaa, 0x92, 0x53, 0xbe, 0xf1, 0x23, 0x50, 0x89, 0x96, + 0x20, 0x3e, 0xe2, 0x9b, 0x85, 0xb1, 0xa6, 0xa8, 0x8b, 0x69, 0xae, 0x69, 0x5a, 0x3a, 0x93, 0xc1, + 0x36, 0x3b, 0x60, 0x87, 0x6b, 0x93, 0xe1, 0xf7, 0xe1, 0x52, 0xd3, 0x95, 0x97, 0xd3, 0x47, 0xc6, + 0xff, 0x5f, 0x83, 0x6b, 0x4c, 0x06, 0x71, 0xc3, 0x07, 0x21, 0x29, 0x4e, 0xe4, 0x8a, 0x62, 0xf2, + 0xd7, 0xdf, 0xd1, 0xf8, 0x4f, 0x26, 0x54, 0x49, 0xc6, 0x4f, 0x6f, 0x9f, 0x2f, 0xff, 0xf6, 0xe2, + 0x1d, 0xb5, 0x6a, 0x8a, 0xac, 0x87, 0xcf, 0x2e, 0x5e, 0x5b, 0xc1, 0x96, 0xad, 0x60, 0x1f, 0xad, + 0x60, 0xcf, 0x9d, 0x88, 0x96, 0x9d, 0x88, 0xde, 0x3b, 0x11, 0xdd, 0x1c, 0x07, 0x17, 0xcd, 0xef, + 0xa4, 0x41, 0x45, 0xe0, 0x1a, 0x70, 0xde, 0xe8, 0xa7, 0xc9, 0x5d, 0x99, 0xf5, 0x49, 0x14, 0xea, + 0xcf, 0x06, 0xfd, 0x40, 0x27, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xbb, 0xb3, 0x6b, 0x93, 0x76, + 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// ServiceClient is the client API for Service service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ServiceClient interface { + // Config queries for the operator configuration. + Config(ctx context.Context, in *ConfigRequest, opts ...grpc.CallOption) (*ConfigResponse, error) +} + +type serviceClient struct { + cc grpc1.ClientConn +} + +func NewServiceClient(cc grpc1.ClientConn) ServiceClient { + return &serviceClient{cc} +} + +func (c *serviceClient) Config(ctx context.Context, in *ConfigRequest, opts ...grpc.CallOption) (*ConfigResponse, error) { + out := new(ConfigResponse) + err := c.cc.Invoke(ctx, "/cosmos.base.node.v2.Service/Config", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ServiceServer is the server API for Service service. +type ServiceServer interface { + // Config queries for the operator configuration. + Config(context.Context, *ConfigRequest) (*ConfigResponse, error) +} + +// UnimplementedServiceServer can be embedded to have forward compatible implementations. +type UnimplementedServiceServer struct { +} + +func (*UnimplementedServiceServer) Config(ctx context.Context, req *ConfigRequest) (*ConfigResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Config not implemented") +} + +func RegisterServiceServer(s grpc1.Server, srv ServiceServer) { + s.RegisterService(&_Service_serviceDesc, srv) +} + +func _Service_Config_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ConfigRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServiceServer).Config(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.base.node.v2.Service/Config", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceServer).Config(ctx, req.(*ConfigRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var Service_serviceDesc = _Service_serviceDesc +var _Service_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cosmos.base.node.v2.Service", + HandlerType: (*ServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Config", + Handler: _Service_Config_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/base/node/v2/query.proto", +} + +func (m *ConfigRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ConfigRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConfigRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *ConfigResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ConfigResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConfigResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.MinimumGasPrice) > 0 { + i -= len(m.MinimumGasPrice) + copy(dAtA[i:], m.MinimumGasPrice) + i = encodeVarintQuery(dAtA, i, uint64(len(m.MinimumGasPrice))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ConfigRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *ConfigResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.MinimumGasPrice) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ConfigRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ConfigRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ConfigRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ConfigResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ConfigResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ConfigResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinimumGasPrice", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MinimumGasPrice = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/server/v2/api/grpc/nodeservice/query.pb.gw.go b/server/v2/api/grpc/nodeservice/query.pb.gw.go new file mode 100644 index 000000000000..b301d29dccfe --- /dev/null +++ b/server/v2/api/grpc/nodeservice/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: cosmos/base/node/v2/query.proto + +/* +Package nodeservice is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package nodeservice + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Service_Config_0(ctx context.Context, marshaler runtime.Marshaler, client ServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ConfigRequest + var metadata runtime.ServerMetadata + + msg, err := client.Config(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Service_Config_0(ctx context.Context, marshaler runtime.Marshaler, server ServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ConfigRequest + var metadata runtime.ServerMetadata + + msg, err := server.Config(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterServiceHandlerServer registers the http handlers for service Service to "mux". +// UnaryRPC :call ServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterServiceHandlerFromEndpoint instead. +func RegisterServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ServiceServer) error { + + mux.Handle("GET", pattern_Service_Config_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Service_Config_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Service_Config_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterServiceHandlerFromEndpoint is same as RegisterServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterServiceHandler(ctx, mux, conn) +} + +// RegisterServiceHandler registers the http handlers for service Service to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterServiceHandlerClient(ctx, mux, NewServiceClient(conn)) +} + +// RegisterServiceHandlerClient registers the http handlers for service Service +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "ServiceClient" to call the correct interceptors. +func RegisterServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ServiceClient) error { + + mux.Handle("GET", pattern_Service_Config_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Service_Config_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Service_Config_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Service_Config_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"cosmos", "base", "node", "v2", "config"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Service_Config_0 = runtime.ForwardResponseMessage +) diff --git a/server/v2/api/grpc/nodeservice/service.go b/server/v2/api/grpc/nodeservice/service.go new file mode 100644 index 000000000000..51f84d36142f --- /dev/null +++ b/server/v2/api/grpc/nodeservice/service.go @@ -0,0 +1,29 @@ +package nodeservice + +import ( + context "context" + + "cosmossdk.io/core/server" +) + +var _ ServiceServer = queryServer{} + +type queryServer struct { + cfg server.ConfigMap +} + +func NewQueryServer(cfg server.ConfigMap) ServiceServer { + return queryServer{cfg: cfg} +} + +func (s queryServer) Config(ctx context.Context, _ *ConfigRequest) (*ConfigResponse, error) { + minGasPricesStr := "" + minGasPrices, ok := s.cfg["server"].(map[string]interface{})["minimum-gas-prices"] + if ok { + minGasPricesStr = minGasPrices.(string) + } + + return &ConfigResponse{ + MinimumGasPrice: minGasPricesStr, + }, nil +} diff --git a/server/v2/api/grpc/server.go b/server/v2/api/grpc/server.go new file mode 100644 index 000000000000..9aa06515de33 --- /dev/null +++ b/server/v2/api/grpc/server.go @@ -0,0 +1,261 @@ +package grpc + +import ( + "context" + "errors" + "fmt" + "io" + "maps" + "net" + "slices" + "strconv" + "strings" + "sync" + + gogoproto "github.com/cosmos/gogoproto/proto" + "github.com/spf13/pflag" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/reflect/protoreflect" + + appmodulev2 "cosmossdk.io/core/appmodule/v2" + "cosmossdk.io/core/server" + "cosmossdk.io/core/transaction" + "cosmossdk.io/log" + serverv2 "cosmossdk.io/server/v2" + "cosmossdk.io/server/v2/api/grpc/gogoreflection" + "cosmossdk.io/server/v2/api/grpc/nodeservice" +) + +const ( + ServerName = "grpc" + + BlockHeightHeader = "x-cosmos-block-height" +) + +type Server[T transaction.Tx] struct { + logger log.Logger + config *Config + cfgOptions []CfgOption + + grpcSrv *grpc.Server + extraGRPCHandlers []func(*grpc.Server) error +} + +// New creates a new grpc server. +func New[T transaction.Tx]( + logger log.Logger, + interfaceRegistry server.InterfaceRegistry, + queryHandlers map[string]appmodulev2.Handler, + queryable func(ctx context.Context, version uint64, msg transaction.Msg) (transaction.Msg, error), + cfg server.ConfigMap, + opts ...OptionFunc[T], +) (*Server[T], error) { + srv := &Server[T]{} + for _, opt := range opts { + opt(srv) + } + + serverCfg := srv.Config().(*Config) + if len(cfg) > 0 { + if err := serverv2.UnmarshalSubConfig(cfg, srv.Name(), &serverCfg); err != nil { + return nil, fmt.Errorf("failed to unmarshal config: %w", err) + } + } + + grpcSrv := grpc.NewServer( + grpc.ForceServerCodec(newProtoCodec(interfaceRegistry).GRPCCodec()), + grpc.MaxSendMsgSize(serverCfg.MaxSendMsgSize), + grpc.MaxRecvMsgSize(serverCfg.MaxRecvMsgSize), + grpc.UnknownServiceHandler(makeUnknownServiceHandler(queryHandlers, queryable)), + ) + + // register grpc query handler v2 + RegisterServiceServer(grpcSrv, &v2Service{queryHandlers, queryable}) + + // register node service + nodeservice.RegisterServiceServer(grpcSrv, nodeservice.NewQueryServer(cfg)) + + // reflection allows external clients to see what services and methods the gRPC server exposes. + gogoreflection.Register(grpcSrv, slices.Collect(maps.Keys(queryHandlers)), logger.With("sub-module", "grpc-reflection")) + + // register extra handlers on the grpc server + var err error + for _, fn := range srv.extraGRPCHandlers { + err = errors.Join(err, fn(grpcSrv)) + } + if err != nil { + return nil, fmt.Errorf("failed to register extra gRPC handlers: %w", err) + } + + srv.grpcSrv = grpcSrv + srv.config = serverCfg + srv.logger = logger.With(log.ModuleKey, srv.Name()) + + return srv, nil +} + +type OptionFunc[T transaction.Tx] func(*Server[T]) + +// WithCfgOptions allows to overwrite the default server configuration. +func WithCfgOptions[T transaction.Tx](cfgOptions ...CfgOption) OptionFunc[T] { + return func(srv *Server[T]) { + srv.cfgOptions = cfgOptions + } +} + +// WithExtraGRPCHandlers allows to register extra handlers on the grpc server. +func WithExtraGRPCHandlers[T transaction.Tx](handlers ...func(*grpc.Server) error) OptionFunc[T] { + return func(srv *Server[T]) { + srv.extraGRPCHandlers = handlers + } +} + +// NewWithConfigOptions creates a new GRPC server with the provided config options. +// It is *not* a fully functional server (since it has been created without dependencies) +// The returned server should only be used to get and set configuration. +func NewWithConfigOptions[T transaction.Tx](opts ...CfgOption) *Server[T] { + return &Server[T]{ + cfgOptions: opts, + } +} + +func (s *Server[T]) StartCmdFlags() *pflag.FlagSet { + flags := pflag.NewFlagSet(s.Name(), pflag.ExitOnError) + flags.String(FlagAddress, "localhost:9090", "Listen address") + return flags +} + +func makeUnknownServiceHandler( + handlers map[string]appmodulev2.Handler, + queryable func(ctx context.Context, version uint64, msg transaction.Msg) (transaction.Msg, error), +) grpc.StreamHandler { + getRegistry := sync.OnceValues(gogoproto.MergedRegistry) + + return func(srv any, stream grpc.ServerStream) error { + method, ok := grpc.MethodFromServerStream(stream) + if !ok { + return status.Error(codes.InvalidArgument, "unable to get method") + } + // if this fails we cannot serve queries anymore... + registry, err := getRegistry() + if err != nil { + return fmt.Errorf("failed to get registry: %w", err) + } + + method = strings.TrimPrefix(method, "/") + fullName := protoreflect.FullName(strings.ReplaceAll(method, "/", ".")) + // get descriptor from the invoke method + desc, err := registry.FindDescriptorByName(fullName) + if err != nil { + return fmt.Errorf("failed to find descriptor %s: %w", method, err) + } + md, ok := desc.(protoreflect.MethodDescriptor) + if !ok { + return fmt.Errorf("%s is not a method", method) + } + // find handler + handler, exists := handlers[string(md.Input().FullName())] + if !exists { + return status.Errorf(codes.Unimplemented, "gRPC method %s is not handled", method) + } + + for { + req := handler.MakeMsg() + err := stream.RecvMsg(req) + if err != nil { + if errors.Is(err, io.EOF) { + return nil + } + return err + } + + // extract height header + ctx := stream.Context() + height, err := getHeightFromCtx(ctx) + if err != nil { + return status.Errorf(codes.InvalidArgument, "invalid get height from context: %v", err) + } + resp, err := queryable(ctx, height, req) + if err != nil { + return err + } + err = stream.SendMsg(resp) + if err != nil { + return err + } + } + } +} + +func getHeightFromCtx(ctx context.Context) (uint64, error) { + md, ok := metadata.FromIncomingContext(ctx) + if !ok { + return 0, nil + } + values := md.Get(BlockHeightHeader) + if len(values) == 0 { + return 0, nil + } + if len(values) != 1 { + return 0, fmt.Errorf("gRPC height metadata must be of length 1, got: %d", len(values)) + } + + heightStr := values[0] + height, err := strconv.ParseUint(heightStr, 10, 64) + if err != nil { + return 0, fmt.Errorf("unable to parse height string from gRPC metadata %s: %w", heightStr, err) + } + + return height, nil +} + +func (s *Server[T]) Name() string { + return ServerName +} + +func (s *Server[T]) Config() any { + if s.config == nil || s.config.Address == "" { + cfg := DefaultConfig() + // overwrite the default config with the provided options + for _, opt := range s.cfgOptions { + opt(cfg) + } + + return cfg + } + + return s.config +} + +func (s *Server[T]) Start(ctx context.Context) error { + if !s.config.Enable { + s.logger.Info(fmt.Sprintf("%s server is disabled via config", s.Name())) + return nil + } + + listener, err := (&net.ListenConfig{}).Listen(ctx, "tcp", s.config.Address) + if err != nil { + return fmt.Errorf("failed to listen on address %s: %w", s.config.Address, err) + } + + s.logger.Info("starting gRPC server...", "address", s.config.Address) + if err := s.grpcSrv.Serve(listener); err != nil { + return fmt.Errorf("failed to start gRPC server: %w", err) + } + + return nil +} + +func (s *Server[T]) Stop(ctx context.Context) error { + if !s.config.Enable { + return nil + } + + s.logger.Info("stopping gRPC server...", "address", s.config.Address) + s.grpcSrv.GracefulStop() + + return nil +} diff --git a/server/v2/cometbft/abci.go b/server/v2/cometbft/abci.go index 7b2f751b6ce2..e8c72f6ef343 100644 --- a/server/v2/cometbft/abci.go +++ b/server/v2/cometbft/abci.go @@ -11,6 +11,9 @@ import ( abci "github.com/cometbft/cometbft/abci/types" abciproto "github.com/cometbft/cometbft/api/cometbft/abci/v1" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + txtypes "github.com/cosmos/cosmos-sdk/types/tx" gogoproto "github.com/cosmos/gogoproto/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoregistry" @@ -27,7 +30,6 @@ import ( "cosmossdk.io/log" "cosmossdk.io/schema/appdata" "cosmossdk.io/server/v2/appmanager" - "cosmossdk.io/server/v2/cometbft/client/grpc/cmtservice" "cosmossdk.io/server/v2/cometbft/handlers" "cosmossdk.io/server/v2/cometbft/mempool" "cosmossdk.io/server/v2/cometbft/types" @@ -37,13 +39,18 @@ import ( consensustypes "cosmossdk.io/x/consensus/types" ) +const ( + QueryPathApp = "app" + QueryPathP2P = "p2p" + QueryPathStore = "store" +) + var _ abci.Application = (*Consensus[transaction.Tx])(nil) type Consensus[T transaction.Tx] struct { logger log.Logger appName, version string app appmanager.AppManager[T] - appCloser func() error txCodec transaction.Codec[T] store types.Store streaming streaming.Manager @@ -78,7 +85,6 @@ func NewConsensus[T transaction.Tx]( logger log.Logger, appName string, app appmanager.AppManager[T], - appCloser func() error, mp mempool.Mempool[T], indexedEvents map[string]struct{}, queryHandlersMap map[string]appmodulev2.Handler, @@ -91,7 +97,6 @@ func NewConsensus[T transaction.Tx]( appName: appName, version: getCometBFTServerVersion(), app: app, - appCloser: appCloser, cfg: cfg, store: store, logger: logger, @@ -221,17 +226,17 @@ func (c *Consensus[T]) Query(ctx context.Context, req *abciproto.QueryRequest) ( } switch path[0] { - case cmtservice.QueryPathApp: + case QueryPathApp: resp, err = c.handlerQueryApp(ctx, path, req) - case cmtservice.QueryPathStore: - resp, err = c.handleQueryStore(path, c.store, req) + case QueryPathStore: + resp, err = c.handleQueryStore(path, req) - case cmtservice.QueryPathP2P: + case QueryPathP2P: resp, err = c.handleQueryP2P(path) default: - resp = QueryResult(errorsmod.Wrap(cometerrors.ErrUnknownRequest, "unknown query path"), c.cfg.AppTomlConfig.Trace) + resp = QueryResult(errorsmod.Wrapf(cometerrors.ErrUnknownRequest, "unknown query path %s", req.Path), c.cfg.AppTomlConfig.Trace) } if err != nil { @@ -267,6 +272,50 @@ func (c *Consensus[T]) maybeRunGRPCQuery(ctx context.Context, req *abci.QueryReq handlerFullName = string(md.Input().FullName()) } + // special case for simulation as it is an external gRPC registered on the grpc server component + // and not on the app itself, so it won't pass the router afterwards. + if req.Path == "/cosmos.tx.v1beta1.Service/Simulate" { + simulateRequest := &txtypes.SimulateRequest{} + err = gogoproto.Unmarshal(req.Data, simulateRequest) + if err != nil { + return nil, true, fmt.Errorf("unable to decode gRPC request with path %s from ABCI.Query: %w", req.Path, err) + } + + tx, err := c.txCodec.Decode(simulateRequest.TxBytes) + if err != nil { + return nil, true, fmt.Errorf("failed to decode tx: %w", err) + } + + txResult, _, err := c.app.Simulate(ctx, tx) + if err != nil { + return nil, true, fmt.Errorf("%v with gas used: '%d'", err, txResult.GasUsed) + } + + msgResponses := make([]*codectypes.Any, 0, len(txResult.Resp)) + // pack the messages into Any + for _, msg := range txResult.Resp { + anyMsg, err := codectypes.NewAnyWithValue(msg) + if err != nil { + return nil, true, fmt.Errorf("failed to pack message response: %w", err) + } + + msgResponses = append(msgResponses, anyMsg) + } + + resp := &txtypes.SimulateResponse{ + GasInfo: &sdk.GasInfo{ + GasUsed: txResult.GasUsed, + GasWanted: txResult.GasWanted, + }, + Result: &sdk.Result{ + MsgResponses: msgResponses, + }, + } + + res, err := queryResponse(resp, req.Height) + return res, true, err + } + handler, found := c.queryHandlersMap[handlerFullName] if !found { return nil, true, fmt.Errorf("no query handler found for %s", req.Path) @@ -281,7 +330,6 @@ func (c *Consensus[T]) maybeRunGRPCQuery(ctx context.Context, req *abci.QueryReq resp := QueryResult(err, c.cfg.AppTomlConfig.Trace) resp.Height = req.Height return resp, true, err - } resp, err = queryResponse(res, req.Height) diff --git a/server/v2/cometbft/abci_test.go b/server/v2/cometbft/abci_test.go index 85433d426cfe..ab29139da33e 100644 --- a/server/v2/cometbft/abci_test.go +++ b/server/v2/cometbft/abci_test.go @@ -699,7 +699,7 @@ func setUpConsensus(t *testing.T, gasLimit uint64, mempool mempool.Mempool[mock. nil, ) - return NewConsensus[mock.Tx](log.NewNopLogger(), "testing-app", am, func() error { return nil }, + return NewConsensus[mock.Tx](log.NewNopLogger(), "testing-app", am, mempool, map[string]struct{}{}, nil, mockStore, Config{AppTomlConfig: DefaultAppTomlConfig()}, mock.TxCodec{}, "test") } diff --git a/server/v2/cometbft/client/grpc/cmtservice/autocli.go b/server/v2/cometbft/client/grpc/cmtservice/autocli.go deleted file mode 100644 index 6d8be1f22994..000000000000 --- a/server/v2/cometbft/client/grpc/cmtservice/autocli.go +++ /dev/null @@ -1,71 +0,0 @@ -package cmtservice - -import ( - autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" - cmtv1beta1 "cosmossdk.io/api/cosmos/base/tendermint/v1beta1" -) - -var CometBFTAutoCLIDescriptor = &autocliv1.ServiceCommandDescriptor{ - Service: cmtv1beta1.Service_ServiceDesc.ServiceName, - RpcCommandOptions: []*autocliv1.RpcCommandOptions{ - { - RpcMethod: "GetNodeInfo", - Use: "node-info", - Short: "Query the current node info", - }, - { - RpcMethod: "GetSyncing", - Use: "syncing", - Short: "Query node syncing status", - }, - { - RpcMethod: "GetLatestBlock", - Use: "block-latest", - Short: "Query for the latest committed block", - }, - { - RpcMethod: "GetBlockByHeight", - Use: "block-by-height ", - Short: "Query for a committed block by height", - Long: "Query for a specific committed block using the CometBFT RPC `block_by_height` method", - PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "height"}}, - }, - { - RpcMethod: "GetLatestValidatorSet", - Use: "validator-set", - Alias: []string{"validator-set-latest", "comet-validator-set", "cometbft-validator-set", "tendermint-validator-set"}, - Short: "Query for the latest validator set", - }, - { - RpcMethod: "GetValidatorSetByHeight", - Use: "validator-set-by-height ", - Short: "Query for a validator set by height", - PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "height"}}, - }, - { - RpcMethod: "ABCIQuery", - Skip: true, - }, - }, -} - -// NewCometBFTCommands is a fake `appmodule.Module` to be considered as a module -// and be added in AutoCLI. -func NewCometBFTCommands() *cometModule { - return &cometModule{} -} - -type cometModule struct{} - -func (m cometModule) IsOnePerModuleType() {} -func (m cometModule) IsAppModule() {} - -func (m cometModule) Name() string { - return "comet" -} - -func (m cometModule) AutoCLIOptions() *autocliv1.ModuleOptions { - return &autocliv1.ModuleOptions{ - Query: CometBFTAutoCLIDescriptor, - } -} diff --git a/server/v2/cometbft/client/grpc/cmtservice/service.go b/server/v2/cometbft/client/grpc/cmtservice/service.go deleted file mode 100644 index e4fb1bb7f51d..000000000000 --- a/server/v2/cometbft/client/grpc/cmtservice/service.go +++ /dev/null @@ -1,56 +0,0 @@ -package cmtservice - -import ( - "context" - "strings" - - abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" - gogogrpc "github.com/cosmos/gogoproto/grpc" - gogoprotoany "github.com/cosmos/gogoproto/types/any" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - - "cosmossdk.io/core/address" - "cosmossdk.io/server/v2/cometbft/client/rpc" - - cmtservice "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" -) - -var _ gogoprotoany.UnpackInterfacesMessage = &cmtservice.GetLatestValidatorSetResponse{} - -const ( - QueryPathApp = "app" - QueryPathP2P = "p2p" - QueryPathStore = "store" -) - -type abciQueryFn = func(context.Context, *abci.QueryRequest) (*abci.QueryResponse, error) - -// RegisterTendermintService registers the CometBFT queries on the gRPC router. -func RegisterTendermintService( - client rpc.CometRPC, - server gogogrpc.Server, - queryFn abciQueryFn, - consensusCodec address.Codec, -) { - cmtservice.RegisterServiceServer(server, cmtservice.NewQueryServer(client, queryFn, consensusCodec)) -} - -// RegisterGRPCGatewayRoutes mounts the CometBFT service's GRPC-gateway routes on the -// given Mux. -func RegisterGRPCGatewayRoutes(clientConn gogogrpc.ClientConn, mux *runtime.ServeMux) { - _ = cmtservice.RegisterServiceHandlerClient(context.Background(), mux, cmtservice.NewServiceClient(clientConn)) -} - -// SplitABCIQueryPath splits a string path using the delimiter '/'. -// -// e.g. "this/is/funny" becomes []string{"this", "is", "funny"} -func SplitABCIQueryPath(requestPath string) (path []string) { - path = strings.Split(requestPath, "/") - - // first element is empty string - if len(path) > 0 && path[0] == "" { - path = path[1:] - } - - return path -} diff --git a/server/v2/cometbft/client/rpc/block.go b/server/v2/cometbft/client/rpc/block.go index 1342f69f52ff..23d96a5b2f43 100644 --- a/server/v2/cometbft/client/rpc/block.go +++ b/server/v2/cometbft/client/rpc/block.go @@ -50,9 +50,15 @@ func QueryBlocks(ctx context.Context, rpcClient CometRPC, page, limit int, query return nil, err } - result := NewSearchBlocksResult(int64(resBlocks.TotalCount), int64(len(blocks)), int64(page), int64(limit), blocks) - - return result, nil + totalPages := calcTotalPages(int64(resBlocks.TotalCount), int64(limit)) + return &sdk.SearchBlocksResult{ + TotalCount: int64(resBlocks.TotalCount), + Count: int64(len(blocks)), + PageNumber: int64(page), + PageTotal: totalPages, + Limit: int64(limit), + Blocks: blocks, + }, nil } // GetBlockByHeight gets block by height @@ -65,7 +71,7 @@ func GetBlockByHeight(ctx context.Context, rpcClient CometRPC, height *int64) (* return nil, err } - out, err := NewResponseResultBlock(resBlock) + out, err := responseResultBlock(resBlock) if err != nil { return nil, err } @@ -90,7 +96,7 @@ func GetBlockByHash(ctx context.Context, rpcClient CometRPC, hashHexString strin } else if resBlock.Block == nil { return nil, fmt.Errorf("block not found with hash: %s", hashHexString) } - out, err := NewResponseResultBlock(resBlock) + out, err := responseResultBlock(resBlock) if err != nil { return nil, err } diff --git a/server/v2/cometbft/client/rpc/utils.go b/server/v2/cometbft/client/rpc/utils.go index 0ac0b23259e6..87431b529f4f 100644 --- a/server/v2/cometbft/client/rpc/utils.go +++ b/server/v2/cometbft/client/rpc/utils.go @@ -6,8 +6,6 @@ import ( cmttypes "github.com/cometbft/cometbft/api/cometbft/types/v1" coretypes "github.com/cometbft/cometbft/rpc/core/types" gogoproto "github.com/cosmos/gogoproto/proto" - - sdk "github.com/cosmos/cosmos-sdk/types" ) // formatBlockResults parses the indexed blocks into a slice of BlockResponse objects. @@ -17,7 +15,7 @@ func formatBlockResults(resBlocks []*coretypes.ResultBlock) ([]*cmttypes.Block, out = make([]*cmttypes.Block, len(resBlocks)) ) for i := range resBlocks { - out[i], err = NewResponseResultBlock(resBlocks[i]) + out[i], err = responseResultBlock(resBlocks[i]) if err != nil { return nil, fmt.Errorf("unable to create response block from comet result block: %v: %w", resBlocks[i], err) } @@ -29,20 +27,8 @@ func formatBlockResults(resBlocks []*coretypes.ResultBlock) ([]*cmttypes.Block, return out, nil } -func NewSearchBlocksResult(totalCount, count, page, limit int64, blocks []*cmttypes.Block) *sdk.SearchBlocksResult { - totalPages := calcTotalPages(totalCount, limit) - return &sdk.SearchBlocksResult{ - TotalCount: totalCount, - Count: count, - PageNumber: page, - PageTotal: totalPages, - Limit: limit, - Blocks: blocks, - } -} - -// NewResponseResultBlock returns a BlockResponse given a ResultBlock from CometBFT -func NewResponseResultBlock(res *coretypes.ResultBlock) (*cmttypes.Block, error) { +// responseResultBlock returns a BlockResponse given a ResultBlock from CometBFT +func responseResultBlock(res *coretypes.ResultBlock) (*cmttypes.Block, error) { blkProto, err := res.Block.ToProto() if err != nil { return nil, err diff --git a/server/v2/cometbft/go.mod b/server/v2/cometbft/go.mod index 5ddf98aa5ae0..6fabbc3b5737 100644 --- a/server/v2/cometbft/go.mod +++ b/server/v2/cometbft/go.mod @@ -28,11 +28,15 @@ require ( github.com/cometbft/cometbft/api v1.0.0-rc.1 github.com/cosmos/cosmos-sdk v0.52.0 github.com/cosmos/gogoproto v1.7.0 - github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.9.0 +<<<<<<< HEAD google.golang.org/protobuf v1.35.1 +======= + google.golang.org/grpc v1.68.0 + google.golang.org/protobuf v1.35.2 +>>>>>>> d697a3de0 (fix(server/v2/comebft): wire missing services + fix simulation (#21964)) sigs.k8s.io/yaml v1.4.0 ) @@ -103,6 +107,7 @@ require ( github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect + github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect @@ -175,7 +180,6 @@ require ( google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect - google.golang.org/grpc v1.68.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.1 // indirect diff --git a/server/v2/cometbft/grpc.go b/server/v2/cometbft/grpc.go new file mode 100644 index 000000000000..3e8f1855ba06 --- /dev/null +++ b/server/v2/cometbft/grpc.go @@ -0,0 +1,220 @@ +package cometbft + +import ( + "context" + + v1 "github.com/cometbft/cometbft/api/cometbft/abci/v1" + "github.com/cosmos/gogoproto/proto" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" + cmtv1beta1 "cosmossdk.io/api/cosmos/base/tendermint/v1beta1" + "cosmossdk.io/core/server" + "cosmossdk.io/core/transaction" + errorsmod "cosmossdk.io/errors/v2" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" + nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + txtypes "github.com/cosmos/cosmos-sdk/types/tx" +) + +// GRPCServiceRegistrar returns a function that registers the CometBFT gRPC service +// Those services are defined for backward compatibility. +// Eventually, they will be removed in favor of the new gRPC services. +func (c *Consensus[T]) GRPCServiceRegistrar( + clientCtx client.Context, + cfg server.ConfigMap, +) func(srv *grpc.Server) error { + return func(srv *grpc.Server) error { + cmtservice.RegisterServiceServer(srv, cmtservice.NewQueryServer(clientCtx.Client, c.Query, clientCtx.ConsensusAddressCodec)) + txtypes.RegisterServiceServer(srv, txServer[T]{clientCtx, c}) + nodeservice.RegisterServiceServer(srv, nodeServer[T]{cfg, c}) + + return nil + } +} + +// CometBFTAutoCLIDescriptor is the auto-generated CLI descriptor for the CometBFT service +var CometBFTAutoCLIDescriptor = &autocliv1.ServiceCommandDescriptor{ + Service: cmtv1beta1.Service_ServiceDesc.ServiceName, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "GetNodeInfo", + Use: "node-info", + Short: "Query the current node info", + }, + { + RpcMethod: "GetSyncing", + Use: "syncing", + Short: "Query node syncing status", + }, + { + RpcMethod: "GetLatestBlock", + Use: "block-latest", + Short: "Query for the latest committed block", + }, + { + RpcMethod: "GetBlockByHeight", + Use: "block-by-height ", + Short: "Query for a committed block by height", + Long: "Query for a specific committed block using the CometBFT RPC `block_by_height` method", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "height"}}, + }, + { + RpcMethod: "GetLatestValidatorSet", + Use: "validator-set", + Alias: []string{"validator-set-latest", "comet-validator-set", "cometbft-validator-set", "tendermint-validator-set"}, + Short: "Query for the latest validator set", + }, + { + RpcMethod: "GetValidatorSetByHeight", + Use: "validator-set-by-height ", + Short: "Query for a validator set by height", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "height"}}, + }, + { + RpcMethod: "ABCIQuery", + Skip: true, + }, + }, +} + +type txServer[T transaction.Tx] struct { + clientCtx client.Context + consensus *Consensus[T] +} + +// BroadcastTx implements tx.ServiceServer. +func (t txServer[T]) BroadcastTx(ctx context.Context, req *txtypes.BroadcastTxRequest) (*txtypes.BroadcastTxResponse, error) { + return client.TxServiceBroadcast(ctx, t.clientCtx, req) +} + +// GetBlockWithTxs implements tx.ServiceServer. +func (t txServer[T]) GetBlockWithTxs(context.Context, *txtypes.GetBlockWithTxsRequest) (*txtypes.GetBlockWithTxsResponse, error) { + return nil, status.Error(codes.Unimplemented, "not implemented") +} + +// GetTx implements tx.ServiceServer. +func (t txServer[T]) GetTx(context.Context, *txtypes.GetTxRequest) (*txtypes.GetTxResponse, error) { + return nil, status.Error(codes.Unimplemented, "not implemented") +} + +// GetTxsEvent implements tx.ServiceServer. +func (t txServer[T]) GetTxsEvent(context.Context, *txtypes.GetTxsEventRequest) (*txtypes.GetTxsEventResponse, error) { + return nil, status.Error(codes.Unimplemented, "not implemented") +} + +// Simulate implements tx.ServiceServer. +func (t txServer[T]) Simulate(ctx context.Context, req *txtypes.SimulateRequest) (*txtypes.SimulateResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid empty tx") + } + + txBytes := req.TxBytes + if txBytes == nil && req.Tx != nil { + // This block is for backwards-compatibility. + // We used to support passing a `Tx` in req. But if we do that, sig + // verification might not pass, because the .Marshal() below might not + // be the same marshaling done by the client. + var err error + txBytes, err = proto.Marshal(req.Tx) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid tx; %v", err) + } + } + + if txBytes == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty txBytes is not allowed") + } + + tx, err := t.consensus.txCodec.Decode(txBytes) + if err != nil { + return nil, errorsmod.Wrap(err, "failed to decode tx") + } + + txResult, _, err := t.consensus.app.Simulate(ctx, tx) + if err != nil { + return nil, status.Errorf(codes.Unknown, "%v with gas used: '%d'", err, txResult.GasUsed) + } + + msgResponses := make([]*codectypes.Any, 0, len(txResult.Resp)) + // pack the messages into Any + for _, msg := range txResult.Resp { + anyMsg, err := codectypes.NewAnyWithValue(msg) + if err != nil { + return nil, status.Errorf(codes.Unknown, "failed to pack message response: %v", err) + } + msgResponses = append(msgResponses, anyMsg) + } + + return &txtypes.SimulateResponse{ + GasInfo: &sdk.GasInfo{ + GasUsed: txResult.GasUsed, + GasWanted: txResult.GasWanted, + }, + Result: &sdk.Result{ + MsgResponses: msgResponses, + }, + }, nil +} + +// TxDecode implements tx.ServiceServer. +func (t txServer[T]) TxDecode(context.Context, *txtypes.TxDecodeRequest) (*txtypes.TxDecodeResponse, error) { + return nil, status.Error(codes.Unimplemented, "not implemented") +} + +// TxDecodeAmino implements tx.ServiceServer. +func (t txServer[T]) TxDecodeAmino(context.Context, *txtypes.TxDecodeAminoRequest) (*txtypes.TxDecodeAminoResponse, error) { + return nil, status.Error(codes.Unimplemented, "not implemented") +} + +// TxEncode implements tx.ServiceServer. +func (t txServer[T]) TxEncode(context.Context, *txtypes.TxEncodeRequest) (*txtypes.TxEncodeResponse, error) { + return nil, status.Error(codes.Unimplemented, "not implemented") +} + +// TxEncodeAmino implements tx.ServiceServer. +func (t txServer[T]) TxEncodeAmino(context.Context, *txtypes.TxEncodeAminoRequest) (*txtypes.TxEncodeAminoResponse, error) { + return nil, status.Error(codes.Unimplemented, "not implemented") +} + +var _ txtypes.ServiceServer = txServer[transaction.Tx]{} + +type nodeServer[T transaction.Tx] struct { + cfg server.ConfigMap + consensus *Consensus[T] +} + +func (s nodeServer[T]) Config(ctx context.Context, _ *nodeservice.ConfigRequest) (*nodeservice.ConfigResponse, error) { + minGasPricesStr := "" + minGasPrices, ok := s.cfg["server"].(map[string]interface{})["minimum-gas-prices"] + if ok { + minGasPricesStr = minGasPrices.(string) + } + + return &nodeservice.ConfigResponse{ + MinimumGasPrice: minGasPricesStr, + PruningKeepRecent: "ambiguous in v2", + PruningInterval: "ambiguous in v2", + HaltHeight: s.consensus.cfg.AppTomlConfig.HaltHeight, + }, nil +} + +func (s nodeServer[T]) Status(ctx context.Context, _ *nodeservice.StatusRequest) (*nodeservice.StatusResponse, error) { + nodeInfo, err := s.consensus.Info(ctx, &v1.InfoRequest{}) + if err != nil { + return nil, err + } + + return &nodeservice.StatusResponse{ + Height: uint64(nodeInfo.LastBlockHeight), + Timestamp: nil, + AppHash: nil, + ValidatorHash: nodeInfo.LastBlockAppHash, + }, nil +} diff --git a/server/v2/cometbft/query.go b/server/v2/cometbft/query.go index 8a624f56fc32..f032b2807355 100644 --- a/server/v2/cometbft/query.go +++ b/server/v2/cometbft/query.go @@ -8,7 +8,6 @@ import ( crypto "github.com/cometbft/cometbft/api/cometbft/crypto/v1" errorsmod "cosmossdk.io/errors/v2" - "cosmossdk.io/server/v2/cometbft/types" cometerrors "cosmossdk.io/server/v2/cometbft/types/errors" ) @@ -84,7 +83,7 @@ func (c *Consensus[T]) handlerQueryApp(ctx context.Context, path []string, req * return nil, errorsmod.Wrapf(cometerrors.ErrUnknownRequest, "unknown query: %s", path) } -func (c *Consensus[T]) handleQueryStore(path []string, _ types.Store, req *abci.QueryRequest) (*abci.QueryResponse, error) { +func (c *Consensus[T]) handleQueryStore(path []string, req *abci.QueryRequest) (*abci.QueryResponse, error) { req.Path = "/" + strings.Join(path[1:], "/") if req.Height <= 1 && req.Prove { return nil, errorsmod.Wrap( diff --git a/server/v2/cometbft/server.go b/server/v2/cometbft/server.go index 55f80f69ed3a..a8269317fad7 100644 --- a/server/v2/cometbft/server.go +++ b/server/v2/cometbft/server.go @@ -116,7 +116,6 @@ func New[T transaction.Tx]( logger, appName, appManager, - nil, srv.serverOptions.Mempool(cfg), indexEvents, queryHandlers, diff --git a/server/v2/go.mod b/server/v2/go.mod new file mode 100644 index 000000000000..cc692130a346 --- /dev/null +++ b/server/v2/go.mod @@ -0,0 +1,120 @@ +module cosmossdk.io/server/v2 + +go 1.23 + +replace ( + cosmossdk.io/api => ../../api + cosmossdk.io/server/v2/appmanager => ./appmanager + cosmossdk.io/server/v2/stf => ./stf + cosmossdk.io/store/v2 => ../../store/v2 + cosmossdk.io/store/v2/db => ../../store/v2/db + cosmossdk.io/x/tx => ../../x/tx +) + +require ( + cosmossdk.io/api v0.7.6 + cosmossdk.io/core v1.0.0-alpha.6 + cosmossdk.io/core/testing v0.0.0-20241108153815-606544c7be7e + cosmossdk.io/log v1.5.0 + cosmossdk.io/server/v2/appmanager v0.0.0-00010101000000-000000000000 + cosmossdk.io/store/v2 v2.0.0-00010101000000-000000000000 + github.com/cosmos/cosmos-proto v1.0.0-beta.5 + github.com/cosmos/gogogateway v1.2.0 + github.com/cosmos/gogoproto v1.7.0 + github.com/golang/protobuf v1.5.4 + github.com/grpc-ecosystem/grpc-gateway v1.16.0 + github.com/hashicorp/go-hclog v1.6.3 + github.com/hashicorp/go-metrics v0.5.3 + github.com/hashicorp/go-plugin v1.6.2 + github.com/mitchellh/mapstructure v1.5.0 + github.com/pelletier/go-toml/v2 v2.2.2 + github.com/prometheus/client_golang v1.20.5 + github.com/prometheus/common v0.60.1 + github.com/rs/zerolog v1.33.0 + github.com/spf13/cobra v1.8.1 + github.com/spf13/pflag v1.0.5 + github.com/spf13/viper v1.19.0 + github.com/stretchr/testify v1.9.0 + google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 + google.golang.org/grpc v1.68.0 + google.golang.org/protobuf v1.35.2 +) + +require ( + cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect + cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac // indirect + github.com/DataDog/datadog-go v4.8.3+incompatible // indirect + github.com/DataDog/zstd v1.5.5 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/bytedance/sonic v1.12.4 // indirect + github.com/bytedance/sonic/loader v0.2.1 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/cloudwego/base64x v0.1.4 // indirect + github.com/cloudwego/iasm v0.2.0 // indirect + github.com/cockroachdb/errors v1.11.1 // indirect + github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect + github.com/cockroachdb/pebble v1.1.0 // indirect + github.com/cockroachdb/redact v1.1.5 // indirect + github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect + github.com/cosmos/iavl v1.3.1 // indirect + github.com/cosmos/ics23/go v0.11.0 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/emicklei/dot v1.6.2 // indirect + github.com/fatih/color v1.18.0 // indirect + github.com/fsnotify/fsnotify v1.8.0 // indirect + github.com/getsentry/sentry-go v0.27.0 // indirect + github.com/gogo/googleapis v1.4.1 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/snappy v0.0.4 // indirect + github.com/google/btree v1.1.2 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/hashicorp/go-immutable-radix v1.3.1 // indirect + github.com/hashicorp/golang-lru v1.0.2 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect + github.com/hashicorp/yamux v0.1.2 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/jhump/protoreflect v1.17.0 // indirect + github.com/klauspost/compress v1.17.9 // indirect + github.com/klauspost/cpuid/v2 v2.2.9 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/linxGnu/grocksdb v1.9.3 // indirect + github.com/magiconair/properties v1.8.7 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-sqlite3 v1.14.22 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/oklog/run v1.1.0 // indirect + github.com/onsi/gomega v1.28.1 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/procfs v0.15.1 // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect + github.com/sagikazarmark/locafero v0.4.0 // indirect + github.com/sagikazarmark/slog-shim v0.1.0 // indirect + github.com/sourcegraph/conc v0.3.0 // indirect + github.com/spf13/afero v1.11.0 // indirect + github.com/spf13/cast v1.7.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect + github.com/subosito/gotenv v1.6.0 // indirect + github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect + github.com/tendermint/go-amino v0.16.0 // indirect + github.com/tidwall/btree v1.7.0 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + go.uber.org/multierr v1.11.0 // indirect + golang.org/x/arch v0.12.0 // indirect + golang.org/x/crypto v0.29.0 // indirect + golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/net v0.30.0 // indirect + golang.org/x/sync v0.9.0 // indirect + golang.org/x/sys v0.27.0 // indirect + golang.org/x/text v0.20.0 // indirect + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect + google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/server/v2/stf/branch/mergeiter.go b/server/v2/stf/branch/mergeiter.go new file mode 100644 index 000000000000..22e6320890ba --- /dev/null +++ b/server/v2/stf/branch/mergeiter.go @@ -0,0 +1,166 @@ +package branch + +import ( + "bytes" + "errors" + + corestore "cosmossdk.io/core/store" +) + +var errInvalidIterator = errors.New("invalid iterator") + +// mergedIterator merges a parent Iterator and a child Iterator. +// The child iterator may contain items that shadow or override items in the parent iterator. +// If the child iterator has the same key as the parent, the child's value takes precedence. +// Deleted items in the child (indicated by nil values) are skipped. +type mergedIterator[Parent, Child corestore.Iterator] struct { + parent Parent // Iterator for the parent store + child Child // Iterator for the child store + ascending bool // Direction of iteration + valid bool // Indicates if the iterator is in a valid state + currKey []byte // Current key pointed by the iterator + currValue []byte // Current value corresponding to currKey + err error // Error encountered during iteration +} + +// Ensure mergedIterator implements the corestore.Iterator interface. +var _ corestore.Iterator = (*mergedIterator[corestore.Iterator, corestore.Iterator])(nil) + +// mergeIterators creates a new merged iterator from parent and child iterators. +// The 'ascending' parameter determines the direction of iteration. +func mergeIterators[Parent, Child corestore.Iterator](parent Parent, child Child, ascending bool) *mergedIterator[Parent, Child] { + iter := &mergedIterator[Parent, Child]{ + parent: parent, + child: child, + ascending: ascending, + } + iter.advance() // Initialize the iterator by advancing to the first valid item + return iter +} + +// Domain returns the start and end range of the iterator. +// It delegates to the parent iterator as both iterators share the same domain. +func (i *mergedIterator[Parent, Child]) Domain() (start, end []byte) { + return i.parent.Domain() +} + +// Valid checks if the iterator is in a valid state. +// It returns true if the iterator has not reached the end. +func (i *mergedIterator[Parent, Child]) Valid() bool { + return i.valid +} + +// Next advances the iterator to the next valid item. +// It skips over deleted items (with nil values) and updates the current key and value. +func (i *mergedIterator[Parent, Child]) Next() { + if !i.valid { + i.err = errInvalidIterator + return + } + i.advance() +} + +// Key returns the current key pointed by the iterator. +// If the iterator is invalid, it returns nil. +func (i *mergedIterator[Parent, Child]) Key() []byte { + if !i.valid { + panic("called key on invalid iterator") + } + return i.currKey +} + +// Value returns the current value corresponding to the current key. +// If the iterator is invalid, it returns nil. +func (i *mergedIterator[Parent, Child]) Value() []byte { + if !i.valid { + panic("called value on invalid iterator") + } + return i.currValue +} + +// Close closes both the parent and child iterators. +// It returns any error encountered during the closing of the iterators. +func (i *mergedIterator[Parent, Child]) Close() (err error) { + err = errors.Join(err, i.parent.Close()) + err = errors.Join(err, i.child.Close()) + i.valid = false + return err +} + +// Error returns any error that occurred during iteration. +// If the iterator is valid, it returns nil. +func (i *mergedIterator[Parent, Child]) Error() error { + return i.err +} + +// advance moves the iterator to the next valid (non-deleted) item. +// It handles merging logic between the parent and child iterators. +func (i *mergedIterator[Parent, Child]) advance() { + for { + // Check if both iterators have reached the end + if !i.parent.Valid() && !i.child.Valid() { + i.valid = false + return + } + + var key, value []byte + + // If parent iterator is exhausted, use the child iterator + if !i.parent.Valid() { + key = i.child.Key() + value = i.child.Value() + i.child.Next() + } else if !i.child.Valid() { + // If child iterator is exhausted, use the parent iterator + key = i.parent.Key() + value = i.parent.Value() + i.parent.Next() + } else { + // Both iterators are valid; compare keys + keyP, keyC := i.parent.Key(), i.child.Key() + switch cmp := i.compare(keyP, keyC); { + case cmp < 0: + // Parent key is less than child key + key = keyP + value = i.parent.Value() + i.parent.Next() + case cmp == 0: + // Keys are equal; child overrides parent + key = keyC + value = i.child.Value() + i.parent.Next() + i.child.Next() + case cmp > 0: + // Child key is less than parent key + key = keyC + value = i.child.Value() + i.child.Next() + } + } + + // Skip deleted items (value is nil) + if value == nil { + continue + } + + // Update the current key and value, and mark iterator as valid + i.currKey = key + i.currValue = value + i.valid = true + return + } +} + +// compare compares two byte slices a and b. +// It returns an integer comparing a and b: +// - Negative if a < b +// - Zero if a == b +// - Positive if a > b +// +// The comparison respects the iterator's direction (ascending or descending). +func (i *mergedIterator[Parent, Child]) compare(a, b []byte) int { + if i.ascending { + return bytes.Compare(a, b) + } + return bytes.Compare(b, a) +} diff --git a/simapp/v2/simdv2/cmd/commands.go b/simapp/v2/simdv2/cmd/commands.go index 3acf7c0950d2..64c91f85c12a 100644 --- a/simapp/v2/simdv2/cmd/commands.go +++ b/simapp/v2/simdv2/cmd/commands.go @@ -12,7 +12,7 @@ import ( "cosmossdk.io/log" runtimev2 "cosmossdk.io/runtime/v2" serverv2 "cosmossdk.io/server/v2" - "cosmossdk.io/server/v2/api/grpc" + grpcserver "cosmossdk.io/server/v2/api/grpc" "cosmossdk.io/server/v2/api/rest" "cosmossdk.io/server/v2/api/telemetry" "cosmossdk.io/server/v2/cometbft" @@ -40,7 +40,10 @@ type CommandDependencies[T transaction.Tx] struct { TxConfig client.TxConfig ModuleManager *runtimev2.MM[T] SimApp *simapp.SimApp[T] - Consensus serverv2.ServerComponent[T] + // could be more generic with serverv2.ServerComponent[T] + // however, we want to register extra grpc handlers + ConsensusServer *cometbft.CometBFTServer[T] + ClientContext client.Context } func InitRootCmd[T transaction.Tx]( @@ -66,8 +69,8 @@ func InitRootCmd[T transaction.Tx]( // build CLI skeleton for initial config parsing or a client application invocation if deps.SimApp == nil { - if deps.Consensus == nil { - deps.Consensus = cometbft.NewWithConfigOptions[T](initCometConfig()) + if deps.ConsensusServer == nil { + deps.ConsensusServer = cometbft.NewWithConfigOptions[T](initCometConfig()) } return serverv2.AddCommands[T]( rootCmd, @@ -75,8 +78,8 @@ func InitRootCmd[T transaction.Tx]( io.NopCloser(nil), deps.GlobalConfig, initServerConfig(), - deps.Consensus, - &grpc.Server[T]{}, + deps.ConsensusServer, + &grpcserver.Server[T]{}, &serverstore.Server[T]{}, &telemetry.Server[T]{}, &rest.Server[T]{}, @@ -85,10 +88,7 @@ func InitRootCmd[T transaction.Tx]( // build full app! simApp := deps.SimApp - grpcServer, err := grpc.New[T](logger, simApp.InterfaceRegistry(), simApp.QueryHandlers(), simApp.Query, deps.GlobalConfig) - if err != nil { - return nil, err - } + // store component (not a server) storeComponent, err := serverstore.New[T](simApp.Store(), deps.GlobalConfig) if err != nil { @@ -100,8 +100,8 @@ func InitRootCmd[T transaction.Tx]( } // consensus component - if deps.Consensus == nil { - deps.Consensus, err = cometbft.New( + if deps.ConsensusServer == nil { + deps.ConsensusServer, err = cometbft.New( logger, simApp.Name(), simApp.Store(), @@ -116,11 +116,29 @@ func InitRootCmd[T transaction.Tx]( return nil, err } } + telemetryServer, err := telemetry.New[T](deps.GlobalConfig, logger) if err != nil { return nil, err } + grpcServer, err := grpcserver.New[T]( + logger, + simApp.InterfaceRegistry(), + simApp.QueryHandlers(), + simApp.Query, + deps.GlobalConfig, + grpcserver.WithExtraGRPCHandlers[T]( + deps.ConsensusServer.Consensus.GRPCServiceRegistrar( + deps.ClientContext, + deps.GlobalConfig, + ), + ), + ) + if err != nil { + return nil, err + } + // wire server commands return serverv2.AddCommands[T]( rootCmd, @@ -128,7 +146,7 @@ func InitRootCmd[T transaction.Tx]( simApp, deps.GlobalConfig, initServerConfig(), - deps.Consensus, + deps.ConsensusServer, grpcServer, storeComponent, telemetryServer, diff --git a/simapp/v2/simdv2/cmd/root_di.go b/simapp/v2/simdv2/cmd/root_di.go index 1d71876a8fde..c2dddc9992f2 100644 --- a/simapp/v2/simdv2/cmd/root_di.go +++ b/simapp/v2/simdv2/cmd/root_di.go @@ -94,6 +94,7 @@ func NewRootCmd[T transaction.Tx]( TxConfig: clientCtx.TxConfig, ModuleManager: moduleManager, SimApp: simApp, + ClientContext: clientCtx, } rootCommand = &cobra.Command{ Use: "simdv2", diff --git a/tests/integration/accounts/base_account_test.go b/tests/integration/accounts/base_account_test.go index 367f099984d4..a50975b8ff79 100644 --- a/tests/integration/accounts/base_account_test.go +++ b/tests/integration/accounts/base_account_test.go @@ -6,6 +6,7 @@ import ( gogoproto "github.com/cosmos/gogoproto/proto" gogoany "github.com/cosmos/gogoproto/types/any" + "github.com/stretchr/testify/require" "cosmossdk.io/simapp" baseaccountv1 "cosmossdk.io/x/accounts/defaults/base/v1" @@ -17,7 +18,6 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" ) var ( diff --git a/tests/integration/accounts/wiring_test.go b/tests/integration/accounts/wiring_test.go index 466bfbc2b765..a60d941e49a8 100644 --- a/tests/integration/accounts/wiring_test.go +++ b/tests/integration/accounts/wiring_test.go @@ -3,12 +3,14 @@ package accounts import ( "testing" + "github.com/stretchr/testify/require" + "cosmossdk.io/core/header" storetypes "cosmossdk.io/store/types" counterv1 "cosmossdk.io/x/accounts/testing/counter/v1" "cosmossdk.io/x/bank/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" ) // TestDependencies aims to test wiring between different account components, diff --git a/x/staking/keeper/grpc_query.go b/x/staking/keeper/grpc_query.go index 898652b7d6a9..e74a960297c3 100644 --- a/x/staking/keeper/grpc_query.go +++ b/x/staking/keeper/grpc_query.go @@ -11,7 +11,6 @@ import ( "cosmossdk.io/collections" errorsmod "cosmossdk.io/errors" "cosmossdk.io/store/prefix" - storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/staking/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -429,14 +428,13 @@ func (k Querier) Redelegations(ctx context.Context, req *types.QueryRedelegation var pageRes *query.PageResponse var err error - store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) switch { case req.DelegatorAddr != "" && req.SrcValidatorAddr != "" && req.DstValidatorAddr != "": redels, err = queryRedelegation(ctx, k, req) case req.DelegatorAddr == "" && req.SrcValidatorAddr != "" && req.DstValidatorAddr == "": redels, pageRes, err = queryRedelegationsFromSrcValidator(ctx, k, req) default: - redels, pageRes, err = queryAllRedelegations(ctx, store, k, req) + redels, pageRes, err = queryAllRedelegations(ctx, k, req) } if err != nil { return nil, status.Error(codes.Internal, err.Error()) @@ -557,7 +555,7 @@ func queryRedelegationsFromSrcValidator(ctx context.Context, k Querier, req *typ }, query.WithCollectionPaginationTriplePrefix[[]byte, []byte, []byte](valAddr)) } -func queryAllRedelegations(ctx context.Context, store storetypes.KVStore, k Querier, req *types.QueryRedelegationsRequest) (redels types.Redelegations, res *query.PageResponse, err error) { +func queryAllRedelegations(ctx context.Context, k Querier, req *types.QueryRedelegationsRequest) (redels types.Redelegations, res *query.PageResponse, err error) { delAddr, err := k.authKeeper.AddressCodec().StringToBytes(req.DelegatorAddr) if err != nil { return nil, nil, err From bfd70bc28052726e66dbe2ac88c9191023f49f2c Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Tue, 19 Nov 2024 15:05:08 +0100 Subject: [PATCH 2/4] fix conflicts --- server/v2/api/grpc/nodeservice/query.pb.go | 532 ------------------ server/v2/api/grpc/nodeservice/query.pb.gw.go | 153 ----- server/v2/api/grpc/nodeservice/service.go | 29 - server/v2/api/grpc/server.go | 261 --------- server/v2/cometbft/go.mod | 16 +- server/v2/cometbft/go.sum | 28 +- server/v2/go.mod | 120 ---- server/v2/stf/branch/mergeiter.go | 166 ------ simapp/v2/go.mod | 21 +- simapp/v2/go.sum | 40 +- 10 files changed, 51 insertions(+), 1315 deletions(-) delete mode 100644 server/v2/api/grpc/nodeservice/query.pb.go delete mode 100644 server/v2/api/grpc/nodeservice/query.pb.gw.go delete mode 100644 server/v2/api/grpc/nodeservice/service.go delete mode 100644 server/v2/api/grpc/server.go delete mode 100644 server/v2/go.mod delete mode 100644 server/v2/stf/branch/mergeiter.go diff --git a/server/v2/api/grpc/nodeservice/query.pb.go b/server/v2/api/grpc/nodeservice/query.pb.go deleted file mode 100644 index 7201c35db4f1..000000000000 --- a/server/v2/api/grpc/nodeservice/query.pb.go +++ /dev/null @@ -1,532 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/base/node/v2/query.proto - -package nodeservice - -import ( - context "context" - fmt "fmt" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// ConfigRequest defines the request structure for the Config gRPC query. -type ConfigRequest struct { -} - -func (m *ConfigRequest) Reset() { *m = ConfigRequest{} } -func (m *ConfigRequest) String() string { return proto.CompactTextString(m) } -func (*ConfigRequest) ProtoMessage() {} -func (*ConfigRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e86a941b0be4e1ff, []int{0} -} -func (m *ConfigRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ConfigRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ConfigRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ConfigRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ConfigRequest.Merge(m, src) -} -func (m *ConfigRequest) XXX_Size() int { - return m.Size() -} -func (m *ConfigRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ConfigRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ConfigRequest proto.InternalMessageInfo - -// ConfigResponse defines the response structure for the Config gRPC query. -type ConfigResponse struct { - MinimumGasPrice string `protobuf:"bytes,1,opt,name=minimum_gas_price,json=minimumGasPrice,proto3" json:"minimum_gas_price,omitempty"` -} - -func (m *ConfigResponse) Reset() { *m = ConfigResponse{} } -func (m *ConfigResponse) String() string { return proto.CompactTextString(m) } -func (*ConfigResponse) ProtoMessage() {} -func (*ConfigResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e86a941b0be4e1ff, []int{1} -} -func (m *ConfigResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ConfigResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ConfigResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ConfigResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ConfigResponse.Merge(m, src) -} -func (m *ConfigResponse) XXX_Size() int { - return m.Size() -} -func (m *ConfigResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ConfigResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ConfigResponse proto.InternalMessageInfo - -func (m *ConfigResponse) GetMinimumGasPrice() string { - if m != nil { - return m.MinimumGasPrice - } - return "" -} - -func init() { - proto.RegisterType((*ConfigRequest)(nil), "cosmos.base.node.v2.ConfigRequest") - proto.RegisterType((*ConfigResponse)(nil), "cosmos.base.node.v2.ConfigResponse") -} - -func init() { proto.RegisterFile("cosmos/base/node/v2/query.proto", fileDescriptor_e86a941b0be4e1ff) } - -var fileDescriptor_e86a941b0be4e1ff = []byte{ - // 275 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0xb1, 0x4a, 0xf4, 0x40, - 0x14, 0x85, 0x33, 0x7f, 0xb1, 0x3f, 0x0e, 0xe8, 0x62, 0x6c, 0x64, 0xd5, 0x51, 0xb2, 0x8d, 0x28, - 0xcc, 0x40, 0x6c, 0xad, 0x14, 0xb1, 0x95, 0xb5, 0xb3, 0x59, 0x66, 0xb3, 0xd7, 0x30, 0x68, 0xe6, - 0x66, 0xe7, 0x26, 0x01, 0x4b, 0x7d, 0x02, 0xc1, 0x97, 0xb2, 0x5c, 0xb0, 0xb1, 0x94, 0xc4, 0x07, - 0x91, 0xc9, 0x68, 0x21, 0x2c, 0xb6, 0xe7, 0x7e, 0xe7, 0xdc, 0xc3, 0xe1, 0xfb, 0x19, 0x52, 0x81, - 0xa4, 0x66, 0x9a, 0x40, 0x59, 0x9c, 0x83, 0x6a, 0x52, 0xb5, 0xa8, 0xc1, 0x3d, 0xc8, 0xd2, 0x61, - 0x85, 0xf1, 0x56, 0x00, 0xa4, 0x07, 0xa4, 0x07, 0x64, 0x93, 0x8e, 0x76, 0x73, 0xc4, 0xfc, 0x1e, - 0x94, 0x2e, 0x8d, 0xd2, 0xd6, 0x62, 0xa5, 0x2b, 0x83, 0x96, 0x82, 0x25, 0x19, 0xf2, 0xf5, 0x73, - 0xb4, 0xb7, 0x26, 0x9f, 0xc0, 0xa2, 0x06, 0xaa, 0x92, 0x53, 0xbe, 0xf1, 0x23, 0x50, 0x89, 0x96, - 0x20, 0x3e, 0xe2, 0x9b, 0x85, 0xb1, 0xa6, 0xa8, 0x8b, 0x69, 0xae, 0x69, 0x5a, 0x3a, 0x93, 0xc1, - 0x36, 0x3b, 0x60, 0x87, 0x6b, 0x93, 0xe1, 0xf7, 0xe1, 0x52, 0xd3, 0x95, 0x97, 0xd3, 0x47, 0xc6, - 0xff, 0x5f, 0x83, 0x6b, 0x4c, 0x06, 0x71, 0xc3, 0x07, 0x21, 0x29, 0x4e, 0xe4, 0x8a, 0x62, 0xf2, - 0xd7, 0xdf, 0xd1, 0xf8, 0x4f, 0x26, 0x54, 0x49, 0xc6, 0x4f, 0x6f, 0x9f, 0x2f, 0xff, 0xf6, 0xe2, - 0x1d, 0xb5, 0x6a, 0x8a, 0xac, 0x87, 0xcf, 0x2e, 0x5e, 0x5b, 0xc1, 0x96, 0xad, 0x60, 0x1f, 0xad, - 0x60, 0xcf, 0x9d, 0x88, 0x96, 0x9d, 0x88, 0xde, 0x3b, 0x11, 0xdd, 0x1c, 0x07, 0x17, 0xcd, 0xef, - 0xa4, 0x41, 0x45, 0xe0, 0x1a, 0x70, 0xde, 0xe8, 0xa7, 0xc9, 0x5d, 0x99, 0xf5, 0x49, 0x14, 0xea, - 0xcf, 0x06, 0xfd, 0x40, 0x27, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xbb, 0xb3, 0x6b, 0x93, 0x76, - 0x01, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// ServiceClient is the client API for Service service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type ServiceClient interface { - // Config queries for the operator configuration. - Config(ctx context.Context, in *ConfigRequest, opts ...grpc.CallOption) (*ConfigResponse, error) -} - -type serviceClient struct { - cc grpc1.ClientConn -} - -func NewServiceClient(cc grpc1.ClientConn) ServiceClient { - return &serviceClient{cc} -} - -func (c *serviceClient) Config(ctx context.Context, in *ConfigRequest, opts ...grpc.CallOption) (*ConfigResponse, error) { - out := new(ConfigResponse) - err := c.cc.Invoke(ctx, "/cosmos.base.node.v2.Service/Config", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ServiceServer is the server API for Service service. -type ServiceServer interface { - // Config queries for the operator configuration. - Config(context.Context, *ConfigRequest) (*ConfigResponse, error) -} - -// UnimplementedServiceServer can be embedded to have forward compatible implementations. -type UnimplementedServiceServer struct { -} - -func (*UnimplementedServiceServer) Config(ctx context.Context, req *ConfigRequest) (*ConfigResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Config not implemented") -} - -func RegisterServiceServer(s grpc1.Server, srv ServiceServer) { - s.RegisterService(&_Service_serviceDesc, srv) -} - -func _Service_Config_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ConfigRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).Config(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/cosmos.base.node.v2.Service/Config", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).Config(ctx, req.(*ConfigRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var Service_serviceDesc = _Service_serviceDesc -var _Service_serviceDesc = grpc.ServiceDesc{ - ServiceName: "cosmos.base.node.v2.Service", - HandlerType: (*ServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Config", - Handler: _Service_Config_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "cosmos/base/node/v2/query.proto", -} - -func (m *ConfigRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ConfigRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ConfigRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *ConfigResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ConfigResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ConfigResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.MinimumGasPrice) > 0 { - i -= len(m.MinimumGasPrice) - copy(dAtA[i:], m.MinimumGasPrice) - i = encodeVarintQuery(dAtA, i, uint64(len(m.MinimumGasPrice))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *ConfigRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *ConfigResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.MinimumGasPrice) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *ConfigRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ConfigRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ConfigRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ConfigResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ConfigResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ConfigResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinimumGasPrice", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.MinimumGasPrice = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipQuery(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthQuery - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupQuery - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthQuery - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") -) diff --git a/server/v2/api/grpc/nodeservice/query.pb.gw.go b/server/v2/api/grpc/nodeservice/query.pb.gw.go deleted file mode 100644 index b301d29dccfe..000000000000 --- a/server/v2/api/grpc/nodeservice/query.pb.gw.go +++ /dev/null @@ -1,153 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: cosmos/base/node/v2/query.proto - -/* -Package nodeservice is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package nodeservice - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -func request_Service_Config_0(ctx context.Context, marshaler runtime.Marshaler, client ServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ConfigRequest - var metadata runtime.ServerMetadata - - msg, err := client.Config(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Service_Config_0(ctx context.Context, marshaler runtime.Marshaler, server ServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ConfigRequest - var metadata runtime.ServerMetadata - - msg, err := server.Config(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterServiceHandlerServer registers the http handlers for service Service to "mux". -// UnaryRPC :call ServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterServiceHandlerFromEndpoint instead. -func RegisterServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ServiceServer) error { - - mux.Handle("GET", pattern_Service_Config_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Service_Config_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Service_Config_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterServiceHandlerFromEndpoint is same as RegisterServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterServiceHandler(ctx, mux, conn) -} - -// RegisterServiceHandler registers the http handlers for service Service to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterServiceHandlerClient(ctx, mux, NewServiceClient(conn)) -} - -// RegisterServiceHandlerClient registers the http handlers for service Service -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "ServiceClient" to call the correct interceptors. -func RegisterServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ServiceClient) error { - - mux.Handle("GET", pattern_Service_Config_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Service_Config_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Service_Config_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Service_Config_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"cosmos", "base", "node", "v2", "config"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Service_Config_0 = runtime.ForwardResponseMessage -) diff --git a/server/v2/api/grpc/nodeservice/service.go b/server/v2/api/grpc/nodeservice/service.go deleted file mode 100644 index 51f84d36142f..000000000000 --- a/server/v2/api/grpc/nodeservice/service.go +++ /dev/null @@ -1,29 +0,0 @@ -package nodeservice - -import ( - context "context" - - "cosmossdk.io/core/server" -) - -var _ ServiceServer = queryServer{} - -type queryServer struct { - cfg server.ConfigMap -} - -func NewQueryServer(cfg server.ConfigMap) ServiceServer { - return queryServer{cfg: cfg} -} - -func (s queryServer) Config(ctx context.Context, _ *ConfigRequest) (*ConfigResponse, error) { - minGasPricesStr := "" - minGasPrices, ok := s.cfg["server"].(map[string]interface{})["minimum-gas-prices"] - if ok { - minGasPricesStr = minGasPrices.(string) - } - - return &ConfigResponse{ - MinimumGasPrice: minGasPricesStr, - }, nil -} diff --git a/server/v2/api/grpc/server.go b/server/v2/api/grpc/server.go deleted file mode 100644 index 9aa06515de33..000000000000 --- a/server/v2/api/grpc/server.go +++ /dev/null @@ -1,261 +0,0 @@ -package grpc - -import ( - "context" - "errors" - "fmt" - "io" - "maps" - "net" - "slices" - "strconv" - "strings" - "sync" - - gogoproto "github.com/cosmos/gogoproto/proto" - "github.com/spf13/pflag" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/reflect/protoreflect" - - appmodulev2 "cosmossdk.io/core/appmodule/v2" - "cosmossdk.io/core/server" - "cosmossdk.io/core/transaction" - "cosmossdk.io/log" - serverv2 "cosmossdk.io/server/v2" - "cosmossdk.io/server/v2/api/grpc/gogoreflection" - "cosmossdk.io/server/v2/api/grpc/nodeservice" -) - -const ( - ServerName = "grpc" - - BlockHeightHeader = "x-cosmos-block-height" -) - -type Server[T transaction.Tx] struct { - logger log.Logger - config *Config - cfgOptions []CfgOption - - grpcSrv *grpc.Server - extraGRPCHandlers []func(*grpc.Server) error -} - -// New creates a new grpc server. -func New[T transaction.Tx]( - logger log.Logger, - interfaceRegistry server.InterfaceRegistry, - queryHandlers map[string]appmodulev2.Handler, - queryable func(ctx context.Context, version uint64, msg transaction.Msg) (transaction.Msg, error), - cfg server.ConfigMap, - opts ...OptionFunc[T], -) (*Server[T], error) { - srv := &Server[T]{} - for _, opt := range opts { - opt(srv) - } - - serverCfg := srv.Config().(*Config) - if len(cfg) > 0 { - if err := serverv2.UnmarshalSubConfig(cfg, srv.Name(), &serverCfg); err != nil { - return nil, fmt.Errorf("failed to unmarshal config: %w", err) - } - } - - grpcSrv := grpc.NewServer( - grpc.ForceServerCodec(newProtoCodec(interfaceRegistry).GRPCCodec()), - grpc.MaxSendMsgSize(serverCfg.MaxSendMsgSize), - grpc.MaxRecvMsgSize(serverCfg.MaxRecvMsgSize), - grpc.UnknownServiceHandler(makeUnknownServiceHandler(queryHandlers, queryable)), - ) - - // register grpc query handler v2 - RegisterServiceServer(grpcSrv, &v2Service{queryHandlers, queryable}) - - // register node service - nodeservice.RegisterServiceServer(grpcSrv, nodeservice.NewQueryServer(cfg)) - - // reflection allows external clients to see what services and methods the gRPC server exposes. - gogoreflection.Register(grpcSrv, slices.Collect(maps.Keys(queryHandlers)), logger.With("sub-module", "grpc-reflection")) - - // register extra handlers on the grpc server - var err error - for _, fn := range srv.extraGRPCHandlers { - err = errors.Join(err, fn(grpcSrv)) - } - if err != nil { - return nil, fmt.Errorf("failed to register extra gRPC handlers: %w", err) - } - - srv.grpcSrv = grpcSrv - srv.config = serverCfg - srv.logger = logger.With(log.ModuleKey, srv.Name()) - - return srv, nil -} - -type OptionFunc[T transaction.Tx] func(*Server[T]) - -// WithCfgOptions allows to overwrite the default server configuration. -func WithCfgOptions[T transaction.Tx](cfgOptions ...CfgOption) OptionFunc[T] { - return func(srv *Server[T]) { - srv.cfgOptions = cfgOptions - } -} - -// WithExtraGRPCHandlers allows to register extra handlers on the grpc server. -func WithExtraGRPCHandlers[T transaction.Tx](handlers ...func(*grpc.Server) error) OptionFunc[T] { - return func(srv *Server[T]) { - srv.extraGRPCHandlers = handlers - } -} - -// NewWithConfigOptions creates a new GRPC server with the provided config options. -// It is *not* a fully functional server (since it has been created without dependencies) -// The returned server should only be used to get and set configuration. -func NewWithConfigOptions[T transaction.Tx](opts ...CfgOption) *Server[T] { - return &Server[T]{ - cfgOptions: opts, - } -} - -func (s *Server[T]) StartCmdFlags() *pflag.FlagSet { - flags := pflag.NewFlagSet(s.Name(), pflag.ExitOnError) - flags.String(FlagAddress, "localhost:9090", "Listen address") - return flags -} - -func makeUnknownServiceHandler( - handlers map[string]appmodulev2.Handler, - queryable func(ctx context.Context, version uint64, msg transaction.Msg) (transaction.Msg, error), -) grpc.StreamHandler { - getRegistry := sync.OnceValues(gogoproto.MergedRegistry) - - return func(srv any, stream grpc.ServerStream) error { - method, ok := grpc.MethodFromServerStream(stream) - if !ok { - return status.Error(codes.InvalidArgument, "unable to get method") - } - // if this fails we cannot serve queries anymore... - registry, err := getRegistry() - if err != nil { - return fmt.Errorf("failed to get registry: %w", err) - } - - method = strings.TrimPrefix(method, "/") - fullName := protoreflect.FullName(strings.ReplaceAll(method, "/", ".")) - // get descriptor from the invoke method - desc, err := registry.FindDescriptorByName(fullName) - if err != nil { - return fmt.Errorf("failed to find descriptor %s: %w", method, err) - } - md, ok := desc.(protoreflect.MethodDescriptor) - if !ok { - return fmt.Errorf("%s is not a method", method) - } - // find handler - handler, exists := handlers[string(md.Input().FullName())] - if !exists { - return status.Errorf(codes.Unimplemented, "gRPC method %s is not handled", method) - } - - for { - req := handler.MakeMsg() - err := stream.RecvMsg(req) - if err != nil { - if errors.Is(err, io.EOF) { - return nil - } - return err - } - - // extract height header - ctx := stream.Context() - height, err := getHeightFromCtx(ctx) - if err != nil { - return status.Errorf(codes.InvalidArgument, "invalid get height from context: %v", err) - } - resp, err := queryable(ctx, height, req) - if err != nil { - return err - } - err = stream.SendMsg(resp) - if err != nil { - return err - } - } - } -} - -func getHeightFromCtx(ctx context.Context) (uint64, error) { - md, ok := metadata.FromIncomingContext(ctx) - if !ok { - return 0, nil - } - values := md.Get(BlockHeightHeader) - if len(values) == 0 { - return 0, nil - } - if len(values) != 1 { - return 0, fmt.Errorf("gRPC height metadata must be of length 1, got: %d", len(values)) - } - - heightStr := values[0] - height, err := strconv.ParseUint(heightStr, 10, 64) - if err != nil { - return 0, fmt.Errorf("unable to parse height string from gRPC metadata %s: %w", heightStr, err) - } - - return height, nil -} - -func (s *Server[T]) Name() string { - return ServerName -} - -func (s *Server[T]) Config() any { - if s.config == nil || s.config.Address == "" { - cfg := DefaultConfig() - // overwrite the default config with the provided options - for _, opt := range s.cfgOptions { - opt(cfg) - } - - return cfg - } - - return s.config -} - -func (s *Server[T]) Start(ctx context.Context) error { - if !s.config.Enable { - s.logger.Info(fmt.Sprintf("%s server is disabled via config", s.Name())) - return nil - } - - listener, err := (&net.ListenConfig{}).Listen(ctx, "tcp", s.config.Address) - if err != nil { - return fmt.Errorf("failed to listen on address %s: %w", s.config.Address, err) - } - - s.logger.Info("starting gRPC server...", "address", s.config.Address) - if err := s.grpcSrv.Serve(listener); err != nil { - return fmt.Errorf("failed to start gRPC server: %w", err) - } - - return nil -} - -func (s *Server[T]) Stop(ctx context.Context) error { - if !s.config.Enable { - return nil - } - - s.logger.Info("stopping gRPC server...", "address", s.config.Address) - s.grpcSrv.GracefulStop() - - return nil -} diff --git a/server/v2/cometbft/go.mod b/server/v2/cometbft/go.mod index 6fabbc3b5737..4123daf2e11d 100644 --- a/server/v2/cometbft/go.mod +++ b/server/v2/cometbft/go.mod @@ -19,9 +19,9 @@ require ( cosmossdk.io/core v1.0.0-alpha.6 cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 cosmossdk.io/log v1.5.0 - cosmossdk.io/server/v2 v2.0.0-20241108144957-78b5cd4dbd08 // main - cosmossdk.io/server/v2/appmanager v0.0.0-20241029092041-78cfc68c83af // main - cosmossdk.io/server/v2/stf v0.0.0-20241029092041-78cfc68c83af // main + cosmossdk.io/server/v2 v2.0.0-20241119134933-d697a3de0f95 // main + cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95 // main + cosmossdk.io/server/v2/stf v0.0.0-20241119134933-d697a3de0f95 // main cosmossdk.io/store/v2 v2.0.0-20241108140525-43e28b43ad7a // main cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 github.com/cometbft/cometbft v1.0.0-rc1.0.20240908111210-ab0be101882f @@ -31,19 +31,15 @@ require ( github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.9.0 -<<<<<<< HEAD - google.golang.org/protobuf v1.35.1 -======= google.golang.org/grpc v1.68.0 google.golang.org/protobuf v1.35.2 ->>>>>>> d697a3de0 (fix(server/v2/comebft): wire missing services + fix simulation (#21964)) sigs.k8s.io/yaml v1.4.0 ) require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect - cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect + cosmossdk.io/core/testing v0.0.0-20241108153815-606544c7be7e // indirect cosmossdk.io/depinject v1.1.0 // indirect cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/math v1.3.0 // indirect @@ -168,13 +164,13 @@ require ( go.etcd.io/bbolt v1.4.0-alpha.1 // indirect go.opencensus.io v0.24.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.28.0 // indirect + golang.org/x/crypto v0.29.0 // indirect golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect golang.org/x/mod v0.21.0 // indirect golang.org/x/net v0.30.0 // indirect golang.org/x/sync v0.9.0 // indirect golang.org/x/sys v0.27.0 // indirect - golang.org/x/term v0.25.0 // indirect + golang.org/x/term v0.26.0 // indirect golang.org/x/text v0.20.0 // indirect golang.org/x/tools v0.25.0 // indirect google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect diff --git a/server/v2/cometbft/go.sum b/server/v2/cometbft/go.sum index 363e35d41fc7..50ebf8120ce9 100644 --- a/server/v2/cometbft/go.sum +++ b/server/v2/cometbft/go.sum @@ -10,8 +10,8 @@ cosmossdk.io/collections v0.4.1-0.20241107084833-00f3065e70ee h1:OLqvi9ekfShobmd cosmossdk.io/collections v0.4.1-0.20241107084833-00f3065e70ee/go.mod h1:DcD++Yfcq0OFtM3CJNYLIBjfZ+4DEyeJ/AUk6gkwlOE= cosmossdk.io/core v1.0.0-alpha.6 h1:5ukC4JcQKmemLQXcAgu/QoOvJI50hpBkIIg4ZT2EN8E= cosmossdk.io/core v1.0.0-alpha.6/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY= -cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 h1:NxxUo0GMJUbIuVg0R70e3cbn9eFTEuMr7ev1AFvypdY= -cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29/go.mod h1:8s2tPeJtSiQuoyPmr2Ag7meikonISO4Fv4MoO8+ORrs= +cosmossdk.io/core/testing v0.0.0-20241108153815-606544c7be7e h1:F+ScucYxwrrDJU8guJXQXpGhdpziYSbxW6HMP2wCNxs= +cosmossdk.io/core/testing v0.0.0-20241108153815-606544c7be7e/go.mod h1:3YvVv9aJayjPhdX0DY1IMrGse4sR63hNBWx2VtDWjGQ= cosmossdk.io/depinject v1.1.0 h1:wLan7LG35VM7Yo6ov0jId3RHWCGRhe8E8bsuARorl5E= cosmossdk.io/depinject v1.1.0/go.mod h1:kkI5H9jCGHeKeYWXTqYdruogYrEeWvBQCw1Pj4/eCFI= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= @@ -24,12 +24,12 @@ cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac h1:3joNZZWZ3k7fMsrBDL1ktuQ2xQwYLZOaDhkruadDFmc= cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ= -cosmossdk.io/server/v2 v2.0.0-20241108144957-78b5cd4dbd08 h1:hmTWRUEaRvaZhFhgC/Bd7z/6Rhn+It/3Fja3lECIOHQ= -cosmossdk.io/server/v2 v2.0.0-20241108144957-78b5cd4dbd08/go.mod h1:OecMMKlPdlFp2PxqV/capqhUhbIDaa5OiNkY1v5hi8c= -cosmossdk.io/server/v2/appmanager v0.0.0-20241029092041-78cfc68c83af h1:uDQXvGBH3kZW1UXFccMlNCgHf2L5QCGjNmw51q6atzI= -cosmossdk.io/server/v2/appmanager v0.0.0-20241029092041-78cfc68c83af/go.mod h1:mONOF8GRbxs5R04zMscuQQI1gx/XHTY7imKjcwLI5uo= -cosmossdk.io/server/v2/stf v0.0.0-20241029092041-78cfc68c83af h1:jefP4LTtln0XsXHeSqRENeAGyPQ9qSbGHMy6811FE/c= -cosmossdk.io/server/v2/stf v0.0.0-20241029092041-78cfc68c83af/go.mod h1:npAiRkgEOigiBlWyLhwTucbzghItNAIPm2eYWSHG/cI= +cosmossdk.io/server/v2 v2.0.0-20241119134933-d697a3de0f95 h1:WUho1r7Zcg5aPn5YtYRN5TW9fvxUirX1mSihBDJ6ccg= +cosmossdk.io/server/v2 v2.0.0-20241119134933-d697a3de0f95/go.mod h1:gPATMrgLSzDoJiyoY+N8ULwfvAJ3Ooh6TYFsW60tHW0= +cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95 h1:GOznErJieaI0OS0LDUsu5Vy3qPnCyjdvkncejP0Zv5s= +cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95/go.mod h1:elhlrldWtm+9U4PxE0G3wjz83yQwVVGVAOncXJPY1Xc= +cosmossdk.io/server/v2/stf v0.0.0-20241119134933-d697a3de0f95 h1:cK7wvmlA18AvLcaInseKTBmt5EXtLwafe7oH1rx7veU= +cosmossdk.io/server/v2/stf v0.0.0-20241119134933-d697a3de0f95/go.mod h1:4e9SzLyeGptQ3tSR6nKCNwCu7Ye4uUS2WIJih29dG2c= cosmossdk.io/store v1.0.0-rc.0.0.20241108140525-43e28b43ad7a h1:5ENKFUhhJPkpx6dGDmc0/LXinjE3oIQDEES9gVVA4xM= cosmossdk.io/store v1.0.0-rc.0.0.20241108140525-43e28b43ad7a/go.mod h1:pjNPBX9giCOI18kf3mgNtn4J3SFaZbV1mAmM58iHdgg= cosmossdk.io/store/v2 v2.0.0-20241108140525-43e28b43ad7a h1:3SB9LPBiLuy8pCUPgfFtCP9I4wYKYajxv5vssyO5YEs= @@ -546,8 +546,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= -golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= +golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= +golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk= golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY= @@ -630,8 +630,8 @@ golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= -golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU= +golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -697,8 +697,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= -google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= +google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/server/v2/go.mod b/server/v2/go.mod deleted file mode 100644 index cc692130a346..000000000000 --- a/server/v2/go.mod +++ /dev/null @@ -1,120 +0,0 @@ -module cosmossdk.io/server/v2 - -go 1.23 - -replace ( - cosmossdk.io/api => ../../api - cosmossdk.io/server/v2/appmanager => ./appmanager - cosmossdk.io/server/v2/stf => ./stf - cosmossdk.io/store/v2 => ../../store/v2 - cosmossdk.io/store/v2/db => ../../store/v2/db - cosmossdk.io/x/tx => ../../x/tx -) - -require ( - cosmossdk.io/api v0.7.6 - cosmossdk.io/core v1.0.0-alpha.6 - cosmossdk.io/core/testing v0.0.0-20241108153815-606544c7be7e - cosmossdk.io/log v1.5.0 - cosmossdk.io/server/v2/appmanager v0.0.0-00010101000000-000000000000 - cosmossdk.io/store/v2 v2.0.0-00010101000000-000000000000 - github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/gogogateway v1.2.0 - github.com/cosmos/gogoproto v1.7.0 - github.com/golang/protobuf v1.5.4 - github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/hashicorp/go-hclog v1.6.3 - github.com/hashicorp/go-metrics v0.5.3 - github.com/hashicorp/go-plugin v1.6.2 - github.com/mitchellh/mapstructure v1.5.0 - github.com/pelletier/go-toml/v2 v2.2.2 - github.com/prometheus/client_golang v1.20.5 - github.com/prometheus/common v0.60.1 - github.com/rs/zerolog v1.33.0 - github.com/spf13/cobra v1.8.1 - github.com/spf13/pflag v1.0.5 - github.com/spf13/viper v1.19.0 - github.com/stretchr/testify v1.9.0 - google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 - google.golang.org/grpc v1.68.0 - google.golang.org/protobuf v1.35.2 -) - -require ( - cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect - cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac // indirect - github.com/DataDog/datadog-go v4.8.3+incompatible // indirect - github.com/DataDog/zstd v1.5.5 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/beorn7/perks v1.0.1 // indirect - github.com/bytedance/sonic v1.12.4 // indirect - github.com/bytedance/sonic/loader v0.2.1 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/cloudwego/base64x v0.1.4 // indirect - github.com/cloudwego/iasm v0.2.0 // indirect - github.com/cockroachdb/errors v1.11.1 // indirect - github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/pebble v1.1.0 // indirect - github.com/cockroachdb/redact v1.1.5 // indirect - github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect - github.com/cosmos/iavl v1.3.1 // indirect - github.com/cosmos/ics23/go v0.11.0 // indirect - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/emicklei/dot v1.6.2 // indirect - github.com/fatih/color v1.18.0 // indirect - github.com/fsnotify/fsnotify v1.8.0 // indirect - github.com/getsentry/sentry-go v0.27.0 // indirect - github.com/gogo/googleapis v1.4.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/snappy v0.0.4 // indirect - github.com/google/btree v1.1.2 // indirect - github.com/google/go-cmp v0.6.0 // indirect - github.com/hashicorp/go-immutable-radix v1.3.1 // indirect - github.com/hashicorp/golang-lru v1.0.2 // indirect - github.com/hashicorp/hcl v1.0.0 // indirect - github.com/hashicorp/yamux v0.1.2 // indirect - github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/jhump/protoreflect v1.17.0 // indirect - github.com/klauspost/compress v1.17.9 // indirect - github.com/klauspost/cpuid/v2 v2.2.9 // indirect - github.com/kr/pretty v0.3.1 // indirect - github.com/kr/text v0.2.0 // indirect - github.com/linxGnu/grocksdb v1.9.3 // indirect - github.com/magiconair/properties v1.8.7 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-sqlite3 v1.14.22 // indirect - github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/oklog/run v1.1.0 // indirect - github.com/onsi/gomega v1.28.1 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/procfs v0.15.1 // indirect - github.com/rogpeppe/go-internal v1.12.0 // indirect - github.com/sagikazarmark/locafero v0.4.0 // indirect - github.com/sagikazarmark/slog-shim v0.1.0 // indirect - github.com/sourcegraph/conc v0.3.0 // indirect - github.com/spf13/afero v1.11.0 // indirect - github.com/spf13/cast v1.7.0 // indirect - github.com/stretchr/objx v0.5.2 // indirect - github.com/subosito/gotenv v1.6.0 // indirect - github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect - github.com/tendermint/go-amino v0.16.0 // indirect - github.com/tidwall/btree v1.7.0 // indirect - github.com/twitchyliquid64/golang-asm v0.15.1 // indirect - go.uber.org/multierr v1.11.0 // indirect - golang.org/x/arch v0.12.0 // indirect - golang.org/x/crypto v0.29.0 // indirect - golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect - golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.30.0 // indirect - golang.org/x/sync v0.9.0 // indirect - golang.org/x/sys v0.27.0 // indirect - golang.org/x/text v0.20.0 // indirect - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect - google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect - gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/server/v2/stf/branch/mergeiter.go b/server/v2/stf/branch/mergeiter.go deleted file mode 100644 index 22e6320890ba..000000000000 --- a/server/v2/stf/branch/mergeiter.go +++ /dev/null @@ -1,166 +0,0 @@ -package branch - -import ( - "bytes" - "errors" - - corestore "cosmossdk.io/core/store" -) - -var errInvalidIterator = errors.New("invalid iterator") - -// mergedIterator merges a parent Iterator and a child Iterator. -// The child iterator may contain items that shadow or override items in the parent iterator. -// If the child iterator has the same key as the parent, the child's value takes precedence. -// Deleted items in the child (indicated by nil values) are skipped. -type mergedIterator[Parent, Child corestore.Iterator] struct { - parent Parent // Iterator for the parent store - child Child // Iterator for the child store - ascending bool // Direction of iteration - valid bool // Indicates if the iterator is in a valid state - currKey []byte // Current key pointed by the iterator - currValue []byte // Current value corresponding to currKey - err error // Error encountered during iteration -} - -// Ensure mergedIterator implements the corestore.Iterator interface. -var _ corestore.Iterator = (*mergedIterator[corestore.Iterator, corestore.Iterator])(nil) - -// mergeIterators creates a new merged iterator from parent and child iterators. -// The 'ascending' parameter determines the direction of iteration. -func mergeIterators[Parent, Child corestore.Iterator](parent Parent, child Child, ascending bool) *mergedIterator[Parent, Child] { - iter := &mergedIterator[Parent, Child]{ - parent: parent, - child: child, - ascending: ascending, - } - iter.advance() // Initialize the iterator by advancing to the first valid item - return iter -} - -// Domain returns the start and end range of the iterator. -// It delegates to the parent iterator as both iterators share the same domain. -func (i *mergedIterator[Parent, Child]) Domain() (start, end []byte) { - return i.parent.Domain() -} - -// Valid checks if the iterator is in a valid state. -// It returns true if the iterator has not reached the end. -func (i *mergedIterator[Parent, Child]) Valid() bool { - return i.valid -} - -// Next advances the iterator to the next valid item. -// It skips over deleted items (with nil values) and updates the current key and value. -func (i *mergedIterator[Parent, Child]) Next() { - if !i.valid { - i.err = errInvalidIterator - return - } - i.advance() -} - -// Key returns the current key pointed by the iterator. -// If the iterator is invalid, it returns nil. -func (i *mergedIterator[Parent, Child]) Key() []byte { - if !i.valid { - panic("called key on invalid iterator") - } - return i.currKey -} - -// Value returns the current value corresponding to the current key. -// If the iterator is invalid, it returns nil. -func (i *mergedIterator[Parent, Child]) Value() []byte { - if !i.valid { - panic("called value on invalid iterator") - } - return i.currValue -} - -// Close closes both the parent and child iterators. -// It returns any error encountered during the closing of the iterators. -func (i *mergedIterator[Parent, Child]) Close() (err error) { - err = errors.Join(err, i.parent.Close()) - err = errors.Join(err, i.child.Close()) - i.valid = false - return err -} - -// Error returns any error that occurred during iteration. -// If the iterator is valid, it returns nil. -func (i *mergedIterator[Parent, Child]) Error() error { - return i.err -} - -// advance moves the iterator to the next valid (non-deleted) item. -// It handles merging logic between the parent and child iterators. -func (i *mergedIterator[Parent, Child]) advance() { - for { - // Check if both iterators have reached the end - if !i.parent.Valid() && !i.child.Valid() { - i.valid = false - return - } - - var key, value []byte - - // If parent iterator is exhausted, use the child iterator - if !i.parent.Valid() { - key = i.child.Key() - value = i.child.Value() - i.child.Next() - } else if !i.child.Valid() { - // If child iterator is exhausted, use the parent iterator - key = i.parent.Key() - value = i.parent.Value() - i.parent.Next() - } else { - // Both iterators are valid; compare keys - keyP, keyC := i.parent.Key(), i.child.Key() - switch cmp := i.compare(keyP, keyC); { - case cmp < 0: - // Parent key is less than child key - key = keyP - value = i.parent.Value() - i.parent.Next() - case cmp == 0: - // Keys are equal; child overrides parent - key = keyC - value = i.child.Value() - i.parent.Next() - i.child.Next() - case cmp > 0: - // Child key is less than parent key - key = keyC - value = i.child.Value() - i.child.Next() - } - } - - // Skip deleted items (value is nil) - if value == nil { - continue - } - - // Update the current key and value, and mark iterator as valid - i.currKey = key - i.currValue = value - i.valid = true - return - } -} - -// compare compares two byte slices a and b. -// It returns an integer comparing a and b: -// - Negative if a < b -// - Zero if a == b -// - Positive if a > b -// -// The comparison respects the iterator's direction (ascending or descending). -func (i *mergedIterator[Parent, Child]) compare(a, b []byte) int { - if i.ascending { - return bytes.Compare(a, b) - } - return bytes.Compare(b, a) -} diff --git a/simapp/v2/go.mod b/simapp/v2/go.mod index 8753ab648969..1bd12b00662d 100644 --- a/simapp/v2/go.mod +++ b/simapp/v2/go.mod @@ -6,12 +6,12 @@ require ( cosmossdk.io/api v0.8.0 // main cosmossdk.io/client/v2 v2.0.0-00010101000000-000000000000 cosmossdk.io/core v1.0.0 // main - cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect; main + cosmossdk.io/core/testing v0.0.0 // indirect; main cosmossdk.io/depinject v1.1.0 cosmossdk.io/log v1.5.0 cosmossdk.io/math v1.3.0 - cosmossdk.io/runtime/v2 v2.0.0-20241105073932-55f7cfcebae4 // main - cosmossdk.io/server/v2 v2.0.0-20241108144957-78b5cd4dbd08 // main + cosmossdk.io/runtime/v2 v2.0.0-20241119134933-d697a3de0f95 // main + cosmossdk.io/server/v2 v2.0.0-20241119134933-d697a3de0f95 // main cosmossdk.io/server/v2/cometbft v0.0.0-00010101000000-000000000000 cosmossdk.io/store/v2 v2.0.0-20241108144957-78b5cd4dbd08 // main cosmossdk.io/tools/confix v0.0.0-00010101000000-000000000000 @@ -40,7 +40,7 @@ require ( github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.9.0 - google.golang.org/protobuf v1.35.1 + google.golang.org/protobuf v1.35.2 ) require ( @@ -72,8 +72,8 @@ require ( cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac // indirect - cosmossdk.io/server/v2/appmanager v0.0.0-20241029092041-78cfc68c83af // indirect; main - cosmossdk.io/server/v2/stf v0.0.0-20241029092041-78cfc68c83af // indirect; main + cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95 // indirect; main + cosmossdk.io/server/v2/stf v0.0.0-20241119134933-d697a3de0f95 // indirect; main cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6 // indirect; main cosmossdk.io/x/tx v1.0.0-alpha.2 // indirect; main filippo.io/edwards25519 v1.1.0 // indirect @@ -226,14 +226,14 @@ require ( go.opentelemetry.io/otel/metric v1.27.0 // indirect go.opentelemetry.io/otel/trace v1.27.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.28.0 // indirect + golang.org/x/crypto v0.29.0 // indirect golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect golang.org/x/mod v0.21.0 // indirect golang.org/x/net v0.30.0 // indirect golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/sync v0.9.0 // indirect golang.org/x/sys v0.27.0 // indirect - golang.org/x/term v0.25.0 // indirect + golang.org/x/term v0.26.0 // indirect golang.org/x/text v0.20.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.25.0 // indirect @@ -259,13 +259,14 @@ require ( // SimApp on main always tests the latest extracted SDK modules importing the sdk replace ( // pseudo version lower than the latest tag - cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20241111180559-13c234f421e8 // main + cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20241119134933-d697a3de0f95 // main cosmossdk.io/client/v2 => ../../client/v2 // pseudo version lower than the latest tag cosmossdk.io/core => cosmossdk.io/core v1.0.0-alpha.6 // main + cosmossdk.io/core/testing => cosmossdk.io/core/testing v0.0.0-20241119134933-d697a3de0f95 // main cosmossdk.io/server/v2/cometbft => ../../server/v2/cometbft // pseudo version lower than the latest tag - cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20241108140525-43e28b43ad7a // main + cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20241119134933-d697a3de0f95 // main cosmossdk.io/tools/confix => ../../tools/confix cosmossdk.io/x/accounts => ../../x/accounts cosmossdk.io/x/accounts/defaults/base => ../../x/accounts/defaults/base diff --git a/simapp/v2/go.sum b/simapp/v2/go.sum index 91a60737fe16..910579cfe97e 100644 --- a/simapp/v2/go.sum +++ b/simapp/v2/go.sum @@ -192,14 +192,14 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= -cosmossdk.io/api v0.7.3-0.20241111180559-13c234f421e8 h1:g7SXTjhuNCfu3ovpfI5xUraWOAyUDLMpFZnO0QE2XrE= -cosmossdk.io/api v0.7.3-0.20241111180559-13c234f421e8/go.mod h1:pPUWNdsU8ghYzPOeVD2sAzPVh2yniq215XjRYubdO4I= +cosmossdk.io/api v0.7.3-0.20241119134933-d697a3de0f95 h1:nkbou1MO8ho3i+MJ+yehGTqaxGCC/L+sc+7sEAzBy0Y= +cosmossdk.io/api v0.7.3-0.20241119134933-d697a3de0f95/go.mod h1:9XEDkRZgZGm1XxHL7Sj2DMXZurCk1pY4x06eR5wyfM0= cosmossdk.io/collections v0.4.1-0.20241107084833-00f3065e70ee h1:OLqvi9ekfShobmdgr4Q/8pu+LjzYJSrNl9tiadPg2xY= cosmossdk.io/collections v0.4.1-0.20241107084833-00f3065e70ee/go.mod h1:DcD++Yfcq0OFtM3CJNYLIBjfZ+4DEyeJ/AUk6gkwlOE= cosmossdk.io/core v1.0.0-alpha.6 h1:5ukC4JcQKmemLQXcAgu/QoOvJI50hpBkIIg4ZT2EN8E= cosmossdk.io/core v1.0.0-alpha.6/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY= -cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 h1:NxxUo0GMJUbIuVg0R70e3cbn9eFTEuMr7ev1AFvypdY= -cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29/go.mod h1:8s2tPeJtSiQuoyPmr2Ag7meikonISO4Fv4MoO8+ORrs= +cosmossdk.io/core/testing v0.0.0-20241119134933-d697a3de0f95 h1:2WlnVICuVVx8AY70ueEHyfHJ8ctjFU9RnJsz4U263Fw= +cosmossdk.io/core/testing v0.0.0-20241119134933-d697a3de0f95/go.mod h1:MJc850tGHoH50R6hC3FSaZvHJDcWWrP+mErk6SaDD4A= cosmossdk.io/depinject v1.1.0 h1:wLan7LG35VM7Yo6ov0jId3RHWCGRhe8E8bsuARorl5E= cosmossdk.io/depinject v1.1.0/go.mod h1:kkI5H9jCGHeKeYWXTqYdruogYrEeWvBQCw1Pj4/eCFI= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= @@ -210,18 +210,18 @@ cosmossdk.io/log v1.5.0 h1:dVdzPJW9kMrnAYyMf1duqacoidB9uZIl+7c6z0mnq0g= cosmossdk.io/log v1.5.0/go.mod h1:Tr46PUJjiUthlwQ+hxYtUtPn4D/oCZXAkYevBeh5+FI= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= -cosmossdk.io/runtime/v2 v2.0.0-20241105073932-55f7cfcebae4 h1:uo4LBzsp1bIZ3rBUyo1V0ON7WMhQ50+HtcLPwgABQLQ= -cosmossdk.io/runtime/v2 v2.0.0-20241105073932-55f7cfcebae4/go.mod h1:SCdBCUiZGKVFNUvglrCUontMZSoXAES5iMbRvPv8bsI= +cosmossdk.io/runtime/v2 v2.0.0-20241119134933-d697a3de0f95 h1:hYI7pvrmdkgFZJ4HVQow7ubopsTmleYet4S56tFMdI0= +cosmossdk.io/runtime/v2 v2.0.0-20241119134933-d697a3de0f95/go.mod h1:J4Wv2eOwAz8t14Ak8XBMWDoFbwqwyllMaJF91O7n/wI= cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac h1:3joNZZWZ3k7fMsrBDL1ktuQ2xQwYLZOaDhkruadDFmc= cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ= -cosmossdk.io/server/v2 v2.0.0-20241108144957-78b5cd4dbd08 h1:hmTWRUEaRvaZhFhgC/Bd7z/6Rhn+It/3Fja3lECIOHQ= -cosmossdk.io/server/v2 v2.0.0-20241108144957-78b5cd4dbd08/go.mod h1:OecMMKlPdlFp2PxqV/capqhUhbIDaa5OiNkY1v5hi8c= -cosmossdk.io/server/v2/appmanager v0.0.0-20241029092041-78cfc68c83af h1:uDQXvGBH3kZW1UXFccMlNCgHf2L5QCGjNmw51q6atzI= -cosmossdk.io/server/v2/appmanager v0.0.0-20241029092041-78cfc68c83af/go.mod h1:mONOF8GRbxs5R04zMscuQQI1gx/XHTY7imKjcwLI5uo= -cosmossdk.io/server/v2/stf v0.0.0-20241029092041-78cfc68c83af h1:jefP4LTtln0XsXHeSqRENeAGyPQ9qSbGHMy6811FE/c= -cosmossdk.io/server/v2/stf v0.0.0-20241029092041-78cfc68c83af/go.mod h1:npAiRkgEOigiBlWyLhwTucbzghItNAIPm2eYWSHG/cI= -cosmossdk.io/store v1.0.0-rc.0.0.20241108140525-43e28b43ad7a h1:5ENKFUhhJPkpx6dGDmc0/LXinjE3oIQDEES9gVVA4xM= -cosmossdk.io/store v1.0.0-rc.0.0.20241108140525-43e28b43ad7a/go.mod h1:pjNPBX9giCOI18kf3mgNtn4J3SFaZbV1mAmM58iHdgg= +cosmossdk.io/server/v2 v2.0.0-20241119134933-d697a3de0f95 h1:WUho1r7Zcg5aPn5YtYRN5TW9fvxUirX1mSihBDJ6ccg= +cosmossdk.io/server/v2 v2.0.0-20241119134933-d697a3de0f95/go.mod h1:gPATMrgLSzDoJiyoY+N8ULwfvAJ3Ooh6TYFsW60tHW0= +cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95 h1:GOznErJieaI0OS0LDUsu5Vy3qPnCyjdvkncejP0Zv5s= +cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95/go.mod h1:elhlrldWtm+9U4PxE0G3wjz83yQwVVGVAOncXJPY1Xc= +cosmossdk.io/server/v2/stf v0.0.0-20241119134933-d697a3de0f95 h1:cK7wvmlA18AvLcaInseKTBmt5EXtLwafe7oH1rx7veU= +cosmossdk.io/server/v2/stf v0.0.0-20241119134933-d697a3de0f95/go.mod h1:4e9SzLyeGptQ3tSR6nKCNwCu7Ye4uUS2WIJih29dG2c= +cosmossdk.io/store v1.0.0-rc.0.0.20241119134933-d697a3de0f95 h1:5hIgRL6VsicdJ7FVK6AG7cSy1C8tiVbCp6W3Y+QQ5ko= +cosmossdk.io/store v1.0.0-rc.0.0.20241119134933-d697a3de0f95/go.mod h1:ceNwMZIU8ZIDoeUdA9+sGxz3GVt0orEGoVpkBfa/UtU= cosmossdk.io/store/v2 v2.0.0-20241108144957-78b5cd4dbd08 h1:7dIhcS/VhEM/vnZWDVtDKqCF/OGaq8Gx+5ekD9GT71k= cosmossdk.io/store/v2 v2.0.0-20241108144957-78b5cd4dbd08/go.mod h1:A2aW375561viy3GcD8GhUwUWnow+R2Du6yCSpAGwsgY= cosmossdk.io/x/tx v1.0.0-alpha.2 h1:UW80FMm7B0fiAMsrfe5+HabSJ3XBg+tQa6/GK9prqWk= @@ -901,8 +901,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= -golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= +golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= +golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1127,8 +1127,8 @@ golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= -golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU= +golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1434,8 +1434,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= -google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= +google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 9876a37bba5f850ab0c4364e30577e848bb721da Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Tue, 19 Nov 2024 16:11:12 +0100 Subject: [PATCH 3/4] `make mocks` --- x/protocolpool/testutil/expected_keepers_mocks.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/protocolpool/testutil/expected_keepers_mocks.go b/x/protocolpool/testutil/expected_keepers_mocks.go index 56f2feff014f..358fcad30bef 100644 --- a/x/protocolpool/testutil/expected_keepers_mocks.go +++ b/x/protocolpool/testutil/expected_keepers_mocks.go @@ -138,7 +138,7 @@ func (m *MockBankKeeper) GetBalance(ctx context.Context, addr types.AccAddress, } // GetBalance indicates an expected call of GetBalance. -func (mr *MockBankKeeperMockRecorder) GetBalance(ctx, addr, denom any) *gomock.Call { +func (mr *MockBankKeeperMockRecorder) GetBalance(ctx, addr, denom interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBalance", reflect.TypeOf((*MockBankKeeper)(nil).GetBalance), ctx, addr, denom) } @@ -197,4 +197,4 @@ func (m *MockBankKeeper) SpendableCoins(ctx context.Context, addr types.AccAddre func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpendableCoins", reflect.TypeOf((*MockBankKeeper)(nil).SpendableCoins), ctx, addr) -} \ No newline at end of file +} From 92903e393ab09a5ccd370bcebae1714632d6b0b2 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Tue, 19 Nov 2024 16:11:44 +0100 Subject: [PATCH 4/4] delete api --- api/cosmos/base/node/v2/query.pulsar.go | 981 ----------------------- api/cosmos/base/node/v2/query_grpc.pb.go | 127 --- 2 files changed, 1108 deletions(-) delete mode 100644 api/cosmos/base/node/v2/query.pulsar.go delete mode 100644 api/cosmos/base/node/v2/query_grpc.pb.go diff --git a/api/cosmos/base/node/v2/query.pulsar.go b/api/cosmos/base/node/v2/query.pulsar.go deleted file mode 100644 index e4039ccde48b..000000000000 --- a/api/cosmos/base/node/v2/query.pulsar.go +++ /dev/null @@ -1,981 +0,0 @@ -// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. -package nodev2 - -import ( - fmt "fmt" - runtime "github.com/cosmos/cosmos-proto/runtime" - _ "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_ConfigRequest protoreflect.MessageDescriptor -) - -func init() { - file_cosmos_base_node_v2_query_proto_init() - md_ConfigRequest = File_cosmos_base_node_v2_query_proto.Messages().ByName("ConfigRequest") -} - -var _ protoreflect.Message = (*fastReflection_ConfigRequest)(nil) - -type fastReflection_ConfigRequest ConfigRequest - -func (x *ConfigRequest) ProtoReflect() protoreflect.Message { - return (*fastReflection_ConfigRequest)(x) -} - -func (x *ConfigRequest) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_base_node_v2_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_ConfigRequest_messageType fastReflection_ConfigRequest_messageType -var _ protoreflect.MessageType = fastReflection_ConfigRequest_messageType{} - -type fastReflection_ConfigRequest_messageType struct{} - -func (x fastReflection_ConfigRequest_messageType) Zero() protoreflect.Message { - return (*fastReflection_ConfigRequest)(nil) -} -func (x fastReflection_ConfigRequest_messageType) New() protoreflect.Message { - return new(fastReflection_ConfigRequest) -} -func (x fastReflection_ConfigRequest_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_ConfigRequest -} - -// Descriptor returns message descriptor, which contains only the protobuf -// type information for the message. -func (x *fastReflection_ConfigRequest) Descriptor() protoreflect.MessageDescriptor { - return md_ConfigRequest -} - -// 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_ConfigRequest) Type() protoreflect.MessageType { - return _fastReflection_ConfigRequest_messageType -} - -// New returns a newly allocated and mutable empty message. -func (x *fastReflection_ConfigRequest) New() protoreflect.Message { - return new(fastReflection_ConfigRequest) -} - -// Interface unwraps the message reflection interface and -// returns the underlying ProtoMessage interface. -func (x *fastReflection_ConfigRequest) Interface() protoreflect.ProtoMessage { - return (*ConfigRequest)(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_ConfigRequest) 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_ConfigRequest) Has(fd protoreflect.FieldDescriptor) bool { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigRequest")) - } - panic(fmt.Errorf("message cosmos.base.node.v2.ConfigRequest 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_ConfigRequest) Clear(fd protoreflect.FieldDescriptor) { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigRequest")) - } - panic(fmt.Errorf("message cosmos.base.node.v2.ConfigRequest 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_ConfigRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { - switch descriptor.FullName() { - default: - if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigRequest")) - } - panic(fmt.Errorf("message cosmos.base.node.v2.ConfigRequest 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_ConfigRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigRequest")) - } - panic(fmt.Errorf("message cosmos.base.node.v2.ConfigRequest 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_ConfigRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigRequest")) - } - panic(fmt.Errorf("message cosmos.base.node.v2.ConfigRequest 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_ConfigRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigRequest")) - } - panic(fmt.Errorf("message cosmos.base.node.v2.ConfigRequest 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_ConfigRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - switch d.FullName() { - default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.base.node.v2.ConfigRequest", 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_ConfigRequest) 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_ConfigRequest) 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_ConfigRequest) 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_ConfigRequest) ProtoMethods() *protoiface.Methods { - size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*ConfigRequest) - 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().(*ConfigRequest) - 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().(*ConfigRequest) - 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: ConfigRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ConfigRequest: 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_ConfigResponse protoreflect.MessageDescriptor - fd_ConfigResponse_minimum_gas_price protoreflect.FieldDescriptor -) - -func init() { - file_cosmos_base_node_v2_query_proto_init() - md_ConfigResponse = File_cosmos_base_node_v2_query_proto.Messages().ByName("ConfigResponse") - fd_ConfigResponse_minimum_gas_price = md_ConfigResponse.Fields().ByName("minimum_gas_price") -} - -var _ protoreflect.Message = (*fastReflection_ConfigResponse)(nil) - -type fastReflection_ConfigResponse ConfigResponse - -func (x *ConfigResponse) ProtoReflect() protoreflect.Message { - return (*fastReflection_ConfigResponse)(x) -} - -func (x *ConfigResponse) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_base_node_v2_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_ConfigResponse_messageType fastReflection_ConfigResponse_messageType -var _ protoreflect.MessageType = fastReflection_ConfigResponse_messageType{} - -type fastReflection_ConfigResponse_messageType struct{} - -func (x fastReflection_ConfigResponse_messageType) Zero() protoreflect.Message { - return (*fastReflection_ConfigResponse)(nil) -} -func (x fastReflection_ConfigResponse_messageType) New() protoreflect.Message { - return new(fastReflection_ConfigResponse) -} -func (x fastReflection_ConfigResponse_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_ConfigResponse -} - -// Descriptor returns message descriptor, which contains only the protobuf -// type information for the message. -func (x *fastReflection_ConfigResponse) Descriptor() protoreflect.MessageDescriptor { - return md_ConfigResponse -} - -// 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_ConfigResponse) Type() protoreflect.MessageType { - return _fastReflection_ConfigResponse_messageType -} - -// New returns a newly allocated and mutable empty message. -func (x *fastReflection_ConfigResponse) New() protoreflect.Message { - return new(fastReflection_ConfigResponse) -} - -// Interface unwraps the message reflection interface and -// returns the underlying ProtoMessage interface. -func (x *fastReflection_ConfigResponse) Interface() protoreflect.ProtoMessage { - return (*ConfigResponse)(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_ConfigResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.MinimumGasPrice != "" { - value := protoreflect.ValueOfString(x.MinimumGasPrice) - if !f(fd_ConfigResponse_minimum_gas_price, 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_ConfigResponse) Has(fd protoreflect.FieldDescriptor) bool { - switch fd.FullName() { - case "cosmos.base.node.v2.ConfigResponse.minimum_gas_price": - return x.MinimumGasPrice != "" - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigResponse")) - } - panic(fmt.Errorf("message cosmos.base.node.v2.ConfigResponse 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_ConfigResponse) Clear(fd protoreflect.FieldDescriptor) { - switch fd.FullName() { - case "cosmos.base.node.v2.ConfigResponse.minimum_gas_price": - x.MinimumGasPrice = "" - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigResponse")) - } - panic(fmt.Errorf("message cosmos.base.node.v2.ConfigResponse 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_ConfigResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { - switch descriptor.FullName() { - case "cosmos.base.node.v2.ConfigResponse.minimum_gas_price": - value := x.MinimumGasPrice - return protoreflect.ValueOfString(value) - default: - if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigResponse")) - } - panic(fmt.Errorf("message cosmos.base.node.v2.ConfigResponse 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_ConfigResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { - switch fd.FullName() { - case "cosmos.base.node.v2.ConfigResponse.minimum_gas_price": - x.MinimumGasPrice = value.Interface().(string) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigResponse")) - } - panic(fmt.Errorf("message cosmos.base.node.v2.ConfigResponse 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_ConfigResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.base.node.v2.ConfigResponse.minimum_gas_price": - panic(fmt.Errorf("field minimum_gas_price of message cosmos.base.node.v2.ConfigResponse is not mutable")) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigResponse")) - } - panic(fmt.Errorf("message cosmos.base.node.v2.ConfigResponse 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_ConfigResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.base.node.v2.ConfigResponse.minimum_gas_price": - return protoreflect.ValueOfString("") - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.node.v2.ConfigResponse")) - } - panic(fmt.Errorf("message cosmos.base.node.v2.ConfigResponse 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_ConfigResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - switch d.FullName() { - default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.base.node.v2.ConfigResponse", 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_ConfigResponse) 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_ConfigResponse) 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_ConfigResponse) 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_ConfigResponse) ProtoMethods() *protoiface.Methods { - size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*ConfigResponse) - 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.MinimumGasPrice) - 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().(*ConfigResponse) - 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.MinimumGasPrice) > 0 { - i -= len(x.MinimumGasPrice) - copy(dAtA[i:], x.MinimumGasPrice) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.MinimumGasPrice))) - 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().(*ConfigResponse) - 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: ConfigResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ConfigResponse: 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 MinimumGasPrice", 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.MinimumGasPrice = 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: cosmos/base/node/v2/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) -) - -// ConfigRequest defines the request structure for the Config gRPC query. -type ConfigRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *ConfigRequest) Reset() { - *x = ConfigRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_base_node_v2_query_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ConfigRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ConfigRequest) ProtoMessage() {} - -// Deprecated: Use ConfigRequest.ProtoReflect.Descriptor instead. -func (*ConfigRequest) Descriptor() ([]byte, []int) { - return file_cosmos_base_node_v2_query_proto_rawDescGZIP(), []int{0} -} - -// ConfigResponse defines the response structure for the Config gRPC query. -type ConfigResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - MinimumGasPrice string `protobuf:"bytes,1,opt,name=minimum_gas_price,json=minimumGasPrice,proto3" json:"minimum_gas_price,omitempty"` -} - -func (x *ConfigResponse) Reset() { - *x = ConfigResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_base_node_v2_query_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ConfigResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ConfigResponse) ProtoMessage() {} - -// Deprecated: Use ConfigResponse.ProtoReflect.Descriptor instead. -func (*ConfigResponse) Descriptor() ([]byte, []int) { - return file_cosmos_base_node_v2_query_proto_rawDescGZIP(), []int{1} -} - -func (x *ConfigResponse) GetMinimumGasPrice() string { - if x != nil { - return x.MinimumGasPrice - } - return "" -} - -var File_cosmos_base_node_v2_query_proto protoreflect.FileDescriptor - -var file_cosmos_base_node_v2_query_proto_rawDesc = []byte{ - 0x0a, 0x1f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x6e, 0x6f, - 0x64, 0x65, 0x2f, 0x76, 0x32, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x13, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x6e, - 0x6f, 0x64, 0x65, 0x2e, 0x76, 0x32, 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, 0x22, 0x0f, 0x0a, 0x0d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x3c, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x11, 0x6d, 0x69, 0x6e, 0x69, 0x6d, - 0x75, 0x6d, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0f, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x47, 0x61, 0x73, 0x50, 0x72, - 0x69, 0x63, 0x65, 0x32, 0x81, 0x01, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x76, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x22, 0x2e, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x76, 0x32, 0x2e, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, - 0x2e, 0x76, 0x32, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x23, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1d, 0x12, 0x1b, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x76, 0x32, - 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x42, 0xc1, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x6e, 0x6f, 0x64, 0x65, - 0x2e, 0x76, 0x32, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x2b, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, - 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, - 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x76, 0x32, 0x3b, 0x6e, 0x6f, 0x64, 0x65, 0x76, 0x32, 0xa2, 0x02, - 0x03, 0x43, 0x42, 0x4e, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x42, 0x61, - 0x73, 0x65, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x13, 0x43, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x73, 0x65, 0x5c, 0x4e, 0x6f, 0x64, 0x65, 0x5c, 0x56, 0x32, - 0xe2, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x73, 0x65, 0x5c, 0x4e, - 0x6f, 0x64, 0x65, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0xea, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x42, 0x61, 0x73, - 0x65, 0x3a, 0x3a, 0x4e, 0x6f, 0x64, 0x65, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, -} - -var ( - file_cosmos_base_node_v2_query_proto_rawDescOnce sync.Once - file_cosmos_base_node_v2_query_proto_rawDescData = file_cosmos_base_node_v2_query_proto_rawDesc -) - -func file_cosmos_base_node_v2_query_proto_rawDescGZIP() []byte { - file_cosmos_base_node_v2_query_proto_rawDescOnce.Do(func() { - file_cosmos_base_node_v2_query_proto_rawDescData = protoimpl.X.CompressGZIP(file_cosmos_base_node_v2_query_proto_rawDescData) - }) - return file_cosmos_base_node_v2_query_proto_rawDescData -} - -var file_cosmos_base_node_v2_query_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_cosmos_base_node_v2_query_proto_goTypes = []interface{}{ - (*ConfigRequest)(nil), // 0: cosmos.base.node.v2.ConfigRequest - (*ConfigResponse)(nil), // 1: cosmos.base.node.v2.ConfigResponse -} -var file_cosmos_base_node_v2_query_proto_depIdxs = []int32{ - 0, // 0: cosmos.base.node.v2.Service.Config:input_type -> cosmos.base.node.v2.ConfigRequest - 1, // 1: cosmos.base.node.v2.Service.Config:output_type -> cosmos.base.node.v2.ConfigResponse - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] 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_cosmos_base_node_v2_query_proto_init() } -func file_cosmos_base_node_v2_query_proto_init() { - if File_cosmos_base_node_v2_query_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_cosmos_base_node_v2_query_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ConfigRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_cosmos_base_node_v2_query_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ConfigResponse); 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_cosmos_base_node_v2_query_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_cosmos_base_node_v2_query_proto_goTypes, - DependencyIndexes: file_cosmos_base_node_v2_query_proto_depIdxs, - MessageInfos: file_cosmos_base_node_v2_query_proto_msgTypes, - }.Build() - File_cosmos_base_node_v2_query_proto = out.File - file_cosmos_base_node_v2_query_proto_rawDesc = nil - file_cosmos_base_node_v2_query_proto_goTypes = nil - file_cosmos_base_node_v2_query_proto_depIdxs = nil -} diff --git a/api/cosmos/base/node/v2/query_grpc.pb.go b/api/cosmos/base/node/v2/query_grpc.pb.go deleted file mode 100644 index f87770fb5e63..000000000000 --- a/api/cosmos/base/node/v2/query_grpc.pb.go +++ /dev/null @@ -1,127 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: cosmos/base/node/v2/query.proto - -package nodev2 - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - Service_Config_FullMethodName = "/cosmos.base.node.v2.Service/Config" -) - -// ServiceClient is the client API for Service service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// Service defines the gRPC querier service for node related queries. -type ServiceClient interface { - // Config queries for the operator configuration. - Config(ctx context.Context, in *ConfigRequest, opts ...grpc.CallOption) (*ConfigResponse, error) -} - -type serviceClient struct { - cc grpc.ClientConnInterface -} - -func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient { - return &serviceClient{cc} -} - -func (c *serviceClient) Config(ctx context.Context, in *ConfigRequest, opts ...grpc.CallOption) (*ConfigResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ConfigResponse) - err := c.cc.Invoke(ctx, Service_Config_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ServiceServer is the server API for Service service. -// All implementations must embed UnimplementedServiceServer -// for forward compatibility. -// -// Service defines the gRPC querier service for node related queries. -type ServiceServer interface { - // Config queries for the operator configuration. - Config(context.Context, *ConfigRequest) (*ConfigResponse, error) - mustEmbedUnimplementedServiceServer() -} - -// UnimplementedServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedServiceServer struct{} - -func (UnimplementedServiceServer) Config(context.Context, *ConfigRequest) (*ConfigResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Config not implemented") -} -func (UnimplementedServiceServer) mustEmbedUnimplementedServiceServer() {} -func (UnimplementedServiceServer) testEmbeddedByValue() {} - -// UnsafeServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to ServiceServer will -// result in compilation errors. -type UnsafeServiceServer interface { - mustEmbedUnimplementedServiceServer() -} - -func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer) { - // If the following call pancis, it indicates UnimplementedServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&Service_ServiceDesc, srv) -} - -func _Service_Config_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ConfigRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).Config(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Service_Config_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).Config(ctx, req.(*ConfigRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// Service_ServiceDesc is the grpc.ServiceDesc for Service service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Service_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "cosmos.base.node.v2.Service", - HandlerType: (*ServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Config", - Handler: _Service_Config_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "cosmos/base/node/v2/query.proto", -}