refactor: remove consensus as a imported type in modules (#21480)

This commit is contained in:
Marko 2024-09-10 17:36:33 +02:00 committed by GitHub
parent 64887ce050
commit f220f8bf62
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
72 changed files with 523 additions and 1781 deletions

View File

@ -1,899 +0,0 @@
// Code generated by protoc-gen-go-pulsar. DO NOT EDIT.
package consensusv1
import (
v1 "buf.build/gen/go/cometbft/cometbft/protocolbuffers/go/cometbft/abci/v1"
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 _ protoreflect.List = (*_CometInfo_1_list)(nil)
type _CometInfo_1_list struct {
list *[]*v1.Misbehavior
}
func (x *_CometInfo_1_list) Len() int {
if x.list == nil {
return 0
}
return len(*x.list)
}
func (x *_CometInfo_1_list) Get(i int) protoreflect.Value {
return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect())
}
func (x *_CometInfo_1_list) Set(i int, value protoreflect.Value) {
valueUnwrapped := value.Message()
concreteValue := valueUnwrapped.Interface().(*v1.Misbehavior)
(*x.list)[i] = concreteValue
}
func (x *_CometInfo_1_list) Append(value protoreflect.Value) {
valueUnwrapped := value.Message()
concreteValue := valueUnwrapped.Interface().(*v1.Misbehavior)
*x.list = append(*x.list, concreteValue)
}
func (x *_CometInfo_1_list) AppendMutable() protoreflect.Value {
v := new(v1.Misbehavior)
*x.list = append(*x.list, v)
return protoreflect.ValueOfMessage(v.ProtoReflect())
}
func (x *_CometInfo_1_list) Truncate(n int) {
for i := n; i < len(*x.list); i++ {
(*x.list)[i] = nil
}
*x.list = (*x.list)[:n]
}
func (x *_CometInfo_1_list) NewElement() protoreflect.Value {
v := new(v1.Misbehavior)
return protoreflect.ValueOfMessage(v.ProtoReflect())
}
func (x *_CometInfo_1_list) IsValid() bool {
return x.list != nil
}
var (
md_CometInfo protoreflect.MessageDescriptor
fd_CometInfo_evidence protoreflect.FieldDescriptor
fd_CometInfo_validators_hash protoreflect.FieldDescriptor
fd_CometInfo_proposer_address protoreflect.FieldDescriptor
fd_CometInfo_last_commit protoreflect.FieldDescriptor
)
func init() {
file_cosmos_consensus_v1_consensus_proto_init()
md_CometInfo = File_cosmos_consensus_v1_consensus_proto.Messages().ByName("CometInfo")
fd_CometInfo_evidence = md_CometInfo.Fields().ByName("evidence")
fd_CometInfo_validators_hash = md_CometInfo.Fields().ByName("validators_hash")
fd_CometInfo_proposer_address = md_CometInfo.Fields().ByName("proposer_address")
fd_CometInfo_last_commit = md_CometInfo.Fields().ByName("last_commit")
}
var _ protoreflect.Message = (*fastReflection_CometInfo)(nil)
type fastReflection_CometInfo CometInfo
func (x *CometInfo) ProtoReflect() protoreflect.Message {
return (*fastReflection_CometInfo)(x)
}
func (x *CometInfo) 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_CometInfo_messageType fastReflection_CometInfo_messageType
var _ protoreflect.MessageType = fastReflection_CometInfo_messageType{}
type fastReflection_CometInfo_messageType struct{}
func (x fastReflection_CometInfo_messageType) Zero() protoreflect.Message {
return (*fastReflection_CometInfo)(nil)
}
func (x fastReflection_CometInfo_messageType) New() protoreflect.Message {
return new(fastReflection_CometInfo)
}
func (x fastReflection_CometInfo_messageType) Descriptor() protoreflect.MessageDescriptor {
return md_CometInfo
}
// Descriptor returns message descriptor, which contains only the protobuf
// type information for the message.
func (x *fastReflection_CometInfo) Descriptor() protoreflect.MessageDescriptor {
return md_CometInfo
}
// 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_CometInfo) Type() protoreflect.MessageType {
return _fastReflection_CometInfo_messageType
}
// New returns a newly allocated and mutable empty message.
func (x *fastReflection_CometInfo) New() protoreflect.Message {
return new(fastReflection_CometInfo)
}
// Interface unwraps the message reflection interface and
// returns the underlying ProtoMessage interface.
func (x *fastReflection_CometInfo) Interface() protoreflect.ProtoMessage {
return (*CometInfo)(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_CometInfo) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
if len(x.Evidence) != 0 {
value := protoreflect.ValueOfList(&_CometInfo_1_list{list: &x.Evidence})
if !f(fd_CometInfo_evidence, value) {
return
}
}
if len(x.ValidatorsHash) != 0 {
value := protoreflect.ValueOfBytes(x.ValidatorsHash)
if !f(fd_CometInfo_validators_hash, value) {
return
}
}
if len(x.ProposerAddress) != 0 {
value := protoreflect.ValueOfBytes(x.ProposerAddress)
if !f(fd_CometInfo_proposer_address, value) {
return
}
}
if x.LastCommit != nil {
value := protoreflect.ValueOfMessage(x.LastCommit.ProtoReflect())
if !f(fd_CometInfo_last_commit, 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_CometInfo) Has(fd protoreflect.FieldDescriptor) bool {
switch fd.FullName() {
case "cosmos.consensus.v1.CometInfo.evidence":
return len(x.Evidence) != 0
case "cosmos.consensus.v1.CometInfo.validators_hash":
return len(x.ValidatorsHash) != 0
case "cosmos.consensus.v1.CometInfo.proposer_address":
return len(x.ProposerAddress) != 0
case "cosmos.consensus.v1.CometInfo.last_commit":
return x.LastCommit != nil
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.CometInfo"))
}
panic(fmt.Errorf("message cosmos.consensus.v1.CometInfo 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_CometInfo) Clear(fd protoreflect.FieldDescriptor) {
switch fd.FullName() {
case "cosmos.consensus.v1.CometInfo.evidence":
x.Evidence = nil
case "cosmos.consensus.v1.CometInfo.validators_hash":
x.ValidatorsHash = nil
case "cosmos.consensus.v1.CometInfo.proposer_address":
x.ProposerAddress = nil
case "cosmos.consensus.v1.CometInfo.last_commit":
x.LastCommit = nil
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.CometInfo"))
}
panic(fmt.Errorf("message cosmos.consensus.v1.CometInfo 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_CometInfo) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
switch descriptor.FullName() {
case "cosmos.consensus.v1.CometInfo.evidence":
if len(x.Evidence) == 0 {
return protoreflect.ValueOfList(&_CometInfo_1_list{})
}
listValue := &_CometInfo_1_list{list: &x.Evidence}
return protoreflect.ValueOfList(listValue)
case "cosmos.consensus.v1.CometInfo.validators_hash":
value := x.ValidatorsHash
return protoreflect.ValueOfBytes(value)
case "cosmos.consensus.v1.CometInfo.proposer_address":
value := x.ProposerAddress
return protoreflect.ValueOfBytes(value)
case "cosmos.consensus.v1.CometInfo.last_commit":
value := x.LastCommit
return protoreflect.ValueOfMessage(value.ProtoReflect())
default:
if descriptor.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.CometInfo"))
}
panic(fmt.Errorf("message cosmos.consensus.v1.CometInfo 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_CometInfo) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {
switch fd.FullName() {
case "cosmos.consensus.v1.CometInfo.evidence":
lv := value.List()
clv := lv.(*_CometInfo_1_list)
x.Evidence = *clv.list
case "cosmos.consensus.v1.CometInfo.validators_hash":
x.ValidatorsHash = value.Bytes()
case "cosmos.consensus.v1.CometInfo.proposer_address":
x.ProposerAddress = value.Bytes()
case "cosmos.consensus.v1.CometInfo.last_commit":
x.LastCommit = value.Message().Interface().(*v1.CommitInfo)
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.CometInfo"))
}
panic(fmt.Errorf("message cosmos.consensus.v1.CometInfo 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_CometInfo) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
switch fd.FullName() {
case "cosmos.consensus.v1.CometInfo.evidence":
if x.Evidence == nil {
x.Evidence = []*v1.Misbehavior{}
}
value := &_CometInfo_1_list{list: &x.Evidence}
return protoreflect.ValueOfList(value)
case "cosmos.consensus.v1.CometInfo.last_commit":
if x.LastCommit == nil {
x.LastCommit = new(v1.CommitInfo)
}
return protoreflect.ValueOfMessage(x.LastCommit.ProtoReflect())
case "cosmos.consensus.v1.CometInfo.validators_hash":
panic(fmt.Errorf("field validators_hash of message cosmos.consensus.v1.CometInfo is not mutable"))
case "cosmos.consensus.v1.CometInfo.proposer_address":
panic(fmt.Errorf("field proposer_address of message cosmos.consensus.v1.CometInfo is not mutable"))
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.CometInfo"))
}
panic(fmt.Errorf("message cosmos.consensus.v1.CometInfo 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_CometInfo) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
switch fd.FullName() {
case "cosmos.consensus.v1.CometInfo.evidence":
list := []*v1.Misbehavior{}
return protoreflect.ValueOfList(&_CometInfo_1_list{list: &list})
case "cosmos.consensus.v1.CometInfo.validators_hash":
return protoreflect.ValueOfBytes(nil)
case "cosmos.consensus.v1.CometInfo.proposer_address":
return protoreflect.ValueOfBytes(nil)
case "cosmos.consensus.v1.CometInfo.last_commit":
m := new(v1.CommitInfo)
return protoreflect.ValueOfMessage(m.ProtoReflect())
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.CometInfo"))
}
panic(fmt.Errorf("message cosmos.consensus.v1.CometInfo 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_CometInfo) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
switch d.FullName() {
default:
panic(fmt.Errorf("%s is not a oneof field in cosmos.consensus.v1.CometInfo", 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_CometInfo) 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_CometInfo) 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_CometInfo) 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_CometInfo) ProtoMethods() *protoiface.Methods {
size := func(input protoiface.SizeInput) protoiface.SizeOutput {
x := input.Message.Interface().(*CometInfo)
if x == nil {
return protoiface.SizeOutput{
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
Size: 0,
}
}
options := runtime.SizeInputToOptions(input)
_ = options
var n int
var l int
_ = l
if len(x.Evidence) > 0 {
for _, e := range x.Evidence {
l = options.Size(e)
n += 1 + l + runtime.Sov(uint64(l))
}
}
l = len(x.ValidatorsHash)
if l > 0 {
n += 1 + l + runtime.Sov(uint64(l))
}
l = len(x.ProposerAddress)
if l > 0 {
n += 1 + l + runtime.Sov(uint64(l))
}
if x.LastCommit != nil {
l = options.Size(x.LastCommit)
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().(*CometInfo)
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.LastCommit != nil {
encoded, err := options.Marshal(x.LastCommit)
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 len(x.ProposerAddress) > 0 {
i -= len(x.ProposerAddress)
copy(dAtA[i:], x.ProposerAddress)
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ProposerAddress)))
i--
dAtA[i] = 0x1a
}
if len(x.ValidatorsHash) > 0 {
i -= len(x.ValidatorsHash)
copy(dAtA[i:], x.ValidatorsHash)
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ValidatorsHash)))
i--
dAtA[i] = 0x12
}
if len(x.Evidence) > 0 {
for iNdEx := len(x.Evidence) - 1; iNdEx >= 0; iNdEx-- {
encoded, err := options.Marshal(x.Evidence[iNdEx])
if err != nil {
return protoiface.MarshalOutput{
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
Buf: input.Buf,
}, err
}
i -= len(encoded)
copy(dAtA[i:], encoded)
i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded)))
i--
dAtA[i] = 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().(*CometInfo)
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: CometInfo: wiretype end group for non-group")
}
if fieldNum <= 0 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: CometInfo: 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 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
}
x.Evidence = append(x.Evidence, &v1.Misbehavior{})
if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Evidence[len(x.Evidence)-1]); 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 ValidatorsHash", wireType)
}
var byteLen 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++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
}
postIndex := iNdEx + byteLen
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.ValidatorsHash = append(x.ValidatorsHash[:0], dAtA[iNdEx:postIndex]...)
if x.ValidatorsHash == nil {
x.ValidatorsHash = []byte{}
}
iNdEx = postIndex
case 3:
if wireType != 2 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ProposerAddress", wireType)
}
var byteLen 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++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
}
postIndex := iNdEx + byteLen
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.ProposerAddress = append(x.ProposerAddress[:0], dAtA[iNdEx:postIndex]...)
if x.ProposerAddress == nil {
x.ProposerAddress = []byte{}
}
iNdEx = postIndex
case 4:
if wireType != 2 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field LastCommit", 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.LastCommit == nil {
x.LastCommit = &v1.CommitInfo{}
}
if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.LastCommit); 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,
}
}
// Since: cosmos-sdk 0.52
// 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)
)
// CometInfo defines the structure of the x/consensus module's comet info.
type CometInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Evidence []*v1.Misbehavior `protobuf:"bytes,1,rep,name=evidence,proto3" json:"evidence,omitempty"`
ValidatorsHash []byte `protobuf:"bytes,2,opt,name=validators_hash,json=validatorsHash,proto3" json:"validators_hash,omitempty"`
ProposerAddress []byte `protobuf:"bytes,3,opt,name=proposer_address,json=proposerAddress,proto3" json:"proposer_address,omitempty"`
LastCommit *v1.CommitInfo `protobuf:"bytes,4,opt,name=last_commit,json=lastCommit,proto3" json:"last_commit,omitempty"`
}
func (x *CometInfo) Reset() {
*x = CometInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_cosmos_consensus_v1_consensus_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CometInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CometInfo) ProtoMessage() {}
// Deprecated: Use CometInfo.ProtoReflect.Descriptor instead.
func (*CometInfo) Descriptor() ([]byte, []int) {
return file_cosmos_consensus_v1_consensus_proto_rawDescGZIP(), []int{0}
}
func (x *CometInfo) GetEvidence() []*v1.Misbehavior {
if x != nil {
return x.Evidence
}
return nil
}
func (x *CometInfo) GetValidatorsHash() []byte {
if x != nil {
return x.ValidatorsHash
}
return nil
}
func (x *CometInfo) GetProposerAddress() []byte {
if x != nil {
return x.ProposerAddress
}
return nil
}
func (x *CometInfo) GetLastCommit() *v1.CommitInfo {
if x != nil {
return x.LastCommit
}
return nil
}
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, 0x1c, 0x63, 0x6f, 0x6d, 0x65,
0x74, 0x62, 0x66, 0x74, 0x2f, 0x61, 0x62, 0x63, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x79, 0x70,
0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd9, 0x01, 0x0a, 0x09, 0x43, 0x6f, 0x6d,
0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x39, 0x0a, 0x08, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e,
0x63, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x6d, 0x65, 0x74,
0x62, 0x66, 0x74, 0x2e, 0x61, 0x62, 0x63, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x69, 0x73, 0x62,
0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x52, 0x08, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63,
0x65, 0x12, 0x27, 0x0a, 0x0f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x5f,
0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x76, 0x61, 0x6c, 0x69,
0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x48, 0x61, 0x73, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x72,
0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03,
0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x41, 0x64,
0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x3d, 0x0a, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x63, 0x6f,
0x6d, 0x6d, 0x69, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x63, 0x6f, 0x6d,
0x65, 0x74, 0x62, 0x66, 0x74, 0x2e, 0x61, 0x62, 0x63, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f,
0x6d, 0x6d, 0x69, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x6c, 0x61, 0x73, 0x74, 0x43, 0x6f,
0x6d, 0x6d, 0x69, 0x74, 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, 1)
var file_cosmos_consensus_v1_consensus_proto_goTypes = []interface{}{
(*CometInfo)(nil), // 0: cosmos.consensus.v1.CometInfo
(*v1.Misbehavior)(nil), // 1: cometbft.abci.v1.Misbehavior
(*v1.CommitInfo)(nil), // 2: cometbft.abci.v1.CommitInfo
}
var file_cosmos_consensus_v1_consensus_proto_depIdxs = []int32{
1, // 0: cosmos.consensus.v1.CometInfo.evidence:type_name -> cometbft.abci.v1.Misbehavior
2, // 1: cosmos.consensus.v1.CometInfo.last_commit:type_name -> cometbft.abci.v1.CommitInfo
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] 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.(*CometInfo); 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: 1,
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
}

