diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a210fd6dacf..c5379e185147 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * (types) [#18768](https://github.com/cosmos/cosmos-sdk/pull/18768) Add MustValAddressFromBech32 function. * (gRPC) [#19049](https://github.com/cosmos/cosmos-sdk/pull/19049) Add debug log prints for each gRPC request. * (server) [#19280](https://github.com/cosmos/cosmos-sdk/pull/19280) Adds in-place testnet CLI command. +* (x/consensus) [#19483](https://github.com/cosmos/cosmos-sdk/pull/19483) Add consensus messages registration to consensus module. ### Improvements diff --git a/api/cosmos/consensus/v1/consensus.pulsar.go b/api/cosmos/consensus/v1/consensus.pulsar.go new file mode 100644 index 000000000000..039a6abf1634 --- /dev/null +++ b/api/cosmos/consensus/v1/consensus.pulsar.go @@ -0,0 +1,1367 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package consensusv1 + +import ( + types "buf.build/gen/go/tendermint/tendermint/protocolbuffers/go/tendermint/types" + fmt "fmt" + runtime "github.com/cosmos/cosmos-proto/runtime" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoiface "google.golang.org/protobuf/runtime/protoiface" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" +) + +var ( + md_ConsensusMsgParams protoreflect.MessageDescriptor + fd_ConsensusMsgParams_version protoreflect.FieldDescriptor + fd_ConsensusMsgParams_block protoreflect.FieldDescriptor + fd_ConsensusMsgParams_evidence protoreflect.FieldDescriptor + fd_ConsensusMsgParams_validator protoreflect.FieldDescriptor + fd_ConsensusMsgParams_abci protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_consensus_v1_consensus_proto_init() + md_ConsensusMsgParams = File_cosmos_consensus_v1_consensus_proto.Messages().ByName("ConsensusMsgParams") + fd_ConsensusMsgParams_version = md_ConsensusMsgParams.Fields().ByName("version") + fd_ConsensusMsgParams_block = md_ConsensusMsgParams.Fields().ByName("block") + fd_ConsensusMsgParams_evidence = md_ConsensusMsgParams.Fields().ByName("evidence") + fd_ConsensusMsgParams_validator = md_ConsensusMsgParams.Fields().ByName("validator") + fd_ConsensusMsgParams_abci = md_ConsensusMsgParams.Fields().ByName("abci") +} + +var _ protoreflect.Message = (*fastReflection_ConsensusMsgParams)(nil) + +type fastReflection_ConsensusMsgParams ConsensusMsgParams + +func (x *ConsensusMsgParams) ProtoReflect() protoreflect.Message { + return (*fastReflection_ConsensusMsgParams)(x) +} + +func (x *ConsensusMsgParams) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_consensus_v1_consensus_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_ConsensusMsgParams_messageType fastReflection_ConsensusMsgParams_messageType +var _ protoreflect.MessageType = fastReflection_ConsensusMsgParams_messageType{} + +type fastReflection_ConsensusMsgParams_messageType struct{} + +func (x fastReflection_ConsensusMsgParams_messageType) Zero() protoreflect.Message { + return (*fastReflection_ConsensusMsgParams)(nil) +} +func (x fastReflection_ConsensusMsgParams_messageType) New() protoreflect.Message { + return new(fastReflection_ConsensusMsgParams) +} +func (x fastReflection_ConsensusMsgParams_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_ConsensusMsgParams +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_ConsensusMsgParams) Descriptor() protoreflect.MessageDescriptor { + return md_ConsensusMsgParams +} + +// 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_ConsensusMsgParams) Type() protoreflect.MessageType { + return _fastReflection_ConsensusMsgParams_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_ConsensusMsgParams) New() protoreflect.Message { + return new(fastReflection_ConsensusMsgParams) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_ConsensusMsgParams) Interface() protoreflect.ProtoMessage { + return (*ConsensusMsgParams)(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_ConsensusMsgParams) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Version != nil { + value := protoreflect.ValueOfMessage(x.Version.ProtoReflect()) + if !f(fd_ConsensusMsgParams_version, value) { + return + } + } + if x.Block != nil { + value := protoreflect.ValueOfMessage(x.Block.ProtoReflect()) + if !f(fd_ConsensusMsgParams_block, value) { + return + } + } + if x.Evidence != nil { + value := protoreflect.ValueOfMessage(x.Evidence.ProtoReflect()) + if !f(fd_ConsensusMsgParams_evidence, value) { + return + } + } + if x.Validator != nil { + value := protoreflect.ValueOfMessage(x.Validator.ProtoReflect()) + if !f(fd_ConsensusMsgParams_validator, value) { + return + } + } + if x.Abci != nil { + value := protoreflect.ValueOfMessage(x.Abci.ProtoReflect()) + if !f(fd_ConsensusMsgParams_abci, 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_ConsensusMsgParams) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.consensus.v1.ConsensusMsgParams.version": + return x.Version != nil + case "cosmos.consensus.v1.ConsensusMsgParams.block": + return x.Block != nil + case "cosmos.consensus.v1.ConsensusMsgParams.evidence": + return x.Evidence != nil + case "cosmos.consensus.v1.ConsensusMsgParams.validator": + return x.Validator != nil + case "cosmos.consensus.v1.ConsensusMsgParams.abci": + return x.Abci != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.ConsensusMsgParams")) + } + panic(fmt.Errorf("message cosmos.consensus.v1.ConsensusMsgParams 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_ConsensusMsgParams) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.consensus.v1.ConsensusMsgParams.version": + x.Version = nil + case "cosmos.consensus.v1.ConsensusMsgParams.block": + x.Block = nil + case "cosmos.consensus.v1.ConsensusMsgParams.evidence": + x.Evidence = nil + case "cosmos.consensus.v1.ConsensusMsgParams.validator": + x.Validator = nil + case "cosmos.consensus.v1.ConsensusMsgParams.abci": + x.Abci = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.ConsensusMsgParams")) + } + panic(fmt.Errorf("message cosmos.consensus.v1.ConsensusMsgParams 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_ConsensusMsgParams) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.consensus.v1.ConsensusMsgParams.version": + value := x.Version + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "cosmos.consensus.v1.ConsensusMsgParams.block": + value := x.Block + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "cosmos.consensus.v1.ConsensusMsgParams.evidence": + value := x.Evidence + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "cosmos.consensus.v1.ConsensusMsgParams.validator": + value := x.Validator + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "cosmos.consensus.v1.ConsensusMsgParams.abci": + value := x.Abci + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.ConsensusMsgParams")) + } + panic(fmt.Errorf("message cosmos.consensus.v1.ConsensusMsgParams 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_ConsensusMsgParams) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.consensus.v1.ConsensusMsgParams.version": + x.Version = value.Message().Interface().(*types.VersionParams) + case "cosmos.consensus.v1.ConsensusMsgParams.block": + x.Block = value.Message().Interface().(*types.BlockParams) + case "cosmos.consensus.v1.ConsensusMsgParams.evidence": + x.Evidence = value.Message().Interface().(*types.EvidenceParams) + case "cosmos.consensus.v1.ConsensusMsgParams.validator": + x.Validator = value.Message().Interface().(*types.ValidatorParams) + case "cosmos.consensus.v1.ConsensusMsgParams.abci": + x.Abci = value.Message().Interface().(*types.ABCIParams) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.ConsensusMsgParams")) + } + panic(fmt.Errorf("message cosmos.consensus.v1.ConsensusMsgParams 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_ConsensusMsgParams) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.consensus.v1.ConsensusMsgParams.version": + if x.Version == nil { + x.Version = new(types.VersionParams) + } + return protoreflect.ValueOfMessage(x.Version.ProtoReflect()) + case "cosmos.consensus.v1.ConsensusMsgParams.block": + if x.Block == nil { + x.Block = new(types.BlockParams) + } + return protoreflect.ValueOfMessage(x.Block.ProtoReflect()) + case "cosmos.consensus.v1.ConsensusMsgParams.evidence": + if x.Evidence == nil { + x.Evidence = new(types.EvidenceParams) + } + return protoreflect.ValueOfMessage(x.Evidence.ProtoReflect()) + case "cosmos.consensus.v1.ConsensusMsgParams.validator": + if x.Validator == nil { + x.Validator = new(types.ValidatorParams) + } + return protoreflect.ValueOfMessage(x.Validator.ProtoReflect()) + case "cosmos.consensus.v1.ConsensusMsgParams.abci": + if x.Abci == nil { + x.Abci = new(types.ABCIParams) + } + return protoreflect.ValueOfMessage(x.Abci.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.ConsensusMsgParams")) + } + panic(fmt.Errorf("message cosmos.consensus.v1.ConsensusMsgParams 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_ConsensusMsgParams) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.consensus.v1.ConsensusMsgParams.version": + m := new(types.VersionParams) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "cosmos.consensus.v1.ConsensusMsgParams.block": + m := new(types.BlockParams) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "cosmos.consensus.v1.ConsensusMsgParams.evidence": + m := new(types.EvidenceParams) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "cosmos.consensus.v1.ConsensusMsgParams.validator": + m := new(types.ValidatorParams) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "cosmos.consensus.v1.ConsensusMsgParams.abci": + m := new(types.ABCIParams) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.ConsensusMsgParams")) + } + panic(fmt.Errorf("message cosmos.consensus.v1.ConsensusMsgParams 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_ConsensusMsgParams) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.consensus.v1.ConsensusMsgParams", 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_ConsensusMsgParams) 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_ConsensusMsgParams) 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_ConsensusMsgParams) 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_ConsensusMsgParams) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*ConsensusMsgParams) + 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.Version != nil { + l = options.Size(x.Version) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Block != nil { + l = options.Size(x.Block) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Evidence != nil { + l = options.Size(x.Evidence) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Validator != nil { + l = options.Size(x.Validator) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Abci != nil { + l = options.Size(x.Abci) + 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().(*ConsensusMsgParams) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Abci != nil { + encoded, err := options.Marshal(x.Abci) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x2a + } + if x.Validator != nil { + encoded, err := options.Marshal(x.Validator) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x22 + } + if x.Evidence != nil { + encoded, err := options.Marshal(x.Evidence) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x1a + } + if x.Block != nil { + encoded, err := options.Marshal(x.Block) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x12 + } + if x.Version != nil { + encoded, err := options.Marshal(x.Version) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*ConsensusMsgParams) + 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: ConsensusMsgParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ConsensusMsgParams: 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 Version", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Version == nil { + x.Version = &types.VersionParams{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Version); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Block == nil { + x.Block = &types.BlockParams{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Block); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Evidence == nil { + x.Evidence = &types.EvidenceParams{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Evidence); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Validator == nil { + x.Validator = &types.ValidatorParams{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Validator); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Abci", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Abci == nil { + x.Abci = &types.ABCIParams{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Abci); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_ConsensusMsgParamsResponse protoreflect.MessageDescriptor +) + +func init() { + file_cosmos_consensus_v1_consensus_proto_init() + md_ConsensusMsgParamsResponse = File_cosmos_consensus_v1_consensus_proto.Messages().ByName("ConsensusMsgParamsResponse") +} + +var _ protoreflect.Message = (*fastReflection_ConsensusMsgParamsResponse)(nil) + +type fastReflection_ConsensusMsgParamsResponse ConsensusMsgParamsResponse + +func (x *ConsensusMsgParamsResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_ConsensusMsgParamsResponse)(x) +} + +func (x *ConsensusMsgParamsResponse) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_consensus_v1_consensus_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_ConsensusMsgParamsResponse_messageType fastReflection_ConsensusMsgParamsResponse_messageType +var _ protoreflect.MessageType = fastReflection_ConsensusMsgParamsResponse_messageType{} + +type fastReflection_ConsensusMsgParamsResponse_messageType struct{} + +func (x fastReflection_ConsensusMsgParamsResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_ConsensusMsgParamsResponse)(nil) +} +func (x fastReflection_ConsensusMsgParamsResponse_messageType) New() protoreflect.Message { + return new(fastReflection_ConsensusMsgParamsResponse) +} +func (x fastReflection_ConsensusMsgParamsResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_ConsensusMsgParamsResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_ConsensusMsgParamsResponse) Descriptor() protoreflect.MessageDescriptor { + return md_ConsensusMsgParamsResponse +} + +// 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_ConsensusMsgParamsResponse) Type() protoreflect.MessageType { + return _fastReflection_ConsensusMsgParamsResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_ConsensusMsgParamsResponse) New() protoreflect.Message { + return new(fastReflection_ConsensusMsgParamsResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_ConsensusMsgParamsResponse) Interface() protoreflect.ProtoMessage { + return (*ConsensusMsgParamsResponse)(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_ConsensusMsgParamsResponse) 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_ConsensusMsgParamsResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.ConsensusMsgParamsResponse")) + } + panic(fmt.Errorf("message cosmos.consensus.v1.ConsensusMsgParamsResponse 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_ConsensusMsgParamsResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.ConsensusMsgParamsResponse")) + } + panic(fmt.Errorf("message cosmos.consensus.v1.ConsensusMsgParamsResponse 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_ConsensusMsgParamsResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.ConsensusMsgParamsResponse")) + } + panic(fmt.Errorf("message cosmos.consensus.v1.ConsensusMsgParamsResponse 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_ConsensusMsgParamsResponse) 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.consensus.v1.ConsensusMsgParamsResponse")) + } + panic(fmt.Errorf("message cosmos.consensus.v1.ConsensusMsgParamsResponse 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_ConsensusMsgParamsResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.ConsensusMsgParamsResponse")) + } + panic(fmt.Errorf("message cosmos.consensus.v1.ConsensusMsgParamsResponse 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_ConsensusMsgParamsResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.ConsensusMsgParamsResponse")) + } + panic(fmt.Errorf("message cosmos.consensus.v1.ConsensusMsgParamsResponse 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_ConsensusMsgParamsResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.consensus.v1.ConsensusMsgParamsResponse", 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_ConsensusMsgParamsResponse) 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_ConsensusMsgParamsResponse) 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_ConsensusMsgParamsResponse) 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_ConsensusMsgParamsResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*ConsensusMsgParamsResponse) + 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().(*ConsensusMsgParamsResponse) + 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().(*ConsensusMsgParamsResponse) + 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: ConsensusMsgParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ConsensusMsgParamsResponse: 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, + } +} + +// Since: cosmos-sdk 0.51 + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: cosmos/consensus/v1/consensus.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) +) + +// ConsensusMsgParams is the Msg/Params request type. This is a consensus message that is sent from cometbft. +type ConsensusMsgParams struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // params defines the x/consensus parameters to be passed from comet. + // + // NOTE: All parameters must be supplied. + Version *types.VersionParams `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + Block *types.BlockParams `protobuf:"bytes,2,opt,name=block,proto3" json:"block,omitempty"` + Evidence *types.EvidenceParams `protobuf:"bytes,3,opt,name=evidence,proto3" json:"evidence,omitempty"` + Validator *types.ValidatorParams `protobuf:"bytes,4,opt,name=validator,proto3" json:"validator,omitempty"` + Abci *types.ABCIParams `protobuf:"bytes,5,opt,name=abci,proto3" json:"abci,omitempty"` +} + +func (x *ConsensusMsgParams) Reset() { + *x = ConsensusMsgParams{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_consensus_v1_consensus_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ConsensusMsgParams) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConsensusMsgParams) ProtoMessage() {} + +// Deprecated: Use ConsensusMsgParams.ProtoReflect.Descriptor instead. +func (*ConsensusMsgParams) Descriptor() ([]byte, []int) { + return file_cosmos_consensus_v1_consensus_proto_rawDescGZIP(), []int{0} +} + +func (x *ConsensusMsgParams) GetVersion() *types.VersionParams { + if x != nil { + return x.Version + } + return nil +} + +func (x *ConsensusMsgParams) GetBlock() *types.BlockParams { + if x != nil { + return x.Block + } + return nil +} + +func (x *ConsensusMsgParams) GetEvidence() *types.EvidenceParams { + if x != nil { + return x.Evidence + } + return nil +} + +func (x *ConsensusMsgParams) GetValidator() *types.ValidatorParams { + if x != nil { + return x.Validator + } + return nil +} + +func (x *ConsensusMsgParams) GetAbci() *types.ABCIParams { + if x != nil { + return x.Abci + } + return nil +} + +// ConsensusMsgParamsResponse defines the response structure for executing a +// ConsensusMsgParams message. +type ConsensusMsgParamsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ConsensusMsgParamsResponse) Reset() { + *x = ConsensusMsgParamsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_consensus_v1_consensus_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ConsensusMsgParamsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConsensusMsgParamsResponse) ProtoMessage() {} + +// Deprecated: Use ConsensusMsgParamsResponse.ProtoReflect.Descriptor instead. +func (*ConsensusMsgParamsResponse) Descriptor() ([]byte, []int) { + return file_cosmos_consensus_v1_consensus_proto_rawDescGZIP(), []int{1} +} + +var File_cosmos_consensus_v1_consensus_proto protoreflect.FileDescriptor + +var file_cosmos_consensus_v1_consensus_proto_rawDesc = []byte{ + 0x0a, 0x23, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, + 0x75, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x13, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x6f, + 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x1d, 0x74, 0x65, 0x6e, 0x64, + 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x61, 0x72, + 0x61, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb5, 0x02, 0x0a, 0x12, 0x43, 0x6f, + 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x12, 0x39, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1f, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x74, + 0x79, 0x70, 0x65, 0x73, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x73, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x33, 0x0a, 0x05, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x74, 0x65, 0x6e, + 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x12, 0x3c, 0x0a, 0x08, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, + 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x52, 0x08, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x3f, + 0x0a, 0x09, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x21, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x74, + 0x79, 0x70, 0x65, 0x73, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x52, 0x09, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x12, + 0x30, 0x0a, 0x04, 0x61, 0x62, 0x63, 0x69, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, + 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x2e, 0x41, 0x42, 0x43, 0x49, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x04, 0x61, 0x62, 0x63, + 0x69, 0x22, 0x1c, 0x0a, 0x1a, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x4d, 0x73, + 0x67, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, + 0xc9, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, + 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x76, 0x31, 0x42, 0x0e, 0x43, 0x6f, 0x6e, + 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, + 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x76, 0x31, 0xa2, + 0x02, 0x03, 0x43, 0x43, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x43, + 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x13, 0x43, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x5c, 0x56, + 0x31, 0xe2, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x6f, 0x6e, 0x73, 0x65, + 0x6e, 0x73, 0x75, 0x73, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x43, 0x6f, + 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var ( + file_cosmos_consensus_v1_consensus_proto_rawDescOnce sync.Once + file_cosmos_consensus_v1_consensus_proto_rawDescData = file_cosmos_consensus_v1_consensus_proto_rawDesc +) + +func file_cosmos_consensus_v1_consensus_proto_rawDescGZIP() []byte { + file_cosmos_consensus_v1_consensus_proto_rawDescOnce.Do(func() { + file_cosmos_consensus_v1_consensus_proto_rawDescData = protoimpl.X.CompressGZIP(file_cosmos_consensus_v1_consensus_proto_rawDescData) + }) + return file_cosmos_consensus_v1_consensus_proto_rawDescData +} + +var file_cosmos_consensus_v1_consensus_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_cosmos_consensus_v1_consensus_proto_goTypes = []interface{}{ + (*ConsensusMsgParams)(nil), // 0: cosmos.consensus.v1.ConsensusMsgParams + (*ConsensusMsgParamsResponse)(nil), // 1: cosmos.consensus.v1.ConsensusMsgParamsResponse + (*types.VersionParams)(nil), // 2: tendermint.types.VersionParams + (*types.BlockParams)(nil), // 3: tendermint.types.BlockParams + (*types.EvidenceParams)(nil), // 4: tendermint.types.EvidenceParams + (*types.ValidatorParams)(nil), // 5: tendermint.types.ValidatorParams + (*types.ABCIParams)(nil), // 6: tendermint.types.ABCIParams +} +var file_cosmos_consensus_v1_consensus_proto_depIdxs = []int32{ + 2, // 0: cosmos.consensus.v1.ConsensusMsgParams.version:type_name -> tendermint.types.VersionParams + 3, // 1: cosmos.consensus.v1.ConsensusMsgParams.block:type_name -> tendermint.types.BlockParams + 4, // 2: cosmos.consensus.v1.ConsensusMsgParams.evidence:type_name -> tendermint.types.EvidenceParams + 5, // 3: cosmos.consensus.v1.ConsensusMsgParams.validator:type_name -> tendermint.types.ValidatorParams + 6, // 4: cosmos.consensus.v1.ConsensusMsgParams.abci:type_name -> tendermint.types.ABCIParams + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_cosmos_consensus_v1_consensus_proto_init() } +func file_cosmos_consensus_v1_consensus_proto_init() { + if File_cosmos_consensus_v1_consensus_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_cosmos_consensus_v1_consensus_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConsensusMsgParams); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_consensus_v1_consensus_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConsensusMsgParamsResponse); 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_consensus_v1_consensus_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_cosmos_consensus_v1_consensus_proto_goTypes, + DependencyIndexes: file_cosmos_consensus_v1_consensus_proto_depIdxs, + MessageInfos: file_cosmos_consensus_v1_consensus_proto_msgTypes, + }.Build() + File_cosmos_consensus_v1_consensus_proto = out.File + file_cosmos_consensus_v1_consensus_proto_rawDesc = nil + file_cosmos_consensus_v1_consensus_proto_goTypes = nil + file_cosmos_consensus_v1_consensus_proto_depIdxs = nil +} diff --git a/proto/cosmos/consensus/v1/consensus.proto b/proto/cosmos/consensus/v1/consensus.proto new file mode 100644 index 000000000000..0bf88a3cafde --- /dev/null +++ b/proto/cosmos/consensus/v1/consensus.proto @@ -0,0 +1,23 @@ +// Since: cosmos-sdk 0.51 +syntax = "proto3"; +package cosmos.consensus.v1; + +import "tendermint/types/params.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/consensus/types"; + +// ConsensusMsgParams is the Msg/Params request type. This is a consensus message that is sent from cometbft. +message ConsensusMsgParams { + // params defines the x/consensus parameters to be passed from comet. + // + // NOTE: All parameters must be supplied. + tendermint.types.VersionParams version = 1; + tendermint.types.BlockParams block = 2; + tendermint.types.EvidenceParams evidence = 3; + tendermint.types.ValidatorParams validator = 4; + tendermint.types.ABCIParams abci = 5; +} + +// ConsensusMsgParamsResponse defines the response structure for executing a +// ConsensusMsgParams message. +message ConsensusMsgParamsResponse {} diff --git a/x/consensus/README.md b/x/consensus/README.md index 902280a6ecb9..2d38ed39a6ff 100644 --- a/x/consensus/README.md +++ b/x/consensus/README.md @@ -4,4 +4,72 @@ sidebar_position: 1 # `x/consensus` +## Abstract + Functionality to modify CometBFT's ABCI consensus params. + +## Contents + +* [State](#state) +* [Params](#params) +* [Keepers](#keepers) +* [Messages](#messages) +* [Consensus Messages](#consensus-messages) +* [Events](#events) + * [Message Events](#message-events) + + +## State + +The `x/consensus` module keeps state of the consensus params from cometbft.: + +## Params + +The consensus module stores it's params in state with the prefix of `0x05`, +it can be updated with governance or the address with authority. + +* Params: `0x05 | ProtocolBuffer(cometbft.ConsensusParams)` + +```protobuf reference +https://github.com/cosmos/cosmos-sdk/blob/381de6452693a9338371223c232fba0c42773a4b/proto/cosmos/consensus/v1/consensus.proto#L11-L18 +``` + +## Keepers + +The consensus module provides methods to Set and Get consensus params. It is recommended to use the `x/consensus` module keeper to get consensus params instead of accessing them through the context. + +## Messages + +### UpdateParams + +Update consensus params. + +```protobuf reference +https://github.com/cosmos/cosmos-sdk/blob/381de6452693a9338371223c232fba0c42773a4b/proto/cosmos/consensus/v1/tx.proto#L12-L47 +``` + +The message will fail under the following conditions: + +* The signer is not the set authority +* Not all values are set + +## Consensus Messages + +The consensus module has a consensus message that is used to set the consensus params when the chain initializes. It is similar to the `UpdateParams` message but it is only used once at the start of the chain. + +```protobuf reference +https://github.com/cosmos/cosmos-sdk/blob/381de6452693a9338371223c232fba0c42773a4b/proto/cosmos/consensus/v1/consensus.proto#L9-L24 +``` + +## Events + +The consensus module emits the following events: + +### Message Events + +#### MsgUpdateParams + +| Type | Attribute Key | Attribute Value | +|--------|---------------|---------------------| +| string | authority | msg.Signer | +| string | parameters | consensus Parmeters | diff --git a/x/consensus/keeper/keeper.go b/x/consensus/keeper/keeper.go index 48112da959b7..d9e4baf3dcc8 100644 --- a/x/consensus/keeper/keeper.go +++ b/x/consensus/keeper/keeper.go @@ -86,3 +86,21 @@ func (k Keeper) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (* return &types.MsgUpdateParamsResponse{}, nil } + +// SetParams sets the consensus parameters on init of a chain. This is a consensus message. It can only be called by the consensus server +// This is used in the consensus message handler set in module.go. +func (k Keeper) SetParams(ctx context.Context, req *types.ConsensusMsgParams) (*types.ConsensusMsgParamsResponse, error) { + consensusParams, err := req.ToProtoConsensusParams() + if err != nil { + return nil, err + } + if err := cmttypes.ConsensusParamsFromProto(consensusParams).ValidateBasic(); err != nil { + return nil, err + } + + if err := k.ParamsStore.Set(ctx, consensusParams); err != nil { + return nil, err + } + + return &types.ConsensusMsgParamsResponse{}, nil +} diff --git a/x/consensus/keeper/keeper_test.go b/x/consensus/keeper/keeper_test.go index b49c634f75d2..3ab63dc3cf61 100644 --- a/x/consensus/keeper/keeper_test.go +++ b/x/consensus/keeper/keeper_test.go @@ -69,6 +69,7 @@ func (s *KeeperTestSuite) TestGRPCQueryConsensusParams() { Block: defaultConsensusParams.Block, Validator: defaultConsensusParams.Validator, Evidence: defaultConsensusParams.Evidence, + Abci: defaultConsensusParams.Abci, } _, err := s.consensusParamsKeeper.UpdateParams(s.ctx, input) s.Require().NoError(err) @@ -79,6 +80,7 @@ func (s *KeeperTestSuite) TestGRPCQueryConsensusParams() { Validator: defaultConsensusParams.Validator, Evidence: defaultConsensusParams.Evidence, Version: defaultConsensusParams.Version, + Abci: defaultConsensusParams.Abci, }, }, true, @@ -150,6 +152,7 @@ func (s *KeeperTestSuite) TestUpdateParams() { Block: defaultConsensusParams.Block, Validator: defaultConsensusParams.Validator, Evidence: defaultConsensusParams.Evidence, + Abci: defaultConsensusParams.Abci, }, expErr: false, expErrMsg: "", @@ -161,6 +164,7 @@ func (s *KeeperTestSuite) TestUpdateParams() { Block: &cmtproto.BlockParams{MaxGas: -10, MaxBytes: -10}, Validator: defaultConsensusParams.Validator, Evidence: defaultConsensusParams.Evidence, + Abci: defaultConsensusParams.Abci, }, expErr: true, expErrMsg: "block.MaxBytes must be -1 or greater than 0. Got -10", @@ -172,6 +176,7 @@ func (s *KeeperTestSuite) TestUpdateParams() { Block: defaultConsensusParams.Block, Validator: defaultConsensusParams.Validator, Evidence: defaultConsensusParams.Evidence, + Abci: defaultConsensusParams.Abci, }, expErr: true, expErrMsg: "invalid authority", @@ -183,6 +188,7 @@ func (s *KeeperTestSuite) TestUpdateParams() { Block: defaultConsensusParams.Block, Validator: defaultConsensusParams.Validator, Evidence: nil, + Abci: defaultConsensusParams.Abci, }, expErr: true, expErrMsg: "all parameters must be present", @@ -194,6 +200,7 @@ func (s *KeeperTestSuite) TestUpdateParams() { Block: nil, Validator: defaultConsensusParams.Validator, Evidence: defaultConsensusParams.Evidence, + Abci: defaultConsensusParams.Abci, }, expErr: true, expErrMsg: "all parameters must be present", @@ -205,6 +212,7 @@ func (s *KeeperTestSuite) TestUpdateParams() { Block: defaultConsensusParams.Block, Validator: nil, Evidence: defaultConsensusParams.Evidence, + Abci: defaultConsensusParams.Abci, }, expErr: true, expErrMsg: "all parameters must be present", @@ -233,3 +241,109 @@ func (s *KeeperTestSuite) TestUpdateParams() { }) } } + +func (s *KeeperTestSuite) TestSetParams() { + defaultConsensusParams := cmttypes.DefaultConsensusParams().ToProto() + testCases := []struct { + name string + input *types.ConsensusMsgParams + expErr bool + expErrMsg string + }{ + { + name: "valid params", + input: &types.ConsensusMsgParams{ + Abci: defaultConsensusParams.Abci, + Version: &cmtproto.VersionParams{App: 1}, + Block: defaultConsensusParams.Block, + Validator: defaultConsensusParams.Validator, + Evidence: defaultConsensusParams.Evidence, + }, + expErr: false, + expErrMsg: "", + }, + { + name: "invalid params", + input: &types.ConsensusMsgParams{ + Abci: defaultConsensusParams.Abci, + Version: &cmtproto.VersionParams{App: 1}, + Block: &cmtproto.BlockParams{MaxGas: -10, MaxBytes: -10}, + Validator: defaultConsensusParams.Validator, + Evidence: defaultConsensusParams.Evidence, + }, + expErr: true, + expErrMsg: "block.MaxBytes must be -1 or greater than 0. Got -10", + }, + { + name: "nil version params", + input: &types.ConsensusMsgParams{ + Abci: defaultConsensusParams.Abci, + Version: nil, + Block: defaultConsensusParams.Block, + Validator: defaultConsensusParams.Validator, + Evidence: defaultConsensusParams.Evidence, + }, + expErr: true, + expErrMsg: "all parameters must be present", + }, + { + name: "nil evidence params", + input: &types.ConsensusMsgParams{ + Abci: defaultConsensusParams.Abci, + Version: &cmtproto.VersionParams{App: 1}, + Block: defaultConsensusParams.Block, + Validator: defaultConsensusParams.Validator, + Evidence: nil, + }, + expErr: true, + expErrMsg: "all parameters must be present", + }, + { + name: "nil block params", + input: &types.ConsensusMsgParams{ + Abci: defaultConsensusParams.Abci, + Version: &cmtproto.VersionParams{App: 1}, + Block: nil, + Validator: defaultConsensusParams.Validator, + Evidence: defaultConsensusParams.Evidence, + }, + expErr: true, + expErrMsg: "all parameters must be present", + }, + { + name: "nil validator params", + input: &types.ConsensusMsgParams{ + Abci: defaultConsensusParams.Abci, + Version: &cmtproto.VersionParams{App: 1}, + Block: defaultConsensusParams.Block, + Validator: nil, + Evidence: defaultConsensusParams.Evidence, + }, + expErr: true, + expErrMsg: "all parameters must be present", + }, + } + + for _, tc := range testCases { + tc := tc + s.Run(tc.name, func() { + s.SetupTest() + _, err := s.consensusParamsKeeper.SetParams(s.ctx, tc.input) + if tc.expErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.expErrMsg) + } else { + s.Require().NoError(err) + + res, err := s.consensusParamsKeeper.Params(s.ctx, &types.QueryParamsRequest{}) + s.Require().NoError(err) + + s.Require().Equal(tc.input.Abci, res.Params.Abci) + s.Require().Equal(tc.input.Block, res.Params.Block) + s.Require().Equal(tc.input.Evidence, res.Params.Evidence) + s.Require().Equal(tc.input.Validator, res.Params.Validator) + s.Require().Equal(tc.input.Version, res.Params.Version) + } + }) + } +} diff --git a/x/consensus/module.go b/x/consensus/module.go index de10392824d0..6ca759424673 100644 --- a/x/consensus/module.go +++ b/x/consensus/module.go @@ -74,3 +74,8 @@ func (am AppModule) RegisterServices(registrar grpc.ServiceRegistrar) error { // ConsensusVersion implements HasConsensusVersion. func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } + +// RegisterConsensusMessages registers the consensus module's messages. +func (am AppModule) RegisterConsensusMessages(builder any) { + // std.RegisterConsensusHandler(builder ,am.keeper.SetParams) // TODO uncomment when api is available +} diff --git a/x/consensus/types/consensus.go b/x/consensus/types/consensus.go new file mode 100644 index 000000000000..d4952bd0b7ae --- /dev/null +++ b/x/consensus/types/consensus.go @@ -0,0 +1,42 @@ +package types + +import ( + "errors" + + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" + cmttypes "github.com/cometbft/cometbft/types" +) + +func (msg ConsensusMsgParams) ToProtoConsensusParams() (cmtproto.ConsensusParams, error) { + if msg.Evidence == nil || msg.Block == nil || msg.Validator == nil || msg.Version == nil { + return cmtproto.ConsensusParams{}, errors.New("all parameters must be present") + } + + cp := cmtproto.ConsensusParams{ + Block: &cmtproto.BlockParams{ + MaxBytes: msg.Block.MaxBytes, + MaxGas: msg.Block.MaxGas, + }, + Evidence: &cmtproto.EvidenceParams{ + MaxAgeNumBlocks: msg.Evidence.MaxAgeNumBlocks, + MaxAgeDuration: msg.Evidence.MaxAgeDuration, + MaxBytes: msg.Evidence.MaxBytes, + }, + Validator: &cmtproto.ValidatorParams{ + PubKeyTypes: msg.Validator.PubKeyTypes, + }, + Version: cmttypes.DefaultConsensusParams().ToProto().Version, // Version is stored in x/upgrade + } + + if msg.Abci != nil { + cp.Abci = &cmtproto.ABCIParams{ + VoteExtensionsEnableHeight: msg.Abci.VoteExtensionsEnableHeight, + } + } + + if msg.Version != nil { + cp.Version.App = msg.Version.App + } + + return cp, nil +} diff --git a/x/consensus/types/consensus.pb.go b/x/consensus/types/consensus.pb.go new file mode 100644 index 000000000000..d3cdd7b67290 --- /dev/null +++ b/x/consensus/types/consensus.pb.go @@ -0,0 +1,701 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/consensus/v1/consensus.proto + +package types + +import ( + fmt "fmt" + types "github.com/cometbft/cometbft/proto/tendermint/types" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// ConsensusMsgParams is the Msg/Params request type. This is a consensus message that is sent from cometbft. +type ConsensusMsgParams struct { + // params defines the x/consensus parameters to be passed from comet. + // + // NOTE: All parameters must be supplied. + Version *types.VersionParams `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + Block *types.BlockParams `protobuf:"bytes,2,opt,name=block,proto3" json:"block,omitempty"` + Evidence *types.EvidenceParams `protobuf:"bytes,3,opt,name=evidence,proto3" json:"evidence,omitempty"` + Validator *types.ValidatorParams `protobuf:"bytes,4,opt,name=validator,proto3" json:"validator,omitempty"` + Abci *types.ABCIParams `protobuf:"bytes,5,opt,name=abci,proto3" json:"abci,omitempty"` +} + +func (m *ConsensusMsgParams) Reset() { *m = ConsensusMsgParams{} } +func (m *ConsensusMsgParams) String() string { return proto.CompactTextString(m) } +func (*ConsensusMsgParams) ProtoMessage() {} +func (*ConsensusMsgParams) Descriptor() ([]byte, []int) { + return fileDescriptor_7ed86dd7d42fb61b, []int{0} +} +func (m *ConsensusMsgParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ConsensusMsgParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ConsensusMsgParams.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 *ConsensusMsgParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConsensusMsgParams.Merge(m, src) +} +func (m *ConsensusMsgParams) XXX_Size() int { + return m.Size() +} +func (m *ConsensusMsgParams) XXX_DiscardUnknown() { + xxx_messageInfo_ConsensusMsgParams.DiscardUnknown(m) +} + +var xxx_messageInfo_ConsensusMsgParams proto.InternalMessageInfo + +func (m *ConsensusMsgParams) GetVersion() *types.VersionParams { + if m != nil { + return m.Version + } + return nil +} + +func (m *ConsensusMsgParams) GetBlock() *types.BlockParams { + if m != nil { + return m.Block + } + return nil +} + +func (m *ConsensusMsgParams) GetEvidence() *types.EvidenceParams { + if m != nil { + return m.Evidence + } + return nil +} + +func (m *ConsensusMsgParams) GetValidator() *types.ValidatorParams { + if m != nil { + return m.Validator + } + return nil +} + +func (m *ConsensusMsgParams) GetAbci() *types.ABCIParams { + if m != nil { + return m.Abci + } + return nil +} + +// ConsensusMsgParamsResponse defines the response structure for executing a +// ConsensusMsgParams message. +type ConsensusMsgParamsResponse struct { +} + +func (m *ConsensusMsgParamsResponse) Reset() { *m = ConsensusMsgParamsResponse{} } +func (m *ConsensusMsgParamsResponse) String() string { return proto.CompactTextString(m) } +func (*ConsensusMsgParamsResponse) ProtoMessage() {} +func (*ConsensusMsgParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7ed86dd7d42fb61b, []int{1} +} +func (m *ConsensusMsgParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ConsensusMsgParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ConsensusMsgParamsResponse.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 *ConsensusMsgParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConsensusMsgParamsResponse.Merge(m, src) +} +func (m *ConsensusMsgParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *ConsensusMsgParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ConsensusMsgParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ConsensusMsgParamsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*ConsensusMsgParams)(nil), "cosmos.consensus.v1.ConsensusMsgParams") + proto.RegisterType((*ConsensusMsgParamsResponse)(nil), "cosmos.consensus.v1.ConsensusMsgParamsResponse") +} + +func init() { + proto.RegisterFile("cosmos/consensus/v1/consensus.proto", fileDescriptor_7ed86dd7d42fb61b) +} + +var fileDescriptor_7ed86dd7d42fb61b = []byte{ + // 306 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0xd1, 0xcf, 0x4a, 0xc3, 0x30, + 0x1c, 0xc0, 0xf1, 0x76, 0x6e, 0xfe, 0x89, 0xb7, 0x78, 0x29, 0x63, 0x8b, 0x73, 0x5e, 0xbc, 0x98, + 0x38, 0x77, 0x12, 0x04, 0xb1, 0x43, 0xd0, 0x83, 0x20, 0x3b, 0x78, 0xf0, 0xd6, 0xa6, 0x61, 0x86, + 0xad, 0x49, 0x69, 0xb2, 0xa2, 0x6f, 0xe1, 0xcb, 0xf8, 0x0e, 0x1e, 0x77, 0xf4, 0x28, 0xed, 0x8b, + 0x48, 0xd3, 0x74, 0x15, 0xea, 0xa9, 0x34, 0xf9, 0x7e, 0xd2, 0x92, 0x1f, 0x38, 0xa5, 0x52, 0xc5, + 0x52, 0x11, 0x2a, 0x85, 0x62, 0x42, 0xad, 0x15, 0xc9, 0x26, 0xcd, 0x0b, 0x4e, 0x52, 0xa9, 0x25, + 0x3c, 0xaa, 0x22, 0xdc, 0xac, 0x67, 0x93, 0xfe, 0x50, 0x33, 0x11, 0xb1, 0x34, 0xe6, 0x42, 0x13, + 0xfd, 0x9e, 0x30, 0x45, 0x92, 0x20, 0x0d, 0x62, 0x6b, 0xc6, 0x9f, 0x1d, 0x00, 0x67, 0x75, 0xff, + 0xa8, 0x16, 0x4f, 0x66, 0x13, 0x5e, 0x81, 0xbd, 0x8c, 0xa5, 0x8a, 0x4b, 0xe1, 0xb9, 0x23, 0xf7, + 0xec, 0xf0, 0xf2, 0x18, 0x37, 0xe7, 0x60, 0x73, 0x0e, 0x7e, 0xae, 0x82, 0x4a, 0xcc, 0xeb, 0x1e, + 0x4e, 0x41, 0x2f, 0x5c, 0x49, 0xba, 0xf4, 0x3a, 0x06, 0x0e, 0xdb, 0xd0, 0x2f, 0xb7, 0x2d, 0xab, + 0x5a, 0x78, 0x0d, 0xf6, 0x59, 0xc6, 0x23, 0x26, 0x28, 0xf3, 0x76, 0x8c, 0x1b, 0xb5, 0xdd, 0x9d, + 0x2d, 0x2c, 0xdd, 0x0a, 0x78, 0x03, 0x0e, 0xb2, 0x60, 0xc5, 0xa3, 0x40, 0xcb, 0xd4, 0xeb, 0x1a, + 0x7e, 0xf2, 0xcf, 0xff, 0xd6, 0x89, 0xf5, 0x8d, 0x81, 0x17, 0xa0, 0x1b, 0x84, 0x94, 0x7b, 0x3d, + 0x63, 0x07, 0x6d, 0x7b, 0xeb, 0xcf, 0x1e, 0x2c, 0x33, 0xe5, 0x78, 0x00, 0xfa, 0xed, 0x6b, 0x9b, + 0x33, 0x95, 0x94, 0x8b, 0xfe, 0xfd, 0x57, 0x8e, 0xdc, 0x4d, 0x8e, 0xdc, 0x9f, 0x1c, 0xb9, 0x1f, + 0x05, 0x72, 0x36, 0x05, 0x72, 0xbe, 0x0b, 0xe4, 0xbc, 0xe0, 0x05, 0xd7, 0xaf, 0xeb, 0x10, 0x53, + 0x19, 0x93, 0xed, 0x4c, 0xcb, 0xc7, 0xb9, 0x8a, 0x96, 0xe4, 0xed, 0xcf, 0x80, 0xcd, 0x87, 0xc3, + 0x5d, 0x33, 0xa6, 0xe9, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x66, 0x95, 0x46, 0x47, 0x01, 0x02, + 0x00, 0x00, +} + +func (m *ConsensusMsgParams) 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 *ConsensusMsgParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConsensusMsgParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Abci != nil { + { + size, err := m.Abci.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConsensus(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if m.Validator != nil { + { + size, err := m.Validator.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConsensus(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.Evidence != nil { + { + size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConsensus(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.Block != nil { + { + size, err := m.Block.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConsensus(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.Version != nil { + { + size, err := m.Version.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConsensus(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ConsensusMsgParamsResponse) 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 *ConsensusMsgParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConsensusMsgParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintConsensus(dAtA []byte, offset int, v uint64) int { + offset -= sovConsensus(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ConsensusMsgParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Version != nil { + l = m.Version.Size() + n += 1 + l + sovConsensus(uint64(l)) + } + if m.Block != nil { + l = m.Block.Size() + n += 1 + l + sovConsensus(uint64(l)) + } + if m.Evidence != nil { + l = m.Evidence.Size() + n += 1 + l + sovConsensus(uint64(l)) + } + if m.Validator != nil { + l = m.Validator.Size() + n += 1 + l + sovConsensus(uint64(l)) + } + if m.Abci != nil { + l = m.Abci.Size() + n += 1 + l + sovConsensus(uint64(l)) + } + return n +} + +func (m *ConsensusMsgParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovConsensus(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozConsensus(x uint64) (n int) { + return sovConsensus(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ConsensusMsgParams) 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 ErrIntOverflowConsensus + } + 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: ConsensusMsgParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ConsensusMsgParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConsensus + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthConsensus + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConsensus + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Version == nil { + m.Version = &types.VersionParams{} + } + if err := m.Version.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConsensus + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthConsensus + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConsensus + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Block == nil { + m.Block = &types.BlockParams{} + } + if err := m.Block.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConsensus + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthConsensus + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConsensus + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Evidence == nil { + m.Evidence = &types.EvidenceParams{} + } + if err := m.Evidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConsensus + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthConsensus + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConsensus + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Validator == nil { + m.Validator = &types.ValidatorParams{} + } + if err := m.Validator.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Abci", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConsensus + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthConsensus + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConsensus + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Abci == nil { + m.Abci = &types.ABCIParams{} + } + if err := m.Abci.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipConsensus(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthConsensus + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ConsensusMsgParamsResponse) 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 ErrIntOverflowConsensus + } + 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: ConsensusMsgParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ConsensusMsgParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipConsensus(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthConsensus + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipConsensus(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, ErrIntOverflowConsensus + } + 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, ErrIntOverflowConsensus + } + 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, ErrIntOverflowConsensus + } + 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, ErrInvalidLengthConsensus + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupConsensus + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthConsensus + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthConsensus = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowConsensus = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupConsensus = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/consensus/types/msgs.go b/x/consensus/types/msgs.go index b62c0052f7cb..a64440f5b139 100644 --- a/x/consensus/types/msgs.go +++ b/x/consensus/types/msgs.go @@ -5,14 +5,10 @@ import ( cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" cmttypes "github.com/cometbft/cometbft/types" - - sdk "github.com/cosmos/cosmos-sdk/types" ) -var _ sdk.Msg = &MsgUpdateParams{} - func (msg MsgUpdateParams) ToProtoConsensusParams() (cmtproto.ConsensusParams, error) { - if msg.Evidence == nil || msg.Block == nil || msg.Validator == nil { + if msg.Evidence == nil || msg.Block == nil || msg.Validator == nil || msg.Abci == nil { return cmtproto.ConsensusParams{}, errors.New("all parameters must be present") }