From ff12daa53f08053af0e96973e15c91891399d0bd Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Thu, 9 Jun 2022 12:11:09 -0600 Subject: [PATCH 01/36] feat: migrate x/crisis to use app wiring --- api/cosmos/crisis/module/v1/module.pulsar.go | 704 +++++++++++++++++++ proto/cosmos/crisis/module/v1/module.proto | 19 + simapp/app.go | 1 + simapp/app.yaml | 4 + x/crisis/module.go | 50 +- 5 files changed, 776 insertions(+), 2 deletions(-) create mode 100644 api/cosmos/crisis/module/v1/module.pulsar.go create mode 100644 proto/cosmos/crisis/module/v1/module.proto diff --git a/api/cosmos/crisis/module/v1/module.pulsar.go b/api/cosmos/crisis/module/v1/module.pulsar.go new file mode 100644 index 000000000000..58bcca5a916b --- /dev/null +++ b/api/cosmos/crisis/module/v1/module.pulsar.go @@ -0,0 +1,704 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package modulev1 + +import ( + _ "cosmossdk.io/api/cosmos/app/v1alpha1" + fmt "fmt" + runtime "github.com/cosmos/cosmos-proto/runtime" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoiface "google.golang.org/protobuf/runtime/protoiface" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" +) + +var ( + md_Module protoreflect.MessageDescriptor + fd_Module_invalid_check_period protoreflect.FieldDescriptor + fd_Module_fee_collector_name protoreflect.FieldDescriptor + fd_Module_skip_genesis_invariants protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_crisis_module_v1_module_proto_init() + md_Module = File_cosmos_crisis_module_v1_module_proto.Messages().ByName("Module") + fd_Module_invalid_check_period = md_Module.Fields().ByName("invalid_check_period") + fd_Module_fee_collector_name = md_Module.Fields().ByName("fee_collector_name") + fd_Module_skip_genesis_invariants = md_Module.Fields().ByName("skip_genesis_invariants") +} + +var _ protoreflect.Message = (*fastReflection_Module)(nil) + +type fastReflection_Module Module + +func (x *Module) ProtoReflect() protoreflect.Message { + return (*fastReflection_Module)(x) +} + +func (x *Module) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_crisis_module_v1_module_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_Module_messageType fastReflection_Module_messageType +var _ protoreflect.MessageType = fastReflection_Module_messageType{} + +type fastReflection_Module_messageType struct{} + +func (x fastReflection_Module_messageType) Zero() protoreflect.Message { + return (*fastReflection_Module)(nil) +} +func (x fastReflection_Module_messageType) New() protoreflect.Message { + return new(fastReflection_Module) +} +func (x fastReflection_Module_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_Module +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_Module) Descriptor() protoreflect.MessageDescriptor { + return md_Module +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_Module) Type() protoreflect.MessageType { + return _fastReflection_Module_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_Module) New() protoreflect.Message { + return new(fastReflection_Module) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_Module) Interface() protoreflect.ProtoMessage { + return (*Module)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.InvalidCheckPeriod != uint32(0) { + value := protoreflect.ValueOfUint32(x.InvalidCheckPeriod) + if !f(fd_Module_invalid_check_period, value) { + return + } + } + if x.FeeCollectorName != "" { + value := protoreflect.ValueOfString(x.FeeCollectorName) + if !f(fd_Module_fee_collector_name, value) { + return + } + } + if x.SkipGenesisInvariants != false { + value := protoreflect.ValueOfBool(x.SkipGenesisInvariants) + if !f(fd_Module_skip_genesis_invariants, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.crisis.module.v1.Module.invalid_check_period": + return x.InvalidCheckPeriod != uint32(0) + case "cosmos.crisis.module.v1.Module.fee_collector_name": + return x.FeeCollectorName != "" + case "cosmos.crisis.module.v1.Module.skip_genesis_invariants": + return x.SkipGenesisInvariants != false + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crisis.module.v1.Module")) + } + panic(fmt.Errorf("message cosmos.crisis.module.v1.Module does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.crisis.module.v1.Module.invalid_check_period": + x.InvalidCheckPeriod = uint32(0) + case "cosmos.crisis.module.v1.Module.fee_collector_name": + x.FeeCollectorName = "" + case "cosmos.crisis.module.v1.Module.skip_genesis_invariants": + x.SkipGenesisInvariants = false + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crisis.module.v1.Module")) + } + panic(fmt.Errorf("message cosmos.crisis.module.v1.Module does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.crisis.module.v1.Module.invalid_check_period": + value := x.InvalidCheckPeriod + return protoreflect.ValueOfUint32(value) + case "cosmos.crisis.module.v1.Module.fee_collector_name": + value := x.FeeCollectorName + return protoreflect.ValueOfString(value) + case "cosmos.crisis.module.v1.Module.skip_genesis_invariants": + value := x.SkipGenesisInvariants + return protoreflect.ValueOfBool(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crisis.module.v1.Module")) + } + panic(fmt.Errorf("message cosmos.crisis.module.v1.Module does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.crisis.module.v1.Module.invalid_check_period": + x.InvalidCheckPeriod = uint32(value.Uint()) + case "cosmos.crisis.module.v1.Module.fee_collector_name": + x.FeeCollectorName = value.Interface().(string) + case "cosmos.crisis.module.v1.Module.skip_genesis_invariants": + x.SkipGenesisInvariants = value.Bool() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crisis.module.v1.Module")) + } + panic(fmt.Errorf("message cosmos.crisis.module.v1.Module does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.crisis.module.v1.Module.invalid_check_period": + panic(fmt.Errorf("field invalid_check_period of message cosmos.crisis.module.v1.Module is not mutable")) + case "cosmos.crisis.module.v1.Module.fee_collector_name": + panic(fmt.Errorf("field fee_collector_name of message cosmos.crisis.module.v1.Module is not mutable")) + case "cosmos.crisis.module.v1.Module.skip_genesis_invariants": + panic(fmt.Errorf("field skip_genesis_invariants of message cosmos.crisis.module.v1.Module is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crisis.module.v1.Module")) + } + panic(fmt.Errorf("message cosmos.crisis.module.v1.Module does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.crisis.module.v1.Module.invalid_check_period": + return protoreflect.ValueOfUint32(uint32(0)) + case "cosmos.crisis.module.v1.Module.fee_collector_name": + return protoreflect.ValueOfString("") + case "cosmos.crisis.module.v1.Module.skip_genesis_invariants": + return protoreflect.ValueOfBool(false) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crisis.module.v1.Module")) + } + panic(fmt.Errorf("message cosmos.crisis.module.v1.Module does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_Module) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.crisis.module.v1.Module", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_Module) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Module) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_Module) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*Module) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.InvalidCheckPeriod != 0 { + n += 1 + runtime.Sov(uint64(x.InvalidCheckPeriod)) + } + l = len(x.FeeCollectorName) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.SkipGenesisInvariants { + n += 2 + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*Module) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.SkipGenesisInvariants { + i-- + if x.SkipGenesisInvariants { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if len(x.FeeCollectorName) > 0 { + i -= len(x.FeeCollectorName) + copy(dAtA[i:], x.FeeCollectorName) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.FeeCollectorName))) + i-- + dAtA[i] = 0x12 + } + if x.InvalidCheckPeriod != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.InvalidCheckPeriod)) + i-- + dAtA[i] = 0x8 + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*Module) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Module: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Module: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field InvalidCheckPeriod", wireType) + } + x.InvalidCheckPeriod = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.InvalidCheckPeriod |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field FeeCollectorName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.FeeCollectorName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SkipGenesisInvariants", wireType) + } + var v 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++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + x.SkipGenesisInvariants = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: cosmos/crisis/module/v1/module.proto + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Module is the config object of the crisis module. +type Module struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Invalid Check Period + InvalidCheckPeriod uint32 `protobuf:"varint,1,opt,name=invalid_check_period,json=invalidCheckPeriod,proto3" json:"invalid_check_period,omitempty"` + FeeCollectorName string `protobuf:"bytes,2,opt,name=fee_collector_name,json=feeCollectorName,proto3" json:"fee_collector_name,omitempty"` + SkipGenesisInvariants bool `protobuf:"varint,3,opt,name=skip_genesis_invariants,json=skipGenesisInvariants,proto3" json:"skip_genesis_invariants,omitempty"` +} + +func (x *Module) Reset() { + *x = Module{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_crisis_module_v1_module_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Module) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Module) ProtoMessage() {} + +// Deprecated: Use Module.ProtoReflect.Descriptor instead. +func (*Module) Descriptor() ([]byte, []int) { + return file_cosmos_crisis_module_v1_module_proto_rawDescGZIP(), []int{0} +} + +func (x *Module) GetInvalidCheckPeriod() uint32 { + if x != nil { + return x.InvalidCheckPeriod + } + return 0 +} + +func (x *Module) GetFeeCollectorName() string { + if x != nil { + return x.FeeCollectorName + } + return "" +} + +func (x *Module) GetSkipGenesisInvariants() bool { + if x != nil { + return x.SkipGenesisInvariants + } + return false +} + +var File_cosmos_crisis_module_v1_module_proto protoreflect.FileDescriptor + +var file_cosmos_crisis_module_v1_module_proto_rawDesc = []byte{ + 0x0a, 0x24, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x72, 0x69, 0x73, 0x69, 0x73, 0x2f, + 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x17, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, + 0x72, 0x69, 0x73, 0x69, 0x73, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a, + 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0xcf, 0x01, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x30, 0x0a, 0x14, + 0x69, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x70, 0x65, + 0x72, 0x69, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x12, 0x69, 0x6e, 0x76, 0x61, + 0x6c, 0x69, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x12, 0x2c, + 0x0a, 0x12, 0x66, 0x65, 0x65, 0x5f, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x5f, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x66, 0x65, 0x65, 0x43, + 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x36, 0x0a, 0x17, + 0x73, 0x6b, 0x69, 0x70, 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x69, 0x6e, 0x76, + 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, 0x73, + 0x6b, 0x69, 0x70, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x49, 0x6e, 0x76, 0x61, 0x72, 0x69, + 0x61, 0x6e, 0x74, 0x73, 0x3a, 0x2d, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x27, 0x0a, 0x25, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x78, 0x2f, 0x63, 0x72, 0x69, + 0x73, 0x69, 0x73, 0x42, 0xdc, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x69, 0x73, 0x69, 0x73, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, + 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x31, 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, 0x72, 0x69, 0x73, + 0x69, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f, 0x64, + 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x43, 0x4d, 0xaa, 0x02, 0x17, 0x43, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x43, 0x72, 0x69, 0x73, 0x69, 0x73, 0x2e, 0x4d, 0x6f, 0x64, 0x75, + 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, + 0x72, 0x69, 0x73, 0x69, 0x73, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, + 0x02, 0x23, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x72, 0x69, 0x73, 0x69, 0x73, 0x5c, + 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1a, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, + 0x43, 0x72, 0x69, 0x73, 0x69, 0x73, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x3a, + 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_cosmos_crisis_module_v1_module_proto_rawDescOnce sync.Once + file_cosmos_crisis_module_v1_module_proto_rawDescData = file_cosmos_crisis_module_v1_module_proto_rawDesc +) + +func file_cosmos_crisis_module_v1_module_proto_rawDescGZIP() []byte { + file_cosmos_crisis_module_v1_module_proto_rawDescOnce.Do(func() { + file_cosmos_crisis_module_v1_module_proto_rawDescData = protoimpl.X.CompressGZIP(file_cosmos_crisis_module_v1_module_proto_rawDescData) + }) + return file_cosmos_crisis_module_v1_module_proto_rawDescData +} + +var file_cosmos_crisis_module_v1_module_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_cosmos_crisis_module_v1_module_proto_goTypes = []interface{}{ + (*Module)(nil), // 0: cosmos.crisis.module.v1.Module +} +var file_cosmos_crisis_module_v1_module_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_cosmos_crisis_module_v1_module_proto_init() } +func file_cosmos_crisis_module_v1_module_proto_init() { + if File_cosmos_crisis_module_v1_module_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_cosmos_crisis_module_v1_module_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Module); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_cosmos_crisis_module_v1_module_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_cosmos_crisis_module_v1_module_proto_goTypes, + DependencyIndexes: file_cosmos_crisis_module_v1_module_proto_depIdxs, + MessageInfos: file_cosmos_crisis_module_v1_module_proto_msgTypes, + }.Build() + File_cosmos_crisis_module_v1_module_proto = out.File + file_cosmos_crisis_module_v1_module_proto_rawDesc = nil + file_cosmos_crisis_module_v1_module_proto_goTypes = nil + file_cosmos_crisis_module_v1_module_proto_depIdxs = nil +} diff --git a/proto/cosmos/crisis/module/v1/module.proto b/proto/cosmos/crisis/module/v1/module.proto new file mode 100644 index 000000000000..d594a9edf173 --- /dev/null +++ b/proto/cosmos/crisis/module/v1/module.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package cosmos.crisis.module.v1; + +import "cosmos/app/v1alpha1/module.proto"; + +// Module is the config object of the crisis module. +message Module { + option (cosmos.app.v1alpha1.module) = { + go_import: "github.com/cosmos/cosmos-sdk/x/crisis" + }; + + // Invalid Check Period + uint32 invalid_check_period = 1; + + string fee_collector_name = 2; + + bool skip_genesis_invariants = 3; +} diff --git a/simapp/app.go b/simapp/app.go index f95aa6bb817d..d6ea6ede746d 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -227,6 +227,7 @@ func NewSimApp( &app.FeeGrantKeeper, &app.StakingKeeper, &app.NFTKeeper, + &app.CrisisKeeper, &msgServiceRouter, ); err != nil { panic(err) diff --git a/simapp/app.yaml b/simapp/app.yaml index 6f5fcff803ac..dae70ebd2f96 100644 --- a/simapp/app.yaml +++ b/simapp/app.yaml @@ -103,3 +103,7 @@ modules: - name: nft config: "@type": cosmos.nft.module.v1.Module + + - name: crisis + config: + "@type": cosmos.crisis.module.v1.Module diff --git a/x/crisis/module.go b/x/crisis/module.go index 7c058a4f22e0..6b2b3bb7486f 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -1,11 +1,16 @@ package crisis import ( + modulev1 "cosmossdk.io/api/cosmos/crisis/module/v1" + "cosmossdk.io/core/appmodule" "encoding/json" "fmt" + "github.com/cosmos/cosmos-sdk/depinject" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "time" - "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -60,7 +65,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod } // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the capability module. -func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {} +func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *gwruntime.ServeMux) {} // GetTxCmd returns the root tx command for the crisis module. func (b AppModuleBasic) GetTxCmd() *cobra.Command { @@ -164,3 +169,44 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val EndBlocker(ctx, *am.keeper) return []abci.ValidatorUpdate{} } + +func init() { + appmodule.Register( + &modulev1.Module{}, + appmodule.Provide( + provideModuleBasic, + provideModule, + ), + ) +} + +type crisisInputs struct { + depinject.In + + Cdc codec.Codec + Config modulev1.Module + Subspace paramstypes.Subspace + BankKeeper types.SupplyKeeper `key:"cosmos.bank.v1.Keeper"` +} + +type crisisOutputs struct { + depinject.Out + + CrisisKeeper keeper.Keeper `key:"cosmos.crisis.v1.Keeper"` + Module runtime.AppModuleWrapper +} + +func provideModuleBasic() runtime.AppModuleBasicWrapper { + return runtime.WrapAppModuleBasic(AppModuleBasic{}) +} + +func provideModule(in crisisInputs) crisisOutputs { + k := keeper.NewKeeper( + in.Subspace, + uint(in.Config.InvalidCheckPeriod), + in.BankKeeper, + in.Config.FeeCollectorName, + ) + m := NewAppModule(&k, in.Config.SkipGenesisInvariants) + return crisisOutputs{CrisisKeeper: k, Module: runtime.WrapAppModule(m)} +} From 3b91f50a2141e183ec960c4dd8258f2f56ab4adb Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Wed, 15 Jun 2022 13:37:28 -0600 Subject: [PATCH 02/36] remove crisis from app --- simapp/app.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index d6ea6ede746d..d52f7de7a5d9 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -264,9 +264,9 @@ func NewSimApp( app.SlashingKeeper = slashingkeeper.NewKeeper( app.appCodec, app.keys[slashingtypes.StoreKey], app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), ) - app.CrisisKeeper = crisiskeeper.NewKeeper( - app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, - ) + //app.CrisisKeeper = crisiskeeper.NewKeeper( + // app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, + //) app.StakingKeeper.SetHooks( stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), @@ -314,7 +314,7 @@ func NewSimApp( // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment // we prefer to be more strict in what arguments the modules expect. - skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) + //skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. @@ -324,7 +324,7 @@ func NewSimApp( encodingConfig.TxConfig, ), vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), - crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), + //crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), gov.NewAppModule(app.appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), mint.NewAppModule(app.appCodec, app.MintKeeper, app.AccountKeeper, nil), slashing.NewAppModule(app.appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), @@ -345,7 +345,7 @@ func NewSimApp( genesisModuleOrder := []string{ capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, - minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, + minttypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName, nft.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, } @@ -355,7 +355,7 @@ func NewSimApp( // Uncomment if you want to set a custom migration order here. // app.mm.SetOrderMigrations(custom order) - app.ModuleManager.RegisterInvariants(&app.CrisisKeeper) + //app.ModuleManager.RegisterInvariants(&app.CrisisKeeper) app.ModuleManager.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) // RegisterUpgradeHandlers is used for registering any on-chain upgrades. From 518738a8809a51dda55e71afcc6373a6105f7573 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Wed, 15 Jun 2022 13:53:14 -0600 Subject: [PATCH 03/36] comment import --- simapp/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simapp/app.go b/simapp/app.go index c95e5552bbf7..a4b309fdd866 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -9,7 +9,7 @@ import ( "github.com/gorilla/mux" "github.com/rakyll/statik/fs" - "github.com/spf13/cast" + //"github.com/spf13/cast" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" tmos "github.com/tendermint/tendermint/libs/os" From cadf47fdfcb96f3bc88097f76b2e303f89b6ada7 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Thu, 16 Jun 2022 09:54:33 -0600 Subject: [PATCH 04/36] change config to pointer --- x/crisis/module.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/crisis/module.go b/x/crisis/module.go index 6b2b3bb7486f..5c1dabe59f92 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -184,7 +184,7 @@ type crisisInputs struct { depinject.In Cdc codec.Codec - Config modulev1.Module + Config *modulev1.Module Subspace paramstypes.Subspace BankKeeper types.SupplyKeeper `key:"cosmos.bank.v1.Keeper"` } From 9a275ec410e71609582a7cd2328637b91f64d67d Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Thu, 16 Jun 2022 10:49:14 -0600 Subject: [PATCH 05/36] remove double param --- simapp/app.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index a4b309fdd866..541407ca9f8a 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -317,7 +317,7 @@ func NewSimApp( // can do so safely. genesisModuleOrder := []string{ capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, - distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, + distrtypes.ModuleName, stakingtypes.ModuleName, crisistypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName, nft.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, @@ -488,5 +488,5 @@ func GetMaccPerms() map[string][]string { func initParamsKeeper(paramsKeeper paramskeeper.Keeper) { paramsKeeper.Subspace(distrtypes.ModuleName) paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) - paramsKeeper.Subspace(crisistypes.ModuleName) + //paramsKeeper.Subspace(crisistypes.ModuleName) } From 8502184449ea37a60df78a7120aa0423bb9879a8 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Thu, 16 Jun 2022 13:23:21 -0600 Subject: [PATCH 06/36] remove slashing keeper --- simapp/app.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index 541407ca9f8a..8f128e44ddc5 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -256,9 +256,6 @@ func NewSimApp( app.appCodec, app.keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, authtypes.FeeCollectorName, ) - app.SlashingKeeper = slashingkeeper.NewKeeper( - app.appCodec, app.keys[slashingtypes.StoreKey], app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), - ) //app.CrisisKeeper = crisiskeeper.NewKeeper( // app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, //) From 557c5033da85800becc799af5b62f64a0deb9adb Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Thu, 16 Jun 2022 13:30:23 -0600 Subject: [PATCH 07/36] remove comments --- simapp/app.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index 8f128e44ddc5..09793f9cc7f3 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -256,9 +256,6 @@ func NewSimApp( app.appCodec, app.keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, authtypes.FeeCollectorName, ) - //app.CrisisKeeper = crisiskeeper.NewKeeper( - // app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, - //) app.StakingKeeper.SetHooks( stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), @@ -485,5 +482,4 @@ func GetMaccPerms() map[string][]string { func initParamsKeeper(paramsKeeper paramskeeper.Keeper) { paramsKeeper.Subspace(distrtypes.ModuleName) paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) - //paramsKeeper.Subspace(crisistypes.ModuleName) } From afcd47d609e3f7d996e4e7f77a346c94e6b224d4 Mon Sep 17 00:00:00 2001 From: Jeancarlo Barrios Date: Fri, 17 Jun 2022 10:36:45 -0600 Subject: [PATCH 08/36] Update x/crisis/module.go Co-authored-by: Julien Robert --- x/crisis/module.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/crisis/module.go b/x/crisis/module.go index 5c1dabe59f92..0b7100aad250 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -205,7 +205,7 @@ func provideModule(in crisisInputs) crisisOutputs { in.Subspace, uint(in.Config.InvalidCheckPeriod), in.BankKeeper, - in.Config.FeeCollectorName, + authtypes.FeeCollectorName, ) m := NewAppModule(&k, in.Config.SkipGenesisInvariants) return crisisOutputs{CrisisKeeper: k, Module: runtime.WrapAppModule(m)} From 80a51b420f84ec7000f069eb1ab35e1304c137d8 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Mon, 20 Jun 2022 07:49:05 -0600 Subject: [PATCH 09/36] change type for auth types --- x/crisis/module.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/crisis/module.go b/x/crisis/module.go index 0b7100aad250..4a1af238a690 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "github.com/cosmos/cosmos-sdk/depinject" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "time" From 38b42b38cde0942f18cfcfac0dd34cb60cc76c4d Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Mon, 20 Jun 2022 11:56:22 -0600 Subject: [PATCH 10/36] t --- x/crisis/module.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/x/crisis/module.go b/x/crisis/module.go index 4a1af238a690..609067cb0070 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "github.com/cosmos/cosmos-sdk/depinject" + types2 "github.com/cosmos/cosmos-sdk/server/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" @@ -184,6 +185,7 @@ func init() { type crisisInputs struct { depinject.In + appOptions types2.AppOptions Cdc codec.Codec Config *modulev1.Module Subspace paramstypes.Subspace @@ -208,6 +210,8 @@ func provideModule(in crisisInputs) crisisOutputs { in.BankKeeper, authtypes.FeeCollectorName, ) + //m := NewAppModule(&k, in.appOptions) + m := NewAppModule(&k, in.Config.SkipGenesisInvariants) return crisisOutputs{CrisisKeeper: k, Module: runtime.WrapAppModule(m)} } From f9f8f76e519443c9a4ba216711bdbd3bd8481d06 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Wed, 22 Jun 2022 08:19:13 -0600 Subject: [PATCH 11/36] depinject flag --- x/crisis/module.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/x/crisis/module.go b/x/crisis/module.go index 609067cb0070..afc95d20274e 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -6,10 +6,12 @@ import ( "encoding/json" "fmt" "github.com/cosmos/cosmos-sdk/depinject" - types2 "github.com/cosmos/cosmos-sdk/server/types" + "github.com/cosmos/cosmos-sdk/server" + servertypes "github.com/cosmos/cosmos-sdk/server/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cast" "time" "github.com/cosmos/cosmos-sdk/runtime" @@ -185,7 +187,7 @@ func init() { type crisisInputs struct { depinject.In - appOptions types2.AppOptions + AppOpts servertypes.AppOptions Cdc codec.Codec Config *modulev1.Module Subspace paramstypes.Subspace @@ -210,8 +212,7 @@ func provideModule(in crisisInputs) crisisOutputs { in.BankKeeper, authtypes.FeeCollectorName, ) - //m := NewAppModule(&k, in.appOptions) - - m := NewAppModule(&k, in.Config.SkipGenesisInvariants) + skipGenesisInvariants := cast.ToBool(in.AppOpts.Get(server.FlagInvCheckPeriod)) + m := NewAppModule(&k, skipGenesisInvariants) return crisisOutputs{CrisisKeeper: k, Module: runtime.WrapAppModule(m)} } From d551e9815e63e03c834124754d82784203fc40dd Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Wed, 22 Jun 2022 17:49:55 -0600 Subject: [PATCH 12/36] remove crisis --- simapp/app.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index a0b582516f7d..454d1de958ae 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -204,7 +204,9 @@ func NewSimApp( var ( appBuilder *runtime.AppBuilder - app = &SimApp{invCheckPeriod: invCheckPeriod} + //app = &SimApp{invCheckPeriod: invCheckPeriod} + app = &SimApp{} + // merge the app.yaml and the appOpts in one config appConfig = depinject.Configs(AppConfig, depinject.Supply(appOpts)) ) @@ -245,9 +247,9 @@ func NewSimApp( initParamsKeeper(app.ParamsKeeper) - app.CrisisKeeper = crisiskeeper.NewKeeper( - app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, - ) + //app.CrisisKeeper = crisiskeeper.NewKeeper( + // app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, + //) app.StakingKeeper.SetHooks( stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), From 8a00c1efc61abbb07982684525c9935bf2a4789a Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Wed, 22 Jun 2022 18:06:10 -0600 Subject: [PATCH 13/36] add skip genesis invariant --- x/crisis/module.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/x/crisis/module.go b/x/crisis/module.go index afc95d20274e..67e0ec85e510 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -206,13 +206,16 @@ func provideModuleBasic() runtime.AppModuleBasicWrapper { } func provideModule(in crisisInputs) crisisOutputs { + invalidCheckPeriod := cast.ToUint(in.AppOpts.Get(server.FlagInvCheckPeriod)) + k := keeper.NewKeeper( in.Subspace, - uint(in.Config.InvalidCheckPeriod), + invalidCheckPeriod, in.BankKeeper, authtypes.FeeCollectorName, ) - skipGenesisInvariants := cast.ToBool(in.AppOpts.Get(server.FlagInvCheckPeriod)) + skipGenesisInvariants := cast.ToBool(in.AppOpts.Get(FlagSkipGenesisInvariants)) + m := NewAppModule(&k, skipGenesisInvariants) return crisisOutputs{CrisisKeeper: k, Module: runtime.WrapAppModule(m)} } From 59c29a6e33fa5680385443b64659f8f1a8acae23 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Wed, 22 Jun 2022 18:28:50 -0600 Subject: [PATCH 14/36] changed the default app opts to have invalid check period --- simapp/test_helpers.go | 2 +- testutil/sims/app_helpers.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 4cdc47f3abad..7a587b56e599 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -42,7 +42,7 @@ type SetupOptions struct { func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) { db := dbm.NewMemDB() encCdc := MakeTestEncodingConfig() - app := NewSimApp(log.NewNopLogger(), db, nil, true, invCheckPeriod, encCdc, simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome)) + app := NewSimApp(log.NewNopLogger(), db, nil, true, invCheckPeriod, encCdc, simtestutil.NewAppOptionsWithFlagHomeAndInvalidCheckPeriod(DefaultNodeHome, invCheckPeriod)) if withGenesis { return app, NewDefaultGenesisState(encCdc.Codec) } diff --git a/testutil/sims/app_helpers.go b/testutil/sims/app_helpers.go index 61a5d5211924..c5cde34e9594 100644 --- a/testutil/sims/app_helpers.go +++ b/testutil/sims/app_helpers.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/cosmos/cosmos-sdk/server" "time" abci "github.com/tendermint/tendermint/abci/types" @@ -243,3 +244,10 @@ func NewAppOptionsWithFlagHome(homePath string) servertypes.AppOptions { flags.FlagHome: homePath, } } + +func NewAppOptionsWithFlagHomeAndInvalidCheckPeriod(homePath string, invalidCheckPeriod uint) servertypes.AppOptions { + return AppOptionsMap{ + flags.FlagHome: homePath, + server.FlagInvCheckPeriod: invalidCheckPeriod, + } +} From 7bdbc5aacb551ac9c0220d8523746d930002e365 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Sun, 26 Jun 2022 23:37:16 -0600 Subject: [PATCH 15/36] change app options to include flag period in tests --- baseapp/block_gas_test.go | 6 ++++- server/export_test.go | 10 ++++++--- simapp/app.go | 2 +- simapp/app_test.go | 43 +++++++++++++++++++++++++----------- simapp/sim_bench_test.go | 14 ++++++++++-- simapp/sim_test.go | 35 ++++++++++++++++++++++++----- simapp/simd/cmd/root.go | 15 ++++++++++--- simapp/test_helpers.go | 10 +++++++-- testutil/network/network.go | 9 ++++++-- testutil/sims/app_helpers.go | 8 ------- x/auth/module_test.go | 8 ++++++- x/gov/genesis_test.go | 8 ++++++- x/gov/module_test.go | 8 ++++++- x/staking/module_test.go | 8 ++++++- 14 files changed, 139 insertions(+), 45 deletions(-) diff --git a/baseapp/block_gas_test.go b/baseapp/block_gas_test.go index 9fd64fe46dd3..a0068cc4615c 100644 --- a/baseapp/block_gas_test.go +++ b/baseapp/block_gas_test.go @@ -2,6 +2,7 @@ package baseapp_test import ( "fmt" + "github.com/cosmos/cosmos-sdk/server" "math" "testing" @@ -64,7 +65,10 @@ func TestBaseApp_BlockGas(t *testing.T) { } encCfg := simapp.MakeTestEncodingConfig() - app = simapp.NewSimApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, 0, encCfg, simtestutil.EmptyAppOptions{}, routerOpt) + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[server.FlagInvCheckPeriod] = 0 + + app = simapp.NewSimApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, encCfg, appOptions, routerOpt) app.InterfaceRegistry().RegisterImplementations((*sdk.Msg)(nil), &testdata.TestMsg{}, ) diff --git a/server/export_test.go b/server/export_test.go index 7f8a5f5e582c..7ae498fc7ab3 100644 --- a/server/export_test.go +++ b/server/export_test.go @@ -129,7 +129,11 @@ func setupApp(t *testing.T, tempDir string) (*simapp.SimApp, context.Context, *t logger, _ := log.NewDefaultLogger("plain", "info", false) db := dbm.NewMemDB() encCfg := simapp.MakeTestEncodingConfig() - app := simapp.NewSimApp(logger, db, nil, true, 0, encCfg, simtestutil.NewAppOptionsWithFlagHome(tempDir)) + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[flags.FlagHome] = tempDir + appOptions[server.FlagInvCheckPeriod] = 0 + + app := simapp.NewSimApp(logger, db, nil, true, encCfg, appOptions) genesisState := simapp.GenesisStateWithSingleValidator(t, app) stateBytes, err := tmjson.MarshalIndent(genesisState, "", " ") @@ -160,13 +164,13 @@ func setupApp(t *testing.T, tempDir string) (*simapp.SimApp, context.Context, *t var simApp *simapp.SimApp if height != -1 { - simApp = simapp.NewSimApp(logger, db, nil, false, 0, encCfg, appOptions) + simApp = simapp.NewSimApp(logger, db, nil, false, encCfg, appOptions) if err := simApp.LoadHeight(height); err != nil { return types.ExportedApp{}, err } } else { - simApp = simapp.NewSimApp(logger, db, nil, true, 0, encCfg, appOptions) + simApp = simapp.NewSimApp(logger, db, nil, true, encCfg, appOptions) } return simApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs) diff --git a/simapp/app.go b/simapp/app.go index 068f3c419575..f3187108d40b 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -198,7 +198,7 @@ var AppConfig = appconfig.LoadYAML(appConfigYaml) // NewSimApp returns a reference to an initialized SimApp. func NewSimApp( - logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, invCheckPeriod uint, encodingConfig simappparams.EncodingConfig, + logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, encodingConfig simappparams.EncodingConfig, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), ) *SimApp { diff --git a/simapp/app_test.go b/simapp/app_test.go index b3e3874a2dfd..8dc066f0519e 100644 --- a/simapp/app_test.go +++ b/simapp/app_test.go @@ -2,6 +2,8 @@ package simapp import ( "encoding/json" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/server" "testing" "github.com/golang/mock/gomock" @@ -40,12 +42,16 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) { encCfg := MakeTestEncodingConfig() db := dbm.NewMemDB() logger, _ := log.NewDefaultLogger("plain", "info", false) + + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[server.FlagInvCheckPeriod] = 0 + appOptions[flags.FlagHome] = DefaultNodeHome + app := NewSimappWithCustomOptions(t, false, SetupOptions{ - Logger: logger, - DB: db, - InvCheckPeriod: 0, - EncConfig: encCfg, - AppOpts: simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), + Logger: logger, + DB: db, + EncConfig: encCfg, + AppOpts: appOptions, }) for acc := range maccPerms { @@ -60,7 +66,7 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) { logger2, _ := log.NewDefaultLogger("plain", "info", false) // Making a new app object with the db, so that initchain hasn't been called - app2 := NewSimApp(logger2, db, nil, true, 0, encCfg, simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome)) + app2 := NewSimApp(logger2, db, nil, true, encCfg, appOptions) _, err := app2.ExportAppStateAndValidators(false, []string{}) require.NoError(t, err, "ExportAppStateAndValidators should not have an error") } @@ -74,7 +80,11 @@ func TestRunMigrations(t *testing.T) { db := dbm.NewMemDB() encCfg := MakeTestEncodingConfig() logger, _ := log.NewDefaultLogger("plain", "info", false) - app := NewSimApp(logger, db, nil, true, 0, encCfg, simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome)) + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[server.FlagInvCheckPeriod] = 0 + appOptions[flags.FlagHome] = DefaultNodeHome + + app := NewSimApp(logger, db, nil, true, encCfg, appOptions) // Create a new baseapp and configurator for the purpose of this test. bApp := baseapp.NewBaseApp(app.Name(), logger, db, encCfg.TxConfig.TxDecoder()) @@ -207,7 +217,11 @@ func TestInitGenesisOnMigration(t *testing.T) { db := dbm.NewMemDB() encCfg := MakeTestEncodingConfig() logger, _ := log.NewDefaultLogger("plain", "info", false) - app := NewSimApp(logger, db, nil, true, 0, encCfg, simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome)) + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[server.FlagInvCheckPeriod] = 0 + appOptions[flags.FlagHome] = DefaultNodeHome + + app := NewSimApp(logger, db, nil, true, encCfg, appOptions) ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) // Create a mock module. This module will serve as the new module we're @@ -251,12 +265,15 @@ func TestUpgradeStateOnGenesis(t *testing.T) { encCfg := MakeTestEncodingConfig() db := dbm.NewMemDB() logger, _ := log.NewDefaultLogger("plain", "info", false) + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[server.FlagInvCheckPeriod] = 0 + appOptions[flags.FlagHome] = DefaultNodeHome + app := NewSimappWithCustomOptions(t, false, SetupOptions{ - Logger: logger, - DB: db, - InvCheckPeriod: 0, - EncConfig: encCfg, - AppOpts: simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), + Logger: logger, + DB: db, + EncConfig: encCfg, + AppOpts: appOptions, }) // make sure the upgrade keeper has version map in state diff --git a/simapp/sim_bench_test.go b/simapp/sim_bench_test.go index 9536a9699d17..6609bb94619d 100644 --- a/simapp/sim_bench_test.go +++ b/simapp/sim_bench_test.go @@ -2,6 +2,8 @@ package simapp import ( "fmt" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/server" "os" "testing" @@ -31,7 +33,11 @@ func BenchmarkFullAppSimulation(b *testing.B) { require.NoError(b, os.RemoveAll(dir)) }() - app := NewSimApp(logger, db, nil, true, FlagPeriodValue, MakeTestEncodingConfig(), simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), interBlockCacheOpt()) + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[flags.FlagHome] = DefaultNodeHome + appOptions[server.FlagInvCheckPeriod] = FlagPeriodValue + + app := NewSimApp(logger, db, nil, true, MakeTestEncodingConfig(), appOptions, interBlockCacheOpt()) // run randomized simulation _, simParams, simErr := simulation.SimulateFromSeed( @@ -78,7 +84,11 @@ func BenchmarkInvariants(b *testing.B) { require.NoError(b, os.RemoveAll(dir)) }() - app := NewSimApp(logger, db, nil, true, FlagPeriodValue, MakeTestEncodingConfig(), simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), interBlockCacheOpt()) + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[flags.FlagHome] = DefaultNodeHome + appOptions[server.FlagInvCheckPeriod] = FlagPeriodValue + + app := NewSimApp(logger, db, nil, true, MakeTestEncodingConfig(), appOptions, interBlockCacheOpt()) // run randomized simulation _, simParams, simErr := simulation.SimulateFromSeed( diff --git a/simapp/sim_test.go b/simapp/sim_test.go index d50a6b0df4d3..1e4938198d3a 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -3,6 +3,8 @@ package simapp import ( "encoding/json" "fmt" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/server" "math/rand" "os" "runtime/debug" @@ -71,7 +73,11 @@ func TestFullAppSimulation(t *testing.T) { require.NoError(t, os.RemoveAll(dir)) }() - app := NewSimApp(logger, db, nil, true, FlagPeriodValue, MakeTestEncodingConfig(), simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), fauxMerkleModeOpt) + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[flags.FlagHome] = DefaultNodeHome + appOptions[server.FlagInvCheckPeriod] = FlagPeriodValue + + app := NewSimApp(logger, db, nil, true, MakeTestEncodingConfig(), appOptions, fauxMerkleModeOpt) require.Equal(t, "SimApp", app.Name()) // run randomized simulation @@ -109,7 +115,11 @@ func TestAppImportExport(t *testing.T) { require.NoError(t, os.RemoveAll(dir)) }() - app := NewSimApp(logger, db, nil, true, FlagPeriodValue, MakeTestEncodingConfig(), simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), fauxMerkleModeOpt) + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[flags.FlagHome] = DefaultNodeHome + appOptions[server.FlagInvCheckPeriod] = FlagPeriodValue + + app := NewSimApp(logger, db, nil, true, MakeTestEncodingConfig(), appOptions, fauxMerkleModeOpt) require.Equal(t, "SimApp", app.Name()) // Run randomized simulation @@ -149,7 +159,11 @@ func TestAppImportExport(t *testing.T) { require.NoError(t, os.RemoveAll(newDir)) }() - newApp := NewSimApp(log.NewNopLogger(), newDB, nil, true, FlagPeriodValue, MakeTestEncodingConfig(), simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), fauxMerkleModeOpt) + appOptions = make(simtestutil.AppOptionsMap, 0) + appOptions[flags.FlagHome] = DefaultNodeHome + appOptions[server.FlagInvCheckPeriod] = FlagPeriodValue + + newApp := NewSimApp(log.NewNopLogger(), newDB, nil, true, MakeTestEncodingConfig(), appOptions, fauxMerkleModeOpt) require.Equal(t, "SimApp", newApp.Name()) var genesisState GenesisState @@ -218,7 +232,11 @@ func TestAppSimulationAfterImport(t *testing.T) { require.NoError(t, os.RemoveAll(dir)) }() - app := NewSimApp(logger, db, nil, true, FlagPeriodValue, MakeTestEncodingConfig(), simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), fauxMerkleModeOpt) + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[flags.FlagHome] = DefaultNodeHome + appOptions[server.FlagInvCheckPeriod] = FlagPeriodValue + + app := NewSimApp(logger, db, nil, true, MakeTestEncodingConfig(), appOptions, fauxMerkleModeOpt) require.Equal(t, "SimApp", app.Name()) // Run randomized simulation @@ -263,7 +281,7 @@ func TestAppSimulationAfterImport(t *testing.T) { require.NoError(t, os.RemoveAll(newDir)) }() - newApp := NewSimApp(log.NewNopLogger(), newDB, nil, true, FlagPeriodValue, MakeTestEncodingConfig(), simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), fauxMerkleModeOpt) + newApp := NewSimApp(log.NewNopLogger(), newDB, nil, true, MakeTestEncodingConfig(), appOptions, fauxMerkleModeOpt) require.Equal(t, "SimApp", newApp.Name()) newApp.InitChain(abci.RequestInitChain{ @@ -314,7 +332,12 @@ func TestAppStateDeterminism(t *testing.T) { } db := dbm.NewMemDB() - app := NewSimApp(logger, db, nil, true, FlagPeriodValue, MakeTestEncodingConfig(), simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), interBlockCacheOpt()) + + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[flags.FlagHome] = DefaultNodeHome + appOptions[server.FlagInvCheckPeriod] = FlagPeriodValue + + app := NewSimApp(logger, db, nil, true, MakeTestEncodingConfig(), appOptions, interBlockCacheOpt()) fmt.Printf( "running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n", diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index af91a0437778..0a7f430a37f7 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -2,6 +2,7 @@ package cmd import ( "errors" + "github.com/spf13/viper" "io" "os" "path/filepath" @@ -278,7 +279,6 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a return simapp.NewSimApp( logger, db, traceStore, true, - cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), a.encCfg, appOpts, baseapp.SetPruning(pruningOpts), @@ -307,14 +307,23 @@ func (a appCreator) appExport( return servertypes.ExportedApp{}, errors.New("application home not set") } + viperAppOpts, ok := appOpts.(*viper.Viper) + if !ok { + return servertypes.ExportedApp{}, errors.New("appOpts is not viper.Viper") + } + + // overwrite the FlagInvCheckPeriod + viperAppOpts.Set(server.FlagInvCheckPeriod, 1) + appOpts = viperAppOpts + if height != -1 { - simApp = simapp.NewSimApp(logger, db, traceStore, false, uint(1), a.encCfg, appOpts) + simApp = simapp.NewSimApp(logger, db, traceStore, false, a.encCfg, appOpts) if err := simApp.LoadHeight(height); err != nil { return servertypes.ExportedApp{}, err } } else { - simApp = simapp.NewSimApp(logger, db, traceStore, true, uint(1), a.encCfg, appOpts) + simApp = simapp.NewSimApp(logger, db, traceStore, true, a.encCfg, appOpts) } return simApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs) diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 7a587b56e599..3fa2e41ff0dc 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -3,6 +3,8 @@ package simapp import ( "context" "encoding/json" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/server" "testing" "github.com/stretchr/testify/require" @@ -42,7 +44,11 @@ type SetupOptions struct { func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) { db := dbm.NewMemDB() encCdc := MakeTestEncodingConfig() - app := NewSimApp(log.NewNopLogger(), db, nil, true, invCheckPeriod, encCdc, simtestutil.NewAppOptionsWithFlagHomeAndInvalidCheckPeriod(DefaultNodeHome, invCheckPeriod)) + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[flags.FlagHome] = DefaultNodeHome + appOptions[server.FlagInvCheckPeriod] = invCheckPeriod + + app := NewSimApp(log.NewNopLogger(), db, nil, true, encCdc, appOptions) if withGenesis { return app, NewDefaultGenesisState(encCdc.Codec) } @@ -68,7 +74,7 @@ func NewSimappWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOptio Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), } - app := NewSimApp(options.Logger, options.DB, nil, true, options.InvCheckPeriod, options.EncConfig, options.AppOpts) + app := NewSimApp(options.Logger, options.DB, nil, true, options.EncConfig, options.AppOpts) genesisState := NewDefaultGenesisState(app.appCodec) genesisState, err = simtestutil.GenesisStateWithValSet(app.AppCodec(), genesisState, valSet, []authtypes.GenesisAccount{acc}, balance) require.NoError(t, err) diff --git a/testutil/network/network.go b/testutil/network/network.go index bc39a4118b82..fb81841322d3 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -6,6 +6,7 @@ import ( "encoding/json" "errors" "fmt" + "github.com/cosmos/cosmos-sdk/client/flags" "net/http" "net/url" "os" @@ -62,10 +63,14 @@ type AppConstructor = func(val Validator) servertypes.Application // NewAppConstructor returns a new simapp AppConstructor func NewAppConstructor(encodingCfg params.EncodingConfig) AppConstructor { return func(val Validator) servertypes.Application { + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[flags.FlagHome] = val.Ctx.Config.RootDir + appOptions[server.FlagInvCheckPeriod] = 0 + return simapp.NewSimApp( - val.Ctx.Logger, dbm.NewMemDB(), nil, true, 0, + val.Ctx.Logger, dbm.NewMemDB(), nil, true, encodingCfg, - simtestutil.NewAppOptionsWithFlagHome(val.Ctx.Config.RootDir), + appOptions, baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices), ) diff --git a/testutil/sims/app_helpers.go b/testutil/sims/app_helpers.go index c5cde34e9594..61a5d5211924 100644 --- a/testutil/sims/app_helpers.go +++ b/testutil/sims/app_helpers.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "github.com/cosmos/cosmos-sdk/server" "time" abci "github.com/tendermint/tendermint/abci/types" @@ -244,10 +243,3 @@ func NewAppOptionsWithFlagHome(homePath string) servertypes.AppOptions { flags.FlagHome: homePath, } } - -func NewAppOptionsWithFlagHomeAndInvalidCheckPeriod(homePath string, invalidCheckPeriod uint) servertypes.AppOptions { - return AppOptionsMap{ - flags.FlagHome: homePath, - server.FlagInvCheckPeriod: invalidCheckPeriod, - } -} diff --git a/x/auth/module_test.go b/x/auth/module_test.go index 84d16cd54762..0658c01999f2 100644 --- a/x/auth/module_test.go +++ b/x/auth/module_test.go @@ -1,6 +1,8 @@ package auth_test import ( + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/server" "testing" "github.com/stretchr/testify/require" @@ -18,7 +20,11 @@ import ( func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { db := dbm.NewMemDB() encCdc := simapp.MakeTestEncodingConfig() - app := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, 5, encCdc, simtestutil.NewAppOptionsWithFlagHome(simapp.DefaultNodeHome)) + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[flags.FlagHome] = simapp.DefaultNodeHome + appOptions[server.FlagInvCheckPeriod] = 5 + + app := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, encCdc, appOptions) genesisState := simapp.GenesisStateWithSingleValidator(t, app) stateBytes, err := tmjson.Marshal(genesisState) diff --git a/x/gov/genesis_test.go b/x/gov/genesis_test.go index 82f8e9c4aacd..4a775419d174 100644 --- a/x/gov/genesis_test.go +++ b/x/gov/genesis_test.go @@ -2,6 +2,8 @@ package gov_test import ( "encoding/json" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/server" "testing" "github.com/stretchr/testify/require" @@ -74,7 +76,11 @@ func TestImportExportQueues(t *testing.T) { } db := dbm.NewMemDB() - app2 := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, 0, simapp.MakeTestEncodingConfig(), simtestutil.NewAppOptionsWithFlagHome(simapp.DefaultNodeHome)) + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[flags.FlagHome] = simapp.DefaultNodeHome + appOptions[server.FlagInvCheckPeriod] = 0 + + app2 := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, simapp.MakeTestEncodingConfig(), appOptions) app2.InitChain( abci.RequestInitChain{ diff --git a/x/gov/module_test.go b/x/gov/module_test.go index 761cd712878b..d9de097cc72e 100644 --- a/x/gov/module_test.go +++ b/x/gov/module_test.go @@ -1,6 +1,8 @@ package gov_test import ( + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/server" "testing" "github.com/stretchr/testify/require" @@ -19,7 +21,11 @@ import ( func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { db := dbm.NewMemDB() encCdc := simapp.MakeTestEncodingConfig() - app := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, 5, encCdc, simtestutil.NewAppOptionsWithFlagHome(simapp.DefaultNodeHome)) + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[flags.FlagHome] = simapp.DefaultNodeHome + appOptions[server.FlagInvCheckPeriod] = 5 + + app := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, encCdc, appOptions) genesisState := simapp.GenesisStateWithSingleValidator(t, app) stateBytes, err := tmjson.Marshal(genesisState) diff --git a/x/staking/module_test.go b/x/staking/module_test.go index 5fe1d917f4fb..f3a9fced99bd 100644 --- a/x/staking/module_test.go +++ b/x/staking/module_test.go @@ -1,6 +1,8 @@ package staking_test import ( + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/server" "testing" "github.com/stretchr/testify/require" @@ -19,7 +21,11 @@ import ( func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { db := dbm.NewMemDB() encCdc := simapp.MakeTestEncodingConfig() - app := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, 5, encCdc, simtestutil.NewAppOptionsWithFlagHome(simapp.DefaultNodeHome)) + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[flags.FlagHome] = simapp.DefaultNodeHome + appOptions[server.FlagInvCheckPeriod] = 5 + + app := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, encCdc, appOptions) genesisState := simapp.GenesisStateWithSingleValidator(t, app) stateBytes, err := tmjson.Marshal(genesisState) From cf525d3159e804603f2f0ee0fe0fada6e360bc11 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Sun, 26 Jun 2022 23:56:02 -0600 Subject: [PATCH 16/36] updated proto removed config --- api/cosmos/crisis/module/v1/module.pulsar.go | 241 ++----------------- proto/cosmos/crisis/module/v1/module.proto | 7 - 2 files changed, 20 insertions(+), 228 deletions(-) diff --git a/api/cosmos/crisis/module/v1/module.pulsar.go b/api/cosmos/crisis/module/v1/module.pulsar.go index 58bcca5a916b..93e5c7555cad 100644 --- a/api/cosmos/crisis/module/v1/module.pulsar.go +++ b/api/cosmos/crisis/module/v1/module.pulsar.go @@ -14,18 +14,12 @@ import ( ) var ( - md_Module protoreflect.MessageDescriptor - fd_Module_invalid_check_period protoreflect.FieldDescriptor - fd_Module_fee_collector_name protoreflect.FieldDescriptor - fd_Module_skip_genesis_invariants protoreflect.FieldDescriptor + md_Module protoreflect.MessageDescriptor ) func init() { file_cosmos_crisis_module_v1_module_proto_init() md_Module = File_cosmos_crisis_module_v1_module_proto.Messages().ByName("Module") - fd_Module_invalid_check_period = md_Module.Fields().ByName("invalid_check_period") - fd_Module_fee_collector_name = md_Module.Fields().ByName("fee_collector_name") - fd_Module_skip_genesis_invariants = md_Module.Fields().ByName("skip_genesis_invariants") } var _ protoreflect.Message = (*fastReflection_Module)(nil) @@ -93,24 +87,6 @@ func (x *fastReflection_Module) Interface() protoreflect.ProtoMessage { // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.InvalidCheckPeriod != uint32(0) { - value := protoreflect.ValueOfUint32(x.InvalidCheckPeriod) - if !f(fd_Module_invalid_check_period, value) { - return - } - } - if x.FeeCollectorName != "" { - value := protoreflect.ValueOfString(x.FeeCollectorName) - if !f(fd_Module_fee_collector_name, value) { - return - } - } - if x.SkipGenesisInvariants != false { - value := protoreflect.ValueOfBool(x.SkipGenesisInvariants) - if !f(fd_Module_skip_genesis_invariants, value) { - return - } - } } // Has reports whether a field is populated. @@ -126,12 +102,6 @@ func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, proto // a repeated field is populated if it is non-empty. func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "cosmos.crisis.module.v1.Module.invalid_check_period": - return x.InvalidCheckPeriod != uint32(0) - case "cosmos.crisis.module.v1.Module.fee_collector_name": - return x.FeeCollectorName != "" - case "cosmos.crisis.module.v1.Module.skip_genesis_invariants": - return x.SkipGenesisInvariants != false default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crisis.module.v1.Module")) @@ -148,12 +118,6 @@ func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool { // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "cosmos.crisis.module.v1.Module.invalid_check_period": - x.InvalidCheckPeriod = uint32(0) - case "cosmos.crisis.module.v1.Module.fee_collector_name": - x.FeeCollectorName = "" - case "cosmos.crisis.module.v1.Module.skip_genesis_invariants": - x.SkipGenesisInvariants = false default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crisis.module.v1.Module")) @@ -170,15 +134,6 @@ func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) { // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "cosmos.crisis.module.v1.Module.invalid_check_period": - value := x.InvalidCheckPeriod - return protoreflect.ValueOfUint32(value) - case "cosmos.crisis.module.v1.Module.fee_collector_name": - value := x.FeeCollectorName - return protoreflect.ValueOfString(value) - case "cosmos.crisis.module.v1.Module.skip_genesis_invariants": - value := x.SkipGenesisInvariants - return protoreflect.ValueOfBool(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crisis.module.v1.Module")) @@ -199,12 +154,6 @@ func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) pro // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "cosmos.crisis.module.v1.Module.invalid_check_period": - x.InvalidCheckPeriod = uint32(value.Uint()) - case "cosmos.crisis.module.v1.Module.fee_collector_name": - x.FeeCollectorName = value.Interface().(string) - case "cosmos.crisis.module.v1.Module.skip_genesis_invariants": - x.SkipGenesisInvariants = value.Bool() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crisis.module.v1.Module")) @@ -225,12 +174,6 @@ func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value proto // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "cosmos.crisis.module.v1.Module.invalid_check_period": - panic(fmt.Errorf("field invalid_check_period of message cosmos.crisis.module.v1.Module is not mutable")) - case "cosmos.crisis.module.v1.Module.fee_collector_name": - panic(fmt.Errorf("field fee_collector_name of message cosmos.crisis.module.v1.Module is not mutable")) - case "cosmos.crisis.module.v1.Module.skip_genesis_invariants": - panic(fmt.Errorf("field skip_genesis_invariants of message cosmos.crisis.module.v1.Module is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crisis.module.v1.Module")) @@ -244,12 +187,6 @@ func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protore // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "cosmos.crisis.module.v1.Module.invalid_check_period": - return protoreflect.ValueOfUint32(uint32(0)) - case "cosmos.crisis.module.v1.Module.fee_collector_name": - return protoreflect.ValueOfString("") - case "cosmos.crisis.module.v1.Module.skip_genesis_invariants": - return protoreflect.ValueOfBool(false) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crisis.module.v1.Module")) @@ -319,16 +256,6 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { var n int var l int _ = l - if x.InvalidCheckPeriod != 0 { - n += 1 + runtime.Sov(uint64(x.InvalidCheckPeriod)) - } - l = len(x.FeeCollectorName) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(l)) - } - if x.SkipGenesisInvariants { - n += 2 - } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -358,28 +285,6 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if x.SkipGenesisInvariants { - i-- - if x.SkipGenesisInvariants { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x18 - } - if len(x.FeeCollectorName) > 0 { - i -= len(x.FeeCollectorName) - copy(dAtA[i:], x.FeeCollectorName) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.FeeCollectorName))) - i-- - dAtA[i] = 0x12 - } - if x.InvalidCheckPeriod != 0 { - i = runtime.EncodeVarint(dAtA, i, uint64(x.InvalidCheckPeriod)) - i-- - dAtA[i] = 0x8 - } if input.Buf != nil { input.Buf = append(input.Buf, dAtA...) } else { @@ -429,77 +334,6 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Module: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field InvalidCheckPeriod", wireType) - } - x.InvalidCheckPeriod = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - x.InvalidCheckPeriod |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field FeeCollectorName", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - x.FeeCollectorName = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SkipGenesisInvariants", wireType) - } - var v 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++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - x.SkipGenesisInvariants = bool(v != 0) default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -553,11 +387,6 @@ type Module struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - - // Invalid Check Period - InvalidCheckPeriod uint32 `protobuf:"varint,1,opt,name=invalid_check_period,json=invalidCheckPeriod,proto3" json:"invalid_check_period,omitempty"` - FeeCollectorName string `protobuf:"bytes,2,opt,name=fee_collector_name,json=feeCollectorName,proto3" json:"fee_collector_name,omitempty"` - SkipGenesisInvariants bool `protobuf:"varint,3,opt,name=skip_genesis_invariants,json=skipGenesisInvariants,proto3" json:"skip_genesis_invariants,omitempty"` } func (x *Module) Reset() { @@ -580,27 +409,6 @@ func (*Module) Descriptor() ([]byte, []int) { return file_cosmos_crisis_module_v1_module_proto_rawDescGZIP(), []int{0} } -func (x *Module) GetInvalidCheckPeriod() uint32 { - if x != nil { - return x.InvalidCheckPeriod - } - return 0 -} - -func (x *Module) GetFeeCollectorName() string { - if x != nil { - return x.FeeCollectorName - } - return "" -} - -func (x *Module) GetSkipGenesisInvariants() bool { - if x != nil { - return x.SkipGenesisInvariants - } - return false -} - var File_cosmos_crisis_module_v1_module_proto protoreflect.FileDescriptor var file_cosmos_crisis_module_v1_module_proto_rawDesc = []byte{ @@ -610,34 +418,25 @@ var file_cosmos_crisis_module_v1_module_proto_rawDesc = []byte{ 0x72, 0x69, 0x73, 0x69, 0x73, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x22, 0xcf, 0x01, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x30, 0x0a, 0x14, - 0x69, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x70, 0x65, - 0x72, 0x69, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x12, 0x69, 0x6e, 0x76, 0x61, - 0x6c, 0x69, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x12, 0x2c, - 0x0a, 0x12, 0x66, 0x65, 0x65, 0x5f, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x5f, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x66, 0x65, 0x65, 0x43, - 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x36, 0x0a, 0x17, - 0x73, 0x6b, 0x69, 0x70, 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x69, 0x6e, 0x76, - 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, 0x73, - 0x6b, 0x69, 0x70, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x49, 0x6e, 0x76, 0x61, 0x72, 0x69, - 0x61, 0x6e, 0x74, 0x73, 0x3a, 0x2d, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x27, 0x0a, 0x25, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x78, 0x2f, 0x63, 0x72, 0x69, - 0x73, 0x69, 0x73, 0x42, 0xdc, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x69, 0x73, 0x69, 0x73, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, - 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x50, 0x01, 0x5a, 0x31, 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, 0x72, 0x69, 0x73, - 0x69, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f, 0x64, - 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x43, 0x4d, 0xaa, 0x02, 0x17, 0x43, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x43, 0x72, 0x69, 0x73, 0x69, 0x73, 0x2e, 0x4d, 0x6f, 0x64, 0x75, - 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, - 0x72, 0x69, 0x73, 0x69, 0x73, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, - 0x02, 0x23, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x72, 0x69, 0x73, 0x69, 0x73, 0x5c, - 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1a, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, - 0x43, 0x72, 0x69, 0x73, 0x69, 0x73, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x3a, - 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x22, 0x37, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x2d, 0xba, 0xc0, 0x96, + 0xda, 0x01, 0x27, 0x0a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, + 0x6b, 0x2f, 0x78, 0x2f, 0x63, 0x72, 0x69, 0x73, 0x69, 0x73, 0x42, 0xdc, 0x01, 0x0a, 0x1b, 0x63, + 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x69, 0x73, 0x69, 0x73, + 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, + 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x31, 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, 0x72, 0x69, 0x73, 0x69, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, + 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, + 0x43, 0x4d, 0xaa, 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x43, 0x72, 0x69, 0x73, + 0x69, 0x73, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x17, 0x43, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x72, 0x69, 0x73, 0x69, 0x73, 0x5c, 0x4d, 0x6f, 0x64, + 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x23, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, + 0x43, 0x72, 0x69, 0x73, 0x69, 0x73, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, + 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1a, 0x43, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x43, 0x72, 0x69, 0x73, 0x69, 0x73, 0x3a, 0x3a, 0x4d, + 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/proto/cosmos/crisis/module/v1/module.proto b/proto/cosmos/crisis/module/v1/module.proto index d594a9edf173..c23ddcf8b9f5 100644 --- a/proto/cosmos/crisis/module/v1/module.proto +++ b/proto/cosmos/crisis/module/v1/module.proto @@ -9,11 +9,4 @@ message Module { option (cosmos.app.v1alpha1.module) = { go_import: "github.com/cosmos/cosmos-sdk/x/crisis" }; - - // Invalid Check Period - uint32 invalid_check_period = 1; - - string fee_collector_name = 2; - - bool skip_genesis_invariants = 3; } From aeb92e77b311a5aa4d9be6b7bf403d5eb0f9c0f6 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Mon, 27 Jun 2022 11:51:28 -0600 Subject: [PATCH 17/36] added free collector name to config --- api/cosmos/crisis/module/v1/module.pulsar.go | 115 +++++++++++++++---- x/crisis/module.go | 7 +- 2 files changed, 100 insertions(+), 22 deletions(-) diff --git a/api/cosmos/crisis/module/v1/module.pulsar.go b/api/cosmos/crisis/module/v1/module.pulsar.go index 93e5c7555cad..f5a0eee0d22f 100644 --- a/api/cosmos/crisis/module/v1/module.pulsar.go +++ b/api/cosmos/crisis/module/v1/module.pulsar.go @@ -14,12 +14,14 @@ import ( ) var ( - md_Module protoreflect.MessageDescriptor + md_Module protoreflect.MessageDescriptor + fd_Module_fee_collector_name protoreflect.FieldDescriptor ) func init() { file_cosmos_crisis_module_v1_module_proto_init() md_Module = File_cosmos_crisis_module_v1_module_proto.Messages().ByName("Module") + fd_Module_fee_collector_name = md_Module.Fields().ByName("fee_collector_name") } var _ protoreflect.Message = (*fastReflection_Module)(nil) @@ -87,6 +89,12 @@ func (x *fastReflection_Module) Interface() protoreflect.ProtoMessage { // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.FeeCollectorName != "" { + value := protoreflect.ValueOfString(x.FeeCollectorName) + if !f(fd_Module_fee_collector_name, value) { + return + } + } } // Has reports whether a field is populated. @@ -102,6 +110,8 @@ func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, proto // a repeated field is populated if it is non-empty. func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { + case "cosmos.crisis.module.v1.Module.fee_collector_name": + return x.FeeCollectorName != "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crisis.module.v1.Module")) @@ -118,6 +128,8 @@ func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool { // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { + case "cosmos.crisis.module.v1.Module.fee_collector_name": + x.FeeCollectorName = "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crisis.module.v1.Module")) @@ -134,6 +146,9 @@ func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) { // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { + case "cosmos.crisis.module.v1.Module.fee_collector_name": + value := x.FeeCollectorName + return protoreflect.ValueOfString(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crisis.module.v1.Module")) @@ -154,6 +169,8 @@ func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) pro // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { + case "cosmos.crisis.module.v1.Module.fee_collector_name": + x.FeeCollectorName = value.Interface().(string) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crisis.module.v1.Module")) @@ -174,6 +191,8 @@ func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value proto // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "cosmos.crisis.module.v1.Module.fee_collector_name": + panic(fmt.Errorf("field fee_collector_name of message cosmos.crisis.module.v1.Module is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crisis.module.v1.Module")) @@ -187,6 +206,8 @@ func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protore // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "cosmos.crisis.module.v1.Module.fee_collector_name": + return protoreflect.ValueOfString("") default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crisis.module.v1.Module")) @@ -256,6 +277,10 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { var n int var l int _ = l + l = len(x.FeeCollectorName) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -285,6 +310,13 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if len(x.FeeCollectorName) > 0 { + i -= len(x.FeeCollectorName) + copy(dAtA[i:], x.FeeCollectorName) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.FeeCollectorName))) + i-- + dAtA[i] = 0xa + } if input.Buf != nil { input.Buf = append(input.Buf, dAtA...) } else { @@ -334,6 +366,38 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Module: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field FeeCollectorName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.FeeCollectorName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -387,6 +451,8 @@ type Module struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + FeeCollectorName string `protobuf:"bytes,1,opt,name=fee_collector_name,json=feeCollectorName,proto3" json:"fee_collector_name,omitempty"` } func (x *Module) Reset() { @@ -409,6 +475,13 @@ func (*Module) Descriptor() ([]byte, []int) { return file_cosmos_crisis_module_v1_module_proto_rawDescGZIP(), []int{0} } +func (x *Module) GetFeeCollectorName() string { + if x != nil { + return x.FeeCollectorName + } + return "" +} + var File_cosmos_crisis_module_v1_module_proto protoreflect.FileDescriptor var file_cosmos_crisis_module_v1_module_proto_rawDesc = []byte{ @@ -418,25 +491,27 @@ var file_cosmos_crisis_module_v1_module_proto_rawDesc = []byte{ 0x72, 0x69, 0x73, 0x69, 0x73, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x22, 0x37, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x2d, 0xba, 0xc0, 0x96, - 0xda, 0x01, 0x27, 0x0a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, - 0x6b, 0x2f, 0x78, 0x2f, 0x63, 0x72, 0x69, 0x73, 0x69, 0x73, 0x42, 0xdc, 0x01, 0x0a, 0x1b, 0x63, - 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x69, 0x73, 0x69, 0x73, - 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, - 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x31, 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, 0x72, 0x69, 0x73, 0x69, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, - 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, - 0x43, 0x4d, 0xaa, 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x43, 0x72, 0x69, 0x73, - 0x69, 0x73, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x17, 0x43, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x72, 0x69, 0x73, 0x69, 0x73, 0x5c, 0x4d, 0x6f, 0x64, - 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x23, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, - 0x43, 0x72, 0x69, 0x73, 0x69, 0x73, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, - 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1a, 0x43, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x43, 0x72, 0x69, 0x73, 0x69, 0x73, 0x3a, 0x3a, 0x4d, - 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x6f, 0x22, 0x65, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x2c, 0x0a, 0x12, 0x66, + 0x65, 0x65, 0x5f, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x66, 0x65, 0x65, 0x43, 0x6f, 0x6c, 0x6c, + 0x65, 0x63, 0x74, 0x6f, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x3a, 0x2d, 0xba, 0xc0, 0x96, 0xda, 0x01, + 0x27, 0x0a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, + 0x78, 0x2f, 0x63, 0x72, 0x69, 0x73, 0x69, 0x73, 0x42, 0xdc, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, + 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x69, 0x73, 0x69, 0x73, 0x2e, 0x6d, + 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x31, 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, 0x72, 0x69, 0x73, 0x69, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, + 0x31, 0x3b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x43, 0x4d, + 0xaa, 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x43, 0x72, 0x69, 0x73, 0x69, 0x73, + 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x17, 0x43, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x72, 0x69, 0x73, 0x69, 0x73, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, + 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x23, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x72, + 0x69, 0x73, 0x69, 0x73, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1a, 0x43, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x43, 0x72, 0x69, 0x73, 0x69, 0x73, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, + 0x75, 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/x/crisis/module.go b/x/crisis/module.go index 67e0ec85e510..8f214181d2a3 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -207,12 +207,15 @@ func provideModuleBasic() runtime.AppModuleBasicWrapper { func provideModule(in crisisInputs) crisisOutputs { invalidCheckPeriod := cast.ToUint(in.AppOpts.Get(server.FlagInvCheckPeriod)) - + feeCollectorName := in.Config.FeeCollectorName + if feeCollectorName == "" { + feeCollectorName = authtypes.FeeCollectorName + } k := keeper.NewKeeper( in.Subspace, invalidCheckPeriod, in.BankKeeper, - authtypes.FeeCollectorName, + feeCollectorName, ) skipGenesisInvariants := cast.ToBool(in.AppOpts.Get(FlagSkipGenesisInvariants)) From 22995aadb475e38342d0f5e7b6a13dc138339868 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Mon, 27 Jun 2022 13:30:30 -0600 Subject: [PATCH 18/36] register invariants --- simapp/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simapp/app.go b/simapp/app.go index f3187108d40b..9f71932c98c9 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -310,7 +310,7 @@ func NewSimApp( // Uncomment if you want to set a custom migration order here. // app.ModuleManager.SetOrderMigrations(custom order) - //app.ModuleManager.RegisterInvariants(&app.CrisisKeeper) + app.ModuleManager.RegisterInvariants(&app.CrisisKeeper) app.ModuleManager.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) // RegisterUpgradeHandlers is used for registering any on-chain upgrades. From b27cec582f985bf87f2560ed2583c4daf6e5621e Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Mon, 27 Jun 2022 15:41:15 -0600 Subject: [PATCH 19/36] add proto --- proto/cosmos/crisis/module/v1/module.proto | 2 ++ 1 file changed, 2 insertions(+) diff --git a/proto/cosmos/crisis/module/v1/module.proto b/proto/cosmos/crisis/module/v1/module.proto index c23ddcf8b9f5..191d3b845572 100644 --- a/proto/cosmos/crisis/module/v1/module.proto +++ b/proto/cosmos/crisis/module/v1/module.proto @@ -9,4 +9,6 @@ message Module { option (cosmos.app.v1alpha1.module) = { go_import: "github.com/cosmos/cosmos-sdk/x/crisis" }; + + string fee_collector_name = 1; } From d59ff9bc907ea4c45707aecb3b17ea9e75ba61aa Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Tue, 28 Jun 2022 12:48:51 -0600 Subject: [PATCH 20/36] change keeper to pointer --- x/crisis/client/cli/tx.go | 4 +++- x/crisis/keeper/keeper.go | 18 +++++++++++------- x/crisis/module.go | 5 +++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/x/crisis/client/cli/tx.go b/x/crisis/client/cli/tx.go index 50b7e16a34b8..8a8ac86645c4 100644 --- a/x/crisis/client/cli/tx.go +++ b/x/crisis/client/cli/tx.go @@ -2,6 +2,7 @@ package cli import ( "errors" + "fmt" "github.com/spf13/cobra" @@ -29,6 +30,7 @@ func NewTxCmd() *cobra.Command { // NewMsgVerifyInvariantTxCmd returns a CLI command handler for creating a // MsgVerifyInvariant transaction. func NewMsgVerifyInvariantTxCmd() *cobra.Command { + fmt.Println("Command Called") cmd := &cobra.Command{ Use: "invariant-broken [module-name] [invariant-route]", Short: "Submit proof that an invariant broken to halt the chain", @@ -49,7 +51,7 @@ func NewMsgVerifyInvariantTxCmd() *cobra.Command { senderAddr := clientCtx.GetFromAddress() msg := types.NewMsgVerifyInvariant(senderAddr, moduleName, route) - + fmt.Println("msg", msg) return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, } diff --git a/x/crisis/keeper/keeper.go b/x/crisis/keeper/keeper.go index 8dcf447c60e0..ecd6c832efcc 100644 --- a/x/crisis/keeper/keeper.go +++ b/x/crisis/keeper/keeper.go @@ -26,13 +26,13 @@ type Keeper struct { func NewKeeper( paramSpace paramtypes.Subspace, invCheckPeriod uint, supplyKeeper types.SupplyKeeper, feeCollectorName string, -) Keeper { +) *Keeper { // set KeyTable if it has not already been set if !paramSpace.HasKeyTable() { paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) } - return Keeper{ + return &Keeper{ routes: make([]types.InvarRoute, 0), paramSpace: paramSpace, invCheckPeriod: invCheckPeriod, @@ -48,17 +48,21 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // RegisterRoute register the routes for each of the invariants func (k *Keeper) RegisterRoute(moduleName, route string, invar sdk.Invariant) { + fmt.Println("-----Register Route for crisis on invariants") + fmt.Println(moduleName, route) + fmt.Println("-----Register Route for crisis on invariants") + invarRoute := types.NewInvarRoute(moduleName, route, invar) k.routes = append(k.routes, invarRoute) } // Routes - return the keeper's invariant routes -func (k Keeper) Routes() []types.InvarRoute { +func (k *Keeper) Routes() []types.InvarRoute { return k.routes } // Invariants returns a copy of all registered Crisis keeper invariants. -func (k Keeper) Invariants() []sdk.Invariant { +func (k *Keeper) Invariants() []sdk.Invariant { invars := make([]sdk.Invariant, len(k.routes)) for i, route := range k.routes { invars[i] = route.Invar @@ -68,7 +72,7 @@ func (k Keeper) Invariants() []sdk.Invariant { // AssertInvariants asserts all registered invariants. If any invariant fails, // the method panics. -func (k Keeper) AssertInvariants(ctx sdk.Context) { +func (k *Keeper) AssertInvariants(ctx sdk.Context) { logger := k.Logger(ctx) start := time.Now() @@ -90,9 +94,9 @@ func (k Keeper) AssertInvariants(ctx sdk.Context) { } // InvCheckPeriod returns the invariant checks period. -func (k Keeper) InvCheckPeriod() uint { return k.invCheckPeriod } +func (k *Keeper) InvCheckPeriod() uint { return k.invCheckPeriod } // SendCoinsFromAccountToFeeCollector transfers amt to the fee collector account. -func (k Keeper) SendCoinsFromAccountToFeeCollector(ctx sdk.Context, senderAddr sdk.AccAddress, amt sdk.Coins) error { +func (k *Keeper) SendCoinsFromAccountToFeeCollector(ctx sdk.Context, senderAddr sdk.AccAddress, amt sdk.Coins) error { return k.supplyKeeper.SendCoinsFromAccountToModule(ctx, senderAddr, k.feeCollectorName, amt) } diff --git a/x/crisis/module.go b/x/crisis/module.go index 8f214181d2a3..d33013246e32 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -211,6 +211,7 @@ func provideModule(in crisisInputs) crisisOutputs { if feeCollectorName == "" { feeCollectorName = authtypes.FeeCollectorName } + k := keeper.NewKeeper( in.Subspace, invalidCheckPeriod, @@ -219,6 +220,6 @@ func provideModule(in crisisInputs) crisisOutputs { ) skipGenesisInvariants := cast.ToBool(in.AppOpts.Get(FlagSkipGenesisInvariants)) - m := NewAppModule(&k, skipGenesisInvariants) - return crisisOutputs{CrisisKeeper: k, Module: runtime.WrapAppModule(m)} + m := NewAppModule(k, skipGenesisInvariants) + return crisisOutputs{CrisisKeeper: *k, Module: runtime.WrapAppModule(m)} } From 0c09cdeee1d048956ea1b0968533546af3057528 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Tue, 28 Jun 2022 12:49:07 -0600 Subject: [PATCH 21/36] change keeper to pointer --- simapp/app.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index 9f71932c98c9..6a6982e7ff0f 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -169,7 +169,7 @@ type SimApp struct { MintKeeper mintkeeper.Keeper DistrKeeper distrkeeper.Keeper GovKeeper govkeeper.Keeper - CrisisKeeper crisiskeeper.Keeper + CrisisKeeper *crisiskeeper.Keeper UpgradeKeeper upgradekeeper.Keeper ParamsKeeper paramskeeper.Keeper AuthzKeeper authzkeeper.Keeper @@ -310,7 +310,7 @@ func NewSimApp( // Uncomment if you want to set a custom migration order here. // app.ModuleManager.SetOrderMigrations(custom order) - app.ModuleManager.RegisterInvariants(&app.CrisisKeeper) + app.ModuleManager.RegisterInvariants(app.CrisisKeeper) app.ModuleManager.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) // RegisterUpgradeHandlers is used for registering any on-chain upgrades. From 22b50fc6c2e285b5c6143f376934108d4e3c2955 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Tue, 28 Jun 2022 13:54:07 -0600 Subject: [PATCH 22/36] change to pointer bug --- x/crisis/module.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/crisis/module.go b/x/crisis/module.go index d33013246e32..3187529efe4d 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -197,7 +197,7 @@ type crisisInputs struct { type crisisOutputs struct { depinject.Out - CrisisKeeper keeper.Keeper `key:"cosmos.crisis.v1.Keeper"` + CrisisKeeper *keeper.Keeper `key:"cosmos.crisis.v1.Keeper"` Module runtime.AppModuleWrapper } @@ -221,5 +221,5 @@ func provideModule(in crisisInputs) crisisOutputs { skipGenesisInvariants := cast.ToBool(in.AppOpts.Get(FlagSkipGenesisInvariants)) m := NewAppModule(k, skipGenesisInvariants) - return crisisOutputs{CrisisKeeper: *k, Module: runtime.WrapAppModule(m)} + return crisisOutputs{CrisisKeeper: k, Module: runtime.WrapAppModule(m)} } From 8f88b949431e3595fd519ed2afe3e24724dd44c3 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Tue, 28 Jun 2022 13:59:53 -0600 Subject: [PATCH 23/36] remove print --- x/crisis/client/cli/tx.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/x/crisis/client/cli/tx.go b/x/crisis/client/cli/tx.go index 8a8ac86645c4..8f02801a3a4c 100644 --- a/x/crisis/client/cli/tx.go +++ b/x/crisis/client/cli/tx.go @@ -2,8 +2,6 @@ package cli import ( "errors" - "fmt" - "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" @@ -30,7 +28,6 @@ func NewTxCmd() *cobra.Command { // NewMsgVerifyInvariantTxCmd returns a CLI command handler for creating a // MsgVerifyInvariant transaction. func NewMsgVerifyInvariantTxCmd() *cobra.Command { - fmt.Println("Command Called") cmd := &cobra.Command{ Use: "invariant-broken [module-name] [invariant-route]", Short: "Submit proof that an invariant broken to halt the chain", @@ -51,7 +48,6 @@ func NewMsgVerifyInvariantTxCmd() *cobra.Command { senderAddr := clientCtx.GetFromAddress() msg := types.NewMsgVerifyInvariant(senderAddr, moduleName, route) - fmt.Println("msg", msg) return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, } From 32f7727df4358d2f2e714cb2ff79185992972983 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Tue, 28 Jun 2022 14:02:40 -0600 Subject: [PATCH 24/36] remove key and comments --- x/crisis/module.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/crisis/module.go b/x/crisis/module.go index 3187529efe4d..e8ec4ce668f1 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -191,13 +191,13 @@ type crisisInputs struct { Cdc codec.Codec Config *modulev1.Module Subspace paramstypes.Subspace - BankKeeper types.SupplyKeeper `key:"cosmos.bank.v1.Keeper"` + BankKeeper types.SupplyKeeper } type crisisOutputs struct { depinject.Out - CrisisKeeper *keeper.Keeper `key:"cosmos.crisis.v1.Keeper"` + CrisisKeeper *keeper.Keeper Module runtime.AppModuleWrapper } From 24fe0292ed2c570ed7d28b83fe695773e808b117 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Tue, 28 Jun 2022 14:03:58 -0600 Subject: [PATCH 25/36] remove key and comments --- simapp/app.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index 6a6982e7ff0f..a6bd6cc94a77 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -9,7 +9,6 @@ import ( "github.com/gorilla/mux" "github.com/rakyll/statik/fs" - //"github.com/spf13/cast" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" tmos "github.com/tendermint/tendermint/libs/os" @@ -204,8 +203,7 @@ func NewSimApp( var ( appBuilder *runtime.AppBuilder - //app = &SimApp{invCheckPeriod: invCheckPeriod} - app = &SimApp{} + app = &SimApp{} // merge the app.yaml and the appOpts in one config appConfig = depinject.Configs(AppConfig, depinject.Supply(appOpts)) @@ -247,10 +245,6 @@ func NewSimApp( initParamsKeeper(app.ParamsKeeper) - //app.CrisisKeeper = crisiskeeper.NewKeeper( - // app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, - //) - // register the proposal types govRouter := govv1beta1.NewRouter() govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). From 7633b81251f9731e19b454e4a0c22016e93e5864 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Tue, 28 Jun 2022 14:21:15 -0600 Subject: [PATCH 26/36] remove comments --- x/crisis/keeper/keeper.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/x/crisis/keeper/keeper.go b/x/crisis/keeper/keeper.go index ecd6c832efcc..dcccfcdaed92 100644 --- a/x/crisis/keeper/keeper.go +++ b/x/crisis/keeper/keeper.go @@ -48,10 +48,6 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // RegisterRoute register the routes for each of the invariants func (k *Keeper) RegisterRoute(moduleName, route string, invar sdk.Invariant) { - fmt.Println("-----Register Route for crisis on invariants") - fmt.Println(moduleName, route) - fmt.Println("-----Register Route for crisis on invariants") - invarRoute := types.NewInvarRoute(moduleName, route, invar) k.routes = append(k.routes, invarRoute) } From a097c4892a29ec064088be6866510b244f941cc9 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Tue, 28 Jun 2022 14:22:34 -0600 Subject: [PATCH 27/36] remove comments --- core/appconfig/debug_container.dot | 3 +++ simapp/app.go | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 core/appconfig/debug_container.dot diff --git a/core/appconfig/debug_container.dot b/core/appconfig/debug_container.dot new file mode 100644 index 000000000000..f246d9aba416 --- /dev/null +++ b/core/appconfig/debug_container.dot @@ -0,0 +1,3 @@ +digraph "" { +} + diff --git a/simapp/app.go b/simapp/app.go index a6bd6cc94a77..0b9fcb025636 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -263,7 +263,7 @@ func NewSimApp( app.GovKeeper = *govKeeper.SetHooks( govtypes.NewMultiGovHooks( - // register the governance hooks + // register the governance hooks ), ) @@ -272,10 +272,6 @@ func NewSimApp( // Sets the version setter for the upgrade module app.UpgradeKeeper.SetVersionSetter(app.BaseApp) - // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment - // we prefer to be more strict in what arguments the modules expect. - //skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) - // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. if err := app.RegisterModules( From 747c7a6a3ed92f1afc14058fe64518c1978bf805 Mon Sep 17 00:00:00 2001 From: Jeancarlo Barrios Date: Tue, 28 Jun 2022 16:26:19 -0600 Subject: [PATCH 28/36] Delete debug_container.dot --- core/appconfig/debug_container.dot | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 core/appconfig/debug_container.dot diff --git a/core/appconfig/debug_container.dot b/core/appconfig/debug_container.dot deleted file mode 100644 index f246d9aba416..000000000000 --- a/core/appconfig/debug_container.dot +++ /dev/null @@ -1,3 +0,0 @@ -digraph "" { -} - From ba7200fc291a380cbc2d870f7dde626e0f8cd69f Mon Sep 17 00:00:00 2001 From: Jeancarlo Barrios Date: Tue, 28 Jun 2022 16:27:01 -0600 Subject: [PATCH 29/36] Update simapp/app.go Co-authored-by: Julien Robert --- simapp/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simapp/app.go b/simapp/app.go index 63e3860c8b0d..26a19ebdafe5 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -262,7 +262,7 @@ func NewSimApp( app.GovKeeper = *govKeeper.SetHooks( govtypes.NewMultiGovHooks( - // register the governance hooks + // register the governance hooks ), ) From c3ec17432ed561ffd6fda7aed02e04b117473530 Mon Sep 17 00:00:00 2001 From: Jeancarlo Barrios Date: Tue, 28 Jun 2022 16:27:13 -0600 Subject: [PATCH 30/36] Update simapp/app.go Co-authored-by: Julien Robert --- simapp/app.go | 1 - 1 file changed, 1 deletion(-) diff --git a/simapp/app.go b/simapp/app.go index 26a19ebdafe5..e16cb3e45679 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -274,7 +274,6 @@ func NewSimApp( // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. if err := app.RegisterModules( - gov.NewAppModule(app.appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), ); err != nil { panic(err) From 8bcc2287ddf84d182666e939fa0b32a83fcec22a Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Tue, 28 Jun 2022 23:35:47 -0600 Subject: [PATCH 31/36] update docs --- docs/architecture/adr-038-state-listening.md | 4 ++-- server/README.md | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/architecture/adr-038-state-listening.md b/docs/architecture/adr-038-state-listening.md index db3c2b8ea743..936d0d59efe4 100644 --- a/docs/architecture/adr-038-state-listening.md +++ b/docs/architecture/adr-038-state-listening.md @@ -435,8 +435,8 @@ e.g. in `NewSimApp`: ```go func NewSimApp( - logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, invCheckPeriod uint, - encodingConfig simappparams.EncodingConfig, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), + logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, encodingConfig simappparams.EncodingConfig, + appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), ) *SimApp { ... diff --git a/server/README.md b/server/README.md index cc4b910631ac..36833100b72c 100644 --- a/server/README.md +++ b/server/README.md @@ -88,7 +88,6 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts server.A return simapp.NewSimApp( logger, db, traceStore, true, - cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), baseapp.SetPruning(pruningOpts), baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))), baseapp.SetHaltHeight(cast.ToUint64(appOpts.Get(server.FlagHaltHeight))), From f736ecf96bd9d201a9e73e6d58928a5b31a66534 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Tue, 28 Jun 2022 23:41:08 -0600 Subject: [PATCH 32/36] updated changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a00bc152d2a6..63d0bd735c71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### API Breaking Changes +* (simapp) [#12270](https://github.com/cosmos/cosmos-sdk/pull/12270) Remove `invCheckPeriod uint` from `NewSimApp` constructor as per migration of `x/crisis` to app wiring +* (simapp) [#12270](https://github.com/cosmos/cosmos-sdk/pull/12270) Remove `invCheckPeriod uint` attribute from `SimApp` struct as per migration of `x/crisis` to app wiring * (simapp) [#XXXXX](https://github.com/cosmos/cosmos-sdk/pull/XXXXX) Move `simapp.ConvertAddrsToValAddrs` and `simapp.CreateTestPubKeys ` to respectively `simtestutil.ConvertAddrsToValAddrs` and `simtestutil.CreateTestPubKeys` (`testutil/sims`) * (simapp) [#12312](https://github.com/cosmos/cosmos-sdk/pull/12312) Move `simapp.EmptyAppOptions` to `simtestutil.EmptyAppOptions` (`testutil/sims`) * (simapp) [#12312](https://github.com/cosmos/cosmos-sdk/pull/12312) Remove `skipUpgradeHeights map[int64]bool` and `homePath string` from `NewSimApp` constructor as per migration of `x/upgrade` to app-wiring. From 675dd40d5807d482f9054fb4cd80cdee414d63e3 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Tue, 28 Jun 2022 23:43:56 -0600 Subject: [PATCH 33/36] change order back to norma; --- simapp/app.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index e16cb3e45679..762b4c0e89d8 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -287,8 +287,8 @@ func NewSimApp( // can do so safely. genesisModuleOrder := []string{ capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, - distrtypes.ModuleName, stakingtypes.ModuleName, crisistypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, - minttypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, + distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, + minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName, nft.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, } From 1d4f9fef1040f30f30fc6fef2219bbaa5492e45c Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Tue, 28 Jun 2022 23:56:23 -0600 Subject: [PATCH 34/36] updated docs --- depinject/README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/depinject/README.md b/depinject/README.md index f4dab01bbcbe..32198b58558c 100644 --- a/depinject/README.md +++ b/depinject/README.md @@ -52,14 +52,11 @@ func NewSimApp( db dbm.DB, traceStore io.Writer, loadLatest bool, - invCheckPeriod uint, encodingConfig simappparams.EncodingConfig, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), ) *SimApp { - app := &SimApp{ - invCheckPeriod: invCheckPeriod, - } + app := &SimApp{} var ( appBuilder *runtime.AppBuilder From 969acf9e302eaa3ec1e5e34cfe67b1e0e1675292 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Wed, 29 Jun 2022 16:17:56 +0200 Subject: [PATCH 35/36] implement comments --- CHANGELOG.md | 1 - simapp/app.go | 2 +- simapp/test_helpers.go | 12 ++++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63d0bd735c71..ba28e5fa2c24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,7 +50,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### API Breaking Changes -* (simapp) [#12270](https://github.com/cosmos/cosmos-sdk/pull/12270) Remove `invCheckPeriod uint` from `NewSimApp` constructor as per migration of `x/crisis` to app wiring * (simapp) [#12270](https://github.com/cosmos/cosmos-sdk/pull/12270) Remove `invCheckPeriod uint` attribute from `SimApp` struct as per migration of `x/crisis` to app wiring * (simapp) [#XXXXX](https://github.com/cosmos/cosmos-sdk/pull/XXXXX) Move `simapp.ConvertAddrsToValAddrs` and `simapp.CreateTestPubKeys ` to respectively `simtestutil.ConvertAddrsToValAddrs` and `simtestutil.CreateTestPubKeys` (`testutil/sims`) * (simapp) [#12312](https://github.com/cosmos/cosmos-sdk/pull/12312) Move `simapp.EmptyAppOptions` to `simtestutil.EmptyAppOptions` (`testutil/sims`) diff --git a/simapp/app.go b/simapp/app.go index 762b4c0e89d8..4ba1be92afe9 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -202,7 +202,7 @@ func NewSimApp( ) *SimApp { var ( appBuilder *runtime.AppBuilder - app = &SimApp{} + app *SimApp // merge the app.yaml and the appOpts in one config appConfig = depinject.Configs(AppConfig, depinject.Supply(appOpts)) diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 3fa2e41ff0dc..9c6d94b79e9f 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -3,9 +3,10 @@ package simapp import ( "context" "encoding/json" + "testing" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server" - "testing" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" @@ -34,11 +35,10 @@ import ( // SetupOptions defines arguments that are passed into `Simapp` constructor. type SetupOptions struct { - Logger log.Logger - DB *dbm.MemDB - InvCheckPeriod uint - EncConfig params.EncodingConfig - AppOpts types.AppOptions + Logger log.Logger + DB *dbm.MemDB + EncConfig params.EncodingConfig + AppOpts types.AppOptions } func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) { From d81378e663d56d168773193db9b0acc3be1d4fe4 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Wed, 29 Jun 2022 16:36:55 +0200 Subject: [PATCH 36/36] updates --- x/auth/module_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/x/auth/module_test.go b/x/auth/module_test.go index f5c9cb572e06..8e58792f44aa 100644 --- a/x/auth/module_test.go +++ b/x/auth/module_test.go @@ -1,8 +1,6 @@ package auth_test import ( - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/server" "testing" "github.com/stretchr/testify/require"