View File

@ -28,7 +28,6 @@ require (
cosmossdk.io/math v1.3.0
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
@ -179,12 +178,7 @@ replace (
cosmossdk.io/core/testing => ../../core/testing
cosmossdk.io/store => ./../../store
cosmossdk.io/x/bank => ./../../x/bank
cosmossdk.io/x/consensus => ./../../x/consensus
cosmossdk.io/x/distribution => ./../../x/distribution
cosmossdk.io/x/gov => ./../../x/gov
cosmossdk.io/x/mint => ./../../x/mint
cosmossdk.io/x/protocolpool => ./../../x/protocolpool
cosmossdk.io/x/slashing => ./../../x/slashing
cosmossdk.io/x/staking => ./../../x/staking
cosmossdk.io/x/tx => ./../../x/tx
)

View File

@ -18,6 +18,8 @@ cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
cosmossdk.io/schema v0.2.0 h1:UH5CR1DqUq8yP+5Np8PbvG4YX0zAUsTN2Qk6yThmfMk=
cosmossdk.io/schema v0.2.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 h1:XQJj9Dv9Gtze0l2TF79BU5lkP6MkUveTUuKICmxoz+o=
cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190/go.mod h1:7WUGupOvmlHJoIMBz1JbObQxeo6/TDiuDBxmtod8HRg=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs=

2
go.mod
View File

@ -14,7 +14,6 @@ require (
cosmossdk.io/schema v0.2.0
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000
cosmossdk.io/x/tx v0.13.3
github.com/99designs/keyring v1.2.2
@ -189,7 +188,6 @@ replace (
cosmossdk.io/core/testing => ./core/testing
cosmossdk.io/store => ./store
cosmossdk.io/x/bank => ./x/bank
cosmossdk.io/x/consensus => ./x/consensus
cosmossdk.io/x/staking => ./x/staking
cosmossdk.io/x/tx => ./x/tx
)

View File

@ -26,4 +26,5 @@ $mockgen_cmd -source=x/gov/testutil/expected_keepers.go -package testutil -desti
$mockgen_cmd -source=x/staking/types/expected_keepers.go -package testutil -destination x/staking/testutil/expected_keepers_mocks.go
# $mockgen_cmd -source=x/auth/vesting/types/expected_keepers.go -package testutil -destination x/auth/vesting/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/protocolpool/types/expected_keepers.go -package testutil -destination x/protocolpool/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/upgrade/types/expected_keepers.go -package testutil -destination x/upgrade/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=core/gas/service.go -package gas -destination core/testing/gas/service_mocks.go

View File

@ -3,11 +3,18 @@ package cometbft
import (
"context"
"crypto/sha256"
"encoding/json"
"io"
"strings"
"testing"
"time"
abciproto "github.com/cometbft/cometbft/api/cometbft/abci/v1"
v1 "github.com/cometbft/cometbft/api/cometbft/types/v1"
"github.com/cosmos/gogoproto/proto"
gogotypes "github.com/cosmos/gogoproto/types"
"github.com/stretchr/testify/require"
appmodulev2 "cosmossdk.io/core/appmodule/v2"
"cosmossdk.io/core/store"
"cosmossdk.io/core/transaction"
@ -20,16 +27,7 @@ import (
"cosmossdk.io/server/v2/stf"
"cosmossdk.io/server/v2/stf/branch"
"cosmossdk.io/server/v2/stf/mock"
abciproto "github.com/cometbft/cometbft/api/cometbft/abci/v1"
v1 "github.com/cometbft/cometbft/api/cometbft/types/v1"
"github.com/cosmos/gogoproto/proto"
"encoding/json"
consensustypes "cosmossdk.io/x/consensus/types"
gogotypes "github.com/cosmos/gogoproto/types"
"github.com/stretchr/testify/require"
)
var (

View File

@ -6,7 +6,6 @@ import (
"cosmossdk.io/core/log"
corestore "cosmossdk.io/core/store"
storev2 "cosmossdk.io/store/v2"
"cosmossdk.io/store/v2/commitment"
"cosmossdk.io/store/v2/commitment/iavl"
@ -17,7 +16,7 @@ import (
)
type MockStore struct {
Storage storev2.VersionedDatabase
Storage storev2.VersionedDatabase
Committer storev2.Committer
}

View File

@ -33,7 +33,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
}
anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(options.Environment), // outermost AnteDecorator. SetUpContext must be called first
ante.NewSetUpContextDecorator(options.Environment, options.ConsensusKeeper), // outermost AnteDecorator. SetUpContext must be called first
circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper),
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(options.Environment),

View File

@ -363,6 +363,7 @@ func NewSimApp(
runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())),
app.AuthKeeper,
app.BankKeeper,
app.ConsensusParamsKeeper,
govModuleAddr,
signingCtx.ValidatorAddressCodec(),
authcodec.NewBech32Codec(sdk.Bech32PrefixConsAddr),
@ -409,7 +410,7 @@ func NewSimApp(
}
homePath := cast.ToString(appOpts.Get(flags.FlagHome))
// set the governance module account as the authority for conducting upgrades
app.UpgradeKeeper = upgradekeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), logger.With(log.ModuleKey, "x/upgrade"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), skipUpgradeHeights, appCodec, homePath, app.BaseApp, govModuleAddr)
app.UpgradeKeeper = upgradekeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), logger.With(log.ModuleKey, "x/upgrade"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), skipUpgradeHeights, appCodec, homePath, app.BaseApp, govModuleAddr, app.ConsensusParamsKeeper)
// Register the proposal types
// Deprecated: Avoid adding new handlers, instead use the new proposal flow
@ -436,7 +437,7 @@ func NewSimApp(
// create evidence keeper with router
evidenceKeeper := evidencekeeper.NewKeeper(
appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), logger.With(log.ModuleKey, "x/evidence"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), app.StakingKeeper, app.SlashingKeeper, app.AuthKeeper.AddressCodec(),
appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), logger.With(log.ModuleKey, "x/evidence"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), app.StakingKeeper, app.SlashingKeeper, app.ConsensusParamsKeeper, app.AuthKeeper.AddressCodec(),
)
// If evidence needs to be handled for the app, set routes in router here and seal
app.EvidenceKeeper = *evidenceKeeper
@ -647,6 +648,7 @@ func (app *SimApp) setAnteHandler(txConfig client.TxConfig) {
AccountAbstractionKeeper: app.AccountsKeeper,
AccountKeeper: app.AuthKeeper,
BankKeeper: app.BankKeeper,
ConsensusKeeper: app.ConsensusParamsKeeper,
SignModeHandler: txConfig.SignModeHandler(),
FeegrantKeeper: app.FeeGrantKeeper,
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,

View File

@ -298,6 +298,7 @@ func (app *SimApp) setCustomAnteHandler() {
ante.HandlerOptions{
AccountKeeper: app.AuthKeeper,
BankKeeper: app.BankKeeper,
ConsensusKeeper: app.ConsensusParamsKeeper,
SignModeHandler: app.txConfig.SignModeHandler(),
FeegrantKeeper: app.FeeGrantKeeper,
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,

View File

@ -18,6 +18,8 @@ import (
"cosmossdk.io/x/bank"
bankkeeper "cosmossdk.io/x/bank/keeper"
banktypes "cosmossdk.io/x/bank/types"
"cosmossdk.io/x/consensus"
consensusparamkeeper "cosmossdk.io/x/consensus/keeper"
consensustypes "cosmossdk.io/x/consensus/types"
"cosmossdk.io/x/distribution"
distrkeeper "cosmossdk.io/x/distribution/keeper"
@ -132,7 +134,8 @@ func initFixture(t *testing.T) *fixture {
grpcRouter := baseapp.NewGRPCQueryRouter()
cometService := runtime.NewContextAwareCometInfoService()
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), cometService)
consensusParamsKeeper := consensusparamkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensustypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcRouter), runtime.EnvWithMsgRouterService(msgRouter)), authtypes.NewModuleAddress("gov").String())
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, consensusParamsKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), cometService)
require.NoError(t, stakingKeeper.Params.Set(newCtx, stakingtypes.DefaultParams()))
poolKeeper := poolkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[pooltypes.StoreKey]), log.NewNopLogger()), accountKeeper, bankKeeper, stakingKeeper, authority.String())
@ -146,6 +149,7 @@ func initFixture(t *testing.T) *fixture {
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
distrModule := distribution.NewAppModule(cdc, distrKeeper, accountKeeper, bankKeeper, stakingKeeper)
poolModule := protocolpool.NewAppModule(cdc, poolKeeper, accountKeeper, bankKeeper)
consensusModule := consensus.NewAppModule(cdc, consensusParamsKeeper)
addr := sdk.AccAddress(PKS[0].Address())
valAddr := sdk.ValAddress(addr)
@ -171,11 +175,12 @@ func initFixture(t *testing.T) *fixture {
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
distrtypes.ModuleName: distrModule,
pooltypes.ModuleName: poolModule,
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
distrtypes.ModuleName: distrModule,
pooltypes.ModuleName: poolModule,
consensustypes.ModuleName: consensusModule,
},
msgRouter,
grpcRouter,

View File

@ -1,4 +1,4 @@
package v4_test
package distribution_test
import (
"context"
@ -8,6 +8,7 @@ import (
"github.com/stretchr/testify/require"
"cosmossdk.io/core/comet"
coretesting "cosmossdk.io/core/testing"
"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/bank"
@ -22,7 +23,9 @@ import (
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/testutil/integration"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
@ -32,6 +35,34 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)
func TestMigration(t *testing.T) {
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}).Codec
storeKey := storetypes.NewKVStoreKey("distribution")
storeService := runtime.NewKVStoreService(storeKey)
tKey := storetypes.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(storeKey, tKey)
env := runtime.NewEnvironment(storeService, coretesting.NewNopLogger())
addr1 := secp256k1.GenPrivKey().PubKey().Address()
consAddr1 := sdk.ConsAddress(addr1)
// Set and check the previous proposer
err := v4.SetPreviousProposerConsAddr(ctx, storeService, cdc, consAddr1)
require.NoError(t, err)
gotAddr, err := v4.GetPreviousProposerConsAddr(ctx, storeService, cdc)
require.NoError(t, err)
require.Equal(t, consAddr1, gotAddr)
err = v4.MigrateStore(ctx, env, cdc)
require.NoError(t, err)
// Check that the previous proposer has been removed
_, err = v4.GetPreviousProposerConsAddr(ctx, storeService, cdc)
require.ErrorContains(t, err, "previous proposer not set")
}
type emptyCometService struct{}
// CometInfo implements comet.Service.

View File

@ -20,6 +20,8 @@ import (
"cosmossdk.io/x/bank"
bankkeeper "cosmossdk.io/x/bank/keeper"
banktypes "cosmossdk.io/x/bank/types"
"cosmossdk.io/x/consensus"
consensusparamkeeper "cosmossdk.io/x/consensus/keeper"
consensusparamtypes "cosmossdk.io/x/consensus/types"
"cosmossdk.io/x/evidence"
"cosmossdk.io/x/evidence/exported"
@ -144,13 +146,15 @@ func initFixture(tb testing.TB) *fixture {
assert.NilError(tb, bankKeeper.SetParams(newCtx, banktypes.DefaultParams()))
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcQueryRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
consensusParamsKeeper := consensusparamkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcQueryRouter), runtime.EnvWithMsgRouterService(msgRouter)), authtypes.NewModuleAddress("gov").String())
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcQueryRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, consensusParamsKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
slashingKeeper := slashingkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), log.NewNopLogger()), cdc, codec.NewLegacyAmino(), stakingKeeper, authority.String())
stakingKeeper.SetHooks(stakingtypes.NewMultiStakingHooks(slashingKeeper.Hooks()))
evidenceKeeper := keeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcQueryRouter), runtime.EnvWithMsgRouterService(msgRouter)), stakingKeeper, slashingKeeper, addresscodec.NewBech32Codec(sdk.Bech32PrefixAccAddr))
evidenceKeeper := keeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcQueryRouter), runtime.EnvWithMsgRouterService(msgRouter)), stakingKeeper, slashingKeeper, consensusParamsKeeper, addresscodec.NewBech32Codec(sdk.Bech32PrefixAccAddr))
router := evidencetypes.NewRouter()
router = router.AddRoute(evidencetypes.RouteEquivocation, testEquivocationHandler(evidenceKeeper))
evidenceKeeper.SetRouter(router)
@ -160,16 +164,18 @@ func initFixture(tb testing.TB) *fixture {
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
slashingModule := slashing.NewAppModule(cdc, slashingKeeper, accountKeeper, bankKeeper, stakingKeeper, cdc.InterfaceRegistry(), cometInfoService)
evidenceModule := evidence.NewAppModule(cdc, *evidenceKeeper, cometInfoService)
consensusModule := consensus.NewAppModule(cdc, consensusParamsKeeper)
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc,
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
slashingtypes.ModuleName: slashingModule,
evidencetypes.ModuleName: evidenceModule,
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
slashingtypes.ModuleName: slashingModule,
evidencetypes.ModuleName: evidenceModule,
consensusparamtypes.ModuleName: consensusModule,
},
msgRouter,
grpcQueryRouter,

View File

@ -13,6 +13,9 @@ import (
"cosmossdk.io/x/bank"
bankkeeper "cosmossdk.io/x/bank/keeper"
banktypes "cosmossdk.io/x/bank/types"
"cosmossdk.io/x/consensus"
consensusparamkeeper "cosmossdk.io/x/consensus/keeper"
consensusparamtypes "cosmossdk.io/x/consensus/types"
"cosmossdk.io/x/gov"
"cosmossdk.io/x/gov/keeper"
"cosmossdk.io/x/gov/types"
@ -54,7 +57,7 @@ type fixture struct {
func initFixture(tb testing.TB) *fixture {
tb.Helper()
keys := storetypes.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, pooltypes.StoreKey, types.StoreKey,
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, pooltypes.StoreKey, types.StoreKey, consensusparamtypes.StoreKey,
)
encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, bank.AppModule{}, gov.AppModule{})
cdc := encodingCfg.Codec
@ -110,7 +113,11 @@ func initFixture(tb testing.TB) *fixture {
assert.NilError(tb, bankKeeper.SetParams(newCtx, banktypes.DefaultParams()))
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger()), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
router := baseapp.NewMsgServiceRouter()
queryRouter := baseapp.NewGRPCQueryRouter()
consensusParamsKeeper := consensusparamkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(router)), authtypes.NewModuleAddress("gov").String())
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger()), accountKeeper, bankKeeper, consensusParamsKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
poolKeeper := poolkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[pooltypes.StoreKey]), log.NewNopLogger()), accountKeeper, bankKeeper, stakingKeeper, authority.String())
@ -120,9 +127,7 @@ func initFixture(tb testing.TB) *fixture {
// Create MsgServiceRouter, but don't populate it before creating the gov
// keeper.
router := baseapp.NewMsgServiceRouter()
router.SetInterfaceRegistry(cdc.InterfaceRegistry())
queryRouter := baseapp.NewGRPCQueryRouter()
queryRouter.SetInterfaceRegistry(cdc.InterfaceRegistry())
govKeeper := keeper.NewKeeper(
@ -146,15 +151,17 @@ func initFixture(tb testing.TB) *fixture {
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
govModule := gov.NewAppModule(cdc, govKeeper, accountKeeper, bankKeeper, poolKeeper)
consensusModule := consensus.NewAppModule(cdc, consensusParamsKeeper)
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc,
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
types.ModuleName: govModule,
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
types.ModuleName: govModule,
consensusparamtypes.ModuleName: consensusModule,
},
baseapp.NewMsgServiceRouter(),
baseapp.NewGRPCQueryRouter(),

View File

@ -17,6 +17,8 @@ import (
"cosmossdk.io/x/bank"
bankkeeper "cosmossdk.io/x/bank/keeper"
banktypes "cosmossdk.io/x/bank/types"
"cosmossdk.io/x/consensus"
consensusparamkeeper "cosmossdk.io/x/consensus/keeper"
consensustypes "cosmossdk.io/x/consensus/types"
minttypes "cosmossdk.io/x/mint/types"
"cosmossdk.io/x/slashing"
@ -117,21 +119,25 @@ func initFixture(tb testing.TB) *fixture {
cometInfoService := runtime.NewContextAwareCometInfoService()
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), cometInfoService)
consensusParamsKeeper := consensusparamkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensustypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)), authtypes.NewModuleAddress("gov").String())
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, consensusParamsKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), cometInfoService)
slashingKeeper := slashingkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)), cdc, &codec.LegacyAmino{}, stakingKeeper, authority.String())
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
slashingModule := slashing.NewAppModule(cdc, slashingKeeper, accountKeeper, bankKeeper, stakingKeeper, cdc.InterfaceRegistry(), cometInfoService)
consensusModule := consensus.NewAppModule(cdc, consensusParamsKeeper)
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc,
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
slashingtypes.ModuleName: slashingModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
slashingtypes.ModuleName: slashingModule,
consensustypes.ModuleName: consensusModule,
},
msgRouter,
queryRouter,

View File

@ -15,6 +15,8 @@ import (
"cosmossdk.io/x/bank"
bankkeeper "cosmossdk.io/x/bank/keeper"
banktypes "cosmossdk.io/x/bank/types"
"cosmossdk.io/x/consensus"
consensusparamkeeper "cosmossdk.io/x/consensus/keeper"
consensustypes "cosmossdk.io/x/consensus/types"
minttypes "cosmossdk.io/x/mint/types"
pooltypes "cosmossdk.io/x/protocolpool/types"
@ -162,19 +164,23 @@ func initFixture(tb testing.TB) *fixture {
assert.NilError(tb, bankKeeper.SetParams(newCtx, banktypes.DefaultParams()))
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[types.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
consensusParamsKeeper := consensusparamkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensustypes.StoreKey]), log.NewNopLogger()), authtypes.NewModuleAddress("gov").String())
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[types.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, consensusParamsKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
authModule := auth.NewAppModule(cdc, accountKeeper, acctsModKeeper, authsims.RandomGenesisAccounts, nil)
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
consensusModule := consensus.NewAppModule(cdc, consensusParamsKeeper)
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc,
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
types.ModuleName: stakingModule,
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
types.ModuleName: stakingModule,
consensustypes.ModuleName: consensusModule,
},
msgRouter,
queryRouter,

View File

@ -17,6 +17,9 @@ import (
bankkeeper "cosmossdk.io/x/bank/keeper"
banktestutil "cosmossdk.io/x/bank/testutil"
banktypes "cosmossdk.io/x/bank/types"
"cosmossdk.io/x/consensus"
consensusparamkeeper "cosmossdk.io/x/consensus/keeper"
consensusparamtypes "cosmossdk.io/x/consensus/types"
"cosmossdk.io/x/distribution"
minttypes "cosmossdk.io/x/mint/types"
"cosmossdk.io/x/staking"
@ -71,7 +74,7 @@ type deterministicFixture struct {
func initDeterministicFixture(t *testing.T) *deterministicFixture {
t.Helper()
keys := storetypes.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, consensusparamtypes.StoreKey,
)
encodingCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, distribution.AppModule{})
cdc := encodingCfg.Codec
@ -124,19 +127,23 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
assert.NilError(t, bankKeeper.SetParams(newCtx, banktypes.DefaultParams()))
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger()), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
consensusParamsKeeper := consensusparamkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), log.NewNopLogger()), authtypes.NewModuleAddress("gov").String())
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger()), accountKeeper, bankKeeper, consensusParamsKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
authModule := auth.NewAppModule(cdc, accountKeeper, acctsModKeeper, authsims.RandomGenesisAccounts, nil)
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)
consensusModule := consensus.NewAppModule(cdc, consensusParamsKeeper)
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc,
encodingCfg.InterfaceRegistry.SigningContext().AddressCodec(),
encodingCfg.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
stakingtypes.ModuleName: stakingModule,
consensusparamtypes.ModuleName: consensusModule,
},
baseapp.NewMsgServiceRouter(),
baseapp.NewGRPCQueryRouter(),

View File

@ -9,14 +9,14 @@ import (
cmttypes "github.com/cometbft/cometbft/types"
dbm "github.com/cosmos/cosmos-db"
"cosmossdk.io/collections"
"cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
corestore "cosmossdk.io/core/store"
"cosmossdk.io/log"
"cosmossdk.io/store"
"cosmossdk.io/store/metrics"
storetypes "cosmossdk.io/store/types"
consensusparamkeeper "cosmossdk.io/x/consensus/keeper"
consensusparamtypes "cosmossdk.io/x/consensus/types"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
@ -26,10 +26,12 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)
const appName = "integration-app"
const (
appName = "integration-app"
consensus = "consensus"
)
// App is a test application that can be used to test the integration of modules.
type App struct {
@ -88,14 +90,12 @@ func NewIntegrationApp(
grpcRouter.SetInterfaceRegistry(interfaceRegistry)
bApp.SetGRPCQueryRouter(grpcRouter)
if keys[consensusparamtypes.StoreKey] != nil {
// set baseApp param store
consensusParamsKeeper := consensusparamkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcRouter), runtime.EnvWithMsgRouterService(msgRouter)), authtypes.NewModuleAddress("gov").String())
bApp.SetParamStore(consensusParamsKeeper.ParamsStore)
consensusparamtypes.RegisterQueryServer(grpcRouter, consensusParamsKeeper)
if keys[consensus] != nil {
cps := newParamStore(runtime.NewKVStoreService(keys[consensus]), appCodec)
bApp.SetParamStore(cps)
params := cmttypes.ConsensusParamsFromProto(*simtestutil.DefaultConsensusParams) // This fills up missing param sections
err := consensusParamsKeeper.ParamsStore.Set(sdkCtx, params.ToProto())
err := cps.Set(sdkCtx, params.ToProto())
if err != nil {
panic(fmt.Errorf("failed to set consensus params: %w", err))
}
@ -211,3 +211,26 @@ func CreateMultiStore(keys map[string]*storetypes.KVStoreKey, logger log.Logger)
_ = cms.LoadLatestVersion()
return cms
}
type paramStoreService struct {
ParamsStore collections.Item[cmtproto.ConsensusParams]
}
func newParamStore(storeService corestore.KVStoreService, cdc codec.Codec) paramStoreService {
sb := collections.NewSchemaBuilder(storeService)
return paramStoreService{
ParamsStore: collections.NewItem(sb, collections.NewPrefix("Consensus"), "params", codec.CollValue[cmtproto.ConsensusParams](cdc)),
}
}
func (pss paramStoreService) Get(ctx context.Context) (cmtproto.ConsensusParams, error) {
return pss.ParamsStore.Get(ctx)
}
func (pss paramStoreService) Has(ctx context.Context) (bool, error) {
return pss.ParamsStore.Has(ctx)
}
func (pss paramStoreService) Set(ctx context.Context, cp cmtproto.ConsensusParams) error {
return pss.ParamsStore.Set(ctx, cp)
}

View File

@ -24,7 +24,6 @@ require (
cosmossdk.io/math v1.3.0
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.3 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect

View File

@ -25,7 +25,6 @@ require (
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.3 // indirect
filippo.io/edwards25519 v1.1.0 // indirect

View File

@ -34,7 +34,6 @@ require (
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc // indirect
cosmossdk.io/x/accounts/defaults/lockup v0.0.0-20240417181816-5e7aae0db1f5
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/distribution v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
@ -186,7 +185,6 @@ replace (
cosmossdk.io/x/accounts/defaults/lockup => ./defaults/lockup
cosmossdk.io/x/accounts/defaults/multisig => ./defaults/multisig
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/distribution => ../distribution
cosmossdk.io/x/mint => ../mint
cosmossdk.io/x/slashing => ../slashing

View File

@ -53,6 +53,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#19535](https://github.com/cosmos/cosmos-sdk/pull/19535) Remove vesting account creation when the chain is running. The accounts module is required for creating [#vesting accounts](../accounts/defaults/lockup/README.md) on a running chain.
* [#19600](https://github.com/cosmos/cosmos-sdk/pull/19600) add a consensus query method to the consensus module in order for modules to query consensus for the consensus params.
* [#19600](https://github.com/cosmos/cosmos-sdk/pull/21403) NewAppModule now takes in `ante.ExtensionOptionChecker`, but it's only used in server/v2 chains, so it's safe to pass in nil for the rest of the users.
* [#21480](https://github.com/cosmos/cosmos-sdk/pull/21480) ConsensusKeeper is a required keeper for ante handlers.
### Consensus Breaking Changes

View File

@ -19,6 +19,7 @@ type HandlerOptions struct {
AccountKeeper AccountKeeper
AccountAbstractionKeeper AccountAbstractionKeeper
BankKeeper types.BankKeeper
ConsensusKeeper ConsensusKeeper
ExtensionOptionChecker ExtensionOptionChecker
FeegrantKeeper FeegrantKeeper
SignModeHandler *txsigning.HandlerMap
@ -44,7 +45,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
}
anteDecorators := []sdk.AnteDecorator{
NewSetUpContextDecorator(options.Environment), // outermost AnteDecorator. SetUpContext must be called first
NewSetUpContextDecorator(options.Environment, options.ConsensusKeeper), // outermost AnteDecorator. SetUpContext must be called first
NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
NewValidateBasicDecorator(options.Environment),
NewTxTimeoutHeightDecorator(options.Environment),

View File

@ -1249,6 +1249,7 @@ func TestCustomSignatureVerificationGasConsumer(t *testing.T) {
ante.HandlerOptions{
AccountKeeper: suite.accountKeeper,
BankKeeper: suite.bankKeeper,
ConsensusKeeper: suite.consensusKeeper,
FeegrantKeeper: suite.feeGrantKeeper,
SignModeHandler: suite.clientCtx.TxConfig.SignModeHandler(),
SigGasConsumer: func(meter gas.Meter, sig signing.SignatureV2, params authtypes.Params) error {

View File

@ -5,7 +5,6 @@ import (
"cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
consensustypes "cosmossdk.io/x/consensus/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/types"
@ -29,5 +28,5 @@ type FeegrantKeeper interface {
}
type ConsensusKeeper interface {
Params(context.Context, *consensustypes.QueryParamsRequest) (*consensustypes.QueryParamsResponse, error)
BlockParams(context.Context) (uint64, uint64, error)
}

View File

@ -6,7 +6,6 @@ import (
"cosmossdk.io/core/appmodule"
errorsmod "cosmossdk.io/errors"
storetypes "cosmossdk.io/store/types"
consensusv1 "cosmossdk.io/x/consensus/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
@ -24,12 +23,14 @@ type GasTx interface {
// CONTRACT: Must be first decorator in the chain
// CONTRACT: Tx must implement GasTx interface
type SetUpContextDecorator struct {
env appmodule.Environment
env appmodule.Environment
consensusKeeper ConsensusKeeper
}
func NewSetUpContextDecorator(env appmodule.Environment) SetUpContextDecorator {
func NewSetUpContextDecorator(env appmodule.Environment, consensusKeeper ConsensusKeeper) SetUpContextDecorator {
return SetUpContextDecorator{
env: env,
env: env,
consensusKeeper: consensusKeeper,
}
}
@ -45,23 +46,13 @@ func (sud SetUpContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool,
newCtx = SetGasMeter(ctx, gasTx.GetGas())
// TODO: possibly cache the result of this query for other antehandlers to use
resp, err := sud.env.QueryRouterService.Invoke(ctx, &consensusv1.QueryParamsRequest{})
maxGas, _, err := sud.consensusKeeper.BlockParams(ctx)
if err != nil {
return newCtx, err
}
res, ok := resp.(*consensusv1.QueryParamsResponse)
if !ok {
return newCtx, fmt.Errorf("unexpected response type: %T", resp)
}
if res.Params.Block != nil {
// If there exists a maximum block gas limit, we must ensure that the tx
// does not exceed it.
if res.Params.Block.MaxGas > 0 && gasTx.GetGas() > uint64(res.Params.Block.MaxGas) {
return newCtx, errorsmod.Wrapf(sdkerrors.ErrInvalidGasLimit, "tx gas limit %d exceeds block max gas %d", gasTx.GetGas(), res.Params.Block.MaxGas)
}
if maxGas > 0 && gasTx.GetGas() > maxGas {
return newCtx, errorsmod.Wrapf(sdkerrors.ErrInvalidGasLimit, "tx gas limit %d exceeds block max gas %d", gasTx.GetGas(), maxGas)
}
// Decorator will catch an OutOfGasPanic caused in the next antehandler

View File

@ -33,7 +33,7 @@ func TestSetupDecorator_BlockMaxGas(t *testing.T) {
tx, err := suite.CreateTestTx(suite.ctx, privs, accNums, accSeqs, suite.ctx.ChainID(), signing.SignMode_SIGN_MODE_DIRECT)
require.NoError(t, err)
sud := ante.NewSetUpContextDecorator(suite.env)
sud := ante.NewSetUpContextDecorator(suite.env, suite.consensusKeeper)
antehandler := sdk.ChainAnteDecorators(sud)
suite.ctx = suite.ctx.
@ -63,7 +63,7 @@ func TestSetup(t *testing.T) {
tx, err := suite.CreateTestTx(suite.ctx, privs, accNums, accSeqs, suite.ctx.ChainID(), signing.SignMode_SIGN_MODE_DIRECT)
require.NoError(t, err)
sud := ante.NewSetUpContextDecorator(suite.env)
sud := ante.NewSetUpContextDecorator(suite.env, suite.consensusKeeper)
antehandler := sdk.ChainAnteDecorators(sud)
// Set height to non-zero value for GasMeter to be set
@ -98,7 +98,7 @@ func TestRecoverPanic(t *testing.T) {
tx, err := suite.CreateTestTx(suite.ctx, privs, accNums, accSeqs, suite.ctx.ChainID(), signing.SignMode_SIGN_MODE_DIRECT)
require.NoError(t, err)
sud := ante.NewSetUpContextDecorator(suite.env)
sud := ante.NewSetUpContextDecorator(suite.env, suite.consensusKeeper)
antehandler := sdk.ChainAnteDecorators(sud, OutOfGasDecorator{})
// Set height to non-zero value for GasMeter to be set

View File

@ -10,9 +10,8 @@ import (
address "cosmossdk.io/core/address"
appmodule "cosmossdk.io/core/appmodule"
types "cosmossdk.io/x/consensus/types"
types0 "github.com/cosmos/cosmos-sdk/types"
types1 "github.com/cosmos/cosmos-sdk/x/auth/types"
types "github.com/cosmos/cosmos-sdk/types"
types0 "github.com/cosmos/cosmos-sdk/x/auth/types"
gomock "github.com/golang/mock/gomock"
)
@ -54,10 +53,10 @@ func (mr *MockAccountKeeperMockRecorder) AddressCodec() *gomock.Call {
}
// GetAccount mocks base method.
func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types0.AccAddress) types0.AccountI {
func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAccount", ctx, addr)
ret0, _ := ret[0].(types0.AccountI)
ret0, _ := ret[0].(types.AccountI)
return ret0
}
@ -82,10 +81,10 @@ func (mr *MockAccountKeeperMockRecorder) GetEnvironment() *gomock.Call {
}
// GetModuleAddress mocks base method.
func (m *MockAccountKeeper) GetModuleAddress(moduleName string) types0.AccAddress {
func (m *MockAccountKeeper) GetModuleAddress(moduleName string) types.AccAddress {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetModuleAddress", moduleName)
ret0, _ := ret[0].(types0.AccAddress)
ret0, _ := ret[0].(types.AccAddress)
return ret0
}
@ -96,10 +95,10 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(moduleName interface{}
}
// GetParams mocks base method.
func (m *MockAccountKeeper) GetParams(ctx context.Context) types1.Params {
func (m *MockAccountKeeper) GetParams(ctx context.Context) types0.Params {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetParams", ctx)
ret0, _ := ret[0].(types1.Params)
ret0, _ := ret[0].(types0.Params)
return ret0
}
@ -110,10 +109,10 @@ func (mr *MockAccountKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call
}
// NewAccountWithAddress mocks base method.
func (m *MockAccountKeeper) NewAccountWithAddress(ctx context.Context, addr types0.AccAddress) types0.AccountI {
func (m *MockAccountKeeper) NewAccountWithAddress(ctx context.Context, addr types.AccAddress) types.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr)
ret0, _ := ret[0].(types0.AccountI)
ret0, _ := ret[0].(types.AccountI)
return ret0
}
@ -124,7 +123,7 @@ func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interfa
}
// SetAccount mocks base method.
func (m *MockAccountKeeper) SetAccount(ctx context.Context, acc types0.AccountI) {
func (m *MockAccountKeeper) SetAccount(ctx context.Context, acc types.AccountI) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetAccount", ctx, acc)
}
@ -159,7 +158,7 @@ func (m *MockFeegrantKeeper) EXPECT() *MockFeegrantKeeperMockRecorder {
}
// UseGrantedFees mocks base method.
func (m *MockFeegrantKeeper) UseGrantedFees(ctx context.Context, granter, grantee types0.AccAddress, fee types0.Coins, msgs []types0.Msg) error {
func (m *MockFeegrantKeeper) UseGrantedFees(ctx context.Context, granter, grantee types.AccAddress, fee types.Coins, msgs []types.Msg) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UseGrantedFees", ctx, granter, grantee, fee, msgs)
ret0, _ := ret[0].(error)
@ -195,17 +194,18 @@ func (m *MockConsensusKeeper) EXPECT() *MockConsensusKeeperMockRecorder {
return m.recorder
}
// Params mocks base method.
func (m *MockConsensusKeeper) Params(arg0 context.Context, arg1 *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
// BlockParams mocks base method.
func (m *MockConsensusKeeper) BlockParams(arg0 context.Context) (uint64, uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Params", arg0, arg1)
ret0, _ := ret[0].(*types.QueryParamsResponse)
ret1, _ := ret[1].(error)
return ret0, ret1
ret := m.ctrl.Call(m, "BlockParams", arg0)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(uint64)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// Params indicates an expected call of Params.
func (mr *MockConsensusKeeperMockRecorder) Params(arg0, arg1 interface{}) *gomock.Call {
// BlockParams indicates an expected call of BlockParams.
func (mr *MockConsensusKeeperMockRecorder) BlockParams(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Params", reflect.TypeOf((*MockConsensusKeeper)(nil).Params), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlockParams", reflect.TypeOf((*MockConsensusKeeper)(nil).BlockParams), arg0)
}

View File

@ -16,7 +16,6 @@ import (
"cosmossdk.io/core/header"
coretesting "cosmossdk.io/core/testing"
storetypes "cosmossdk.io/store/types"
consensustypes "cosmossdk.io/x/consensus/types"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
@ -101,10 +100,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite {
grpcQueryRouter.SetInterfaceRegistry(suite.encCfg.InterfaceRegistry)
suite.consensusKeeper = antetestutil.NewMockConsensusKeeper(ctrl)
suite.consensusKeeper.EXPECT().Params(gomock.Any(), gomock.Any()).Return(&consensustypes.QueryParamsResponse{
Params: simtestutil.DefaultConsensusParams,
}, nil).AnyTimes()
consensustypes.RegisterQueryServer(grpcQueryRouter, suite.consensusKeeper)
suite.consensusKeeper.EXPECT().BlockParams(gomock.Any()).Return(uint64(simtestutil.DefaultConsensusParams.Block.MaxGas), uint64(simtestutil.DefaultConsensusParams.Block.MaxBytes), nil).AnyTimes()
suite.env = runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcQueryRouter), runtime.EnvWithMsgRouterService(msgRouter))
suite.accountKeeper = keeper.NewAccountKeeper(
@ -127,6 +123,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite {
ante.HandlerOptions{
AccountKeeper: suite.accountKeeper,
BankKeeper: suite.bankKeeper,
ConsensusKeeper: suite.consensusKeeper,
FeegrantKeeper: suite.feeGrantKeeper,
SignModeHandler: suite.encCfg.TxConfig.SignModeHandler(),
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,

View File

@ -55,6 +55,7 @@ type ModuleInputs struct {
ProtoFileResolver txsigning.ProtoFileResolver
Environment appmodulev2.Environment
// BankKeeper is the expected bank keeper to be passed to AnteHandlers / Tx Validators
ConsensusKeeper ante.ConsensusKeeper
BankKeeper authtypes.BankKeeper `optional:"true"`
MetadataBankKeeper BankKeeper `optional:"true"`
AccountKeeper ante.AccountKeeper `optional:"true"`
@ -200,6 +201,7 @@ func newAnteHandler(txConfig client.TxConfig, in ModuleInputs) (sdk.AnteHandler,
ante.HandlerOptions{
Environment: in.Environment,
AccountKeeper: in.AccountKeeper,
ConsensusKeeper: in.ConsensusKeeper,
BankKeeper: in.BankKeeper,
SignModeHandler: txConfig.SignModeHandler(),
FeegrantKeeper: in.FeeGrantKeeper,

View File

@ -7,13 +7,12 @@ require (
cosmossdk.io/core v1.0.0-alpha.1
cosmossdk.io/depinject v1.0.0
cosmossdk.io/errors v1.0.1
cosmossdk.io/log v1.4.1
cosmossdk.io/math v1.3.0
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000
cosmossdk.io/x/tx v0.13.3
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft v1.0.0-rc1.0.20240908111210-ab0be101882f // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.53.0
github.com/cosmos/gogoproto v1.7.0
@ -29,9 +28,9 @@ require (
require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/schema v0.2.0 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
@ -46,6 +45,8 @@ require (
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v1.1.1 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft v1.0.0-rc1.0.20240908111210-ab0be101882f // indirect
github.com/cometbft/cometbft-db v0.14.0 // indirect
github.com/cometbft/cometbft/api v1.0.0-rc.1 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
@ -111,6 +112,7 @@ require (
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
@ -163,14 +165,11 @@ require (
sigs.k8s.io/yaml v1.4.0 // indirect
)
require cosmossdk.io/log v1.4.1
require cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000
require (
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
cosmossdk.io/schema v0.2.0 // indirect
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
)
replace github.com/cosmos/cosmos-sdk => ../../.
@ -182,7 +181,6 @@ replace (
cosmossdk.io/core/testing => ../../core/testing
cosmossdk.io/store => ../../store
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/staking => ../staking
cosmossdk.io/x/tx => ../tx
)

View File

@ -30,7 +30,6 @@ require (
require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.3 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
@ -180,7 +179,6 @@ replace (
cosmossdk.io/collections => ../../collections
cosmossdk.io/core/testing => ../../core/testing
cosmossdk.io/store => ../../store
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/staking => ../staking
cosmossdk.io/x/tx => ../tx
)

View File

@ -26,7 +26,6 @@ require (
cosmossdk.io/math v1.3.0 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.3 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
@ -177,7 +176,6 @@ replace (
cosmossdk.io/core/testing => ../../core/testing
cosmossdk.io/store => ../../store
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/staking => ../staking
cosmossdk.io/x/tx => ../tx
)

View File

@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
cmttypes "github.com/cometbft/cometbft/types"
@ -143,3 +144,57 @@ func (k Keeper) paramCheck(ctx context.Context, consensusParams cmtproto.Consens
return &nextParams, nil
}
// BlockParams returns the maximum gas allowed in a block and the maximum bytes allowed in a block.
func (k Keeper) BlockParams(ctx context.Context) (uint64, uint64, error) {
params, err := k.ParamsStore.Get(ctx)
if err != nil {
return 0, 0, err
}
if params.Block == nil {
return 0, 0, errors.New("block gas is nil")
}
return uint64(params.Block.MaxGas), uint64(params.Block.MaxBytes), nil
}
// AppVersion returns the current application version.
func (k Keeper) AppVersion(ctx context.Context) (uint64, error) {
params, err := k.ParamsStore.Get(ctx)
if err != nil {
return 0, err
}
if params.Version == nil {
return 0, errors.New("app version is nil")
}
return params.Version.App, nil
}
// ValidatorPubKeyTypes returns the list of public key types that are allowed to be used for validators.
func (k Keeper) ValidatorPubKeyTypes(ctx context.Context) ([]string, error) {
params, err := k.ParamsStore.Get(ctx)
if err != nil {
return nil, err
}
fmt.Println("keyhere")
if params.Validator == nil {
return []string{}, errors.New("validator pub key types is nil")
}
return params.Validator.PubKeyTypes, nil
}
// EvidenceParams returns the maximum age of evidence, the time duration of the maximum age, and the maximum bytes.
func (k Keeper) EvidenceParams(ctx context.Context) (int64, time.Duration, uint64, error) {
params, err := k.ParamsStore.Get(ctx)
if err != nil {
return 0, 0, 0, err
}
if params.Evidence == nil {
return 0, 0, 0, errors.New("evidence age is nil")
}
return params.Evidence.MaxAgeNumBlocks, params.Evidence.MaxAgeDuration, uint64(params.Evidence.MaxBytes), nil
}

View File

@ -1,15 +0,0 @@
// Since: cosmos-sdk 0.52
syntax = "proto3";
package cosmos.consensus.v1;
import "cometbft/abci/v1/types.proto";
option go_package = "cosmossdk.io/x/consensus/types";
// CometInfo defines the structure of the x/consensus module's comet info.
message CometInfo {
repeated cometbft.abci.v1.Misbehavior evidence = 1;
bytes validators_hash = 2;
bytes proposer_address = 3;
cometbft.abci.v1.CommitInfo last_commit = 4;
}

View File

@ -1,503 +0,0 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: cosmos/consensus/v1/consensus.proto
package types
import (
fmt "fmt"
v1 "github.com/cometbft/cometbft/api/cometbft/abci/v1"
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
// CometInfo defines the structure of the x/consensus module's comet info.
type CometInfo struct {
Evidence []*v1.Misbehavior `protobuf:"bytes,1,rep,name=evidence,proto3" json:"evidence,omitempty"`
ValidatorsHash []byte `protobuf:"bytes,2,opt,name=validators_hash,json=validatorsHash,proto3" json:"validators_hash,omitempty"`
ProposerAddress []byte `protobuf:"bytes,3,opt,name=proposer_address,json=proposerAddress,proto3" json:"proposer_address,omitempty"`
LastCommit *v1.CommitInfo `protobuf:"bytes,4,opt,name=last_commit,json=lastCommit,proto3" json:"last_commit,omitempty"`
}
func (m *CometInfo) Reset() { *m = CometInfo{} }
func (m *CometInfo) String() string { return proto.CompactTextString(m) }
func (*CometInfo) ProtoMessage() {}
func (*CometInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_7ed86dd7d42fb61b, []int{0}
}
func (m *CometInfo) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *CometInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_CometInfo.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 *CometInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_CometInfo.Merge(m, src)
}
func (m *CometInfo) XXX_Size() int {
return m.Size()
}
func (m *CometInfo) XXX_DiscardUnknown() {
xxx_messageInfo_CometInfo.DiscardUnknown(m)
}
var xxx_messageInfo_CometInfo proto.InternalMessageInfo
func (m *CometInfo) GetEvidence() []*v1.Misbehavior {
if m != nil {
return m.Evidence
}
return nil
}
func (m *CometInfo) GetValidatorsHash() []byte {
if m != nil {
return m.ValidatorsHash
}
return nil
}
func (m *CometInfo) GetProposerAddress() []byte {
if m != nil {
return m.ProposerAddress
}
return nil
}
func (m *CometInfo) GetLastCommit() *v1.CommitInfo {
if m != nil {
return m.LastCommit
}
return nil
}
func init() {
proto.RegisterType((*CometInfo)(nil), "cosmos.consensus.v1.CometInfo")
}
func init() {
proto.RegisterFile("cosmos/consensus/v1/consensus.proto", fileDescriptor_7ed86dd7d42fb61b)
}
var fileDescriptor_7ed86dd7d42fb61b = []byte{
// 285 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x90, 0xb1, 0x4e, 0xf3, 0x30,
0x14, 0x85, 0xeb, 0xbf, 0xbf, 0x10, 0xb8, 0x88, 0xa2, 0xb0, 0x44, 0xa8, 0x58, 0x15, 0x0c, 0x94,
0xc5, 0x51, 0xca, 0x02, 0x03, 0x03, 0x74, 0x81, 0x81, 0x25, 0x23, 0x4b, 0xe4, 0x38, 0xae, 0x62,
0xd1, 0xe4, 0x46, 0xbe, 0xc6, 0x82, 0xb7, 0xe0, 0xb1, 0x18, 0x3b, 0xc2, 0x86, 0x92, 0x17, 0x41,
0x49, 0x28, 0x41, 0x62, 0x3c, 0xc7, 0xe7, 0x93, 0x7c, 0x3f, 0x7a, 0x22, 0x01, 0x73, 0xc0, 0x40,
0x42, 0x81, 0xaa, 0xc0, 0x27, 0x0c, 0x5c, 0xd8, 0x07, 0x5e, 0x1a, 0xb0, 0xe0, 0x1d, 0x74, 0x23,
0xde, 0xf7, 0x2e, 0x3c, 0x9c, 0x48, 0xc8, 0x95, 0x4d, 0x96, 0x36, 0x10, 0x89, 0xd4, 0x0d, 0x66,
0x5f, 0x4a, 0xf5, 0x8d, 0x1c, 0x7f, 0x10, 0xba, 0xb3, 0x68, 0x06, 0x77, 0xc5, 0x12, 0xbc, 0x4b,
0xba, 0xad, 0x9c, 0x4e, 0x55, 0x21, 0x95, 0x4f, 0xa6, 0xc3, 0xd9, 0x68, 0x7e, 0xc4, 0x37, 0x38,
0x6f, 0x70, 0xee, 0x42, 0x7e, 0xaf, 0x31, 0x51, 0x99, 0x70, 0x1a, 0x4c, 0xf4, 0x33, 0xf7, 0x4e,
0xe9, 0xd8, 0x89, 0x95, 0x4e, 0x85, 0x05, 0x83, 0x71, 0x26, 0x30, 0xf3, 0xff, 0x4d, 0xc9, 0x6c,
0x37, 0xda, 0xeb, 0xeb, 0x5b, 0x81, 0x99, 0x77, 0x46, 0xf7, 0x4b, 0x03, 0x25, 0xa0, 0x32, 0xb1,
0x48, 0x53, 0xa3, 0x10, 0xfd, 0x61, 0xbb, 0x1c, 0x6f, 0xfa, 0xeb, 0xae, 0xf6, 0xae, 0xe8, 0x68,
0x25, 0xd0, 0xc6, 0x12, 0xf2, 0x5c, 0x5b, 0xff, 0xff, 0x94, 0xcc, 0x46, 0xf3, 0xc9, 0xdf, 0x1f,
0x2d, 0xda, 0xf7, 0xe6, 0x82, 0x88, 0x36, 0x40, 0x97, 0x6f, 0x2e, 0xde, 0x2a, 0x46, 0xd6, 0x15,
0x23, 0x9f, 0x15, 0x23, 0xaf, 0x35, 0x1b, 0xac, 0x6b, 0x36, 0x78, 0xaf, 0xd9, 0xe0, 0x81, 0x75,
0xa2, 0x30, 0x7d, 0xe4, 0x1a, 0x82, 0xe7, 0x5f, 0x56, 0x5b, 0x37, 0xc9, 0x56, 0x2b, 0xe7, 0xfc,
0x2b, 0x00, 0x00, 0xff, 0xff, 0x7c, 0x63, 0x02, 0x4f, 0x76, 0x01, 0x00, 0x00,
}
func (m *CometInfo) 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 *CometInfo) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *CometInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.LastCommit != nil {
{
size, err := m.LastCommit.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintConsensus(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x22
}
if len(m.ProposerAddress) > 0 {
i -= len(m.ProposerAddress)
copy(dAtA[i:], m.ProposerAddress)
i = encodeVarintConsensus(dAtA, i, uint64(len(m.ProposerAddress)))
i--
dAtA[i] = 0x1a
}
if len(m.ValidatorsHash) > 0 {
i -= len(m.ValidatorsHash)
copy(dAtA[i:], m.ValidatorsHash)
i = encodeVarintConsensus(dAtA, i, uint64(len(m.ValidatorsHash)))
i--
dAtA[i] = 0x12
}
if len(m.Evidence) > 0 {
for iNdEx := len(m.Evidence) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Evidence[iNdEx].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 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 *CometInfo) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if len(m.Evidence) > 0 {
for _, e := range m.Evidence {
l = e.Size()
n += 1 + l + sovConsensus(uint64(l))
}
}
l = len(m.ValidatorsHash)
if l > 0 {
n += 1 + l + sovConsensus(uint64(l))
}
l = len(m.ProposerAddress)
if l > 0 {
n += 1 + l + sovConsensus(uint64(l))
}
if m.LastCommit != nil {
l = m.LastCommit.Size()
n += 1 + l + sovConsensus(uint64(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 *CometInfo) 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: CometInfo: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: CometInfo: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
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
}
m.Evidence = append(m.Evidence, &v1.Misbehavior{})
if err := m.Evidence[len(m.Evidence)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ValidatorsHash", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowConsensus
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthConsensus
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthConsensus
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ValidatorsHash = append(m.ValidatorsHash[:0], dAtA[iNdEx:postIndex]...)
if m.ValidatorsHash == nil {
m.ValidatorsHash = []byte{}
}
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ProposerAddress", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowConsensus
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthConsensus
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthConsensus
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ProposerAddress = append(m.ProposerAddress[:0], dAtA[iNdEx:postIndex]...)
if m.ProposerAddress == nil {
m.ProposerAddress = []byte{}
}
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field LastCommit", 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.LastCommit == nil {
m.LastCommit = &v1.CommitInfo{}
}
if err := m.LastCommit.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 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")
)

View File

@ -9,11 +9,8 @@ require (
cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000
cosmossdk.io/depinject v1.0.0
cosmossdk.io/errors v1.0.1
cosmossdk.io/log v1.4.1
cosmossdk.io/math v1.3.0
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91
cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.53.0
@ -33,8 +30,9 @@ require (
require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/tx v0.13.3 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
@ -179,7 +177,6 @@ replace (
cosmossdk.io/core/testing => ../../core/testing
cosmossdk.io/store => ../../store
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/protocolpool => ../protocolpool
cosmossdk.io/x/staking => ../staking
cosmossdk.io/x/tx => ../tx

View File

@ -1,47 +0,0 @@
package v4_test
import (
"testing"
"github.com/stretchr/testify/require"
coretesting "cosmossdk.io/core/testing"
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/distribution"
v4 "cosmossdk.io/x/distribution/migrations/v4"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
)
func TestMigration(t *testing.T) {
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{}).Codec
storeKey := storetypes.NewKVStoreKey("distribution")
storeService := runtime.NewKVStoreService(storeKey)
tKey := storetypes.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(storeKey, tKey)
env := runtime.NewEnvironment(storeService, coretesting.NewNopLogger())
addr1 := secp256k1.GenPrivKey().PubKey().Address()
consAddr1 := sdk.ConsAddress(addr1)
// Set and check the previous proposer
err := v4.SetPreviousProposerConsAddr(ctx, storeService, cdc, consAddr1)
require.NoError(t, err)
gotAddr, err := v4.GetPreviousProposerConsAddr(ctx, storeService, cdc)
require.NoError(t, err)
require.Equal(t, consAddr1, gotAddr)
err = v4.MigrateStore(ctx, env, cdc)
require.NoError(t, err)
// Check that the previous proposer has been removed
_, err = v4.GetPreviousProposerConsAddr(ctx, storeService, cdc)
require.ErrorContains(t, err, "previous proposer not set")
}

View File

@ -20,9 +20,12 @@ require (
google.golang.org/grpc v1.66.1
)
require cosmossdk.io/schema v0.2.0 // indirect
require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/math v1.3.0 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
@ -88,6 +91,7 @@ require (
github.com/hashicorp/go-metrics v0.5.3 // indirect
github.com/hashicorp/go-plugin v1.6.1 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/hdevalence/ed25519consensus v0.2.0 // indirect
@ -107,6 +111,7 @@ require (
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
@ -162,13 +167,8 @@ require (
)
require (
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
)
replace github.com/cosmos/cosmos-sdk => ../../.
@ -179,7 +179,6 @@ replace (
cosmossdk.io/core/testing => ../../core/testing
cosmossdk.io/store => ../../store
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/staking => ../staking
cosmossdk.io/x/tx => ../tx
)

View File

@ -31,6 +31,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#20016](https://github.com/cosmos/cosmos-sdk/pull/20016) `NewMsgSubmitEvidence` now takes a string as argument instead of an `AccAddress`.
* [#19482](https://github.com/cosmos/cosmos-sdk/pull/19482) `appmodule.Environment` is passed to `NewKeeper` instead of individual services
* [#19627](https://github.com/cosmos/cosmos-sdk/pull/19627) `NewAppModule` now takes in a `codec.Codec` as its first argument
* [#21480](https://github.com/cosmos/cosmos-sdk/pull/21480) ConsensusKeeper is required to be passed to the keeper.
## [v0.1.1](https://github.com/cosmos/cosmos-sdk/releases/tag/x/evidence/v0.1.1) - 2024-04-22

View File

@ -33,9 +33,10 @@ type ModuleInputs struct {
EvidenceHandlers []eviclient.EvidenceHandler `optional:"true"`
CometService comet.Service
StakingKeeper types.StakingKeeper
SlashingKeeper types.SlashingKeeper
AddressCodec address.Codec
StakingKeeper types.StakingKeeper
SlashingKeeper types.SlashingKeeper
ConsensusKeeper types.ConsensusKeeper
AddressCodec address.Codec
}
type ModuleOutputs struct {
@ -46,7 +47,7 @@ type ModuleOutputs struct {
}
func ProvideModule(in ModuleInputs) ModuleOutputs {
k := keeper.NewKeeper(in.Cdc, in.Environment, in.StakingKeeper, in.SlashingKeeper, in.AddressCodec)
k := keeper.NewKeeper(in.Cdc, in.Environment, in.StakingKeeper, in.SlashingKeeper, in.ConsensusKeeper, in.AddressCodec)
m := NewAppModule(in.Cdc, *k, in.CometService, in.EvidenceHandlers...)
return ModuleOutputs{EvidenceKeeper: *k, Module: m}

View File

@ -11,7 +11,6 @@ require (
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.3.0
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.53.0
github.com/cosmos/gogoproto v1.7.0
@ -177,7 +176,6 @@ replace (
cosmossdk.io/core/testing => ../../core/testing
cosmossdk.io/store => ../../store
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/staking => ../staking
cosmossdk.io/x/tx => ../tx
)

View File

@ -5,7 +5,6 @@ import (
"fmt"
st "cosmossdk.io/api/cosmos/staking/v1beta1"
consensusv1 "cosmossdk.io/x/consensus/types"
"cosmossdk.io/x/evidence/types"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -73,27 +72,18 @@ func (k Keeper) handleEquivocationEvidence(ctx context.Context, evidence *types.
// Reject evidence if the double-sign is too old. Evidence is considered stale
// if the difference in time and number of blocks is greater than the allowed
// parameters defined.
resp, err := k.QueryRouterService.Invoke(ctx, &consensusv1.QueryParamsRequest{})
if err != nil {
return fmt.Errorf("failed to query consensus params: %w", err)
}
res, ok := resp.(*consensusv1.QueryParamsResponse)
if !ok {
return fmt.Errorf("unexpected response type: %T", resp)
}
if res.Params.Evidence != nil {
if ageDuration > res.Params.Evidence.MaxAgeDuration && ageBlocks > res.Params.Evidence.MaxAgeNumBlocks {
k.Logger.Info(
"ignored equivocation; evidence too old",
"validator", consAddr,
"infraction_height", infractionHeight,
"max_age_num_blocks", res.Params.Evidence.MaxAgeNumBlocks,
"infraction_time", infractionTime,
"max_age_duration", res.Params.Evidence.MaxAgeDuration,
)
return nil
}
eviAgeBlocks, eviAgeDuration, _, err := k.consensusKeeper.EvidenceParams(ctx)
if err == nil && ageDuration > eviAgeDuration && ageBlocks > eviAgeBlocks {
k.Logger.Info(
"ignored equivocation; evidence too old",
"validator", consAddr,
"infraction_height", infractionHeight,
"max_age_num_blocks", eviAgeBlocks,
"infraction_time", infractionTime,
"max_age_duration", eviAgeDuration,
)
return nil
}
if ok := k.slashingKeeper.HasValidatorSigningInfo(ctx, consAddr); !ok {

View File

@ -23,11 +23,12 @@ import (
type Keeper struct {
appmodule.Environment
cdc codec.BinaryCodec
router types.Router
stakingKeeper types.StakingKeeper
slashingKeeper types.SlashingKeeper
addressCodec address.Codec
cdc codec.BinaryCodec
router types.Router
stakingKeeper types.StakingKeeper
slashingKeeper types.SlashingKeeper
consensusKeeper types.ConsensusKeeper
addressCodec address.Codec
Schema collections.Schema
// Evidences key: evidence hash bytes | value: Evidence
@ -37,16 +38,17 @@ type Keeper struct {
// NewKeeper creates a new Keeper object.
func NewKeeper(
cdc codec.BinaryCodec, env appmodule.Environment, stakingKeeper types.StakingKeeper,
slashingKeeper types.SlashingKeeper, ac address.Codec,
slashingKeeper types.SlashingKeeper, ck types.ConsensusKeeper, ac address.Codec,
) *Keeper {
sb := collections.NewSchemaBuilder(env.KVStoreService)
k := &Keeper{
Environment: env,
cdc: cdc,
stakingKeeper: stakingKeeper,
slashingKeeper: slashingKeeper,
addressCodec: ac,
Evidences: collections.NewMap(sb, types.KeyPrefixEvidence, "evidences", collections.BytesKey, codec.CollInterfaceValue[exported.Evidence](cdc)),
Environment: env,
cdc: cdc,
stakingKeeper: stakingKeeper,
slashingKeeper: slashingKeeper,
consensusKeeper: ck,
addressCodec: ac,
Evidences: collections.NewMap(sb, types.KeyPrefixEvidence, "evidences", collections.BytesKey, codec.CollInterfaceValue[exported.Evidence](cdc)),
}
schema, err := sb.Build()
if err != nil {

View File

@ -102,12 +102,14 @@ func (suite *KeeperTestSuite) SetupTest() {
stakingKeeper := evidencetestutil.NewMockStakingKeeper(ctrl)
slashingKeeper := evidencetestutil.NewMockSlashingKeeper(ctrl)
accountKeeper := evidencetestutil.NewMockAccountKeeper(ctrl)
ck := evidencetestutil.NewMockConsensusKeeper(ctrl)
evidenceKeeper := keeper.NewKeeper(
encCfg.Codec,
env,
stakingKeeper,
slashingKeeper,
ck,
address.NewBech32Codec("cosmos"),
)

View File

@ -254,3 +254,43 @@ func (mr *MockAccountKeeperMockRecorder) SetAccount(ctx, acc interface{}) *gomoc
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetAccount", reflect.TypeOf((*MockAccountKeeper)(nil).SetAccount), ctx, acc)
}
// MockConsensusKeeper is a mock of ConsensusKeeper interface.
type MockConsensusKeeper struct {
ctrl *gomock.Controller
recorder *MockConsensusKeeperMockRecorder
}
// MockConsensusKeeperMockRecorder is the mock recorder for MockConsensusKeeper.
type MockConsensusKeeperMockRecorder struct {
mock *MockConsensusKeeper
}
// NewMockConsensusKeeper creates a new mock instance.
func NewMockConsensusKeeper(ctrl *gomock.Controller) *MockConsensusKeeper {
mock := &MockConsensusKeeper{ctrl: ctrl}
mock.recorder = &MockConsensusKeeperMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockConsensusKeeper) EXPECT() *MockConsensusKeeperMockRecorder {
return m.recorder
}
// EvidenceParams mocks base method.
func (m *MockConsensusKeeper) EvidenceParams(arg0 context.Context) (int64, time.Duration, uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EvidenceParams", arg0)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(time.Duration)
ret2, _ := ret[2].(uint64)
ret3, _ := ret[3].(error)
return ret0, ret1, ret2, ret3
}
// EvidenceParams indicates an expected call of EvidenceParams.
func (mr *MockConsensusKeeperMockRecorder) EvidenceParams(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EvidenceParams", reflect.TypeOf((*MockConsensusKeeper)(nil).EvidenceParams), arg0)
}

View File

@ -37,3 +37,7 @@ type SlashingKeeper interface {
type AccountKeeper interface {
SetAccount(ctx context.Context, acc sdk.AccountI)
}
type ConsensusKeeper interface {
EvidenceParams(context.Context) (maxAge int64, maxAgeDuration time.Duration, maxBytes uint64, err error)
}

View File

@ -38,7 +38,6 @@ require (
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.3 // indirect
@ -185,7 +184,6 @@ replace (
cosmossdk.io/core/testing => ../../core/testing
cosmossdk.io/store => ../../store
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/gov => ../gov
cosmossdk.io/x/staking => ../staking
cosmossdk.io/x/tx => ../tx

View File

@ -37,7 +37,6 @@ require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.3 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
@ -181,7 +180,6 @@ replace (
cosmossdk.io/core/testing => ../../core/testing
cosmossdk.io/store => ../../store
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/protocolpool => ../protocolpool
cosmossdk.io/x/staking => ../staking
cosmossdk.io/x/tx => ../tx

View File

@ -27,7 +27,9 @@ require (
)
require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.3 // indirect
@ -49,6 +51,7 @@ require (
github.com/cometbft/cometbft-db v0.14.0 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v1.0.3-0.20240829004618-717cba019b33 // indirect
github.com/cosmos/crypto v0.1.2 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v1.3.0 // indirect
@ -57,6 +60,7 @@ require (
github.com/danieljoos/wincred v1.2.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/dgraph-io/badger/v4 v4.2.0 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
@ -72,8 +76,10 @@ require (
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.2.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/flatbuffers v2.0.8+incompatible // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/gorilla/handlers v1.5.2 // indirect
@ -86,6 +92,7 @@ require (
github.com/hashicorp/go-metrics v0.5.3 // indirect
github.com/hashicorp/go-plugin v1.6.1 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/hdevalence/ed25519consensus v0.2.0 // indirect
@ -105,6 +112,7 @@ require (
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
@ -129,6 +137,7 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.19.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/supranational/blst v0.3.13 // 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
@ -137,6 +146,7 @@ require (
gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b // indirect
gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
@ -157,20 +167,9 @@ require (
)
require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
github.com/cometbft/cometbft/api v1.0.0-rc.1 // indirect
github.com/cosmos/crypto v0.1.2 // indirect
github.com/dgraph-io/badger/v4 v4.2.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/flatbuffers v2.0.8+incompatible // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/supranational/blst v0.3.13 // indirect
go.opencensus.io v0.24.0 // indirect
)
replace github.com/cosmos/cosmos-sdk => ../../.

View File

@ -27,7 +27,6 @@ require (
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.3 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
@ -176,7 +175,6 @@ replace (
cosmossdk.io/core/testing => ../../core/testing
cosmossdk.io/store => ../../store
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/staking => ../staking
cosmossdk.io/x/tx => ../tx
)

View File

@ -31,7 +31,6 @@ require (
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.3 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
@ -177,7 +176,6 @@ replace (
cosmossdk.io/core/testing => ../../core/testing
cosmossdk.io/store => ../../store
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/distribution => ../distribution
cosmossdk.io/x/gov => ../gov
cosmossdk.io/x/mint => ../mint

View File

@ -30,7 +30,6 @@ require (
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.3 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
@ -177,7 +176,6 @@ replace (
cosmossdk.io/core/testing => ../../core/testing
cosmossdk.io/store => ../../store
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/staking => ../staking
cosmossdk.io/x/tx => ../tx
)

View File

@ -32,7 +32,6 @@ require (
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/schema v0.2.0 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.3 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
@ -178,7 +177,6 @@ replace (
cosmossdk.io/core/testing => ../../core/testing
cosmossdk.io/store => ../../store
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/staking => ../staking
cosmossdk.io/x/tx => ../tx
)

View File

@ -96,6 +96,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#17335](https://github.com/cosmos/cosmos-sdk/pull/17335) Remove usage of `"cosmossdk.io/x/staking/types".Infraction_*` in favour of `"cosmossdk.io/api/cosmos/staking/v1beta1".Infraction_` in order to remove dependency between modules on staking
* [#20295](https://github.com/cosmos/cosmos-sdk/pull/20295) `GetValidatorByConsAddr` now returns the Cosmos SDK `cryptotypes.Pubkey` instead of `cometcrypto.Publickey`. The caller is responsible to translate the returned value to the expected type.
* Remove `CmtConsPublicKey()` and `TmConsPublicKey()` from `Validator` interface and as methods on the `Validator` struct.
* [#21480](https://github.com/cosmos/cosmos-sdk/pull/21480) ConsensusKeeper is required to be passed to the keeper.
### State Breaking changes

View File

@ -43,6 +43,7 @@ type ModuleInputs struct {
ConsensusAddressCodec address.ConsensusAddressCodec
AccountKeeper types.AccountKeeper
BankKeeper types.BankKeeper
ConsensusKeeper types.ConsensusKeeper
Cdc codec.Codec
Environment appmodule.Environment
CometInfoService comet.Service
@ -73,6 +74,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
in.Environment,
in.AccountKeeper,
in.BankKeeper,
in.ConsensusKeeper,
as,
in.ValidatorAddressCodec,
in.ConsensusAddressCodec,

View File

@ -156,7 +156,6 @@ require (
require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
cosmossdk.io/log v1.4.1
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000
github.com/cosmos/crypto v0.1.2 // indirect
github.com/dgraph-io/badger/v4 v4.2.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
@ -183,6 +182,5 @@ replace (
cosmossdk.io/core/testing => ../../core/testing
cosmossdk.io/store => ../../store
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/tx => ../tx
)

View File

@ -57,6 +57,7 @@ type Keeper struct {
cdc codec.BinaryCodec
authKeeper types.AccountKeeper
bankKeeper types.BankKeeper
consensusKeeper types.ConsensusKeeper
hooks types.StakingHooks
authority string
validatorAddressCodec addresscodec.Codec
@ -119,6 +120,7 @@ func NewKeeper(
env appmodule.Environment,
ak types.AccountKeeper,
bk types.BankKeeper,
ck types.ConsensusKeeper,
authority string,
validatorAddressCodec addresscodec.Codec,
consensusAddressCodec addresscodec.Codec,
@ -148,6 +150,7 @@ func NewKeeper(
cdc: cdc,
authKeeper: ak,
bankKeeper: bk,
consensusKeeper: ck,
hooks: nil,
authority: authority,
validatorAddressCodec: validatorAddressCodec,

View File

@ -14,7 +14,6 @@ import (
"cosmossdk.io/log"
"cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
consensustypes "cosmossdk.io/x/consensus/types"
stakingkeeper "cosmossdk.io/x/staking/keeper"
stakingtestutil "cosmossdk.io/x/staking/testutil"
stakingtypes "cosmossdk.io/x/staking/types"
@ -81,14 +80,11 @@ func (s *KeeperTestSuite) SetupTest() {
// create consensus keeper
ck := stakingtestutil.NewMockConsensusKeeper(ctrl)
ck.EXPECT().Params(gomock.Any(), gomock.Any()).Return(&consensustypes.QueryParamsResponse{
Params: simtestutil.DefaultConsensusParams,
}, nil).AnyTimes()
ck.EXPECT().ValidatorPubKeyTypes(gomock.Any()).Return(simtestutil.DefaultConsensusParams.Validator.PubKeyTypes, nil).AnyTimes()
queryHelper := baseapp.NewQueryServerTestHelper(ctx, encCfg.InterfaceRegistry)
consensustypes.RegisterQueryServer(queryHelper, ck)
bankKeeper := stakingtestutil.NewMockBankKeeper(ctrl)
env := runtime.NewEnvironment(storeService, coretesting.NewNopLogger(), runtime.EnvWithQueryRouterService(queryHelper.GRPCQueryRouter), runtime.EnvWithMsgRouterService(s.baseApp.MsgServiceRouter()))
env := runtime.NewEnvironment(storeService, coretesting.NewNopLogger(), runtime.EnvWithMsgRouterService(s.baseApp.MsgServiceRouter()))
authority, err := accountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress(stakingtypes.GovModuleName))
s.Require().NoError(err)
keeper := stakingkeeper.NewKeeper(
@ -96,6 +92,7 @@ func (s *KeeperTestSuite) SetupTest() {
env,
accountKeeper,
bankKeeper,
ck,
authority,
address.NewBech32Codec("cosmosvaloper"),
address.NewBech32Codec("cosmosvalcons"),

View File

@ -17,7 +17,6 @@ import (
"cosmossdk.io/core/event"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"
consensusv1 "cosmossdk.io/x/consensus/types"
"cosmossdk.io/x/staking/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
@ -75,20 +74,24 @@ func (k msgServer) CreateValidator(ctx context.Context, msg *types.MsgCreateVali
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidType, "Expecting cryptotypes.PubKey, got %T", cv)
}
resp, err := k.QueryRouterService.Invoke(ctx, &consensusv1.QueryParamsRequest{})
pubkeyTypes, err := k.consensusKeeper.ValidatorPubKeyTypes(ctx)
if err != nil {
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "failed to query consensus params: %s", err)
}
res, ok := resp.(*consensusv1.QueryParamsResponse)
if !ok {
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "unexpected response type: %T", resp)
pkType := pk.Type()
if !slices.Contains(pubkeyTypes, pkType) {
return nil, errorsmod.Wrapf(
types.ErrValidatorPubKeyTypeNotSupported,
"got: %s, expected: %s", pk.Type(), pubkeyTypes,
)
}
if res.Params.Validator == nil {
if pubkeyTypes == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "validator params are not set")
}
if err = validatePubKey(pk, res.Params.Validator.PubKeyTypes); err != nil {
if err = validatePubKey(pk, pubkeyTypes); err != nil {
return nil, err
}
@ -660,21 +663,16 @@ func (k msgServer) RotateConsPubKey(ctx context.Context, msg *types.MsgRotateCon
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidType, "expecting cryptotypes.PubKey, got %T", cv)
}
// check if the new public key type is valid
resp, err := k.QueryRouterService.Invoke(ctx, &consensusv1.QueryParamsRequest{})
pubkeyTypes, err := k.consensusKeeper.ValidatorPubKeyTypes(ctx)
if err != nil {
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "failed to query consensus params: %s", err)
}
paramsRes, ok := resp.(*consensusv1.QueryParamsResponse)
if !ok {
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "unexpected response type: %T", resp)
return nil, err
}
if paramsRes.Params.Validator == nil {
if pubkeyTypes == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "validator params are not set")
}
if err = validatePubKey(pk, paramsRes.Params.Validator.PubKeyTypes); err != nil {
if err = validatePubKey(pk, pubkeyTypes); err != nil {
return nil, err
}

View File

@ -11,10 +11,9 @@ import (
stakingv1beta1 "cosmossdk.io/api/cosmos/staking/v1beta1"
address "cosmossdk.io/core/address"
math "cosmossdk.io/math"
types "cosmossdk.io/x/consensus/types"
types0 "cosmossdk.io/x/staking/types"
types1 "github.com/cosmos/cosmos-sdk/crypto/types"
types2 "github.com/cosmos/cosmos-sdk/types"
types "cosmossdk.io/x/staking/types"
types0 "github.com/cosmos/cosmos-sdk/crypto/types"
types1 "github.com/cosmos/cosmos-sdk/types"
gomock "github.com/golang/mock/gomock"
)
@ -56,10 +55,10 @@ func (mr *MockAccountKeeperMockRecorder) AddressCodec() *gomock.Call {
}
// GetAccount mocks base method.
func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types2.AccAddress) types2.AccountI {
func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types1.AccAddress) types1.AccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAccount", ctx, addr)
ret0, _ := ret[0].(types2.AccountI)
ret0, _ := ret[0].(types1.AccountI)
return ret0
}
@ -70,10 +69,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo
}
// GetModuleAccount mocks base method.
func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, moduleName string) types2.ModuleAccountI {
func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, moduleName string) types1.ModuleAccountI {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetModuleAccount", ctx, moduleName)
ret0, _ := ret[0].(types2.ModuleAccountI)
ret0, _ := ret[0].(types1.ModuleAccountI)
return ret0
}
@ -84,10 +83,10 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAccount(ctx, moduleName interf
}
// GetModuleAddress mocks base method.
func (m *MockAccountKeeper) GetModuleAddress(name string) types2.AccAddress {
func (m *MockAccountKeeper) GetModuleAddress(name string) types1.AccAddress {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetModuleAddress", name)
ret0, _ := ret[0].(types2.AccAddress)
ret0, _ := ret[0].(types1.AccAddress)
return ret0
}
@ -98,7 +97,7 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom
}
// SetModuleAccount mocks base method.
func (m *MockAccountKeeper) SetModuleAccount(arg0 context.Context, arg1 types2.ModuleAccountI) {
func (m *MockAccountKeeper) SetModuleAccount(arg0 context.Context, arg1 types1.ModuleAccountI) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetModuleAccount", arg0, arg1)
}
@ -133,7 +132,7 @@ func (m *MockBankKeeper) EXPECT() *MockBankKeeperMockRecorder {
}
// BurnCoins mocks base method.
func (m *MockBankKeeper) BurnCoins(arg0 context.Context, arg1 []byte, arg2 types2.Coins) error {
func (m *MockBankKeeper) BurnCoins(arg0 context.Context, arg1 []byte, arg2 types1.Coins) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BurnCoins", arg0, arg1, arg2)
ret0, _ := ret[0].(error)
@ -147,7 +146,7 @@ func (mr *MockBankKeeperMockRecorder) BurnCoins(arg0, arg1, arg2 interface{}) *g
}
// DelegateCoinsFromAccountToModule mocks base method.
func (m *MockBankKeeper) DelegateCoinsFromAccountToModule(ctx context.Context, senderAddr types2.AccAddress, recipientModule string, amt types2.Coins) error {
func (m *MockBankKeeper) DelegateCoinsFromAccountToModule(ctx context.Context, senderAddr types1.AccAddress, recipientModule string, amt types1.Coins) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DelegateCoinsFromAccountToModule", ctx, senderAddr, recipientModule, amt)
ret0, _ := ret[0].(error)
@ -161,10 +160,10 @@ func (mr *MockBankKeeperMockRecorder) DelegateCoinsFromAccountToModule(ctx, send
}
// GetAllBalances mocks base method.
func (m *MockBankKeeper) GetAllBalances(ctx context.Context, addr types2.AccAddress) types2.Coins {
func (m *MockBankKeeper) GetAllBalances(ctx context.Context, addr types1.AccAddress) types1.Coins {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAllBalances", ctx, addr)
ret0, _ := ret[0].(types2.Coins)
ret0, _ := ret[0].(types1.Coins)
return ret0
}
@ -175,10 +174,10 @@ func (mr *MockBankKeeperMockRecorder) GetAllBalances(ctx, addr interface{}) *gom
}
// GetBalance mocks base method.
func (m *MockBankKeeper) GetBalance(ctx context.Context, addr types2.AccAddress, denom string) types2.Coin {
func (m *MockBankKeeper) GetBalance(ctx context.Context, addr types1.AccAddress, denom string) types1.Coin {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetBalance", ctx, addr, denom)
ret0, _ := ret[0].(types2.Coin)
ret0, _ := ret[0].(types1.Coin)
return ret0
}
@ -189,10 +188,10 @@ func (mr *MockBankKeeperMockRecorder) GetBalance(ctx, addr, denom interface{}) *
}
// GetSupply mocks base method.
func (m *MockBankKeeper) GetSupply(ctx context.Context, denom string) types2.Coin {
func (m *MockBankKeeper) GetSupply(ctx context.Context, denom string) types1.Coin {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetSupply", ctx, denom)
ret0, _ := ret[0].(types2.Coin)
ret0, _ := ret[0].(types1.Coin)
return ret0
}
@ -217,10 +216,10 @@ func (mr *MockBankKeeperMockRecorder) IsSendEnabledDenom(ctx, denom interface{})
}
// LockedCoins mocks base method.
func (m *MockBankKeeper) LockedCoins(ctx context.Context, addr types2.AccAddress) types2.Coins {
func (m *MockBankKeeper) LockedCoins(ctx context.Context, addr types1.AccAddress) types1.Coins {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LockedCoins", ctx, addr)
ret0, _ := ret[0].(types2.Coins)
ret0, _ := ret[0].(types1.Coins)
return ret0
}
@ -231,7 +230,7 @@ func (mr *MockBankKeeperMockRecorder) LockedCoins(ctx, addr interface{}) *gomock
}
// SendCoinsFromAccountToModule mocks base method.
func (m *MockBankKeeper) SendCoinsFromAccountToModule(ctx context.Context, senderAddr types2.AccAddress, recipientModule string, amt types2.Coins) error {
func (m *MockBankKeeper) SendCoinsFromAccountToModule(ctx context.Context, senderAddr types1.AccAddress, recipientModule string, amt types1.Coins) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SendCoinsFromAccountToModule", ctx, senderAddr, recipientModule, amt)
ret0, _ := ret[0].(error)
@ -245,7 +244,7 @@ func (mr *MockBankKeeperMockRecorder) SendCoinsFromAccountToModule(ctx, senderAd
}
// SendCoinsFromModuleToModule mocks base method.
func (m *MockBankKeeper) SendCoinsFromModuleToModule(ctx context.Context, senderPool, recipientPool string, amt types2.Coins) error {
func (m *MockBankKeeper) SendCoinsFromModuleToModule(ctx context.Context, senderPool, recipientPool string, amt types1.Coins) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SendCoinsFromModuleToModule", ctx, senderPool, recipientPool, amt)
ret0, _ := ret[0].(error)
@ -259,10 +258,10 @@ func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToModule(ctx, senderPoo
}
// SpendableCoins mocks base method.
func (m *MockBankKeeper) SpendableCoins(ctx context.Context, addr types2.AccAddress) types2.Coins {
func (m *MockBankKeeper) SpendableCoins(ctx context.Context, addr types1.AccAddress) types1.Coins {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SpendableCoins", ctx, addr)
ret0, _ := ret[0].(types2.Coins)
ret0, _ := ret[0].(types1.Coins)
return ret0
}
@ -273,7 +272,7 @@ func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr interface{}) *gom
}
// UndelegateCoinsFromModuleToAccount mocks base method.
func (m *MockBankKeeper) UndelegateCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr types2.AccAddress, amt types2.Coins) error {
func (m *MockBankKeeper) UndelegateCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr types1.AccAddress, amt types1.Coins) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UndelegateCoinsFromModuleToAccount", ctx, senderModule, recipientAddr, amt)
ret0, _ := ret[0].(error)
@ -310,10 +309,10 @@ func (m *MockValidatorSet) EXPECT() *MockValidatorSetMockRecorder {
}
// Delegation mocks base method.
func (m *MockValidatorSet) Delegation(arg0 context.Context, arg1 types2.AccAddress, arg2 types2.ValAddress) (types2.DelegationI, error) {
func (m *MockValidatorSet) Delegation(arg0 context.Context, arg1 types1.AccAddress, arg2 types1.ValAddress) (types1.DelegationI, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Delegation", arg0, arg1, arg2)
ret0, _ := ret[0].(types2.DelegationI)
ret0, _ := ret[0].(types1.DelegationI)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -325,10 +324,10 @@ func (mr *MockValidatorSetMockRecorder) Delegation(arg0, arg1, arg2 interface{})
}
// GetPubKeyByConsAddr mocks base method.
func (m *MockValidatorSet) GetPubKeyByConsAddr(arg0 context.Context, arg1 types2.ConsAddress) (types1.PubKey, error) {
func (m *MockValidatorSet) GetPubKeyByConsAddr(arg0 context.Context, arg1 types1.ConsAddress) (types0.PubKey, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetPubKeyByConsAddr", arg0, arg1)
ret0, _ := ret[0].(types1.PubKey)
ret0, _ := ret[0].(types0.PubKey)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -340,7 +339,7 @@ func (mr *MockValidatorSetMockRecorder) GetPubKeyByConsAddr(arg0, arg1 interface
}
// IterateBondedValidatorsByPower mocks base method.
func (m *MockValidatorSet) IterateBondedValidatorsByPower(arg0 context.Context, arg1 func(int64, types2.ValidatorI) bool) error {
func (m *MockValidatorSet) IterateBondedValidatorsByPower(arg0 context.Context, arg1 func(int64, types1.ValidatorI) bool) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IterateBondedValidatorsByPower", arg0, arg1)
ret0, _ := ret[0].(error)
@ -354,7 +353,7 @@ func (mr *MockValidatorSetMockRecorder) IterateBondedValidatorsByPower(arg0, arg
}
// IterateValidators mocks base method.
func (m *MockValidatorSet) IterateValidators(arg0 context.Context, arg1 func(int64, types2.ValidatorI) bool) error {
func (m *MockValidatorSet) IterateValidators(arg0 context.Context, arg1 func(int64, types1.ValidatorI) bool) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IterateValidators", arg0, arg1)
ret0, _ := ret[0].(error)
@ -368,7 +367,7 @@ func (mr *MockValidatorSetMockRecorder) IterateValidators(arg0, arg1 interface{}
}
// Jail mocks base method.
func (m *MockValidatorSet) Jail(arg0 context.Context, arg1 types2.ConsAddress) error {
func (m *MockValidatorSet) Jail(arg0 context.Context, arg1 types1.ConsAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Jail", arg0, arg1)
ret0, _ := ret[0].(error)
@ -397,7 +396,7 @@ func (mr *MockValidatorSetMockRecorder) MaxValidators(arg0 interface{}) *gomock.
}
// Slash mocks base method.
func (m *MockValidatorSet) Slash(arg0 context.Context, arg1 types2.ConsAddress, arg2, arg3 int64, arg4 math.LegacyDec) (math.Int, error) {
func (m *MockValidatorSet) Slash(arg0 context.Context, arg1 types1.ConsAddress, arg2, arg3 int64, arg4 math.LegacyDec) (math.Int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Slash", arg0, arg1, arg2, arg3, arg4)
ret0, _ := ret[0].(math.Int)
@ -412,7 +411,7 @@ func (mr *MockValidatorSetMockRecorder) Slash(arg0, arg1, arg2, arg3, arg4 inter
}
// SlashWithInfractionReason mocks base method.
func (m *MockValidatorSet) SlashWithInfractionReason(arg0 context.Context, arg1 types2.ConsAddress, arg2, arg3 int64, arg4 math.LegacyDec, arg5 stakingv1beta1.Infraction) (math.Int, error) {
func (m *MockValidatorSet) SlashWithInfractionReason(arg0 context.Context, arg1 types1.ConsAddress, arg2, arg3 int64, arg4 math.LegacyDec, arg5 stakingv1beta1.Infraction) (math.Int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SlashWithInfractionReason", arg0, arg1, arg2, arg3, arg4, arg5)
ret0, _ := ret[0].(math.Int)
@ -457,7 +456,7 @@ func (mr *MockValidatorSetMockRecorder) TotalBondedTokens(arg0 interface{}) *gom
}
// Unjail mocks base method.
func (m *MockValidatorSet) Unjail(arg0 context.Context, arg1 types2.ConsAddress) error {
func (m *MockValidatorSet) Unjail(arg0 context.Context, arg1 types1.ConsAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Unjail", arg0, arg1)
ret0, _ := ret[0].(error)
@ -471,10 +470,10 @@ func (mr *MockValidatorSetMockRecorder) Unjail(arg0, arg1 interface{}) *gomock.C
}
// Validator mocks base method.
func (m *MockValidatorSet) Validator(arg0 context.Context, arg1 types2.ValAddress) (types2.ValidatorI, error) {
func (m *MockValidatorSet) Validator(arg0 context.Context, arg1 types1.ValAddress) (types1.ValidatorI, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Validator", arg0, arg1)
ret0, _ := ret[0].(types2.ValidatorI)
ret0, _ := ret[0].(types1.ValidatorI)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -486,10 +485,10 @@ func (mr *MockValidatorSetMockRecorder) Validator(arg0, arg1 interface{}) *gomoc
}
// ValidatorByConsAddr mocks base method.
func (m *MockValidatorSet) ValidatorByConsAddr(arg0 context.Context, arg1 types2.ConsAddress) (types2.ValidatorI, error) {
func (m *MockValidatorSet) ValidatorByConsAddr(arg0 context.Context, arg1 types1.ConsAddress) (types1.ValidatorI, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ValidatorByConsAddr", arg0, arg1)
ret0, _ := ret[0].(types2.ValidatorI)
ret0, _ := ret[0].(types1.ValidatorI)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -524,10 +523,10 @@ func (m *MockDelegationSet) EXPECT() *MockDelegationSetMockRecorder {
}
// GetValidatorSet mocks base method.
func (m *MockDelegationSet) GetValidatorSet() types0.ValidatorSet {
func (m *MockDelegationSet) GetValidatorSet() types.ValidatorSet {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetValidatorSet")
ret0, _ := ret[0].(types0.ValidatorSet)
ret0, _ := ret[0].(types.ValidatorSet)
return ret0
}
@ -538,7 +537,7 @@ func (mr *MockDelegationSetMockRecorder) GetValidatorSet() *gomock.Call {
}
// IterateDelegations mocks base method.
func (m *MockDelegationSet) IterateDelegations(ctx context.Context, delegator types2.AccAddress, fn func(int64, types2.DelegationI) bool) error {
func (m *MockDelegationSet) IterateDelegations(ctx context.Context, delegator types1.AccAddress, fn func(int64, types1.DelegationI) bool) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IterateDelegations", ctx, delegator, fn)
ret0, _ := ret[0].(error)
@ -575,7 +574,7 @@ func (m *MockStakingHooks) EXPECT() *MockStakingHooksMockRecorder {
}
// AfterConsensusPubKeyUpdate mocks base method.
func (m *MockStakingHooks) AfterConsensusPubKeyUpdate(ctx context.Context, oldPubKey, newPubKey types1.PubKey, rotationFee types2.Coin) error {
func (m *MockStakingHooks) AfterConsensusPubKeyUpdate(ctx context.Context, oldPubKey, newPubKey types0.PubKey, rotationFee types1.Coin) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AfterConsensusPubKeyUpdate", ctx, oldPubKey, newPubKey, rotationFee)
ret0, _ := ret[0].(error)
@ -589,7 +588,7 @@ func (mr *MockStakingHooksMockRecorder) AfterConsensusPubKeyUpdate(ctx, oldPubKe
}
// AfterDelegationModified mocks base method.
func (m *MockStakingHooks) AfterDelegationModified(ctx context.Context, delAddr types2.AccAddress, valAddr types2.ValAddress) error {
func (m *MockStakingHooks) AfterDelegationModified(ctx context.Context, delAddr types1.AccAddress, valAddr types1.ValAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AfterDelegationModified", ctx, delAddr, valAddr)
ret0, _ := ret[0].(error)
@ -617,7 +616,7 @@ func (mr *MockStakingHooksMockRecorder) AfterUnbondingInitiated(ctx, id interfac
}
// AfterValidatorBeginUnbonding mocks base method.
func (m *MockStakingHooks) AfterValidatorBeginUnbonding(ctx context.Context, consAddr types2.ConsAddress, valAddr types2.ValAddress) error {
func (m *MockStakingHooks) AfterValidatorBeginUnbonding(ctx context.Context, consAddr types1.ConsAddress, valAddr types1.ValAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AfterValidatorBeginUnbonding", ctx, consAddr, valAddr)
ret0, _ := ret[0].(error)
@ -631,7 +630,7 @@ func (mr *MockStakingHooksMockRecorder) AfterValidatorBeginUnbonding(ctx, consAd
}
// AfterValidatorBonded mocks base method.
func (m *MockStakingHooks) AfterValidatorBonded(ctx context.Context, consAddr types2.ConsAddress, valAddr types2.ValAddress) error {
func (m *MockStakingHooks) AfterValidatorBonded(ctx context.Context, consAddr types1.ConsAddress, valAddr types1.ValAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AfterValidatorBonded", ctx, consAddr, valAddr)
ret0, _ := ret[0].(error)
@ -645,7 +644,7 @@ func (mr *MockStakingHooksMockRecorder) AfterValidatorBonded(ctx, consAddr, valA
}
// AfterValidatorCreated mocks base method.
func (m *MockStakingHooks) AfterValidatorCreated(ctx context.Context, valAddr types2.ValAddress) error {
func (m *MockStakingHooks) AfterValidatorCreated(ctx context.Context, valAddr types1.ValAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AfterValidatorCreated", ctx, valAddr)
ret0, _ := ret[0].(error)
@ -659,7 +658,7 @@ func (mr *MockStakingHooksMockRecorder) AfterValidatorCreated(ctx, valAddr inter
}
// AfterValidatorRemoved mocks base method.
func (m *MockStakingHooks) AfterValidatorRemoved(ctx context.Context, consAddr types2.ConsAddress, valAddr types2.ValAddress) error {
func (m *MockStakingHooks) AfterValidatorRemoved(ctx context.Context, consAddr types1.ConsAddress, valAddr types1.ValAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AfterValidatorRemoved", ctx, consAddr, valAddr)
ret0, _ := ret[0].(error)
@ -673,7 +672,7 @@ func (mr *MockStakingHooksMockRecorder) AfterValidatorRemoved(ctx, consAddr, val
}
// BeforeDelegationCreated mocks base method.
func (m *MockStakingHooks) BeforeDelegationCreated(ctx context.Context, delAddr types2.AccAddress, valAddr types2.ValAddress) error {
func (m *MockStakingHooks) BeforeDelegationCreated(ctx context.Context, delAddr types1.AccAddress, valAddr types1.ValAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BeforeDelegationCreated", ctx, delAddr, valAddr)
ret0, _ := ret[0].(error)
@ -687,7 +686,7 @@ func (mr *MockStakingHooksMockRecorder) BeforeDelegationCreated(ctx, delAddr, va
}
// BeforeDelegationRemoved mocks base method.
func (m *MockStakingHooks) BeforeDelegationRemoved(ctx context.Context, delAddr types2.AccAddress, valAddr types2.ValAddress) error {
func (m *MockStakingHooks) BeforeDelegationRemoved(ctx context.Context, delAddr types1.AccAddress, valAddr types1.ValAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BeforeDelegationRemoved", ctx, delAddr, valAddr)
ret0, _ := ret[0].(error)
@ -701,7 +700,7 @@ func (mr *MockStakingHooksMockRecorder) BeforeDelegationRemoved(ctx, delAddr, va
}
// BeforeDelegationSharesModified mocks base method.
func (m *MockStakingHooks) BeforeDelegationSharesModified(ctx context.Context, delAddr types2.AccAddress, valAddr types2.ValAddress) error {
func (m *MockStakingHooks) BeforeDelegationSharesModified(ctx context.Context, delAddr types1.AccAddress, valAddr types1.ValAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BeforeDelegationSharesModified", ctx, delAddr, valAddr)
ret0, _ := ret[0].(error)
@ -715,7 +714,7 @@ func (mr *MockStakingHooksMockRecorder) BeforeDelegationSharesModified(ctx, delA
}
// BeforeValidatorModified mocks base method.
func (m *MockStakingHooks) BeforeValidatorModified(ctx context.Context, valAddr types2.ValAddress) error {
func (m *MockStakingHooks) BeforeValidatorModified(ctx context.Context, valAddr types1.ValAddress) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BeforeValidatorModified", ctx, valAddr)
ret0, _ := ret[0].(error)
@ -729,7 +728,7 @@ func (mr *MockStakingHooksMockRecorder) BeforeValidatorModified(ctx, valAddr int
}
// BeforeValidatorSlashed mocks base method.
func (m *MockStakingHooks) BeforeValidatorSlashed(ctx context.Context, valAddr types2.ValAddress, fraction math.LegacyDec) error {
func (m *MockStakingHooks) BeforeValidatorSlashed(ctx context.Context, valAddr types1.ValAddress, fraction math.LegacyDec) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BeforeValidatorSlashed", ctx, valAddr, fraction)
ret0, _ := ret[0].(error)
@ -765,17 +764,17 @@ func (m *MockConsensusKeeper) EXPECT() *MockConsensusKeeperMockRecorder {
return m.recorder
}
// Params mocks base method.
func (m *MockConsensusKeeper) Params(arg0 context.Context, arg1 *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
// ValidatorPubKeyTypes mocks base method.
func (m *MockConsensusKeeper) ValidatorPubKeyTypes(arg0 context.Context) ([]string, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Params", arg0, arg1)
ret0, _ := ret[0].(*types.QueryParamsResponse)
ret := m.ctrl.Call(m, "ValidatorPubKeyTypes", arg0)
ret0, _ := ret[0].([]string)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Params indicates an expected call of Params.
func (mr *MockConsensusKeeperMockRecorder) Params(arg0, arg1 interface{}) *gomock.Call {
// ValidatorPubKeyTypes indicates an expected call of ValidatorPubKeyTypes.
func (mr *MockConsensusKeeperMockRecorder) ValidatorPubKeyTypes(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Params", reflect.TypeOf((*MockConsensusKeeper)(nil).Params), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatorPubKeyTypes", reflect.TypeOf((*MockConsensusKeeper)(nil).ValidatorPubKeyTypes), arg0)
}

View File

@ -6,7 +6,6 @@ import (
st "cosmossdk.io/api/cosmos/staking/v1beta1"
"cosmossdk.io/core/address"
"cosmossdk.io/math"
consensustypes "cosmossdk.io/x/consensus/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -117,5 +116,5 @@ type StakingHooksWrapper struct{ StakingHooks }
func (StakingHooksWrapper) IsOnePerModuleType() {}
type ConsensusKeeper interface {
Params(context.Context, *consensustypes.QueryParamsRequest) (*consensustypes.QueryParamsResponse, error)
ValidatorPubKeyTypes(context.Context) ([]string, error)
}

View File

@ -33,6 +33,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#19443](https://github.com/cosmos/cosmos-sdk/pull/19443) `NewKeeper` takes an `appmodule.Environment` instead of individual services.
* [#21259](https://github.com/cosmos/cosmos-sdk/pull/21259) Upgrade has been migrated to cosrestore.StoreUpgrades. Renaming keys support has been removed from the upgrade module.
* [#21480](https://github.com/cosmos/cosmos-sdk/pull/21480) ConsensusKeeper is required to be passed to the keeper.
### State Machine Breaking

View File

@ -41,6 +41,7 @@ type ModuleInputs struct {
Cdc codec.Codec
AddressCodec address.Codec
AppVersionModifier coreserver.VersionModifier
ConsensusKeeper types.ConsensusKeeper
AppOpts servertypes.AppOptions `optional:"true"` // server v0
Viper *viper.Viper `optional:"true"` // server v2
@ -85,7 +86,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
}
// set the governance module account as the authority for conducting upgrades
k := keeper.NewKeeper(in.Environment, skipUpgradeHeights, in.Cdc, homePath, in.AppVersionModifier, authorityStr)
k := keeper.NewKeeper(in.Environment, skipUpgradeHeights, in.Cdc, homePath, in.AppVersionModifier, authorityStr, in.ConsensusKeeper)
m := NewAppModule(k)
return ModuleOutputs{UpgradeKeeper: k, Module: m}

View File

@ -10,7 +10,6 @@ require (
cosmossdk.io/errors v1.0.1
cosmossdk.io/log v1.4.1
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000
cosmossdk.io/x/gov v0.0.0-20230925135524-a1bc045b3190
github.com/cometbft/cometbft v1.0.0-rc1.0.20240908111210-ab0be101882f
github.com/cometbft/cometbft/api v1.0.0-rc.1
@ -18,6 +17,7 @@ require (
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.53.0
github.com/cosmos/gogoproto v1.7.0
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.4
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/hashicorp/go-cleanhttp v0.5.2
@ -97,7 +97,6 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.2.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/flatbuffers v2.0.8+incompatible // indirect
@ -207,7 +206,6 @@ replace (
cosmossdk.io/core/testing => ../../core/testing
cosmossdk.io/store => ../../store
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/gov => ../gov
cosmossdk.io/x/staking => ../staking
cosmossdk.io/x/tx => ../tx

View File

@ -5,7 +5,6 @@ import (
"errors"
"fmt"
consensusv1 "cosmossdk.io/x/consensus/types"
"cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/telemetry"
@ -43,20 +42,9 @@ func (k Keeper) PreBlocker(ctx context.Context) error {
}
if lastAppliedPlan != "" && !k.HasHandler(lastAppliedPlan) {
var appVersion uint64
resp, err := k.QueryRouterService.Invoke(ctx, &consensusv1.QueryParamsRequest{})
appVersion, err := k.consensusKeeper.AppVersion(ctx)
if err != nil {
return errors.New("failed to query consensus params")
}
res, ok := resp.(*consensusv1.QueryParamsResponse)
if !ok {
return fmt.Errorf("unexpected response type: %T", resp)
}
if res.Params.Version != nil {
appVersion = res.Params.Version.App
return err
}
return fmt.Errorf("wrong app version %d, upgrade handler is missing for %s upgrade plan", appVersion, lastAppliedPlan)

View File

@ -8,6 +8,7 @@ import (
"time"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"cosmossdk.io/core/appmodule"
@ -18,6 +19,7 @@ import (
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/upgrade"
"cosmossdk.io/x/upgrade/keeper"
upgradetestutil "cosmossdk.io/x/upgrade/testutil"
"cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/baseapp"
@ -138,7 +140,9 @@ func setupTest(t *testing.T, height int64, skip map[int64]bool) *TestSuite {
authority, err := addresscodec.NewBech32Codec("cosmos").BytesToString(authtypes.NewModuleAddress(govModuleName))
require.NoError(t, err)
s.keeper = keeper.NewKeeper(s.env, skip, s.encCfg.Codec, t.TempDir(), s.baseApp, authority)
ctrl := gomock.NewController(t)
ck := upgradetestutil.NewMockConsensusKeeper(ctrl)
s.keeper = keeper.NewKeeper(s.env, skip, s.encCfg.Codec, t.TempDir(), s.baseApp, authority, ck)
s.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now(), Height: height})
@ -529,8 +533,11 @@ func TestDowngradeVerification(t *testing.T) {
authority, err := addresscodec.NewBech32Codec("cosmos").BytesToString(authtypes.NewModuleAddress(govModuleName))
require.NoError(t, err)
ctrl := gomock.NewController(t)
// downgrade. now keeper does not have the handler.
k := keeper.NewKeeper(s.env, map[int64]bool{}, s.encCfg.Codec, t.TempDir(), nil, authority)
ck := upgradetestutil.NewMockConsensusKeeper(ctrl)
ck.EXPECT().AppVersion(gomock.Any()).Return(uint64(0), nil).AnyTimes()
k := keeper.NewKeeper(s.env, map[int64]bool{}, s.encCfg.Codec, t.TempDir(), nil, authority, ck)
m := upgrade.NewAppModule(k)
// assertions

View File

@ -5,6 +5,7 @@ import (
"fmt"
"testing"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/suite"
"cosmossdk.io/core/appmodule"
@ -13,6 +14,7 @@ import (
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/upgrade"
"cosmossdk.io/x/upgrade/keeper"
upgradetestutil "cosmossdk.io/x/upgrade/testutil"
"cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/baseapp"
@ -47,7 +49,9 @@ func (suite *UpgradeTestSuite) SetupTest() {
authority, err := addresscodec.NewBech32Codec("cosmos").BytesToString(authtypes.NewModuleAddress(types.GovModuleName))
suite.Require().NoError(err)
suite.encodedAuthority = authority
suite.upgradeKeeper = keeper.NewKeeper(env, skipUpgradeHeights, suite.encCfg.Codec, suite.T().TempDir(), nil, authority)
ctrl := gomock.NewController(suite.T())
ck := upgradetestutil.NewMockConsensusKeeper(ctrl)
suite.upgradeKeeper = keeper.NewKeeper(env, skipUpgradeHeights, suite.encCfg.Codec, suite.T().TempDir(), nil, authority, ck)
err = suite.upgradeKeeper.SetModuleVersionMap(suite.ctx, appmodule.VersionMap{
"bank": 0,
})

View File

@ -38,6 +38,8 @@ type Keeper struct {
downgradeVerified bool // tells if we've already sanity checked that this binary version isn't being used against an old state.
authority string // the address capable of executing and canceling an upgrade. Usually the gov module account
initVersionMap appmodule.VersionMap // the module version map at init genesis
consensusKeeper types.ConsensusKeeper
}
// NewKeeper constructs an upgrade Keeper which requires the following arguments:
@ -53,6 +55,7 @@ func NewKeeper(
homePath string,
vs server.VersionModifier,
authority string,
ck types.ConsensusKeeper,
) *Keeper {
k := &Keeper{
Environment: env,
@ -62,6 +65,7 @@ func NewKeeper(
upgradeHandlers: map[string]types.UpgradeHandler{},
versionModifier: vs,
authority: authority,
consensusKeeper: ck,
}
if homePath == "" {

View File

@ -7,6 +7,7 @@ import (
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
cmttypes "github.com/cometbft/cometbft/types"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/suite"
"cosmossdk.io/core/appmodule"
@ -16,6 +17,7 @@ import (
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/upgrade"
"cosmossdk.io/x/upgrade/keeper"
upgradetestutil "cosmossdk.io/x/upgrade/testutil"
"cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/baseapp"
@ -73,7 +75,9 @@ func (s *KeeperTestSuite) SetupTest() {
authority, err := ac.BytesToString(authtypes.NewModuleAddress(types.GovModuleName))
s.Require().NoError(err)
s.encodedAuthority = authority
s.upgradeKeeper = keeper.NewKeeper(env, skipUpgradeHeights, s.encCfg.Codec, homeDir, s.baseApp, authority)
ctrl := gomock.NewController(s.T())
s.upgradeKeeper = keeper.NewKeeper(env, skipUpgradeHeights, s.encCfg.Codec, homeDir, s.baseApp, authority, upgradetestutil.NewMockConsensusKeeper(ctrl))
s.T().Log("home dir:", homeDir)
s.homeDir = homeDir
@ -257,7 +261,8 @@ func (s *KeeperTestSuite) TestIsSkipHeight() {
skip := map[int64]bool{skipOne: true}
storeService := runtime.NewKVStoreService(s.key)
env := runtime.NewEnvironment(storeService, coretesting.NewNopLogger())
upgradeKeeper := keeper.NewKeeper(env, skip, s.encCfg.Codec, s.T().TempDir(), s.baseApp, s.encodedAuthority)
ctrl := gomock.NewController(s.T())
upgradeKeeper := keeper.NewKeeper(env, skip, s.encCfg.Codec, s.T().TempDir(), s.baseApp, s.encodedAuthority, upgradetestutil.NewMockConsensusKeeper(ctrl))
s.Require().True(upgradeKeeper.IsSkipHeight(9))
s.Require().False(upgradeKeeper.IsSkipHeight(10))
}

View File

@ -0,0 +1,50 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: x/upgrade/types/expected_keepers.go
// Package testutil is a generated GoMock package.
package testutil
import (
context "context"
reflect "reflect"
gomock "github.com/golang/mock/gomock"
)
// MockConsensusKeeper is a mock of ConsensusKeeper interface.
type MockConsensusKeeper struct {
ctrl *gomock.Controller
recorder *MockConsensusKeeperMockRecorder
}
// MockConsensusKeeperMockRecorder is the mock recorder for MockConsensusKeeper.
type MockConsensusKeeperMockRecorder struct {
mock *MockConsensusKeeper
}
// NewMockConsensusKeeper creates a new mock instance.
func NewMockConsensusKeeper(ctrl *gomock.Controller) *MockConsensusKeeper {
mock := &MockConsensusKeeper{ctrl: ctrl}
mock.recorder = &MockConsensusKeeperMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockConsensusKeeper) EXPECT() *MockConsensusKeeperMockRecorder {
return m.recorder
}
// AppVersion mocks base method.
func (m *MockConsensusKeeper) AppVersion(ctx context.Context) (uint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "AppVersion", ctx)
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// AppVersion indicates an expected call of AppVersion.
func (mr *MockConsensusKeeperMockRecorder) AppVersion(ctx interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AppVersion", reflect.TypeOf((*MockConsensusKeeper)(nil).AppVersion), ctx)
}

View File

@ -0,0 +1,7 @@
package types
import "context"
type ConsensusKeeper interface {
AppVersion(ctx context.Context) (uint64, error)
}